Skip to content

Commit fb028a8

Browse files
committed
(#5) Export window API and added E2E test
1 parent f8be1a5 commit fb028a8

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Diff for: index.e2e.spec.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
activeWindow,
23
assert,
34
Button,
45
centerOf,
@@ -10,7 +11,7 @@ import {
1011
right,
1112
screen,
1213
sleep,
13-
straightTo
14+
straightTo,
1415
} from "./index";
1516

1617
const openXfceMenu = async () => {
@@ -97,3 +98,20 @@ describe("E2E mouse button demo", () => {
9798
}
9899
});
99100
});
101+
102+
describe("E2E window demo", () => {
103+
it("should list gnome-calculator", async () => {
104+
jest.setTimeout(30000);
105+
screen.config.resourceDirectory = "./e2e/assets";
106+
await assert.isVisible("mouse.png");
107+
await assert.isVisible("desktop.png");
108+
await openXfceMenu();
109+
await run("uxterm");
110+
await sleep(1500);
111+
const foregroundWindow = await activeWindow();
112+
const windowTitle = await foregroundWindow.title;
113+
await close();
114+
115+
expect(windowTitle).toBe("uxterm")
116+
});
117+
});

Diff for: index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Mouse } from "./lib/mouse.class";
77
import { createMovementApi } from "./lib/movement.function";
88
import { Screen } from "./lib/screen.class";
99
import { LineHelper } from "./lib/util/linehelper.class";
10+
import { createWindowApi } from "./lib/window.function";
1011

1112
export { jestMatchers } from "./lib/expect/jest.matcher.function";
1213
export { sleep } from "./lib/sleep.function";
@@ -19,6 +20,7 @@ export { OptionalSearchParameters } from "./lib/optionalsearchparameters.class";
1920
export { linear } from "./lib/movementtype.function";
2021
export { Point } from "./lib/point.class";
2122
export { Region } from "./lib/region.class";
23+
export { Window } from "./lib/window.class";
2224

2325
const screenActions = new VisionAdapter();
2426
const nativeActions = new NativeAdapter();
@@ -31,6 +33,7 @@ const screen = new Screen(screenActions);
3133
const assert = new Assert(screen);
3234

3335
const {straightTo, up, down, left, right} = createMovementApi(nativeActions, lineHelper);
36+
const {windows, activeWindow } = createWindowApi(nativeActions);
3437

3538
export {
3639
clipboard,
@@ -43,4 +46,6 @@ export {
4346
down,
4447
left,
4548
right,
49+
windows,
50+
activeWindow,
4651
};

0 commit comments

Comments
 (0)