Skip to content

Commit

Permalink
don't use wayland backend in x11 tests
Browse files Browse the repository at this point in the history
We were previously using `manager_nospawn`, which is a fixture that enables
the test for both backends, even though this test is x11 specific. You can
see this with the failed test name+params here:

    FAILED test/backend/x11/test_window.py::test_urgent_hook_fire[wayland-2]

instead, let's introduce our own xmanager_nospawn, and use that.

This is the other half of #4762

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
  • Loading branch information
tych0 committed Apr 21, 2024
1 parent b6d4a89 commit 5db755d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
15 changes: 15 additions & 0 deletions test/backend/x11/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,21 @@ def xmanager(request, xephyr):
yield manager


@pytest.fixture(scope="function")
def xmanager_nospawn(request, xephyr):
"""
This replicates the `manager` fixture except that the x11 backend is hard-coded. We
cannot simply parametrize the `backend_name` fixture module-wide because it gets
parametrized by `pytest_generate_tests` in test/conftest.py and only one of these
parametrize calls can be used.
"""
backend = XBackend({"DISPLAY": xephyr.display}, args=[xephyr.display])

with TestManager(backend, request.config.getoption("--debuglog")) as manager:
manager.display = xephyr.display
yield manager


@pytest.fixture(scope="function")
def conn(xmanager):
conn = Connection(xmanager.display)
Expand Down
32 changes: 16 additions & 16 deletions test/backend/x11/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ class SmartConfig(BareConfig):


@dualmonitor
def test_urgent_hook_fire(manager_nospawn):
manager_nospawn.display = manager_nospawn.backend.env["DISPLAY"]
conn = Connection(manager_nospawn.display)
def test_urgent_hook_fire(xmanager_nospawn):
xmanager_nospawn.display = xmanager_nospawn.backend.env["DISPLAY"]
conn = Connection(xmanager_nospawn.display)

manager_nospawn.hook_fired = Value("i", 0)
xmanager_nospawn.hook_fired = Value("i", 0)

def _hook_test(val):
manager_nospawn.hook_fired.value += 1
xmanager_nospawn.hook_fired.value += 1

hook.subscribe.client_urgent_hint_changed(_hook_test)

manager_nospawn.start(UrgentConfig)
xmanager_nospawn.start(UrgentConfig)

manager_nospawn.test_window("one")
window_info = manager_nospawn.c.window.info()
xmanager_nospawn.test_window("one")
window_info = xmanager_nospawn.c.window.info()

# send activate window message
data = xcffib.xproto.ClientMessageData.synthetic([0, 0, 0, 0, 0], "IIIII")
Expand All @@ -95,25 +95,25 @@ def _hook_test(val):
conn.default_screen.root.send_event(ev, mask=xcffib.xproto.EventMask.SubstructureRedirect)
conn.xsync()

manager_nospawn.terminate()
assert manager_nospawn.hook_fired.value == 1
xmanager_nospawn.terminate()
assert xmanager_nospawn.hook_fired.value == 1

# test that focus_on_window_activation = "smart" also fires the hook
manager_nospawn.start(SmartConfig, no_spawn=True)
xmanager_nospawn.start(SmartConfig, no_spawn=True)

manager_nospawn.test_window("one")
window_info = manager_nospawn.c.window.info()
manager_nospawn.c.window.toscreen(1)
xmanager_nospawn.test_window("one")
window_info = xmanager_nospawn.c.window.info()
xmanager_nospawn.c.window.toscreen(1)

# send activate window message
ev = xcffib.xproto.ClientMessageEvent.synthetic(
32, window_info["id"], conn.atoms["_NET_ACTIVE_WINDOW"], data
)
conn.default_screen.root.send_event(ev, mask=xcffib.xproto.EventMask.SubstructureRedirect)
conn.xsync()
manager_nospawn.terminate()
xmanager_nospawn.terminate()

assert manager_nospawn.hook_fired.value == 2
assert xmanager_nospawn.hook_fired.value == 2


@manager_config
Expand Down

0 comments on commit 5db755d

Please sign in to comment.