mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-19 07:08:48 +01:00
fix(nix): shared scenarios take their pixels and waits from the platform
The quiet period of three seconds was written in nine places, each a number. It is support.QUIET. The window the lock scenario moves is a third into the work area, not at 400,300, and the scenario now checks that it moved, or the check that it is back in its tile after the unlock proves nothing. The room the padding must change by, the pointer drag and the tile hotplug checks after an unplug come from the work area.
This commit is contained in:
1 parent
1c701333ad
commit
5c4621ae44
14 files changed
+86
-21
No files matched your search
@@ -4,6 +4,7 @@ from typing import Any
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Platform
|
||||
from komorebi_vm.core.scenarios.support import QUIET
|
||||
|
||||
|
||||
def _config(names: list[str], layout: str, rule: str | None = None) -> dict[str, Any]:
|
||||
@@ -60,7 +61,7 @@ def run(platform: Platform, checks: Checks) -> None:
|
||||
|
||||
platform.rewrite_config(_config(["uno", "dos", "tres"], "Columns"))
|
||||
# the reload does not say when it is done: the next window shows whether the rule is
|
||||
platform.wait_for(lambda: False, timeout=3)
|
||||
platform.wait_for(lambda: False, timeout=QUIET)
|
||||
later = platform.spawn("reload-sent-2")
|
||||
checks.check(
|
||||
"once the file loses the rule, a window of that title stays on the first workspace",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
from komorebi_vm.core.scenarios.support import QUIET
|
||||
|
||||
|
||||
def _middle(platform: Platform, client: Client) -> tuple[int, int] | None:
|
||||
@@ -68,7 +69,7 @@ def run(platform: Platform, checks: Checks, first: Client, second: Client) -> No
|
||||
platform.pointer.move(*b)
|
||||
checks.check(
|
||||
"turned off, the pointer over the second window no longer moves the focus",
|
||||
not platform.wait_for(lambda: _focused(platform, second), timeout=3)
|
||||
not platform.wait_for(lambda: _focused(platform, second), timeout=QUIET)
|
||||
and _focused(platform, first),
|
||||
)
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
managed = platform.state().managed()
|
||||
|
||||
platform.remove_display()
|
||||
first = platform.displays()[0]
|
||||
checks.check(
|
||||
"after a display is unplugged the daemon has one monitor fewer",
|
||||
platform.wait_for(lambda: _monitors(platform) == len(platform.displays()), timeout=30),
|
||||
@@ -50,7 +49,10 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
platform.wait_for(
|
||||
lambda: (
|
||||
_in_one_of(platform, clients, platform.displays())
|
||||
and (len(platform.displays()) > 1 or _tiled_in(platform, clients, first))
|
||||
and (
|
||||
len(platform.displays()) > 1
|
||||
or _tiled_in(platform, clients, platform.work_area())
|
||||
)
|
||||
),
|
||||
timeout=30,
|
||||
),
|
||||
|
||||
@@ -36,7 +36,22 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
"while the screen is locked the daemon has the same windows: the lock screen is not one",
|
||||
platform.state().managed() == len(clients),
|
||||
)
|
||||
platform.move_window(clients[0], 400, 300)
|
||||
# a third of the way into the work area, and not on the tile the window is on
|
||||
area = platform.work_area()
|
||||
tile = platform.os_window(clients[0])
|
||||
assert tile is not None
|
||||
target = (area.x + area.w // 3, area.y + area.h // 3)
|
||||
if target == (tile.frame.x, tile.frame.y):
|
||||
target = (target[0] + 50, target[1] + 50)
|
||||
platform.move_window(clients[0], *target)
|
||||
moved = platform.wait_for(
|
||||
lambda: (
|
||||
(w := platform.os_window(clients[0])) is not None
|
||||
and (w.frame.x, w.frame.y) != (tile.frame.x, tile.frame.y)
|
||||
),
|
||||
timeout=10,
|
||||
)
|
||||
checks.check("the window was moved while the screen was locked", moved)
|
||||
after = [platform.os_window(c) for c in clients]
|
||||
checks.check(
|
||||
"the others did not move for it",
|
||||
|
||||
@@ -4,9 +4,7 @@ from typing import Any
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
|
||||
# how long a window has to stay unmanaged for it to be left alone
|
||||
QUIET = 3
|
||||
from komorebi_vm.core.scenarios.support import QUIET
|
||||
|
||||
|
||||
def _kinds(platform: Platform) -> list[tuple[str, str, dict[str, Any]]]:
|
||||
|
||||
@@ -21,6 +21,9 @@ def run(
|
||||
container = configured[1] if state.container_padding is None else state.container_padding
|
||||
print(f" padding of the workspace {workspace}, of its containers {container}")
|
||||
area = platform.work_area()
|
||||
# how much room the windows must lose or regain, in square pixels: a small part of the work
|
||||
# area, for the display is not the same size on every platform
|
||||
unit = area.w * area.h // 400
|
||||
|
||||
def frames() -> list[Rect]:
|
||||
return [w.frame for c in clients if (w := platform.os_window(c)) is not None]
|
||||
@@ -61,7 +64,7 @@ def run(
|
||||
platform.komorebic("focused-workspace-container-padding", str(container + 30))
|
||||
checks.check(
|
||||
"a container padding 30 px more leaves the windows less room",
|
||||
platform.wait_for(lambda: room() < base - 5000, timeout=20),
|
||||
platform.wait_for(lambda: room() < base - unit, timeout=20),
|
||||
)
|
||||
checks.check(
|
||||
"... and none is over another, or outside the work area",
|
||||
@@ -77,5 +80,5 @@ def run(
|
||||
print(f" margin {margin()} (was {start}), room {room()} (was {base})")
|
||||
checks.check(
|
||||
"... and have the room they had",
|
||||
platform.wait_for(lambda: abs(room() - base) <= 2000, timeout=20),
|
||||
platform.wait_for(lambda: abs(room() - base) <= unit // 2, timeout=20),
|
||||
)
|
||||
@@ -3,9 +3,7 @@
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
from komorebi_vm.core.scenarios.layouts import tiled
|
||||
|
||||
# how long a daemon that is paused has to leave a window alone for it to count
|
||||
QUIET = 3
|
||||
from komorebi_vm.core.scenarios.support import QUIET
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
|
||||
@@ -6,6 +6,8 @@ from komorebi_vm.core.platform import Client, Platform
|
||||
|
||||
# how far outside a window's frame its resize border is pressed: the gap between two tiles
|
||||
OFFSET = 4
|
||||
# the shortest drag, in pixels: far enough to be a drag on any display
|
||||
MIN_DRAG = 60
|
||||
# how far the edge may end up from where the pointer put it, in pixels
|
||||
SLACK = 6
|
||||
|
||||
@@ -20,8 +22,9 @@ def _side_by_side(layout: list[Rect]) -> tuple[int, int] | None:
|
||||
return None
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks, clients: list[Client], dx: int = 60) -> None:
|
||||
"""Drags the edge between a tile and the one to its right by `dx` pixels, and checks that the
|
||||
def run(platform: Platform, checks: Checks, clients: list[Client], dx: int | None = None) -> None:
|
||||
"""Drags the edge between a tile and the one to its right by `dx` pixels (a thirty-second of
|
||||
the work area's width, and at least `MIN_DRAG`, when it is not given), and checks that the
|
||||
two tiles moved the edge by what the pointer moved, that every other edge stayed, and that the
|
||||
windows still tile on the work area, as the operating system has them.
|
||||
|
||||
@@ -30,6 +33,8 @@ def run(platform: Platform, checks: Checks, clients: list[Client], dx: int = 60)
|
||||
if not platform.has("pointer"):
|
||||
print(" skipped: this platform has no pointer")
|
||||
return
|
||||
if dx is None:
|
||||
dx = max(MIN_DRAG, platform.work_area().w // 32)
|
||||
state = platform.state()
|
||||
workspace = state.workspace()
|
||||
layout = workspace.latest_layout
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Platform
|
||||
from komorebi_vm.core.scenarios.support import QUIET
|
||||
|
||||
|
||||
def _on(platform: Platform, title: str) -> int | None:
|
||||
@@ -45,7 +46,7 @@ def run(platform: Platform, checks: Checks) -> None:
|
||||
# on purpose, so what is checked is that the daemon does not send the window back on its own
|
||||
checks.check(
|
||||
"... and an initial rule does not send it there again on its own",
|
||||
not platform.wait_for(lambda: _on(platform, "sent-once") != 0, timeout=3),
|
||||
not platform.wait_for(lambda: _on(platform, "sent-once") != 0, timeout=QUIET),
|
||||
)
|
||||
|
||||
always = platform.spawn("sent-always")
|
||||
@@ -80,7 +81,7 @@ def run(platform: Platform, checks: Checks) -> None:
|
||||
checks.check(
|
||||
"once the rules are cleared, a window they matched stays on the workspace in view",
|
||||
platform.wait_for(lambda: _on(platform, "sent-once") == 0, timeout=20)
|
||||
and not platform.wait_for(lambda: _on(platform, "sent-once") != 0, timeout=3),
|
||||
and not platform.wait_for(lambda: _on(platform, "sent-once") != 0, timeout=QUIET),
|
||||
)
|
||||
for client in (always, ignored, later):
|
||||
platform.close(client)
|
||||
@@ -3,6 +3,7 @@ is left alone."""
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Platform
|
||||
from komorebi_vm.core.scenarios.support import QUIET
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks) -> None:
|
||||
@@ -30,7 +31,7 @@ def run(platform: Platform, checks: Checks) -> None:
|
||||
checks.check(
|
||||
"a window an ignore rule by class matches is not managed",
|
||||
not platform.wait_for(
|
||||
lambda: platform.state().workspace_of(left.title) is not None, timeout=3
|
||||
lambda: platform.state().workspace_of(left.title) is not None, timeout=QUIET
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ rule has, whatever its kind."""
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.platform import Platform
|
||||
from komorebi_vm.core.scenarios.support import QUIET
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks) -> None:
|
||||
@@ -34,7 +35,7 @@ def run(platform: Platform, checks: Checks) -> None:
|
||||
checks.check(
|
||||
"a window an ignore rule by exe matches is not managed",
|
||||
not platform.wait_for(
|
||||
lambda: platform.state().workspace_of(left.title) is not None, timeout=3
|
||||
lambda: platform.state().workspace_of(left.title) is not None, timeout=QUIET
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
from komorebi_vm.core.geometry import Rect
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
|
||||
# how long something that must not happen is waited for, in seconds (scaled for the host): a window
|
||||
# a rule leaves alone, a window that stays where it is. It is more than the daemon takes to act on
|
||||
# an event on either port, and the price of every such check
|
||||
QUIET = 3
|
||||
|
||||
|
||||
def os_focused(platform: Platform, clients: list[Client]) -> str:
|
||||
"""The title of the window the operating system says has the focus, among `clients`.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
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 positions
|
||||
from komorebi_vm.core.scenarios.support import QUIET, positions
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
@@ -20,7 +20,7 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
platform.komorebic("change-layout", "columns")
|
||||
checks.check(
|
||||
"... a layout change does not move them either",
|
||||
not platform.wait_for(lambda: positions(platform, clients) != before, timeout=3),
|
||||
not platform.wait_for(lambda: positions(platform, clients) != before, timeout=QUIET),
|
||||
)
|
||||
|
||||
platform.komorebic("toggle-tiling")
|
||||
|
||||
@@ -884,3 +884,37 @@ def test_focus_follows_mouse_is_driven_without_naming_an_implementation() -> Non
|
||||
focus_follows_mouse.run(platform, checks, clients[0], clients[2])
|
||||
assert checks.failed == 0, checks.failures
|
||||
assert not [a for a in platform.said if "--implementation" in a]
|
||||
|
||||
|
||||
def test_the_window_is_moved_inside_the_work_area_of_the_platform_while_locked() -> None:
|
||||
class Records(FakePlatform):
|
||||
def __init__(self) -> None:
|
||||
super().__init__(panel=40)
|
||||
self.targets: list[tuple[int, int]] = []
|
||||
|
||||
def move_window(self, client: Client, x: int, y: int) -> None:
|
||||
self.targets.append((x, y))
|
||||
super().move_window(client, x, y)
|
||||
|
||||
platform = Records()
|
||||
checks = Checks()
|
||||
clients = opened(platform, checks)
|
||||
locking.run(platform, checks, clients)
|
||||
assert checks.failed == 0, checks.failures
|
||||
(x, y) = platform.targets[0]
|
||||
assert platform.work_area().x <= x < platform.work_area().w
|
||||
assert platform.work_area().y <= y < platform.work_area().h
|
||||
|
||||
|
||||
def test_a_platform_that_cannot_move_a_window_while_locked_fails_locking() -> None:
|
||||
"""Else the check that the window is back in its tile after the unlock is a vacuous one."""
|
||||
|
||||
class Cannot(FakePlatform):
|
||||
def move_window(self, client: Client, x: int, y: int) -> None:
|
||||
pass
|
||||
|
||||
platform = Cannot()
|
||||
checks = Checks()
|
||||
clients = opened(platform, checks)
|
||||
locking.run(platform, checks, clients)
|
||||
assert any("was moved while the screen was locked" in f for f in checks.failures)
|
||||
Reference in new issue
Block a user