* tests/conform/ADDING_NEW_TESTS

* tests/conform/test-conform-common.c
	* tests/conform/test-pick.c:
	Instead of using clutter_stage_new /clutter_actor_destroy as a way to
	avoid cascading side effects between unit tests, due to left over
	actors, we now destroy all children of the default stage between
	tests instead.

	* tests/conform/wrapper.sh:
	Adds a convenience note about how to run valgrind for an individual
	unit test
This commit is contained in:
Robert Bragg
2008-11-10 18:52:50 +00:00
parent 803182d5c9
commit acff6d8196
5 changed files with 69 additions and 5 deletions

View File

@ -27,5 +27,5 @@ Don't call clutter_init since that is handled in test-conform-common.c
Make sure you clean up *everything* you create. Noteable things you might miss
include timelines, behaviours, and all actors you add to the stage. This is important because otherwise you can cause cascading failures in other tests.
Use stage = clutter_stage_new () with a corresponding clutter_actor_destroy instead of clutter_stage_get_default ().
Be aware that to help avoid tests causing cascading side effects for other tests all children of the default stage are destroyed between tests.

View File

@ -11,7 +11,20 @@ void
test_conform_simple_fixture_setup (TestConformSimpleFixture *fixture,
gconstpointer data)
{
/* const TestConformSharedState *shared_state = data; */
/* const TestConformSharedState *shared_state = data; */
ClutterActor *stage = clutter_stage_get_default ();
GList *actors = clutter_container_get_children (CLUTTER_CONTAINER (stage));
GList *tmp;
/* To help reduce leakage between unit tests, we destroy all children of the stage */
for (tmp = actors; tmp != NULL; tmp = tmp->next)
{
ClutterActor *leaked_actor = tmp->data;
if (g_test_verbose ())
g_print ("Freeing leaked actor %p\n", leaked_actor);
clutter_actor_destroy (leaked_actor);
}
}

View File

@ -71,7 +71,7 @@ test_pick (TestConformSimpleFixture *fixture,
state.pass = TRUE;
state.stage = clutter_stage_new ();
state.stage = clutter_stage_get_default ();
clutter_actor_set_size (state.stage, STAGE_WIDTH, STAGE_HEIGHT);
state.actor_width = STAGE_WIDTH / ACTORS_X;
@ -100,7 +100,6 @@ test_pick (TestConformSimpleFixture *fixture,
clutter_main ();
clutter_actor_destroy (state.stage);
if (g_test_verbose ())
g_print ("end result: %s\n", state.pass ? "FAIL" : "pass");

View File

@ -12,4 +12,7 @@ echo "NOTE: For debugging purposes, you can run this single test as follows:"
echo "$ libtool --mode=execute \\"
echo " gdb --eval-command=\"b $UNIT_TEST\" \\"
echo " --args ./test-conformance -p $UNIT_TEST_PATH"
echo "or:"
echo "$ env G_SLICE=always-malloc \\"
echo " libtool --mode=execute \\"
echo " valgrind ./test-conformance -p $UNIT_TEST_PATH"