Skip to content

Commit 453913c

Browse files
authored
Merge branch 'develop' into dependabot/npm_and_yarn/lodash-4.17.15
2 parents 758ce60 + c9c62ca commit 453913c

25 files changed

+1138
-431
lines changed

lib/provider/native/robotjs-keyboard-action.class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import robot = require("robotjs-node10");
1+
import robot = require("@nut-tree/libnut");
22
import { Key } from "../../key.enum";
33
import { KeyboardActionProvider } from "./keyboard-action-provider.interface";
44

lib/provider/native/robotjs-keyboard.action.class.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import robot = require("robotjs-node10");
1+
import robot = require("@nut-tree/libnut");
22
import { Key } from "../../key.enum";
33
import { KeyboardAction } from "./robotjs-keyboard-action.class";
44

5-
jest.mock("robotjs-node10");
5+
jest.mock("@nut-tree/libnut");
66

77
beforeEach(() => {
88
jest.resetAllMocks();

lib/provider/native/robotjs-mouse-action.class.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import robot = require("robotjs-node10");
1+
import robot = require("@nut-tree/libnut");
22
import { Button } from "../../button.enum";
33
import { Point } from "../../point.class";
44
import { MouseAction } from "./robotjs-mouse-action.class";
55

6-
jest.mock("robotjs-node10");
6+
jest.mock("@nut-tree/libnut");
77

88
beforeEach(() => {
99
jest.resetAllMocks();

lib/provider/native/robotjs-mouse-action.class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import robot = require("robotjs-node10");
1+
import robot = require("@nut-tree/libnut");
22
import { Button } from "../../button.enum";
33
import { Point } from "../../point.class";
44
import { MouseActionInterface } from "./mouse-action-provider.interface";

lib/provider/native/robotjs-screen-action.class.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import robot = require("robotjs-node10");
1+
import robot = require("@nut-tree/libnut");
22
import { Region } from "../../region.class";
33
import { ScreenAction } from "./robotjs-screen-action.class";
44

5-
jest.mock("robotjs-node10");
5+
jest.mock("@nut-tree/libnut");
66

77
beforeEach(() => {
88
jest.resetAllMocks();

lib/provider/native/robotjs-screen-action.class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import robot = require("robotjs-node10");
1+
import robot = require("@nut-tree/libnut");
22
import { Image } from "../../image.class";
33
import { Region } from "../../region.class";
44
import { ScreenActionProvider } from "./screen-action-provider.interface";
8.85 KB
Loading
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { lowerBound, upperBound } from "./bound-value.function";
2+
3+
describe("lowerBound function", () => {
4+
it.each([
5+
[5, 10, 1, 1],
6+
[5, 5, 10, 10],
7+
[5, 1, 10, 5],
8+
[0, 0, 0, 0]
9+
])("Input: %f, Boundary: %f, minValue: %f, Expected: %f",
10+
(input: number, boundary: number, minValue: number, expected: number) => {
11+
// WHEN
12+
const result = lowerBound(input, boundary, minValue);
13+
14+
// THEN
15+
expect(result).toBe(expected);
16+
});
17+
});
18+
19+
describe("upperBound function", () => {
20+
it.each([
21+
[5, 10, 1, 5],
22+
[5, 5, 10, 10],
23+
[5, 1, 10, 10],
24+
[5, 5, 5, 5]
25+
])("Input: %f, Boundary: %f, maxValue: %f, Expected: %f",
26+
(input: number, boundary: number, maxValue: number, expected: number) => {
27+
// WHEN
28+
const result = upperBound(input, boundary, maxValue);
29+
30+
// THEN
31+
expect(result).toBe(expected);
32+
});
33+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function lowerBound(value: number, boundary: number, minValue: number): number {
2+
return (value <= boundary) ? minValue : value;
3+
}
4+
5+
export function upperBound(value: number, boundary: number, maxValue: number): number {
6+
return (value >= boundary) ? maxValue : value;
7+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { mockPartial } from "sneer";
2+
import { Image } from "../../image.class";
3+
import { MatchRequest } from "../../match-request.class";
4+
import { Region } from "../../region.class";
5+
import { determineScaledSearchRegion } from "./determine-searchregion.function";
6+
7+
describe("determineSearchRegion", () => {
8+
it("should return a search region adopted to pixel density", () => {
9+
// GIVEN
10+
const imageMock = mockPartial<Image>({
11+
pixelDensity: {
12+
scaleX: 1.5,
13+
scaleY: 2.0
14+
}
15+
});
16+
const needlePath = "/path/to/needle";
17+
const inputSearchRegion = new Region(0, 0, 100, 100);
18+
const expectedSearchRegion = new Region(0, 0, 150, 200);
19+
20+
const matchRequest = new MatchRequest(
21+
imageMock,
22+
needlePath,
23+
inputSearchRegion,
24+
0.99
25+
);
26+
27+
// WHEN
28+
const result = determineScaledSearchRegion(matchRequest);
29+
30+
// THEN
31+
expect(result).toEqual(expectedSearchRegion);
32+
});
33+
34+
it.each([[0, 1], [1, 0]])("should not adjust searchregion for factor 0: scaleX: %i scaleY: %i",
35+
(scaleX: number, scaleY: number) => {
36+
// GIVEN
37+
const imageMock = mockPartial<Image>({
38+
pixelDensity: {
39+
scaleX,
40+
scaleY
41+
}
42+
});
43+
const needlePath = "/path/to/needle";
44+
const inputSearchRegion = new Region(0, 0, 100, 100);
45+
const expectedSearchRegion = new Region(0, 0, 100, 100);
46+
47+
const matchRequest = new MatchRequest(
48+
imageMock,
49+
needlePath,
50+
inputSearchRegion,
51+
0.99
52+
);
53+
54+
// WHEN
55+
const result = determineScaledSearchRegion(matchRequest);
56+
57+
// THEN
58+
expect(result).toEqual(expectedSearchRegion);
59+
});
60+
});

0 commit comments

Comments
 (0)