This commit is contained in:
thaisym1912
2018-08-01 21:50:48 +07:00
committed by Vishwas Shashidhar
parent 75d2e06673
commit 33b3e0840b
7 changed files with 131 additions and 24 deletions

View File

@@ -0,0 +1,69 @@
const Application = require('./spectronSetup');
const WindowsActions = require('./spectronWindowsActions');
const WebActions = require('./spectronWebActions');
const Utils = require('./spectronUtils');
const {isMac} = require('../../js/utils/misc');
let app;
let windowActions;
let webActions;
!isMac ? describe('Tests for always on top with mult-apps are opened', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll(async (done) => {
try {
app = await new Application({}).startApplication({alwaysOnTop: false});
windowActions = await new WindowsActions(app);
webActions = await new WebActions(app);
done();
} catch(err) {
done.fail(new Error(`Unable to start application error: ${err}`));
};
});
afterAll(async (done) => {
try {
await Utils.killProcess("notepad.exe");
await Utils.killProcess("mspaint.exe");
await windowActions.openMenu(["Window","Always on Top"]);
if (app && app.isRunning()) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
await app.stop();
done();
}
} catch (err) {
done.fail(new Error(`Failed at post-condition: ${err}`));
};
});
/**
* Verify Always on Top options when multiple applications are opened
* TC-ID: 2898431
* Cover scenarios in AVT-990
*/
it('Verify Always on Top options when multiple applications are opened', async (done) => {
try {
await windowActions.openMenu(["Window","Always on Top"]);
await webActions.minimizeWindows();
await Utils.openAppInMaximize("C:\\Windows\\notepad.exe");
await Utils.openAppInMaximize("C:\\Windows\\system32\\mspaint.exe");
await windowActions.showWindow();
await windowActions.clickOutsideWindow();
await windowActions.verifyWindowsOnTop();
//Close and open app again, make sure it's always on top
await app.stop();
app = await new Application({}).startApplication();
windowActions = await new WindowsActions(app);
webActions = await new WebActions(app);
await windowActions.clickOutsideWindow();
await windowActions.verifyWindowsOnTop();
done();
} catch(err) {
done.fail(new Error(`Fail to keep Always on Top options when multiple applications are opened with error: ${err}`));
};
});
}): describe.skip();

View File

@@ -2,6 +2,7 @@ const Application = require('./spectronSetup');
const WindowsActions = require('./spectronWindowsActions');
const WebActions = require('./spectronWebActions');
const { isMac } = require('../../js/utils/misc');
const Utils = require('./spectronUtils');
let app;
let windowActions;
@@ -47,7 +48,7 @@ let webActions;
// Size and position of previos session keep after resizing and dragging
await windowActions.setPosition(defaultPosition[0], 20);
await windowActions.setSize(defaultSize[0] - 100, defaultSize[0] - 100);
await windowActions.sleep(1000); // Sleep 1s after resizing
await Utils.sleep(1000); // Sleep 1s after resizing
var previousPosition = await windowActions.getCurrentPosition();
var previousSize = await windowActions.getCurrentSize();
await app.stop();
@@ -59,7 +60,7 @@ let webActions;
// Size and position of previous session keep after maximizing
await webActions.maximizeWindows();
await windowActions.sleep(1000); // Sleep 1s after resizing
await Utils.sleep(1000); // Sleep 1s after resizing
previousSize = await windowActions.getCurrentSize();
await app.stop();
app = await new Application({}).startApplication({defaultSize: false, defaultPosition: false});

View File

