From d032b9b2bf21c9c7c02f1a1b11d4e4a1bc7472b6 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 12 Oct 2010 17:31:15 +0100 Subject: [PATCH] conform: Start cleaning up the conformance test suite Re-order the units into a sensible list, with basic tests at the beginning, and per-class tests at the end - with Cogl last. Also, start renaming the unit functions from test_ to , so that the executable wrappers and the reports have sensible names. --- tests/conform/test-actor-destroy.c | 18 ++++- tests/conform/test-actor-invariants.c | 7 -- tests/conform/test-actor-size.c | 6 +- tests/conform/test-anchors.c | 6 +- tests/conform/test-clutter-text.c | 46 ++++--------- tests/conform/test-conform-main.c | 80 ++++++++++++----------- tests/conform/test-pick.c | 4 +- tests/conform/test-text-cache.c | 3 +- tests/conform/test-timeline-interpolate.c | 3 +- tests/conform/test-timeline-rewind.c | 3 +- 10 files changed, 77 insertions(+), 99 deletions(-) diff --git a/tests/conform/test-actor-destroy.c b/tests/conform/test-actor-destroy.c index 6c49e2511..eed2aa63b 100644 --- a/tests/conform/test-actor-destroy.c +++ b/tests/conform/test-actor-destroy.c @@ -151,18 +151,32 @@ test_destroy_init (TestDestroy *self) clutter_actor_set_name (self->tex, "Texture"); } +static void +on_destroy (ClutterActor *actor, + gpointer data) +{ + gboolean *destroy_called = data; + + *destroy_called = TRUE; +} + void -test_actor_destruction (TestConformSimpleFixture *fixture, - gconstpointer dummy) +actor_destruction (void) { ClutterActor *test = g_object_new (TEST_TYPE_DESTROY, NULL); ClutterActor *child = clutter_rectangle_new (); + gboolean destroy_called = FALSE; if (g_test_verbose ()) g_print ("Adding external child...\n"); clutter_actor_set_name (child, "Child"); clutter_container_add_actor (CLUTTER_CONTAINER (test), child); + g_signal_connect (child, "destroy", G_CALLBACK (on_destroy), &destroy_called); + + if (g_test_verbose ()) + g_print ("Calling destroy()...\n"); clutter_actor_destroy (test); + g_assert (destroy_called); } diff --git a/tests/conform/test-actor-invariants.c b/tests/conform/test-actor-invariants.c index 4720cd06e..00476842b 100644 --- a/tests/conform/test-actor-invariants.c +++ b/tests/conform/test-actor-invariants.c @@ -5,13 +5,6 @@ #include "test-conform-common.h" -void -verify_failure (TestConformSimpleFixture *fixture, - gconstpointer data) -{ - g_assert (FALSE); -} - void test_initial_state (TestConformSimpleFixture *fixture, gconstpointer data) diff --git a/tests/conform/test-actor-size.c b/tests/conform/test-actor-size.c index e0dc83856..18597dec9 100644 --- a/tests/conform/test-actor-size.c +++ b/tests/conform/test-actor-size.c @@ -79,8 +79,7 @@ test_actor_init (TestActor *self) } void -test_preferred_size (TestConformSimpleFixture *fixture, - gconstpointer data) +actor_preferred_size (void) { ClutterActor *test; TestActor *self; @@ -140,8 +139,7 @@ test_preferred_size (TestConformSimpleFixture *fixture, } void -test_fixed_size (TestConformSimpleFixture *fixture, - gconstpointer data) +actor_fixed_size (void) { ClutterActor *rect; gboolean min_width_set, nat_width_set; diff --git a/tests/conform/test-anchors.c b/tests/conform/test-anchors.c index e4d906ff6..8592a0640 100644 --- a/tests/conform/test-anchors.c +++ b/tests/conform/test-anchors.c @@ -672,8 +672,7 @@ idle_cb (gpointer data) } void -test_anchors (TestConformSimpleFixture *fixture, - gconstpointer data) +actor_anchors (void) { TestState state; ClutterActor *stage; @@ -701,8 +700,5 @@ test_anchors (TestConformSimpleFixture *fixture, g_idle_remove_by_data (&state); clutter_actor_destroy (state.rect); - - if (g_test_verbose ()) - g_print ("OK\n"); } diff --git a/tests/conform/test-clutter-text.c b/tests/conform/test-clutter-text.c index 9c3813acc..7afec1780 100644 --- a/tests/conform/test-clutter-text.c +++ b/tests/conform/test-clutter-text.c @@ -17,8 +17,7 @@ test_text_data[] = { }; void -test_text_utf8_validation (TestConformSimpleFixture *fixture, - gconstpointer data) +text_utf8_validation (void) { int i; @@ -71,8 +70,7 @@ insert_unichar (ClutterText *text, gunichar unichar, int position) } void -test_text_empty (TestConformSimpleFixture *fixture, - gconstpointer data) +text_set_empty (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); @@ -80,16 +78,6 @@ test_text_empty (TestConformSimpleFixture *fixture, g_assert_cmpint (*clutter_text_get_text (text), ==, '\0'); g_assert_cmpint (clutter_text_get_cursor_position (text), ==, -1); - clutter_actor_destroy (CLUTTER_ACTOR (text)); -} - -void -test_text_set_empty (TestConformSimpleFixture *fixture, - gconstpointer data) -{ - ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); - - /* annoyingly slightly different from initially empty */ clutter_text_set_text (text, ""); g_assert_cmpint (get_nchars (text), ==, 0); g_assert_cmpint (get_nbytes (text), ==, 0); @@ -99,8 +87,7 @@ test_text_set_empty (TestConformSimpleFixture *fixture, } void -test_text_set_text (TestConformSimpleFixture *fixture, - gconstpointer data) +text_set_text (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); @@ -121,8 +108,7 @@ test_text_set_text (TestConformSimpleFixture *fixture, } void -test_text_append_some (TestConformSimpleFixture *fixture, - gconstpointer data) +text_append_some (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); int i; @@ -148,8 +134,7 @@ test_text_append_some (TestConformSimpleFixture *fixture, } void -test_text_prepend_some (TestConformSimpleFixture *fixture, - gconstpointer data) +text_prepend_some (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); int i; @@ -181,8 +166,7 @@ test_text_prepend_some (TestConformSimpleFixture *fixture, } void -test_text_insert (TestConformSimpleFixture *fixture, - gconstpointer data) +text_insert (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); int i; @@ -207,8 +191,7 @@ test_text_insert (TestConformSimpleFixture *fixture, } void -test_text_delete_chars (TestConformSimpleFixture *fixture, - gconstpointer data) +text_delete_chars (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); int i; @@ -240,8 +223,7 @@ test_text_delete_chars (TestConformSimpleFixture *fixture, } void -test_text_get_chars (TestConformSimpleFixture *fixture, - gconstpointer data) +text_get_chars (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); gchar *chars; @@ -271,8 +253,7 @@ test_text_get_chars (TestConformSimpleFixture *fixture, } void -test_text_delete_text (TestConformSimpleFixture *fixture, - gconstpointer data) +text_delete_text (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); int i; @@ -302,8 +283,7 @@ test_text_delete_text (TestConformSimpleFixture *fixture, } void -test_text_password_char (TestConformSimpleFixture *fixture, - gconstpointer data) +text_password_char (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); @@ -357,8 +337,7 @@ send_unichar (ClutterText *text, gunichar unichar) } void -test_text_cursor (TestConformSimpleFixture *fixture, - gconstpointer data) +text_cursor (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); int i; @@ -404,8 +383,7 @@ test_text_cursor (TestConformSimpleFixture *fixture, } void -test_text_event (TestConformSimpleFixture *fixture, - gconstpointer data) +text_event (void) { ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); int i; diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index 720dfe21b..979315244 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -32,6 +32,13 @@ test_conform_todo_test (TestConformSimpleFixture *fixture, #endif } +void +verify_failure (TestConformSimpleFixture *fixture, + gconstpointer data) +{ + g_assert (FALSE); +} + static TestConformSharedState *shared_state = NULL; /* This is a bit of sugar for adding new conformance tests: @@ -45,12 +52,12 @@ static TestConformSharedState *shared_state = NULL; * definition in test-conform-common.h) */ #define TEST_CONFORM_SIMPLE(NAMESPACE, FUNC) G_STMT_START { \ - extern void FUNC (TestConformSimpleFixture *fixture, gconstpointer data); \ - g_test_add ("/conform" NAMESPACE "/" #FUNC, \ - TestConformSimpleFixture, \ - shared_state, /* data argument for test */ \ - test_conform_simple_fixture_setup, \ - FUNC, \ + extern void FUNC (TestConformSimpleFixture *, gconstpointer); \ + g_test_add ("/conform" NAMESPACE "/" #FUNC, \ + TestConformSimpleFixture, \ + shared_state, /* data argument for test */ \ + test_conform_simple_fixture_setup, \ + FUNC, \ test_conform_simple_fixture_teardown); } G_STMT_END /* this is a macro that conditionally executes a test if CONDITION @@ -118,34 +125,14 @@ main (int argc, char **argv) each. To comment out a test use the SKIP or TODO macros. Using #if 0 would break the script. */ - /* this is a sanity check for the test suite itself */ + /* sanity check for the test suite itself */ TEST_CONFORM_TODO ("/suite", verify_failure); - TEST_CONFORM_SIMPLE ("/timeline", test_timeline); - TEST_CONFORM_SKIP (!g_test_slow (), "/timeline", test_timeline_interpolate); - TEST_CONFORM_SKIP (!g_test_slow (), "/timeline", test_timeline_rewind); - - TEST_CONFORM_SIMPLE ("/score", test_score); - - TEST_CONFORM_SIMPLE ("/picking", test_pick); - - TEST_CONFORM_SIMPLE ("/text", test_text_utf8_validation); - TEST_CONFORM_SIMPLE ("/text", test_text_empty); - TEST_CONFORM_SIMPLE ("/text", test_text_set_empty); - TEST_CONFORM_SIMPLE ("/text", test_text_set_text); - TEST_CONFORM_SIMPLE ("/text", test_text_append_some); - TEST_CONFORM_SIMPLE ("/text", test_text_prepend_some); - TEST_CONFORM_SIMPLE ("/text", test_text_insert); - TEST_CONFORM_SIMPLE ("/text", test_text_delete_chars); - TEST_CONFORM_SIMPLE ("/text", test_text_delete_text); - TEST_CONFORM_SIMPLE ("/text", test_text_cursor); - TEST_CONFORM_SIMPLE ("/text", test_text_event); - TEST_CONFORM_SIMPLE ("/text", test_text_get_chars); - TEST_CONFORM_SIMPLE ("/text", test_text_cache); - TEST_CONFORM_SIMPLE ("/text", test_text_password_char); - - TEST_CONFORM_SIMPLE ("/rectangle", test_rect_set_size); - TEST_CONFORM_SIMPLE ("/rectangle", test_rect_set_color); + 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 ("/invariants", test_initial_state); TEST_CONFORM_SIMPLE ("/invariants", test_shown_not_parented); @@ -161,6 +148,23 @@ main (int argc, char **argv) TEST_CONFORM_SIMPLE ("/opacity", test_rectangle_opacity); TEST_CONFORM_SIMPLE ("/opacity", test_paint_opacity); + TEST_CONFORM_SIMPLE ("/text", text_utf8_validation); + TEST_CONFORM_SIMPLE ("/text", text_set_empty); + TEST_CONFORM_SIMPLE ("/text", text_set_text); + TEST_CONFORM_SIMPLE ("/text", text_append_some); + TEST_CONFORM_SIMPLE ("/text", text_prepend_some); + TEST_CONFORM_SIMPLE ("/text", text_insert); + TEST_CONFORM_SIMPLE ("/text", text_delete_chars); + TEST_CONFORM_SIMPLE ("/text", text_delete_text); + TEST_CONFORM_SIMPLE ("/text", text_cursor); + TEST_CONFORM_SIMPLE ("/text", text_event); + TEST_CONFORM_SIMPLE ("/text", text_get_chars); + TEST_CONFORM_SIMPLE ("/text", text_cache); + TEST_CONFORM_SIMPLE ("/text", text_password_char); + + TEST_CONFORM_SIMPLE ("/rectangle", test_rect_set_size); + TEST_CONFORM_SIMPLE ("/rectangle", test_rect_set_color); + TEST_CONFORM_SIMPLE ("/texture", test_texture_pick_with_alpha); TEST_CONFORM_SIMPLE ("/texture", test_texture_fbo); TEST_CONFORM_SIMPLE ("/texture/cairo", test_clutter_cairo_texture); @@ -169,9 +173,6 @@ main (int argc, char **argv) TEST_CONFORM_SIMPLE ("/binding-pool", test_binding_pool); - TEST_CONFORM_SIMPLE ("/actor", test_anchors); - TEST_CONFORM_SIMPLE ("/actor", test_actor_destruction); - TEST_CONFORM_SIMPLE ("/model", test_list_model_populate); TEST_CONFORM_SIMPLE ("/model", test_list_model_iterate); TEST_CONFORM_SIMPLE ("/model", test_list_model_filter); @@ -188,9 +189,6 @@ main (int argc, char **argv) TEST_CONFORM_SIMPLE ("/group", test_group_depth_sorting); - TEST_CONFORM_SIMPLE ("/sizing", test_fixed_size); - TEST_CONFORM_SIMPLE ("/sizing", test_preferred_size); - TEST_CONFORM_SIMPLE ("/script", test_script_single); TEST_CONFORM_SIMPLE ("/script", test_script_child); TEST_CONFORM_SIMPLE ("/script", test_script_implicit_alpha); @@ -203,6 +201,12 @@ main (int argc, char **argv) TEST_CONFORM_SIMPLE ("/script", test_state_base); TEST_CONFORM_SIMPLE ("/script", test_script_layout_property); + TEST_CONFORM_SIMPLE ("/timeline", test_timeline); + TEST_CONFORM_SKIP (!g_test_slow (), "/timeline", timeline_interpolation); + TEST_CONFORM_SKIP (!g_test_slow (), "/timeline", timeline_rewind); + + TEST_CONFORM_SIMPLE ("/score", test_score); + TEST_CONFORM_SIMPLE ("/behaviours", test_behaviours); TEST_CONFORM_SIMPLE ("/cogl", test_cogl_object); diff --git a/tests/conform/test-pick.c b/tests/conform/test-pick.c index d57c7d8f9..1e7e6255b 100644 --- a/tests/conform/test-pick.c +++ b/tests/conform/test-pick.c @@ -117,8 +117,7 @@ on_timeout (State *state) } void -test_pick (TestConformSimpleFixture *fixture, - gconstpointer data) +actor_picking (void) { int y, x; State state; @@ -159,4 +158,3 @@ test_pick (TestConformSimpleFixture *fixture, g_assert (state.pass); } - diff --git a/tests/conform/test-text-cache.c b/tests/conform/test-text-cache.c index a5425e77e..fc41b0200 100644 --- a/tests/conform/test-text-cache.c +++ b/tests/conform/test-text-cache.c @@ -257,8 +257,7 @@ make_layout_like_label (ClutterText *label) } void -test_text_cache (TestConformSimpleFixture *fixture, - gconstpointer _data) +text_cache (void) { CallbackData data; diff --git a/tests/conform/test-timeline-interpolate.c b/tests/conform/test-timeline-interpolate.c index bc01d91b1..5eab888b3 100644 --- a/tests/conform/test-timeline-interpolate.c +++ b/tests/conform/test-timeline-interpolate.c @@ -132,8 +132,7 @@ completed_cb (ClutterTimeline *timeline, } void -test_timeline_interpolate (TestConformSimpleFixture *fixture, - gconstpointer data) +timeline_interpolation (void) { TestState state; diff --git a/tests/conform/test-timeline-rewind.c b/tests/conform/test-timeline-rewind.c index 86b8f1ada..888affbb4 100644 --- a/tests/conform/test-timeline-rewind.c +++ b/tests/conform/test-timeline-rewind.c @@ -67,8 +67,7 @@ new_frame_cb (ClutterTimeline *timeline, } void -test_timeline_rewind (TestConformSimpleFixture *fixture, - gconstpointer data) +timeline_rewind (void) { TestState state;