mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
tests/clutter: Port to MetaContext
The clutter tests neeed to start and stop, thus uses their own main loop instead of the one in MetaContext. Shouldn't matter, since nothing in mutter should happen that makes the test self-terminate from inside mutter. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
parent
2f19a5f28d
commit
2ac262f138
@ -13,6 +13,8 @@ typedef struct {
|
|||||||
|
|
||||||
static ClutterTestEnvironment *test_environ = NULL;
|
static ClutterTestEnvironment *test_environ = NULL;
|
||||||
|
|
||||||
|
static GMainLoop *clutter_test_main_loop = NULL;
|
||||||
|
|
||||||
#define DBUS_NAME_WARNING "Lost or failed to acquire name"
|
#define DBUS_NAME_WARNING "Lost or failed to acquire name"
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -29,58 +31,6 @@ log_func (const gchar *log_domain,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
|
||||||
test_get_plugin_name (void)
|
|
||||||
{
|
|
||||||
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_override_x11_display_policy (META_X11_DISPLAY_POLICY_DISABLED);
|
|
||||||
meta_test_init ();
|
|
||||||
|
|
||||||
display = g_getenv ("DISPLAY");
|
|
||||||
if (!display || *display == '\0')
|
|
||||||
{
|
|
||||||
g_error ("No DISPLAY environment variable found, but we require a "
|
|
||||||
"DISPLAY set in order to run the conformance test suite.\n"
|
|
||||||
"Skipping all tests.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we explicitly disable the synchronisation to the vertical refresh
|
|
||||||
* rate, and run the master clock using a 60 fps timer instead.
|
|
||||||
*/
|
|
||||||
_clutter_set_sync_to_vblank (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
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:
|
* clutter_test_init:
|
||||||
* @argc: (inout): number of arguments in @argv
|
* @argc: (inout): number of arguments in @argv
|
||||||
@ -94,9 +44,18 @@ void
|
|||||||
clutter_test_init (int *argc,
|
clutter_test_init (int *argc,
|
||||||
char ***argv)
|
char ***argv)
|
||||||
{
|
{
|
||||||
init_common_pre ();
|
MetaContext *context;
|
||||||
g_assert (clutter_init (NULL, NULL) == CLUTTER_INIT_SUCCESS);
|
|
||||||
init_common_post (argc, argv);
|
context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED,
|
||||||
|
META_CONTEXT_TEST_FLAG_NO_X11);
|
||||||
|
g_assert (meta_context_configure (context, argc, argv, NULL));
|
||||||
|
g_assert (meta_context_setup (context, NULL));
|
||||||
|
|
||||||
|
test_environ = g_new0 (ClutterTestEnvironment, 1);
|
||||||
|
|
||||||
|
g_assert (meta_context_start (context, NULL));
|
||||||
|
|
||||||
|
clutter_test_main_loop = g_main_loop_new (NULL, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -306,13 +265,17 @@ clutter_test_run (void)
|
|||||||
void
|
void
|
||||||
clutter_test_main (void)
|
clutter_test_main (void)
|
||||||
{
|
{
|
||||||
meta_run_main_loop ();
|
g_assert_nonnull (clutter_test_main_loop);
|
||||||
|
|
||||||
|
g_main_loop_run (clutter_test_main_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
clutter_test_quit (void)
|
clutter_test_quit (void)
|
||||||
{
|
{
|
||||||
meta_quit (META_EXIT_SUCCESS);
|
g_assert_nonnull (clutter_test_main_loop);
|
||||||
|
|
||||||
|
g_main_loop_quit (clutter_test_main_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -30,12 +30,8 @@
|
|||||||
#include "clutter/clutter-actor.h"
|
#include "clutter/clutter-actor.h"
|
||||||
#include "clutter/clutter-color.h"
|
#include "clutter/clutter-color.h"
|
||||||
#include "clutter/clutter-private.h"
|
#include "clutter/clutter-private.h"
|
||||||
#include "core/main-private.h"
|
|
||||||
#include "meta/common.h"
|
#include "meta/common.h"
|
||||||
#include "meta/main.h"
|
#include "tests/meta-context-test.h"
|
||||||
#include "backends/x11/nested/meta-backend-x11-nested.h"
|
|
||||||
#include "wayland/meta-wayland.h"
|
|
||||||
#include "wayland/meta-xwayland.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -6,11 +6,9 @@
|
|||||||
#include <gmodule.h>
|
#include <gmodule.h>
|
||||||
|
|
||||||
#include "backends/x11/nested/meta-backend-x11-nested.h"
|
#include "backends/x11/nested/meta-backend-x11-nested.h"
|
||||||
#include "core/main-private.h"
|
#include "tests/clutter-test-utils.h"
|
||||||
#include "meta/main.h"
|
#include "tests/meta-context-test.h"
|
||||||
#include "meta/meta-enums.h"
|
|
||||||
#include "wayland/meta-wayland.h"
|
|
||||||
#include "wayland/meta-xwayland.h"
|
|
||||||
#include "test-unit-names.h"
|
#include "test-unit-names.h"
|
||||||
|
|
||||||
#define MAX_DESC_SIZE 72
|
#define MAX_DESC_SIZE 72
|
||||||
@ -127,13 +125,6 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
g_option_context_free (context);
|
g_option_context_free (context);
|
||||||
|
|
||||||
meta_wayland_override_display_name ("mutter-test-display");
|
|
||||||
meta_xwayland_override_display_number (512);
|
|
||||||
meta_override_compositor_configuration (META_COMPOSITOR_TYPE_WAYLAND,
|
|
||||||
META_TYPE_BACKEND_X11_NESTED,
|
|
||||||
NULL);
|
|
||||||
meta_init ();
|
|
||||||
|
|
||||||
module = g_module_open (NULL, 0);
|
module = g_module_open (NULL, 0);
|
||||||
if (!module)
|
if (!module)
|
||||||
g_error ("*** Failed to open self for symbol lookup");
|
g_error ("*** Failed to open self for symbol lookup");
|
||||||
|
@ -1,4 +1,20 @@
|
|||||||
|
test_context_sources = [
|
||||||
|
'meta-backend-test.c',
|
||||||
|
'meta-backend-test.h',
|
||||||
|
'meta-context-test.c',
|
||||||
|
'meta-context-test.h',
|
||||||
|
'meta-gpu-test.c',
|
||||||
|
'meta-gpu-test.h',
|
||||||
|
'meta-monitor-manager-test.c',
|
||||||
|
'meta-monitor-manager-test.h',
|
||||||
|
'monitor-test-utils.c',
|
||||||
|
'monitor-test-utils.h',
|
||||||
|
'test-utils.c',
|
||||||
|
'test-utils.h',
|
||||||
|
]
|
||||||
|
|
||||||
clutter_test_utils = files (
|
clutter_test_utils = files (
|
||||||
|
test_context_sources,
|
||||||
'clutter-test-utils.c',
|
'clutter-test-utils.c',
|
||||||
'clutter-test-utils.h',
|
'clutter-test-utils.h',
|
||||||
)
|
)
|
||||||
@ -42,21 +58,6 @@ test_env.set('G_TEST_SRCDIR', join_paths(meson.source_root(), 'src'))
|
|||||||
test_env.set('G_TEST_BUILDDIR', meson.build_root())
|
test_env.set('G_TEST_BUILDDIR', meson.build_root())
|
||||||
test_env.set('MUTTER_TEST_PLUGIN_PATH', '@0@'.format(default_plugin.full_path()))
|
test_env.set('MUTTER_TEST_PLUGIN_PATH', '@0@'.format(default_plugin.full_path()))
|
||||||
|
|
||||||
test_context_sources = [
|
|
||||||
'meta-backend-test.c',
|
|
||||||
'meta-backend-test.h',
|
|
||||||
'meta-context-test.c',
|
|
||||||
'meta-context-test.h',
|
|
||||||
'meta-gpu-test.c',
|
|
||||||
'meta-gpu-test.h',
|
|
||||||
'meta-monitor-manager-test.c',
|
|
||||||
'meta-monitor-manager-test.h',
|
|
||||||
'monitor-test-utils.c',
|
|
||||||
'monitor-test-utils.h',
|
|
||||||
'test-utils.c',
|
|
||||||
'test-utils.h',
|
|
||||||
]
|
|
||||||
|
|
||||||
test_client = executable('mutter-test-client',
|
test_client = executable('mutter-test-client',
|
||||||
sources: ['test-client.c'],
|
sources: ['test-client.c'],
|
||||||
include_directories: tests_includepath,
|
include_directories: tests_includepath,
|
||||||
|
Loading…
Reference in New Issue
Block a user