mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-17 14:21:22 +01:00
feat(nix): the promoting scenario
promote puts the focused window on the first tile and keeps its focus, with every window where the layout says. core-e2e passes 241 checks on KDE.
This commit is contained in:
1 parent
211acae92d
commit
63d5833a84
4 files changed
+62
No files matched your search
@@ -0,0 +1,35 @@
|
||||
"""A promoted window takes the first tile, and keeps the focus."""
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
from komorebi_vm.core.scenarios.layouts import tiled
|
||||
from komorebi_vm.core.scenarios.support import focus_agrees
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
"""Promotes the last of `clients`, which are tiled windows of the first workspace in a
|
||||
container each, with more than one of them."""
|
||||
target = clients[-1]
|
||||
platform.activate(target)
|
||||
platform.wait_for(lambda: focus_agrees(platform, clients, target.title))
|
||||
first = platform.state().workspace().latest_layout[0]
|
||||
|
||||
platform.komorebic("promote")
|
||||
checks.check(
|
||||
f"after 'promote' the daemon has {target.title} in the first container",
|
||||
platform.wait_for(lambda: platform.state().containers()[0] == [target.title], timeout=20),
|
||||
)
|
||||
|
||||
def on_the_first_tile() -> bool:
|
||||
window = platform.os_window(target)
|
||||
return window is not None and (window.frame.x, window.frame.y) == (first.x, first.y)
|
||||
|
||||
checks.check("... and the window is on the first tile", platform.wait_for(on_the_first_tile))
|
||||
checks.check(
|
||||
"... every window is where the layout says",
|
||||
platform.wait_for(lambda: tiled(platform, clients), timeout=20),
|
||||
)
|
||||
checks.check(
|
||||
"... and the window still has the focus",
|
||||
platform.wait_for(lambda: focus_agrees(platform, clients, target.title), timeout=20),
|
||||
)
|
||||
@@ -410,6 +410,9 @@ class FakePlatform:
|
||||
a, b = self.tiles[i], self.tiles[i + 1]
|
||||
self.tiles[i] = Rect(a.x, a.y, a.w + d, a.h)
|
||||
self.tiles[i + 1] = Rect(b.x + d, b.y, b.w - d, b.h)
|
||||
case ("promote",):
|
||||
self.containers.insert(0, self.containers.pop(self.focus))
|
||||
self.focus = 0
|
||||
case ("toggle-float",):
|
||||
if self.floats:
|
||||
self.containers.insert(self.focus, [self.floats.pop()])
|
||||
|
||||
@@ -17,6 +17,7 @@ from komorebi_vm.core.scenarios import (
|
||||
moving,
|
||||
padding,
|
||||
placement,
|
||||
promoting,
|
||||
resize,
|
||||
resize_commands,
|
||||
rules,
|
||||
@@ -295,6 +296,27 @@ def test_a_daemon_that_does_not_resize_fails_resize_commands() -> None:
|
||||
assert checks.failed > 0
|
||||
|
||||
|
||||
def test_a_daemon_that_is_right_passes_promoting() -> None:
|
||||
platform = FakePlatform()
|
||||
checks = Checks()
|
||||
clients = opened(platform, checks)
|
||||
promoting.run(platform, checks, clients)
|
||||
assert checks.failed == 0, checks.failures
|
||||
assert checks.passed > 3
|
||||
|
||||
|
||||
def test_a_daemon_that_does_not_promote_fails_promoting() -> None:
|
||||
class Stubborn(FakePlatform):
|
||||
def komorebic(self, *args: str) -> str:
|
||||
return "" if args == ("promote",) else super().komorebic(*args)
|
||||
|
||||
platform = Stubborn()
|
||||
checks = Checks()
|
||||
clients = opened(platform, checks)
|
||||
promoting.run(platform, checks, clients)
|
||||
assert checks.failed > 0
|
||||
|
||||
|
||||
def test_a_command_the_port_lacks_is_skipped_by_name() -> None:
|
||||
platform = FakePlatform()
|
||||
checks = Checks()
|
||||
|
||||
@@ -27,6 +27,7 @@ from komorebi_vm.core.scenarios import (
|
||||
moving,
|
||||
padding,
|
||||
placement,
|
||||
promoting,
|
||||
resize_commands,
|
||||
rules,
|
||||
stacks,
|
||||
@@ -460,6 +461,7 @@ floating.run(platform, checks, neutral)
|
||||
minimizing.run(platform, checks, neutral)
|
||||
maximizing.run(platform, checks, neutral)
|
||||
resize_commands.run(platform, checks, neutral)
|
||||
promoting.run(platform, checks, neutral)
|
||||
padding.run(platform, checks, neutral)
|
||||
monocle.run(platform, checks, neutral)
|
||||
workspace_moves.run(platform, checks, neutral)
|
||||
|
||||
Reference in new issue
Block a user