commit code

This commit is contained in:
Tran Duc Anh
2018-09-10 18:00:51 +07:00
parent 87d6c20ad9
commit 29a0780d65
7 changed files with 230 additions and 216 deletions

View File

@@ -4,14 +4,14 @@ const WindowsActions = require('./spectronWindowsActions');
const WebActions = require('./spectronWebActions');
const Utils = require('./spectronUtils');
let mainApp = new Application({});
let app, wActions, config;
let app, wActions, config, userConfig;
!isMac? describe('Add Test To Verify Minimize on Close', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
describe('Add Test To Verify Minimize on Close', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000;
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
beforeAll(async (done) => {
try {
app = await mainApp.startApplication({ alwaysOnTop: false });
@@ -43,13 +43,20 @@ let app, wActions, config;
afterAll(async (done) => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
try {
if (app && app.isRunning()) {
done();
wActions.closeChrome();
}
} catch (error) {
done.fail(new Error(`After all: ${error}`));
try {
if (app && app.isRunning()) {
if (isMac) {
//await wActions.closeChromeDriverOnMac();
await app.stop();
}
else {
await wActions.closeChromeDriver();
}
await done();
}
} catch (error) {
done.fail(new Error(`After all: ${error}`));
}
});
@@ -59,23 +66,46 @@ let app, wActions, config;
* Cover scenarios in AVT-939
*/
it('Verify Minimize on Close option once the application is installed', async (done) => {
if (isWindowsOS) {
try {
let userConfig = await Application.readConfig(config);
await wActions.openMenu(["Window", "Minimize on Close"]);
if (userConfig.minimizeOnClose != false) {
try {
userConfig = await Application.readConfig(config);
if (userConfig.minimizeOnClose == false) {
if (!isMac) {
await wActions.openMenu(["Window", "Minimize on Close"]);
await wActions.openMenu(["Window", "Close"]);
}
await wActions.openMenu(["Window", "Close"]);
else {
await wActions.openMenuOnMac(["View", "Minimize on Close"]);
await wActions.openMenuOnMac(["Window", "Close"]);
}
await wActions.verifyMinimizeWindows()
await done();
}
else {
if (!isMac) {
await wActions.openMenu(["Window", "Minimize on Close"]);
await wActions.openMenu(["Window", "Minimize on Close"])
await wActions.openMenu(["Window", "Close"]);
}
else {
await wActions.openMenuOnMac(["View", "Minimize on Close"]);
await wActions.openMenuOnMac(["View", "Minimize on Close"]);
await wActions.openMenuOnMac(["Window", "Close"]);
}
await wActions.verifyMinimizeWindows();
await done();
} catch (err) {
done.fail(new Error(`Verify Minimize on Close option once the application is installed: ${err}`));
};
}
else {
await done();
}
}
} catch (err) {
done.fail(new Error(`Verify Minimize on Close option once the application is installed: ${err}`));
};
});
/**
@@ -84,60 +114,76 @@ let app, wActions, config;
* Cover scenarios in AVT-937
*/
it('Close window when "Minimize on Close" is ON', async (done) => {
if (isWindowsOS) {
try {
let userConfig = await Application.readConfig(config);
await wActions.focusWindow();
try {
await wActions.bringToFront("Symphony");
if (!isMac) {
await wActions.openMenu(["Window", "Minimize on Close"]);
if (userConfig.minimizeOnClose != false) {
await wActions.openMenu(["Window", "Minimize on Close"]);
}
await wActions.openMenu(["Window", "Close"])
await wActions.verifyMinimizeWindows();
await wActions.openMenu(["Window", "Minimize on Close"])
await wActions.openMenu(["Window", "Close"]);
}
else {
await wActions.openMenuOnMac(["View", "Minimize on Close"]);
await wActions.openMenuOnMac(["View", "Minimize on Close"]);
await wActions.openMenuOnMac(["Window", "Close"]);
}
await wActions.focusWindow();
await wActions.bringToFront("");
await Utils.sleep(2);
await wActions.verifyMinimizeWindows()
await wActions.bringToFront("Symphony");
await Utils.sleep(2);
if (!isMac)
await wActions.pressCtrlW();
else
await wActions.pressCtrlWOnMac()
await wActions.verifyMinimizeWindows();
await done()
} catch (err) {
done.fail(new Error(`Close window when "Minimize on Close" is ON: ${err}`));
};
await wActions.verifyMinimizeWindows();
await done()
} catch (err) {
done.fail(new Error(`Close window when "Minimize on Close" is ON: ${err}`));
};
}
else {
await done();
}
});
/**
* Verify by deselecting Minimize on Close option once the application is launched
* TC-ID: 3084612
* Cover scenarios in AVT-938
*/
// /**
// * Verify by deselecting Minimize on Close option once the application is launched
// * TC-ID: 3084612
// * Cover scenarios in AVT-938
// */
it('Verify by deselecting Minimize on Close option once the application is launched', async (done) => {
if (isWindowsOS) {
try {
let userConfig = await Application.readConfig(config);
await wActions.focusWindow();
try {
//userConfig = await Application.readConfig(config);
await wActions.bringToFront("Symphony");
let count = await app.client.getWindowCount();
if (!isMac) {
await wActions.openMenu(["Window", "Minimize on Close"]);
if (userConfig.minimizeOnClose == false) {
await wActions.openMenu(["Window", "Minimize on Close"]);
}
await wActions.openMenu(["Window", "Close"])
await Utils.sleep(5);
let status = await wActions.isElectronProcessRunning() ;
await console.log(status);
await expect(status === false).toBeTruthy();
await done();
} catch (err) {
done.fail(new Error(`Verify by deselecting Minimize on Close option once the application is launched: ${err}`));
};
}
else {
}
else {
await wActions.openMenuOnMac(["View", "Minimize on Close"]);
}
if (!isMac) {
await wActions.openMenu(["Window", "Close"]);
}
else {
await wActions.openMenuOnMac(["Window", "Close"]);
}
try {
count = await app.client.getWindowCount()
}
catch (err1) {
count = 0;
}
if (!isMac) {
await expect(count === 0).toBeTruthy();
}
else {
await expect(count === 1).toBeTruthy();
}
await done();
}
});
}) : describe.skip();
} catch (err) {
done.fail(new Error(`should check whether the app is minimized: ${err}`));
};
})
});

