aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-10 16:34:04 +0100
committerDanilo M. <danix@danix.xyz>2026-11-10 16:34:04 +0100
commit5a8da8ab392266d5f3bbf3abed61472d6734f31c (patch)
treef5c95722e93515d9bcb527345fe8994333ead568 /tests
parent25c0248a3285c30b12df9d228a13e435786b66f7 (diff)
downloaddeck-it-5a8da8ab392266d5f3bbf3abed61472d6734f31c.tar.gz
deck-it-5a8da8ab392266d5f3bbf3abed61472d6734f31c.zip
feat(windows): preview cards and keystone's workspace icons
Each window is a card like the Alt+Tab switcher's: a preview in the window's shape (grim -T on Hyprland's stableId, also for hidden workspaces, refreshed every 5 s), the desktop top left, close top right, the app icon bottom left, each on its own scrim, the title below. Tap focuses, a long press opens the move menu at the press point (the grid re-renders under a title that changes every second, so the card itself may already be gone), and Chrome's image menu is suppressed. Module.image serves module images at /api/<module>/image/<key>; windows answers only for a window the last state listed. Workspace tiles, card markers and the move menu use the icons from keystone's Workspaces.qml, falling back to the number; the icon route also searches the theme's places, preferences and categories folders, where two of them live. The workspaces are centred. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_server.py9
-rw-r--r--tests/test_windows.py29
2 files changed, 37 insertions, 1 deletions
diff --git a/tests/test_server.py b/tests/test_server.py
index 054b3a6..0881849 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -57,7 +57,8 @@ class Server(unittest.TestCase):
{"ping": lambda body: {"got": body.get("n")},
"boom": lambda body: int(body.get("x")),
"put": lambda data: {"len": len(data)}},
- uploads={"put": ("audio/wav", 10)}),
+ uploads={"put": ("audio/wav", 10)},
+ image=lambda key: (b"img", "image/jpeg") if key == "k1" else None),
])
cls.server = srv.UnixHTTPServer(cls.sock, srv.Handler)
threading.Thread(target=cls.server.serve_forever, daemon=True).start()
@@ -114,6 +115,12 @@ class Server(unittest.TestCase):
with mock.patch.dict(srv.CFG, {"assistant": {"background": ""}}):
self.assertEqual(self.req("GET", "/api/bg", HOST)[0], 404)
+ def test_module_images(self):
+ self.assertEqual(self.req("GET", "/api/demo/image/k1", HOST), (200, b"img"))
+ self.assertEqual(self.req("GET", "/api/demo/image/k2", HOST)[0], 404)
+ self.assertEqual(self.req("GET", "/api/nope/image/k1", HOST)[0], 404)
+ self.assertEqual(self.req("GET", "/api/demo/image/k1", {"Host": "127.0.0.1:8765"})[0], 401)
+
def test_nerd_font(self):
from unittest import mock
import tempfile
diff --git a/tests/test_windows.py b/tests/test_windows.py
index e632406..6950152 100644
--- a/tests/test_windows.py
+++ b/tests/test_windows.py
@@ -19,12 +19,23 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
+import json
import unittest
from unittest import mock
import deckit.modules.windows as windows
+class WorkspaceIcons(unittest.TestCase):
+ def test_reads_keystones_map(self):
+ import tempfile
+ f = Path(tempfile.mkdtemp()) / "Workspaces.qml"
+ f.write_text('Singleton {\n readonly property var icons: ({\n 1: "web-browser",\n'
+ ' 2: "text-editor",\n })\n}\n')
+ self.assertEqual(windows.workspace_icons(f), {1: "web-browser", 2: "text-editor"})
+ self.assertEqual(windows.workspace_icons("/nonexistent"), {})
+
+
class DesktopIcons(unittest.TestCase):
def test_maps_class_and_wmclass(self):
import tempfile
@@ -100,6 +111,24 @@ class Commands(unittest.TestCase):
self.assertEqual(st["launches"],
[{"key": "com.obsproject.Studio", "icon": "obs", "label": "OBS Studio"}])
+ def test_preview_only_for_a_listed_window(self):
+ client = {"address": "0x1", "stableId": "18000005", "class": "kitty", "title": "t",
+ "workspace": {"id": 3}, "mapped": True}
+ responses = {
+ ("hyprctl", "clients", "-j"): json.dumps([client]),
+ ("hyprctl", "activewindow", "-j"): "{}",
+ ("hyprctl", "workspaces", "-j"): '[{"id": 3}]',
+ }
+ shots = []
+ m = windows.make({"run": lambda cmd: responses[tuple(cmd)],
+ "shot": lambda key: shots.append(key) or (b"jpg", "image/jpeg")})
+ self.assertIsNone(m.image("18000005")) # not listed yet
+ self.assertEqual(m.state()["windows"][0]["id"], "18000005")
+ self.assertEqual(m.image("18000005"), (b"jpg", "image/jpeg"))
+ for bad in ("deadbeef", "-s", "../x", "18000005 -o"):
+ self.assertIsNone(m.image(bad))
+ self.assertEqual(shots, ["18000005"])
+
def test_launch_runs_only_listed_installed_apps(self):
entries = {"kitty": {"name": "kitty", "icon": "kitty", "wmclass": None},
"other": {"name": "Other", "icon": None, "wmclass": None}}