Skip to content

Commit 7495ba3

Browse files
committed
(#53) Updated to new API
1 parent a04e134 commit 7495ba3

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

index.e2e.spec.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { assert, Key, keyboard, Location, mouse, movement, screen } from "./index";
1+
import { assert, centerOf, Key, keyboard, mouse, screen, straightTo } from "./index";
22

33
const openXfceMenu = async () => {
4-
const menu = await screen.find("menu.png");
5-
await mouse.move(await movement.straightTo(Location.centerOf(menu)));
4+
await mouse.move(straightTo(centerOf(screen.find("menu.png"))));
65
await mouse.leftClick();
76
await mouse.leftClick();
87
};
@@ -14,22 +13,18 @@ const run = async (cmd: string) => {
1413
};
1514

1615
const calculate = async () => {
17-
const plus = await screen.find("plus.png");
18-
await mouse.move(await movement.straightTo(Location.centerOf(plus)));
16+
await mouse.move(straightTo(centerOf(screen.find("plus.png"))));
1917
await mouse.leftClick();
20-
const one = await screen.find("one.png");
21-
await mouse.move(await movement.straightTo(Location.centerOf(one)));
18+
await mouse.move(straightTo(centerOf(screen.find("one.png"))));
2219
await mouse.leftClick();
23-
const zero = await screen.find("zero.png");
24-
await mouse.move(await movement.straightTo(Location.centerOf(zero)));
20+
await mouse.move(straightTo(centerOf(screen.find("zero.png"))));
2521
await mouse.leftClick();
2622
await mouse.leftClick();
2723
await keyboard.type(Key.Enter);
2824
};
2925

3026
const close = async () => {
31-
const x = await screen.find("close.png");
32-
await mouse.move(await movement.straightTo(Location.centerOf(x)));
27+
await mouse.move(straightTo(centerOf(screen.find("close.png"))));
3328
await mouse.leftClick();
3429
};
3530

index.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,40 @@ import { Assert } from "./lib/assert.class";
44
import { Clipboard } from "./lib/clipboard.class";
55
import { Keyboard } from "./lib/keyboard.class";
66
import { Mouse } from "./lib/mouse.class";
7-
import { Movement } from "./lib/movement.class";
7+
import { createMovementApi } from "./lib/movement.function";
88
import { Screen } from "./lib/screen.class";
99
import { LineHelper } from "./lib/util/linehelper.class";
1010

1111
export { jestMatchers } from "./lib/expect/jest.matcher.function";
1212
export { Image } from "./lib/image.class";
1313
export { Key } from "./lib/key.enum";
14-
export { Location } from "./lib/location.class";
14+
export { centerOf, randomPointIn } from "./lib/location.function";
1515
export { LocationParameters } from "./lib/locationparameters.class";
16-
export { Movement } from "./lib/movement.class";
17-
export { MovementType } from "./lib/movementtype.class";
16+
export { linear } from "./lib/movementtype.function";
1817
export { Point } from "./lib/point.class";
1918
export { Region } from "./lib/region.class";
2019

2120
const screenActions = new VisionAdapter();
2221
const nativeActions = new NativeAdapter();
22+
const lineHelper = new LineHelper();
2323

2424
const clipboard = new Clipboard(nativeActions);
2525
const keyboard = new Keyboard(nativeActions);
2626
const mouse = new Mouse(nativeActions);
27-
const movement = new Movement(nativeActions, new LineHelper());
2827
const screen = new Screen(screenActions);
2928
const assert = new Assert(screen);
3029

31-
export { clipboard, keyboard, mouse, movement, screen, assert };
30+
const {straightTo, up, down, left, right} = createMovementApi(nativeActions, lineHelper);
31+
32+
export {
33+
clipboard,
34+
keyboard,
35+
mouse,
36+
screen,
37+
assert,
38+
straightTo,
39+
up,
40+
down,
41+
left,
42+
right,
43+
};

0 commit comments

Comments
 (0)