@@ -8,6 +8,7 @@ module.exports = {
SEARCH_LIBRARY_PATH_MAC: "node_modules/electron/dist/Electron.app/Contents/library",
SEARCH_LIBRARY_PATH_WIN: "node_modules/electron/dist/library",
TESTED_HOST: "https://cip4-qa.symphony.com/",
MENU: {
"root": {
name: "menu", step: 0, items: [
@@ -18,5 +19,4 @@ module.exports = {
]
}
}
};

View File

@@ -1,9 +1,10 @@
module.exports= {
// Title bar
TITLE_BAR: "#title-bar",
MAXIMIZE_BTN: "#title-bar-maximize-button",
SYM_LOGO: "#logo",
MINIMIZED_BUTTON: "button#title-bar-minimize-button",
MAXIMIZE_BTN: "#title-bar-maximize-button",
MINIMIZE_BTN: "#title-bar-minimize-button",
CLOSE_BUTTON: "button#title-bar-close-button",
MAIN_MENU_ITEM: "#hamburger-menu-button"
};
MAIN_MENU_ITEM: "#hamburger-menu-button",
SYM_LOGO: "#logo"
};

View File

@@ -0,0 +1,19 @@
const childProcess = require('child_process');
class Utils {
static async openAppInMaximize(appPath) {
await childProcess.exec('start /MAX ' + appPath);
}
static async killProcess(processName) {
await childProcess.exec('taskkill /f /t /im ' + processName);
}
static async sleep(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms)
})
}
}
module.exports = Utils;

View File

@@ -16,10 +16,21 @@ class WebActions {
})
}
async minimizeWindowByClick() {
await this.app.client.click(ui.MINIMIZED_BUTTON);
async clickMinimizeButton(){
await this.app.client.waitForVisible(ui.MINIMIZE_BTN, 10000).click(ui.MINIMIZE_BTN);
}
async minimizeWindows() {
await this.clickMinimizeButton();
await this.app.browserWindow.isMinimized().then(function (isMinimized) {
expect(isMinimized).toBeTruthy();
})
}
async openApplicationMenuByClick() {
await this.app.client.click(ui.MAIN_MENU_ITEM);
}
async closeWindowByClick() {
await this.app.client.click(ui.CLOSE_BUTTON);
}
@@ -27,7 +38,6 @@ class WebActions {
async openApplicationMenuByClick() {
await this.app.client.click(ui.MAIN_MENU_ITEM);
}
}
module.exports = WebActions;

View File

@@ -1,13 +1,11 @@
const robot = require('robotjs');
const constants = require('./spectronConstants.js');
const WebActions = require ('./spectronWebActions.js');
const WebActions = require('./spectronWebActions.js')
class WindowsActions {
constructor(app) {
this.app = app;
this.webAction = new WebActions(app);
}
async getCurrentSize() {
@@ -49,9 +47,20 @@ class WindowsActions {
})
}
async sleep(ms){
return new Promise(resolve=>{
setTimeout(resolve,ms)
async showWindow() {
await this.app.browserWindow.show();
}
async clickOutsideWindow() {
await this.setPosition(0, 0);
var currentSize = await this.getCurrentSize();
await robot.moveMouse(currentSize[0] + 20, currentSize[1] + 20);
await robot.mouseClick();
}
async verifyWindowsOnTop() {
await this.app.browserWindow.isAlwaysOnTop().then(function (isAlwaysOnTop) {
expect(isAlwaysOnTop).toBeTruthy();
})
}
@@ -145,8 +154,8 @@ class WindowsActions {
var arrStep = [];
for (var i = 0; i < arrMenu.length; i++) {
var item = await this.menuSearch(constants.MENU.root, arrMenu[i]);
await arrStep.push(item);
}
await arrStep.push(item);
}
await this.actionForMenus(arrStep);
return arrStep;
}
@@ -160,10 +169,9 @@ class WindowsActions {
await robot.moveMouse(x, y);
await robot.mouseClick();
await this.webAction.openApplicationMenuByClick();
await robot.setKeyboardDelay(1000);
await robot.setKeyboardDelay(200);
await robot.keyTap('enter');
for (var i = 0; i < arrMenu.length; i++) {
for (var s = 0; s < arrMenu[i].step; s++) {
await robot.keyTap('down');
}
@@ -174,8 +182,7 @@ class WindowsActions {
}
await robot.keyTap('enter');
});
}
}
}
module.exports = WindowsActions;