From 0d95f4d854faefaf0107eda925f25fbd6de775ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 9 Jul 2020 21:28:57 +0200 Subject: [PATCH] tests/clutter: Always use stage from backend This removes all occurrences of creating a custom stage from the tests, making them always use the one from MetaBackend. This will allow for further cleanups. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1364 --- cogl/tests/conform/test-multitexture.c | 6 +- cogl/tests/conform/test-readpixels.c | 4 +- cogl/tests/conform/test-texture-mipmaps.c | 4 +- cogl/tests/conform/test-texture-pixmap-x11.c | 4 +- cogl/tests/conform/test-viewport.c | 4 +- src/tests/clutter-test-utils.c | 121 +++++++++++++++--- src/tests/clutter-test-utils.h | 16 ++- .../cally-atkcomponent-example.c | 9 +- .../cally-atkeditabletext-example.c | 9 +- .../accessibility/cally-atkevents-example.c | 13 +- .../accessibility/cally-atktext-example.c | 9 +- .../accessibility/cally-clone-example.c | 9 +- .../accessibility/cally-examples-util.c | 2 + .../accessibility/cally-examples-util.h | 2 + src/tests/clutter/accessibility/meson.build | 3 + src/tests/clutter/conform/actor-pick.c | 4 +- src/tests/clutter/conform/cally-text.c | 6 +- src/tests/clutter/conform/meson.build | 1 + src/tests/clutter/conform/text-cache.c | 6 +- src/tests/clutter/conform/texture-fbo.c | 2 +- .../clutter/conform/timeline-interpolate.c | 4 +- src/tests/clutter/conform/timeline-rewind.c | 4 +- src/tests/clutter/conform/timeline.c | 16 ++- src/tests/clutter/interactive/meson.build | 3 +- src/tests/clutter/interactive/test-actors.c | 25 ++-- .../clutter/interactive/test-animation.c | 11 +- .../interactive/test-bind-constraint.c | 11 +- .../clutter/interactive/test-binding-pool.c | 13 +- .../clutter/interactive/test-cairo-clock.c | 11 +- .../clutter/interactive/test-cairo-flowers.c | 13 +- .../interactive/test-cogl-multitexture.c | 11 +- .../clutter/interactive/test-cogl-offscreen.c | 11 +- .../interactive/test-cogl-point-sprites.c | 11 +- .../interactive/test-cogl-shader-glsl.c | 13 +- .../interactive/test-cogl-tex-convert.c | 11 +- .../interactive/test-cogl-tex-polygon.c | 11 +- .../clutter/interactive/test-cogl-tex-tile.c | 11 +- src/tests/clutter/interactive/test-content.c | 11 +- src/tests/clutter/interactive/test-devices.c | 10 +- src/tests/clutter/interactive/test-easing.c | 19 ++- src/tests/clutter/interactive/test-events.c | 11 +- src/tests/clutter/interactive/test-grab.c | 11 +- src/tests/clutter/interactive/test-image.c | 11 +- .../interactive/test-keyframe-transition.c | 11 +- src/tests/clutter/interactive/test-layout.c | 12 +- .../clutter/interactive/test-paint-wrapper.c | 25 ++-- .../interactive/test-path-constraint.c | 11 +- .../clutter/interactive/test-rotate-zoom.c | 11 +- src/tests/clutter/interactive/test-script.c | 7 +- .../clutter/interactive/test-script.json | 6 +- .../clutter/interactive/test-shader-effects.c | 10 +- .../clutter/interactive/test-stage-sizing.c | 11 +- .../clutter/interactive/test-state-script.c | 11 +- .../clutter/interactive/test-swipe-action.c | 11 +- .../clutter/interactive/test-text-field.c | 11 +- src/tests/clutter/interactive/test-text.c | 11 +- .../clutter/interactive/test-touch-events.c | 11 +- src/tests/clutter/micro-bench/meson.build | 7 +- .../clutter/micro-bench/test-cogl-perf.c | 23 ++-- src/tests/clutter/micro-bench/test-picking.c | 17 ++- .../clutter/micro-bench/test-random-text.c | 9 +- .../clutter/micro-bench/test-text-perf.c | 9 +- src/tests/clutter/micro-bench/test-text.c | 11 +- src/tests/clutter/performance/meson.build | 3 + src/tests/clutter/performance/test-common.h | 4 +- src/tests/clutter/performance/test-picking.c | 20 +-- .../clutter/performance/test-text-perf.c | 9 +- 67 files changed, 438 insertions(+), 330 deletions(-) diff --git a/cogl/tests/conform/test-multitexture.c b/cogl/tests/conform/test-multitexture.c index ba6033431..6480d921f 100644 --- a/cogl/tests/conform/test-multitexture.c +++ b/cogl/tests/conform/test-multitexture.c @@ -162,7 +162,7 @@ on_paint (ClutterActor *actor, /* Comment this out if you want visual feedback for what this test paints */ #if 1 - clutter_main_quit (); + clutter_test_quit (); #endif } @@ -191,7 +191,7 @@ test_multitexture (TestUtilsGTestFixture *fixture, clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); /* We force continuous redrawing incase someone comments out the - * clutter_main_quit and wants visual feedback for the test since we + * clutter_test_quit and wants visual feedback for the test since we * wont be doing anything else that will trigger redrawing. */ idle_source = g_idle_add (queue_redraw, stage); @@ -199,7 +199,7 @@ test_multitexture (TestUtilsGTestFixture *fixture, clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); g_clear_handle_id (&idle_source, g_source_remove); diff --git a/cogl/tests/conform/test-readpixels.c b/cogl/tests/conform/test-readpixels.c index bf2fc7887..b94c35db6 100644 --- a/cogl/tests/conform/test-readpixels.c +++ b/cogl/tests/conform/test-readpixels.c @@ -137,7 +137,7 @@ on_paint (ClutterActor *actor, /* Comment this out if you want visual feedback of what this test * paints. */ - clutter_main_quit (); + clutter_test_quit (); } static gboolean @@ -165,7 +165,7 @@ test_readpixels (TestUtilsGTestFixture *fixture, g_signal_connect_after (stage, "paint", G_CALLBACK (on_paint), NULL); clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); g_clear_handle_id (&idle_source, g_source_remove); diff --git a/cogl/tests/conform/test-texture-mipmaps.c b/cogl/tests/conform/test-texture-mipmaps.c index afcc9d246..547e6e560 100644 --- a/cogl/tests/conform/test-texture-mipmaps.c +++ b/cogl/tests/conform/test-texture-mipmaps.c @@ -92,7 +92,7 @@ on_paint (ClutterActor *actor, /* Comment this out if you want visual feedback for what this test paints */ #if 1 - clutter_main_quit (); + clutter_test_quit (); #endif } @@ -129,7 +129,7 @@ test_texture_mipmaps (TestUtilsGTestFixture *fixture, clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); g_clear_handle_id (&idle_source, g_source_remove); diff --git a/cogl/tests/conform/test-texture-pixmap-x11.c b/cogl/tests/conform/test-texture-pixmap-x11.c index 89201c133..ef1936082 100644 --- a/cogl/tests/conform/test-texture-pixmap-x11.c +++ b/cogl/tests/conform/test-texture-pixmap-x11.c @@ -183,7 +183,7 @@ on_paint (ClutterActor *actor, update_pixmap (state); else if (big_updated) /* If we successfully got the update then the test is over */ - clutter_main_quit (); + clutter_test_quit (); } state->frame_count++; @@ -226,7 +226,7 @@ test_texture_pixmap_x11 (TestUtilsGTestFixture *fixture, clutter_actor_show (state.stage); - clutter_main (); + clutter_test_main (); g_clear_signal_handler (&paint_handler, state.stage); diff --git a/cogl/tests/conform/test-viewport.c b/cogl/tests/conform/test-viewport.c index 873b035c4..56c04836f 100644 --- a/cogl/tests/conform/test-viewport.c +++ b/cogl/tests/conform/test-viewport.c @@ -375,7 +375,7 @@ on_paint (ClutterActor *actor, /* Comment this out if you want visual feedback of what this test * paints. */ - clutter_main_quit (); + clutter_test_quit (); } static gboolean @@ -403,7 +403,7 @@ test_viewport (TestUtilsGTestFixture *fixture, g_signal_connect_after (stage, "paint", G_CALLBACK (on_paint), NULL); clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); g_clear_handle_id (&idle_source, g_source_remove); diff --git a/src/tests/clutter-test-utils.c b/src/tests/clutter-test-utils.c index 6f6322735..84701e204 100644 --- a/src/tests/clutter-test-utils.c +++ b/src/tests/clutter-test-utils.c @@ -4,6 +4,8 @@ #include #include +#include "compositor/meta-plugin-manager.h" + typedef struct { gpointer dummy_field; } ClutterTestEnvironment; @@ -26,25 +28,30 @@ log_func (const gchar *log_domain, return TRUE; } -/* - * clutter_test_init: - * @argc: (inout): number of arguments in @argv - * @argv: (inout) (array length=argc) (nullable): array of arguments - * - * Initializes the Clutter test environment. - * - * Since: 1.18 - */ -void -clutter_test_init (int *argc, - char ***argv) +static const char * +test_get_plugin_name (void) { - const char *display = g_getenv ("DISPLAY"); + const char *name; + + name = g_getenv ("MUTTER_TEST_PLUGIN_PATH"); + if (name) + return name; + else + return "libdefault"; +} + +static void +init_common_pre (void) +{ + const char *display; if (G_UNLIKELY (test_environ != NULL)) g_error ("Attempting to initialize the test suite more than once, " "aborting...\n"); + meta_plugin_manager_load (test_get_plugin_name ()); + meta_test_init (); + display = g_getenv ("DISPLAY"); if (!display || *display == '\0') { @@ -57,15 +64,53 @@ clutter_test_init (int *argc, * rate, and run the master clock using a 60 fps timer instead. */ _clutter_set_sync_to_vblank (FALSE); +} - /* perform the actual initialization */ - g_assert (clutter_init (NULL, NULL) == CLUTTER_INIT_SUCCESS); - +static void +init_common_post (int *argc, + char ***argv) +{ g_test_init (argc, argv, NULL); g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=%s"); /* our global state, accessible from each test unit */ test_environ = g_new0 (ClutterTestEnvironment, 1); + + meta_start (); +} + +/* + * clutter_test_init: + * @argc: (inout): number of arguments in @argv + * @argv: (inout) (array length=argc) (nullable): array of arguments + * + * Initializes the Clutter test environment. + * + * Since: 1.18 + */ +void +clutter_test_init (int *argc, + char ***argv) +{ + init_common_pre (); + g_assert (clutter_init (NULL, NULL) == CLUTTER_INIT_SUCCESS); + init_common_post (argc, argv); +} + +void +clutter_test_init_with_args (int *argc, + char ***argv, + const char *parameter_string, + GOptionEntry *entries, + const char *translation_domain) +{ + init_common_pre (); + g_assert (clutter_init_with_args (argc, argv, + parameter_string, + entries, + translation_domain, + NULL) == CLUTTER_INIT_SUCCESS); + init_common_post (argc, argv); } /** @@ -91,17 +136,39 @@ typedef struct { GDestroyNotify test_notify; } ClutterTestData; +static gboolean +list_equal_unsorted (GList *list_a, + GList *list_b) +{ + GList *l_a; + GList *l_b; + + for (l_a = list_a, l_b = list_b; + l_a && l_b; + l_a = l_a->next, l_b = l_b->next) + { + if (l_a->data != l_b->data) + return FALSE; + } + + return !l_a && !l_b; +} + static void clutter_test_func_wrapper (gconstpointer data_) { const ClutterTestData *data = data_; ClutterActor *stage; + GList *pre_stage_children; + GList *post_stage_children; g_test_log_set_fatal_handler (log_func, NULL); /* ensure that the previous test state has been cleaned up */ stage = clutter_test_get_stage (); - g_assert_false (clutter_actor_is_mapped (stage)); + clutter_actor_hide (stage); + + pre_stage_children = clutter_actor_get_children (stage); if (data->test_data != NULL) { @@ -119,7 +186,13 @@ clutter_test_func_wrapper (gconstpointer data_) if (data->test_notify != NULL) data->test_notify (data->test_data); - clutter_actor_remove_all_children (stage); + post_stage_children = clutter_actor_get_children (stage); + + g_assert_true (list_equal_unsorted (pre_stage_children, post_stage_children)); + + g_list_free (pre_stage_children); + g_list_free (post_stage_children); + clutter_actor_hide (stage); } @@ -244,6 +317,18 @@ clutter_test_run (void) return res; } +void +clutter_test_main (void) +{ + meta_run_main_loop (); +} + +void +clutter_test_quit (void) +{ + meta_quit (META_EXIT_SUCCESS); +} + typedef struct { ClutterActor *stage; diff --git a/src/tests/clutter-test-utils.h b/src/tests/clutter-test-utils.h index 62e8e9fdc..5264f84e2 100644 --- a/src/tests/clutter-test-utils.h +++ b/src/tests/clutter-test-utils.h @@ -86,8 +86,6 @@ G_BEGIN_DECLS int \ main (int argc, char *argv[]) \ { \ - meta_test_init ();\ -\ clutter_test_init (&argc, &argv); \ \ { \ @@ -100,9 +98,23 @@ main (int argc, char *argv[]) \ CLUTTER_EXPORT void clutter_test_init (int *argc, char ***argv); + +CLUTTER_EXPORT +void clutter_test_init_with_args (int *argc, + char ***argv, + const char *parameter_string, + GOptionEntry *entries, + const char *translation_domain); + CLUTTER_EXPORT int clutter_test_run (void); +CLUTTER_EXPORT +void clutter_test_main (void); + +CLUTTER_EXPORT +void clutter_test_quit (void); + CLUTTER_EXPORT void clutter_test_add (const char *test_path, GTestFunc test_func); diff --git a/src/tests/clutter/accessibility/cally-atkcomponent-example.c b/src/tests/clutter/accessibility/cally-atkcomponent-example.c index 20401294b..4e7024597 100644 --- a/src/tests/clutter/accessibility/cally-atkcomponent-example.c +++ b/src/tests/clutter/accessibility/cally-atkcomponent-example.c @@ -40,18 +40,15 @@ main (int argc, char *argv[]) ClutterActor *group[4]; int i = 0; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; - cally_util_a11y_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkComponent Test"); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), CLUTTER_COLOR_White); clutter_actor_set_size (stage, WIDTH, HEIGHT); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); button1 = clutter_actor_new (); clutter_actor_set_background_color (button1, CLUTTER_COLOR_Yellow); @@ -92,7 +89,7 @@ main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/accessibility/cally-atkeditabletext-example.c b/src/tests/clutter/accessibility/cally-atkeditabletext-example.c index b80ec74d8..0c28ee90b 100644 --- a/src/tests/clutter/accessibility/cally-atkeditabletext-example.c +++ b/src/tests/clutter/accessibility/cally-atkeditabletext-example.c @@ -248,13 +248,10 @@ main (int argc, char *argv[]) g_set_application_name ("AtkEditableText"); - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; - cally_util_a11y_init (&argc, &argv); - stage = clutter_stage_new (); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + stage = clutter_test_get_stage (); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); make_ui (stage); @@ -263,7 +260,7 @@ main (int argc, char *argv[]) test_atk_text (text_actor); test_atk_text (text_editable_actor); - clutter_main (); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/accessibility/cally-atkevents-example.c b/src/tests/clutter/accessibility/cally-atkevents-example.c index 3c3bf2bed..3d7e67cde 100644 --- a/src/tests/clutter/accessibility/cally-atkevents-example.c +++ b/src/tests/clutter/accessibility/cally-atkevents-example.c @@ -144,9 +144,6 @@ main (int argc, char *argv[]) g_set_application_name ("AtkText"); - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; - if (cally_util_a11y_init (&argc, &argv) == FALSE) { g_error ("This example requires the accessibility support, " @@ -174,24 +171,24 @@ main (int argc, char *argv[]) atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:activate"); atk_add_global_event_listener (window_event_listener, "Atk:AtkWindow:deactivate"); - stage_main = clutter_stage_new (); + stage_main = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage_main), "Cally - AtkEvents/1"); - g_signal_connect (stage_main, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage_main, "destroy", G_CALLBACK (clutter_test_quit), NULL); make_ui (stage_main); clutter_actor_show (stage_main); if (clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE)) { - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkEvents/2"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); make_ui (stage); clutter_actor_show (stage); } - clutter_main (); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/accessibility/cally-atktext-example.c b/src/tests/clutter/accessibility/cally-atktext-example.c index 78e19c301..64a920da5 100644 --- a/src/tests/clutter/accessibility/cally-atktext-example.c +++ b/src/tests/clutter/accessibility/cally-atktext-example.c @@ -234,14 +234,11 @@ main (int argc, char *argv[]) g_set_application_name ("AtkText"); - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; - cally_util_a11y_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - AtkText Test"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); make_ui (stage); @@ -250,7 +247,7 @@ main (int argc, char *argv[]) test_atk_text (text_actor); test_atk_text (text_editable_actor); - clutter_main (); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/accessibility/cally-clone-example.c b/src/tests/clutter/accessibility/cally-clone-example.c index c234d9554..0078a9855 100644 --- a/src/tests/clutter/accessibility/cally-clone-example.c +++ b/src/tests/clutter/accessibility/cally-clone-example.c @@ -96,20 +96,17 @@ main (int argc, char *argv[]) g_set_application_name ("Clone Example"); - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; - cally_util_a11y_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cally - Clone Test"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); make_ui (stage); clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/accessibility/cally-examples-util.c b/src/tests/clutter/accessibility/cally-examples-util.c index ea3e31aa7..cf8dd8742 100644 --- a/src/tests/clutter/accessibility/cally-examples-util.c +++ b/src/tests/clutter/accessibility/cally-examples-util.c @@ -124,6 +124,8 @@ cally_util_a11y_init (int *argc, char ***argv) gchar *bridge_path = NULL; gboolean result = FALSE; + clutter_test_init (argc, argv); + if (clutter_get_accessibility_enabled () == FALSE) { g_warning ("Accessibility: clutter has no accessibility enabled" diff --git a/src/tests/clutter/accessibility/cally-examples-util.h b/src/tests/clutter/accessibility/cally-examples-util.h index dab5926cc..ea7d2c0b2 100644 --- a/src/tests/clutter/accessibility/cally-examples-util.h +++ b/src/tests/clutter/accessibility/cally-examples-util.h @@ -20,5 +20,7 @@ * Boston, MA 02111-1307, USA. */ +#include "tests/clutter-test-utils.h" + gboolean cally_util_a11y_init (int *argc, char ***argv); diff --git a/src/tests/clutter/accessibility/meson.build b/src/tests/clutter/accessibility/meson.build index fe9732efc..cf5154561 100644 --- a/src/tests/clutter/accessibility/meson.build +++ b/src/tests/clutter/accessibility/meson.build @@ -7,6 +7,7 @@ clutter_test_accessibility_c_args = [ '-DPREFIXDIR="@0@"'.format(libdir), '-DCLUTTER_DISABLE_DEPRECATION_WARNINGS', '-DGLIB_DISABLE_DEPRECATION_WARNINGS', + '-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), ] clutter_test_accessibility_c_args += clutter_debug_c_args @@ -14,6 +15,7 @@ clutter_test_accessibility_c_args += clutter_debug_c_args clutter_accessibility_tests_dependencies = [ clutter_deps, libmutter_clutter_dep, + libmutter_dep, ] clutter_accessibility_tests = [ @@ -29,6 +31,7 @@ foreach test : clutter_accessibility_tests sources: [ clutter_test_accessibility_common_sources, test + '.c', + clutter_test_utils, ], include_directories: clutter_includes, c_args: clutter_test_accessibility_c_args, diff --git a/src/tests/clutter/conform/actor-pick.c b/src/tests/clutter/conform/actor-pick.c index fff660d6d..011acec4a 100644 --- a/src/tests/clutter/conform/actor-pick.c +++ b/src/tests/clutter/conform/actor-pick.c @@ -165,7 +165,7 @@ on_timeout (gpointer data) } } - clutter_main_quit (); + clutter_test_quit (); return G_SOURCE_REMOVE; } @@ -209,7 +209,7 @@ actor_pick (void) clutter_threads_add_idle (on_timeout, &state); - clutter_main (); + clutter_test_main (); if (!g_test_quiet ()) { diff --git a/src/tests/clutter/conform/cally-text.c b/src/tests/clutter/conform/cally-text.c index 501f037ae..1644181f5 100644 --- a/src/tests/clutter/conform/cally-text.c +++ b/src/tests/clutter/conform/cally-text.c @@ -214,7 +214,7 @@ do_tests (CallbackData *data) data = data->next; } - clutter_main_quit (); + clutter_test_quit (); return FALSE; } @@ -279,7 +279,7 @@ cally_text (void) memset (&data, 0, sizeof (data)); - data.stage = clutter_stage_new (); + data.stage = clutter_test_get_stage (); data.default_attributes = default_attributes; data.run_attributes = build_attribute_set ("fg-color", "0,0,0", NULL); @@ -315,7 +315,7 @@ cally_text (void) clutter_actor_show (data.stage); clutter_threads_add_idle ((GSourceFunc) do_tests, &data); - clutter_main (); + clutter_test_main (); clutter_actor_destroy (data.stage); diff --git a/src/tests/clutter/conform/meson.build b/src/tests/clutter/conform/meson.build index e1f3449b6..387360ddf 100644 --- a/src/tests/clutter/conform/meson.build +++ b/src/tests/clutter/conform/meson.build @@ -54,6 +54,7 @@ test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) test_env.set('G_ENABLE_DIAGNOSTIC', '0') test_env.set('CLUTTER_ENABLE_DIAGNOSTIC', '0') test_env.set('CLUTTER_SCALE', '1') +test_env.set('MUTTER_TEST_PLUGIN_PATH', '@0@'.format(default_plugin.full_path())) foreach test : clutter_conform_tests test_executable = executable('@0@'.format(test), diff --git a/src/tests/clutter/conform/text-cache.c b/src/tests/clutter/conform/text-cache.c index 5dbb2991c..63d38d07d 100644 --- a/src/tests/clutter/conform/text-cache.c +++ b/src/tests/clutter/conform/text-cache.c @@ -234,7 +234,7 @@ do_tests (CallbackData *data) pango_layout_set_alignment (data->test_layout, PANGO_ALIGN_RIGHT); g_assert (check_result (data, "Change alignment", TRUE) == FALSE); - clutter_main_quit (); + clutter_test_quit (); return FALSE; } @@ -265,7 +265,7 @@ text_cache (void) memset (&data, 0, sizeof (data)); - data.stage = clutter_stage_new (); + data.stage = clutter_test_get_stage (); data.label = clutter_text_new_with_text (TEST_FONT, ""); @@ -279,7 +279,7 @@ text_cache (void) clutter_threads_add_idle ((GSourceFunc) do_tests, &data); - clutter_main (); + clutter_test_main (); clutter_actor_destroy (data.stage); diff --git a/src/tests/clutter/conform/texture-fbo.c b/src/tests/clutter/conform/texture-fbo.c index d03232a25..f8f274cb2 100644 --- a/src/tests/clutter/conform/texture-fbo.c +++ b/src/tests/clutter/conform/texture-fbo.c @@ -167,7 +167,7 @@ texture_fbo (TestConformSimpleFixture *fixture, state.frame = 0; - state.stage = clutter_stage_new (); + state.stage = clutter_test_get_stage (); clutter_actor_set_background_color (CLUTTER_ACTOR (state.stage), &stage_color); diff --git a/src/tests/clutter/conform/timeline-interpolate.c b/src/tests/clutter/conform/timeline-interpolate.c index d8a9dd818..0de7bffca 100644 --- a/src/tests/clutter/conform/timeline-interpolate.c +++ b/src/tests/clutter/conform/timeline-interpolate.c @@ -124,7 +124,7 @@ completed_cb (ClutterTimeline *timeline, if (state->completion_count == 2) { if (state->passed) - clutter_main_quit (); + clutter_test_quit (); else g_assert_not_reached (); } @@ -160,7 +160,7 @@ timeline_interpolation (void) state.start_time = g_get_real_time (); clutter_timeline_start (state.timeline); - clutter_main(); + clutter_test_main (); g_object_unref (state.timeline); } diff --git a/src/tests/clutter/conform/timeline-rewind.c b/src/tests/clutter/conform/timeline-rewind.c index e669e9e8d..aadedc5d1 100644 --- a/src/tests/clutter/conform/timeline-rewind.c +++ b/src/tests/clutter/conform/timeline-rewind.c @@ -30,7 +30,7 @@ watchdog_timeout (gpointer data) else { g_test_message ("Passed"); - clutter_main_quit (); + clutter_test_quit (); } return G_SOURCE_REMOVE; @@ -92,7 +92,7 @@ timeline_rewind (void) clutter_timeline_start (state.timeline); - clutter_main(); + clutter_test_main (); g_object_unref (state.timeline); } diff --git a/src/tests/clutter/conform/timeline.c b/src/tests/clutter/conform/timeline.c index 6cab2b3e3..5b991ef30 100644 --- a/src/tests/clutter/conform/timeline.c +++ b/src/tests/clutter/conform/timeline.c @@ -167,7 +167,7 @@ check_timeline (ClutterTimeline *timeline, static gboolean timeout_cb (gpointer data G_GNUC_UNUSED) { - clutter_main_quit (); + clutter_test_quit (); return FALSE; } @@ -181,6 +181,14 @@ delay_cb (gpointer data) return TRUE; } +static gboolean +add_timeout_idle (gpointer user_data) +{ + clutter_threads_add_timeout (2000, timeout_cb, NULL); + + return G_SOURCE_REMOVE; +} + static void timeline_base (void) { @@ -275,9 +283,9 @@ timeline_base (void) clutter_timeline_start (timeline_2); clutter_timeline_start (timeline_3); - clutter_threads_add_timeout (2000, timeout_cb, NULL); + g_idle_add (add_timeout_idle, NULL); - clutter_main (); + clutter_test_main (); g_assert (check_timeline (timeline_1, &data_1, TRUE)); g_assert (check_timeline (timeline_2, &data_2, TRUE)); @@ -300,7 +308,7 @@ timeline_base (void) clutter_threads_add_timeout (2000, timeout_cb, NULL); delay_tag = clutter_threads_add_timeout (99, delay_cb, NULL); - clutter_main (); + clutter_test_main (); g_assert (check_timeline (timeline_1, &data_1, FALSE)); g_assert (check_timeline (timeline_2, &data_2, FALSE)); diff --git a/src/tests/clutter/interactive/meson.build b/src/tests/clutter/interactive/meson.build index fc3f24350..cf5e14e01 100644 --- a/src/tests/clutter/interactive/meson.build +++ b/src/tests/clutter/interactive/meson.build @@ -55,7 +55,8 @@ clutter_interactive_test_unit_names_h = custom_target('gen-test-unit-names', clutter_tests_interactive_sources = [ 'test-main.c', clutter_interactive_test_unit_names_h, - clutter_tests_interactive_test_sources + clutter_tests_interactive_test_sources, + clutter_test_utils, ] executable('test-interactive', diff --git a/src/tests/clutter/interactive/test-actors.c b/src/tests/clutter/interactive/test-actors.c index f654d5b10..95210bf93 100644 --- a/src/tests/clutter/interactive/test-actors.c +++ b/src/tests/clutter/interactive/test-actors.c @@ -7,6 +7,7 @@ #include #include "test-utils.h" +#include "tests/clutter-test-utils.h" #define NHANDS 6 @@ -93,7 +94,7 @@ input_cb (ClutterActor *stage, if (clutter_event_get_key_symbol (event) == CLUTTER_KEY_q) { - clutter_main_quit (); + clutter_test_quit (); return TRUE; } @@ -146,7 +147,7 @@ stop_and_quit (ClutterActor *stage, { clutter_timeline_stop (data->timeline); - clutter_main_quit (); + clutter_test_quit (); } G_MODULE_EXPORT int @@ -160,22 +161,14 @@ test_actors_main (int argc, char *argv[]) error = NULL; - if (clutter_init_with_args (&argc, &argv, - NULL, - super_oh_entries, - NULL, - &error) != CLUTTER_INIT_SUCCESS) - { - g_warning ("Unable to initialise Clutter:\n%s", - error->message); - g_error_free (error); - - return EXIT_FAILURE; - } + clutter_test_init_with_args (&argc, &argv, + NULL, + super_oh_entries, + NULL); oh = g_new (SuperOH, 1); - oh->stage = clutter_stage_new (); + oh->stage = clutter_test_get_stage (); clutter_actor_set_size (oh->stage, 800, 600); clutter_actor_set_name (oh->stage, "Default Stage"); clutter_actor_set_background_color (oh->stage, CLUTTER_COLOR_LightSkyBlue); @@ -274,7 +267,7 @@ test_actors_main (int argc, char *argv[]) /* and start it */ clutter_timeline_start (oh->timeline); - clutter_main (); + clutter_test_main (); clutter_timeline_stop (oh->timeline); diff --git a/src/tests/clutter/interactive/test-animation.c b/src/tests/clutter/interactive/test-animation.c index dbd5e5876..12cea0f6d 100644 --- a/src/tests/clutter/interactive/test-animation.c +++ b/src/tests/clutter/interactive/test-animation.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + static gboolean is_expanded = FALSE; int @@ -89,13 +91,12 @@ test_animation_main (int argc, char *argv[]) ClutterActor *stage, *rect; ClutterAction *action; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_background_color (stage, CLUTTER_COLOR_LightSkyBlue); clutter_stage_set_title (CLUTTER_STAGE (stage), "Animation"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); rect = clutter_actor_new (); clutter_actor_set_background_color (rect, CLUTTER_COLOR_LightOrange); @@ -118,7 +119,7 @@ test_animation_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-bind-constraint.c b/src/tests/clutter/interactive/test-bind-constraint.c index f8df31b02..bc8da6cd6 100644 --- a/src/tests/clutter/interactive/test-bind-constraint.c +++ b/src/tests/clutter/interactive/test-bind-constraint.c @@ -1,6 +1,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define RECT_SIZE 128 #define H_PADDING 32 @@ -175,11 +177,10 @@ test_bind_constraint_main (int argc, char *argv[]) ClutterColor rect_color; gint i; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + stage = clutter_test_get_stage (); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); clutter_stage_set_title (CLUTTER_STAGE (stage), "Constraints"); clutter_actor_set_size (stage, 800, 600); @@ -251,7 +252,7 @@ test_bind_constraint_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-binding-pool.c b/src/tests/clutter/interactive/test-binding-pool.c index c9ddfe57a..3d869662c 100644 --- a/src/tests/clutter/interactive/test-binding-pool.c +++ b/src/tests/clutter/interactive/test-binding-pool.c @@ -7,6 +7,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define TYPE_KEY_GROUP (key_group_get_type ()) #define KEY_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_KEY_GROUP, KeyGroup)) #define IS_KEY_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_KEY_GROUP)) @@ -254,15 +256,14 @@ test_binding_pool_main (int argc, char *argv[]) ClutterActor *stage, *key_group; gint group_x, group_y; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Key Binding Pool"); g_signal_connect (stage, - "button-press-event", G_CALLBACK (clutter_main_quit), + "button-press-event", G_CALLBACK (clutter_test_quit), NULL); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); key_group = g_object_new (TYPE_KEY_GROUP, NULL); clutter_actor_add_child (stage, key_group); @@ -313,7 +314,7 @@ test_binding_pool_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-cairo-clock.c b/src/tests/clutter/interactive/test-cairo-clock.c index 931282b02..9f0d210bf 100644 --- a/src/tests/clutter/interactive/test-cairo-clock.c +++ b/src/tests/clutter/interactive/test-cairo-clock.c @@ -3,6 +3,8 @@ #include #include +#include "tests/clutter-test-utils.h" + int test_cairo_clock_main (int argc, char *argv[]); @@ -85,11 +87,10 @@ test_cairo_clock_main (int argc, char *argv[]) ClutterContent *canvas; /* initialize Clutter */ - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return EXIT_FAILURE; + clutter_test_init (&argc, &argv); /* create a resizable stage */ - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "2D Clock"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_LightSkyBlue); clutter_actor_set_size (stage, 300, 300); @@ -101,7 +102,7 @@ test_cairo_clock_main (int argc, char *argv[]) clutter_actor_set_content (stage, canvas); /* quit on destroy */ - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); /* connect our drawing code */ g_signal_connect (canvas, "draw", G_CALLBACK (draw_clock), NULL); @@ -112,7 +113,7 @@ test_cairo_clock_main (int argc, char *argv[]) /* set up a timer that invalidates the canvas every second */ clutter_threads_add_timeout (1000, invalidate_clock, canvas); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-cairo-flowers.c b/src/tests/clutter/interactive/test-cairo-flowers.c index 62393d1e2..5cfce9a41 100644 --- a/src/tests/clutter/interactive/test-cairo-flowers.c +++ b/src/tests/clutter/interactive/test-cairo-flowers.c @@ -3,6 +3,8 @@ */ #include +#include "tests/clutter-test-utils.h" + #ifndef _MSC_VER #include /* for sleep(), used for screenshots */ #endif @@ -194,7 +196,7 @@ stop_and_quit (ClutterActor *actor, ClutterTimeline *timeline) { clutter_timeline_stop (timeline); - clutter_main_quit (); + clutter_test_quit (); } G_MODULE_EXPORT int @@ -206,10 +208,9 @@ test_cairo_flowers_main (int argc, char **argv) srand (time (NULL)); - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cairo Flowers"); /* Create a timeline to manage animation */ @@ -243,10 +244,10 @@ test_cairo_flowers_main (int argc, char **argv) clutter_timeline_start (timeline); g_signal_connect (stage, "key-press-event", - G_CALLBACK (clutter_main_quit), + G_CALLBACK (clutter_test_quit), NULL); - clutter_main(); + clutter_test_main (); g_object_unref (timeline); diff --git a/src/tests/clutter/interactive/test-cogl-multitexture.c b/src/tests/clutter/interactive/test-cogl-multitexture.c index 00bd30f92..4805d90fe 100644 --- a/src/tests/clutter/interactive/test-cogl-multitexture.c +++ b/src/tests/clutter/interactive/test-cogl-multitexture.c @@ -9,6 +9,8 @@ #include #include +#include "tests/clutter-test-utils.h" + typedef struct _TestMultiLayerMaterialState { ClutterActor *group; @@ -123,16 +125,15 @@ test_cogl_multitexture_main (int argc, char *argv[]) 0, 0, 1, 1 }; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_get_size (stage, &stage_w, &stage_h); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl: Multi-texturing"); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), &stage_color); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); /* We create a non-descript actor that we know doesn't have a * default paint handler, so that we can easily control @@ -229,7 +230,7 @@ test_cogl_multitexture_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main(); + clutter_test_main (); cogl_object_unref (state->material1); cogl_object_unref (state->material0); diff --git a/src/tests/clutter/interactive/test-cogl-offscreen.c b/src/tests/clutter/interactive/test-cogl-offscreen.c index 10c0432bd..8580fb45a 100644 --- a/src/tests/clutter/interactive/test-cogl-offscreen.c +++ b/src/tests/clutter/interactive/test-cogl-offscreen.c @@ -4,6 +4,8 @@ #include #include +#include "tests/clutter-test-utils.h" + /* Coglbox declaration *--------------------------------------------------*/ @@ -318,14 +320,13 @@ test_cogl_offscreen_main (int argc, char *argv[]) ClutterActor *stage; ClutterActor *coglbox; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); /* Stage */ - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Offscreen Buffers"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); /* Cogl Box */ coglbox = test_coglbox_new (); @@ -333,7 +334,7 @@ test_cogl_offscreen_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/interactive/test-cogl-point-sprites.c b/src/tests/clutter/interactive/test-cogl-point-sprites.c index 4ee0615eb..6d4326470 100644 --- a/src/tests/clutter/interactive/test-cogl-point-sprites.c +++ b/src/tests/clutter/interactive/test-cogl-point-sprites.c @@ -4,6 +4,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define N_FIREWORKS 32 /* Units per second per second */ #define GRAVITY -1.5f @@ -219,8 +221,7 @@ test_cogl_point_sprites_main (int argc, char *argv[]) GError *error = NULL; int i; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return EXIT_FAILURE; + clutter_test_init (&argc, &argv); data.material = cogl_material_new (); data.last_spark_time = g_timer_new (); @@ -253,17 +254,17 @@ test_cogl_point_sprites_main (int argc, char *argv[]) data.sparks[i].y = 2.0f; } - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), CLUTTER_COLOR_Black); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Point Sprites"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); g_signal_connect_after (stage, "paint", G_CALLBACK (paint_cb), &data); clutter_actor_show (stage); clutter_threads_add_idle (idle_cb, stage); - clutter_main (); + clutter_test_main (); cogl_object_unref (data.material); g_timer_destroy (data.last_spark_time); diff --git a/src/tests/clutter/interactive/test-cogl-shader-glsl.c b/src/tests/clutter/interactive/test-cogl-shader-glsl.c index ddea678ee..b25789e06 100644 --- a/src/tests/clutter/interactive/test-cogl-shader-glsl.c +++ b/src/tests/clutter/interactive/test-cogl-shader-glsl.c @@ -5,6 +5,8 @@ #include #include +#include "tests/clutter-test-utils.h" + typedef struct { const char *name; @@ -261,7 +263,7 @@ key_release_cb (ClutterActor *actor, if (keysym == CLUTTER_KEY_q || ((mods & CLUTTER_SHIFT_MASK) && keysym == CLUTTER_KEY_q)) - clutter_main_quit (); + clutter_test_quit (); return CLUTTER_EVENT_STOP; } @@ -291,7 +293,7 @@ destroy_window_cb (ClutterStage *stage, ClutterEvent *event, gpointer user_data) { - clutter_main_quit (); + clutter_test_quit (); return CLUTTER_EVENT_STOP; } @@ -304,10 +306,9 @@ test_cogl_shader_glsl_main (int argc, char *argv[]) GError *error; ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Assembly Shader Test"); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), &stage_color); @@ -342,7 +343,7 @@ test_cogl_shader_glsl_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-cogl-tex-convert.c b/src/tests/clutter/interactive/test-cogl-tex-convert.c index 73f848ac7..c098ff6a3 100644 --- a/src/tests/clutter/interactive/test-cogl-tex-convert.c +++ b/src/tests/clutter/interactive/test-cogl-tex-convert.c @@ -4,6 +4,8 @@ #include #include +#include "tests/clutter-test-utils.h" + /* Coglbox declaration *--------------------------------------------------*/ @@ -217,14 +219,13 @@ test_cogl_tex_convert_main (int argc, char *argv[]) ClutterActor *stage; ClutterActor *coglbox; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); /* Stage */ - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Texture Conversion"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); /* Cogl Box */ coglbox = test_coglbox_new (); @@ -232,7 +233,7 @@ test_cogl_tex_convert_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/interactive/test-cogl-tex-polygon.c b/src/tests/clutter/interactive/test-cogl-tex-polygon.c index 5bd47a153..77e8feccd 100644 --- a/src/tests/clutter/interactive/test-cogl-tex-polygon.c +++ b/src/tests/clutter/interactive/test-cogl-tex-polygon.c @@ -4,6 +4,8 @@ #include #include +#include "tests/clutter-test-utils.h" + /* Coglbox declaration *--------------------------------------------------*/ @@ -394,15 +396,14 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) ClutterTimeline *timeline; ClutterColor blue = { 0x30, 0x30, 0xff, 0xff }; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); /* Stage */ - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), &blue); clutter_actor_set_size (stage, 640, 480); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Texture Polygon"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); /* Cogl Box */ coglbox = test_coglbox_new (); @@ -442,7 +443,7 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/interactive/test-cogl-tex-tile.c b/src/tests/clutter/interactive/test-cogl-tex-tile.c index d012df6fc..d51522491 100644 --- a/src/tests/clutter/interactive/test-cogl-tex-tile.c +++ b/src/tests/clutter/interactive/test-cogl-tex-tile.c @@ -5,6 +5,8 @@ #include #include +#include "tests/clutter-test-utils.h" + /* Coglbox declaration *--------------------------------------------------*/ @@ -201,14 +203,13 @@ test_cogl_tex_tile_main (int argc, char *argv[]) ClutterActor *coglbox; ClutterTimeline *timeline; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); /* Stage */ - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Texture Tiling"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); /* Cogl Box */ coglbox = test_coglbox_new (); @@ -222,7 +223,7 @@ test_cogl_tex_tile_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/interactive/test-content.c b/src/tests/clutter/interactive/test-content.c index ede6db591..fbeebaba3 100644 --- a/src/tests/clutter/interactive/test-content.c +++ b/src/tests/clutter/interactive/test-content.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + typedef struct _ColorContent { GObject parent_instance; @@ -176,13 +178,12 @@ test_content_main (int argc, char *argv[]) ClutterContent *content; int i, n_rects; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return EXIT_FAILURE; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_name (stage, "Stage"); clutter_stage_set_title (CLUTTER_STAGE (stage), "Content"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); clutter_actor_show (stage); grid = clutter_actor_new (); @@ -227,7 +228,7 @@ test_content_main (int argc, char *argv[]) clutter_actor_add_child (grid, box); } - clutter_main (); + clutter_test_main (); g_object_unref (content); diff --git a/src/tests/clutter/interactive/test-devices.c b/src/tests/clutter/interactive/test-devices.c index 191252ff0..606babdf4 100644 --- a/src/tests/clutter/interactive/test-devices.c +++ b/src/tests/clutter/interactive/test-devices.c @@ -7,6 +7,7 @@ #endif #include "test-utils.h" +#include "tests/clutter-test-utils.h" typedef struct { ClutterActor *stage; @@ -218,17 +219,16 @@ test_devices_main (int argc, char **argv) ClutterSeat *seat; GList *stage_devices, *l; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); app = g_new0 (TestDevicesApp, 1); app->devices = g_hash_table_new (g_direct_hash, g_direct_equal) ; - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_background_color (stage, CLUTTER_COLOR_LightSkyBlue); clutter_stage_set_title (CLUTTER_STAGE (stage), "Devices"); g_signal_connect (stage, - "destroy", G_CALLBACK (clutter_main_quit), + "destroy", G_CALLBACK (clutter_test_quit), NULL); g_signal_connect (stage, "motion-event", G_CALLBACK (stage_motion_event_cb), @@ -286,7 +286,7 @@ test_devices_main (int argc, char **argv) g_list_free (stage_devices); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-easing.c b/src/tests/clutter/interactive/test-easing.c index 7459cc1e1..0fa42c713 100644 --- a/src/tests/clutter/interactive/test-easing.c +++ b/src/tests/clutter/interactive/test-easing.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + /* all the easing modes provided by Clutter */ static const struct { const gchar *name; @@ -222,19 +224,16 @@ test_easing_main (int argc, char *argv[]) ClutterActor *stage, *rect, *label; gchar *text; gfloat stage_width, stage_height; - GError *error = NULL; - if (clutter_init_with_args (&argc, &argv, - NULL, - test_easing_entries, - NULL, - &error) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init_with_args (&argc, &argv, + NULL, + test_easing_entries, + NULL); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Easing Modes"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_LightSkyBlue); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); main_stage = stage; clutter_actor_get_size (stage, &stage_width, &stage_height); @@ -264,7 +263,7 @@ test_easing_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-events.c b/src/tests/clutter/interactive/test-events.c index bb93978d9..1700def39 100644 --- a/src/tests/clutter/interactive/test-events.c +++ b/src/tests/clutter/interactive/test-events.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + gboolean IsMotion = TRUE; int @@ -393,13 +395,12 @@ test_events_main (int argc, char *argv[]) { ClutterActor *stage, *actor, *focus_box, *group; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Events"); clutter_actor_set_name (stage, "Stage"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); g_signal_connect (stage, "event", G_CALLBACK (input_cb), (char *) "stage"); g_signal_connect (stage, "activate", G_CALLBACK (stage_state_cb), (char *) "activate"); @@ -481,7 +482,7 @@ test_events_main (int argc, char *argv[]) clutter_actor_show (CLUTTER_ACTOR (stage)); - clutter_main(); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/interactive/test-grab.c b/src/tests/clutter/interactive/test-grab.c index fb00e7b00..4127d3e80 100644 --- a/src/tests/clutter/interactive/test-grab.c +++ b/src/tests/clutter/interactive/test-grab.c @@ -1,6 +1,8 @@ #include #include +#include "tests/clutter-test-utils.h" + int test_grab_main (int argc, char *argv[]); @@ -213,8 +215,7 @@ test_grab_main (int argc, char *argv[]) ccol = { 0, 0xff, 0xff, 0xff }, ycol = { 0xff, 0xff, 0, 0xff }; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); g_print ("Red box: aquire grab on press, releases it on next button release\n"); g_print ("Blue box: aquire grab on press, destroys the blue box actor on release\n"); @@ -222,9 +223,9 @@ test_grab_main (int argc, char *argv[]) g_print ("Green box: toggle per actor motion events.\n\n"); g_print ("Cyan box: toggle grab (from cyan box) for keyboard events.\n\n"); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Grabs"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); g_signal_connect (stage, "event", G_CALLBACK (debug_event_cb), (char *) "stage"); g_signal_connect (stage, "activate", @@ -292,7 +293,7 @@ test_grab_main (int argc, char *argv[]) clutter_actor_show (CLUTTER_ACTOR (stage)); - clutter_main(); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/interactive/test-image.c b/src/tests/clutter/interactive/test-image.c index 81fd3c36d..11c07e64b 100644 --- a/src/tests/clutter/interactive/test-image.c +++ b/src/tests/clutter/interactive/test-image.c @@ -3,6 +3,8 @@ #include #include +#include "tests/clutter-test-utils.h" + typedef struct _SolidContent { GObject parent_instance; @@ -184,13 +186,12 @@ test_image_main (int argc, char *argv[]) GdkPixbuf *pixbuf; int i, n_rects; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return EXIT_FAILURE; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_name (stage, "Stage"); clutter_stage_set_title (CLUTTER_STAGE (stage), "Content"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); clutter_actor_show (stage); grid = clutter_actor_new (); @@ -251,7 +252,7 @@ test_image_main (int argc, char *argv[]) clutter_actor_add_child (grid, box); } - clutter_main (); + clutter_test_main (); g_object_unref (color); g_object_unref (image); diff --git a/src/tests/clutter/interactive/test-keyframe-transition.c b/src/tests/clutter/interactive/test-keyframe-transition.c index ec5d0c5b5..3deabc2f7 100644 --- a/src/tests/clutter/interactive/test-keyframe-transition.c +++ b/src/tests/clutter/interactive/test-keyframe-transition.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + static const ClutterColor colors[] = { { 255, 0, 0, 255 }, { 0, 255, 0, 255 }, @@ -40,12 +42,11 @@ test_keyframe_transition_main (int argc, char *argv[]) ClutterActor *stage; int i; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return EXIT_FAILURE; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Keyframe Transitions"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); for (i = 0; i < 3; i++) { @@ -108,7 +109,7 @@ test_keyframe_transition_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-layout.c b/src/tests/clutter/interactive/test-layout.c index 97ef4fad9..ce8202cfd 100644 --- a/src/tests/clutter/interactive/test-layout.c +++ b/src/tests/clutter/interactive/test-layout.c @@ -6,6 +6,7 @@ #include #include "test-utils.h" +#include "tests/clutter-test-utils.h" /* layout actor, by Lucas Rocha */ @@ -497,7 +498,7 @@ keypress_cb (ClutterActor *actor, switch (clutter_event_get_key_symbol (event)) { case CLUTTER_KEY_q: - clutter_main_quit (); + clutter_test_quit (); break; case CLUTTER_KEY_a: @@ -599,13 +600,12 @@ test_layout_main (int argc, char *argv[]) gint i, size; GError *error = NULL; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_size (stage, 800, 600); clutter_stage_set_title (CLUTTER_STAGE (stage), "Layout"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); main_timeline = clutter_timeline_new_for_actor (stage, 2000); clutter_timeline_set_repeat_count (main_timeline, -1); @@ -670,7 +670,7 @@ test_layout_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); g_object_unref (main_timeline); diff --git a/src/tests/clutter/interactive/test-paint-wrapper.c b/src/tests/clutter/interactive/test-paint-wrapper.c index 038226d07..c42573cc5 100644 --- a/src/tests/clutter/interactive/test-paint-wrapper.c +++ b/src/tests/clutter/interactive/test-paint-wrapper.c @@ -16,6 +16,7 @@ #endif #include "test-utils.h" +#include "tests/clutter-test-utils.h" #define NHANDS 6 @@ -87,7 +88,7 @@ input_cb (ClutterActor *stage, if (clutter_event_get_key_symbol (event) == CLUTTER_KEY_q) { - clutter_main_quit (); + clutter_test_quit (); return TRUE; } @@ -197,7 +198,7 @@ stop_and_quit (ClutterActor *actor, g_clear_signal_handler (&oh->frame_id, oh->timeline); clutter_timeline_stop (oh->timeline); - clutter_main_quit (); + clutter_test_quit (); } G_MODULE_EXPORT int @@ -212,22 +213,14 @@ test_paint_wrapper_main (int argc, char *argv[]) error = NULL; - if (clutter_init_with_args (&argc, &argv, - NULL, - super_oh_entries, - NULL, - &error) != CLUTTER_INIT_SUCCESS) - { - g_warning ("Unable to initialise Clutter:\n%s", - error->message); - g_error_free (error); - - return EXIT_FAILURE; - } + clutter_test_init_with_args (&argc, &argv, + NULL, + super_oh_entries, + NULL); oh = g_new(SuperOH, 1); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_size (stage, 800, 600); clutter_stage_set_title (CLUTTER_STAGE (stage), "Paint Test"); @@ -329,7 +322,7 @@ test_paint_wrapper_main (int argc, char *argv[]) /* and start it */ clutter_timeline_start (oh->timeline); - clutter_main (); + clutter_test_main (); g_object_unref (oh->timeline); g_free (oh->paint_guards); diff --git a/src/tests/clutter/interactive/test-path-constraint.c b/src/tests/clutter/interactive/test-path-constraint.c index de6a70b82..baa1ea790 100644 --- a/src/tests/clutter/interactive/test-path-constraint.c +++ b/src/tests/clutter/interactive/test-path-constraint.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define PATH_DESCRIPTION \ "M 0, 0 " \ "L 0, 300 " \ @@ -106,12 +108,11 @@ test_path_constraint_main (int argc, ClutterPath *path; ClutterColor rect_color = { 0xcc, 0x00, 0x00, 0xff }; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Path Constraint"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); path = clutter_path_new (); clutter_path_set_description (path, PATH_DESCRIPTION); @@ -131,7 +132,7 @@ test_path_constraint_main (int argc, clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-rotate-zoom.c b/src/tests/clutter/interactive/test-rotate-zoom.c index 071e454b3..f21492158 100644 --- a/src/tests/clutter/interactive/test-rotate-zoom.c +++ b/src/tests/clutter/interactive/test-rotate-zoom.c @@ -23,6 +23,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define STAGE_WIDTH 800 #define STAGE_HEIGHT 550 @@ -66,12 +68,11 @@ test_rotate_zoom_main (int argc, char *argv[]) gfloat width, height; /* initialize Clutter */ - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return EXIT_FAILURE; + clutter_test_init (&argc, &argv); /* create a resizable stage */ - stage = clutter_stage_new (); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + stage = clutter_test_get_stage (); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); clutter_stage_set_title (CLUTTER_STAGE (stage), "Rotate and Zoom actions"); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); clutter_actor_set_reactive (stage, FALSE); @@ -87,7 +88,7 @@ test_rotate_zoom_main (int argc, char *argv[]) STAGE_WIDTH / 2 - width / 2, STAGE_HEIGHT / 2 - height / 2); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-script.c b/src/tests/clutter/interactive/test-script.c index ea881c237..e15ff32b4 100644 --- a/src/tests/clutter/interactive/test-script.c +++ b/src/tests/clutter/interactive/test-script.c @@ -7,6 +7,8 @@ #include #include +#include "tests/clutter-test-utils.h" + static ClutterScript *script = NULL; static guint merge_id = 0; @@ -84,8 +86,7 @@ test_script_main (int argc, char *argv[]) gchar *file; gint res; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); script = clutter_script_new (); g_assert (CLUTTER_IS_SCRIPT (script)); @@ -145,7 +146,7 @@ test_script_main (int argc, char *argv[]) G_CALLBACK (blue_button_press), NULL); - clutter_main (); + clutter_test_main (); g_object_unref (script); diff --git a/src/tests/clutter/interactive/test-script.json b/src/tests/clutter/interactive/test-script.json index 07cf21b06..b958315ae 100644 --- a/src/tests/clutter/interactive/test-script.json +++ b/src/tests/clutter/interactive/test-script.json @@ -5,8 +5,8 @@ "title" : { "translatable" : true, "string" : "ClutterScript test" }, "color" : "white", "signals" : [ - { "name" : "key-press-event", "handler" : "clutter_main_quit" }, - { "name" : "destroy", "handler" : "clutter_main_quit" } + { "name" : "key-press-event", "handler" : "clutter_test_quit" }, + { "name" : "destroy", "handler" : "clutter_test_quit" } ], "children" : [ { @@ -30,7 +30,7 @@ "depth" : -200.0, "reactive" : true, "signals" : [ - { "name" : "button-press-event", "handler" : "clutter_main_quit" } + { "name" : "button-press-event", "handler" : "clutter_test_quit" } ] }, { diff --git a/src/tests/clutter/interactive/test-shader-effects.c b/src/tests/clutter/interactive/test-shader-effects.c index 9c5db6a34..992587c58 100644 --- a/src/tests/clutter/interactive/test-shader-effects.c +++ b/src/tests/clutter/interactive/test-shader-effects.c @@ -7,6 +7,7 @@ #include #include "test-utils.h" +#include "tests/clutter-test-utils.h" int test_shader_effects_main (int argc, char *argv[]); @@ -18,13 +19,12 @@ test_shader_effects_main (int argc, char *argv[]) ClutterActor *stage, *hand, *label, *rect; gchar *file; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Rotations"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_Aluminium3); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); /* Make a timeline */ timeline = clutter_timeline_new_for_actor (stage, 7692); @@ -80,7 +80,7 @@ test_shader_effects_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main(); + clutter_test_main (); g_object_unref (timeline); diff --git a/src/tests/clutter/interactive/test-stage-sizing.c b/src/tests/clutter/interactive/test-stage-sizing.c index c4fedb956..020b4be86 100644 --- a/src/tests/clutter/interactive/test-stage-sizing.c +++ b/src/tests/clutter/interactive/test-stage-sizing.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + int test_stage_sizing_main (int argc, char *argv[]); @@ -32,12 +34,11 @@ test_stage_sizing_main (int argc, char *argv[]) ClutterActor *stage, *rect, *label, *box; ClutterMargin margin = { 12.f, 12.f, 6.f, 6.f }; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Stage Sizing"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); box = clutter_actor_new (); clutter_actor_set_layout_manager (box, clutter_box_layout_new ()); @@ -76,7 +77,7 @@ test_stage_sizing_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-state-script.c b/src/tests/clutter/interactive/test-state-script.c index 66b54b092..5905704f0 100644 --- a/src/tests/clutter/interactive/test-state-script.c +++ b/src/tests/clutter/interactive/test-state-script.c @@ -4,6 +4,8 @@ #include +#include "tests/clutter-test-utils.h" + #define TEST_STATE_SCRIPT_FILE "test-script-signals.json" int @@ -16,8 +18,7 @@ test_state_script_main (int argc, char *argv[]) ClutterScript *script; GError *error = NULL; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return EXIT_FAILURE; + clutter_test_init (&argc, &argv); script = clutter_script_new (); clutter_script_load_from_file (script, TEST_STATE_SCRIPT_FILE, &error); @@ -26,9 +27,9 @@ test_state_script_main (int argc, char *argv[]) TEST_STATE_SCRIPT_FILE, error->message); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "State Script"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); clutter_actor_show (stage); button = CLUTTER_ACTOR (clutter_script_get_object (script, "button")); @@ -37,7 +38,7 @@ test_state_script_main (int argc, char *argv[]) clutter_script_connect_signals (script, NULL); - clutter_main (); + clutter_test_main (); g_object_unref (script); diff --git a/src/tests/clutter/interactive/test-swipe-action.c b/src/tests/clutter/interactive/test-swipe-action.c index 546185590..d160ff288 100644 --- a/src/tests/clutter/interactive/test-swipe-action.c +++ b/src/tests/clutter/interactive/test-swipe-action.c @@ -1,6 +1,8 @@ #include #include +#include "tests/clutter-test-utils.h" + enum { VERTICAL = 0, @@ -115,13 +117,12 @@ test_swipe_action_main (int argc, char *argv[]) { ClutterActor *stage, *rect; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Swipe action"); clutter_actor_set_size (stage, 640, 480); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); rect = clutter_actor_new (); clutter_actor_set_background_color (rect, CLUTTER_COLOR_Red); @@ -186,7 +187,7 @@ test_swipe_action_main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-text-field.c b/src/tests/clutter/interactive/test-text-field.c index 34d9f00c1..a145b6758 100644 --- a/src/tests/clutter/interactive/test-text-field.c +++ b/src/tests/clutter/interactive/test-text-field.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + gint test_text_field_main (gint argc, gchar **argv); @@ -257,13 +259,12 @@ test_text_field_main (gint argc, ClutterLayoutManager *grid; PangoAttrList *entry_attrs; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return EXIT_FAILURE; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Text Fields"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_Black); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); grid = clutter_grid_layout_new (); clutter_grid_layout_set_column_spacing (CLUTTER_GRID_LAYOUT (grid), 6); @@ -321,7 +322,7 @@ test_text_field_main (gint argc, clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-text.c b/src/tests/clutter/interactive/test-text.c index bbe2a1b4e..308482d73 100644 --- a/src/tests/clutter/interactive/test-text.c +++ b/src/tests/clutter/interactive/test-text.c @@ -3,6 +3,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define FONT "Mono Bold 24px" static const gchar *runes = @@ -27,13 +29,12 @@ test_text_main (gint argc, ClutterColor cursor_color = { 0xff, 0x33, 0x33, 0xff }; ClutterTextBuffer *buffer; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Text Editing"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_Black); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); buffer = clutter_text_buffer_new_with_text ("ยท", -1); @@ -89,7 +90,7 @@ test_text_main (gint argc, clutter_actor_set_size (stage, 1024, 768); clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); return EXIT_SUCCESS; } diff --git a/src/tests/clutter/interactive/test-touch-events.c b/src/tests/clutter/interactive/test-touch-events.c index 88e9a2cbc..6dd2befa3 100644 --- a/src/tests/clutter/interactive/test-touch-events.c +++ b/src/tests/clutter/interactive/test-touch-events.c @@ -22,6 +22,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define STAGE_WIDTH 800 #define STAGE_HEIGHT 550 #define NUM_COLORS 10 @@ -125,12 +127,11 @@ test_touch_events_main (int argc, char *argv[]) int i; /* initialize Clutter */ - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return EXIT_FAILURE; + clutter_test_init (&argc, &argv); /* create a resizable stage */ - stage = clutter_stage_new (); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + stage = clutter_test_get_stage (); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); clutter_stage_set_title (CLUTTER_STAGE (stage), "Touch events"); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); clutter_actor_set_reactive (stage, TRUE); @@ -167,7 +168,7 @@ test_touch_events_main (int argc, char *argv[]) sequence_to_color = g_hash_table_new (NULL, NULL); - clutter_main (); + clutter_test_main (); g_queue_foreach (&all_events, (GFunc) clutter_event_free, NULL); g_queue_clear (&events); diff --git a/src/tests/clutter/micro-bench/meson.build b/src/tests/clutter/micro-bench/meson.build index b8fe1e794..4c2b3b803 100644 --- a/src/tests/clutter/micro-bench/meson.build +++ b/src/tests/clutter/micro-bench/meson.build @@ -3,6 +3,7 @@ clutter_tests_micro_bench_c_args = [ '-DGLIB_DISABLE_DEPRECATION_WARNINGS', '-DCOGL_DISABLE_DEPRECATION_WARNINGS', '-DCLUTTER_DISABLE_DEPRECATION_WARNINGS', + '-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), ] clutter_tests_micro_bench_c_args += clutter_debug_c_args @@ -16,12 +17,16 @@ clutter_tests_micro_bench_tests = [ foreach test : clutter_tests_micro_bench_tests executable(test, - sources: '@0@.c'.format(test), + sources: [ + '@0@.c'.format(test), + clutter_test_utils, + ], include_directories: clutter_includes, c_args: clutter_tests_micro_bench_c_args, dependencies: [ clutter_deps, libmutter_clutter_dep, + libmutter_dep, ], install: false, ) diff --git a/src/tests/clutter/micro-bench/test-cogl-perf.c b/src/tests/clutter/micro-bench/test-cogl-perf.c index 68b3802ff..1b2c29bbc 100644 --- a/src/tests/clutter/micro-bench/test-cogl-perf.c +++ b/src/tests/clutter/micro-bench/test-cogl-perf.c @@ -6,6 +6,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define STAGE_WIDTH 800 #define STAGE_HEIGHT 600 @@ -130,27 +132,18 @@ main (int argc, char *argv[]) { TestState state; ClutterActor *stage; - GError *error = NULL; g_setenv ("CLUTTER_VBLANK", "none", FALSE); g_setenv ("CLUTTER_SHOW_FPS", "1", FALSE); - if (clutter_init_with_args (&argc, &argv, - NULL, - entries, - NULL, - &error) != CLUTTER_INIT_SUCCESS) - { - g_warning ("Unable to initialise Clutter:\n%s", - error->message); - g_error_free (error); - - return EXIT_FAILURE; - } + clutter_test_init_with_args (&argc, &argv, + NULL, + entries, + NULL); state.current_test = 0; - state.stage = stage = clutter_stage_new (); + state.stage = stage = clutter_test_get_stage (); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), CLUTTER_COLOR_White); @@ -163,7 +156,7 @@ main (int argc, char *argv[]) clutter_actor_show (stage); - clutter_main (); + clutter_test_main (); clutter_actor_destroy (stage); diff --git a/src/tests/clutter/micro-bench/test-picking.c b/src/tests/clutter/micro-bench/test-picking.c index 7150bb0a0..c1efa0453 100644 --- a/src/tests/clutter/micro-bench/test-picking.c +++ b/src/tests/clutter/micro-bench/test-picking.c @@ -3,6 +3,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define N_ACTORS 100 #define N_EVENTS 5 @@ -76,20 +78,17 @@ main (int argc, char **argv) gdouble angle; ClutterColor color = { 0x00, 0x00, 0x00, 0xff }; ClutterActor *stage, *rect; - GError *error = NULL; g_setenv ("CLUTTER_VBLANK", "none", FALSE); g_setenv ("CLUTTER_DEFAULT_FPS", "1000", FALSE); g_setenv ("CLUTTER_SHOW_FPS", "1", FALSE); - if (clutter_init_with_args (&argc, &argv, - NULL, - entries, - NULL, - &error) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init_with_args (&argc, &argv, + NULL, + entries, + NULL); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_size (stage, 512, 512); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), CLUTTER_COLOR_Black); clutter_stage_set_title (CLUTTER_STAGE (stage), "Picking"); @@ -132,7 +131,7 @@ main (int argc, char **argv) g_signal_connect (stage, "paint", G_CALLBACK (on_paint), NULL); - clutter_main (); + clutter_test_main (); clutter_actor_destroy (stage); diff --git a/src/tests/clutter/micro-bench/test-random-text.c b/src/tests/clutter/micro-bench/test-random-text.c index 69eb6d018..c5612924f 100644 --- a/src/tests/clutter/micro-bench/test-random-text.c +++ b/src/tests/clutter/micro-bench/test-random-text.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define MAX_TEXT_LEN 10 #define MIN_FONT_SIZE 10 #define MAX_FONT_SIZE 30 @@ -87,17 +89,16 @@ main (int argc, char *argv[]) { ClutterActor *stage; - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Random Text"); clutter_actor_show (stage); clutter_threads_add_idle (on_idle, stage); - clutter_main (); + clutter_test_main (); clutter_actor_destroy (stage); diff --git a/src/tests/clutter/micro-bench/test-text-perf.c b/src/tests/clutter/micro-bench/test-text-perf.c index 9e72656b2..38e8b9540 100644 --- a/src/tests/clutter/micro-bench/test-text-perf.c +++ b/src/tests/clutter/micro-bench/test-text-perf.c @@ -3,6 +3,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define STAGE_WIDTH 800 #define STAGE_HEIGHT 600 @@ -115,8 +117,7 @@ main (int argc, char *argv[]) g_setenv ("CLUTTER_VBLANK", "none", FALSE); g_setenv ("CLUTTER_DEFAULT_FPS", "1000", FALSE); - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); if (argc != 3) { @@ -129,7 +130,7 @@ main (int argc, char *argv[]) g_print ("Monospace %dpx, string length = %d\n", font_size, n_chars); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), CLUTTER_COLOR_Black); clutter_stage_set_title (CLUTTER_STAGE (stage), "Text Performance"); @@ -183,7 +184,7 @@ main (int argc, char *argv[]) clutter_threads_add_idle (queue_redraw, stage); - clutter_main (); + clutter_test_main (); return 0; } diff --git a/src/tests/clutter/micro-bench/test-text.c b/src/tests/clutter/micro-bench/test-text.c index d62967f09..94c90acf0 100644 --- a/src/tests/clutter/micro-bench/test-text.c +++ b/src/tests/clutter/micro-bench/test-text.c @@ -3,6 +3,8 @@ #include #include +#include "tests/clutter-test-utils.h" + #define STAGE_WIDTH 640 #define STAGE_HEIGHT 480 @@ -50,10 +52,9 @@ main (int argc, char *argv[]) g_setenv ("CLUTTER_VBLANK", "none", FALSE); g_setenv ("CLUTTER_DEFAULT_FPS", "1000", FALSE); - if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) - return 1; + clutter_test_init (&argc, &argv); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), CLUTTER_COLOR_Black); clutter_stage_set_title (CLUTTER_STAGE (stage), "Text"); @@ -112,9 +113,9 @@ main (int argc, char *argv[]) clutter_actor_show (stage); g_signal_connect (stage, "key-press-event", - G_CALLBACK (clutter_main_quit), NULL); + G_CALLBACK (clutter_test_quit), NULL); - clutter_main(); + clutter_test_main (); clutter_actor_destroy (stage); diff --git a/src/tests/clutter/performance/meson.build b/src/tests/clutter/performance/meson.build index a8eef886b..b1d8bd516 100644 --- a/src/tests/clutter/performance/meson.build +++ b/src/tests/clutter/performance/meson.build @@ -4,6 +4,7 @@ clutter_tests_performance_c_args = [ '-DGLIB_DISABLE_DEPRECATION_WARNINGS', '-DCOGL_DISABLE_DEPRECATION_WARNINGS', '-DCLUTTER_DISABLE_DEPRECATION_WARNINGS', + '-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), ] clutter_tests_performance_c_args += clutter_debug_c_args @@ -18,6 +19,7 @@ foreach test : clutter_tests_performance_tests sources: [ '@0@.c'.format(test), 'test-common.h', + clutter_test_utils, ], include_directories: [ clutter_includes, @@ -27,6 +29,7 @@ foreach test : clutter_tests_performance_tests dependencies: [ clutter_deps, libmutter_clutter_dep, + libmutter_dep, ], install: false, ) diff --git a/src/tests/clutter/performance/test-common.h b/src/tests/clutter/performance/test-common.h index 693d9188a..bf8e1b61b 100644 --- a/src/tests/clutter/performance/test-common.h +++ b/src/tests/clutter/performance/test-common.h @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + static GTimer *testtimer = NULL; static gint testframes = 0; static float testmaxtime = 1.0; @@ -59,7 +61,7 @@ perf_stage_paint_cb (ClutterStage *stage, testframes ++; if (g_timer_elapsed (testtimer, NULL) > testmaxtime) { - clutter_main_quit (); + clutter_test_quit (); } } diff --git a/src/tests/clutter/performance/test-picking.c b/src/tests/clutter/performance/test-picking.c index 6b56737b3..39d743ab2 100644 --- a/src/tests/clutter/performance/test-picking.c +++ b/src/tests/clutter/performance/test-picking.c @@ -72,22 +72,16 @@ main (int argc, char **argv) clutter_perf_fps_init (); - if (CLUTTER_INIT_SUCCESS != - clutter_init_with_args (&argc, &argv, - NULL, - entries, - NULL, - NULL)) - { - g_warning ("Failed to initialize clutter"); - return -1; - } + clutter_test_init_with_args (&argc, &argv, + NULL, + entries, + NULL); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_size (stage, 512, 512); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), CLUTTER_COLOR_Black); clutter_stage_set_title (CLUTTER_STAGE (stage), "Picking Performance"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); printf ("Picking performance test with " "%d actors and %d events per frame\n", @@ -125,7 +119,7 @@ main (int argc, char **argv) clutter_perf_fps_start (CLUTTER_STAGE (stage)); clutter_threads_add_idle (queue_redraw, stage); - clutter_main (); + clutter_test_main (); clutter_perf_fps_report ("test-picking"); return 0; diff --git a/src/tests/clutter/performance/test-text-perf.c b/src/tests/clutter/performance/test-text-perf.c index d947d430b..bce727f38 100644 --- a/src/tests/clutter/performance/test-text-perf.c +++ b/src/tests/clutter/performance/test-text-perf.c @@ -89,8 +89,7 @@ main (int argc, char *argv[]) clutter_perf_fps_init (); - if (CLUTTER_INIT_SUCCESS != clutter_init (&argc, &argv)) - g_error ("Failed to initialize Clutter"); + clutter_test_init (&argc, &argv); if (argc != 3) { @@ -107,11 +106,11 @@ main (int argc, char *argv[]) g_print ("Monospace %dpx, string length = %d\n", font_size, n_chars); - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT); clutter_actor_set_background_color (CLUTTER_ACTOR (stage), &stage_color); clutter_stage_set_title (CLUTTER_STAGE (stage), "Text Performance"); - g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); + g_signal_connect (stage, "destroy", G_CALLBACK (clutter_test_quit), NULL); label = create_label (); w = clutter_actor_get_width (label); @@ -160,7 +159,7 @@ main (int argc, char *argv[]) clutter_perf_fps_start (CLUTTER_STAGE (stage)); clutter_threads_add_idle (queue_redraw, stage); - clutter_main (); + clutter_test_main (); clutter_perf_fps_report ("test-text-perf"); return 0;