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
This commit is contained in:
Jonas Ådahl 2020-07-09 21:28:57 +02:00
parent 21e2f41a26
commit 0d95f4d854
67 changed files with 438 additions and 330 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -4,6 +4,8 @@
#include <glib-object.h>
#include <clutter/clutter.h>
#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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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"

View File

@ -20,5 +20,7 @@
* Boston, MA 02111-1307, USA.
*/
#include "tests/clutter-test-utils.h"
gboolean
cally_util_a11y_init (int *argc, char ***argv);

View File

@ -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,

View File

@ -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 ())
{

View File

@ -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);

View File

@ -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),

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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));

View File

@ -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',

View File

@ -7,6 +7,7 @@
#include <gmodule.h>
#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,
clutter_test_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;
}
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);

View File

@ -2,6 +2,8 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#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;
}

View File

@ -1,6 +1,8 @@
#include <stdlib.h>
#include <clutter/clutter.h>
#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;
}

View File

@ -7,6 +7,8 @@
#include <clutter/clutter.h>
#include <clutter/clutter-keysyms.h>
#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;
}

View File

@ -3,6 +3,8 @@
#include <cairo.h>
#include <clutter/clutter.h>
#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;
}

View File

@ -3,6 +3,8 @@
*/
#include <clutter/clutter.h>
#include "tests/clutter-test-utils.h"
#ifndef _MSC_VER
#include <unistd.h> /* 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);

View File

@ -9,6 +9,8 @@
#include <clutter/clutter.h>
#include <cogl/cogl.h>
#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);

View File

@ -4,6 +4,8 @@
#include <clutter/clutter.h>
#include <cogl/cogl.h>
#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;
}

View File

@ -4,6 +4,8 @@
#include <gmodule.h>
#include <string.h>
#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);

View File

@ -5,6 +5,8 @@
#include <glib.h>
#include <gmodule.h>
#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;
}

View File

@ -4,6 +4,8 @@
#include <clutter/clutter.h>
#include <cogl/cogl.h>
#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;
}

View File

@ -4,6 +4,8 @@
#include <clutter/clutter.h>
#include <cogl/cogl.h>
#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;
}

View File

@ -5,6 +5,8 @@
#include <clutter/clutter.h>
#include <cogl/cogl.h>
#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;
}

View File

@ -2,6 +2,8 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#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);

View File

@ -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;
}

View File

@ -2,6 +2,8 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#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,
clutter_test_init_with_args (&argc, &argv,
NULL,
test_easing_entries,
NULL,
&error) != CLUTTER_INIT_SUCCESS)
return 1;
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;
}

View File

@ -2,6 +2,8 @@
#include <clutter/clutter.h>
#include <string.h>
#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;
}

View File

@ -1,6 +1,8 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#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;
}

View File

@ -3,6 +3,8 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <clutter/clutter.h>
#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);

View File

@ -2,6 +2,8 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#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;
}

View File

@ -6,6 +6,7 @@
#include <clutter/clutter.h>
#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);

View File

@ -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,
clutter_test_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;
}
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);

View File

@ -2,6 +2,8 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#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;
}

View File

@ -23,6 +23,8 @@
#include <clutter/clutter.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#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;
}

View File

@ -7,6 +7,8 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#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);

View File

@ -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" }
]
},
{

View File

@ -7,6 +7,7 @@
#include <clutter/clutter.h>
#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);

View File

@ -2,6 +2,8 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#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;
}

View File

@ -4,6 +4,8 @@
#include <clutter/clutter.h>
#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);

View File

@ -1,6 +1,8 @@
#include <stdlib.h>
#include <clutter/clutter.h>
#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;
}

View File

@ -2,6 +2,8 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#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;
}

View File

@ -3,6 +3,8 @@
#include <gmodule.h>
#include <clutter/clutter.h>
#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;
}

View File

@ -22,6 +22,8 @@
#include <glib.h>
#include <clutter/clutter.h>
#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);

View File

@ -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,
)

View File

@ -6,6 +6,8 @@
#include <cogl/cogl.h>
#include <math.h>
#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,
clutter_test_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;
}
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);

View File

@ -3,6 +3,8 @@
#include <stdlib.h>
#include <clutter/clutter.h>
#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,
clutter_test_init_with_args (&argc, &argv,
NULL,
entries,
NULL,
&error) != CLUTTER_INIT_SUCCESS)
return 1;
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);

View File

@ -2,6 +2,8 @@
#include <clutter/clutter.h>
#include <stdlib.h>
#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);

View File

@ -3,6 +3,8 @@
#include <stdlib.h>
#include <string.h>
#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;
}

View File

@ -3,6 +3,8 @@
#include <stdlib.h>
#include <string.h>
#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);

View File

@ -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,
)

View File

@ -2,6 +2,8 @@
#include <glib.h>
#include <clutter/clutter.h>
#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 ();
}
}

View File

@ -72,22 +72,16 @@ main (int argc, char **argv)
clutter_perf_fps_init ();
if (CLUTTER_INIT_SUCCESS !=
clutter_init_with_args (&argc, &argv,
clutter_test_init_with_args (&argc, &argv,
NULL,
entries,
NULL,
NULL))
{
g_warning ("Failed to initialize clutter");
return -1;
}
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;

View File

@ -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;