Merge remote-tracking branch 'upstream/master' into test

# Conflicts:
#	package.json
This commit is contained in:
Keerthi Niranjan 2017-07-25 21:06:15 +05:30
commit 25917d0301
17 changed files with 714 additions and 56 deletions

View File

@ -46,9 +46,5 @@ rm -f $tempFilePath
## For launching symphony with sandbox enabled, create a shell script that is used as the launch point for the app
EXEC_PATH=$installPath/Symphony.app/Contents/MacOS
mv $EXEC_PATH/Symphony $EXEC_PATH/Symphony-bin
cat > $EXEC_PATH/Symphony << EOT
#!/bin/sh
exec "\${0%/*}/Symphony-bin" --enable-sandbox \$@
EOT
chmod 755 $EXEC_PATH/Symphony
exec $EXEC_PATH/Symphony --install $newPath
chmod 755 $EXEC_PATH/Symphony

View File

@ -57,7 +57,6 @@
<ROW Component="Symphony" ComponentId="{A6B4BA2F-2403-4B8E-9303-BF8400A9B1C4}" Directory_="Symphony_Dir" Attributes="0"/>
<ROW Component="Symphony.config" ComponentId="{644A231D-2C96-4D3D-ADB0-7820DA373499}" Directory_="config_Dir" Attributes="0" KeyPath="Symphony.config_1" Type="0"/>
<ROW Component="Symphony.exe" ComponentId="{853053E4-D96C-42FE-9AF1-52FF1F449FFD}" Directory_="APPDIR" Attributes="256" KeyPath="Symphony.exe"/>
<ROW Component="SymphonyElectron.exe" ComponentId="{050ABDCB-63C1-46C4-8E40-B3C80931C3DA}" Directory_="APPDIR" Attributes="256" KeyPath="SymphonyElectron.exe"/>
<ROW Component="am.pak" ComponentId="{76F935B8-6077-4C7A-AD1B-77E2DBA856CC}" Directory_="locales_Dir" Attributes="0" KeyPath="am.pak" Type="0"/>
<ROW Component="appupdate.yml" ComponentId="{F7586760-660A-4C38-8937-138DBEC18D34}" Directory_="resources_Dir" Attributes="0" KeyPath="appupdate.yml" Type="0"/>
<ROW Component="blink_image_resources_200_percent.pak" ComponentId="{56AB17A5-B690-4CBE-A39D-512381AAAFE1}" Directory_="APPDIR" Attributes="0" KeyPath="blink_image_resources_200_percent.pak" Type="0"/>
@ -69,16 +68,15 @@
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.MsiFeatsComponent">
<ROW Feature="D564007E3BBE4F85950A09B470A7CA65" Title="Visual C++ Redistributable for Visual Studio 2013 x86" Description="Visual C++ Redistributable for Visual Studio 2013 x86" Display="3" Level="1" Attributes="0" Components="AI_CustomARPName"/>
<ROW Feature="MainFeature" Title="MainFeature" Description="Description" Display="1" Level="1" Directory_="APPDIR" Attributes="0" Components="AI_CustomARPName PodUrl ProductInformation ScreenSnippet.exe Symphony Symphony.config Symphony.exe SymphonyElectron.exe am.pak appupdate.yml blink_image_resources_200_percent.pak d3dcompiler_47.dll ffmpeg.dll libEGL.dll libGLESv2.dll node.dll"/>
<ROW Feature="MainFeature" Title="MainFeature" Description="Description" Display="1" Level="1" Directory_="APPDIR" Attributes="0" Components="AI_CustomARPName PodUrl ProductInformation ScreenSnippet.exe Symphony Symphony.config Symphony.exe am.pak appupdate.yml blink_image_resources_200_percent.pak d3dcompiler_47.dll ffmpeg.dll libEGL.dll libGLESv2.dll node.dll"/>
<ATTRIBUTE name="CurrentFeature" value="MainFeature"/>
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.MsiFilesComponent">
<ROW File="LICENSE.electron.txt" Component_="blink_image_resources_200_percent.pak" FileName="LICENS~1.TXT|LICENSE.electron.txt" Attributes="0" SourcePath="..\..\dist\win-unpacked\LICENSE.electron.txt" SelfReg="false" NextFile="LICENSES.chromium.html"/>
<ROW File="LICENSES.chromium.html" Component_="blink_image_resources_200_percent.pak" FileName="LICENS~1.HTM|LICENSES.chromium.html" Attributes="0" SourcePath="..\..\dist\win-unpacked\LICENSES.chromium.html" SelfReg="false" NextFile="natives_blob.bin"/>
<ROW File="ScreenSnippet.exe" Component_="ScreenSnippet.exe" FileName="SCREEN~1.EXE|ScreenSnippet.exe" Attributes="0" SourcePath="..\..\node_modules\screen-snippet\bin\Release\ScreenSnippet.exe" SelfReg="false" NextFile="SymphonyElectron.exe" DigSign="true"/>
<ROW File="ScreenSnippet.exe" Component_="ScreenSnippet.exe" FileName="SCREEN~1.EXE|ScreenSnippet.exe" Attributes="0" SourcePath="..\..\node_modules\screen-snippet\bin\Release\ScreenSnippet.exe" SelfReg="false" DigSign="true"/>
<ROW File="Symphony.config_1" Component_="Symphony.config" FileName="SYMPHO~1.CON|Symphony.config" Attributes="0" SourcePath="..\..\dist\win-unpacked\config\Symphony.config" SelfReg="false" NextFile="ScreenSnippet.exe"/>
<ROW File="Symphony.exe" Component_="Symphony.exe" FileName="Symphony.exe" Attributes="0" SourcePath="Symphony.exe" SelfReg="false" NextFile="ui_resources_200_percent.pak" DigSign="true"/>
<ROW File="SymphonyElectron.exe" Component_="SymphonyElectron.exe" FileName="SYMPHO~1.EXE|Symphony-Electron.exe" Attributes="0" SourcePath="..\..\dist\win-unpacked\Symphony-Electron.exe" SelfReg="false" DigSign="true"/>
<ROW File="Symphony.exe" Component_="Symphony.exe" FileName="Symphony.exe" Attributes="0" SourcePath="..\..\dist\win-unpacked\Symphony.exe" SelfReg="false" NextFile="ui_resources_200_percent.pak" DigSign="true"/>
<ROW File="am.pak" Component_="am.pak" FileName="am.pak" Attributes="0" SourcePath="..\..\dist\win-unpacked\locales\am.pak" SelfReg="false" NextFile="ar.pak"/>
<ROW File="app.asar" Component_="appupdate.yml" FileName="APP~1.ASA|app.asar" Attributes="0" SourcePath="..\..\dist\win-unpacked\resources\app.asar" SelfReg="false" NextFile="electron.asar"/>
<ROW File="appupdate.yml" Component_="appupdate.yml" FileName="APP-UP~1.YML|app-update.yml" Attributes="0" SourcePath="..\..\dist\win-unpacked\resources\app-update.yml" SelfReg="false" NextFile="app.asar"/>
@ -362,7 +360,7 @@
<ROW Action="SET_APPDIR" Type="307" Source="APPDIR" Target="[ProgramFilesFolder][Manufacturer]\[ProductName]" MultiBuildTarget="DefaultBuild:[AI_UserProgramFiles][Manufacturer]\[ProductName]"/>
<ROW Action="SET_SHORTCUTDIR" Type="307" Source="SHORTCUTDIR" Target="[ProgramMenuFolder][ProductName]"/>
<ROW Action="SET_TARGETDIR_TO_APPDIR" Type="51" Source="TARGETDIR" Target="[APPDIR]"/>
<ROW Action="Symphony.exe" Type="1042" Source="SymphonyElectron.exe" Target="--install"/>
<ROW Action="Symphony.exe" Type="1042" Source="Symphony.exe" Target="--install"/>
<ROW Action="UninstallPreviousVersions" Type="1" Source="aicustact.dll" Target="UninstallPreviousVersions" Options="1"/>
</COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.MsiIconsComponent">

