mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
conform/invariants: Clean up
Use modern API, and add a minimal check that hiding an actor will cause it to unmap.
This commit is contained in:
parent
ffc5260448
commit
c62b69bb14
@ -6,39 +6,55 @@
|
||||
#include "test-conform-common.h"
|
||||
|
||||
void
|
||||
test_initial_state (TestConformSimpleFixture *fixture,
|
||||
actor_initial_state (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
|
||||
actor = clutter_rectangle_new ();
|
||||
g_object_ref_sink (actor);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print ("initial state - visible: %s, realized: %s, mapped: %s\n",
|
||||
CLUTTER_ACTOR_IS_VISIBLE (actor) ? "yes" : "no",
|
||||
CLUTTER_ACTOR_IS_REALIZED (actor) ? "yes" : "no",
|
||||
CLUTTER_ACTOR_IS_MAPPED (actor) ? "yes" : "no");
|
||||
|
||||
g_assert (!(CLUTTER_ACTOR_IS_REALIZED (actor)));
|
||||
g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor)));
|
||||
g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (actor)));
|
||||
|
||||
clutter_actor_destroy (actor);
|
||||
g_object_unref (actor);
|
||||
}
|
||||
|
||||
void
|
||||
test_shown_not_parented (TestConformSimpleFixture *fixture,
|
||||
actor_shown_not_parented (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
|
||||
actor = clutter_rectangle_new ();
|
||||
g_object_ref_sink (actor);
|
||||
|
||||
clutter_actor_show (actor);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print ("show without a parent - visible: %s, realized: %s, mapped: %s\n",
|
||||
CLUTTER_ACTOR_IS_VISIBLE (actor) ? "yes" : "no",
|
||||
CLUTTER_ACTOR_IS_REALIZED (actor) ? "yes" : "no",
|
||||
CLUTTER_ACTOR_IS_MAPPED (actor) ? "yes" : "no");
|
||||
|
||||
g_assert (!CLUTTER_ACTOR_IS_REALIZED (actor));
|
||||
g_assert (!CLUTTER_ACTOR_IS_MAPPED (actor));
|
||||
g_assert (CLUTTER_ACTOR_IS_VISIBLE (actor));
|
||||
|
||||
clutter_actor_destroy (actor);
|
||||
g_object_unref (actor);
|
||||
}
|
||||
|
||||
void
|
||||
test_realized (TestConformSimpleFixture *fixture,
|
||||
actor_realized (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
@ -46,13 +62,12 @@ test_realized (TestConformSimpleFixture *fixture,
|
||||
|
||||
stage = clutter_stage_new ();
|
||||
|
||||
actor = clutter_rectangle_new ();
|
||||
actor = clutter_actor_new ();
|
||||
|
||||
g_assert (!(CLUTTER_ACTOR_IS_REALIZED (actor)));
|
||||
|
||||
clutter_actor_hide (actor); /* don't show, so won't map */
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
|
||||
actor);
|
||||
clutter_actor_add_child (stage, actor);
|
||||
clutter_actor_realize (actor);
|
||||
|
||||
g_assert (CLUTTER_ACTOR_IS_REALIZED (actor));
|
||||
@ -64,7 +79,7 @@ test_realized (TestConformSimpleFixture *fixture,
|
||||
}
|
||||
|
||||
void
|
||||
test_mapped (TestConformSimpleFixture *fixture,
|
||||
actor_mapped (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *actor;
|
||||
@ -73,23 +88,42 @@ test_mapped (TestConformSimpleFixture *fixture,
|
||||
stage = clutter_stage_new ();
|
||||
clutter_actor_show (stage);
|
||||
|
||||
actor = clutter_rectangle_new ();
|
||||
actor = clutter_actor_new ();
|
||||
|
||||
g_assert (!(CLUTTER_ACTOR_IS_REALIZED (actor)));
|
||||
g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor)));
|
||||
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
|
||||
actor);
|
||||
clutter_actor_add_child (stage, actor);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print ("adding to a container should map - "
|
||||
"visible: %s, realized: %s, mapped: %s\n",
|
||||
CLUTTER_ACTOR_IS_VISIBLE (actor) ? "yes" : "no",
|
||||
CLUTTER_ACTOR_IS_REALIZED (actor) ? "yes" : "no",
|
||||
CLUTTER_ACTOR_IS_MAPPED (actor) ? "yes" : "no");
|
||||
|
||||
g_assert (CLUTTER_ACTOR_IS_REALIZED (actor));
|
||||
g_assert (CLUTTER_ACTOR_IS_MAPPED (actor));
|
||||
g_assert (CLUTTER_ACTOR_IS_VISIBLE (actor));
|
||||
|
||||
clutter_actor_hide (actor);
|
||||
|
||||
if (g_test_verbose ())
|
||||
g_print ("hiding should unmap - "
|
||||
"visible: %s, realized: %s, mapped: %s\n",
|
||||
CLUTTER_ACTOR_IS_VISIBLE (actor) ? "yes" : "no",
|
||||
CLUTTER_ACTOR_IS_REALIZED (actor) ? "yes" : "no",
|
||||
CLUTTER_ACTOR_IS_MAPPED (actor) ? "yes" : "no");
|
||||
|
||||
g_assert (CLUTTER_ACTOR_IS_REALIZED (actor));
|
||||
g_assert (!CLUTTER_ACTOR_IS_MAPPED (actor));
|
||||
g_assert (!CLUTTER_ACTOR_IS_VISIBLE (actor));
|
||||
|
||||
clutter_actor_destroy (stage);
|
||||
}
|
||||
|
||||
void
|
||||
test_realize_not_recursive (TestConformSimpleFixture *fixture,
|
||||
actor_realize_not_recursive (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *actor, *group;
|
||||
@ -98,9 +132,9 @@ test_realize_not_recursive (TestConformSimpleFixture *fixture,
|
||||
stage = clutter_stage_new ();
|
||||
clutter_actor_show (stage);
|
||||
|
||||
group = clutter_group_new ();
|
||||
group = clutter_actor_new ();
|
||||
|
||||
actor = clutter_rectangle_new ();
|
||||
actor = clutter_actor_new ();
|
||||
|
||||
clutter_actor_hide (group); /* don't show, so won't map */
|
||||
clutter_actor_hide (actor); /* don't show, so won't map */
|
||||
@ -108,10 +142,8 @@ test_realize_not_recursive (TestConformSimpleFixture *fixture,
|
||||
g_assert (!(CLUTTER_ACTOR_IS_REALIZED (group)));
|
||||
g_assert (!(CLUTTER_ACTOR_IS_REALIZED (actor)));
|
||||
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
|
||||
group);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group),
|
||||
actor);
|
||||
clutter_actor_add_child (stage, group);
|
||||
clutter_actor_add_child (group, actor);
|
||||
|
||||
clutter_actor_realize (group);
|
||||
|
||||
@ -129,7 +161,7 @@ test_realize_not_recursive (TestConformSimpleFixture *fixture,
|
||||
}
|
||||
|
||||
void
|
||||
test_map_recursive (TestConformSimpleFixture *fixture,
|
||||
actor_map_recursive (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *actor, *group;
|
||||
@ -138,9 +170,9 @@ test_map_recursive (TestConformSimpleFixture *fixture,
|
||||
stage = clutter_stage_new ();
|
||||
clutter_actor_show (stage);
|
||||
|
||||
group = clutter_group_new ();
|
||||
group = clutter_actor_new ();
|
||||
|
||||
actor = clutter_rectangle_new ();
|
||||
actor = clutter_actor_new ();
|
||||
|
||||
clutter_actor_hide (group); /* hide at first */
|
||||
clutter_actor_show (actor); /* show at first */
|
||||
@ -152,10 +184,8 @@ test_map_recursive (TestConformSimpleFixture *fixture,
|
||||
g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (group)));
|
||||
g_assert ((CLUTTER_ACTOR_IS_VISIBLE (actor)));
|
||||
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
|
||||
group);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group),
|
||||
actor);
|
||||
clutter_actor_add_child (stage, group);
|
||||
clutter_actor_add_child (group, actor);
|
||||
|
||||
g_assert (!(CLUTTER_ACTOR_IS_REALIZED (group)));
|
||||
g_assert (!(CLUTTER_ACTOR_IS_REALIZED (actor)));
|
||||
@ -179,7 +209,7 @@ test_map_recursive (TestConformSimpleFixture *fixture,
|
||||
}
|
||||
|
||||
void
|
||||
test_show_on_set_parent (TestConformSimpleFixture *fixture,
|
||||
actor_show_on_set_parent (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *actor, *group;
|
||||
@ -188,14 +218,13 @@ test_show_on_set_parent (TestConformSimpleFixture *fixture,
|
||||
|
||||
stage = clutter_stage_new ();
|
||||
|
||||
group = clutter_group_new ();
|
||||
group = clutter_actor_new ();
|
||||
|
||||
g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (group)));
|
||||
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage),
|
||||
group);
|
||||
clutter_actor_add_child (stage, group);
|
||||
|
||||
actor = clutter_rectangle_new ();
|
||||
actor = clutter_actor_new ();
|
||||
g_object_get (actor,
|
||||
"show-on-set-parent", &show_on_set_parent,
|
||||
NULL);
|
||||
@ -203,7 +232,7 @@ test_show_on_set_parent (TestConformSimpleFixture *fixture,
|
||||
g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (actor)));
|
||||
g_assert (show_on_set_parent == TRUE);
|
||||
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (group), actor);
|
||||
clutter_actor_add_child (group, actor);
|
||||
g_object_get (actor,
|
||||
"show-on-set-parent", &show_on_set_parent,
|
||||
NULL);
|
||||
@ -212,7 +241,7 @@ test_show_on_set_parent (TestConformSimpleFixture *fixture,
|
||||
g_assert (show_on_set_parent == TRUE);
|
||||
|
||||
g_object_ref (actor);
|
||||
clutter_actor_unparent (actor);
|
||||
clutter_actor_remove_child (group, actor);
|
||||
g_object_get (actor,
|
||||
"show-on-set-parent", &show_on_set_parent,
|
||||
NULL);
|
||||
@ -228,7 +257,7 @@ test_show_on_set_parent (TestConformSimpleFixture *fixture,
|
||||
}
|
||||
|
||||
void
|
||||
test_clone_no_map (TestConformSimpleFixture *fixture,
|
||||
clone_no_map (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
ClutterActor *stage;
|
||||
@ -264,7 +293,7 @@ test_clone_no_map (TestConformSimpleFixture *fixture,
|
||||
}
|
||||
|
||||
void
|
||||
test_contains (TestConformSimpleFixture *fixture,
|
||||
actor_contains (TestConformSimpleFixture *fixture,
|
||||
gconstpointer data)
|
||||
{
|
||||
/* This build up the following tree:
|
||||
@ -298,28 +327,29 @@ test_contains (TestConformSimpleFixture *fixture,
|
||||
/* j */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
d.actor_a = clutter_group_new ();
|
||||
d.actor_b = clutter_group_new ();
|
||||
d.actor_c = clutter_group_new ();
|
||||
d.actor_d = clutter_group_new ();
|
||||
d.actor_e = clutter_group_new ();
|
||||
d.actor_f = clutter_group_new ();
|
||||
d.actor_g = clutter_group_new ();
|
||||
d.actor_h = clutter_group_new ();
|
||||
d.actor_i = clutter_group_new ();
|
||||
d.actor_j = clutter_group_new ();
|
||||
d.actor_a = clutter_actor_new ();
|
||||
d.actor_b = clutter_actor_new ();
|
||||
d.actor_c = clutter_actor_new ();
|
||||
d.actor_d = clutter_actor_new ();
|
||||
d.actor_e = clutter_actor_new ();
|
||||
d.actor_f = clutter_actor_new ();
|
||||
d.actor_g = clutter_actor_new ();
|
||||
d.actor_h = clutter_actor_new ();
|
||||
d.actor_i = clutter_actor_new ();
|
||||
d.actor_j = clutter_actor_new ();
|
||||
|
||||
clutter_container_add (CLUTTER_CONTAINER (d.actor_a),
|
||||
d.actor_b, d.actor_c, d.actor_d, NULL);
|
||||
clutter_actor_add_child (d.actor_a, d.actor_b);
|
||||
clutter_actor_add_child (d.actor_a, d.actor_c);
|
||||
clutter_actor_add_child (d.actor_a, d.actor_d);
|
||||
|
||||
clutter_container_add (CLUTTER_CONTAINER (d.actor_b),
|
||||
d.actor_e, d.actor_f, NULL);
|
||||
clutter_actor_add_child (d.actor_b, d.actor_e);
|
||||
clutter_actor_add_child (d.actor_b, d.actor_f);
|
||||
|
||||
clutter_container_add (CLUTTER_CONTAINER (d.actor_c),
|
||||
d.actor_g, d.actor_h, NULL);
|
||||
clutter_actor_add_child (d.actor_c, d.actor_g);
|
||||
clutter_actor_add_child (d.actor_c, d.actor_h);
|
||||
|
||||
clutter_container_add (CLUTTER_CONTAINER (d.actor_d),
|
||||
d.actor_i, d.actor_j, NULL);
|
||||
clutter_actor_add_child (d.actor_d, d.actor_i);
|
||||
clutter_actor_add_child (d.actor_d, d.actor_j);
|
||||
|
||||
for (y = 0; y < 10; y++)
|
||||
for (x = 0; x < 10; x++)
|
||||
|
@ -149,15 +149,15 @@ main (int argc, char **argv)
|
||||
TEST_CONFORM_SIMPLE ("/actor/iter", actor_iter_traverse_children);
|
||||
TEST_CONFORM_SIMPLE ("/actor/iter", actor_iter_traverse_remove);
|
||||
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", test_initial_state);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", test_shown_not_parented);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", test_realized);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", test_realize_not_recursive);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", test_map_recursive);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", test_mapped);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", test_show_on_set_parent);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", test_clone_no_map);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", test_contains);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", actor_initial_state);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", actor_shown_not_parented);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", actor_realized);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", actor_realize_not_recursive);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", actor_map_recursive);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", actor_mapped);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", actor_show_on_set_parent);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", clone_no_map);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", actor_contains);
|
||||
TEST_CONFORM_SIMPLE ("/actor/invariants", default_stage);
|
||||
|
||||
TEST_CONFORM_SIMPLE ("/actor/opacity", test_label_opacity);
|
||||
|
Loading…
Reference in New Issue
Block a user