context/test: Configure test setup during configuration

This includes setting up the GLib test framework, overriding the X11
and Wayland display names.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
Jonas Ådahl 2021-03-02 10:44:02 +01:00
parent bbf6d88d54
commit 8cb177499d
2 changed files with 14 additions and 12 deletions

View File

@ -45,6 +45,8 @@ test_env.set('MUTTER_TEST_PLUGIN_PATH', '@0@'.format(default_plugin.full_path())
test_context_sources = [ test_context_sources = [
'meta-context-test.c', 'meta-context-test.c',
'meta-context-test.h', 'meta-context-test.h',
'test-utils.c',
'test-utils.h',
] ]
test_client = executable('mutter-test-client', test_client = executable('mutter-test-client',
@ -77,8 +79,6 @@ test_runner = executable('mutter-test-runner',
unit_tests = executable('mutter-test-unit-tests', unit_tests = executable('mutter-test-unit-tests',
sources: [ sources: [
test_context_sources, test_context_sources,
'test-utils.c',
'test-utils.h',
'unit-tests.c', 'unit-tests.c',
'boxes-tests.c', 'boxes-tests.c',
'boxes-tests.h', 'boxes-tests.h',
@ -122,8 +122,6 @@ headless_start_test = executable('mutter-headless-start-test',
'meta-gpu-test.h', 'meta-gpu-test.h',
'meta-monitor-manager-test.c', 'meta-monitor-manager-test.c',
'meta-monitor-manager-test.h', 'meta-monitor-manager-test.h',
'test-utils.c',
'test-utils.h',
], ],
include_directories: tests_includepath, include_directories: tests_includepath,
c_args: tests_c_args, c_args: tests_c_args,
@ -144,8 +142,6 @@ stage_view_tests = executable('mutter-stage-view-tests',
'monitor-test-utils.c', 'monitor-test-utils.c',
'monitor-test-utils.h', 'monitor-test-utils.h',
'stage-view-tests.c', 'stage-view-tests.c',
'test-utils.c',
'test-utils.h',
], ],
include_directories: tests_includepath, include_directories: tests_includepath,
c_args: tests_c_args, c_args: tests_c_args,
@ -190,8 +186,6 @@ if have_native_tests
'native-screen-cast.h', 'native-screen-cast.h',
'native-virtual-monitor.c', 'native-virtual-monitor.c',
'native-virtual-monitor.h', 'native-virtual-monitor.h',
'test-utils.c',
'test-utils.h',
ref_test_sources, ref_test_sources,
], ],
include_directories: tests_includepath, include_directories: tests_includepath,
@ -205,8 +199,6 @@ if have_native_tests
sources: [ sources: [
test_context_sources, test_context_sources,
'ref-test-sanity.c', 'ref-test-sanity.c',
'test-utils.c',
'test-utils.h',
ref_test_sources, ref_test_sources,
], ],
include_directories: tests_includepath, include_directories: tests_includepath,
@ -236,8 +228,6 @@ if have_native_tests
sources: [ sources: [
test_context_sources, test_context_sources,
'native-persistent-virtual-monitor.c', 'native-persistent-virtual-monitor.c',
'test-utils.c',
'test-utils.h',
], ],
include_directories: tests_includepath, include_directories: tests_includepath,
c_args: tests_c_args, c_args: tests_c_args,

View File

@ -22,6 +22,10 @@
#include "tests/meta-context-test.h" #include "tests/meta-context-test.h"
#include "tests/test-utils.h"
#include "wayland/meta-wayland.h"
#include "wayland/meta-xwayland.h"
struct _MetaContextTest struct _MetaContextTest
{ {
GObject parent; GObject parent;
@ -35,6 +39,14 @@ meta_context_test_configure (MetaContext *context,
char ***argv, char ***argv,
GError **error) GError **error)
{ {
g_test_init (argc, argv, NULL);
g_test_bug_base ("https://gitlab.gnome.org/GNOME/mutter/issues/");
meta_ensure_test_client_path (*argc, *argv);
meta_wayland_override_display_name ("mutter-test-display");
meta_xwayland_override_display_number (512);
return TRUE; return TRUE;
} }