From: Emmanuele Bassi Date: Mon, 14 Sep 2009 20:45:51 +0000 (+0100) Subject: [tests] Add initial sizing conformance test suite X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=092401c01b249cd3ae9e4788ecbcce91ebb80f38;p=profile%2Fivi%2Fclutter.git [tests] Add initial sizing conformance test suite The size requisition and allocation mechanisms should be thoroughly tested to avoid unwanted regressions. For starters, we can test the explicit size setting and the side effects of calling clutter_actor_set_size(). --- diff --git a/.gitignore b/.gitignore index bd4666f..da9baf1 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 cde2591..d8f0b69 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 0000000..ce4e530 --- /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 1efd432..a690bd6 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 (); }