feat(nix): the resize_commands scenario

resize-axis horizontal increase widens the focused window and decrease
gives the width back, with every window inside the work area and none
over another, and no pointer. core-e2e passes 237 checks on KDE.
This commit is contained in:
LGUG2Z committed 2026-10-30 12:03:00 -07:00
1 parent a8b30e1c1b
commit 9b1162dcbe
4 files changed
+74

No files matched your search

@@ -0,0 +1,43 @@
"""The resize commands move an edge of the focused window, with no pointer."""
from komorebi_vm.core.checks import Checks
from komorebi_vm.core.platform import Client, Platform
from komorebi_vm.core.scenarios.support import focus_agrees
# how much wider the window must get for the command to have done something
MIN_STEP = 10
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
"""Resizes the first of `clients`, which are tiled windows of the first workspace, with
`resize-axis horizontal increase` and `decrease`."""
target = clients[0]
platform.activate(target)
platform.wait_for(lambda: focus_agrees(platform, clients, target.title))
def width() -> int:
window = platform.os_window(target)
return window.frame.w if window is not None else 0
def clear() -> bool:
frames = [w.frame for c in clients if (w := platform.os_window(c)) is not None]
area = platform.work_area()
return all(f.inside(area) for f in frames) and not any(
a.overlaps(b) for i, a in enumerate(frames) for b in frames[i + 1 :]
)
before = width()
platform.komorebic("resize-axis", "horizontal", "increase")
checks.check(
f"after 'resize-axis horizontal increase' {target.title} is wider",
platform.wait_for(lambda: width() >= before + MIN_STEP, timeout=20),
)
print(f" width {before} -> {width()}")
checks.check("... and every window is inside the work area, none over another", clear())
platform.komorebic("resize-axis", "horizontal", "decrease")
checks.check(
"after 'decrease' it has the width it had",
platform.wait_for(lambda: abs(width() - before) <= platform.tolerance, timeout=20),
)
checks.check("... and every window is inside the work area, none over another", clear())
+7
View File
@@ -403,6 +403,13 @@ class FakePlatform:
self._relayout()
case ("toggle-maximize",):
self.maximized = None if self.maximized else self.containers[self.focus][0]
case ("resize-axis", "horizontal", way):
d = 50 if way == "increase" else -50
i = self.focus
if n > 1 and i < n - 1:
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 ("toggle-float",):
if self.floats:
self.containers.insert(self.focus, [self.floats.pop()])
@@ -18,6 +18,7 @@ from komorebi_vm.core.scenarios import (
padding,
placement,
resize,
resize_commands,
rules,
stacks,
startup_rules,
@@ -273,6 +274,27 @@ def test_a_daemon_that_does_not_follow_the_window_fails_workspace_moves() -> Non
assert checks.failed > 0
def test_a_daemon_that_is_right_passes_resize_commands() -> None:
platform = FakePlatform()
checks = Checks()
clients = opened(platform, checks)
resize_commands.run(platform, checks, clients)
assert checks.failed == 0, checks.failures
assert checks.passed > 3
def test_a_daemon_that_does_not_resize_fails_resize_commands() -> None:
class Stubborn(FakePlatform):
def komorebic(self, *args: str) -> str:
return "" if args[0] == "resize-axis" else super().komorebic(*args)
platform = Stubborn()
checks = Checks()
clients = opened(platform, checks)
resize_commands.run(platform, checks, clients)
assert checks.failed > 0
def test_a_command_the_port_lacks_is_skipped_by_name() -> None:
platform = FakePlatform()
checks = Checks()
+2
View File
@@ -27,6 +27,7 @@ from komorebi_vm.core.scenarios import (
moving,
padding,
placement,
resize_commands,
rules,
stacks,
startup_rules,
@@ -458,6 +459,7 @@ layouts.run(platform, checks, neutral)
floating.run(platform, checks, neutral)
minimizing.run(platform, checks, neutral)
maximizing.run(platform, checks, neutral)
resize_commands.run(platform, checks, neutral)
padding.run(platform, checks, neutral)
monocle.run(platform, checks, neutral)
workspace_moves.run(platform, checks, neutral)