Skip to content

Commit

Permalink
feat: viewing publications in full screen mode
Browse files Browse the repository at this point in the history
* viewing publications in full screen mode
  • Loading branch information
ronnymikalsen committed Sep 7, 2017
1 parent 099d8b0 commit fb85e0b
Show file tree
Hide file tree
Showing 44 changed files with 38,978 additions and 3,411 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ before_script:
- chmod +x ./scripts/saucelabs/start-tunnel.sh
- chmod +x ./scripts/saucelabs/wait-tunnel.sh
- chmod +x ./scripts/saucelabs/stop-tunnel.sh
- chmod +x ./integration/scripts/wait-on.sh

script:
- travis_wait 40 ./scripts/ci/build-and-test.sh
2 changes: 1 addition & 1 deletion integration/e2e/features/display_metadata.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mobile @desktop
@android @iphone @desktop
Feature: Displaying Metadata
In order to understand more about the publication
As a user
Expand Down
20 changes: 20 additions & 0 deletions integration/e2e/features/fullscreen.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature: Viewing publications in fullscreen mode
In order to view high quality images in great detail
As a user
I want the viewer to be presented using the entire screen

Background:
Given the viewer is opened with a publication

@android @desktop
Scenario: Fullscreen mode
Given the viewer is in dashboard view
When the user select full screen mode
Then the viewer should be presented using the entire screen

@android @desktop
Scenario: Exit Fullscreen mode
Given the viewer is in full screen mode
When the user select exit full screen mode
Then the viewer should be presented normally

2 changes: 1 addition & 1 deletion integration/e2e/features/pan-on-image.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@android @iphone @desktop
Feature: Pan on image
In order to view high quality images of digitised items in great detail
As a user
Expand All @@ -6,7 +7,6 @@ Feature: Pan on image
Background:
Given the viewer is opened with a publication

@mobile @desktop
Scenario: Panning on image
Given the viewer is in page view
And the view is zoomed in
Expand Down
2 changes: 1 addition & 1 deletion integration/e2e/features/rights-notices.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@mobile @desktop
@android @iphone @desktop
Feature: Rights Notices
In order to ensure that the interests of the owning or publishing institutions are conveyed
As a copyright owner
Expand Down
10 changes: 5 additions & 5 deletions integration/e2e/features/zoom.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ Feature: Zoom
#
# TODO Ignoring this until we find out how to use TouchActions
@Ignore
@mobile
@android @iphone
Scenario: Zooming in on mobile
Given zoom level is home
When the user pinch out
Then the current zoom level has increased

# TODO Ignoring this until we find out how to use TouchActions
@Ignore
@mobile
@android @iphone
Scenario: Zooming out on mobile
Given the view is zoomed in
When the user pinch out
Then the current zoom level has increased

# TODO Ignoring this until we find out how to use TouchActions
@Ignore
@mobile
@android @iphone
Scenario: Zooming out on mobile
Given the view is zoomed in
When the user pinch in
Expand All @@ -39,15 +39,15 @@ Feature: Zoom

# TODO Ignoring this until we find out how to use Actions
@Ignore
@mobile
@android @iphone
Scenario: Auto zooming in on mobile
Given zoom level is home
When the user double taps
Then the current zoom level has increased

# TODO Ignoring this until we find out how to use Actions
@Ignore
@mobile
@android @iphone
Scenario: Auto zooming out on mobile
Given the view is zoomed in
When the user double taps
Expand Down
2 changes: 1 addition & 1 deletion integration/e2e/helpers/cucumber.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineSupportCode } from 'cucumber';

defineSupportCode(({ setDefaultTimeout }) => {
setDefaultTimeout(120000);
setDefaultTimeout(240 * 1000);
});
25 changes: 17 additions & 8 deletions integration/e2e/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ import { browser, ElementFinder, protractor } from 'protractor/built';
import { Capabilities } from 'selenium-webdriver';

