Merge branch 'master' into electron-99

This commit is contained in:
Vishwas Shashidhar 2017-07-18 21:23:08 +05:30
commit 57323623e2
6 changed files with 622 additions and 2 deletions

View File

@ -22,6 +22,9 @@ describe('Tests for Activity Detection', function() {
afterAll(function (done) {
childProcess.exec('npm run rebuild', function (err, stdout) {
if (err){
throw(err);
}
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
done();
});

70
tests/close.test.js Normal file
View File

@ -0,0 +1,70 @@
describe('Tests for Close', () => {
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();
});
});
afterAll((done) => {
if (app && app.isRunning()) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
app.stop().then(() => {
done();
}).catch((err) => {
console.log(err);
done();
});
} else {
done();
}
});
it('should launch the app', (done) => {
return app.client.waitUntilWindowLoaded().then(() => {
return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy();
done();
}).catch((err) => {
expect(err).toBeNull();
});
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should check window count', () => {
return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should check browser window visibility', () => {
return app.browserWindow.isVisible().then((isVisible) => {
expect(isVisible).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should close the app', () => {
return app.stop();
});
it('should check whether the app is running', () => {
expect(app.isRunning()).toBe(false);
});
});

142
tests/full-screen.test.js Normal file
View File

@ -0,0 +1,142 @@
const path = require('path');
const fs = require('fs');
const childProcess = require('child_process');
const Application = require('./spectron/spectronSetup');
const {isMac} = require('../js/utils/misc');
let robot;
let configPath;
let app = new Application({});
describe('Tests for Full screen', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
beforeAll((done) => {
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) => {
console.log(config);
configPath = config;
done();
}).catch((err) => {
expect(err).toBeNull();
});
}).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.client.getWindowCount().then((count) => {
if (count > 0) {
app.stop().then(() => {
done();
}).catch((err) => {
console.log(err);
done();
});
} else {
done();
}
})
} else {
done();
}
});
it('should launch the app', (done) => {
return app.client.waitUntilWindowLoaded().then(() => {
return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy();
done();
}).catch((err) => {
expect(err).toBeNull();
});
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should check window count', () => {
return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should check browser window visibility', () => {
return app.browserWindow.isVisible().then((isVisible) => {
expect(isVisible).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should bring the app to top', () => {
app.browserWindow.focus();
return app.browserWindow.setAlwaysOnTop(true).then(() => {
return app.browserWindow.isAlwaysOnTop().then((isOnTop) => {
console.log(isOnTop);
expect(isOnTop).toBeTruthy();
});
});
});
it('should set the app full screen and check whether it is in full screen', () => {
if (isMac) {
robot.setMouseDelay(100);
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();
})
});
}
});
});

View File

@ -0,0 +1,196 @@
const path = require('path');
const fs = require('fs');
const childProcess = require('child_process');
const Application = require('./spectron/spectronSetup');
const {isMac} = require('../js/utils/misc');
let robot;
let configPath;
let app = new Application({});
describe('Tests for Minimize on Close', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
beforeAll((done) => {
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) => {
console.log(config);
configPath = config;
done();
}).catch((err) => {
expect(err).toBeNull();
});
}).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.client.getWindowCount().then((count) => {
if (count > 0) {
app.stop().then(() => {
done();
}).catch((err) => {
console.log(err);
done();
});
} else {
done();
}
})
} else {
done();
}
});
it('should launch the app', (done) => {
return app.client.waitUntilWindowLoaded().then(() => {
return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy();
done();
}).catch((err) => {
expect(err).toBeNull();
});
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should check window count', () => {
return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should check browser window visibility', () => {
return app.browserWindow.isVisible().then((isVisible) => {
expect(isVisible).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should bring the app to top', () => {
app.browserWindow.focus();
return app.browserWindow.setAlwaysOnTop(true).then(() => {
return app.browserWindow.isAlwaysOnTop().then((isOnTop) => {
console.log(isOnTop);
expect(isOnTop).toBeTruthy();
});
});
});
it('should check whether the app is minimized', (done) => {
Application.readConfig(configPath).then((userConfig) => {
if (isMac) {
if (userConfig.minimizeOnClose) {
robot.setKeyboardDelay(100);
robot.keyToggle('w', 'down', ['command']);
robot.keyToggle('w', 'up');
robot.keyToggle('command', 'up');
app.browserWindow.isMinimized().then(function (minimized) {
expect(minimized).toBeTruthy();
done();
}).catch((err) => {
expect(err).toBeNull();
done();
});
} else {
robot.setMouseDelay(100);
robot.moveMouseSmooth(200, 10);
robot.mouseClick();
robot.setKeyboardDelay(100);
for (let i = 0; i < 9; i++) {
robot.keyTap('down');
}
robot.keyTap('enter');
robot.keyToggle('w', 'down', ['command']);
robot.keyToggle('w', 'up');
robot.keyToggle('command', 'up');
app.browserWindow.isMinimized().then(function (minimized) {
expect(minimized).toBeTruthy();
done();
}).catch((err) => {
expect(err).toBeNull();
done();
});
}
} else {
if (!userConfig.minimizeOnClose) {
app.browserWindow.getBounds().then((bounds) => {
robot.setMouseDelay(100);
let x = bounds.x + 95;
let y = bounds.y + 35;
robot.moveMouse(x, y);
robot.mouseClick();
for (let i = 0; i < 5; i++) {
robot.keyTap('down');
}
robot.keyTap('enter');
robot.keyToggle('w', 'down', ['control']);
robot.keyToggle('w', 'up');
robot.keyToggle('control', 'up');
app.browserWindow.isMinimized().then(function (minimized) {
expect(minimized).toBeTruthy();
done();
}).catch((err) => {
expect(err).toBeNull();
done();
});
});
} else {
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.keyToggle('w', 'down', ['control']);
robot.keyToggle('w', 'up');
robot.keyToggle('control', 'up');
app.browserWindow.isMinimized().then(function (minimized) {
expect(minimized).toBeTruthy();
done();
}).catch((err) => {
expect(err).toBeNull();
done();
});
});
}
}
}).catch((err) => {
expect(err).toBeNull();
done();
})
});
});

