| Index: chrome/test/data/webui/print_preview.js
|
| diff --git a/chrome/test/data/webui/print_preview.js b/chrome/test/data/webui/print_preview.js
|
| index 98b36629273d1349853d3144e488a09e1bca1648..5612030a401913fd12f2b18db0ff138449a40a6c 100644
|
| --- a/chrome/test/data/webui/print_preview.js
|
| +++ b/chrome/test/data/webui/print_preview.js
|
| @@ -2,6 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +var ROOT_PATH = '../../../../';
|
| +
|
| /**
|
| * Test fixture for print preview WebUI testing.
|
| * @constructor
|
| @@ -9,6 +11,7 @@
|
| */
|
| function PrintPreviewWebUITest() {
|
| testing.Test.call(this);
|
| + this.printPreview_ = null;
|
| this.nativeLayer_ = null;
|
| this.initialSettings_ = null;
|
| this.localDestinationInfos_ = null;
|
| @@ -62,18 +65,30 @@ PrintPreviewWebUITest.prototype = {
|
| * @override
|
| */
|
| preLoad: function() {
|
| + window.isTest = true;
|
| window.addEventListener('DOMContentLoaded', function() {
|
| + /**
|
| + * Test version of the native layer.
|
| + * @constructor
|
| + * @extends {settings.TestBrowserProxy}
|
| + */
|
| function NativeLayerStub() {
|
| - cr.EventTarget.call(this);
|
| + settings.TestBrowserProxy.call(this, [ 'getInitialSettings' ]);
|
| + this.eventTarget_ = new cr.EventTarget();
|
| this.printStarted_ = false;
|
| this.generateDraft_ = false;
|
| + this.initialSettings_ = null;
|
| }
|
| NativeLayerStub.prototype = {
|
| - __proto__: cr.EventTarget.prototype,
|
| + __proto__: settings.TestBrowserProxy.prototype,
|
| + getEventTarget: function() { return this.eventTarget_; },
|
| isPrintStarted: function() { return this.printStarted_; },
|
| generateDraft: function() { return this.generateDraft_; },
|
| + getInitialSettings: function() {
|
| + this.methodCalled('getInitialSettings');
|
| + return Promise.resolve(this.initialSettings_);
|
| + },
|
| previewReadyForTest: function() {},
|
| - startGetInitialSettings: function() {},
|
| startGetLocalDestinations: function() {},
|
| startGetPrivetDestinations: function() {},
|
| startGetExtensionDestinations: function() {},
|
| @@ -109,15 +124,42 @@ PrintPreviewWebUITest.prototype = {
|
| }.bind(this));
|
| },
|
|
|
| + extraLibraries: [
|
| + ROOT_PATH + 'ui/webui/resources/js/cr.js',
|
| + ROOT_PATH + 'ui/webui/resources/js/promise_resolver.js',
|
| + ROOT_PATH + 'ui/webui/resources/js/util.js',
|
| + ROOT_PATH + 'chrome/test/data/webui/settings/test_browser_proxy.js',
|
| + ],
|
| +
|
| /**
|
| - * Dispatch the INITIAL_SETTINGS_SET event. This call is NOT async and will
|
| - * happen in the same thread.
|
| + * Creates an instance of print_preview.PrintPreview and initializes the
|
| + * |nativeLayer_| and |previewArea_|.
|
| + */
|
| + createPrintPreview: function() {
|
| + this.printPreview_ = new print_preview.PrintPreview();
|
| + this.nativeLayer_ = this.printPreview_.nativeLayer_;
|
| + this.previewArea_ = this.printPreview_.previewArea_;
|
| + },
|
| +
|
| + /**
|
| + * Initialize print preview with the initial settings currently stored in
|
| + * |this.initialSettings_|. Creates |this.printPreview_| if it does not
|
| + * already exist.
|
| */
|
| setInitialSettings: function() {
|
| - var initialSettingsSetEvent =
|
| - new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
|
| - initialSettingsSetEvent.initialSettings = this.initialSettings_;
|
| - this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
|
| + if (!this.printPreview_) {
|
| + this.printPreview_ = new print_preview.PrintPreview();
|
| + this.nativeLayer_ = this.printPreview_.nativeLayer_;
|
| + this.previewArea_ = this.printPreview_.previewArea_;
|
| + }
|
| + this.nativeLayer_.initialSettings_ = this.initialSettings_;
|
| + this.printPreview_.initialize();
|
| + testing.Test.disableAnimationsAndTransitions();
|
| + // Enable when failure is resolved.
|
| + // AX_TEXT_03: http://crbug.com/559209
|
| + this.accessibilityAuditConfig.ignoreSelectors(
|
| + 'multipleLabelableElementsPerLabel',
|
| + '#page-settings > .right-column > *');
|
| },
|
|
|
| /**
|
| @@ -128,7 +170,7 @@ PrintPreviewWebUITest.prototype = {
|
| var localDestsSetEvent =
|
| new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
|
| localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
|
| - this.nativeLayer_.dispatchEvent(localDestsSetEvent);
|
| + this.nativeLayer_.getEventTarget().dispatchEvent(localDestsSetEvent);
|
| },
|
|
|
| /**
|
| @@ -140,7 +182,7 @@ PrintPreviewWebUITest.prototype = {
|
| var capsSetEvent =
|
| new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
|
| capsSetEvent.settingsInfo = device;
|
| - this.nativeLayer_.dispatchEvent(capsSetEvent);
|
| + this.nativeLayer_.getEventTarget().dispatchEvent(capsSetEvent);
|
| },
|
|
|
| /**
|
| @@ -160,7 +202,7 @@ PrintPreviewWebUITest.prototype = {
|
| dispatchInvalidSettings: function() {
|
| var invalidSettingsEvent =
|
| new Event(print_preview.NativeLayer.EventType.SETTINGS_INVALID);
|
| - this.nativeLayer_.dispatchEvent(invalidSettingsEvent);
|
| + this.nativeLayer_.getEventTarget().dispatchEvent(invalidSettingsEvent);
|
| },
|
|
|
| /**
|
| @@ -210,8 +252,6 @@ PrintPreviewWebUITest.prototype = {
|
| */
|
| setupAdvancedSettingsTest: function(device) {
|
| // Need to disable this since overlay animation will not fully complete.
|
| - this.accessibilityIssuesAreErrors = false;
|
| - this.setInitialSettings();
|
| this.setLocalDestinations();
|
| this.setCapabilities(device);
|
| this.expandMoreSettings();
|
| @@ -245,91 +285,98 @@ PrintPreviewWebUITest.prototype = {
|
| { printerName: 'FooName', deviceName: 'FooDevice' },
|
| { printerName: 'BarName', deviceName: 'BarDevice' }
|
| ];
|
| - this.nativeLayer_ = printPreview.nativeLayer_;
|
| - this.previewArea_ = printPreview.previewArea_;
|
| -
|
| - testing.Test.disableAnimationsAndTransitions();
|
| -
|
| - // Enable when failure is resolved.
|
| - // AX_TEXT_03: http://crbug.com/559209
|
| - this.accessibilityAuditConfig.ignoreSelectors(
|
| - 'multipleLabelableElementsPerLabel',
|
| - '#page-settings > .right-column > *');
|
| - }
|
| + },
|
| };
|
|
|
| // Test some basic assumptions about the print preview WebUI.
|
| TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| -
|
| - var recentList = $('destination-search').querySelector('.recent-list ul');
|
| - var localList = $('destination-search').querySelector('.local-list ul');
|
| - assertNotEquals(null, recentList);
|
| - assertEquals(1, recentList.childNodes.length);
|
| - assertEquals('FooName',
|
| - recentList.childNodes.item(0).querySelector(
|
| - '.destination-list-item-name').textContent);
|
| -
|
| - assertNotEquals(null, localList);
|
| - assertEquals(3, localList.childNodes.length);
|
| - assertEquals('Save as PDF',
|
| - localList.childNodes.item(PrintPreviewWebUITest.PDF_INDEX).
|
| - querySelector('.destination-list-item-name').textContent);
|
| - assertEquals('FooName',
|
| - localList.childNodes.item(PrintPreviewWebUITest.FOO_INDEX).
|
| - querySelector('.destination-list-item-name').textContent);
|
| - assertEquals('BarName',
|
| - localList.childNodes.item(PrintPreviewWebUITest.BAR_INDEX).
|
| - querySelector('.destination-list-item-name').textContent);
|
| -
|
| - testDone();
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + var recentList =
|
| + $('destination-search').querySelector('.recent-list ul');
|
| + var localList =
|
| + $('destination-search').querySelector('.local-list ul');
|
| + assertNotEquals(null, recentList);
|
| + assertEquals(1, recentList.childNodes.length);
|
| + assertEquals('FooName',
|
| + recentList.childNodes.item(0).querySelector(
|
| + '.destination-list-item-name').textContent);
|
| + assertNotEquals(null, localList);
|
| + assertEquals(3, localList.childNodes.length);
|
| + assertEquals('Save as PDF',
|
| + localList.childNodes.item(PrintPreviewWebUITest.PDF_INDEX).
|
| + querySelector('.destination-list-item-name').textContent);
|
| + assertEquals('FooName',
|
| + localList.childNodes.item(PrintPreviewWebUITest.FOO_INDEX).
|
| + querySelector('.destination-list-item-name').textContent);
|
| + assertEquals('BarName',
|
| + localList.childNodes.item(PrintPreviewWebUITest.BAR_INDEX).
|
| + querySelector('.destination-list-item-name').textContent);
|
| + testDone();
|
| + }.bind(this));
|
| });
|
|
|
| // Test that the printer list is structured correctly after calling
|
| // addCloudPrinters with an empty list.
|
| TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| -
|
| - var cloudPrintEnableEvent =
|
| - new Event(print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE);
|
| - cloudPrintEnableEvent.baseCloudPrintUrl = 'cloudprint url';
|
| - this.nativeLayer_.dispatchEvent(cloudPrintEnableEvent);
|
| -
|
| - var searchDoneEvent =
|
| - new Event(cloudprint.CloudPrintInterfaceEventType.SEARCH_DONE);
|
| - searchDoneEvent.printers = [];
|
| - searchDoneEvent.isRecent = true;
|
| - searchDoneEvent.email = 'foo@chromium.org';
|
| - printPreview.cloudPrintInterface_.dispatchEvent(searchDoneEvent);
|
| -
|
| - var recentList = $('destination-search').querySelector('.recent-list ul');
|
| - var localList = $('destination-search').querySelector('.local-list ul');
|
| - var cloudList = $('destination-search').querySelector('.cloud-list ul');
|
| -
|
| - assertNotEquals(null, recentList);
|
| - assertEquals(1, recentList.childNodes.length);
|
| - assertEquals('FooName',
|
| - recentList.childNodes.item(0).querySelector(
|
| - '.destination-list-item-name').textContent);
|
| -
|
| - assertNotEquals(null, localList);
|
| - assertEquals(3, localList.childNodes.length);
|
| - assertEquals('Save as PDF',
|
| - localList.childNodes.item(PrintPreviewWebUITest.PDF_INDEX).
|
| - querySelector('.destination-list-item-name').textContent);
|
| - assertEquals('FooName',
|
| - localList.childNodes.item(PrintPreviewWebUITest.FOO_INDEX).
|
| - querySelector('.destination-list-item-name').textContent);
|
| - assertEquals('BarName',
|
| - localList.childNodes.item(PrintPreviewWebUITest.BAR_INDEX).
|
| - querySelector('.destination-list-item-name').textContent);
|
| -
|
| - assertNotEquals(null, cloudList);
|
| - assertEquals(0, cloudList.childNodes.length);
|
| -
|
| - testDone();
|
| +
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| +
|
| + var cloudPrintEnableEvent =
|
| + new Event(print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE);
|
| + cloudPrintEnableEvent.baseCloudPrintUrl = 'cloudprint url';
|
| + this.nativeLayer_.getEventTarget().dispatchEvent(
|
| + cloudPrintEnableEvent);
|
| +
|
| + var searchDoneEvent =
|
| + new Event(cloudprint.CloudPrintInterfaceEventType.SEARCH_DONE);
|
| + searchDoneEvent.printers = [];
|
| + searchDoneEvent.isRecent = true;
|
| + searchDoneEvent.email = 'foo@chromium.org';
|
| + this.printPreview_.cloudPrintInterface_.dispatchEvent(searchDoneEvent);
|
| +
|
| + var recentList =
|
| + $('destination-search').querySelector('.recent-list ul');
|
| + var localList =
|
| + $('destination-search').querySelector('.local-list ul');
|
| + var cloudList =
|
| + $('destination-search').querySelector('.cloud-list ul');
|
| +
|
| + assertNotEquals(null, recentList);
|
| + assertEquals(1, recentList.childNodes.length);
|
| + assertEquals('FooName',
|
| + recentList.childNodes.item(0).
|
| + querySelector('.destination-list-item-name').
|
| + textContent);
|
| +
|
| + assertNotEquals(null, localList);
|
| + assertEquals(3, localList.childNodes.length);
|
| + assertEquals('Save as PDF',
|
| + localList.childNodes.item(
|
| + PrintPreviewWebUITest.PDF_INDEX).
|
| + querySelector('.destination-list-item-name').
|
| + textContent);
|
| + assertEquals('FooName',
|
| + localList.childNodes.
|
| + item(PrintPreviewWebUITest.FOO_INDEX).
|
| + querySelector('.destination-list-item-name').
|
| + textContent);
|
| + assertEquals('BarName',
|
| + localList.childNodes.
|
| + item(PrintPreviewWebUITest.BAR_INDEX).
|
| + querySelector('.destination-list-item-name').
|
| + textContent);
|
| +
|
| + assertNotEquals(null, cloudList);
|
| + assertEquals(0, cloudList.childNodes.length);
|
| +
|
| + testDone();
|
| + }.bind(this));
|
| });
|
|
|
| /**
|
| @@ -406,9 +453,12 @@ TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination',
|
| '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' +
|
| '"account":"", "capabilities":0, "name":"", "extensionId":"",' +
|
| '"extensionName":""}]}';
|
| - this.setInitialSettings();
|
|
|
| - testDone();
|
| + this.setInitialSettings();
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + testDone();
|
| + });
|
| });
|
|
|
| // Test with multiple destinations
|
| @@ -450,39 +500,42 @@ TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations',
|
| };
|
|
|
| this.initialSettings_.serializedAppStateStr_ = JSON.stringify(appState);
|
| -
|
| this.setInitialSettings();
|
|
|
| - // Set capabilities for the three recently used destinations + 1 more
|
| - this.setCapabilities(getCddTemplate('ID1'));
|
| - this.setCapabilities(getCddTemplate('ID2'));
|
| - this.setCapabilities(getCddTemplate('ID3'));
|
| - this.setCapabilities(getCddTemplate('ID4'));
|
| -
|
| - // The most recently used destination should be the currently selected one.
|
| - // This is ID1.
|
| - assertEquals(
|
| - 'ID1', printPreview.destinationStore_.selectedDestination.id);
|
| -
|
| - // Look through the destinations. ID1, ID2, and ID3 should all be recent.
|
| - var destinations = printPreview.destinationStore_.destinations_;
|
| - var idsFound = [];
|
| -
|
| - for (var i = 0; i < destinations.length; i++) {
|
| - if (!destinations[i])
|
| - continue;
|
| - if (destinations[i].isRecent)
|
| - idsFound.push(destinations[i].id);
|
| - }
|
| -
|
| - // Make sure there were 3 recent destinations and that they are the correct
|
| - // IDs.
|
| - assertEquals(3, idsFound.length);
|
| - assertNotEquals(-1, idsFound.indexOf("ID1"));
|
| - assertNotEquals(-1, idsFound.indexOf("ID2"));
|
| - assertNotEquals(-1, idsFound.indexOf("ID3"));
|
| -
|
| - testDone();
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + // Set capabilities for the three recently used destinations + 1 more
|
| + this.setCapabilities(getCddTemplate('ID1'));
|
| + this.setCapabilities(getCddTemplate('ID2'));
|
| + this.setCapabilities(getCddTemplate('ID3'));
|
| + this.setCapabilities(getCddTemplate('ID4'));
|
| +
|
| + // The most recently used destination should be the currently selected
|
| + // one. This is ID1.
|
| + assertEquals(
|
| + 'ID1', this.printPreview_.destinationStore_.selectedDestination.id);
|
| +
|
| + // Look through the destinations. ID1, ID2, and ID3 should all be
|
| + // recent.
|
| + var destinations = this.printPreview_.destinationStore_.destinations_;
|
| + var idsFound = [];
|
| +
|
| + for (var i = 0; i < destinations.length; i++) {
|
| + if (!destinations[i])
|
| + continue;
|
| + if (destinations[i].isRecent)
|
| + idsFound.push(destinations[i].id);
|
| + }
|
| +
|
| + // Make sure there were 3 recent destinations and that they are the
|
| + // correct IDs.
|
| + assertEquals(3, idsFound.length);
|
| + assertNotEquals(-1, idsFound.indexOf("ID1"));
|
| + assertNotEquals(-1, idsFound.indexOf("ID2"));
|
| + assertNotEquals(-1, idsFound.indexOf("ID3"));
|
| +
|
| + testDone();
|
| + }.bind(this));
|
| });
|
|
|
| TEST_F('PrintPreviewWebUITest',
|
| @@ -491,50 +544,60 @@ TEST_F('PrintPreviewWebUITest',
|
| this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ =
|
| '{"namePattern":".*Bar.*"}';
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
|
|
| - assertEquals(
|
| - 'BarDevice', printPreview.destinationStore_.selectedDestination.id);
|
| + assertEquals(
|
| + 'BarDevice',
|
| + this.printPreview_.destinationStore_.selectedDestination.id);
|
|
|
| - testDone();
|
| + testDone();
|
| + }.bind(this));
|
| });
|
|
|
| TEST_F('PrintPreviewWebUITest', 'TestSystemDialogLinkIsHiddenInAppKioskMode',
|
| function() {
|
| - if (cr.isChromeOS) {
|
| - assertEquals(null, $('system-dialog-link'));
|
| - } else {
|
| + if (!cr.isChromeOS)
|
| this.initialSettings_.isInAppKioskMode_ = true;
|
| - this.setInitialSettings();
|
| -
|
| - checkElementDisplayed($('system-dialog-link'), false);
|
| - }
|
|
|
| - testDone();
|
| + this.setInitialSettings();
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + if (cr.isChromeOS)
|
| + assertEquals(null, $('system-dialog-link'));
|
| + else
|
| + checkElementDisplayed($('system-dialog-link'), false);
|
| + testDone();
|
| + });
|
| });
|
|
|
| // Test that disabled settings hide the disabled sections.
|
| TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() {
|
| + this.createPrintPreview();
|
| checkSectionVisible($('layout-settings'), false);
|
| checkSectionVisible($('color-settings'), false);
|
| checkSectionVisible($('copies-settings'), false);
|
|
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - var device = getCddTemplate("FooDevice");
|
| - device.capabilities.printer.color = {
|
| - "option": [
|
| - {"is_default": true, "type": "STANDARD_COLOR"}
|
| - ]
|
| - };
|
| - delete device.capabilities.printer.copies;
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + var device = getCddTemplate("FooDevice");
|
| + device.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "STANDARD_COLOR"}
|
| + ]
|
| + };
|
| + delete device.capabilities.printer.copies;
|
| + this.setCapabilities(device);
|
|
|
| - checkSectionVisible($('layout-settings'), true);
|
| - checkSectionVisible($('color-settings'), false);
|
| - checkSectionVisible($('copies-settings'), false);
|
| + checkSectionVisible($('layout-settings'), true);
|
| + checkSectionVisible($('color-settings'), false);
|
| + checkSectionVisible($('copies-settings'), false);
|
|
|
| - this.waitForAnimationToEnd('other-options-collapsible');
|
| + this.waitForAnimationToEnd('other-options-collapsible');
|
| + }.bind(this));
|
| });
|
|
|
| // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the
|
| @@ -545,86 +608,92 @@ TEST_F('PrintPreviewWebUITest', 'PrintToPDFSelectedCapabilities', function() {
|
| this.initialSettings_.systemDefaultDestinationId_ = 'Save as PDF';
|
| this.setInitialSettings();
|
|
|
| - var device = {
|
| - printerId: 'Save as PDF',
|
| - capabilities: {
|
| - version: '1.0',
|
| - printer: {
|
| - page_orientation: {
|
| - option: [
|
| - {type: 'AUTO', is_default: true},
|
| - {type: 'PORTRAIT'},
|
| - {type: 'LANDSCAPE'}
|
| - ]
|
| - },
|
| - color: {
|
| - option: [
|
| - {type: 'STANDARD_COLOR', is_default: true}
|
| - ]
|
| - },
|
| - media_size: {
|
| - option: [
|
| - { name: 'NA_LETTER',
|
| - width_microns: 0,
|
| - height_microns: 0,
|
| - is_default: true
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + var device = {
|
| + printerId: 'Save as PDF',
|
| + capabilities: {
|
| + version: '1.0',
|
| + printer: {
|
| + page_orientation: {
|
| + option: [
|
| + {type: 'AUTO', is_default: true},
|
| + {type: 'PORTRAIT'},
|
| + {type: 'LANDSCAPE'}
|
| + ]
|
| + },
|
| + color: {
|
| + option: [
|
| + {type: 'STANDARD_COLOR', is_default: true}
|
| + ]
|
| + },
|
| + media_size: {
|
| + option: [
|
| + { name: 'NA_LETTER',
|
| + width_microns: 0,
|
| + height_microns: 0,
|
| + is_default: true
|
| + }
|
| + ]
|
| + }
|
| }
|
| - ]
|
| + }
|
| + };
|
| + this.setCapabilities(device);
|
| +
|
| + var otherOptions = $('other-options-settings');
|
| + // If rasterization is an option, other options should be visible. If
|
| + // not, there should be no available other options.
|
| + checkSectionVisible(otherOptions, isPrintAsImageEnabled());
|
| + if (isPrintAsImageEnabled()) {
|
| + checkElementDisplayed(
|
| + otherOptions.querySelector('#fit-to-page-container'), false);
|
| + checkElementDisplayed(
|
| + otherOptions.querySelector('#rasterize-container'), true);
|
| }
|
| - }
|
| - }
|
| - };
|
| - this.setCapabilities(device);
|
| -
|
| - var otherOptions = $('other-options-settings');
|
| - // If rasterization is an option, other options should be visible. If not,
|
| - // there should be no available other options.
|
| - checkSectionVisible(otherOptions, isPrintAsImageEnabled());
|
| - if (isPrintAsImageEnabled()) {
|
| - checkElementDisplayed(
|
| - otherOptions.querySelector('#fit-to-page-container'), false);
|
| - checkElementDisplayed(
|
| - otherOptions.querySelector('#rasterize-container'), true);
|
| - }
|
| - checkSectionVisible($('media-size-settings'), false);
|
| - checkSectionVisible($('scaling-settings'), false);
|
| -
|
| - testDone();
|
| + checkSectionVisible($('media-size-settings'), false);
|
| + checkSectionVisible($('scaling-settings'), false);
|
| +
|
| + testDone();
|
| + }.bind(this));
|
| });
|
|
|
| // When the source is 'HTML', we always hide the fit to page option and show
|
| // media size option.
|
| TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| -
|
| - var otherOptions = $('other-options-settings');
|
| - var fitToPage = otherOptions.querySelector('#fit-to-page-container');
|
| - var rasterize;
|
| - if (isPrintAsImageEnabled())
|
| - rasterize = otherOptions.querySelector('#rasterize-container');
|
| - var mediaSize = $('media-size-settings');
|
| - var scalingSettings = $('scaling-settings');
|
| -
|
| - // Check that options are collapsed (section is visible, because duplex is
|
| - // available).
|
| - checkSectionVisible(otherOptions, true);
|
| - checkElementDisplayed(fitToPage, false);
|
| - if (isPrintAsImageEnabled())
|
| - checkElementDisplayed(rasterize, false);
|
| - checkSectionVisible(mediaSize, false);
|
| - checkSectionVisible(scalingSettings, false);
|
| -
|
| - this.expandMoreSettings();
|
| -
|
| - checkElementDisplayed(fitToPage, false);
|
| - if (isPrintAsImageEnabled())
|
| - checkElementDisplayed(rasterize, false);
|
| - checkSectionVisible(mediaSize, true);
|
| - checkSectionVisible(scalingSettings, true);
|
| -
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
| +
|
| + var otherOptions = $('other-options-settings');
|
| + var fitToPage = otherOptions.querySelector('#fit-to-page-container');
|
| + var rasterize;
|
| + if (isPrintAsImageEnabled())
|
| + rasterize = otherOptions.querySelector('#rasterize-container');
|
| + var mediaSize = $('media-size-settings');
|
| + var scalingSettings = $('scaling-settings');
|
| +
|
| + // Check that options are collapsed (section is visible, because duplex
|
| + // is available).
|
| + checkSectionVisible(otherOptions, true);
|
| + checkElementDisplayed(fitToPage, false);
|
| + if (isPrintAsImageEnabled())
|
| + checkElementDisplayed(rasterize, false);
|
| + checkSectionVisible(mediaSize, false);
|
| + checkSectionVisible(scalingSettings, false);
|
| +
|
| + this.expandMoreSettings();
|
| +
|
| + checkElementDisplayed(fitToPage, false);
|
| + if (isPrintAsImageEnabled())
|
| + checkElementDisplayed(rasterize, false);
|
| + checkSectionVisible(mediaSize, true);
|
| + checkSectionVisible(scalingSettings, true);
|
| +
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // When the source is "PDF", depending on the selected destination printer, we
|
| @@ -632,35 +701,38 @@ TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() {
|
| TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() {
|
| this.initialSettings_.isDocumentModifiable_ = false;
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| -
|
| - var otherOptions = $('other-options-settings');
|
| - var scalingSettings = $('scaling-settings');
|
| - var fitToPageContainer =
|
| - otherOptions.querySelector('#fit-to-page-container');
|
| - var rasterizeContainer;
|
| - if (isPrintAsImageEnabled()) {
|
| - rasterizeContainer =
|
| - otherOptions.querySelector('#rasterize-container');
|
| - }
|
| -
|
| - checkSectionVisible(otherOptions, true);
|
| - checkElementDisplayed(fitToPageContainer, true);
|
| - if (isPrintAsImageEnabled())
|
| - checkElementDisplayed(rasterizeContainer, false);
|
| - expectTrue(
|
| - fitToPageContainer.querySelector('.checkbox').checked);
|
| - this.expandMoreSettings();
|
| - if (isPrintAsImageEnabled()) {
|
| - checkElementDisplayed(rasterizeContainer, true);
|
| - expectFalse(
|
| - rasterizeContainer.querySelector('.checkbox').checked);
|
| - }
|
| - checkSectionVisible($('media-size-settings'), true);
|
| - checkSectionVisible(scalingSettings, true);
|
| -
|
| - this.waitForAnimationToEnd('other-options-collapsible');
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
| +
|
| + var otherOptions = $('other-options-settings');
|
| + var scalingSettings = $('scaling-settings');
|
| + var fitToPageContainer =
|
| + otherOptions.querySelector('#fit-to-page-container');
|
| + var rasterizeContainer;
|
| + if (isPrintAsImageEnabled()) {
|
| + rasterizeContainer =
|
| + otherOptions.querySelector('#rasterize-container');
|
| + }
|
| +
|
| + checkSectionVisible(otherOptions, true);
|
| + checkElementDisplayed(fitToPageContainer, true);
|
| + if (isPrintAsImageEnabled())
|
| + checkElementDisplayed(rasterizeContainer, false);
|
| + expectTrue(
|
| + fitToPageContainer.querySelector('.checkbox').checked);
|
| + this.expandMoreSettings();
|
| + if (isPrintAsImageEnabled()) {
|
| + checkElementDisplayed(rasterizeContainer, true);
|
| + expectFalse(
|
| + rasterizeContainer.querySelector('.checkbox').checked);
|
| + }
|
| + checkSectionVisible($('media-size-settings'), true);
|
| + checkSectionVisible(scalingSettings, true);
|
| +
|
| + this.waitForAnimationToEnd('other-options-collapsible');
|
| + }.bind(this));
|
| });
|
|
|
| // When the source is "PDF", depending on the selected destination printer, we
|
| @@ -668,37 +740,40 @@ TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() {
|
| TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() {
|
| this.initialSettings_.isDocumentModifiable_ = false;
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| -
|
| - var otherOptions = $('other-options-settings');
|
| - var scalingSettings = $('scaling-settings');
|
| -
|
| - checkSectionVisible(otherOptions, true);
|
| - var fitToPageContainer =
|
| - otherOptions.querySelector('#fit-to-page-container');
|
| - checkElementDisplayed(fitToPageContainer, true);
|
| - expectTrue(
|
| - fitToPageContainer.querySelector('.checkbox').checked);
|
| - this.expandMoreSettings();
|
| - checkSectionVisible($('media-size-settings'), true);
|
| - checkSectionVisible(scalingSettings, true);
|
| -
|
| - // Change scaling input
|
| - var scalingInput = scalingSettings.querySelector('.user-value');
|
| - expectEquals('100', scalingInput.value);
|
| - scalingInput.stepUp(5);
|
| - expectEquals('105', scalingInput.value);
|
| -
|
| - // Trigger the event
|
| - var enterEvent = document.createEvent('Event');
|
| - enterEvent.initEvent('keydown');
|
| - enterEvent.keyCode = 'Enter';
|
| - scalingInput.dispatchEvent(enterEvent);
|
| - expectFalse(
|
| - fitToPageContainer.querySelector('.checkbox').checked);
|
| -
|
| - this.waitForAnimationToEnd('other-options-collapsible');
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
| +
|
| + var otherOptions = $('other-options-settings');
|
| + var scalingSettings = $('scaling-settings');
|
| +
|
| + checkSectionVisible(otherOptions, true);
|
| + var fitToPageContainer =
|
| + otherOptions.querySelector('#fit-to-page-container');
|
| + checkElementDisplayed(fitToPageContainer, true);
|
| + expectTrue(
|
| + fitToPageContainer.querySelector('.checkbox').checked);
|
| + this.expandMoreSettings();
|
| + checkSectionVisible($('media-size-settings'), true);
|
| + checkSectionVisible(scalingSettings, true);
|
| +
|
| + // Change scaling input
|
| + var scalingInput = scalingSettings.querySelector('.user-value');
|
| + expectEquals('100', scalingInput.value);
|
| + scalingInput.stepUp(5);
|
| + expectEquals('105', scalingInput.value);
|
| +
|
| + // Trigger the event
|
| + var enterEvent = document.createEvent('Event');
|
| + enterEvent.initEvent('keydown');
|
| + enterEvent.keyCode = 'Enter';
|
| + scalingInput.dispatchEvent(enterEvent);
|
| + expectFalse(
|
| + fitToPageContainer.querySelector('.checkbox').checked);
|
| +
|
| + this.waitForAnimationToEnd('other-options-collapsible');
|
| + }.bind(this));
|
| });
|
|
|
| // When the number of copies print preset is set for source 'PDF', we update
|
| @@ -706,25 +781,30 @@ TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() {
|
| TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() {
|
| this.initialSettings_.isDocumentModifiable_ = false;
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| -
|
| - // Indicate that the number of copies print preset is set for source PDF.
|
| - var printPresetOptions = {
|
| - disableScaling: true,
|
| - copies: 2
|
| - };
|
| - var printPresetOptionsEvent = new Event(
|
| - print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS);
|
| - printPresetOptionsEvent.optionsFromDocument = printPresetOptions;
|
| - this.nativeLayer_.dispatchEvent(printPresetOptionsEvent);
|
| -
|
| - checkSectionVisible($('copies-settings'), true);
|
| - expectEquals(
|
| - printPresetOptions.copies,
|
| - parseInt($('copies-settings').querySelector('.user-value').value));
|
| -
|
| - this.waitForAnimationToEnd('other-options-collapsible');
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
| +
|
| + // Indicate that the number of copies print preset is set for source
|
| + // PDF.
|
| + var printPresetOptions = {
|
| + disableScaling: true,
|
| + copies: 2
|
| + };
|
| + var printPresetOptionsEvent = new Event(
|
| + print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS);
|
| + printPresetOptionsEvent.optionsFromDocument = printPresetOptions;
|
| + this.nativeLayer_.getEventTarget().
|
| + dispatchEvent(printPresetOptionsEvent);
|
| +
|
| + checkSectionVisible($('copies-settings'), true);
|
| + expectEquals(
|
| + printPresetOptions.copies,
|
| + parseInt($('copies-settings').querySelector('.user-value').value));
|
| +
|
| + this.waitForAnimationToEnd('other-options-collapsible');
|
| + }.bind(this));
|
| });
|
|
|
| // When the duplex print preset is set for source 'PDF', we update the
|
| @@ -732,102 +812,120 @@ TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() {
|
| TEST_F('PrintPreviewWebUITest', 'CheckDuplexPrintPreset', function() {
|
| this.initialSettings_.isDocumentModifiable_ = false;
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
|
|
| - // Indicate that the duplex print preset is set to "long edge" for source PDF.
|
| - var printPresetOptions = {
|
| - duplex: 1
|
| - };
|
| - var printPresetOptionsEvent = new Event(
|
| - print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS);
|
| - printPresetOptionsEvent.optionsFromDocument = printPresetOptions;
|
| - this.nativeLayer_.dispatchEvent(printPresetOptionsEvent);
|
| -
|
| - var otherOptions = $('other-options-settings');
|
| - checkSectionVisible(otherOptions, true);
|
| - var duplexContainer = otherOptions.querySelector('#duplex-container');
|
| - checkElementDisplayed(duplexContainer, true);
|
| - expectTrue(duplexContainer.querySelector('.checkbox').checked);
|
| -
|
| - this.waitForAnimationToEnd('other-options-collapsible');
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
| +
|
| + // Indicate that the duplex print preset is set to "long edge" for
|
| + // source PDF.
|
| + var printPresetOptions = {
|
| + duplex: 1
|
| + };
|
| + var printPresetOptionsEvent = new Event(
|
| + print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS);
|
| + printPresetOptionsEvent.optionsFromDocument = printPresetOptions;
|
| + this.nativeLayer_.getEventTarget().
|
| + dispatchEvent(printPresetOptionsEvent);
|
| +
|
| + var otherOptions = $('other-options-settings');
|
| + checkSectionVisible(otherOptions, true);
|
| + var duplexContainer = otherOptions.querySelector('#duplex-container');
|
| + checkElementDisplayed(duplexContainer, true);
|
| + expectTrue(duplexContainer.querySelector('.checkbox').checked);
|
| +
|
| + this.waitForAnimationToEnd('other-options-collapsible');
|
| + }.bind(this));
|
| });
|
|
|
| // Make sure that custom margins controls are properly set up.
|
| TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| -
|
| - printPreview.printTicketStore_.marginsType.updateValue(
|
| - print_preview.ticket_items.MarginsTypeValue.CUSTOM);
|
| -
|
| - ['left', 'top', 'right', 'bottom'].forEach(function(margin) {
|
| - var control = $('preview-area').querySelector('.margin-control-' + margin);
|
| - assertNotEquals(null, control);
|
| - var input = control.querySelector('.margin-control-textbox');
|
| - assertTrue(input.hasAttribute('aria-label'));
|
| - assertNotEquals('undefined', input.getAttribute('aria-label'));
|
| - });
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
| +
|
| + this.printPreview_.printTicketStore_.marginsType.updateValue(
|
| + print_preview.ticket_items.MarginsTypeValue.CUSTOM);
|
| +
|
| + ['left', 'top', 'right', 'bottom'].forEach(function(margin) {
|
| + var control =
|
| + $('preview-area').querySelector('.margin-control-' + margin);
|
| + assertNotEquals(null, control);
|
| + var input = control.querySelector('.margin-control-textbox');
|
| + assertTrue(input.hasAttribute('aria-label'));
|
| + assertNotEquals('undefined', input.getAttribute('aria-label'));
|
| + });
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Page layout has zero margins. Hide header and footer option.
|
| TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter',
|
| function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
|
|
| - var otherOptions = $('other-options-settings');
|
| - var headerFooter = otherOptions.querySelector('#header-footer-container');
|
| + var otherOptions = $('other-options-settings');
|
| + var headerFooter =
|
| + otherOptions.querySelector('#header-footer-container');
|
|
|
| - // Check that options are collapsed (section is visible, because duplex is
|
| - // available).
|
| - checkSectionVisible(otherOptions, true);
|
| - checkElementDisplayed(headerFooter, false);
|
| + // Check that options are collapsed (section is visible, because duplex
|
| + // is available).
|
| + checkSectionVisible(otherOptions, true);
|
| + checkElementDisplayed(headerFooter, false);
|
|
|
| - this.expandMoreSettings();
|
| + this.expandMoreSettings();
|
|
|
| - checkElementDisplayed(headerFooter, true);
|
| + checkElementDisplayed(headerFooter, true);
|
|
|
| - printPreview.printTicketStore_.marginsType.updateValue(
|
| - print_preview.ticket_items.MarginsTypeValue.CUSTOM);
|
| - printPreview.printTicketStore_.customMargins.updateValue(
|
| - new print_preview.Margins(0, 0, 0, 0));
|
| + this.printPreview_.printTicketStore_.marginsType.updateValue(
|
| + print_preview.ticket_items.MarginsTypeValue.CUSTOM);
|
| + this.printPreview_.printTicketStore_.customMargins.updateValue(
|
| + new print_preview.Margins(0, 0, 0, 0));
|
|
|
| - checkElementDisplayed(headerFooter, false);
|
| + checkElementDisplayed(headerFooter, false);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Page layout has half-inch margins. Show header and footer option.
|
| TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter',
|
| function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
|
|
| - var otherOptions = $('other-options-settings');
|
| - var headerFooter = otherOptions.querySelector('#header-footer-container');
|
| + var otherOptions = $('other-options-settings');
|
| + var headerFooter =
|
| + otherOptions.querySelector('#header-footer-container');
|
|
|
| - // Check that options are collapsed (section is visible, because duplex is
|
| - // available).
|
| - checkSectionVisible(otherOptions, true);
|
| - checkElementDisplayed(headerFooter, false);
|
| + // Check that options are collapsed (section is visible, because duplex
|
| + // is available).
|
| + checkSectionVisible(otherOptions, true);
|
| + checkElementDisplayed(headerFooter, false);
|
|
|
| - this.expandMoreSettings();
|
| + this.expandMoreSettings();
|
|
|
| - checkElementDisplayed(headerFooter, true);
|
| + checkElementDisplayed(headerFooter, true);
|
|
|
| - printPreview.printTicketStore_.marginsType.updateValue(
|
| - print_preview.ticket_items.MarginsTypeValue.CUSTOM);
|
| - printPreview.printTicketStore_.customMargins.updateValue(
|
| - new print_preview.Margins(36, 36, 36, 36));
|
| + this.printPreview_.printTicketStore_.marginsType.updateValue(
|
| + print_preview.ticket_items.MarginsTypeValue.CUSTOM);
|
| + this.printPreview_.printTicketStore_.customMargins.updateValue(
|
| + new print_preview.Margins(36, 36, 36, 36));
|
|
|
| - checkElementDisplayed(headerFooter, true);
|
| + checkElementDisplayed(headerFooter, true);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Page layout has zero top and bottom margins. Hide header and footer option.
|
| @@ -835,29 +933,33 @@ TEST_F('PrintPreviewWebUITest',
|
| 'ZeroTopAndBottomMarginsHideHeaderFooter',
|
| function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
|
|
| - var otherOptions = $('other-options-settings');
|
| - var headerFooter = otherOptions.querySelector('#header-footer-container');
|
| + var otherOptions = $('other-options-settings');
|
| + var headerFooter =
|
| + otherOptions.querySelector('#header-footer-container');
|
|
|
| - // Check that options are collapsed (section is visible, because duplex is
|
| - // available).
|
| - checkSectionVisible(otherOptions, true);
|
| - checkElementDisplayed(headerFooter, false);
|
| + // Check that options are collapsed (section is visible, because duplex
|
| + // is available).
|
| + checkSectionVisible(otherOptions, true);
|
| + checkElementDisplayed(headerFooter, false);
|
|
|
| - this.expandMoreSettings();
|
| + this.expandMoreSettings();
|
|
|
| - checkElementDisplayed(headerFooter, true);
|
| + checkElementDisplayed(headerFooter, true);
|
|
|
| - printPreview.printTicketStore_.marginsType.updateValue(
|
| - print_preview.ticket_items.MarginsTypeValue.CUSTOM);
|
| - printPreview.printTicketStore_.customMargins.updateValue(
|
| - new print_preview.Margins(0, 36, 0, 36));
|
| + this.printPreview_.printTicketStore_.marginsType.updateValue(
|
| + print_preview.ticket_items.MarginsTypeValue.CUSTOM);
|
| + this.printPreview_.printTicketStore_.customMargins.updateValue(
|
| + new print_preview.Margins(0, 36, 0, 36));
|
|
|
| - checkElementDisplayed(headerFooter, false);
|
| + checkElementDisplayed(headerFooter, false);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Page layout has zero top and half-inch bottom margin. Show header and footer
|
| @@ -866,167 +968,192 @@ TEST_F('PrintPreviewWebUITest',
|
| 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter',
|
| function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
|
|
| - var otherOptions = $('other-options-settings');
|
| - var headerFooter = otherOptions.querySelector('#header-footer-container');
|
| + var otherOptions = $('other-options-settings');
|
| + var headerFooter =
|
| + otherOptions.querySelector('#header-footer-container');
|
|
|
| - // Check that options are collapsed (section is visible, because duplex is
|
| - // available).
|
| - checkSectionVisible(otherOptions, true);
|
| - checkElementDisplayed(headerFooter, false);
|
| + // Check that options are collapsed (section is visible, because duplex
|
| + // is available).
|
| + checkSectionVisible(otherOptions, true);
|
| + checkElementDisplayed(headerFooter, false);
|
|
|
| - this.expandMoreSettings();
|
| + this.expandMoreSettings();
|
|
|
| - checkElementDisplayed(headerFooter, true);
|
| + checkElementDisplayed(headerFooter, true);
|
|
|
| - printPreview.printTicketStore_.marginsType.updateValue(
|
| - print_preview.ticket_items.MarginsTypeValue.CUSTOM);
|
| - printPreview.printTicketStore_.customMargins.updateValue(
|
| - new print_preview.Margins(0, 36, 36, 36));
|
| + this.printPreview_.printTicketStore_.marginsType.updateValue(
|
| + print_preview.ticket_items.MarginsTypeValue.CUSTOM);
|
| + this.printPreview_.printTicketStore_.customMargins.updateValue(
|
| + new print_preview.Margins(0, 36, 36, 36));
|
|
|
| - checkElementDisplayed(headerFooter, true);
|
| + checkElementDisplayed(headerFooter, true);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Check header footer availability with small (label) page size.
|
| TEST_F('PrintPreviewWebUITest', 'SmallPaperSizeHeaderFooter', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - var device = getCddTemplate("FooDevice");
|
| - device.capabilities.printer.media_size = {
|
| - "option": [
|
| - {"name": "SmallLabel", "width_microns": 38100, "height_microns": 12700,
|
| - "is_default": false},
|
| - {"name": "BigLabel", "width_microns": 50800, "height_microns": 76200,
|
| - "is_default": true}
|
| - ]
|
| - };
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + var device = getCddTemplate("FooDevice");
|
| + device.capabilities.printer.media_size = {
|
| + "option": [
|
| + {"name": "SmallLabel", "width_microns": 38100,
|
| + "height_microns": 12700, "is_default": false},
|
| + {"name": "BigLabel", "width_microns": 50800,
|
| + "height_microns": 76200, "is_default": true}
|
| + ]
|
| + };
|
| + this.setCapabilities(device);
|
|
|
| - var otherOptions = $('other-options-settings');
|
| - var headerFooter = otherOptions.querySelector('#header-footer-container');
|
| + var otherOptions = $('other-options-settings');
|
| + var headerFooter =
|
| + otherOptions.querySelector('#header-footer-container');
|
|
|
| - // Check that options are collapsed (section is visible, because duplex is
|
| - // available).
|
| - checkSectionVisible(otherOptions, true);
|
| - checkElementDisplayed(headerFooter, false);
|
| + // Check that options are collapsed (section is visible, because duplex
|
| + // is available).
|
| + checkSectionVisible(otherOptions, true);
|
| + checkElementDisplayed(headerFooter, false);
|
|
|
| - this.expandMoreSettings();
|
| + this.expandMoreSettings();
|
|
|
| - // Big label should have header/footer
|
| - checkElementDisplayed(headerFooter, true);
|
| + // Big label should have header/footer
|
| + checkElementDisplayed(headerFooter, true);
|
|
|
| - // Small label should not
|
| - printPreview.printTicketStore_.mediaSize.updateValue(
|
| - device.capabilities.printer.media_size.option[0]);
|
| - checkElementDisplayed(headerFooter, false);
|
| + // Small label should not
|
| + this.printPreview_.printTicketStore_.mediaSize.updateValue(
|
| + device.capabilities.printer.media_size.option[0]);
|
| + checkElementDisplayed(headerFooter, false);
|
|
|
| - // Oriented in landscape, there should be enough space for header/footer.
|
| - printPreview.printTicketStore_.landscape.updateValue(true);
|
| - checkElementDisplayed(headerFooter, true);
|
| + // Oriented in landscape, there should be enough space for
|
| + // header/footer.
|
| + this.printPreview_.printTicketStore_.landscape.updateValue(true);
|
| + checkElementDisplayed(headerFooter, true);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test that the color settings, one option, standard monochrome.
|
| TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| -
|
| - // Only one option, standard monochrome.
|
| - var device = getCddTemplate("FooDevice");
|
| - device.capabilities.printer.color = {
|
| - "option": [
|
| - {"is_default": true, "type": "STANDARD_MONOCHROME"}
|
| - ]
|
| - };
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| +
|
| + // Only one option, standard monochrome.
|
| + var device = getCddTemplate("FooDevice");
|
| + device.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "STANDARD_MONOCHROME"}
|
| + ]
|
| + };
|
| + this.setCapabilities(device);
|
|
|
| - checkSectionVisible($('color-settings'), false);
|
| + checkSectionVisible($('color-settings'), false);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test that the color settings, one option, custom monochrome.
|
| TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome',
|
| function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| -
|
| - // Only one option, standard monochrome.
|
| - var device = getCddTemplate("FooDevice");
|
| - device.capabilities.printer.color = {
|
| - "option": [
|
| - {"is_default": true, "type": "CUSTOM_MONOCHROME", "vendor_id": "42"}
|
| - ]
|
| - };
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| +
|
| + // Only one option, standard monochrome.
|
| + var device = getCddTemplate("FooDevice");
|
| + device.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "CUSTOM_MONOCHROME",
|
| + "vendor_id": "42"}
|
| + ]
|
| + };
|
| + this.setCapabilities(device);
|
|
|
| - checkSectionVisible($('color-settings'), false);
|
| + checkSectionVisible($('color-settings'), false);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test that the color settings, one option, standard color.
|
| TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| -
|
| - var device = getCddTemplate("FooDevice");
|
| - device.capabilities.printer.color = {
|
| - "option": [
|
| - {"is_default": true, "type": "STANDARD_COLOR"}
|
| - ]
|
| - };
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| +
|
| + var device = getCddTemplate("FooDevice");
|
| + device.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "STANDARD_COLOR"}
|
| + ]
|
| + };
|
| + this.setCapabilities(device);
|
|
|
| - checkSectionVisible($('color-settings'), false);
|
| + checkSectionVisible($('color-settings'), false);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test that the color settings, one option, custom color.
|
| TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| -
|
| - var device = getCddTemplate("FooDevice");
|
| - device.capabilities.printer.color = {
|
| - "option": [
|
| - {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"}
|
| - ]
|
| - };
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| +
|
| + var device = getCddTemplate("FooDevice");
|
| + device.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"}
|
| + ]
|
| + };
|
| + this.setCapabilities(device);
|
|
|
| - checkSectionVisible($('color-settings'), false);
|
| + checkSectionVisible($('color-settings'), false);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test that the color settings, two options, both standard, defaults to color.
|
| TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor',
|
| function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| -
|
| - var device = getCddTemplate("FooDevice");
|
| - device.capabilities.printer.color = {
|
| - "option": [
|
| - {"type": "STANDARD_MONOCHROME"},
|
| - {"is_default": true, "type": "STANDARD_COLOR"}
|
| - ]
|
| - };
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| +
|
| + var device = getCddTemplate("FooDevice");
|
| + device.capabilities.printer.color = {
|
| + "option": [
|
| + {"type": "STANDARD_MONOCHROME"},
|
| + {"is_default": true, "type": "STANDARD_COLOR"}
|
| + ]
|
| + };
|
| + this.setCapabilities(device);
|
|
|
| - checkSectionVisible($('color-settings'), true);
|
| - expectEquals(
|
| - 'color',
|
| - $('color-settings').querySelector('.color-settings-select').value);
|
| + checkSectionVisible($('color-settings'), true);
|
| + expectEquals(
|
| + 'color',
|
| + $('color-settings').querySelector('.color-settings-select').value);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test that the color settings, two options, both standard, defaults to
|
| @@ -1034,184 +1161,213 @@ TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor',
|
| TEST_F('PrintPreviewWebUITest',
|
| 'TestColorSettingsBothStandardDefaultMonochrome', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| -
|
| - var device = getCddTemplate("FooDevice");
|
| - device.capabilities.printer.color = {
|
| - "option": [
|
| - {"is_default": true, "type": "STANDARD_MONOCHROME"},
|
| - {"type": "STANDARD_COLOR"}
|
| - ]
|
| - };
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| +
|
| + var device = getCddTemplate("FooDevice");
|
| + device.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "STANDARD_MONOCHROME"},
|
| + {"type": "STANDARD_COLOR"}
|
| + ]
|
| + };
|
| + this.setCapabilities(device);
|
|
|
| - checkSectionVisible($('color-settings'), true);
|
| - expectEquals(
|
| - 'bw', $('color-settings').querySelector('.color-settings-select').value);
|
| + checkSectionVisible($('color-settings'), true);
|
| + expectEquals(
|
| + 'bw',
|
| + $('color-settings').querySelector('.color-settings-select').value);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test that the color settings, two options, both custom, defaults to color.
|
| TEST_F('PrintPreviewWebUITest',
|
| 'TestColorSettingsBothCustomDefaultColor', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| -
|
| - var device = getCddTemplate("FooDevice");
|
| - device.capabilities.printer.color = {
|
| - "option": [
|
| - {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"},
|
| - {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"}
|
| - ]
|
| - };
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| +
|
| + var device = getCddTemplate("FooDevice");
|
| + device.capabilities.printer.color = {
|
| + "option": [
|
| + {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"},
|
| + {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"}
|
| + ]
|
| + };
|
| + this.setCapabilities(device);
|
|
|
| - checkSectionVisible($('color-settings'), true);
|
| - expectEquals(
|
| - 'color',
|
| - $('color-settings').querySelector('.color-settings-select').value);
|
| + checkSectionVisible($('color-settings'), true);
|
| + expectEquals(
|
| + 'color',
|
| + $('color-settings').querySelector('.color-settings-select').value);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test to verify that duplex settings are set according to the printer
|
| // capabilities.
|
| TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| -
|
| - var otherOptions = $('other-options-settings');
|
| - checkSectionVisible(otherOptions, true);
|
| - duplexContainer = otherOptions.querySelector('#duplex-container');
|
| - expectFalse(duplexContainer.hidden);
|
| - expectFalse(duplexContainer.querySelector('.checkbox').checked);
|
| -
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
| +
|
| + var otherOptions = $('other-options-settings');
|
| + checkSectionVisible(otherOptions, true);
|
| + duplexContainer = otherOptions.querySelector('#duplex-container');
|
| + expectFalse(duplexContainer.hidden);
|
| + expectFalse(duplexContainer.querySelector('.checkbox').checked);
|
| +
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test to verify that duplex settings are set according to the printer
|
| // capabilities.
|
| TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - var device = getCddTemplate("FooDevice");
|
| - delete device.capabilities.printer.duplex;
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + var device = getCddTemplate("FooDevice");
|
| + delete device.capabilities.printer.duplex;
|
| + this.setCapabilities(device);
|
|
|
| - // Check that it is collapsed.
|
| - var otherOptions = $('other-options-settings');
|
| - checkSectionVisible(otherOptions, false);
|
| + // Check that it is collapsed.
|
| + var otherOptions = $('other-options-settings');
|
| + checkSectionVisible(otherOptions, false);
|
|
|
| - this.expandMoreSettings();
|
| + this.expandMoreSettings();
|
|
|
| - // Now it should be visible.
|
| - checkSectionVisible(otherOptions, true);
|
| - expectTrue(otherOptions.querySelector('#duplex-container').hidden);
|
| + // Now it should be visible.
|
| + checkSectionVisible(otherOptions, true);
|
| + expectTrue(otherOptions.querySelector('#duplex-container').hidden);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test that changing the selected printer updates the preview.
|
| TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| -
|
| - var previewGenerator = mock(print_preview.PreviewGenerator);
|
| - printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy();
|
| -
|
| - // The number of settings that can change due to a change in the destination
|
| - // that will therefore dispatch ticket item change events.
|
| - previewGenerator.expects(exactly(9)).requestPreview();
|
| -
|
| - var barDestination =
|
| - printPreview.destinationStore_.destinations().find(function(d) {
|
| - return d.id == 'BarDevice';
|
| - });
|
| -
|
| - printPreview.destinationStore_.selectDestination(barDestination);
|
| -
|
| - var device = getCddTemplate("BarDevice");
|
| - device.capabilities.printer.color = {
|
| - "option": [
|
| - {"is_default": true, "type": "STANDARD_MONOCHROME"}
|
| - ]
|
| - };
|
| - this.setCapabilities(device);
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
| +
|
| + var previewGenerator = mock(print_preview.PreviewGenerator);
|
| + this.printPreview_.previewArea_.previewGenerator_ =
|
| + previewGenerator.proxy();
|
| +
|
| + // The number of settings that can change due to a change in the
|
| + // destination that will therefore dispatch ticket item change events.
|
| + previewGenerator.expects(exactly(9)).requestPreview();
|
| +
|
| + var barDestination =
|
| + this.printPreview_.destinationStore_.destinations().find(
|
| + function(d) {
|
| + return d.id == 'BarDevice';
|
| + });
|
| +
|
| + this.printPreview_.destinationStore_.selectDestination(barDestination);
|
| +
|
| + var device = getCddTemplate("BarDevice");
|
| + device.capabilities.printer.color = {
|
| + "option": [
|
| + {"is_default": true, "type": "STANDARD_MONOCHROME"}
|
| + ]
|
| + };
|
| + this.setCapabilities(device);
|
|
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test that error message is displayed when plugin doesn't exist.
|
| TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() {
|
| - var previewAreaEl = $('preview-area');
|
| + this.setInitialSettings();
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + var previewAreaEl = $('preview-area');
|
|
|
| - var loadingMessageEl =
|
| - previewAreaEl.getElementsByClassName('preview-area-loading-message')[0];
|
| - expectTrue(loadingMessageEl.hidden);
|
| + var loadingMessageEl =
|
| + previewAreaEl.
|
| + getElementsByClassName('preview-area-loading-message')[0];
|
| + expectTrue(loadingMessageEl.hidden);
|
|
|
| - var previewFailedMessageEl = previewAreaEl.getElementsByClassName(
|
| - 'preview-area-preview-failed-message')[0];
|
| - expectTrue(previewFailedMessageEl.hidden);
|
| + var previewFailedMessageEl = previewAreaEl.getElementsByClassName(
|
| + 'preview-area-preview-failed-message')[0];
|
| + expectTrue(previewFailedMessageEl.hidden);
|
|
|
| - var printFailedMessageEl =
|
| - previewAreaEl.getElementsByClassName('preview-area-print-failed')[0];
|
| - expectTrue(printFailedMessageEl.hidden);
|
| + var printFailedMessageEl =
|
| + previewAreaEl.
|
| + getElementsByClassName('preview-area-print-failed')[0];
|
| + expectTrue(printFailedMessageEl.hidden);
|
|
|
| - var customMessageEl =
|
| - previewAreaEl.getElementsByClassName('preview-area-custom-message')[0];
|
| - expectFalse(customMessageEl.hidden);
|
| + var customMessageEl =
|
| + previewAreaEl.
|
| + getElementsByClassName('preview-area-custom-message')[0];
|
| + expectFalse(customMessageEl.hidden);
|
|
|
| - testDone();
|
| + testDone();
|
| + });
|
| });
|
|
|
| // Test custom localized paper names.
|
| TEST_F('PrintPreviewWebUITest', 'TestCustomPaperNames', function() {
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| -
|
| - var customLocalizedMediaName = 'Vendor defined localized media name';
|
| - var customMediaName = 'Vendor defined media name';
|
| -
|
| - var device = getCddTemplate("FooDevice");
|
| - device.capabilities.printer.media_size = {
|
| - option: [
|
| - { name: 'CUSTOM',
|
| - width_microns: 15900,
|
| - height_microns: 79400,
|
| - is_default: true,
|
| - custom_display_name_localized: [
|
| - { locale: navigator.language,
|
| - value: customLocalizedMediaName
|
| - }
|
| - ]
|
| - },
|
| - { name: 'CUSTOM',
|
| - width_microns: 15900,
|
| - height_microns: 79400,
|
| - custom_display_name: customMediaName
|
| - }
|
| - ]
|
| - };
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
|
|
| - this.setCapabilities(device);
|
| + var customLocalizedMediaName = 'Vendor defined localized media name';
|
| + var customMediaName = 'Vendor defined media name';
|
|
|
| - this.expandMoreSettings();
|
| -
|
| - checkSectionVisible($('media-size-settings'), true);
|
| - var mediaSelect = $('media-size-settings').querySelector('.settings-select');
|
| - // Check the default media item.
|
| - expectEquals(
|
| - customLocalizedMediaName,
|
| - mediaSelect.options[mediaSelect.selectedIndex].text);
|
| - // Check the other media item.
|
| - expectEquals(
|
| - customMediaName,
|
| - mediaSelect.options[mediaSelect.selectedIndex == 0 ? 1 : 0].text);
|
| -
|
| - this.waitForAnimationToEnd('more-settings');
|
| + var device = getCddTemplate("FooDevice");
|
| + device.capabilities.printer.media_size = {
|
| + option: [
|
| + { name: 'CUSTOM',
|
| + width_microns: 15900,
|
| + height_microns: 79400,
|
| + is_default: true,
|
| + custom_display_name_localized: [
|
| + { locale: navigator.language,
|
| + value: customLocalizedMediaName
|
| + }
|
| + ]
|
| + },
|
| + { name: 'CUSTOM',
|
| + width_microns: 15900,
|
| + height_microns: 79400,
|
| + custom_display_name: customMediaName
|
| + }
|
| + ]
|
| + };
|
| +
|
| + this.setCapabilities(device);
|
| +
|
| + this.expandMoreSettings();
|
| +
|
| + checkSectionVisible($('media-size-settings'), true);
|
| + var mediaSelect =
|
| + $('media-size-settings').querySelector('.settings-select');
|
| + // Check the default media item.
|
| + expectEquals(
|
| + customLocalizedMediaName,
|
| + mediaSelect.options[mediaSelect.selectedIndex].text);
|
| + // Check the other media item.
|
| + expectEquals(
|
| + customMediaName,
|
| + mediaSelect.options[mediaSelect.selectedIndex == 0 ? 1 : 0].text);
|
| +
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| function getCddTemplateWithAdvancedSettings(printerId) {
|
| @@ -1290,20 +1446,25 @@ function openAdvancedSettings() {
|
| // box).
|
| TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings1Option', function() {
|
| var device = getCddTemplateWithAdvancedSettings("FooDevice");
|
| - this.setupAdvancedSettingsTest(device);
|
| -
|
| - // Open the advanced settings overlay.
|
| - openAdvancedSettings();
|
| -
|
| - // Check that advanced settings close button is now visible,
|
| - // but not the search box (only 1 capability).
|
| - var advancedSettingsCloseButton = $('advanced-settings').
|
| - querySelector('.close-button');
|
| - checkElementDisplayed(advancedSettingsCloseButton, true);
|
| - checkElementDisplayed($('advanced-settings').
|
| - querySelector('.search-box-area'), false);
|
| -
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.accessibilityIssuesAreErrors = false;
|
| + this.setInitialSettings();
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setupAdvancedSettingsTest(device);
|
| +
|
| + // Open the advanced settings overlay.
|
| + openAdvancedSettings();
|
| +
|
| + // Check that advanced settings close button is now visible,
|
| + // but not the search box (only 1 capability).
|
| + var advancedSettingsCloseButton = $('advanced-settings').
|
| + querySelector('.close-button');
|
| + checkElementDisplayed(advancedSettingsCloseButton, true);
|
| + checkElementDisplayed($('advanced-settings').
|
| + querySelector('.search-box-area'), false);
|
| +
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
|
|
| @@ -1323,25 +1484,31 @@ TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings2Options', function() {
|
| ]
|
| }
|
| });
|
| - this.setupAdvancedSettingsTest(device);
|
| -
|
| - // Open the advanced settings overlay.
|
| - openAdvancedSettings();
|
| -
|
| - // Check advanced settings is visible and that the search box now
|
| - // appears.
|
| - var advancedSettingsCloseButton = $('advanced-settings').
|
| - querySelector('.close-button');
|
| - checkElementDisplayed(advancedSettingsCloseButton, true);
|
| - checkElementDisplayed($('advanced-settings').
|
| - querySelector('.search-box-area'), true);
|
| -
|
| - this.waitForAnimationToEnd('more-settings');
|
| + this.accessibilityIssuesAreErrors = false;
|
| + this.setInitialSettings();
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setupAdvancedSettingsTest(device);
|
| +
|
| + // Open the advanced settings overlay.
|
| + openAdvancedSettings();
|
| +
|
| + // Check advanced settings is visible and that the search box now
|
| + // appears.
|
| + var advancedSettingsCloseButton = $('advanced-settings').
|
| + querySelector('.close-button');
|
| + checkElementDisplayed(advancedSettingsCloseButton, true);
|
| + checkElementDisplayed($('advanced-settings').
|
| + querySelector('.search-box-area'), true);
|
| +
|
| + this.waitForAnimationToEnd('more-settings');
|
| + }.bind(this));
|
| });
|
|
|
| // Test that initialization with saved destination only issues one call
|
| // to startPreview.
|
| TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() {
|
| + this.createPrintPreview();
|
| // Load in a bunch of recent destinations with non null capabilities.
|
| var origin = cr.isChromeOS ? 'chrome_os' : 'local';
|
| var initSettings = {
|
| @@ -1360,10 +1527,10 @@ TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() {
|
| this.setCapabilities(getCddTemplate('ID3'));
|
|
|
| // Use a real preview generator.
|
| - printPreview.previewArea_.previewGenerator_ =
|
| - new print_preview.PreviewGenerator(printPreview.destinationStore_,
|
| - printPreview.printTicketStore_, this.nativeLayer_,
|
| - printPreview.documentInfo_);
|
| + this.printPreview_.previewArea_.previewGenerator_ =
|
| + new print_preview.PreviewGenerator(this.printPreview_.destinationStore_,
|
| + this.printPreview_.printTicketStore_, this.nativeLayer_,
|
| + this.printPreview_.documentInfo_);
|
|
|
| // Preview generator starts out with inFlightRequestId_ == -1. The id
|
| // increments by 1 for each startGetPreview call it makes. It should only
|
| @@ -1371,12 +1538,16 @@ TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() {
|
| // crbug.com/666595
|
| expectEquals(
|
| -1,
|
| - printPreview.previewArea_.previewGenerator_.inFlightRequestId_);
|
| + this.printPreview_.previewArea_.previewGenerator_.inFlightRequestId_);
|
| this.setInitialSettings();
|
| - expectEquals(
|
| - 0,
|
| - printPreview.previewArea_.previewGenerator_.inFlightRequestId_);
|
| - testDone();
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + expectEquals(
|
| + 0,
|
| + this.printPreview_.previewArea_.previewGenerator_.
|
| + inFlightRequestId_);
|
| + testDone();
|
| + }.bind(this));
|
| });
|
|
|
| // Test that invalid settings errors disable the print preview and display
|
| @@ -1385,85 +1556,95 @@ TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() {
|
| TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() {
|
| // Setup
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| -
|
| - // Manually enable the print header. This is needed since there is no
|
| - // plugin during test, so it will be set as disabled normally.
|
| - printPreview.printHeader_.isEnabled = true;
|
| -
|
| - // There will be an error message in the preview area since the plugin is
|
| - // not running. However, it should not be the invalid settings error.
|
| - var previewAreaEl = $('preview-area');
|
| - var customMessageEl =
|
| - previewAreaEl.getElementsByClassName('preview-area-custom-message')[0];
|
| - expectFalse(customMessageEl.hidden);
|
| - var expectedMessageStart = 'The selected printer is not available or not ' +
|
| - 'installed correctly.'
|
| - expectFalse(customMessageEl.textContent.includes(expectedMessageStart));
|
| -
|
| - // Verify that the print button is enabled.
|
| - var printHeader = $('print-header');
|
| - var printButton = printHeader.querySelector('button.print');
|
| - checkElementDisplayed(printButton, true);
|
| - expectFalse(printButton.disabled);
|
| -
|
| - // Report invalid settings error.
|
| - this.dispatchInvalidSettings();
|
| -
|
| - // Should be in an error state, print button disabled, invalid custom error
|
| - // message shown.
|
| - expectFalse(customMessageEl.hidden);
|
| - expectTrue(customMessageEl.textContent.includes(expectedMessageStart));
|
| - expectTrue(printButton.disabled);
|
| -
|
| - // Select a new destination
|
| - var barDestination =
|
| - printPreview.destinationStore_.destinations().find(function(d) {
|
| - return d.id == 'BarDevice';
|
| - });
|
| -
|
| - printPreview.destinationStore_.selectDestination(barDestination);
|
| -
|
| - // Dispatch events indicating capabilities were fetched and new preview has
|
| - // loaded.
|
| - this.setCapabilities(getCddTemplate("BarDevice"));
|
| - this.dispatchPreviewDone();
|
| -
|
| - // Has active print button and successfully "prints", indicating recovery
|
| - // from error state.
|
| - expectFalse(printButton.disabled);
|
| - expectFalse(this.hasPrinted());
|
| - printButton.click();
|
| - expectTrue(this.hasPrinted());
|
| - testDone();
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
| +
|
| + // Manually enable the print header. This is needed since there is no
|
| + // plugin during test, so it will be set as disabled normally.
|
| + this.printPreview_.printHeader_.isEnabled = true;
|
| +
|
| + // There will be an error message in the preview area since the plugin
|
| + // is not running. However, it should not be the invalid settings error.
|
| + var previewAreaEl = $('preview-area');
|
| + var customMessageEl =
|
| + previewAreaEl.
|
| + getElementsByClassName('preview-area-custom-message')[0];
|
| + expectFalse(customMessageEl.hidden);
|
| + var expectedMessageStart = 'The selected printer is not available or '
|
| + + 'not installed correctly.'
|
| + expectFalse(customMessageEl.textContent.includes(expectedMessageStart));
|
| +
|
| + // Verify that the print button is enabled.
|
| + var printHeader = $('print-header');
|
| + var printButton = printHeader.querySelector('button.print');
|
| + checkElementDisplayed(printButton, true);
|
| + expectFalse(printButton.disabled);
|
| +
|
| + // Report invalid settings error.
|
| + this.dispatchInvalidSettings();
|
| +
|
| + // Should be in an error state, print button disabled, invalid custom
|
| + // error message shown.
|
| + expectFalse(customMessageEl.hidden);
|
| + expectTrue(customMessageEl.textContent.includes(expectedMessageStart));
|
| + expectTrue(printButton.disabled);
|
| +
|
| + // Select a new destination
|
| + var barDestination =
|
| + this.printPreview_.destinationStore_.destinations().find(
|
| + function(d) {
|
| + return d.id == 'BarDevice';
|
| + });
|
| +
|
| + this.printPreview_.destinationStore_.selectDestination(barDestination);
|
| +
|
| + // Dispatch events indicating capabilities were fetched and new preview
|
| + // has loaded.
|
| + this.setCapabilities(getCddTemplate("BarDevice"));
|
| + this.dispatchPreviewDone();
|
| +
|
| + // Has active print button and successfully "prints", indicating
|
| + // recovery from error state.
|
| + expectFalse(printButton.disabled);
|
| + expectFalse(this.hasPrinted());
|
| + printButton.click();
|
| + expectTrue(this.hasPrinted());
|
| + testDone();
|
| + }.bind(this));
|
| });
|
|
|
| // Test the preview generator to make sure the generate draft parameter is set
|
| // correctly. It should be false if the only change is the page range.
|
| TEST_F('PrintPreviewWebUITest', 'TestGenerateDraft', function() {
|
| + this.createPrintPreview();
|
| +
|
| // Use a real preview generator.
|
| - printPreview.previewArea_.previewGenerator_ =
|
| - new print_preview.PreviewGenerator(printPreview.destinationStore_,
|
| - printPreview.printTicketStore_, this.nativeLayer_,
|
| - printPreview.documentInfo_);
|
| + this.printPreview_.previewArea_.previewGenerator_ =
|
| + new print_preview.PreviewGenerator(this.printPreview_.destinationStore_,
|
| + this.printPreview_.printTicketStore_, this.nativeLayer_,
|
| + this.printPreview_.documentInfo_);
|
|
|
| this.setInitialSettings();
|
| - this.setLocalDestinations();
|
| - this.setCapabilities(getCddTemplate("FooDevice"));
|
| + this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then(
|
| + function() {
|
| + this.setLocalDestinations();
|
| + this.setCapabilities(getCddTemplate("FooDevice"));
|
|
|
| - // The first request should generate draft because there was no previous print
|
| - // preview draft.
|
| - expectTrue(this.generateDraft());
|
| + // The first request should generate draft because there was no
|
| + // previous print preview draft.
|
| + expectTrue(this.generateDraft());
|
|
|
| - // Change the page range - no new draft needed.
|
| - printPreview.printTicketStore_.pageRange.updateValue("2");
|
| - expectFalse(this.generateDraft());
|
| + // Change the page range - no new draft needed.
|
| + this.printPreview_.printTicketStore_.pageRange.updateValue("2");
|
| + expectFalse(this.generateDraft());
|
|
|
| - // Change the margin type - need to regenerate again.
|
| - printPreview.printTicketStore_.marginsType.updateValue(
|
| - print_preview.ticket_items.MarginsTypeValue.NO_MARGINS);
|
| - expectTrue(this.generateDraft());
|
| + // Change the margin type - need to regenerate again.
|
| + this.printPreview_.printTicketStore_.marginsType.updateValue(
|
| + print_preview.ticket_items.MarginsTypeValue.NO_MARGINS);
|
| + expectTrue(this.generateDraft());
|
|
|
| - testDone();
|
| + testDone();
|
| + }.bind(this));
|
| });
|
|
|