mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-17 06:11:21 +01:00
feat(nix): the lifecycle_hidden scenario
A window put away on another workspace is managed again after the daemon stops and starts, and the ones in view are inside the work area and clear of each other. KdePlatform.start_komorebi waits for the unit to be gone first: systemctl start does nothing for a unit that is still stopping, and a daemon with a window put away took longer to exit. core-e2e passes 261 checks on KDE.
This commit is contained in:
1 parent
2be21aaa6d
commit
672a6951bd
4 files changed
+82
-1
No files matched your search
@@ -0,0 +1,50 @@
|
||||
"""A window that was put away on another workspace is not lost when the daemon restarts."""
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
from komorebi_vm.core.scenarios.support import focus_agrees
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
"""Sends the last of `clients`, which are tiled windows of workspace 0, to workspace 1,
|
||||
stops the daemon and starts it again.
|
||||
|
||||
Where the daemon puts the window afterwards is not asked for, only that it manages every
|
||||
window again and that the ones in view are inside the work area and clear of each other.
|
||||
"""
|
||||
target = clients[-1]
|
||||
platform.activate(target)
|
||||
platform.wait_for(lambda: focus_agrees(platform, clients, target.title))
|
||||
platform.komorebic("send-to-workspace", "1")
|
||||
checks.check(
|
||||
f"{target.title} is put away on workspace 1",
|
||||
platform.wait_for(lambda: platform.state().containers(1) == [[target.title]], timeout=20),
|
||||
)
|
||||
|
||||
platform.komorebic("stop")
|
||||
checks.check(
|
||||
"the daemon stops answering",
|
||||
platform.wait_for(lambda: platform.komorebic_status("state")[0] != 0, timeout=20),
|
||||
)
|
||||
platform.start_komorebi()
|
||||
checks.check(
|
||||
"the daemon manages every window again, the one that was put away too",
|
||||
platform.wait_for(lambda: platform.state().managed() >= len(clients), timeout=30),
|
||||
)
|
||||
checks.check(
|
||||
f"... and it has {target.title} on a workspace",
|
||||
platform.wait_for(lambda: platform.state().workspace_of(target.title) is not None),
|
||||
)
|
||||
area = platform.work_area()
|
||||
frames = [
|
||||
w.frame
|
||||
for c in clients
|
||||
if not platform.hidden(c) and (w := platform.os_window(c)) is not None
|
||||
]
|
||||
checks.check(
|
||||
"... the windows in view are inside the work area", all(f.inside(area) for f in frames)
|
||||
)
|
||||
checks.check(
|
||||
"... and not on each other",
|
||||
not any(a.overlaps(b) for i, a in enumerate(frames) for b in frames[i + 1 :]),
|
||||
)
|
||||
@@ -47,10 +47,13 @@ class KdePlatform:
|
||||
return self.kde.wait_for(predicate, timeout=timeout)
|
||||
|
||||
def start_komorebi(self) -> None:
|
||||
# a unit that is still stopping is not started again by `systemctl start`
|
||||
self.kde.wait_for(lambda: not self.kde.komorebi_running(), timeout=30)
|
||||
self.kde.start_komorebi()
|
||||
status = self.kde.wait_for(lambda: self.kde.run("komorebic state")[0] == 0, timeout=30)
|
||||
if not status:
|
||||
raise AssertionError("the daemon did not answer komorebic")
|
||||
tail = "\n".join(self.kde.komorebi_log().splitlines()[-30:])
|
||||
raise AssertionError(f"the daemon did not answer komorebic; its log ends:\n{tail}")
|
||||
|
||||
def restart_with(self, config: dict[str, Any]) -> None:
|
||||
if self.kde.komorebi_running():
|
||||
|
||||
@@ -12,6 +12,7 @@ from komorebi_vm.core.scenarios import (
|
||||
hotplug,
|
||||
layouts,
|
||||
lifecycle,
|
||||
lifecycle_hidden,
|
||||
maximizing,
|
||||
minimizing,
|
||||
monocle,
|
||||
@@ -383,6 +384,29 @@ def test_a_daemon_that_ignores_toggle_tiling_fails_tiling_off() -> None:
|
||||
assert checks.failed > 0
|
||||
|
||||
|
||||
def test_a_daemon_that_is_right_passes_lifecycle_hidden() -> None:
|
||||
platform = FakePlatform()
|
||||
checks = Checks()
|
||||
clients = opened(platform, checks)
|
||||
lifecycle_hidden.run(platform, checks, clients)
|
||||
assert checks.failed == 0, checks.failures
|
||||
assert checks.passed > 4
|
||||
|
||||
|
||||
def test_a_daemon_that_loses_the_put_away_window_fails_lifecycle_hidden() -> None:
|
||||
class Forgetful(FakePlatform):
|
||||
def start_komorebi(self) -> None:
|
||||
super().start_komorebi()
|
||||
self.spaces = [[c for c in self.spaces[0] if c != ["win3"]], [], []]
|
||||
self.unmanaged.append("win3")
|
||||
|
||||
platform = Forgetful()
|
||||
checks = Checks()
|
||||
clients = opened(platform, checks)
|
||||
lifecycle_hidden.run(platform, checks, clients)
|
||||
assert checks.failed > 0
|
||||
|
||||
|
||||
def test_a_command_the_port_lacks_is_skipped_by_name() -> None:
|
||||
platform = FakePlatform()
|
||||
checks = Checks()
|
||||
|
||||
@@ -22,6 +22,7 @@ from komorebi_vm.core.scenarios import (
|
||||
focus,
|
||||
layouts,
|
||||
lifecycle,
|
||||
lifecycle_hidden,
|
||||
maximizing,
|
||||
minimizing,
|
||||
monocle,
|
||||
@@ -496,6 +497,9 @@ checks.check("it is managed", kde.wait_for(lambda: kde.managed_all() == 1, timeo
|
||||
print("== 12b. a daemon that stops and starts again takes the windows up")
|
||||
lifecycle.run(platform, checks, [Client("afterwards"), platform.spawn("beside")])
|
||||
checks.check("the daemon answers", kde.wait_for(answering, timeout=30))
|
||||
print("== 12b2. the same, with a window put away on another workspace")
|
||||
lifecycle_hidden.run(platform, checks, [Client("afterwards"), Client("beside")])
|
||||
checks.check("the daemon answers", kde.wait_for(answering, timeout=30))
|
||||
platform.close(Client("after-the-restart"))
|
||||
platform.close(Client("beside"))
|
||||
checks.check("one window is left", kde.wait_for(lambda: kde.managed_all() == 1, timeout=20))
|
||||
|
||||
Reference in new issue
Block a user