mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
conform: Add a suite for the Actor scene graph API
Verify that insertion and removal maintain a stable graph, with pointers to the various children. This should help out tracking regressions in the scene graph API.
This commit is contained in:
parent
813eef4325
commit
419a6a38f2
@ -59,6 +59,7 @@ units_sources += \
|
||||
|
||||
# actors tests
|
||||
units_sources += \
|
||||
test-actor-graph.c \
|
||||
test-actor-destroy.c \
|
||||
test-actor-invariants.c \
|
||||
test-actor-layout.c \
|
||||
|
147
tests/conform/test-actor-graph.c
Normal file
147
tests/conform/test-actor-graph.c
Normal file
@ -0,0 +1,147 @@
|
||||
#include <clutter/clutter.h>
|
||||
#include "test-conform-common.h"
|
||||
|
||||
void
|
||||
actor_add_child (TestConformSimpleFixture *fixture,
|
||||
gconstpointer dummy)
|
||||
{
|
||||
ClutterActor *actor = clutter_actor_new ();
|
||||
ClutterActor *iter;
|
||||
|
||||
g_object_ref_sink (actor);
|
||||
|
||||
clutter_actor_add_child (actor, g_object_new (CLUTTER_TYPE_ACTOR,
|
||||
"name", "foo",
|
||||
NULL));
|
||||
clutter_actor_add_child (actor, g_object_new (CLUTTER_TYPE_ACTOR,
|
||||
"name", "bar",
|
||||
NULL));
|
||||
clutter_actor_add_child (actor, g_object_new (CLUTTER_TYPE_ACTOR,
|
||||
"name", "baz",
|
||||
NULL));
|
||||
|
||||
g_assert_cmpint (clutter_actor_get_n_children (actor), ==, 3);
|
||||
|
||||
iter = clutter_actor_get_first_child (actor);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "foo");
|
||||
|
||||
iter = clutter_actor_get_next_sibling (iter);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "bar");
|
||||
|
||||
iter = clutter_actor_get_next_sibling (iter);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "baz");
|
||||
g_assert (iter == clutter_actor_get_last_child (actor));
|
||||
g_assert (clutter_actor_get_next_sibling (iter) == NULL);
|
||||
|
||||
iter = clutter_actor_get_last_child (actor);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "baz");
|
||||
|
||||
iter = clutter_actor_get_previous_sibling (iter);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "bar");
|
||||
|
||||
iter = clutter_actor_get_previous_sibling (iter);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "foo");
|
||||
g_assert (iter == clutter_actor_get_first_child (actor));
|
||||
g_assert (clutter_actor_get_previous_sibling (iter) == NULL);
|
||||
|
||||
clutter_actor_destroy (actor);
|
||||
g_object_unref (actor);
|
||||
}
|
||||
|
||||
void
|
||||
actor_insert_child (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *actor = clutter_actor_new ();
|
||||
ClutterActor *iter;
|
||||
|
||||
g_object_ref_sink (actor);
|
||||
|
||||
clutter_actor_insert_child_at_index (actor,
|
||||
g_object_new (CLUTTER_TYPE_ACTOR,
|
||||
"name", "foo",
|
||||
NULL),
|
||||
0);
|
||||
|
||||
iter = clutter_actor_get_first_child (actor);
|
||||
g_assert (iter != NULL);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "foo");
|
||||
g_assert (iter == clutter_actor_get_child_at_index (actor, 0));
|
||||
|
||||
clutter_actor_insert_child_below (actor,
|
||||
g_object_new (CLUTTER_TYPE_ACTOR,
|
||||
"name", "bar",
|
||||
NULL),
|
||||
iter);
|
||||
|
||||
g_assert_cmpint (clutter_actor_get_n_children (actor), ==, 2);
|
||||
|
||||
iter = clutter_actor_get_first_child (actor);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "bar");
|
||||
iter = clutter_actor_get_next_sibling (iter);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "foo");
|
||||
g_assert (iter == clutter_actor_get_child_at_index (actor, 1));
|
||||
|
||||
iter = clutter_actor_get_first_child (actor);
|
||||
clutter_actor_insert_child_above (actor,
|
||||
g_object_new (CLUTTER_TYPE_ACTOR,
|
||||
"name", "baz",
|
||||
NULL),
|
||||
iter);
|
||||
|
||||
iter = clutter_actor_get_last_child (actor);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "foo");
|
||||
|
||||
iter = clutter_actor_get_previous_sibling (iter);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "baz");
|
||||
|
||||
iter = clutter_actor_get_previous_sibling (iter);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "bar");
|
||||
|
||||
clutter_actor_destroy (actor);
|
||||
g_object_unref (actor);
|
||||
}
|
||||
|
||||
void
|
||||
actor_remove_child (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *actor = clutter_actor_new ();
|
||||
ClutterActor *iter;
|
||||
|
||||
g_object_ref_sink (actor);
|
||||
|
||||
clutter_actor_add_child (actor, g_object_new (CLUTTER_TYPE_ACTOR,
|
||||
"name", "foo",
|
||||
NULL));
|
||||
clutter_actor_add_child (actor, g_object_new (CLUTTER_TYPE_ACTOR,
|
||||
"name", "bar",
|
||||
NULL));
|
||||
|
||||
g_assert_cmpint (clutter_actor_get_n_children (actor), ==, 2);
|
||||
|
||||
g_assert (clutter_actor_get_first_child (actor) != clutter_actor_get_last_child (actor));
|
||||
|
||||
iter = clutter_actor_get_first_child (actor);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "foo");
|
||||
|
||||
iter = clutter_actor_get_last_child (actor);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "bar");
|
||||
|
||||
clutter_actor_remove_child (actor, clutter_actor_get_first_child (actor));
|
||||
|
||||
g_assert_cmpint (clutter_actor_get_n_children (actor), ==, 1);
|
||||
|
||||
iter = clutter_actor_get_first_child (actor);
|
||||
g_assert_cmpstr (clutter_actor_get_name (iter), ==, "bar");
|
||||
g_assert (clutter_actor_get_first_child (actor) == clutter_actor_get_last_child (actor));
|
||||
|
||||
clutter_actor_remove_child (actor, clutter_actor_get_first_child (actor));
|
||||
|
||||
g_assert_cmpint (clutter_actor_get_n_children (actor), ==, 0);
|
||||
g_assert (clutter_actor_get_first_child (actor) == NULL);
|
||||
g_assert (clutter_actor_get_last_child (actor) == NULL);
|
||||
|
||||
clutter_actor_destroy (actor);
|
||||
g_object_unref (actor);
|
||||
}
|
@ -128,15 +128,18 @@ main (int argc, char **argv)
|
||||
/* sanity check for the test suite itself */
|
||||
TEST_CONFORM_TODO ("/suite", verify_failure);
|
||||
|
||||
TEST_CONFORM_SIMPLE ("/actor", actor_add_child);
|
||||
TEST_CONFORM_SIMPLE ("/actor", actor_insert_child);
|
||||
TEST_CONFORM_SIMPLE ("/actor", actor_remove_child);
|
||||
TEST_CONFORM_SIMPLE ("/actor", actor_destruction);
|
||||
TEST_CONFORM_SIMPLE ("/actor", actor_anchors);
|
||||
TEST_CONFORM_SIMPLE ("/actor", actor_picking);
|
||||
TEST_CONFORM_SIMPLE ("/actor", actor_fixed_size);
|
||||
TEST_CONFORM_SIMPLE ("/actor", actor_preferred_size);
|
||||
TEST_CONFORM_SIMPLE ("/actor", test_offscreen_redirect);
|
||||
TEST_CONFORM_SIMPLE ("/actor", test_shader_effect);
|
||||
TEST_CONFORM_SIMPLE ("/actor", basic_layout);
|
||||
TEST_CONFORM_SIMPLE ("/actor", margin_layout);
|
||||
TEST_CONFORM_SIMPLE ("/actor", test_offscreen_redirect);
|
||||
TEST_CONFORM_SIMPLE ("/actor", test_shader_effect);
|
||||
|
||||
TEST_CONFORM_SIMPLE ("/invariants", test_initial_state);
|
||||
TEST_CONFORM_SIMPLE ("/invariants", test_shown_not_parented);
|
||||
|
Loading…
Reference in New Issue
Block a user