Skip to content

Commit 1f57424

Browse files
committed
tests/wm: ensure correct gdk backend
1 parent ffd3370 commit 1f57424

File tree

3 files changed

+52
-30
lines changed

3 files changed

+52
-30
lines changed

test/dbus-interfaces/com.github.amezin.ddterm.TestHook.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<property type="b" name="WindowAbove" access="read"/>
1616
<property type="b" name="WindowSkipTaskbar" access="read"/>
1717
<property type="b" name="WindowOnAllWorkspaces" access="read"/>
18+
<property type="s" name="ClientType" access="read"/>
1819

1920
<method name="Destroy"/>
2021

test/extensionhook.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import GLib from 'gi://GLib';
22
import GObject from 'gi://GObject';
33
import Gio from 'gi://Gio';
4+
import Meta from 'gi://Meta';
45
import Shell from 'gi://Shell';
56

67
import {
@@ -154,6 +155,7 @@ const Interface = GObject.registerClass({
154155
this.HasWindow = false;
155156
this.MaximizedHorizontally = false;
156157
this.MaximizedVertically = false;
158+
this.ClientType = '';
157159
this._update_window_rect();
158160

159161
return;
@@ -268,6 +270,11 @@ const Interface = GObject.registerClass({
268270
]));
269271
}));
270272

273+
this.ClientType = {
274+
[Meta.WindowClientType.WAYLAND]: 'wayland',
275+
[Meta.WindowClientType.X11]: 'x11',
276+
}[win.get_client_type()];
277+
271278
this.HasWindow = true;
272279
} finally {
273280
this.thaw_notify();

test/test_wm.py

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -255,36 +255,6 @@ def monitor_config(
255255

256256
return monitor_layout
257257

258-
@pytest.fixture
259-
def gdk_backend(
260-
self,
261-
request,
262-
dbus_connection,
263-
extension_test_hook,
264-
settings_test_hook,
265-
app_dbus_actions
266-
):
267-
force_x11 = request.param == GdkBackend.X11
268-
269-
# Make sure cached value is up to date
270-
glibutil.dispatch_pending_sources()
271-
272-
if settings_test_hook.force_x11_gdk_backend == force_x11:
273-
return request.param
274-
275-
settings_test_hook.force_x11_gdk_backend = force_x11
276-
277-
if extension_test_hook.AppRunning:
278-
app_dbus_actions.activate_action('quit', None)
279-
280-
extension_test_hook.wait_property(
281-
'AppRunning',
282-
False,
283-
timeout=dbusutil.DEFAULT_LONG_TIMEOUT_MS
284-
)
285-
286-
return request.param
287-
288258
@pytest.fixture
289259
def window_size(self, settings_test_hook, request):
290260
settings_test_hook.window_size = request.param
@@ -447,12 +417,14 @@ def test_show(
447417
extension_test_hook,
448418
shell_test_hook,
449419
wait_idle,
420+
gdk_backend,
450421
):
451422
extension_dbus_interface.Activate(timeout=dbusutil.DEFAULT_LONG_TIMEOUT_MS)
452423
glibutil.dispatch_pending_sources()
453424

454425
assert extension_test_hook.HasWindow
455426
assert unmaximized_rect == extension_dbus_interface.TargetRect
427+
assert extension_test_hook.ClientType == gdk_backend
456428

457429
extension_test_hook.wait_property('RenderedFirstFrame', True)
458430
wait_idle()
@@ -533,12 +505,14 @@ def test_maximize_unmaximize(
533505
settings_test_hook,
534506
shell_test_hook,
535507
wait_idle,
508+
gdk_backend,
536509
):
537510
extension_dbus_interface.Activate(timeout=dbusutil.DEFAULT_LONG_TIMEOUT_MS)
538511
glibutil.dispatch_pending_sources()
539512

540513
assert extension_test_hook.HasWindow
541514
assert unmaximized_rect == extension_dbus_interface.TargetRect
515+
assert extension_test_hook.ClientType == gdk_backend
542516

543517
extension_test_hook.wait_property('RenderedFirstFrame', True)
544518
wait_idle()
@@ -584,12 +558,14 @@ def test_mouse_resize(
584558
extension_test_hook,
585559
shell_test_hook,
586560
wait_idle,
561+
gdk_backend,
587562
):
588563
extension_dbus_interface.Activate(timeout=dbusutil.DEFAULT_LONG_TIMEOUT_MS)
589564
glibutil.dispatch_pending_sources()
590565

591566
assert extension_test_hook.HasWindow
592567
assert unmaximized_rect == extension_dbus_interface.TargetRect
568+
assert extension_test_hook.ClientType == gdk_backend
593569

594570
extension_test_hook.wait_property('RenderedFirstFrame', True)
595571
wait_idle()
@@ -642,6 +618,7 @@ def test_resize_maximize_unmaximize(
642618
settings_test_hook,
643619
shell_test_hook,
644620
wait_idle,
621+
gdk_backend,
645622
):
646623
settings_test_hook.window_maximize = False
647624

@@ -650,6 +627,7 @@ def test_resize_maximize_unmaximize(
650627

651628
assert extension_test_hook.HasWindow
652629
assert unmaximized_rect == extension_dbus_interface.TargetRect
630+
assert extension_test_hook.ClientType == gdk_backend
653631

654632
wait_idle()
655633

@@ -737,6 +715,12 @@ def monitor_layout(self, layout_mode, monitor0_scale, monitor1_scale):
737715

738716
return (displayconfig.SimpleMonitorConfig(scale=monitor0_scale),)
739717

718+
@pytest.fixture
719+
def gdk_backend(self, request):
720+
assert request.param == GdkBackend.X11
721+
722+
return request.param
723+
740724

741725
class TestWayland(CommonTests, fixtures.GnomeSessionWaylandFixtures):
742726
@pytest.fixture
@@ -759,6 +743,36 @@ def expected_show_transitions(
759743

760744
return animation_mode.expected_transitions(window_position)
761745

746+
@pytest.fixture
747+
def gdk_backend(
748+
self,
749+
request,
750+
dbus_connection,
751+
extension_test_hook,
752+
settings_test_hook,
753+
app_dbus_actions
754+
):
755+
force_x11 = request.param == GdkBackend.X11
756+
757+
# Make sure cached value is up to date
758+
glibutil.dispatch_pending_sources()
759+
760+
if settings_test_hook.force_x11_gdk_backend == force_x11:
761+
return request.param
762+
763+
if extension_test_hook.AppRunning:
764+
app_dbus_actions.activate_action('quit', None)
765+
766+
extension_test_hook.wait_property(
767+
'AppRunning',
768+
False,
769+
timeout=dbusutil.DEFAULT_LONG_TIMEOUT_MS
770+
)
771+
772+
settings_test_hook.force_x11_gdk_backend = force_x11
773+
774+
return request.param
775+
762776

763777
class TestWaylandTwoMonitors(TestWayland):
764778
@pytest.fixture

0 commit comments

Comments
 (0)