mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
[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().
This commit is contained in:
parent
abbe2ebf8b
commit
092401c01b
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
|
||||
|
@ -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:
|
||||
|
77
tests/conform/test-actor-size.c
Normal file
77
tests/conform/test-actor-size.c
Normal file
@ -0,0 +1,77 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#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);
|
||||
}
|
@ -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 ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user