AVT-768 Add test "Verify whether the main window can be minimized upto 300px" (#402)

This commit is contained in:
thaisym1912
2018-06-22 17:58:04 +07:00
committed by Vishwas Shashidhar
parent 4fa422c19f
commit aac37db4a3
3 changed files with 74 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ describe('Tests for Always on top', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut(); jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => { beforeAll((done) => {
return app.startApplication().then((startedApp) => { return app.startApplication({alwaysOnTop: false}).then((startedApp) => {
app = startedApp; app = startedApp;
getConfigPath().then((config) => { getConfigPath().then((config) => {
configPath = config; configPath = config;

View File

@@ -0,0 +1,66 @@
const Application = require('./spectronSetup');
const robot = require('robotjs');
let app = new Application({});
describe('Tests for Resizing windows', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll((done) => {
return app.startApplication().then((startedApp) => {
app = startedApp;
done();
}).catch((err) => {
done.fail(new Error(`Unable to start application error: ${err}`));
});
});
afterAll((done) => {
if (app && app.isRunning()) {
// resize to default size
app.browserWindow.getBounds().then((bounds) => {
let x = bounds.x - (defaultWidth - bounds.width);
let y = bounds.y - (defaultHeight - bounds.height);
robot.moveMouse(bounds.x, bounds.y);
robot.mouseToggle("down");
robot.dragMouse(x, y);
robot.mouseToggle("up");
})
//close app
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
app.stop().then(() => {
done();
}).catch((err) => {
done();
});
}
});
/**
* Verify whether the main window can be minimized upto 300px
* TC-ID: 3028239
* Cover scenarios in AVT-768
*/
it('should be minimized up to 300px', (done) => {
app.browserWindow.getBounds().then((bounds) => {
defaultHeight = bounds.height;
defaultWidth = bounds.width;
let x = bounds.x + bounds.width;
let y = bounds.y + bounds.height;
robot.setMouseDelay(500);
robot.moveMouse(bounds.x, bounds.y);
robot.mouseToggle("down");
robot.dragMouse(x, y);
robot.mouseToggle("up");
return app.browserWindow.getBounds().then((bounds) => {
const data = {x: bounds.width, y: bounds.height};
expect(data).toEqual({x: 300, y: 300});
done();
}).catch((err) => {
done.fail(new Error(`failed to minimize window to 300 px with error: ${err}`));
})
});
});
});

View File

@@ -30,8 +30,14 @@ class App {
this.app = new Application(this.options); this.app = new Application(this.options);
} }
startApplication() { startApplication(configurations) {
return this.app.start().then((app) => { return this.app.start().then((app) => {
if (configurations)
{
if (configurations.alwaysOnTop) {
app.browserWindow.setAlwaysOnTop(true);
}
}
return app; return app;
}).catch((err) => { }).catch((err) => {
throw new Error("Unable to start application " + err); throw new Error("Unable to start application " + err);