From abac520f0c081c3c4c986d50ff42a297dd6e8ccd Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 12 Jun 2009 03:46:38 +0100 Subject: [PATCH] [tests] Add unit for Clone behaviour A clone actor should not modify the state of its source, so we need to check that it's not breaking any invariant. --- .gitignore | 2 ++ tests/conform/test-actor-invariants.c | 34 +++++++++++++++++++++++++++ tests/conform/test-conform-main.c | 1 + 3 files changed, 37 insertions(+) diff --git a/.gitignore b/.gitignore index 186a5c5ce..d8e56f390 100644 --- a/.gitignore +++ b/.gitignore @@ -206,6 +206,8 @@ TAGS /tests/conform/test-color-to-string /tests/conform/test-units-constructors /tests/conform/test-units-string +/tests/conform/test-premult +/tests/conform/test-clone-no-map /tests/conform/test-conformance-result.xml /tests/micro-bench/test-text-perf /tests/micro-bench/test-text diff --git a/tests/conform/test-actor-invariants.c b/tests/conform/test-actor-invariants.c index 77eea9ad2..d6d6eed86 100644 --- a/tests/conform/test-actor-invariants.c +++ b/tests/conform/test-actor-invariants.c @@ -222,3 +222,37 @@ test_show_on_set_parent (TestConformSimpleFixture *fixture, clutter_actor_destroy (actor); clutter_actor_destroy (group); } + +void +test_clone_no_map (TestConformSimpleFixture *fixture, + gconstpointer data) +{ + ClutterActor *stage; + ClutterActor *group; + ClutterActor *actor; + ClutterActor *clone; + + stage = clutter_stage_get_default (); + + group = clutter_group_new (); + actor = clutter_rectangle_new (); + + clutter_actor_hide (group); + + clutter_container_add_actor (CLUTTER_CONTAINER (group), actor); + clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); + + g_assert (!(CLUTTER_ACTOR_IS_MAPPED (group))); + g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor))); + + clone = clutter_clone_new (group); + + clutter_container_add_actor (CLUTTER_CONTAINER (stage), clone); + + g_assert (CLUTTER_ACTOR_IS_MAPPED (clone)); + g_assert (!(CLUTTER_ACTOR_IS_MAPPED (group))); + g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor))); + + clutter_actor_destroy (CLUTTER_ACTOR (clone)); + clutter_actor_destroy (CLUTTER_ACTOR (group)); +} diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index faa46a6e2..5de1913e8 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -125,6 +125,7 @@ main (int argc, char **argv) TEST_CONFORM_SIMPLE ("/invariants", test_map_recursive); TEST_CONFORM_SIMPLE ("/invariants", test_mapped); TEST_CONFORM_SIMPLE ("/invariants", test_show_on_set_parent); + TEST_CONFORM_SIMPLE ("/invariants", test_clone_no_map); TEST_CONFORM_SIMPLE ("/vertex-buffer", test_vertex_buffer_contiguous); TEST_CONFORM_SIMPLE ("/vertex-buffer", test_vertex_buffer_interleved);