From f08b583a312cd87f3263078eecdb19a9328ac79f Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 14 Aug 2009 15:58:00 +0100 Subject: [PATCH] [tests] Abstract GTest and Clutter initialization The set up process of the conformance test suite is complex enough to warrant a split up into its own function. --- tests/conform/test-conform-main.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index 235eccad3..1077dcd86 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -3,6 +3,7 @@ #include #include +#include #include #include "test-conform-common.h" @@ -14,6 +15,8 @@ test_conform_skip_test (TestConformSimpleFixture *fixture, /* void */ } +static TestConformSharedState *shared_state = NULL; + /* This is a bit of sugar for adding new conformance tests: * * - It adds an extern function definition just to save maintaining a header @@ -56,11 +59,10 @@ test_conform_skip_test (TestConformSimpleFixture *fixture, test_conform_skip_test, \ test_conform_simple_fixture_teardown); } G_STMT_END -int -main (int argc, char **argv) +static void +clutter_test_init (gint *argc, + gchar ***argv) { - TestConformSharedState *shared_state = g_new0 (TestConformSharedState, 1); - #ifdef HAVE_CLUTTER_GLX /* on X11 we need a display connection to run the test suite */ const gchar *display = g_getenv ("DISPLAY"); @@ -68,7 +70,8 @@ main (int argc, char **argv) { g_print ("No DISPLAY found. Unable to run the conformance " "test suite without a display."); - return EXIT_SUCCESS; + + exit (EXIT_SUCCESS); } #endif @@ -79,17 +82,24 @@ main (int argc, char **argv) */ g_setenv ("CLUTTER_VBLANK", "none", FALSE); - g_test_init (&argc, &argv, NULL); + g_test_init (argc, argv, NULL); g_test_bug_base ("http://bugzilla.openedhand.com/show_bug.cgi?id=%s"); /* Initialise the state you need to share with everything. */ - shared_state->argc_addr = &argc; - shared_state->argv_addr = &argv; + shared_state = g_new0 (TestConformSharedState, 1); + shared_state->argc_addr = argc; + shared_state->argv_addr = argv; g_assert (clutter_init (shared_state->argc_addr, shared_state->argv_addr) == CLUTTER_INIT_SUCCESS); +} + +int +main (int argc, char **argv) +{ + clutter_test_init (&argc, &argv); TEST_CONFORM_SIMPLE ("/timeline", test_timeline); TEST_CONFORM_SKIP (!g_test_slow (), "/timeline", test_timeline_interpolate); @@ -97,7 +107,6 @@ main (int argc, char **argv) TEST_CONFORM_SIMPLE ("/picking", test_pick); - /* ClutterText */ TEST_CONFORM_SIMPLE ("/text", test_text_utf8_validation); TEST_CONFORM_SIMPLE ("/text", test_text_empty); TEST_CONFORM_SIMPLE ("/text", test_text_set_empty);