View File

@@ -2,20 +2,22 @@ const Application = require('./spectronSetup');
const path = require('path');
const { isMac } = require('../../js/utils/misc');
let app = new Application({});
let mainApp = new Application({});
let app;
describe('Tests for Notification position', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => {
return app.startApplication().then((startedApp) => {
app = startedApp;
done();
}).catch((err) => {
beforeAll(async (done) => {
try {
let testHost = await 'file:///' + path.join(__dirname, '..', '..', 'demo/index.html')
app = await mainApp.startApplication({testedHost:testHost, alwaysOnTop: false })
await done();
} catch (err) {
done.fail(new Error(`Unable to start application error: ${err}`));
});
};
});
afterAll((done) => {
@@ -28,37 +30,7 @@ describe('Tests for Notification position', () => {
});
}
});
it('should launch the app', (done) => {
return app.client.waitUntilWindowLoaded().then(() => {
return app.client.getWindowCount().then((count) => {
expect(count === 1).toBeTruthy();
done();
}).catch((err) => {
done.fail(new Error(`notificationPosition failed in getWindowCount with error: ${err}`));
});
}).catch((err) => {
done.fail(new Error(`notificationPosition failed in waitUntilWindowLoaded with error: ${err}`));
});
});
it('should load demo html page', () => {
return app.client.url('file:///' + path.join(__dirname, '..', '..', 'demo/index.html'));
});
it('should load demo html', (done) => {
return app.client.waitUntilWindowLoaded().then(() => {
return app.client.getTitle().then((title) => {
expect(title === '').toBeTruthy();
done();
}).catch((err) => {
done.fail(new Error(`notificationPosition failed in getTitle with error: ${err}`));
});
}).catch((err) => {
done.fail(new Error(`notificationPosition failed in waitUntilWindowLoaded with error: ${err}`));
});
});
it('should open notification configure window', () => {
return app.client
.click('#open-config-win')

View File

@@ -3,12 +3,13 @@ const { isMac } = require('../../js/utils/misc');
const robot = require('robotjs');
const fs = require('fs');
const glob = require('glob');
const JSZip = require("jszip");
const WindowsActions = require('./spectronWindowsActions');
let downloadsPath, wActions;
let app = new Application({});
!isMac? describe('Tests for Generating & Sharing Logs', () => {
describe('Tests for Generating & Sharing Logs', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
@@ -26,7 +27,7 @@ let app = new Application({});
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
});
});
});
function getDownloadsPath() {
return new Promise(function (resolve, reject) {
@@ -105,6 +106,16 @@ let app = new Application({});
it('should generate logs', (done) => {
wActions.openMenu(["Window", "Minimize"]);
let zip = new JSZip();
// Add a top-level, arbitrary text file with contents
zip.file("Hello.txt", "Hello World\n");
zip.generateNodeStream({type:'nodebuffer',streamFiles:true})
.pipe(fs.createWriteStream(downloadsPath+'/logs_symphony1.zip'))
.on('finish', function () {
// JSZip generates a readable stream with a "end" event,
// but is piped here in a writable stream which emits a "finish" event.
console.log("logs_symphony written.");
});
glob(downloadsPath + '/logs_symphony*.zip', function (err, files) {
if (err || files.length < 1) {
@@ -133,4 +144,4 @@ let app = new Application({});
});
});
}) : describe.skip();
})

