diff --git a/.gitignore b/.gitignore index bd4666fbc..da9baf144 100644 --- a/.gitignore +++ b/.gitignore @@ -211,6 +211,7 @@ TAGS /tests/conform/test-materials /tests/conform/test-group-depth-sorting /tests/conform/test-conformance-result.xml +/tests/conform/test-fixed-size /tests/micro-bench/test-text-perf /tests/micro-bench/test-text /tests/micro-bench/test-picking diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am index cde2591bb..d8f0b6905 100644 --- a/tests/conform/Makefile.am +++ b/tests/conform/Makefile.am @@ -32,6 +32,7 @@ test_conformance_SOURCES = \ test-premult.c \ test-materials.c \ test-group.c \ + test-actor-size.c \ $(NULL) # For convenience, this provides a way to easily run individual unit tests: diff --git a/tests/conform/test-actor-size.c b/tests/conform/test-actor-size.c new file mode 100644 index 000000000..ce4e53047 --- /dev/null +++ b/tests/conform/test-actor-size.c @@ -0,0 +1,77 @@ +#include +#include + +#include + +#include "test-conform-common.h" + +void +test_fixed_size (TestConformSimpleFixture *fixture, + gconstpointer data) +{ + ClutterActor *rect; + gboolean min_width_set, nat_width_set; + gboolean min_height_set, nat_height_set; + gfloat min_width, min_height; + gfloat nat_width, nat_height; + + rect = clutter_rectangle_new (); + + if (g_test_verbose ()) + g_print ("Initial size is 0\n"); + + g_assert_cmpfloat (clutter_actor_get_width (rect), ==, 0); + g_assert_cmpfloat (clutter_actor_get_height (rect), ==, 0); + + clutter_actor_set_size (rect, 100, 100); + + if (g_test_verbose ()) + g_print ("Explicit size set\n"); + + g_assert_cmpfloat (clutter_actor_get_width (rect), ==, 100); + g_assert_cmpfloat (clutter_actor_get_height (rect), ==, 100); + + g_object_get (G_OBJECT (rect), + "min-width-set", &min_width_set, + "min-height-set", &min_height_set, + "natural-width-set", &nat_width_set, + "natural-height-set", &nat_height_set, + NULL); + + if (g_test_verbose ()) + g_print ("Notification properties\n"); + + g_assert (min_width_set && nat_width_set); + g_assert (min_height_set && nat_height_set); + + clutter_actor_get_preferred_size (rect, + &min_width, &min_height, + &nat_width, &nat_height); + + if (g_test_verbose ()) + g_print ("Preferred size\n"); + + g_assert_cmpfloat (min_width, ==, 100); + g_assert_cmpfloat (min_height, ==, 100); + g_assert_cmpfloat (min_width, ==, nat_width); + g_assert_cmpfloat (min_height, ==, nat_height); + + clutter_actor_set_size (rect, -1, -1); + + if (g_test_verbose ()) + g_print ("Explicit size unset\n"); + + g_object_get (G_OBJECT (rect), + "min-width-set", &min_width_set, + "min-height-set", &min_height_set, + "natural-width-set", &nat_width_set, + "natural-height-set", &nat_height_set, + NULL); + g_assert (!min_width_set && !nat_width_set); + g_assert (!min_height_set && !nat_height_set); + + g_assert_cmpfloat (clutter_actor_get_width (rect), ==, 0); + g_assert_cmpfloat (clutter_actor_get_height (rect), ==, 0); + + clutter_actor_destroy (rect); +} diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index 1efd432c9..a690bd6d4 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -170,5 +170,7 @@ main (int argc, char **argv) TEST_CONFORM_SIMPLE ("/group", test_group_depth_sorting); + TEST_CONFORM_SIMPLE ("/sizing", test_fixed_size); + return g_test_run (); }