fix: test fix to normalized coordinate space.

This commit is contained in:
Zoe
2026-09-20 23:58:02 -05:00
parent 5ea5c9aeb1
commit d4b5ea0254
4 changed files with 35 additions and 26 deletions
+7 -7
View File
@@ -19,13 +19,13 @@ test("adapter accepts tool calls and rejects truncated responses", async (t) =>
await assert.rejects(complete(config, [], []), /incomplete/);
});
test("tool descriptions do not inject coordinate normalization or pixel prompting", () => {
for (const space of ["pixels", "normalized_1000"] as const) {
const description = toolsForCoordinates(space)[0]?.function.description ?? "";
assert.doesNotMatch(description, /normalized/i);
assert.doesNotMatch(description, /pixel/i);
assert.doesNotMatch(description, /0\.\.1000/);
}
test("tool descriptions advertise coordinate conventions", () => {
const normalized = toolsForCoordinates("normalized_1000")[0]?.function.description ?? "";
assert.match(normalized, /Coordinates must be normalized integers in the range \[0, 1000\], where \(0, 0\) is top-left and \(1000, 1000\) is bottom-right\./);
const pixels = toolsForCoordinates("pixels")[0]?.function.description ?? "";
assert.match(pixels, /Click coordinates are screenshot pixels, not normalized coordinates\./);
assert.doesNotMatch(pixels, /normalized integers in the range/);
});
test("tool inputs reject invalid commands, bounds, and action names", () => {
+4 -12
View File
@@ -38,7 +38,7 @@ class ValidationTests(unittest.TestCase):
desktop.main()
if actions:
self.assertEqual(events, ["capture", "action", 0.5, "capture"])
command.assert_called_once_with("xdotool", "mousemove", "--sync", "640", "500", "click", "1")
command.assert_called_once_with("xdotool", "mousemove", "--sync", "640", "400", "click", "1")
else:
self.assertEqual(events, ["capture", "capture"])
@@ -64,17 +64,9 @@ class ValidationTests(unittest.TestCase):
self.assertIn("OnlyShowIn=XFCE;", entries[0].read_text())
def test_normalized_coordinates(self):
# 1280x800: width > 1000 (normalized 0..1000), height <= 1000 (pixels 0..799)
self.assertEqual(desktop.click_pixels({"x": 0, "y": 0}, 1280, 800, "normalized_1000"), (0, 0))
self.assertEqual(desktop.click_pixels({"x": 500, "y": 400}, 1280, 800, "normalized_1000"), (640, 400))
self.assertEqual(desktop.click_pixels({"x": 1000, "y": 799}, 1280, 800, "normalized_1000"), (1279, 799))
# 1920x1080: both > 1000 (both normalized 0..1000)
self.assertEqual(desktop.click_pixels({"x": 500, "y": 500}, 1920, 1080, "normalized_1000"), (960, 540))
# 800x600: both <= 1000 (both pixels)
self.assertEqual(desktop.click_pixels({"x": 400, "y": 300}, 800, 600, "normalized_1000"), (400, 300))
# 1x1: both <= 1000
self.assertEqual(desktop.click_pixels({"x": 0, "y": 0}, 1, 1, "normalized_1000"), (0, 0))
# pixels mode
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):