Make the headless input tests work

These needed some updates and workarounds.

They are now part of the testsuite and can
be run like this:

    meson test -Cbuild --suite headless
This commit is contained in:
Matthias Clasen 2023-05-03 10:48:32 -04:00
parent 623c93ccc8
commit be8e203edc
6 changed files with 54 additions and 25 deletions

View File

@ -1,4 +1,5 @@
import sys
import os
import subprocess
import gi
@ -191,11 +192,9 @@ def launch_observer():
print('launch observer')
if display == None:
Gdk.set_allowed_backends('wayland')
display = Gdk.Display.open('gtk-test')
display = Gdk.Display.open(os.getenv('WAYLAND_DISPLAY'))
window = Gtk.Window.new()
window.set_display(display)
controller = Gtk.EventControllerKey.new()
controller.set_propagation_phase(Gtk.PropagationPhase.CAPTURE)
@ -341,12 +340,10 @@ def launch_drag_source(value):
print('launch drag source')
if display == None:
Gdk.set_allowed_backends('wayland')
display = Gdk.Display.open('gtk-test')
display = Gdk.Display.open(os.getenv('WAYLAND_DISPLAY'))
ds_window = Gtk.Window.new()
ds_window.set_title('Drag Source')
ds_window.set_display(display)
ds = Gtk.DragSource.new()
ds.set_content(Gdk.ContentProvider.new_for_value(value))
@ -393,14 +390,17 @@ def do_drop(controller, value, x, y):
loop.quit()
def launch_drop_target():
global display
global dt_window
if verbose:
print('launch drop target')
if display == None:
display = Gdk.Display.open(os.getenv('WAYLAND_DISPLAY'))
dt_window = Gtk.Window.new()
dt_window.set_title('Drop Target')
dt_window.set_display(display)
controller = Gtk.DropTarget.new(GObject.TYPE_STRING, Gdk.DragAction.COPY)
dt_window.add_controller(controller)
@ -448,6 +448,8 @@ def dnd_tests():
pointer_move(100, 100)
button_press(1)
expect_button_press(button=1, x=100, y=100, timeout=300)
# need to wait out the MIN_TIME_TO_DND
wait(150)
pointer_move(120, 150)
expect_drag(timeout=1000)
@ -493,6 +495,11 @@ def mutter_appeared(name):
stream_path = screen_cast_session.RecordMonitor('Meta-0', {})
session.Start()
# work around lack of initial devices
key_press(Gdk.KEY_Control_L)
key_release(Gdk.KEY_Control_L)
pointer_move(-100, -100)
basic_keyboard_tests()
basic_pointer_tests()
dnd_tests()

View File

@ -1,4 +1,5 @@
import sys
import os
import subprocess
import gi
@ -14,6 +15,7 @@ monitors = {}
waiting = False
done = False
monitor_model = None
display = None
def terminate():
for key in monitors:
@ -99,13 +101,14 @@ def monitors_changed(monitors, position, removed, added):
def launch_observer():
global monitor_model
global display
if display == None:
display = Gdk.Display.open(os.getenv('WAYLAND_DISPLAY'))
if verbose:
print('launch observer')
Gdk.set_allowed_backends('wayland')
display = Gdk.Display.open('gtk-test')
monitor_model = display.get_monitors()
assert monitor_model.get_n_items() == 0, "Unexpected initial monitors"
monitor_model.connect('items-changed', monitors_changed)

View File

@ -0,0 +1,19 @@
env = environment()
env.prepend('GI_TYPELIB_PATH',
project_build_root / 'gtk',
gi_dep.get_variable(pkgconfig: 'typelibdir'),
)
env.prepend('LD_PRELOAD', project_build_root / 'gtk' / 'libgtk-4.so')
env.prepend('MESON_CURRENT_SOURCE_DIR', meson.current_source_dir())
test('monitor',
find_program('run-headless-monitor-tests.sh', dirs: meson.current_source_dir()),
suite: ['headless'],
env: env,
)
test('input',
find_program('run-headless-input-tests.sh', dirs: meson.current_source_dir()),
suite: ['headless'],
env: env,
)

View File

@ -1,24 +1,22 @@
#! /bin/sh
builddir=$(pwd)/build
srcdir=${MESON_CURRENT_SOURCE_DIR:-./testsuite/headless}
dbus-run-session sh <<EOF
#echo DBUS_SESSION_BUS_ADDRESS=\$DBUS_SESSION_BUS_ADDRESS
#echo WAYLAND_DISPLAY=gtk-test
mutter --headless --virtual-monitor 1024x768 --no-x11 --wayland-display gtk-test >&mutter.log &
export GTK_A11Y=none
export GIO_USE_VFS=local
mutter --headless --virtual-monitor 1024x768 --no-x11 --wayland-display gtk-test2 >&mutter2.log &
pid=\$!
export WAYLAND_DISPLAY=gtk-test
export WAYLAND_DISPLAY=gtk-test2
export GDK_BACKEND=wayland
export GTK_A11Y=none
#export WAYLAND_DEBUG=1
export GI_TYPELIB_PATH=$builddir/gtk:/usr/lib64/girepository-1.0
export LD_PRELOAD=$builddir/gtk/libgtk-4.so
python tests/headless-input-tests.py
python ${srcdir}/headless-input-tests.py
status=\$?
kill \$pid

View File

@ -1,22 +1,22 @@
#! /bin/sh
builddir=$(pwd)/build
srcdir=${MESON_CURRENT_SOURCE_DIR:-./testsuite/headless}
dbus-run-session sh <<EOF
# echo DBUS_SESSION_BUS_ADDRESS=\$DBUS_SESSION_BUS_ADDRESS
# echo WAYLAND_DISPLAY=gtk-test
export GTK_A11Y=none
export GIO_USE_VFS=local
mutter --headless --no-x11 --wayland-display gtk-test >&mutter.log &
pid=\$!
export WAYLAND_DISPLAY=gtk-test
export GDK_BACKEND=wayland
export GI_TYPELIB_PATH=$builddir/gtk:/usr/lib64/girepository-1.0
export LD_PRELOAD=$builddir/gtk/libgtk-4.so
python tests/headless-monitor-tests.py
python ${srcdir}/headless-monitor-tests.py
status=\$?
kill \$pid

View File

@ -70,7 +70,9 @@ subdir('css')
subdir('a11y')
subdir('tools')
subdir('reftests')
if build_gir
subdir('introspection')
endif
if wayland_enabled
subdir('headless')
endif