mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-15 21:32:26 +01:00
feat(e2e): sync the neutral core from kfde 6fb6a66e
This commit is contained in:
1 parent
c51f79acb5
commit
6a05754308
7 files changed
+493
-9
No files matched your search
@@ -258,6 +258,31 @@ class Platform(Protocol):
|
||||
size."""
|
||||
...
|
||||
|
||||
def put_file(self, path: str, data: bytes) -> None:
|
||||
"""Writes `data` to `path` on the machine, where the daemon can read it, and makes the
|
||||
directories above it. `path` is one `temp_path` made."""
|
||||
...
|
||||
|
||||
def wallpaper(self, display: int = 0) -> str:
|
||||
"""The path of the picture a display shows, as the operating system says it (the Plasma
|
||||
shell on KDE, `IDesktopWallpaper` on Windows), or the empty string when it does not know."""
|
||||
...
|
||||
|
||||
def set_wallpaper(self, path: str, display: int = 0) -> None:
|
||||
"""Sets the wallpaper of a display as the user does, and returns when it is set."""
|
||||
...
|
||||
|
||||
def resize_grab(self, frame: Rect, grab: str) -> tuple[int, int]:
|
||||
"""Where the pointer is pressed to take a window of this frame by `grab`: `left`, `right`,
|
||||
`top`, `bottom`, or a corner (`topleft`, `topright`, `bottomleft`, `bottomright`).
|
||||
|
||||
It is the platform's knowledge, because where a window's resize zone is differs: on KDE it
|
||||
is the gap outside the frame on every side (`resize.outside_grab`), on Windows the left,
|
||||
right and bottom zones are an invisible border outside the visible frame, and the top one
|
||||
is inside it.
|
||||
"""
|
||||
...
|
||||
|
||||
def fullscreen(self, client: Client, on: bool = True) -> None:
|
||||
"""Takes the window fullscreen, as the program's own key does it (`on`), or brings it back
|
||||
from fullscreen (`on` false). The daemon is not asked: it learns of it from the system, and
|
||||
|
||||
@@ -5,7 +5,8 @@ from komorebi_vm.core.geometry import Rect
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
from komorebi_vm.core.scenarios.layouts import tiled
|
||||
|
||||
# how far outside a window's frame its resize border is pressed: the gap between two tiles
|
||||
# how far outside a window's frame its resize border is pressed by a platform whose border is the
|
||||
# gap between two tiles (`outside_grab`)
|
||||
OFFSET = 4
|
||||
# the shortest drag, in pixels: far enough to be a drag on any display
|
||||
MIN_DRAG = 60
|
||||
@@ -48,7 +49,7 @@ def run(platform: Platform, checks: Checks, clients: list[Client], dx: int | Non
|
||||
window = platform.os_window(Client(titles[left]))
|
||||
assert window is not None
|
||||
before = list(layout)
|
||||
grab = (window.frame.x + window.frame.w + OFFSET, window.frame.y + window.frame.h // 2)
|
||||
grab = platform.resize_grab(window.frame, "right")
|
||||
|
||||
platform.pointer.drag(grab, (grab[0] + dx, grab[1]))
|
||||
|
||||
@@ -140,8 +141,9 @@ def _settled(platform: Platform, clients: list[Client]) -> dict[str, Rect]:
|
||||
return last
|
||||
|
||||
|
||||
def _press_point(grab: str, r: Rect) -> tuple[int, int]:
|
||||
"""Where the pointer is pressed for a grab: in the gap outside the frame."""
|
||||
def outside_grab(r: Rect, grab: str) -> tuple[int, int]:
|
||||
"""Where the pointer is pressed for a grab by a platform whose resize border is the gap outside
|
||||
the frame, `OFFSET` pixels from it: what KDE has on every side."""
|
||||
left, right, top, bottom = r.x - OFFSET, r.x + r.w + OFFSET, r.y - OFFSET, r.y + r.h + OFFSET
|
||||
cx, cy = r.x + r.w // 2, r.y + r.h // 2
|
||||
return {
|
||||
@@ -184,7 +186,9 @@ def _stacked(layout: list[Rect]) -> tuple[int, int] | None:
|
||||
return None
|
||||
|
||||
|
||||
def _cases(layout: list[Rect], titles: list[str], area: Rect) -> list[tuple[str, str, int, int]]:
|
||||
def _cases(
|
||||
platform: Platform, layout: list[Rect], titles: list[str], area: Rect
|
||||
) -> list[tuple[str, str, int, int]]:
|
||||
"""Drags to make, as (window, grab, dx, dy), from the layout: both sides of an edge that two
|
||||
tiles share, a horizontal one, a corner next to two neighbours, and an edge of the screen."""
|
||||
cases: list[tuple[str, str, int, int]] = []
|
||||
@@ -212,7 +216,7 @@ def _cases(layout: list[Rect], titles: list[str], area: Rect) -> list[tuple[str,
|
||||
cases.append((titles[k], "bottomleft", -72, 72))
|
||||
break
|
||||
first = min(range(len(layout)), key=lambda i: layout[i].x)
|
||||
if _press_point("left", layout[first])[0] >= area.x:
|
||||
if platform.resize_grab(layout[first], "left")[0] >= area.x:
|
||||
cases.append((titles[first], "left", -72, 0))
|
||||
return cases
|
||||
|
||||
@@ -230,7 +234,7 @@ def _problems(
|
||||
before = _settled(platform, clients)
|
||||
tiles_before = _tiles(platform)
|
||||
|
||||
px, py = _press_point(grab, before[name])
|
||||
px, py = platform.resize_grab(before[name], grab)
|
||||
end = (max(area.x, px + dx), max(area.y, py + dy))
|
||||
platform.pointer.drag((px, py), end)
|
||||
platform.wait_for(lambda: _tiles(platform) != tiles_before, timeout=3)
|
||||
@@ -303,7 +307,7 @@ def edge_cases(platform: Platform, checks: Checks, clients: list[Client]) -> Non
|
||||
tiles = _tiles(platform)
|
||||
titles = list(tiles)
|
||||
layout = [tiles[t] for t in titles]
|
||||
for case in _cases(layout, titles, platform.work_area()):
|
||||
for case in _cases(platform, layout, titles, platform.work_area()):
|
||||
problems = _problems(platform, clients, case)
|
||||
name, grab, dx, dy = case
|
||||
checks.check(
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
"""In the scrolling layout the window that has the focus is in view, wherever the others are."""
|
||||
"""In the scrolling layout the window that has the focus is in view, wherever the others are.
|
||||
|
||||
`run` checks that on the windows a suite has open. `columns` opens five windows of its own in two
|
||||
columns, and checks where the strip puts the ones that are out of view, that it scrolls with the
|
||||
focus and with `pan`, and the commands of the columns (`consume`, `expel`, `toggle-column-stack`,
|
||||
`scrolling-layout-full-width`). Both ports lay the strip out with the same model.
|
||||
"""
|
||||
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.geometry import Rect
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
from komorebi_vm.core.scenarios.layouts import tiled
|
||||
from komorebi_vm.core.scenarios.monitors import _plug
|
||||
from komorebi_vm.core.scenarios.support import focus_agrees
|
||||
|
||||
STRIP = 5
|
||||
|
||||
# how many pixels of a window that rests at an edge of the work area are on the screen: 5 of them by
|
||||
# design, and the paddings, what the compositor rounds and a terminal's grid of cells are the rest
|
||||
PARKED_AT_MOST = 30
|
||||
|
||||
|
||||
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,
|
||||
@@ -31,3 +45,203 @@ def run(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
"back in bsp every window is where the layout says",
|
||||
platform.wait_for(lambda: tiled(platform, clients), timeout=20),
|
||||
)
|
||||
|
||||
|
||||
def columns(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
"""Five windows in two columns on a workspace with none: the last two are in view and the
|
||||
others are scrolled out, where the system keeps them; focusing to the far left and back, and
|
||||
`pan`, scroll the strip; then the commands of a column of several windows. The layout is bsp
|
||||
again and the windows are closed at the end."""
|
||||
area = platform.work_area()
|
||||
left, right = area.x, area.x + area.w
|
||||
tol = platform.tolerance
|
||||
titles = [f"strip{i}" for i in range(1, STRIP + 1)]
|
||||
|
||||
def frame(i: int) -> Rect:
|
||||
window = platform.os_window(Client(titles[i - 1]))
|
||||
return window.frame if window is not None else Rect(0, 0, 0, 0)
|
||||
|
||||
def in_view(i: int) -> bool:
|
||||
r = frame(i)
|
||||
return r.x >= left - tol and r.x + r.w <= right + tol
|
||||
|
||||
def out_of_view(i: int) -> bool:
|
||||
r = frame(i)
|
||||
return r.x >= right - PARKED_AT_MOST or r.x + r.w <= left + PARKED_AT_MOST
|
||||
|
||||
def agree(i: int) -> bool:
|
||||
return focus_agrees(platform, [Client(t) for t in titles], titles[i - 1])
|
||||
|
||||
def wait(predicate, timeout: float = 10) -> bool: # noqa: ANN001
|
||||
return platform.wait_for(predicate, timeout=timeout)
|
||||
|
||||
platform.komorebic("change-layout", "scrolling")
|
||||
platform.komorebic("scrolling-layout-columns", "2")
|
||||
opened = [platform.spawn(t) for t in titles]
|
||||
checks.check(
|
||||
"the daemon manages all five", wait(lambda: platform.state().managed() >= STRIP, 20)
|
||||
)
|
||||
checks.check(
|
||||
"the focused (last) window is in view, and so is the one before it",
|
||||
wait(lambda: in_view(5) and in_view(4), 20),
|
||||
)
|
||||
checks.check(
|
||||
"the first three are scrolled out of view",
|
||||
wait(lambda: all(out_of_view(i) for i in (1, 2, 3)), 20),
|
||||
)
|
||||
# the window rests with its right edge a few pixels inside the work area, as wide as the one
|
||||
# in view: nothing pulled it further onto the screen, and nothing was resized. A terminal draws
|
||||
# in whole cells, so its frame can be a cell narrower than the tile it was rested by
|
||||
checks.check(
|
||||
"the first window rests at the left edge, a few pixels of it on the screen or a cell short"
|
||||
f" of them (right edge at {frame(1).x + frame(1).w}), not pulled back",
|
||||
wait(lambda: left - tol < frame(1).x + frame(1).w <= left + PARKED_AT_MOST),
|
||||
)
|
||||
checks.check(
|
||||
f"... and it kept its width ({frame(1).w} against {frame(4).w})",
|
||||
wait(lambda: abs(frame(1).w - frame(4).w) <= tol),
|
||||
)
|
||||
checks.check("the system and the daemon agree on the focus", wait(lambda: agree(5)))
|
||||
|
||||
for _ in range(STRIP - 1):
|
||||
platform.komorebic("focus", "left")
|
||||
checks.check(
|
||||
"focusing to the far left scrolls the strip back: the first is in view",
|
||||
wait(lambda: in_view(1) and agree(1)),
|
||||
)
|
||||
checks.check("... and the last is past the right edge", wait(lambda: out_of_view(5)))
|
||||
for _ in range(STRIP - 1):
|
||||
platform.komorebic("focus", "right")
|
||||
checks.check(
|
||||
"walking right again reaches the last, in view", wait(lambda: agree(5) and in_view(5))
|
||||
)
|
||||
|
||||
# the view moves a column without the focus moving first
|
||||
platform.komorebic("pan", "left")
|
||||
checks.check(
|
||||
"panning left brings the third into view and puts the last out of it",
|
||||
wait(lambda: in_view(3) and out_of_view(5)),
|
||||
)
|
||||
checks.check(
|
||||
"... and the focus goes to the nearest column in view, the fourth", wait(lambda: agree(4))
|
||||
)
|
||||
platform.komorebic("pan", "right")
|
||||
checks.check("panning right puts the last in view again", wait(lambda: in_view(5)))
|
||||
|
||||
# a column of two windows: the fourth is put at the top of the column of the fifth
|
||||
platform.komorebic("focus", "right")
|
||||
wait(lambda: agree(5))
|
||||
platform.komorebic("consume", "left")
|
||||
checks.check(
|
||||
"consuming left puts the fourth above the fifth, in one column",
|
||||
wait(lambda: abs(frame(4).x - frame(5).x) <= tol and frame(4).y < frame(5).y),
|
||||
)
|
||||
checks.check(
|
||||
"... each with a share of the height of the column",
|
||||
wait(lambda: frame(4).h < area.h * 0.6 and frame(5).h < area.h * 0.6),
|
||||
)
|
||||
checks.check("... and the focus stays on the fifth", wait(lambda: agree(5)))
|
||||
|
||||
pair = [Client(titles[3]), Client(titles[4])]
|
||||
platform.komorebic("toggle-column-stack")
|
||||
checks.check(
|
||||
"stacking the column shows one window of the two",
|
||||
wait(lambda: sum(platform.hidden(c) for c in pair) == 1),
|
||||
)
|
||||
platform.komorebic("toggle-column-stack")
|
||||
checks.check(
|
||||
"spreading it out shows both again, one above the other",
|
||||
wait(lambda: not any(platform.hidden(c) for c in pair) and frame(4).y < frame(5).y),
|
||||
)
|
||||
|
||||
platform.komorebic("expel")
|
||||
checks.check(
|
||||
"expelling puts the focused window in a column of its own on the right",
|
||||
wait(lambda: frame(5).x > frame(4).x + tol and abs(frame(5).y - frame(4).y) <= tol),
|
||||
)
|
||||
|
||||
platform.komorebic("scrolling-layout-full-width")
|
||||
checks.check(
|
||||
"the full width makes the focused column as wide as the work area",
|
||||
wait(lambda: frame(5).w >= area.w - 60 and in_view(5)),
|
||||
)
|
||||
platform.komorebic("scrolling-layout-full-width")
|
||||
checks.check(
|
||||
"and again puts it back to the width it had",
|
||||
wait(lambda: abs(frame(5).w - frame(4).w) <= tol),
|
||||
)
|
||||
|
||||
platform.komorebic("change-layout", "bsp")
|
||||
for client in opened:
|
||||
platform.close(client)
|
||||
|
||||
|
||||
def two_monitors(platform: Platform, checks: Checks, clients: list[Client]) -> None:
|
||||
"""A strip with a display next to it leaks no window onto it.
|
||||
|
||||
Five windows in two columns on the first monitor, with a second display on its right. A window
|
||||
shows on whichever display it overlaps, so one that rests past the right edge, or overhangs it,
|
||||
would be seen on the neighbour: the daemon hides it, or makes it narrower, instead. Scrolling
|
||||
with `focus` and `pan`, both ways, leaves no shown window on the second display, and no window
|
||||
that is shown past the right edge of the first. The layout is bsp again, the windows are
|
||||
closed, and the display is unplugged if the scenario plugged it, at the end."""
|
||||
plugged = _plug(platform)
|
||||
first, second = platform.displays()[0], platform.displays()[1]
|
||||
tol = platform.tolerance
|
||||
titles = [f"leak{i}" for i in range(1, STRIP + 1)]
|
||||
mine = [Client(t) for t in titles]
|
||||
|
||||
def leaks() -> list[str]:
|
||||
"""The windows that are shown and have a part on the second display, or reach past the
|
||||
right edge of the first."""
|
||||
out = []
|
||||
for client in mine:
|
||||
window = platform.os_window(client)
|
||||
if window is None or platform.hidden(client):
|
||||
continue
|
||||
frame = window.frame
|
||||
if frame.overlaps(second) or frame.x + frame.w > first.x + first.w + tol:
|
||||
out.append(f"{client.title} {frame}")
|
||||
return out
|
||||
|
||||
def settled(title: str) -> bool:
|
||||
return focus_agrees(platform, mine, title)
|
||||
|
||||
def quiet(step: str, title: str) -> None:
|
||||
platform.wait_for(lambda: settled(title), timeout=10)
|
||||
platform.wait_for(lambda: not leaks(), timeout=5)
|
||||
checks.check(f"{step}: no window is shown on the second display", not leaks())
|
||||
if leaks():
|
||||
print(" leaked: " + "; ".join(leaks()))
|
||||
|
||||
platform.komorebic("focus-monitor", "0")
|
||||
platform.komorebic("change-layout", "scrolling")
|
||||
platform.komorebic("scrolling-layout-columns", "2")
|
||||
opened = [platform.spawn(t) for t in titles]
|
||||
checks.check(
|
||||
"the daemon manages all five",
|
||||
platform.wait_for(lambda: platform.state().managed() >= STRIP, timeout=20),
|
||||
)
|
||||
quiet("with the strip at its right end", titles[-1])
|
||||
for i in range(STRIP - 1, 0, -1):
|
||||
platform.komorebic("focus", "left")
|
||||
quiet(f"focusing left to {titles[i - 1]}", titles[i - 1])
|
||||
for i in range(1, STRIP):
|
||||
platform.komorebic("focus", "right")
|
||||
quiet(f"focusing right to {titles[i]}", titles[i])
|
||||
platform.komorebic("pan", "left")
|
||||
platform.wait_for(lambda: not leaks(), timeout=10)
|
||||
checks.check("panning left: no window is shown on the second display", not leaks())
|
||||
platform.komorebic("pan", "right")
|
||||
platform.wait_for(lambda: not leaks(), timeout=10)
|
||||
checks.check("panning right: no window is shown on the second display", not leaks())
|
||||
|
||||
platform.komorebic("change-layout", "bsp")
|
||||
for client in opened:
|
||||
platform.close(client)
|
||||
platform.komorebic("focus-workspace", "0")
|
||||
if plugged:
|
||||
platform.remove_display()
|
||||
platform.wait_for(
|
||||
lambda: len(platform.state().monitors) == len(platform.displays()), timeout=30
|
||||
)
|
||||
@@ -0,0 +1,160 @@
|
||||
"""Wallpapers, and the colors of the borders that come from them.
|
||||
|
||||
A monitor's wallpaper is set when the daemon starts, and the wallpaper of a workspace replaces it
|
||||
while the workspace is shown. The borders of the windows take the colors of the wallpaper's
|
||||
palette, and follow it from workspace to workspace. A wallpaper the user changed by hand is put back
|
||||
when its workspace is shown again.
|
||||
|
||||
The pictures are a dozen bands of color each, since a palette wants at least eight: a warm one for
|
||||
the monitor, a cool one for the second workspace, and a green one the user sets by hand. Both ports
|
||||
read the same `wallpaper` of `komorebi.json`, and keep a palette for each picture.
|
||||
"""
|
||||
|
||||
import io
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from komorebi_vm.core import pixels
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.geometry import Rect
|
||||
from komorebi_vm.core.platform import Client, Platform
|
||||
|
||||
|
||||
def picture(hue: tuple[int, int, int], ramp: int) -> bytes:
|
||||
"""A 192 by 108 PNG of diagonal bands of `hue`, going dark and light, `ramp` varying the hue."""
|
||||
data: list[tuple[int, int, int]] = []
|
||||
for y in range(108):
|
||||
for x in range(192):
|
||||
band = (x // 16 + y // 16) % 12
|
||||
shade = 40 + (band % 4) * 55
|
||||
red, green, blue = hue
|
||||
green = min(255, green + band * ramp)
|
||||
data.append(
|
||||
(min(255, red * shade // 255), min(255, green * shade // 255), blue * shade // 255)
|
||||
)
|
||||
image = Image.new("RGB", (192, 108))
|
||||
image.putdata(data)
|
||||
out = io.BytesIO()
|
||||
image.save(out, "PNG")
|
||||
return out.getvalue()
|
||||
|
||||
|
||||
def _hue(red: int, blue: int) -> str:
|
||||
return "warm" if red > blue + 40 else "cool" if blue > red + 40 else "neither"
|
||||
|
||||
|
||||
def hue_of(image: Image.Image) -> str:
|
||||
"""Warm, cool or neither: the average color of a grid of points of the screen."""
|
||||
width, height = image.size
|
||||
points = [
|
||||
pixels.pixel(image, width * i // 10, height * j // 12)
|
||||
for i in range(1, 10)
|
||||
for j in range(1, 9)
|
||||
]
|
||||
return _hue(
|
||||
round(sum(p[0] for p in points) / len(points)),
|
||||
round(sum(p[2] for p in points) / len(points)),
|
||||
)
|
||||
|
||||
|
||||
def ring_hue(frame: Rect, image: Image.Image, reach: int = 12) -> str:
|
||||
"""The hue of the ring around a window: the colors within `reach` pixels of the left edge of
|
||||
its frame, on either side of it, at its middle. The window's own color is neutral, so what has
|
||||
a hue is the border; where the ports draw it, outside the frame or on its edge, differs."""
|
||||
seen = set()
|
||||
for x in range(max(0, frame.x - reach), min(image.size[0], frame.x + reach)):
|
||||
red, _, blue = pixels.pixel(image, x, frame.y + frame.h // 2)
|
||||
seen.add(_hue(red, blue))
|
||||
seen.discard("neither")
|
||||
return seen.pop() if len(seen) == 1 else "neither" if not seen else "mixed"
|
||||
|
||||
|
||||
def run(platform: Platform, checks: Checks) -> None:
|
||||
"""The daemon starts with a wallpaper for the monitor and one for its second workspace; the
|
||||
scenario follows them from workspace to workspace, with the borders, and sets one by hand.
|
||||
The workspace is empty, and so it is when the scenario ends."""
|
||||
warm = platform.temp_path("wallpapers/warm.png")
|
||||
cool = platform.temp_path("wallpapers/my pictures/cool.png")
|
||||
other = platform.temp_path("wallpapers/other.png")
|
||||
platform.put_file(warm, picture((255, 0, 20), 20))
|
||||
platform.put_file(cool, picture((20, 80, 255), 14))
|
||||
platform.put_file(other, picture((60, 255, 60), 0))
|
||||
|
||||
def shows(path: str) -> bool:
|
||||
return platform.wallpaper() == path
|
||||
|
||||
def screen_is(hue: str, name: str) -> bool:
|
||||
"""Takes pictures of the screen until it is `hue`: one can catch the shell half way."""
|
||||
return platform.wait_for(lambda: hue_of(platform.screenshot(name)) == hue, timeout=20)
|
||||
|
||||
def has_ring(client: Client, hue: str, name: str) -> bool:
|
||||
"""The window has a ring of `hue` in a screenshot taken until it does."""
|
||||
|
||||
def ring() -> bool:
|
||||
window = platform.os_window(client)
|
||||
return window is not None and ring_hue(window.frame, platform.screenshot(name)) == hue
|
||||
|
||||
return platform.wait_for(ring, timeout=20)
|
||||
|
||||
platform.set_wallpaper(other)
|
||||
checks.check(
|
||||
"the screen shows a picture of the user's choice to begin with",
|
||||
platform.wait_for(lambda: shows(other), timeout=20),
|
||||
)
|
||||
|
||||
platform.restart_with(
|
||||
{
|
||||
"monitors": [
|
||||
{
|
||||
"wallpaper": {"path": warm},
|
||||
"workspaces": [
|
||||
{"name": "one"},
|
||||
{"name": "two", "wallpaper": {"path": cool}},
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
checks.check(
|
||||
"at start the screen shows the monitor's wallpaper",
|
||||
platform.wait_for(lambda: shows(warm), timeout=20),
|
||||
)
|
||||
checks.check("and the screen is warm", screen_is("warm", "wallpaper-a1"))
|
||||
|
||||
platform.komorebic("focus-workspace", "1")
|
||||
checks.check(
|
||||
"workspace two's own wallpaper is shown when it is (the path has a space in it)",
|
||||
platform.wait_for(lambda: shows(cool), timeout=10),
|
||||
)
|
||||
checks.check("and the screen is cool", screen_is("cool", "wallpaper-a2"))
|
||||
platform.komorebic("focus-workspace", "0")
|
||||
checks.check(
|
||||
"back on workspace one, the monitor's wallpaper again",
|
||||
platform.wait_for(lambda: shows(warm), timeout=10),
|
||||
)
|
||||
|
||||
left = platform.spawn("wallpaper-left")
|
||||
checks.check(
|
||||
"on the warm workspace the focused window's ring is warm",
|
||||
has_ring(left, "warm", "wallpaper-c1"),
|
||||
)
|
||||
platform.komorebic("focus-workspace", "1")
|
||||
right = platform.spawn("wallpaper-right")
|
||||
checks.check("on the cool one it is cool", has_ring(right, "cool", "wallpaper-c2"))
|
||||
platform.komorebic("focus-workspace", "0")
|
||||
checks.check("and warm again when the first is back", has_ring(left, "warm", "wallpaper-c3"))
|
||||
|
||||
platform.set_wallpaper(other)
|
||||
checks.check("the user changed it", platform.wait_for(lambda: shows(other), timeout=10))
|
||||
platform.komorebic("focus-workspace", "1")
|
||||
platform.wait_for(lambda: shows(cool), timeout=10)
|
||||
platform.komorebic("focus-workspace", "0")
|
||||
checks.check(
|
||||
"showing the workspace again set it back",
|
||||
platform.wait_for(lambda: shows(warm), timeout=10),
|
||||
)
|
||||
|
||||
platform.close(left)
|
||||
platform.komorebic("focus-workspace", "1")
|
||||
platform.close(right)
|
||||
platform.komorebic("focus-workspace", "0")
|
||||
@@ -13,6 +13,7 @@ from PIL import Image
|
||||
from komorebi_vm.core.geometry import Rect
|
||||
from komorebi_vm.core.platform import Client, OsWindow
|
||||
from komorebi_vm.core.scenarios.commands import PRINTED
|
||||
from komorebi_vm.core.scenarios.resize import outside_grab
|
||||
from komorebi_vm.core.snapshot import Snapshot, parse
|
||||
|
||||
SCREEN = Rect(0, 0, 1920, 1080)
|
||||
@@ -214,6 +215,18 @@ class FakePlatform:
|
||||
if self.retiles_on_unlock:
|
||||
self.moved.clear()
|
||||
|
||||
def put_file(self, path: str, data: bytes) -> None: # noqa: ARG002
|
||||
pass
|
||||
|
||||
def wallpaper(self, display: int = 0) -> str: # noqa: ARG002
|
||||
return ""
|
||||
|
||||
def set_wallpaper(self, path: str, display: int = 0) -> None:
|
||||
pass
|
||||
|
||||
def resize_grab(self, frame, grab): # noqa: ANN001, ANN201
|
||||
return outside_grab(frame, grab)
|
||||
|
||||
def move_window(self, client: Client, x: int, y: int) -> None:
|
||||
here = self.os_window(client)
|
||||
assert here is not None
|
||||
|
||||
@@ -36,10 +36,13 @@ from komorebi_vm.core.scenarios import (
|
||||
state_fidelity,
|
||||
tiling,
|
||||
tiling_off,
|
||||
wallpaper,
|
||||
workspace_moves,
|
||||
workspaces,
|
||||
)
|
||||
from tests.fake_platform import FakePlatform
|
||||
from tests.fake_strip import FakeStrip
|
||||
from tests.fake_wallpaper import FakeWallpaper
|
||||
|
||||
|
||||
def opened(platform: FakePlatform, checks: Checks): # noqa: ANN201
|
||||
@@ -918,3 +921,55 @@ def test_a_platform_that_cannot_move_a_window_while_locked_fails_locking() -> No
|
||||
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)
|
||||
|
||||
|
||||
def test_a_daemon_that_is_right_passes_the_scrolling_columns() -> None:
|
||||
platform = FakeStrip()
|
||||
checks = Checks()
|
||||
scrolling.columns(platform, checks, [])
|
||||
assert checks.failed == 0, checks.failures
|
||||
assert checks.passed > 15
|
||||
|
||||
|
||||
def test_a_daemon_that_pulls_the_windows_back_fails_the_scrolling_columns() -> None:
|
||||
class Pulls(FakeStrip):
|
||||
def _strip_frame(self, title): # noqa: ANN001, ANN202
|
||||
r = super()._strip_frame(title)
|
||||
return Rect(max(r.x, 0), r.y, r.w, r.h)
|
||||
|
||||
platform = Pulls()
|
||||
checks = Checks()
|
||||
scrolling.columns(platform, checks, [])
|
||||
assert checks.failed > 0
|
||||
|
||||
|
||||
def test_a_strip_with_a_monitor_next_to_it_leaks_nothing() -> None:
|
||||
platform = FakeStrip()
|
||||
checks = Checks()
|
||||
scrolling.two_monitors(platform, checks, [])
|
||||
assert checks.failed == 0, checks.failures
|
||||
assert checks.passed > 10
|
||||
|
||||
|
||||
def test_a_daemon_that_rests_windows_on_the_next_monitor_fails_two_monitors() -> None:
|
||||
platform = FakeStrip()
|
||||
platform.leaks = True
|
||||
checks = Checks()
|
||||
scrolling.two_monitors(platform, checks, [])
|
||||
assert checks.failed > 0
|
||||
|
||||
|
||||
def test_a_daemon_that_sets_the_wallpapers_passes_wallpaper() -> None:
|
||||
platform = FakeWallpaper()
|
||||
checks = Checks()
|
||||
wallpaper.run(platform, checks)
|
||||
assert checks.failed == 0, checks.failures
|
||||
assert checks.passed > 8
|
||||
|
||||
|
||||
def test_a_daemon_that_leaves_a_changed_wallpaper_fails_wallpaper() -> None:
|
||||
platform = FakeWallpaper()
|
||||
platform.puts_back = False
|
||||
checks = Checks()
|
||||
wallpaper.run(platform, checks)
|
||||
assert checks.failed > 0
|
||||
@@ -6,6 +6,7 @@ from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.geometry import Rect
|
||||
from komorebi_vm.core.platform import Client, OsWindow, Pointer
|
||||
from komorebi_vm.core.scenarios import tiling
|
||||
from komorebi_vm.core.scenarios.resize import outside_grab
|
||||
from komorebi_vm.core.snapshot import Snapshot, parse
|
||||
|
||||
|
||||
@@ -103,6 +104,18 @@ class FakePlatform:
|
||||
def unlock(self) -> None:
|
||||
pass
|
||||
|
||||
def put_file(self, path: str, data: bytes) -> None: # noqa: ARG002
|
||||
pass
|
||||
|
||||
def wallpaper(self, display: int = 0) -> str: # noqa: ARG002
|
||||
return ""
|
||||
|
||||
def set_wallpaper(self, path: str, display: int = 0) -> None:
|
||||
pass
|
||||
|
||||
def resize_grab(self, frame: Rect, grab: str) -> tuple[int, int]:
|
||||
return outside_grab(frame, grab)
|
||||
|
||||
def move_window(self, client: Client, x: int, y: int) -> None:
|
||||
pass
|
||||
|
||||
|
||||
Reference in new issue
Block a user