From f2015baeb76b68eb5c5ac20f7f4bbf8dc43c8499 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 18 Dec 2011 21:09:44 +0000 Subject: [PATCH] conform/actor-graph: Add lower/raise units Check that the lower_bottom(), lower(), raise(), and raise_top() methods work as intended. --- tests/conform/test-actor-graph.c | 106 ++++++++++++++++++++++++++++++ tests/conform/test-conform-main.c | 2 + 2 files changed, 108 insertions(+) diff --git a/tests/conform/test-actor-graph.c b/tests/conform/test-actor-graph.c index 1d34fa792..bae546197 100644 --- a/tests/conform/test-actor-graph.c +++ b/tests/conform/test-actor-graph.c @@ -145,3 +145,109 @@ actor_remove_child (TestConformSimpleFixture *fixture, clutter_actor_destroy (actor); g_object_unref (actor); } + +void +actor_raise_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_child_at_index (actor, 1); + g_assert_cmpstr (clutter_actor_get_name (iter), ==, "bar"); + + clutter_actor_raise (iter, clutter_actor_get_child_at_index (actor, 2)); + + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 0)), + ==, + "foo"); + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 1)), + ==, + "baz"); + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 2)), + ==, + "bar"); + + iter = clutter_actor_get_child_at_index (actor, 0); + clutter_actor_raise_top (iter); + + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 0)), + ==, + "baz"); + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 1)), + ==, + "bar"); + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 2)), + ==, + "foo"); + + clutter_actor_destroy (actor); + g_object_unref (actor); +} + +void +actor_lower_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_child_at_index (actor, 1); + g_assert_cmpstr (clutter_actor_get_name (iter), ==, "bar"); + + clutter_actor_lower (iter, clutter_actor_get_child_at_index (actor, 0)); + + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 0)), + ==, + "bar"); + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 1)), + ==, + "foo"); + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 2)), + ==, + "baz"); + + iter = clutter_actor_get_child_at_index (actor, 2); + clutter_actor_lower_bottom (iter); + + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 0)), + ==, + "baz"); + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 1)), + ==, + "bar"); + g_assert_cmpstr (clutter_actor_get_name (clutter_actor_get_child_at_index (actor, 2)), + ==, + "foo"); + + clutter_actor_destroy (actor); + g_object_unref (actor); +} diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index fbd4acd11..30d23e88c 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -131,6 +131,8 @@ main (int argc, char **argv) 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_raise_child); + TEST_CONFORM_SIMPLE ("/actor", actor_lower_child); TEST_CONFORM_SIMPLE ("/actor", actor_destruction); TEST_CONFORM_SIMPLE ("/actor", actor_anchors); TEST_CONFORM_SIMPLE ("/actor", actor_picking);