diff --git a/e2e/lib/komorebi_vm/core/platform.py b/e2e/lib/komorebi_vm/core/platform.py index b25fafc8..9309d6a8 100644 --- a/e2e/lib/komorebi_vm/core/platform.py +++ b/e2e/lib/komorebi_vm/core/platform.py @@ -128,10 +128,15 @@ class Platform(Protocol): `exe` is the name of the program that opens it, without an extension (`e2e-exe` is `e2e-exe.exe` on Windows and `e2e-exe` on Linux), for a rule that matches by it. The - platform makes a program of that name; a rule's `id` is the same on every platform. + platform makes a program of that name, and `exe_id` spells the id of a rule for it. """ ... + def exe_id(self, program: str) -> str: + """The `id` of a rule that matches the windows of the program `spawn(exe=program)` opens: + the program's file name, which is `program` on Linux and `program.exe` on Windows.""" + ... + def os_window(self, client: Client) -> OsWindow | None: """What the operating system says about the window, or `None` if it has none.""" ... diff --git a/e2e/lib/komorebi_vm/core/scenarios/rules_exe.py b/e2e/lib/komorebi_vm/core/scenarios/rules_exe.py index 666f372b..decf25b1 100644 --- a/e2e/lib/komorebi_vm/core/scenarios/rules_exe.py +++ b/e2e/lib/komorebi_vm/core/scenarios/rules_exe.py @@ -1,6 +1,6 @@ """Rules that match a window by the program that opened it decide where it goes, or that it is left alone. The program is `e2e-exe-sent.exe` on Windows and `e2e-exe-sent` on Linux, and the -rule is the same. +rule's id is `platform.exe_id(program)`. The names differ from those of `rules_class`: `ignore-rule` drops a rule whose id an earlier rule has, whatever its kind.""" @@ -17,8 +17,8 @@ def run(platform: Platform, checks: Checks) -> None: and with workspaces 0 and 1. The rules are cleared afterwards. """ platform.komorebic("ensure-workspaces", "0", "2") - platform.komorebic("workspace-rule", "exe", "e2e-exe-sent", "0", "1") - platform.komorebic("ignore-rule", "exe", "e2e-exe-left") + platform.komorebic("workspace-rule", "exe", platform.exe_id("e2e-exe-sent"), "0", "1") + platform.komorebic("ignore-rule", "exe", platform.exe_id("e2e-exe-left")) sent = platform.spawn("by-exe-sent", exe="e2e-exe-sent") checks.check( diff --git a/e2e/lib/tests/fake_platform.py b/e2e/lib/tests/fake_platform.py index 88d6095f..4a9f52ba 100644 --- a/e2e/lib/tests/fake_platform.py +++ b/e2e/lib/tests/fake_platform.py @@ -347,6 +347,9 @@ class FakePlatform: def screenshot(self, name: str) -> Image.Image: return Image.new("RGB", (4, 4)) + def exe_id(self, program: str) -> str: + return program + def os_window(self, client: Client) -> OsWindow | None: if client.title == self.maximized: return OsWindow(client.title, Rect(0, 0, 1920, 1080), focused=True) diff --git a/e2e/lib/tests/test_tiling.py b/e2e/lib/tests/test_tiling.py index 007ccef2..283f705f 100644 --- a/e2e/lib/tests/test_tiling.py +++ b/e2e/lib/tests/test_tiling.py @@ -69,6 +69,9 @@ class FakePlatform: def komorebic(self, *args: str) -> str: return "" + def exe_id(self, program: str) -> str: + return program + def minimize(self, client: Client) -> None: pass