View File

@ -1,5 +1,6 @@
const Application = require('./spectron/spectronSetup');
const path = require('path');
const {isMac} = require('../js/utils/misc');
let app = new Application({});
describe('Tests for Notification position', () => {
@ -77,7 +78,11 @@ describe('Tests for Notification position', () => {
it('should check notification position', () => {
return app.browserWindow.getBounds().then((bounds) => {
expect(bounds.x === 0).toBeTruthy();
expect(bounds.y > 0).toBeTruthy();
if (isMac) {
expect(bounds.y > 0).toBeTruthy();
} else {
expect(bounds.y === 0).toBeTruthy();
}
}).catch((err) => {
expect(err).toBeNull();
});
@ -157,7 +162,11 @@ describe('Tests for Notification position', () => {
it('should check notification position and equal to upper-right', () => {
return app.browserWindow.getBounds().then((bounds) => {
expect(bounds.x > 0).toBeTruthy();
expect(bounds.y > 0).toBeTruthy();
if (isMac) {
expect(bounds.y > 0).toBeTruthy();
} else {
expect(bounds.y === 0).toBeTruthy();
}
}).catch((err) => {
expect(err).toBeNull();
});

View File

@ -0,0 +1,200 @@
const path = require('path');
const fs = require('fs');
const childProcess = require('child_process');
const Application = require('./spectron/spectronSetup');
const {isMac} = require('../js/utils/misc');
let robot;
let configPath;
let app = new Application({});
describe('Tests for Zoom in and Zoom out', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
beforeAll((done) => {
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();
});
}).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.client.getWindowCount().then((count) => {
if (count > 0) {
app.stop().then(() => {
done();
}).catch((err) => {
console.log(err);
done();
});
} else {
done();
}
})
} else {
done();
}
});
it('should launch the app', (done) => {
return app.client.waitUntilWindowLoaded().then(() => {
return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy();
done();
}).catch((err) => {
expect(err).toBeNull();
});
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should check window count', () => {
return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should check browser window visibility', () => {
return app.browserWindow.isVisible().then((isVisible) => {
expect(isVisible).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
});
});
it('should bring the app to top', () => {
app.browserWindow.focus();
return app.browserWindow.setAlwaysOnTop(true).then(() => {
return app.browserWindow.isAlwaysOnTop().then((isOnTop) => {
expect(isOnTop).toBeTruthy();
});
});
});
it('should zoom in the app and check whether it is zoomed in', () => {
robot.setKeyboardDelay(500);
if (isMac) {
robot.keyToggle('0', 'down', ['command']);
robot.keyToggle('0', 'up');
robot.keyToggle('command', 'up');
for (var i = 0; i < 4; i++) {
robot.keyToggle('+', 'down', ['command']);
}
robot.keyToggle('+', 'up');
robot.keyToggle('command', 'up');
return app.electron.webFrame.getZoomFactor().then((zoomFactor) => {
expect(zoomFactor > 1).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.keyToggle('0', 'down', ['control']);
robot.keyToggle('0', 'up');
robot.keyToggle('control', 'up');
for (var i = 0; i < 4; i++) {
robot.keyToggle('+', 'down', ['control', 'shift']);
}
robot.keyToggle('+', 'up');
robot.keyToggle('control', 'up');
robot.keyToggle('shift', 'up');
return app.electron.webFrame.getZoomFactor().then((zoomFactor) => {
expect(zoomFactor > 1).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
})
});
}
});
it('should zoom out the app and check whether it is zoomed out', () => {
robot.setKeyboardDelay(500);
if (isMac) {
robot.keyToggle('0', 'down', ['command']);
robot.keyToggle('0', 'up');
robot.keyToggle('command', 'up');
for (var i = 0; i < 4; i++) {
robot.keyToggle('-', 'down', ['command']);
}
robot.keyToggle('-', 'up');
robot.keyToggle('command', 'up');
return app.electron.webFrame.getZoomFactor().then((zoomFactor) => {
expect(zoomFactor < 1).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.keyToggle('0', 'down', ['control']);
robot.keyToggle('0', 'up');
robot.keyToggle('control', 'up');
for (var i = 0; i < 4; i++) {
robot.keyToggle('-', 'down', ['control']);
}
robot.keyToggle('-', 'up');
robot.keyToggle('control', 'up');
return app.electron.webFrame.getZoomFactor().then((zoomFactor) => {
expect(zoomFactor < 1).toBeTruthy();
}).catch((err) => {
expect(err).toBeNull();
})
});
}
});
});