From aac37db4a3382b1bc3d49f5025db1039146fbb56 Mon Sep 17 00:00:00 2001 From: thaisym1912 <33540170+thaisym1912@users.noreply.github.com> Date: Fri, 22 Jun 2018 17:58:04 +0700 Subject: [PATCH] AVT-768 Add test "Verify whether the main window can be minimized upto 300px" (#402) --- tests/spectron/alwaysOnTop.spectron.js | 2 +- tests/spectron/resizeWindows.spectron.js | 66 ++++++++++++++++++++++++ tests/spectron/spectronSetup.js | 8 ++- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 tests/spectron/resizeWindows.spectron.js diff --git a/tests/spectron/alwaysOnTop.spectron.js b/tests/spectron/alwaysOnTop.spectron.js index 47ef4dcd..0e09c55e 100644 --- a/tests/spectron/alwaysOnTop.spectron.js +++ b/tests/spectron/alwaysOnTop.spectron.js @@ -12,7 +12,7 @@ describe('Tests for Always on top', () => { jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut(); beforeAll((done) => { - return app.startApplication().then((startedApp) => { + return app.startApplication({alwaysOnTop: false}).then((startedApp) => { app = startedApp; getConfigPath().then((config) => { configPath = config; diff --git a/tests/spectron/resizeWindows.spectron.js b/tests/spectron/resizeWindows.spectron.js new file mode 100644 index 00000000..6e4e0efe --- /dev/null +++ b/tests/spectron/resizeWindows.spectron.js @@ -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}`)); + }) + }); + }); +}); \ No newline at end of file diff --git a/tests/spectron/spectronSetup.js b/tests/spectron/spectronSetup.js index ee0582e8..de651a09 100644 --- a/tests/spectron/spectronSetup.js +++ b/tests/spectron/spectronSetup.js @@ -30,8 +30,14 @@ class App { this.app = new Application(this.options); } - startApplication() { + startApplication(configurations) { return this.app.start().then((app) => { + if (configurations) + { + if (configurations.alwaysOnTop) { + app.browserWindow.setAlwaysOnTop(true); + } + } return app; }).catch((err) => { throw new Error("Unable to start application " + err);