Electron-84: Implemented RobotJS test for Windows

This commit is contained in:
Vikas Shashidhar
2017-07-11 19:43:17 +05:30
committed by Vishwas Shashidhar
parent 37e9a08900
commit fb3c016a93
+65 -19
View File
@@ -2,6 +2,7 @@ const path = require('path');
const fs = require('fs'); const fs = require('fs');
const childProcess = require('child_process'); const childProcess = require('child_process');
const Application = require('./spectron/spectronSetup'); const Application = require('./spectron/spectronSetup');
const {isMac} = require('../js/utils/misc');
let robot; let robot;
let configPath; let configPath;
@@ -17,14 +18,34 @@ describe('Tests for Full screen', () => {
robot = require('robotjs'); robot = require('robotjs');
return app.startApplication().then((startedApp) => { return app.startApplication().then((startedApp) => {
app = startedApp; app = startedApp;
app.browserWindow.setFullScreen(false); getConfigPath().then((config) => {
done(); console.log(config);
configPath = config;
done();
}).catch((err) => {
expect(err).toBeNull();
});
}).catch((err) => { }).catch((err) => {
expect(err).toBeNull(); expect(err).toBeNull();
}); });
}); });
}); });
function getConfigPath() {
return new Promise(function (resolve, reject) {
app.client.addCommand('getUserDataPath', function () {
return this.execute(function () {
return require('electron').remote.app.getPath('userData');
})
});
app.client.getUserDataPath().then((path) => {
resolve(path.value + '/Symphony.config')
}).catch((err) => {
reject(err);
});
});
}
afterAll((done) => { afterAll((done) => {
if (app && app.isRunning()) { if (app && app.isRunning()) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
@@ -74,23 +95,48 @@ describe('Tests for Full screen', () => {
}); });
}); });
it('should set the app full screen and check whether it is in full screen', () => { it('should bring the app to top', () => {
robot.setMouseDelay(200); app.browserWindow.focus();
robot.moveMouseSmooth(205, 10); return app.browserWindow.setAlwaysOnTop(true).then(() => {
robot.mouseClick(); return app.browserWindow.isAlwaysOnTop().then((isOnTop) => {
robot.setKeyboardDelay(200); console.log(isOnTop);
robot.keyTap('down'); expect(isOnTop).toBeTruthy();
robot.keyTap('down'); });
robot.keyTap('down'); });
robot.keyTap('down'); });
robot.keyTap('down');
robot.keyTap('down');
robot.keyTap('enter');
return app.browserWindow.isFullScreen().then((fullscreen) => { it('should set the app full screen and check whether it is in full screen', () => {
expect(fullscreen).toBeTruthy(); if (isMac) {
}).catch((err) => { robot.setMouseDelay(100);
expect(err).toBeNull(); robot.moveMouseSmooth(205, 10);
}) robot.mouseClick();
robot.setKeyboardDelay(100);
for (let i = 0; i < 6; i++) {
robot.keyTap('down');
}
robot.keyTap('enter');
return app.browserWindow.isFullScreen().then((fullscreen) => {
expect(fullscreen).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
})
} else {
return app.browserWindow.getBounds().then((bounds) => {
robot.setMouseDelay(100);
let x = bounds.x + 200;
let y = bounds.y + 200;
robot.moveMouseSmooth(x, y);
robot.mouseClick();
robot.keyTap('f11');
return app.browserWindow.isFullScreen().then((fullscreen) => {
expect(fullscreen).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
})
});
}
}); });
}); });