mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 01:11:13 -06:00
Merge remote-tracking branch 'upstream/master' into ELECTRON-77
This commit is contained in:
commit
b05bbd5aa7
@ -3,7 +3,6 @@
|
||||
"minimizeOnClose" : false,
|
||||
"launchOnStartup" : true,
|
||||
"alwaysOnTop" : false,
|
||||
"launchOnStartup" : true,
|
||||
"notificationSettings": {
|
||||
"position": "upper-right",
|
||||
"display": ""
|
||||
|
@ -15,9 +15,8 @@
|
||||
"prebuild": "npm run rebuild && npm run browserify-preload",
|
||||
"browserify-preload": "browserify -o js/preload/_preloadMain.js -x electron --insert-global-vars=__filename,__dirname js/preload/preloadMain.js",
|
||||
"rebuild": "electron-rebuild -f",
|
||||
"test": "npm run lint && npm run copy-config && jest --verbose --testPathPattern test --runInBand",
|
||||
"test": "npm run lint && jest --verbose --testPathPattern test --runInBand",
|
||||
"lint": "eslint --ext .js js/",
|
||||
"copy-config": "ncp 'config' 'node_modules/electron/dist/Electron.app/Contents/config'",
|
||||
"rename-exe": "cd dist/win-unpacked && ren Symphony.exe Symphony-Electron.exe"
|
||||
},
|
||||
"jest": {
|
||||
@ -81,6 +80,7 @@
|
||||
"eslint-plugin-react": "^6.10.0",
|
||||
"jest": "^19.0.2",
|
||||
"ncp": "^2.0.0",
|
||||
"robotjs": "^0.4.7",
|
||||
"spectron": "^3.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -1,5 +1,11 @@
|
||||
const Application = require('./spectron/spectronSetup');
|
||||
const {isMac} = require('../js/utils/misc.js');
|
||||
const childProcess = require('child_process');
|
||||
|
||||
let app = new Application({});
|
||||
let robot;
|
||||
let configPath;
|
||||
let mIsAlwaysOnTop;
|
||||
|
||||
describe('Tests for Always on top', () => {
|
||||
|
||||
@ -7,22 +13,49 @@ describe('Tests for Always on top', () => {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
|
||||
|
||||
beforeAll((done) => {
|
||||
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;
|
||||
getConfigPath().then((config) => {
|
||||
configPath = config;
|
||||
done();
|
||||
});
|
||||
}).catch((err) => {
|
||||
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) => {
|
||||
if (app && app.isRunning()) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
app.stop().then(() => {
|
||||
done();
|
||||
childProcess.exec('npm run rebuild', function (err, stdout) {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
done();
|
||||
});
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
done();
|
||||
childProcess.exec('npm run rebuild', function () {
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
expect(err).toBeNull();
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -32,8 +65,6 @@ describe('Tests for Always on top', () => {
|
||||
return app.client.getWindowCount().then((count) => {
|
||||
expect(count === 1).toBeTruthy();
|
||||
done();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
@ -56,24 +87,100 @@ describe('Tests for Always on top', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should bring the app to front in windows', (done) => {
|
||||
if (!isMac) {
|
||||
app.browserWindow.focus();
|
||||
app.browserWindow.restore();
|
||||
app.browserWindow.setAlwaysOnTop(true).then(() => {
|
||||
app.browserWindow.isAlwaysOnTop().then((isOnTop) => {
|
||||
app.browserWindow.getBounds().then((bounds) => {
|
||||
robot.setMouseDelay(200);
|
||||
app.browserWindow.restore().then(() => {
|
||||
let x = bounds.x + 95;
|
||||
let y = bounds.y + 35;
|
||||
|
||||
robot.moveMouseSmooth(x, y);
|
||||
robot.mouseClick();
|
||||
robot.setKeyboardDelay(200);
|
||||
for (let i = 0; i < 4
|
||||
; i++) {
|
||||
robot.keyTap('down');
|
||||
}
|
||||
robot.keyTap('enter');
|
||||
expect(isOnTop).toBeTruthy();
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should check is always on top', () => {
|
||||
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
||||
expect(isAlwaysOnTop).toBeFalsy();
|
||||
return Application.readConfig(configPath).then((userData) => {
|
||||
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
||||
mIsAlwaysOnTop = isAlwaysOnTop;
|
||||
if (userData.alwaysOnTop) {
|
||||
expect(isAlwaysOnTop).toBeTruthy();
|
||||
} else {
|
||||
expect(isAlwaysOnTop).toBeFalsy();
|
||||
}
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should change the always on top property', () => {
|
||||
return app.browserWindow.setAlwaysOnTop(true);
|
||||
it('should toggle the always on top property to true', (done) => {
|
||||
if (isMac) {
|
||||
robot.setMouseDelay(200);
|
||||
robot.moveMouse(190, 0);
|
||||
robot.mouseClick();
|
||||
for (let i = 0; i < 8; i++) {
|
||||
robot.keyTap('down');
|
||||
}
|
||||
robot.keyTap('enter');
|
||||
done();
|
||||
} else {
|
||||
app.browserWindow.getBounds().then((bounds) => {
|
||||
app.browserWindow.focus();
|
||||
robot.setMouseDelay(200);
|
||||
app.browserWindow.restore().then(() => {
|
||||
let x = bounds.x + 95;
|
||||
let y = bounds.y + 35;
|
||||
|
||||
robot.moveMouseSmooth(x, y);
|
||||
robot.mouseClick();
|
||||
for (let i = 0; i < 4; i++) {
|
||||
robot.keyTap('down');
|
||||
}
|
||||
robot.keyTap('enter');
|
||||
done();
|
||||
});
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should check is always on top to be true', () => {
|
||||
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
||||
expect(isAlwaysOnTop).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
if (!mIsAlwaysOnTop) {
|
||||
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
||||
expect(isAlwaysOnTop).toBeTruthy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
} else {
|
||||
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
||||
expect(isAlwaysOnTop).toBeFalsy();
|
||||
}).catch((err) => {
|
||||
expect(err).toBeNull();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,8 @@
|
||||
const Application = require('spectron').Application;
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const {isMac} = require('../../js/utils/misc');
|
||||
const ncp = require('ncp').ncp;
|
||||
|
||||
class App {
|
||||
|
||||
@ -12,6 +15,8 @@ class App {
|
||||
this.options.args = [path.join(__dirname, '..', '..', 'js/main.js')];
|
||||
}
|
||||
|
||||
App.copyConfigPath();
|
||||
|
||||
this.app = new Application(this.options);
|
||||
}
|
||||
|
||||
@ -35,6 +40,33 @@ class App {
|
||||
return 90000
|
||||
}
|
||||
|
||||
static readConfig(configPath) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
fs.readFile(configPath, function (err, data) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
resolve(JSON.parse(data));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static copyConfigPath() {
|
||||
if (isMac) {
|
||||
ncp('config', 'node_modules/electron/dist/Electron.app/Contents/config', function (err) {
|
||||
if (err) {
|
||||
throw(err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ncp('config', 'node_modules/electron/dist/config', function (err) {
|
||||
if (err) {
|
||||
throw(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = App;
|
Loading…
Reference in New Issue
Block a user