mirror of
https://github.com/brl/mutter.git
synced 2024-12-28 05:42:14 +00:00
tests/wayland-unit-tests: Change to use headless backend
Change to use the headless backend with a virtual monitor, instead of the nested backend. This means tests can create and use virtual input devices, which isn't possible with the nested backend. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1993>
This commit is contained in:
parent
7992b46566
commit
d111c47c88
@ -176,21 +176,6 @@ stage_view_tests = executable('mutter-stage-view-tests',
|
|||||||
install_dir: mutter_installed_tests_libexecdir,
|
install_dir: mutter_installed_tests_libexecdir,
|
||||||
)
|
)
|
||||||
|
|
||||||
wayland_tests = executable('mutter-wayland-tests',
|
|
||||||
sources: [
|
|
||||||
'meta-wayland-test-driver.c',
|
|
||||||
'meta-wayland-test-driver.h',
|
|
||||||
'wayland-unit-tests.c',
|
|
||||||
test_driver_server_header,
|
|
||||||
test_driver_protocol_code,
|
|
||||||
],
|
|
||||||
include_directories: tests_includes,
|
|
||||||
c_args: tests_c_args,
|
|
||||||
dependencies: libmutter_test_dep,
|
|
||||||
install: have_installed_tests,
|
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
|
||||||
)
|
|
||||||
|
|
||||||
anonymous_file_test = executable('anonymous-file-tests',
|
anonymous_file_test = executable('anonymous-file-tests',
|
||||||
sources: [
|
sources: [
|
||||||
'anonymous-file.c',
|
'anonymous-file.c',
|
||||||
@ -273,6 +258,21 @@ if have_native_tests
|
|||||||
install: have_installed_tests,
|
install: have_installed_tests,
|
||||||
install_dir: mutter_installed_tests_libexecdir,
|
install_dir: mutter_installed_tests_libexecdir,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
wayland_tests = executable('mutter-wayland-tests',
|
||||||
|
sources: [
|
||||||
|
'meta-wayland-test-driver.c',
|
||||||
|
'meta-wayland-test-driver.h',
|
||||||
|
'wayland-unit-tests.c',
|
||||||
|
test_driver_server_header,
|
||||||
|
test_driver_protocol_code,
|
||||||
|
],
|
||||||
|
include_directories: tests_includes,
|
||||||
|
c_args: tests_c_args,
|
||||||
|
dependencies: libmutter_test_dep,
|
||||||
|
install: have_installed_tests,
|
||||||
|
install_dir: mutter_installed_tests_libexecdir,
|
||||||
|
)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
stacking_tests = [
|
stacking_tests = [
|
||||||
@ -338,13 +338,6 @@ test('stage-view', stage_view_tests,
|
|||||||
timeout: 60,
|
timeout: 60,
|
||||||
)
|
)
|
||||||
|
|
||||||
test('wayland', wayland_tests,
|
|
||||||
suite: ['core', 'mutter/unit'],
|
|
||||||
env: test_env,
|
|
||||||
is_parallel: false,
|
|
||||||
timeout: 60,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('anonymous-file', anonymous_file_test,
|
test('anonymous-file', anonymous_file_test,
|
||||||
suite: ['core', 'mutter/unit'],
|
suite: ['core', 'mutter/unit'],
|
||||||
env: test_env,
|
env: test_env,
|
||||||
@ -380,4 +373,11 @@ if have_native_tests
|
|||||||
is_parallel: false,
|
is_parallel: false,
|
||||||
timeout: 60,
|
timeout: 60,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
test('wayland', wayland_tests,
|
||||||
|
suite: ['core', 'mutter/unit'],
|
||||||
|
env: test_env,
|
||||||
|
is_parallel: false,
|
||||||
|
timeout: 60,
|
||||||
|
)
|
||||||
endif
|
endif
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "backends/meta-virtual-monitor.h"
|
||||||
#include "core/display-private.h"
|
#include "core/display-private.h"
|
||||||
#include "core/window-private.h"
|
#include "core/window-private.h"
|
||||||
#include "meta-test/meta-context-test.h"
|
#include "meta-test/meta-context-test.h"
|
||||||
@ -33,7 +34,9 @@ typedef struct _WaylandTestClient
|
|||||||
GMainLoop *main_loop;
|
GMainLoop *main_loop;
|
||||||
} WaylandTestClient;
|
} WaylandTestClient;
|
||||||
|
|
||||||
|
static MetaContext *test_context;
|
||||||
static MetaWaylandTestDriver *test_driver;
|
static MetaWaylandTestDriver *test_driver;
|
||||||
|
static MetaVirtualMonitor *virtual_monitor;
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_test_client_path (const char *test_client_name)
|
get_test_client_path (const char *test_client_name)
|
||||||
@ -259,14 +262,33 @@ toplevel_activation (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pre_run_wayland_tests (void)
|
on_before_tests (void)
|
||||||
{
|
{
|
||||||
MetaWaylandCompositor *compositor;
|
MetaBackend *backend = meta_context_get_backend (test_context);
|
||||||
|
MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (backend);
|
||||||
compositor = meta_wayland_compositor_get_default ();
|
MetaWaylandCompositor *compositor =
|
||||||
g_assert_nonnull (compositor);
|
meta_context_get_wayland_compositor (test_context);
|
||||||
|
g_autoptr (MetaVirtualMonitorInfo) monitor_info = NULL;
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
test_driver = meta_wayland_test_driver_new (compositor);
|
test_driver = meta_wayland_test_driver_new (compositor);
|
||||||
|
|
||||||
|
monitor_info = meta_virtual_monitor_info_new (400, 400, 60.0,
|
||||||
|
"MetaTestVendor",
|
||||||
|
"MetaVirtualMonitor",
|
||||||
|
"0x1234");
|
||||||
|
virtual_monitor = meta_monitor_manager_create_virtual_monitor (monitor_manager,
|
||||||
|
monitor_info,
|
||||||
|
&error);
|
||||||
|
if (!virtual_monitor)
|
||||||
|
g_error ("Failed to create virtual monitor: %s", error->message);
|
||||||
|
meta_monitor_manager_reload (monitor_manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_after_tests (void)
|
||||||
|
{
|
||||||
|
g_clear_object (&virtual_monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -291,14 +313,18 @@ main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
g_autoptr (MetaContext) context = NULL;
|
g_autoptr (MetaContext) context = NULL;
|
||||||
|
|
||||||
context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED,
|
context = meta_create_test_context (META_CONTEXT_TEST_TYPE_HEADLESS,
|
||||||
META_CONTEXT_TEST_FLAG_TEST_CLIENT);
|
META_CONTEXT_TEST_FLAG_NO_X11);
|
||||||
g_assert (meta_context_configure (context, &argc, &argv, NULL));
|
g_assert (meta_context_configure (context, &argc, &argv, NULL));
|
||||||
|
|
||||||
|
test_context = context;
|
||||||
|
|
||||||
init_wayland_tests ();
|
init_wayland_tests ();
|
||||||
|
|
||||||
g_signal_connect (context, "before-tests",
|
g_signal_connect (context, "before-tests",
|
||||||
G_CALLBACK (pre_run_wayland_tests), NULL);
|
G_CALLBACK (on_before_tests), NULL);
|
||||||
|
g_signal_connect (context, "after-tests",
|
||||||
|
G_CALLBACK (on_after_tests), NULL);
|
||||||
|
|
||||||
return meta_context_test_run_tests (META_CONTEXT_TEST (context));
|
return meta_context_test_run_tests (META_CONTEXT_TEST (context));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user