Skip to content

Commit eb11444

Browse files
committed
Add test for screen.
1 parent 643b925 commit eb11444

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"typings": "index.d.ts",
77
"scripts": {
88
"test": "npm run test:unit && npm run test:integration",
9-
"test:unit": "node test/all.js",
10-
"test:integration": "node test/integration/mouse.js",
9+
"test:unit": "tape test/all.js",
10+
"test:integration": "tape test/integration/*.js",
1111
"install": "prebuild-install || node-gyp rebuild"
1212
},
1313
"repository": {
@@ -45,6 +45,6 @@
4545
"devDependencies": {
4646
"prebuild": "v6.1.0",
4747
"tape": "^3.5.0",
48-
"targetpractice": "0.0.5"
48+
"targetpractice": "0.0.6"
4949
}
5050
}

src/robotjs.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ NAN_METHOD(scrollMouse)
247247
{
248248
return Nan::ThrowError("Invalid number of arguments.");
249249
}
250-
250+
251251
int x = info[0]->Int32Value();
252252
int y = info[1]->Int32Value();
253253

test/integration/mouse.js

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ test('Test scrolling.', { timeout: 10000 }, function(t)
8484
target.on('scroll', function(element)
8585
{
8686
// On Linux the textarea scrolls more aggressively.
87+
// TODO: I couldn't find a way to make scrolling more accurate on Linux.
8788
const expectedScroll = os.platform() === 'linux' ? 180 : 10;
8889
t.equal(element.id, 'textarea_1', 'Confirm textarea_1 was used.');
8990
t.equal(element.scroll_y, expectedScroll, 'Confirm scroll to 10.');

test/integration/screen.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* jshint esversion: 6 */
2+
var test = require('tape');
3+
var robot = require('../..');
4+
var targetpractice = require('targetpractice/index.js');
5+
var elements;
6+
7+
robot.setMouseDelay(100);
8+
9+
test('Test clicking.', { timeout: 10000 }, function(t)
10+
{
11+
t.plan(1);
12+
13+
// Start the UI.
14+
var target = targetpractice.start();
15+
16+
// Wait for the list of elements.
17+
target.on('elements', function(elements)
18+
{
19+
// For this test we want a button.
20+
// setTimeout(() => {
21+
var color_1 = elements.color_1;
22+
const color = robot.getPixelColor(color_1.x, color_1.y);
23+
t.equal(color, "c0ff33", 'Color is what we expected.');
24+
// }, 100);
25+
});
26+
27+
// Close the UI.
28+
t.on("end", function()
29+
{
30+
targetpractice.stop();
31+
});
32+
});

0 commit comments

Comments
 (0)