[ADF-1412] Viewer enhancements (#2873)

* collection navigation support for Viewer

* code cleanup

* full screen mode support

* keyboard shortcuts

* zooming scale label

* layout fixes

* test fixes

* image toolbar with basic tranformations

* test fixes

* test fixes
This commit is contained in:
Denys Vuika
2018-01-28 23:01:01 +00:00
committed by Eugenio Romano
parent d2d635b94d
commit 08f2cc9236
16 changed files with 358 additions and 45 deletions

View File

@@ -232,7 +232,7 @@ describe('ViewerComponent', () => {
component.sidebarPosition = 'right';
fixture.detectChanges();
let sidebar = element.querySelector('.adf-viewer__sidebar');
expect(getComputedStyle(sidebar).order).toEqual('2');
expect(getComputedStyle(sidebar).order).toEqual('4');
});
it('should display sidebar on the right side as fallback', () => {
@@ -241,11 +241,71 @@ describe('ViewerComponent', () => {
component.sidebarPosition = 'unknown-value';
fixture.detectChanges();
let sidebar = element.querySelector('.adf-viewer__sidebar');
expect(getComputedStyle(sidebar).order).toEqual('2');
expect(getComputedStyle(sidebar).order).toEqual('4');
});
describe('Full Screen Mode', () => {
it('should request only if enabled', () => {
const domElement = jasmine.createSpyObj('el', ['requestFullscreen']);
spyOn(fixture.nativeElement, 'querySelector').and.returnValue(domElement);
component.allowFullScreen = false;
component.enterFullScreen();
expect(domElement.requestFullscreen).not.toHaveBeenCalled();
});
it('should use standard mode', () => {
const domElement = jasmine.createSpyObj('el', ['requestFullscreen']);
spyOn(fixture.nativeElement, 'querySelector').and.returnValue(domElement);
component.enterFullScreen();
expect(domElement.requestFullscreen).toHaveBeenCalled();
});
it('should use webkit prefix', () => {
const domElement = jasmine.createSpyObj('el', ['webkitRequestFullscreen']);
spyOn(fixture.nativeElement, 'querySelector').and.returnValue(domElement);
component.enterFullScreen();
expect(domElement.webkitRequestFullscreen).toHaveBeenCalled();
});
it('should use moz prefix', () => {
const domElement = jasmine.createSpyObj('el', ['mozRequestFullScreen']);
spyOn(fixture.nativeElement, 'querySelector').and.returnValue(domElement);
component.enterFullScreen();
expect(domElement.mozRequestFullScreen).toHaveBeenCalled();
});
it('should use ms prefix', () => {
const domElement = jasmine.createSpyObj('el', ['msRequestFullscreen']);
spyOn(fixture.nativeElement, 'querySelector').and.returnValue(domElement);
component.enterFullScreen();
expect(domElement.msRequestFullscreen).toHaveBeenCalled();
});
});
describe('Toolbar', () => {
it('should render fullscreen button', () => {
component.allowFullScreen = true;
fixture.detectChanges();
expect(element.querySelector('[data-automation-id="toolbar-fullscreen"]')).toBeDefined();
});
it('should not render fullscreen button', () => {
component.allowFullScreen = false;
fixture.detectChanges();
expect(element.querySelector('[data-automation-id="toolbar-fullscreen"]')).toBeNull();
});
it('should render default download button', () => {
component.allowDownload = true;
fixture.detectChanges();
@@ -397,7 +457,7 @@ describe('ViewerComponent', () => {
});
it('should Esc button hide the viewer', () => {
EventMock.keyDown(27);
EventMock.keyUp(27);
fixture.detectChanges();
expect(element.querySelector('.adf-viewer-content')).toBeNull();
});