From e375d0a151823fa084694526818efd51a8dd469b Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 01:22:45 -0700 Subject: [PATCH] feat(nix): the scrolling scenario In the scrolling layout each window in turn, given the focus, has it and is inside the work area; changed back to bsp, every window is where the layout says. core-e2e passes 265 checks on KDE. --- .../komorebi_vm/core/scenarios/scrolling.py | 33 +++++++++++++++++++ nix/tests/vm/lib/tests/test_focus_moving.py | 26 +++++++++++++++ nix/tests/vm/suites/core-e2e/test.py | 2 ++ 3 files changed, 61 insertions(+) create mode 100644 nix/tests/vm/lib/komorebi_vm/core/scenarios/scrolling.py diff --git a/nix/tests/vm/lib/komorebi_vm/core/scenarios/scrolling.py b/nix/tests/vm/lib/komorebi_vm/core/scenarios/scrolling.py new file mode 100644 index 00000000..f082748f --- /dev/null +++ b/nix/tests/vm/lib/komorebi_vm/core/scenarios/scrolling.py @@ -0,0 +1,33 @@ +"""In the scrolling layout the window that has the focus is in view, wherever the others are.""" + +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: + """Changes the layout of the first workspace, which has `clients` tiled in a container each, + to scrolling, gives each of them the focus in turn, and changes it back to bsp.""" + area = platform.work_area() + + def in_view(client: Client) -> bool: + window = platform.os_window(client) + return window is not None and window.frame.inside(area) + + platform.komorebic("change-layout", "scrolling") + for client in clients: + platform.activate(client) + checks.check( + f"in scrolling, {client.title} has the focus and is inside the work area", + platform.wait_for( + lambda c=client: focus_agrees(platform, clients, c.title) and in_view(c), + timeout=20, + ), + ) + + platform.komorebic("change-layout", "bsp") + checks.check( + "back in bsp every window is where the layout says", + platform.wait_for(lambda: tiled(platform, clients), timeout=20), + ) diff --git a/nix/tests/vm/lib/tests/test_focus_moving.py b/nix/tests/vm/lib/tests/test_focus_moving.py index 6b4606f9..aeb9520c 100644 --- a/nix/tests/vm/lib/tests/test_focus_moving.py +++ b/nix/tests/vm/lib/tests/test_focus_moving.py @@ -2,6 +2,7 @@ from komorebi_vm.core.checks import Checks from komorebi_vm.core.geometry import Rect +from komorebi_vm.core.platform import OsWindow from komorebi_vm.core.scenarios import ( closing, commands, @@ -24,6 +25,7 @@ from komorebi_vm.core.scenarios import ( resize, resize_commands, rules, + scrolling, stacks, startup_rules, tiling, @@ -407,6 +409,30 @@ def test_a_daemon_that_loses_the_put_away_window_fails_lifecycle_hidden() -> Non assert checks.failed > 0 +def test_a_daemon_that_is_right_passes_scrolling() -> None: + platform = FakePlatform() + checks = Checks() + clients = opened(platform, checks) + scrolling.run(platform, checks, clients) + assert checks.failed == 0, checks.failures + assert checks.passed > 3 + + +def test_a_daemon_that_loses_the_focused_window_off_screen_fails_scrolling() -> None: + class Off(FakePlatform): + def os_window(self, client): # noqa: ANN001, ANN201 + window = super().os_window(client) + if window is not None and window.focused: + return OsWindow(window.title, Rect(5000, 0, 100, 100), focused=True) + return window + + platform = Off() + checks = Checks() + clients = opened(platform, checks) + scrolling.run(platform, checks, clients) + assert checks.failed > 0 + + def test_a_command_the_port_lacks_is_skipped_by_name() -> None: platform = FakePlatform() checks = Checks() diff --git a/nix/tests/vm/suites/core-e2e/test.py b/nix/tests/vm/suites/core-e2e/test.py index c61a0c3a..220ae828 100644 --- a/nix/tests/vm/suites/core-e2e/test.py +++ b/nix/tests/vm/suites/core-e2e/test.py @@ -33,6 +33,7 @@ from komorebi_vm.core.scenarios import ( promoting, resize_commands, rules, + scrolling, stacks, startup_rules, tiling, @@ -469,6 +470,7 @@ promoting.run(platform, checks, neutral) flipping.run(platform, checks, neutral) pausing.run(platform, checks, neutral) tiling_off.run(platform, checks, neutral) +scrolling.run(platform, checks, neutral) padding.run(platform, checks, neutral) monocle.run(platform, checks, neutral) workspace_moves.run(platform, checks, neutral)