1
0
Fork 0

2008-11-10 Emmanuele Bassi <ebassi@linux.intel.com>

* 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.
This commit is contained in:
Emmanuele Bassi 2008-11-10 12:28:42 +00:00
parent 98f942fd72
commit ca7bdc12a4
5 changed files with 93 additions and 46 deletions

View file

@ -1,13 +1,24 @@
2008-11-10 Emmanuele Bassi <ebassi@linux.intel.com>
* 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 <robert@linux.intel.com> 2008-11-10 Robert Bragg <robert@linux.intel.com>
* tests/conform/Makefile.am: * tests/conform/Makefile.am:
* tests/conform/wrapper.sh: * tests/conform/wrapper.sh:
* tests/conform/test-conform-main.c: * tests/conform/test-conform-main.c:
* tests/conform/test-timeline.c: * tests/conform/test-timeline.c:
Adds Neil's updates to test-timeline.c so it now works with the new unit Adds Neil's updates to test-timeline.c so it now works with the new
testing infrastructure. unit testing infrastructure.
Also some fixes to ensure wrappers get setup correctly for the timeline Also some fixes to ensure wrappers get setup correctly for the
tests. timeline tests.
* tests/interactive/test-main.c: * tests/interactive/test-main.c:
cast the symbol return pointer as (gpointer *) to avoid warning cast the symbol return pointer as (gpointer *) to avoid warning

View file

@ -59,7 +59,8 @@ check_result (CallbackData *data, const char *note,
PangoRectangle test_extents; PangoRectangle test_extents;
gboolean fail = FALSE; 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 a redraw to get the on_paint handler to run */
force_redraw (data); force_redraw (data);
@ -69,27 +70,42 @@ check_result (CallbackData *data, const char *note,
pango_layout_get_extents (data->test_layout, NULL, &test_extents); pango_layout_get_extents (data->test_layout, NULL, &test_extents);
if (memcmp (&test_extents, &data->label_extents, sizeof (PangoRectangle))) if (memcmp (&test_extents, &data->label_extents, sizeof (PangoRectangle)))
{ {
printf ("extents are different, "); if (g_test_verbose ())
g_print ("extents are different, ");
fail = TRUE; fail = TRUE;
} }
else else
printf ("extents are the same, "); {
if (g_test_verbose ())
g_print ("extents are the same, ");
}
if (data->layout_changed) if (data->layout_changed)
printf ("layout changed, "); {
if (g_test_verbose ())
g_print ("layout changed, ");
}
else else
printf ("layout did not change, "); {
if (g_test_verbose ())
g_print ("layout did not change, ");
}
if (data->layout_changed != layout_should_change) if (data->layout_changed != layout_should_change)
fail = TRUE; fail = TRUE;
if (fail) if (fail)
{ {
printf ("FAIL\n"); if (g_test_verbose ())
g_print ("FAIL\n");
data->test_failed = TRUE; data->test_failed = TRUE;
} }
else else
printf ("pass\n"); {
if (g_test_verbose ())
g_print ("pass\n");
}
return fail; return fail;
} }
@ -225,7 +241,6 @@ test_label_cache (TestConformSimpleFixture *fixture,
gconstpointer _data) gconstpointer _data)
{ {
CallbackData data; CallbackData data;
int ret = 0;
memset (&data, 0, sizeof (data)); memset (&data, 0, sizeof (data));
@ -245,16 +260,17 @@ test_label_cache (TestConformSimpleFixture *fixture,
clutter_main (); clutter_main ();
printf ("\nOverall result: "); if (g_test_verbose ())
g_print ("\nOverall result: ");
if (data.test_failed) if (g_test_verbose ())
{ {
printf ("FAIL\n"); if (data.test_failed)
exit (1); g_print ("FAIL\n");
else
g_print ("pass\n");
} }
else else
printf ("pass\n"); g_assert (data.test_failed != TRUE);
return;
} }

View file

@ -35,16 +35,22 @@ on_timeout (State *state)
y * state->actor_height y * state->actor_height
+ state->actor_height / 2); + 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) if (actor == NULL)
printf ("NULL: FAIL\n"); {
if (g_test_verbose ())
g_print ("NULL: FAIL\n");
}
else else
{ {
gid = clutter_actor_get_gid (actor); gid = clutter_actor_get_gid (actor);
if (gid == state->gids[y * ACTORS_X + x]) if (gid == state->gids[y * ACTORS_X + x])
pass = TRUE; 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) if (!pass)
@ -96,9 +102,9 @@ test_pick (TestConformSimpleFixture *fixture,
clutter_actor_destroy (state.stage); clutter_actor_destroy (state.stage);
g_print ("end result: %s\n", state.pass ? "pass" : "FAIL"); if (g_test_verbose ())
g_assert (state.pass); g_print ("end result: %s\n", state.pass ? "FAIL" : "pass");
return; g_assert (state.pass);
} }

View file

