mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 21:02:14 +00:00
tests: Add check for compositor state on XWayland startup
Check that the first X11 window started has a compositor defined. See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2472#note_1582262 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
This commit is contained in:
parent
28bd3da21a
commit
b48351005e
@ -464,6 +464,20 @@ if have_native_tests
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
if have_xwayland
|
if have_xwayland
|
||||||
|
x11_compositor_checker = executable('x11-compositor-checker',
|
||||||
|
sources: ['x11-compositor-checker.c'],
|
||||||
|
include_directories: tests_includes,
|
||||||
|
c_args: [
|
||||||
|
tests_c_args,
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
x11_dep,
|
||||||
|
],
|
||||||
|
install: have_installed_tests,
|
||||||
|
install_dir: mutter_installed_tests_libexecdir,
|
||||||
|
install_rpath: pkglibdir,
|
||||||
|
)
|
||||||
|
|
||||||
test_cases += [
|
test_cases += [
|
||||||
{
|
{
|
||||||
'name': 'wayland-x11-interop',
|
'name': 'wayland-x11-interop',
|
||||||
@ -480,7 +494,10 @@ if have_native_tests
|
|||||||
{
|
{
|
||||||
'name': 'xwayland',
|
'name': 'xwayland',
|
||||||
'suite': 'wayland',
|
'suite': 'wayland',
|
||||||
'depends': [ test_client ],
|
'depends': [
|
||||||
|
test_client,
|
||||||
|
x11_compositor_checker,
|
||||||
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
'xwayland-tests.c',
|
'xwayland-tests.c',
|
||||||
],
|
],
|
||||||
|
52
src/tests/x11-compositor-checker.c
Normal file
52
src/tests/x11-compositor-checker.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Alan Jenkins.
|
||||||
|
* Copyright (C) 2023 Canonical Ltd.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
has_compositor (Display *dpy,
|
||||||
|
int screen)
|
||||||
|
{
|
||||||
|
char prop_name[20];
|
||||||
|
|
||||||
|
snprintf (prop_name, 20, "_NET_WM_CM_S%d", screen);
|
||||||
|
return XGetSelectionOwner (dpy, XInternAtom (dpy, prop_name, False)) != None;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
Display *dpy = XOpenDisplay ("");
|
||||||
|
|
||||||
|
if (has_compositor (dpy, XDefaultScreen (dpy)))
|
||||||
|
{
|
||||||
|
printf ("X11 Compositor is available for display %s.%d\n",
|
||||||
|
DisplayString (dpy), XDefaultScreen (dpy));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("NO X11 Compositor is available for display %s:%d\n",
|
||||||
|
DisplayString (dpy), XDefaultScreen (dpy));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
@ -247,9 +247,68 @@ meta_test_hammer_activate (void)
|
|||||||
meta_test_client_destroy (wayland_client);
|
meta_test_client_destroy (wayland_client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
compositor_check_proc_async (GObject *source_object,
|
||||||
|
GAsyncResult *res,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
GMainLoop *loop = user_data;
|
||||||
|
|
||||||
|
g_subprocess_wait_check_finish (G_SUBPROCESS (source_object), res, &error);
|
||||||
|
g_assert_no_error (error);
|
||||||
|
g_main_loop_quit (loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_test_xwayland_compositor_selection (void)
|
||||||
|
{
|
||||||
|
g_autoptr (GError) error = NULL;
|
||||||
|
g_autoptr (GSubprocessLauncher) launcher = NULL;
|
||||||
|
g_autoptr (GSubprocess) subprocess = NULL;
|
||||||
|
g_autoptr (GMainLoop) loop = NULL;
|
||||||
|
MetaDisplay *display = meta_context_get_display (test_context);
|
||||||
|
MetaWaylandCompositor *compositor;
|
||||||
|
const char *x11_display_name;
|
||||||
|
const char *x11_compositor_checker;
|
||||||
|
|
||||||
|
g_assert_null (meta_display_get_x11_display (display));
|
||||||
|
|
||||||
|
g_assert (meta_is_wayland_compositor ());
|
||||||
|
compositor = meta_context_get_wayland_compositor (test_context);
|
||||||
|
x11_display_name = meta_wayland_get_public_xwayland_display_name (compositor);
|
||||||
|
g_assert_nonnull (x11_display_name);
|
||||||
|
|
||||||
|
launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
|
||||||
|
g_subprocess_launcher_setenv (launcher,
|
||||||
|
"DISPLAY", x11_display_name,
|
||||||
|
TRUE);
|
||||||
|
|
||||||
|
x11_compositor_checker = g_test_build_filename (G_TEST_BUILT,
|
||||||
|
"src",
|
||||||
|
"tests",
|
||||||
|
"x11-compositor-checker",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
subprocess = g_subprocess_launcher_spawn (launcher,
|
||||||
|
&error,
|
||||||
|
x11_compositor_checker,
|
||||||
|
NULL);
|
||||||
|
g_assert_no_error (error);
|
||||||
|
|
||||||
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
g_subprocess_wait_check_async (subprocess, NULL,
|
||||||
|
compositor_check_proc_async, loop);
|
||||||
|
g_main_loop_run (loop);
|
||||||
|
|
||||||
|
g_assert_nonnull (meta_display_get_x11_display (display));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_tests (void)
|
init_tests (void)
|
||||||
{
|
{
|
||||||
|
g_test_add_func ("/backends/xwayland/compositor/selection",
|
||||||
|
meta_test_xwayland_compositor_selection);
|
||||||
g_test_add_func ("/backends/xwayland/restart/selection",
|
g_test_add_func ("/backends/xwayland/restart/selection",
|
||||||
meta_test_xwayland_restart_selection);
|
meta_test_xwayland_restart_selection);
|
||||||
g_test_add_func ("/backends/xwayland/crash/only-x11",
|
g_test_add_func ("/backends/xwayland/crash/only-x11",
|
||||||
|
Loading…
Reference in New Issue
Block a user