Skip to content

Commit

Permalink
Add test for screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Feb 25, 2018
1 parent 643b925 commit eb11444
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"typings": "index.d.ts",
"scripts": {
"test": "npm run test:unit && npm run test:integration",
"test:unit": "node test/all.js",
"test:integration": "node test/integration/mouse.js",
"test:unit": "tape test/all.js",
"test:integration": "tape test/integration/*.js",
"install": "prebuild-install || node-gyp rebuild"
},
"repository": {
Expand Down Expand Up @@ -45,6 +45,6 @@
"devDependencies": {
"prebuild": "v6.1.0",
"tape": "^3.5.0",
"targetpractice": "0.0.5"
"targetpractice": "0.0.6"
}
}
2 changes: 1 addition & 1 deletion src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ NAN_METHOD(scrollMouse)
{
return Nan::ThrowError("Invalid number of arguments.");
}

int x = info[0]->Int32Value();
int y = info[1]->Int32Value();

Expand Down
1 change: 1 addition & 0 deletions test/integration/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ test('Test scrolling.', { timeout: 10000 }, function(t)
target.on('scroll', function(element)
{
// On Linux the textarea scrolls more aggressively.
// TODO: I couldn't find a way to make scrolling more accurate on Linux.
const expectedScroll = os.platform() === 'linux' ? 180 : 10;
t.equal(element.id, 'textarea_1', 'Confirm textarea_1 was used.');
t.equal(element.scroll_y, expectedScroll, 'Confirm scroll to 10.');
Expand Down
32 changes: 32 additions & 0 deletions test/integration/screen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* jshint esversion: 6 */
var test = require('tape');
var robot = require('../..');
var targetpractice = require('targetpractice/index.js');
var elements;

robot.setMouseDelay(100);

test('Test clicking.', { timeout: 10000 }, function(t)
{
t.plan(1);

// Start the UI.
var target = targetpractice.start();

// Wait for the list of elements.
target.on('elements', function(elements)
{
// For this test we want a button.
// setTimeout(() => {
var color_1 = elements.color_1;
const color = robot.getPixelColor(color_1.x, color_1.y);
t.equal(color, "c0ff33", 'Color is what we expected.');
// }, 100);
});

// Close the UI.
t.on("end", function()
{
targetpractice.stop();
});
});

0 comments on commit eb11444

Please sign in to comment.