Skip to content

Commit 7bc68de

Browse files
committed
(#40) Adapter implementation and tests for highlightScreenRegion
1 parent 9638564 commit 7bc68de

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/adapter/vision.adapter.class.spec.ts

+17
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ describe("VisionAdapter class", () => {
3737
expect(screenMock.grabScreenRegion).toBeCalledWith(screenRegion);
3838
});
3939

40+
it("should delegate calls to highlightScreenRegion", async () => {
41+
// GIVEN
42+
const finderMock = new TemplateMatchingFinder();
43+
const screenMock = new ScreenAction();
44+
const SUT = new VisionAdapter(finderMock, screenMock);
45+
const screenRegion = new Region(0, 0, 100, 100);
46+
const opacity = 0.25;
47+
const duration = 1;
48+
49+
// WHEN
50+
await SUT.highlightScreenRegion(screenRegion, duration, opacity);
51+
52+
// THEN
53+
expect(screenMock.highlightScreenRegion).toBeCalledTimes(1);
54+
expect(screenMock.highlightScreenRegion).toBeCalledWith(screenRegion, duration, opacity);
55+
});
56+
4057
it("should delegate calls to screenWidth", async () => {
4158
// GIVEN
4259
const finderMock = new TemplateMatchingFinder();

lib/adapter/vision.adapter.class.ts

+11
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ export class VisionAdapter {
4949
return this.screen.grabScreenRegion(region);
5050
}
5151

52+
/**
53+
* {@link highlightScreenRegion} highlights a screen {@link Region} for a given duration by overlaying it with an opaque window
54+
*
55+
* @param region The {@link Region} to highlight
56+
* @param duration The highlight duration
57+
* @param opacity Overlay opacity
58+
*/
59+
public highlightScreenRegion(region: Region, duration: number, opacity: number): Promise<void> {
60+
return this.screen.highlightScreenRegion(region, duration, opacity);
61+
}
62+
5263
/**
5364
* {@link findOnScreenRegion} will search for a given pattern inside a {@link Region} of the main screen
5465
* If multiple possible occurrences are found, the one with the highest probability is returned.

0 commit comments

Comments
 (0)