diff --git a/ChangeLog b/ChangeLog index 6e27e0d4d..ef6552aa8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,13 +1,24 @@ +2008-11-10 Emmanuele Bassi + + * tests/conform/test-label-cache.c: + * tests/conform/test-pick.c: + * tests/conform/test-timeline.c: Show all the output messages only + if the test was done with the verbose flag turned on. + + * tests/interactive/test-main.c: Do not use the (gpointer*) cast, + but use a temporary gpointer instead. + 2008-11-10 Robert Bragg + * tests/conform/Makefile.am: * tests/conform/wrapper.sh: * tests/conform/test-conform-main.c: * tests/conform/test-timeline.c: - Adds Neil's updates to test-timeline.c so it now works with the new unit - testing infrastructure. + Adds Neil's updates to test-timeline.c so it now works with the new + unit testing infrastructure. - Also some fixes to ensure wrappers get setup correctly for the timeline - tests. + Also some fixes to ensure wrappers get setup correctly for the + timeline tests. * tests/interactive/test-main.c: cast the symbol return pointer as (gpointer *) to avoid warning diff --git a/tests/conform/test-label-cache.c b/tests/conform/test-label-cache.c index 9f9a687e1..e9298f8fd 100644 --- a/tests/conform/test-label-cache.c +++ b/tests/conform/test-label-cache.c @@ -59,7 +59,8 @@ check_result (CallbackData *data, const char *note, PangoRectangle test_extents; gboolean fail = FALSE; - printf ("%s: ", note); + if (g_test_verbose ()) + g_print ("%s: ", note); /* Force a redraw to get the on_paint handler to run */ force_redraw (data); @@ -69,27 +70,42 @@ check_result (CallbackData *data, const char *note, pango_layout_get_extents (data->test_layout, NULL, &test_extents); if (memcmp (&test_extents, &data->label_extents, sizeof (PangoRectangle))) { - printf ("extents are different, "); + if (g_test_verbose ()) + g_print ("extents are different, "); fail = TRUE; } else - printf ("extents are the same, "); + { + if (g_test_verbose ()) + g_print ("extents are the same, "); + } if (data->layout_changed) - printf ("layout changed, "); + { + if (g_test_verbose ()) + g_print ("layout changed, "); + } else - printf ("layout did not change, "); + { + if (g_test_verbose ()) + g_print ("layout did not change, "); + } if (data->layout_changed != layout_should_change) fail = TRUE; if (fail) { - printf ("FAIL\n"); + if (g_test_verbose ()) + g_print ("FAIL\n"); + data->test_failed = TRUE; } else - printf ("pass\n"); + { + if (g_test_verbose ()) + g_print ("pass\n"); + } return fail; } @@ -225,7 +241,6 @@ test_label_cache (TestConformSimpleFixture *fixture, gconstpointer _data) { CallbackData data; - int ret = 0; memset (&data, 0, sizeof (data)); @@ -245,16 +260,17 @@ test_label_cache (TestConformSimpleFixture *fixture, clutter_main (); - printf ("\nOverall result: "); + if (g_test_verbose ()) + g_print ("\nOverall result: "); - if (data.test_failed) + if (g_test_verbose ()) { - printf ("FAIL\n"); - exit (1); + if (data.test_failed) + g_print ("FAIL\n"); + else + g_print ("pass\n"); } else - printf ("pass\n"); - - return; + g_assert (data.test_failed != TRUE); } diff --git a/tests/conform/test-pick.c b/tests/conform/test-pick.c index c39f32ba1..e40c767ce 100644 --- a/tests/conform/test-pick.c +++ b/tests/conform/test-pick.c @@ -35,16 +35,22 @@ on_timeout (State *state) y * state->actor_height + state->actor_height / 2); - printf ("actor %u -> ", state->gids[y * ACTORS_X + x]); + if (g_test_verbose ()) + g_print ("actor %u -> ", state->gids[y * ACTORS_X + x]); if (actor == NULL) - printf ("NULL: FAIL\n"); + { + if (g_test_verbose ()) + g_print ("NULL: FAIL\n"); + } else { gid = clutter_actor_get_gid (actor); if (gid == state->gids[y * ACTORS_X + x]) pass = TRUE; - printf ("% 8i: %s\n", gid, pass ? "pass" : "FAIL"); + + if (g_test_verbose ()) + g_print ("% 8i: %s\n", gid, pass ? "pass" : "FAIL"); } if (!pass) @@ -96,9 +102,9 @@ test_pick (TestConformSimpleFixture *fixture, clutter_actor_destroy (state.stage); - g_print ("end result: %s\n", state.pass ? "pass" : "FAIL"); - g_assert (state.pass); + if (g_test_verbose ()) + g_print ("end result: %s\n", state.pass ? "FAIL" : "pass"); - return; + g_assert (state.pass); } diff --git a/tests/conform/test-timeline.c b/tests/conform/test-timeline.c index e64184dd3..b8a063523 100644 --- a/tests/conform/test-timeline.c +++ b/tests/conform/test-timeline.c @@ -45,7 +45,9 @@ static void timeline_complete_cb (ClutterTimeline *timeline, TimelineData *data) { - printf ("%i: Completed\n", data->timeline_num); + if (g_test_verbose ()) + g_print ("%i: Completed\n", data->timeline_num); + data->completed_count++; } @@ -54,9 +56,10 @@ timeline_new_frame_cb (ClutterTimeline *timeline, gint frame_no, TimelineData *data) { - printf ("%i: Doing frame %d, delta = %i\n", - data->timeline_num, frame_no, - clutter_timeline_get_delta (timeline, NULL)); + if (g_test_verbose ()) + g_print ("%i: Doing frame %d, delta = %i\n", + data->timeline_num, frame_no, + clutter_timeline_get_delta (timeline, NULL)); data->frame_hit_count[frame_no]++; } @@ -66,9 +69,10 @@ timeline_marker_reached_cb (ClutterTimeline *timeline, guint frame_num, TimelineData *data) { - printf ("%i: Marker `%s' (%d) reached, delta = %i\n", - data->timeline_num, marker_name, frame_num, - clutter_timeline_get_delta (timeline, NULL)); + if (g_test_verbose ()) + g_print ("%i: Marker `%s' (%d) reached, delta = %i\n", + data->timeline_num, marker_name, frame_num, + clutter_timeline_get_delta (timeline, NULL)); data->markers_hit = g_slist_prepend (data->markers_hit, g_strdup (marker_name)); } @@ -105,8 +109,9 @@ check_timeline (ClutterTimeline *timeline, marker_reached_count[i]++; else { - printf ("FAIL: unknown marker '%s' hit for %i\n", - (char *) node->data, data->timeline_num); + if (g_test_verbose ()) + g_print ("FAIL: unknown marker '%s' hit for %i\n", + (char *) node->data, data->timeline_num); succeeded = FALSE; } } @@ -114,8 +119,9 @@ check_timeline (ClutterTimeline *timeline, for (i = 0; i < n_markers; i++) if (marker_reached_count[i] != 1) { - printf ("FAIL: marker '%s' hit %i times for %i\n", - markers[i], marker_reached_count[i], data->timeline_num); + if (g_test_verbose ()) + g_print ("FAIL: marker '%s' hit %i times for %i\n", + markers[i], marker_reached_count[i], data->timeline_num); succeeded = FALSE; } @@ -127,17 +133,19 @@ check_timeline (ClutterTimeline *timeline, if (missed_frame_count) { - printf ("FAIL: missed %i frame%s for %i\n", - missed_frame_count, missed_frame_count == 1 ? "" : "s", - data->timeline_num); + if (g_test_verbose ()) + g_print ("FAIL: missed %i frame%s for %i\n", + missed_frame_count, missed_frame_count == 1 ? "" : "s", + data->timeline_num); succeeded = FALSE; } } if (data->completed_count != 1) { - printf ("FAIL: timeline %i completed %i times\n", - data->timeline_num, data->completed_count); + if (g_test_verbose ()) + g_print ("FAIL: timeline %i completed %i times\n", + data->timeline_num, data->completed_count); succeeded = FALSE; } @@ -238,7 +246,8 @@ test_timeline (TestConformSimpleFixture *fixture, "completed", G_CALLBACK (timeline_complete_cb), &data_3); - printf ("Without delay...\n"); + if (g_test_verbose ()) + g_print ("Without delay...\n"); clutter_timeline_start (timeline_1); clutter_timeline_start (timeline_2); @@ -255,7 +264,8 @@ test_timeline (TestConformSimpleFixture *fixture, if (!check_timeline (timeline_3, &data_3, TRUE)) pass = FALSE; - printf ("With delay...\n"); + if (g_test_verbose ()) + g_print ("With delay...\n"); timeline_data_destroy (&data_1); timeline_data_init (&data_1, 1); @@ -288,6 +298,8 @@ test_timeline (TestConformSimpleFixture *fixture, timeline_data_destroy (&data_2); timeline_data_destroy (&data_3); - g_printf ("Overall result: %s\n", pass == TRUE ? "PASS" : "FAIL"); + if (g_test_verbose ()) + g_print ("Overall result: %s\n", pass == TRUE ? "PASS" : "FAIL"); + g_assert (pass == TRUE); } diff --git a/tests/interactive/test-main.c b/tests/interactive/test-main.c index dd00ac46d..1724ededa 100644 --- a/tests/interactive/test-main.c +++ b/tests/interactive/test-main.c @@ -8,11 +8,12 @@ main (int argc, char **argv) GModule *module; char *unit_test; char *main_symbol_name; + gpointer func; int (*unit_test_main) (int argc, char **argv); int ret; if (argc != 2) - g_error ("Usage: %s unit_test"); + g_error ("Usage: %s unit_test", argv[0]); module = g_module_open (NULL, 0); if (!module) @@ -23,9 +24,10 @@ main (int argc, char **argv) main_symbol_name = g_strdup_printf ("%s_main", unit_test); main_symbol_name = g_strdelimit (main_symbol_name, "-", '_'); - if (!g_module_symbol (module, main_symbol_name, (gpointer *)&unit_test_main)) + if (!g_module_symbol (module, main_symbol_name, &func)) g_error ("Failed to look up main symbol for the test: %s", unit_test); + unit_test_main = func; ret = unit_test_main (argc - 1, argv + 1); g_free (unit_test);