const EC = protractor.ExpectedConditions;
const TIMEOUT = 15000;
const RETRY = 100;
export class Utils {
public async waitForElement(el) {
await browser.wait(EC.presenceOf(el), TIMEOUT)
.catch(function (err) {
console.log(err);
return null;
});
return el;

public async waitForElement(el: ElementFinder) {
let found = false;
for (let i = 0; i < RETRY; i++) {
await browser.sleep(10);
const isElementPresent = await browser.isElementPresent(el);
if (isElementPresent) {
found = true;
break;
}
}
if (!found) {
throw Error(el.locator());
} else {
return el;
}
}

async clickElement(el: ElementFinder) {
Expand Down
12 changes: 5 additions & 7 deletions integration/e2e/pages/metadata.po.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { protractor } from 'protractor/built';
import { browser, element, by } from 'protractor';
import { browser, element, ElementFinder, by } from 'protractor';
import { Utils } from '../helpers/utils';

const utils = new Utils();
Expand All @@ -22,16 +22,14 @@ export class MetadataPage {
return metadatas;
}

async getAttribution() {
getAttribution() {
const el = element(by.css('#metadata-attribution'));
await utils.waitForElement(el);
return el;
return utils.waitForElement(el);
}

async getLicense() {
getLicense() {
const el = element(by.css('#metadata-license'));
await utils.waitForElement(el);
return el;
return utils.waitForElement(el);
}
}

Expand Down
37 changes: 25 additions & 12 deletions integration/e2e/pages/viewer.po.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
import { browser, element, by, ElementFinder, By } from 'protractor';
import { Utils } from '../helpers/utils';
import { browser, element, ElementFinder, by, By } from 'protractor';
import { promise, WebElement } from 'selenium-webdriver';
import { Utils } from '../helpers/utils';

const utils = new Utils();
export class ViewerPage {
private thumbStartPosition = {x: 600, y: 300};
private pointerPosition1 = {x: 650, y: 275};
private pointerPosition2 = {x: 750, y: 200};

open() {
return browser.get('');
async open() {
await browser.get('/');
await browser.sleep(5000);
}

async openContentsDialog() {
await element(by.css('#contentsDialogButton')).click();
await utils.waitForElement(element(by.css('.contents-container')));
}

async openSeadragonElement() {
fullscreenButton(): ElementFinder {
return element(by.css('#fullscreenButton'));
}

exitFullscreenButton(): ElementFinder {
return element(by.css('#exitFullscreenButton'));
}

openSeadragonElement() {
const el = element(by.css('.openseadragon-container'));
await utils.waitForElement(el);
return el;
return utils.waitForElement(el);
}

async getAttribution() {
getAttribution() {
const el = element(by.css('#attribution-container > .contents'));
await utils.waitForElement(el);
return el;
return utils.waitForElement(el);
}

isFullscreen(): promise.Promise<boolean> {
return browser.executeScript('return (document.fullscreenElement'
+ ' || document.mozFullScreenElement'
+ ' || document.webkitFullscreenElement'
+ ' || document.msFullscreenElement) != null');
}

getAnimationTime(): promise.Promise<number> {
Expand Down Expand Up @@ -121,8 +135,7 @@ export class ViewerPage {
}

async clickNavigationButton(buttonId: string): Promise<void> {
const button = element(by.id(buttonId));
utils.waitForElement(button);
const button = await utils.waitForElement(element(by.id(buttonId)));
await utils.clickElement(button);
}

Expand Down
2 changes: 1 addition & 1 deletion integration/e2e/step-definitions/content-dialog.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defineSupportCode(function ({ Given, Then }) {

Then(/^descriptive metadata are displayed to the user$/, async () => {
const metadatas = await metadata.getAll();
expect(metadatas.length).to.equal(10);
expect(metadatas.length).to.equal(7);
});

});
32 changes: 32 additions & 0 deletions integration/e2e/step-definitions/fullscreen.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { defineSupportCode } from 'cucumber';
import { expect } from '../helpers/chai-imports';

import { ViewerPage } from './../pages/viewer.po';
import { MetadataPage } from './../pages/metadata.po';

defineSupportCode(function ({ Given, When, Then }) {
const page = new ViewerPage();
const metadata = new MetadataPage();

Given(/^the viewer is in full screen mode$/, async () => {
await page.fullscreenButton().click();
});

When(/^the user select full screen mode$/, async () => {
await page.fullscreenButton().click();
});

When(/^the user select exit full screen mode$/, async () => {
await page.exitFullscreenButton().click();
});

Then(/^the viewer should be presented using the entire screen$/, async () => {
expect(await page.isFullscreen()).to.be.true;
});

Then(/^the viewer should be presented normally$/, async () => {
expect(await page.isFullscreen()).to.be.false;
});

});

6 changes: 3 additions & 3 deletions integration/e2e/step-definitions/rights-notices.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ defineSupportCode(function ({ Given, Then }) {
await viewer.openContentsDialog();
const metadataAttribution = await metadata.getAttribution();

expect(pageAttribution.getText()).to.eventually.equal('This is a test attribution');
expect(metadataAttribution.getText()).to.eventually.equal('This is a test attribution');
expect(await pageAttribution.getText()).to.eql('This is a test attribution');
expect(await metadataAttribution.getText()).to.eql('This is a test attribution');
});

Then(/the license must be shown as hyperlinks$/, async () => {
await viewer.openContentsDialog();
const license = await metadata.getLicense();

expect(license.getText()).to.eventually.equal('https://beta.nb.no/lisens/copyright');
expect(await license.getText()).to.eql('https://beta.nb.no/lisens/cc0');
});

});
4 changes: 4 additions & 0 deletions integration/e2e/step-definitions/viewer-page.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ defineSupportCode(function ({ Given, Then }) {
expect(true).to.be.true;
});

Given(/^the viewer is in dashboard view$/, async () => {
expect(true).to.be.true;
});

});
Loading

0 comments on commit fb85e0b

Please sign in to comment.