mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Electron-93
1. Fixed always on top tests for windows 2. Moved ncp from CLI to Programmatic usage
This commit is contained in:
parent
8d0f9423a9
commit
1f6219a3f6
@ -5,6 +5,7 @@ const childProcess = require('child_process');
|
|||||||
let app = new Application({});
|
let app = new Application({});
|
||||||
let robot;
|
let robot;
|
||||||
let configPath;
|
let configPath;
|
||||||
|
let mIsAlwaysOnTop;
|
||||||
|
|
||||||
describe('Tests for Always on top', () => {
|
describe('Tests for Always on top', () => {
|
||||||
|
|
||||||
@ -19,8 +20,6 @@ describe('Tests for Always on top', () => {
|
|||||||
getConfigPath().then((config) => {
|
getConfigPath().then((config) => {
|
||||||
configPath = config;
|
configPath = config;
|
||||||
done();
|
done();
|
||||||
}).catch((err) => {
|
|
||||||
expect(err).toBeNull();
|
|
||||||
});
|
});
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
expect(err).toBeNull();
|
expect(err).toBeNull();
|
||||||
@ -66,8 +65,6 @@ describe('Tests for Always on top', () => {
|
|||||||
return app.client.getWindowCount().then((count) => {
|
return app.client.getWindowCount().then((count) => {
|
||||||
expect(count === 1).toBeTruthy();
|
expect(count === 1).toBeTruthy();
|
||||||
done();
|
done();
|
||||||
}).catch((err) => {
|
|
||||||
expect(err).toBeNull();
|
|
||||||
});
|
});
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
expect(err).toBeNull();
|
expect(err).toBeNull();
|
||||||
@ -90,9 +87,49 @@ 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', () => {
|
it('should check is always on top', () => {
|
||||||
|
return Application.readConfig(configPath).then((userData) => {
|
||||||
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
||||||
|
mIsAlwaysOnTop = isAlwaysOnTop;
|
||||||
|
if (userData.alwaysOnTop) {
|
||||||
|
expect(isAlwaysOnTop).toBeTruthy();
|
||||||
|
} else {
|
||||||
expect(isAlwaysOnTop).toBeFalsy();
|
expect(isAlwaysOnTop).toBeFalsy();
|
||||||
|
}
|
||||||
|
});
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
expect(err).toBeNull();
|
expect(err).toBeNull();
|
||||||
});
|
});
|
||||||
@ -107,30 +144,31 @@ describe('Tests for Always on top', () => {
|
|||||||
robot.keyTap('down');
|
robot.keyTap('down');
|
||||||
}
|
}
|
||||||
robot.keyTap('enter');
|
robot.keyTap('enter');
|
||||||
setTimeout(() => {
|
|
||||||
done();
|
done();
|
||||||
}, 5000)
|
|
||||||
} else {
|
} else {
|
||||||
app.browserWindow.getBounds().then((bounds) => {
|
app.browserWindow.getBounds().then((bounds) => {
|
||||||
|
app.browserWindow.focus();
|
||||||
robot.setMouseDelay(200);
|
robot.setMouseDelay(200);
|
||||||
|
app.browserWindow.restore().then(() => {
|
||||||
let x = bounds.x + 95;
|
let x = bounds.x + 95;
|
||||||
let y = bounds.x + 95;
|
let y = bounds.y + 35;
|
||||||
robot.moveMouse(x, y);
|
|
||||||
|
robot.moveMouseSmooth(x, y);
|
||||||
robot.mouseClick();
|
robot.mouseClick();
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
robot.keyTap('down');
|
robot.keyTap('down');
|
||||||
}
|
}
|
||||||
robot.keyTap('enter');
|
robot.keyTap('enter');
|
||||||
setTimeout(() => {
|
|
||||||
done();
|
done();
|
||||||
}, 5000)
|
});
|
||||||
|
}).catch((err) => {
|
||||||
|
expect(err).toBeNull();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check is always on top to be true', () => {
|
it('should check is always on top to be true', () => {
|
||||||
return Application.readConfig(configPath).then((userData) => {
|
if (!mIsAlwaysOnTop) {
|
||||||
if (userData.alwaysOnTop) {
|
|
||||||
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
return app.browserWindow.isAlwaysOnTop().then((isAlwaysOnTop) => {
|
||||||
expect(isAlwaysOnTop).toBeTruthy();
|
expect(isAlwaysOnTop).toBeTruthy();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
@ -144,56 +182,5 @@ describe('Tests for Always on top', () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it('should toggle the always on top property to false', (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');
|
|
||||||
setTimeout(() => {
|
|
||||||
done();
|
|
||||||
}, 5000);
|
|
||||||
} else {
|
|
||||||
app.browserWindow.getBounds().then((bounds) => {
|
|
||||||
robot.setMouseDelay(200);
|
|
||||||
let x = bounds.x + 95;
|
|
||||||
let y = bounds.x + 95;
|
|
||||||
robot.moveMouse(x, y);
|
|
||||||
robot.mouseClick();
|
|
||||||
for (let i = 0; i < 4; i++) {
|
|
||||||
robot.keyTap('down');
|
|
||||||
}
|
|
||||||
robot.keyTap('enter');
|
|
||||||
setTimeout(() => {
|
|
||||||
done();
|
|
||||||
}, 5000)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check is always on top to be true', () => {
|
|
||||||
return Application.readConfig(configPath).then((userData) => {
|
|
||||||
if (userData.alwaysOnTop) {
|
|
||||||
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();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}).catch((err) => {
|
|
||||||
expect(err).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
const Application = require('spectron').Application;
|
const Application = require('spectron').Application;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const childProcess = require('child_process');
|
const {isMac} = require('../../js/utils/misc');
|
||||||
const { isMac } = require('../../js/utils/misc');
|
const ncp = require('ncp').ncp;
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
|
|
||||||
@ -51,16 +51,16 @@ class App {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static copyConfigPath(){
|
static copyConfigPath() {
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
childProcess.exec(`ncp 'config' 'node_modules/electron/dist/Electron.app/Contents/config'`, function (err) {
|
ncp('config', 'node_modules/electron/dist/Electron.app/Contents/config', function (err) {
|
||||||
if (err){
|
if (err) {
|
||||||
throw(err);
|
throw(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
childProcess.exec(`ncp config node_modules/electron/dist/config`, function (err) {
|
ncp('config', 'node_modules/electron/dist/config', function (err) {
|
||||||
if (err){
|
if (err) {
|
||||||
throw(err);
|
throw(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user