mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 01:11:13 -06:00
Electron-84: integrated RobotJS into the test
This commit is contained in:
parent
a3598f9731
commit
37e9a08900
@ -1,30 +1,45 @@
|
||||
describe('Tests for Full Screen', () => {
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const childProcess = require('child_process');
|
||||
const Application = require('./spectron/spectronSetup');
|
||||
let robot;
|
||||
let configPath;
|
||||
|
||||
let app = new Application({});
|
||||
|
||||
describe('Tests for Full screen', () => {
|
||||
|
||||
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
|
||||
|
||||
let app;
|
||||
|
||||
beforeAll((done) => {
|
||||
const Application = require('./spectron/spectronSetup');
|
||||
app = new Application({});
|
||||
return app.startApplication().then((startedApp) => {
|
||||
app = startedApp;
|
||||
done();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
childProcess.exec(`npm rebuild robotjs --target=${process.version} --build-from-source`, function () {
|
||||
robot = require('robotjs');
|
||||
return app.startApplication().then((startedApp) => {
|
||||
app = startedApp;
|
||||
app.browserWindow.setFullScreen(false);
|
||||
done();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterAll((done) => {
|
||||
if (app && app.isRunning()) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
app.stop().then(() => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
done();
|
||||
});
|
||||
app.client.getWindowCount().then((count) => {
|
||||
if (count > 0) {
|
||||
app.stop().then(() => {
|
||||
done();
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
done();
|
||||
});
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
@ -32,7 +47,6 @@ describe('Tests for Full Screen', () => {
|
||||
|
||||
it('should launch the app', (done) => {
|
||||
return app.client.waitUntilWindowLoaded().then(() => {
|
||||
app.browserWindow.setFullScreen(false);
|
||||
return app.client.getWindowCount().then((count) => {
|
||||
expect(count === 1).toBeTruthy();
|
||||
done();
|
||||
@ -60,16 +74,23 @@ describe('Tests for Full Screen', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should set the app full screen', () => {
|
||||
return app.browserWindow.setFullScreen(true);
|
||||
});
|
||||
it('should set the app full screen and check whether it is in full screen', () => {
|
||||
robot.setMouseDelay(200);
|
||||
robot.moveMouseSmooth(205, 10);
|
||||
robot.mouseClick();
|
||||
robot.setKeyboardDelay(200);
|
||||
robot.keyTap('down');
|
||||
robot.keyTap('down');
|
||||
robot.keyTap('down');
|
||||
robot.keyTap('down');
|
||||
robot.keyTap('down');
|
||||
robot.keyTap('down');
|
||||
robot.keyTap('enter');
|
||||
|
||||
it('should check whether the app is in full screen', () => {
|
||||
return app.browserWindow.isFullScreen().then((isFullScreen) => {
|
||||
expect(isFullScreen).toBeTruthy();
|
||||
return app.browserWindow.isFullScreen().then((fullscreen) => {
|
||||
expect(fullscreen).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user