feat: support normalizing coordinate spaces

This commit is contained in:
Zoe
2026-09-19 18:23:51 -05:00
parent c49f228847
commit 5389d4541c
9 changed files with 85 additions and 15 deletions
+13
View File
@@ -32,6 +32,19 @@ class ValidationTests(unittest.TestCase):
self.assertIn("--register-session\n", entries[0].read_text())
self.assertIn("OnlyShowIn=XFCE;", entries[0].read_text())
def test_normalized_coordinates(self):
for value, expected in [(0, (0, 0)), (500, (640, 400)), (1000, (1279, 799))]:
self.assertEqual(desktop.click_pixels({"x": value, "y": value}, 1280, 800, "normalized_1000"), expected)
self.assertEqual(desktop.click_pixels({"x": 1000, "y": 1000}, 1, 1, "normalized_1000"), (0, 0))
self.assertEqual(desktop.click_pixels({"x": 480, "y": 425}, 1280, 800, "pixels"), (480, 425))
for value in (-1, 1001, 0.5, True):
with self.assertRaises(ValueError):
desktop.click_pixels({"x": value, "y": 0}, 1280, 800, "normalized_1000")
def test_invalid_coordinate_space(self):
with self.assertRaises(ValueError):
desktop.validate({"actions": [], "coordinateSpace": "guess"}, 1280, 800)
def test_capture(self):
self.assertEqual(desktop.validate({"actions": []}, 100, 100), [])