1import { expect, it } from "vite-plus/test";
2import { captureDestinationFrame, findCaptureDestination } from "./feedbackGeometry.js";
3
4const window = (pid, title) => ({ get_pid: () => pid, get_title: () => title });
5
6it("activates only a window of the process authenticated by D-Bus", () => {
7 const target = window(42, "T3 Code");
8 expect(findCaptureDestination([window(99, "T3 Code"), target], 42, "T3 Code")).toBe(target);
9 expect(findCaptureDestination([window(99, "T3 Code")], 42, "T3 Code")).toBeUndefined();
10 expect(findCaptureDestination([target], 42, "Title before navigation")).toBe(target);
11});
12
13it("does not guess between ambiguous windows from the same process", () => {
14 expect(findCaptureDestination([window(42, "T3"), window(42, "T3")], 42, "T3")).toBeUndefined();
15 expect(findCaptureDestination([window(42, "A"), window(42, "B")], 42, "C")).toBeUndefined();
16});
17
18it("maps the composer onto GNOME's current window position and logical scale", () => {
19 expect(
20 captureDestinationFrame(
21 { x: 0.1, y: 0.8, width: 0.2, height: 0.1 },
22 { x: -1920, y: 30, width: 1200, height: 900 },
23 ),
24 ).toEqual({ x: -1800, y: 750, width: 240, height: 90 });
25});
26
27it.each([NaN, Infinity, -1, 2])("rejects invalid/off-window animation geometry %s", (x) => {
28 expect(() =>
29 captureDestinationFrame(
30 { x, y: 0, width: 0.2, height: 0.1 },
31 { x: 0, y: 0, width: 1200, height: 900 },
32 ),
33 ).toThrow("Invalid");
34});