mirror of
https://github.com/brl/mutter.git
synced 2025-01-22 09:29:25 +00:00
[tests] Add a Group actor unit
We need to test that the depth sorting of ClutterGroup works correctly in case we wish to change the data structure that stores the children, and do so without changing the default behaviour.
This commit is contained in:
parent
f1d5881207
commit
87831b3427
1
.gitignore
vendored
1
.gitignore
vendored
@ -209,6 +209,7 @@ TAGS
|
||||
/tests/conform/test-premult
|
||||
/tests/conform/test-clone-no-map
|
||||
/tests/conform/test-materials
|
||||
/tests/conform/test-group-depth-sorting
|
||||
/tests/conform/test-conformance-result.xml
|
||||
/tests/micro-bench/test-text-perf
|
||||
/tests/micro-bench/test-text
|
||||
|
@ -31,6 +31,7 @@ test_conformance_SOURCES = \
|
||||
test-clutter-units.c \
|
||||
test-premult.c \
|
||||
test-materials.c \
|
||||
test-group.c \
|
||||
$(NULL)
|
||||
|
||||
# For convenience, this provides a way to easily run individual unit tests:
|
||||
|
@ -168,5 +168,7 @@ main (int argc, char **argv)
|
||||
TEST_CONFORM_SIMPLE ("/units", test_units_constructors);
|
||||
TEST_CONFORM_SIMPLE ("/units", test_units_string);
|
||||
|
||||
TEST_CONFORM_SIMPLE ("/group", test_group_depth_sorting);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
57
tests/conform/test-group.c
Normal file
57
tests/conform/test-group.c
Normal file
@ -0,0 +1,57 @@
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-conform-common.h"
|
||||
|
||||
void
|
||||
test_group_depth_sorting (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *group;
|
||||
ClutterActor *child, *test;
|
||||
ClutterGroup *g;
|
||||
GList *children;
|
||||
|
||||
group = clutter_group_new ();
|
||||
g = CLUTTER_GROUP (group);
|
||||
|
||||
child = clutter_rectangle_new ();
|
||||
clutter_actor_set_size (child, 20, 20);
|
||||
clutter_actor_set_depth (child, 0);
|
||||
clutter_actor_set_name (child, "zero");
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), child);
|
||||
|
||||
children = clutter_container_get_children (CLUTTER_CONTAINER (group));
|
||||
g_assert (children->data == child);
|
||||
g_assert (children->next == NULL);
|
||||
g_list_free (children);
|
||||
|
||||
child = clutter_rectangle_new ();
|
||||
clutter_actor_set_size (child, 20, 20);
|
||||
clutter_actor_set_depth (child, 10);
|
||||
clutter_actor_set_name (child, "plus-ten");
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), child);
|
||||
|
||||
test = clutter_group_get_nth_child (g, 0);
|
||||
g_assert_cmpstr (clutter_actor_get_name (test), ==, "zero");
|
||||
|
||||
test = clutter_group_get_nth_child (g, 1);
|
||||
g_assert_cmpstr (clutter_actor_get_name (test), ==, "plus-ten");
|
||||
|
||||
child = clutter_rectangle_new ();
|
||||
clutter_actor_set_size (child, 20, 20);
|
||||
clutter_actor_set_depth (child, -10);
|
||||
clutter_actor_set_name (child, "minus-ten");
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), child);
|
||||
|
||||
g_assert_cmpint (clutter_group_get_n_children (g), ==, 3);
|
||||
|
||||
test = clutter_group_get_nth_child (g, 0);
|
||||
g_assert_cmpstr (clutter_actor_get_name (test), ==, "minus-ten");
|
||||
|
||||
test = clutter_group_get_nth_child (g, 1);
|
||||
g_assert_cmpstr (clutter_actor_get_name (test), ==, "zero");
|
||||
|
||||
test = clutter_group_get_nth_child (g, 2);
|
||||
g_assert_cmpstr (clutter_actor_get_name (test), ==, "plus-ten");
|
||||
|
||||
clutter_actor_destroy (group);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user