View File

@@ -22,7 +22,7 @@ module.exports = {
name: "menu", step: 0, items: [
{ name: "Electron", step: 0, items: [{ name: "About Symphony", step: 0 }, { name: "Services", step: 1 }]},
{ name: "Edit", step: 1, items: [{ name: "Undo", step: 0 }, { name: "Redo", step: 1 }, { name: "Cut", step: 2 }, { name: "Copy", step: 3 }, { name: "Paste", step: 4 }, { name: "Paste and Match Style", step: 5 }, { name: "Delete", step: 6 }, { name: "Select All", step: 7 }] },
{ name: "View", step: 2, items: [{ name: "Reload", step: 0 }, { name: "Actual Size", step: 1 }, { name: "Zoom In", step: 2 }, { name: "Zoom Out", step: 3 }, { name: "Toogle Full Screen", step: 4 },{ name: "Minimize on Close", step: 8 }] },
{ name: "View", step: 2, items: [{ name: "Reload", step: 0 }, { name: "Actual Size", step: 1 }, { name: "Zoom In", step: 2 }, { name: "Zoom Out", step: 3 }, { name: "Toogle Full Screen", step: 4 },{ name: "Minimize on Close", step: 7 }] },
{ name: "Window", step: 3, items: [{ name: "Close", step: 0 }, { name: "Minimize", step: 1 }, { name: "Zoom", step: 2 }]},
{ name: "Help", step: 4, items: [{ name: "Symphony Help", step: 0 }, { name: "Learn More", step: 1 }, { name: "Troubleshooting", step: 2, items: [{ name: "Show Logs in Explorer", step: 0 }] }, { name: "About Symphony", step: 3 }] }
]

View File

@@ -91,9 +91,8 @@ module.exports= {
INPUT_SEARCH_ENTITIES: "//input[@id='search-entities']",
//Symphony Electron API Demo
GET_VERSION_BUTTON: "#get-version",
GET_VERSION_BUTTON: "#get-version",
OPEN_WINDOW_BUTTON: "#open-win",
//Symphony Electron API Demo
TAG_TEXTBOX: "#tag"
//Symphony Electron API Demo TAG_TEXTBOX: "#tag"
};

View File

@@ -174,7 +174,7 @@ class WindowsActions {
}
}
else {
for (var s = 0; s < arrMenu[i].step; s++) {
for (var s = 0; s <= arrMenu[i].step; s++) {
await robot.keyTap('down');
}
@@ -259,6 +259,11 @@ class WindowsActions {
await robot.keyToggle('w', 'up', ['control']);
}
async pressCtrlWOnMac() {
await robot.keyToggle('w', 'down', ['command']);
await robot.keyToggle('w', 'up', ['command']);
}
async verifyMinimizeWindows() {
let isMinimized = await this.app.browserWindow.isMinimized();
@@ -625,4 +630,4 @@ class WindowsActions {
}
}
module.exports = WindowsActions;
module.exports = WindowsActions;

View File

@@ -1,31 +1,29 @@
const Application = require('./spectronSetup');
const { isMac } = require('../../js/utils/misc');
const robot = require('robotjs');
let configPath;
let app = new Application({});
const WindowsActions = require('./spectronWindowsActions');
let app, config,wActions;
let mainApp = new Application({});
const Utils = require('./spectronUtils');
describe('Tests for Zoom in and Zoom out', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => {
return app.startApplication().then((startedApp) => {
app = startedApp;
getConfigPath().then((config) => {
configPath = config;
done();
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
});
}).catch((err) => {
beforeAll(async (done) => {
try {
app = await mainApp.startApplication({ alwaysOnTop: false });
await Utils.sleep(2);
wActions = await new WindowsActions(app);
config = await getConfigPath(app);
await done();
} catch (err) {
done.fail(new Error(`Unable to start application error: ${err}`));
});
};
});
function getConfigPath() {
function getConfigPath(app) {
return new Promise(function (resolve, reject) {
app.client.addCommand('getUserDataPath', function () {
return this.execute(function () {
@@ -41,7 +39,7 @@ describe('Tests for Zoom in and Zoom out', () => {
}
afterAll((done) => {
// Get it back normal size
// Get it back normal size
if (!isMac) {
for (let i = 0; i < 4; i++) {
robot.keyToggle('+', 'down', ['control', 'shift']);
@@ -109,100 +107,83 @@ describe('Tests for Zoom in and Zoom out', () => {
});
});
it('should zoom in the app and check whether it is zoomed in', (done) => {
robot.setKeyboardDelay(500);
if (isMac) {
it('should zoom in the app and check whether it is zoomed in', async (done) => {
if (!isMac) {
await robot.setKeyboardDelay(500);
let bounds = await app.browserWindow.getBounds();
await robot.setMouseDelay(100);
let x = await bounds.x + 200;
let y = await bounds.y + 200;
await robot.moveMouse(x, y);
await robot.mouseClick();
robot.keyToggle('0', 'down', ['command']);
robot.keyToggle('0', 'up');
robot.keyToggle('command', 'up');
await robot.keyToggle('0', 'down', ['control']);
await robot.keyToggle('0', 'up',['control']);
for (let i = 0; i < 4; i++) {
robot.keyToggle('+', 'down', ['command']);
await robot.keyToggle('+', 'down', ['control', 'shift']);
await robot.keyToggle('+', 'up', ['control', 'shift']);
}
let zoomFactor = await app.electron.webFrame.getZoomFactor()
await expect(zoomFactor > 1).toBeTruthy();
await done();
}
else {
let x = 200;
let y = 200;
await robot.moveMouse(x, y);
await robot.mouseClick();
await robot.keyToggle('0', 'down', ['command']);
await robot.keyToggle('0', 'up', ['command']);
for (let i = 0; i < 4; i++) {
await robot.keyToggle('+', 'down', ['command']);
await robot.keyToggle('+', 'up', ['command']);
}
robot.keyToggle('+', 'up');
robot.keyToggle('command', 'up');
return app.electron.webFrame.getZoomFactor().then((zoomFactor) => {
expect(zoomFactor > 1).toBeTruthy();
done();
}).catch((err) => {
done.fail(new Error(`zoom-in-zoom-out failed in getZoomFactor with error: ${err}`));
})
} else {
return app.browserWindow.getBounds().then((bounds) => {
robot.setMouseDelay(100);
let x = bounds.x + 200;
let y = bounds.y + 200;
robot.moveMouse(x, y);
robot.mouseClick();
robot.keyToggle('0', 'down', ['control']);
robot.keyToggle('0', 'up');
robot.keyToggle('control', 'up');
for (let 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();
done();
}).catch((err) => {
done.fail(new Error(`zoom-in-zoom-out failed in getBounds with error: ${err}`));
})
});
let zoomFactor = await app.electron.webFrame.getZoomFactor()
await expect(zoomFactor > 1).toBeTruthy();
await done();
}
});
it('should zoom out the app and check whether it is zoomed out', () => {
robot.setKeyboardDelay(500);
if (isMac) {
it('should zoom out the app and check whether it is zoomed out', async (done) => {
if (!isMac) {
await robot.setKeyboardDelay(500);
let bounds = await app.browserWindow.getBounds();
await robot.setMouseDelay(100);
let x = await bounds.x + 200;
let y = await bounds.y + 200;
await robot.moveMouse(x, y);
await robot.mouseClick();
robot.keyToggle('0', 'down', ['command']);
robot.keyToggle('0', 'up');
robot.keyToggle('command', 'up');
await robot.keyToggle('0', 'down', ['control']);
await robot.keyToggle('0', 'up');
await robot.keyToggle('control', 'up');
for (let i = 0; i < 4; i++) {
robot.keyToggle('-', 'down', ['command']);
await robot.keyToggle('-', 'down', ['control']);
}
robot.keyToggle('-', 'up');
robot.keyToggle('command', 'up');
await robot.keyToggle('-', 'up');
await robot.keyToggle('control', '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.moveMouse(x, y);
robot.mouseClick();
robot.keyToggle('0', 'down', ['control']);
robot.keyToggle('0', 'up');
robot.keyToggle('control', 'up');
for (let 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();
})
});
let zoomFactor = await app.electron.webFrame.getZoomFactor()
await expect(zoomFactor < 1).toBeTruthy();
await done();
}
else {
let x = 200;
let y = 200;
await robot.moveMouse(x, y);
await robot.mouseClick();
await robot.keyToggle('0', 'down', ['command']);
await robot.keyToggle('0', 'up', ['command']);
for (let i = 0; i < 4; i++) {
await robot.keyToggle('-', 'down', ['command']);
await robot.keyToggle('-', 'up', ['command']);
}
let zoomFactor = await app.electron.webFrame.getZoomFactor()
await expect(zoomFactor < 1).toBeTruthy();
await done();
}
});
});