View File

@ -9,7 +9,11 @@ const urlParser = require('url');
const { getConfigField } = require('./config.js');
const { isMac, isDevEnv } = require('./utils/misc.js');
const protocolHandler = require('./protocolHandler');
const getCmdLineArg = require('./utils/getCmdLineArg.js')
const getCmdLineArg = require('./utils/getCmdLineArg.js');
const childProcess = require('child_process');
const path = require('path');
const AppDirectory = require('appdirectory');
const dirs = new AppDirectory('Symphony');
require('electron-dl')();
@ -94,9 +98,18 @@ function setupThenOpenMainWindow() {
let hasInstallFlag = getCmdLineArg(process.argv, '--install', true);
if (!isMac && hasInstallFlag) {
getConfigField('launchOnStartup')
.then(setStartup)
.then(app.quit)
.catch(app.quit);
.then(setStartup)
.then(updateUserConfigWin)
.then(app.quit)
.catch(app.quit);
return;
}
// allows mac installer to overwrite user config
if (isMac && hasInstallFlag) {
updateUserConfigMac()
.then(app.quit)
.catch(app.quit);
return;
}
@ -118,6 +131,37 @@ function setStartup(lStartup){
});
}
// Method to overwrite user config on mac installer
function updateUserConfigMac() {
return new Promise((resolve, reject) => {
let userConfigPath = dirs.userConfig() + '/';
let globalConfigPath = process.argv[2];
let userName = process.env.USER;
childProcess.exec(`rsync -r "${globalConfigPath}" "${userConfigPath}" && chown -R "${userName}" "${userConfigPath}"`, {timeout: 60000}, (err) => {
if (err) {
reject(err);
}
resolve();
});
});
}
// Method to overwrite user config on windows installer
function updateUserConfigWin() {
return new Promise((resolve, reject) => {
let userConfigPath = app.getPath('userData');
let globalConfigPath = path.join(__dirname, '..', '..', '..', 'config/Symphony.config');
childProcess.exec(`echo D|xcopy /y /e /s /c "${globalConfigPath}" "${userConfigPath}"`, {timeout: 60000}, (err) => {
if (err) {
reject(err);
}
resolve();
});
});
}
function getUrlAndCreateMainWindow() {
// for dev env allow passing url argument
if (isDevEnv) {

View File

@ -48,6 +48,8 @@ let externalDisplay;
// user selected display id for notification
let displayId;
let sandboxed = false;
let config = {
// corner to put notifications
// upper-right, upper-left, lower-right, lower-left
@ -131,7 +133,7 @@ let config = {
acceptFirstMouse: true,
webPreferences: {
preload: path.join(__dirname, 'electron-notify-preload.js'),
sandbox: !isNodeEnv,
sandbox: sandboxed,
nodeIntegration: isNodeEnv
}
}

View File

@ -17,6 +17,7 @@ let configurationWindow;
let screens;
let position;
let display;
let sandboxed = false;
let windowConfig = {
width: 460,
@ -27,7 +28,7 @@ let windowConfig = {
resizable: false,
webPreferences: {
preload: path.join(__dirname, 'configure-notification-position-preload.js'),
sandbox: true,
sandbox: sandboxed,
nodeIntegration: false
}
};

View File

@ -37,6 +37,7 @@ let boundsChangeWindow;
let alwaysOnTop = false;
let position = 'lower-right';
let display;
let sandboxed = false;
// note: this file is built using browserify in prebuild step.
const preloadMainScript = path.join(__dirname, 'preload/_preloadMain.js');
@ -81,9 +82,10 @@ function doCreateMainWindow(initialUrl, initialBounds) {
minHeight: MIN_HEIGHT,
alwaysOnTop: false,
webPreferences: {
sandbox: !isNodeEnv,
sandbox: sandboxed,
nodeIntegration: isNodeEnv,
preload: preloadMainScript,
nativeWindowOpen: true
}
};
@ -212,6 +214,9 @@ function doCreateMainWindow(initialUrl, initialBounds) {
// bug in electron is preventing this from working in sandboxed evt...
// https://github.com/electron/electron/issues/8841
mainWindow.webContents.on('will-navigate', function(event, willNavUrl) {
if (!sandboxed) {
return;
}
event.preventDefault();
openUrlInDefaultBrower(willNavUrl);
});

View File

@ -12,12 +12,14 @@
"demo-win-search": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file:///demo/search.html",
"demo-mac-search": "npm run prebuild && cross-env ELECTRON_DEV=true electron . --url=file://$(pwd)/demo/search.html",
"unpacked-mac": "npm run prebuild && npm run test && build --mac --dir",
"unpacked-win": "npm run prebuild && npm run test && build --win --x64 --dir && npm run rename-exe",
"unpacked-win-x86": "npm run prebuild && npm run test && build --win --ia32 --dir && npm run rename-exe",
"packed-mac": "npm run unpacked-mac && packagesbuild -v installer/mac/symphony-mac-packager.pkgproj",
"unpacked-win": "npm run prebuild && npm run test && build --win --x64 --dir",
"unpacked-win-x86": "npm run prebuild && npm run test && build --win --ia32",
"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 && jest --verbose --testPathPattern test --runInBand",
"test": "npm run lint && jest --verbose --testPathPattern test && npm run rebuild",
"spectron-test": "jest --config tests/spectron/jest_spectron.json --runInBand && npm run rebuild",
"lint": "eslint --ext .js js/",
"rename-exe": "cd dist/win-unpacked && ren Symphony.exe Symphony-Electron.exe"
},
@ -70,7 +72,7 @@
"devDependencies": {
"browserify": "^14.1.0",
"cross-env": "^3.2.4",
"electron": "1.6.11",
"electron": "1.7.5",
"electron-builder": "^13.9.0",
"electron-builder-squirrel-windows": "^12.3.0",
"electron-packager": "^8.5.2",
@ -90,10 +92,11 @@
"async": "^2.1.5",
"auto-launch": "^5.0.1",
"electron-context-menu": "^0.8.0",
"electron-dl": "^1.9.0",
"electron-squirrel-startup": "^1.0.0",
"filesize": "^3.5.10",
"keymirror": "0.1.1",
"electron-dl": "^1.9.0",
"filesize": "^3.5.10",
"appdirectory": "^0.1.0",
"randomstring": "^1.1.5",
"winreg": "^1.2.3"
},

View File

@ -3,10 +3,10 @@ const childProcess = require('child_process');
let activityDetection;
describe('Tests for Activity Detection', function() {
describe('Tests for Activity Detection', function () {
var originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
beforeAll(function (done) {
childProcess.exec(`npm rebuild --target=${process.version} --build-from-source`, function (err) {
@ -21,13 +21,11 @@ describe('Tests for Activity Detection', function() {
});
afterAll(function (done) {
childProcess.exec('npm run rebuild', function (err, stdout) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
done();
});
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
done();
});
it('should return null', function() {
it('should return null', function () {
activityDetection.setActivityWindow(0, electron.ipcRenderer);
const noData = activityDetection.activityDetection();

View File

@ -1,5 +1,5 @@
const Application = require('./spectron/spectronSetup');
const {isMac} = require('../js/utils/misc.js');
const Application = require('./spectronSetup');
const {isMac} = require('../../js/utils/misc.js');
const childProcess = require('child_process');
let app = new Application({});
@ -46,16 +46,12 @@ describe('Tests for Always on top', () => {
if (app && app.isRunning()) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
app.stop().then(() => {
childProcess.exec('npm run rebuild', function (err, stdout) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
done();
});
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
done();
}).catch((err) => {
childProcess.exec('npm run rebuild', function () {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
expect(err).toBeNull();
done();
});
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
expect(err).toBeNull();
done();
});
}
});

View File

@ -1,4 +1,4 @@
const Application = require('./spectron/spectronSetup');
const Application = require('./spectronSetup');
let app = new Application({});
describe('Tests for Bring to front', () => {

View File

@ -1,4 +1,4 @@
const Application = require('./spectron/spectronSetup');
const Application = require('./spectronSetup');
const path = require('path');
let app = new Application({});
@ -40,7 +40,7 @@ describe('Tests for clipboard', () => {
});
it('should check window count', () => {
return app.client.url('file:///' + path.join(__dirname, '..', 'demo/index.html'));
return app.client.url('file:///' + path.join(__dirname, '..', '..', 'demo/index.html'));
});
it('should set the username field', () => {

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('./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);
});
});

View File

@ -0,0 +1,142 @@
const path = require('path');
const fs = require('fs');
const childProcess = require('child_process');
const Application = require('./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,4 @@
{
"testMatch": ["**/*.spectron.js"],
"verbose": true
}

View File

@ -0,0 +1,196 @@
const path = require('path');
const fs = require('fs');
const childProcess = require('child_process');
const Application = require('./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 Application = require('./spectronSetup');
const path = require('path');
const {isMac} = require('../../js/utils/misc');
let app = new Application({});
describe('Tests for Notification position', () => {
@ -42,13 +43,7 @@ describe('Tests for Notification position', () => {
});
it('should load demo html page', () => {
let filePath;
if (process.platform === 'win32') {
filePath = 'file:///' + path.join(__dirname, '..', 'demo/index.html');
} else {
filePath = 'file://$(pwd)/' + path.join(__dirname, '..', 'demo/index.html')
}
return app.client.url(filePath);
return app.client.url('file:///' + path.join(__dirname, '..', '..', 'demo/index.html'));
});
it('should load demo html', () => {
@ -77,7 +72,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 +156,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('./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();
})
});
}
});
});