@ -45,7 +45,9 @@ static void
timeline_complete_cb (ClutterTimeline *timeline, timeline_complete_cb (ClutterTimeline *timeline,
TimelineData *data) TimelineData *data)
{ {
printf ("%i: Completed\n", data->timeline_num); if (g_test_verbose ())
g_print ("%i: Completed\n", data->timeline_num);
data->completed_count++; data->completed_count++;
} }
@ -54,9 +56,10 @@ timeline_new_frame_cb (ClutterTimeline *timeline,
gint frame_no, gint frame_no,
TimelineData *data) TimelineData *data)
{ {
printf ("%i: Doing frame %d, delta = %i\n", if (g_test_verbose ())
data->timeline_num, frame_no, g_print ("%i: Doing frame %d, delta = %i\n",
clutter_timeline_get_delta (timeline, NULL)); data->timeline_num, frame_no,
clutter_timeline_get_delta (timeline, NULL));
data->frame_hit_count[frame_no]++; data->frame_hit_count[frame_no]++;
} }
@ -66,9 +69,10 @@ timeline_marker_reached_cb (ClutterTimeline *timeline,
guint frame_num, guint frame_num,
TimelineData *data) TimelineData *data)
{ {
printf ("%i: Marker `%s' (%d) reached, delta = %i\n", if (g_test_verbose ())
data->timeline_num, marker_name, frame_num, g_print ("%i: Marker `%s' (%d) reached, delta = %i\n",
clutter_timeline_get_delta (timeline, NULL)); data->timeline_num, marker_name, frame_num,
clutter_timeline_get_delta (timeline, NULL));
data->markers_hit = g_slist_prepend (data->markers_hit, data->markers_hit = g_slist_prepend (data->markers_hit,
g_strdup (marker_name)); g_strdup (marker_name));
} }
@ -105,8 +109,9 @@ check_timeline (ClutterTimeline *timeline,
marker_reached_count[i]++; marker_reached_count[i]++;
else else
{ {
printf ("FAIL: unknown marker '%s' hit for %i\n", if (g_test_verbose ())
(char *) node->data, data->timeline_num); g_print ("FAIL: unknown marker '%s' hit for %i\n",
(char *) node->data, data->timeline_num);
succeeded = FALSE; succeeded = FALSE;
} }
} }
@ -114,8 +119,9 @@ check_timeline (ClutterTimeline *timeline,
for (i = 0; i < n_markers; i++) for (i = 0; i < n_markers; i++)
if (marker_reached_count[i] != 1) if (marker_reached_count[i] != 1)
{ {
printf ("FAIL: marker '%s' hit %i times for %i\n", if (g_test_verbose ())
markers[i], marker_reached_count[i], data->timeline_num); g_print ("FAIL: marker '%s' hit %i times for %i\n",
markers[i], marker_reached_count[i], data->timeline_num);
succeeded = FALSE; succeeded = FALSE;
} }
@ -127,17 +133,19 @@ check_timeline (ClutterTimeline *timeline,
if (missed_frame_count) if (missed_frame_count)
{ {
printf ("FAIL: missed %i frame%s for %i\n", if (g_test_verbose ())
missed_frame_count, missed_frame_count == 1 ? "" : "s", g_print ("FAIL: missed %i frame%s for %i\n",
data->timeline_num); missed_frame_count, missed_frame_count == 1 ? "" : "s",
data->timeline_num);
succeeded = FALSE; succeeded = FALSE;
} }
} }
if (data->completed_count != 1) if (data->completed_count != 1)
{ {
printf ("FAIL: timeline %i completed %i times\n", if (g_test_verbose ())
data->timeline_num, data->completed_count); g_print ("FAIL: timeline %i completed %i times\n",
data->timeline_num, data->completed_count);
succeeded = FALSE; succeeded = FALSE;
} }
@ -238,7 +246,8 @@ test_timeline (TestConformSimpleFixture *fixture,
"completed", G_CALLBACK (timeline_complete_cb), "completed", G_CALLBACK (timeline_complete_cb),
&data_3); &data_3);
printf ("Without delay...\n"); if (g_test_verbose ())
g_print ("Without delay...\n");
clutter_timeline_start (timeline_1); clutter_timeline_start (timeline_1);
clutter_timeline_start (timeline_2); clutter_timeline_start (timeline_2);
@ -255,7 +264,8 @@ test_timeline (TestConformSimpleFixture *fixture,
if (!check_timeline (timeline_3, &data_3, TRUE)) if (!check_timeline (timeline_3, &data_3, TRUE))
pass = FALSE; pass = FALSE;
printf ("With delay...\n"); if (g_test_verbose ())
g_print ("With delay...\n");
timeline_data_destroy (&data_1); timeline_data_destroy (&data_1);
timeline_data_init (&data_1, 1); timeline_data_init (&data_1, 1);
@ -288,6 +298,8 @@ test_timeline (TestConformSimpleFixture *fixture,
timeline_data_destroy (&data_2); timeline_data_destroy (&data_2);
timeline_data_destroy (&data_3); 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); g_assert (pass == TRUE);
} }

View file

@ -8,11 +8,12 @@ main (int argc, char **argv)
GModule *module; GModule *module;
char *unit_test; char *unit_test;
char *main_symbol_name; char *main_symbol_name;
gpointer func;
int (*unit_test_main) (int argc, char **argv); int (*unit_test_main) (int argc, char **argv);
int ret; int ret;
if (argc != 2) if (argc != 2)
g_error ("Usage: %s unit_test"); g_error ("Usage: %s unit_test", argv[0]);
module = g_module_open (NULL, 0); module = g_module_open (NULL, 0);
if (!module) 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_strdup_printf ("%s_main", unit_test);
main_symbol_name = g_strdelimit (main_symbol_name, "-", '_'); 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); 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); ret = unit_test_main (argc - 1, argv + 1);
g_free (unit_test); g_free (unit_test);