aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_windows.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_windows.py')
-rw-r--r--tests/test_windows.py29
1 files changed, 29 insertions, 0 deletions
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}}