Index: chrome/test/data/webui/print_preview/print_preview.js |
diff --git a/chrome/test/data/webui/print_preview/print_preview.js b/chrome/test/data/webui/print_preview/print_preview.js |
deleted file mode 100644 |
index 8c167375d7b37a829105100754c40358a19ff79d..0000000000000000000000000000000000000000 |
--- a/chrome/test/data/webui/print_preview/print_preview.js |
+++ /dev/null |
@@ -1,736 +0,0 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
-// 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 |
- * @extends {testing.Test} |
- */ |
-function PrintPreviewWebUITest() { |
- testing.Test.call(this); |
- this.printPreview_ = null; |
- this.nativeLayer_ = null; |
- this.initialSettings_ = null; |
- this.localDestinationInfos_ = null; |
- this.previewArea_ = null; |
-} |
- |
-PrintPreviewWebUITest.prototype = { |
- __proto__: testing.Test.prototype, |
- |
- /** |
- * Browse to the sample page, cause print preview & call preLoad(). |
- * @type {string} |
- * @override |
- */ |
- browsePrintPreload: 'print_preview/print_preview_hello_world_test.html', |
- |
- /** @override */ |
- runAccessibilityChecks: true, |
- |
- /** @override */ |
- accessibilityIssuesAreErrors: true, |
- |
- /** @override */ |
- isAsync: true, |
- |
- /** |
- * Stub out low-level functionality like the NativeLayer and |
- * CloudPrintInterface. |
- * @this {PrintPreviewWebUITest} |
- * @override |
- */ |
- preLoad: function() { |
- window.isTest = true; |
- window.addEventListener('DOMContentLoaded', function() { |
- function CloudPrintInterfaceStub() { |
- cr.EventTarget.call(this); |
- } |
- CloudPrintInterfaceStub.prototype = { |
- __proto__: cr.EventTarget.prototype, |
- search: function(isRecent) {} |
- }; |
- var oldCpInterfaceEventType = cloudprint.CloudPrintInterfaceEventType; |
- cloudprint.CloudPrintInterface = CloudPrintInterfaceStub; |
- cloudprint.CloudPrintInterfaceEventType = oldCpInterfaceEventType; |
- |
- print_preview.PreviewArea.prototype.checkPluginCompatibility_ = |
- function() { |
- return false; |
- }; |
- }.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', |
- 'native_layer_stub.js', |
- ], |
- |
- /** |
- * Creates an instance of print_preview.PrintPreview and initializes the |
- * |nativeLayer_| and |previewArea_|. |
- */ |
- createPrintPreview: function() { |
- this.nativeLayer_ = new print_preview.NativeLayerStub(); |
- print_preview.NativeLayer.setInstance(this.nativeLayer_); |
- this.printPreview_ = new print_preview.PrintPreview(); |
- this.previewArea_ = this.printPreview_.getPreviewArea(); |
- }, |
- |
- /** |
- * Initialize print preview with the initial settings currently stored in |
- * |this.initialSettings_|. Creates |this.printPreview_| if it does not |
- * already exist. |
- */ |
- setInitialSettings: function() { |
- if (!this.printPreview_) |
- this.createPrintPreview(); |
- this.nativeLayer_.setInitialSettings(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 > *'); |
- }, |
- |
- /** |
- * Dispatch the LOCAL_DESTINATIONS_SET event. This call is NOT async and will |
- * happen in the same thread. |
- */ |
- setLocalDestinations: function() { |
- var localDestsSetEvent = |
- new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
- localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
- this.nativeLayer_.getEventTarget().dispatchEvent(localDestsSetEvent); |
- }, |
- |
- /** |
- * Dispatch the CAPABILITIES_SET event. This call is NOT async and will |
- * happen in the same thread. |
- * @device - The device whose capabilities should be dispatched. |
- */ |
- setCapabilities: function(device) { |
- var capsSetEvent = |
- new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
- capsSetEvent.settingsInfo = device; |
- this.nativeLayer_.getEventTarget().dispatchEvent(capsSetEvent); |
- }, |
- |
- /** |
- * Dispatch the PREVIEW_GENERATION_DONE event. This call is NOT async and |
- * will happen in the same thread. |
- */ |
- dispatchPreviewDone: function() { |
- var previewDoneEvent = |
- new Event(print_preview.PreviewArea.EventType.PREVIEW_GENERATION_DONE); |
- this.previewArea_.dispatchEvent(previewDoneEvent); |
- }, |
- |
- /** |
- * Dispatch the SETTINGS_INVALID event. This call is NOT async and will |
- * happen in the same thread. |
- */ |
- dispatchInvalidSettings: function() { |
- var invalidSettingsEvent = |
- new Event(print_preview.NativeLayer.EventType.SETTINGS_INVALID); |
- this.nativeLayer_.getEventTarget().dispatchEvent(invalidSettingsEvent); |
- }, |
- |
- /** |
- * @return {boolean} Whether the UI has "printed" or not. (called startPrint |
- * on the native layer) |
- */ |
- hasPrinted: function() { |
- return this.nativeLayer_.isPrintStarted(); |
- }, |
- |
- /** |
- * @return {boolean} Whether the UI is "generating draft" in the most recent |
- * preview. (checking the result of the startGetPreview call in the native |
- * layer) |
- */ |
- generateDraft: function() { |
- return this.nativeLayer_.generateDraft(); |
- }, |
- |
- /** |
- * Even though animation duration and delay is set to zero, it is necessary to |
- * wait until the animation has finished. |
- */ |
- waitForAnimationToEnd: function(elementId) { |
- // add a listener for the animation end event |
- document.addEventListener('animationend', function f(e) { |
- if (e.target.id == elementId) { |
- document.removeEventListener(f, 'animationend'); |
- testDone(); |
- } |
- }); |
- }, |
- |
- /** |
- * Expand the 'More Settings' div to expose all options. |
- */ |
- expandMoreSettings: function() { |
- var moreSettings = $('more-settings'); |
- checkSectionVisible(moreSettings, true); |
- moreSettings.click(); |
- }, |
- |
- /** |
- * Repeated setup steps for the advanced settings tests. |
- * Disables accessiblity errors, sets initial settings, and verifies |
- * advanced options section is visible after expanding more settings. |
- */ |
- setupAdvancedSettingsTest: function(device) { |
- // Need to disable this since overlay animation will not fully complete. |
- this.setLocalDestinations(); |
- this.setCapabilities(device); |
- this.expandMoreSettings(); |
- |
- // Check that the advanced options settings section is visible. |
- checkSectionVisible($('advanced-options-settings'), true); |
- }, |
- |
- /** |
- * @this {PrintPreviewWebUITest} |
- * @override |
- */ |
- setUp: function() { |
- testing.Test.prototype.setUp.call(this); |
- Mock4JS.clearMocksToVerify(); |
- |
- this.initialSettings_ = new print_preview.NativeInitialSettings( |
- false /*isInKioskAutoPrintMode*/, |
- false /*isInAppKioskMode*/, |
- ',' /*thousandsDelimeter*/, |
- '.' /*decimalDelimeter*/, |
- 1 /*unitType*/, |
- true /*isDocumentModifiable*/, |
- 'title' /*documentTitle*/, |
- true /*documentHasSelection*/, |
- false /*selectionOnly*/, |
- 'FooDevice' /*systemDefaultDestinationId*/, |
- null /*serializedAppStateStr*/, |
- null /*serializedDefaultDestinationSelectionRulesStr*/); |
- this.localDestinationInfos_ = [ |
- { printerName: 'FooName', deviceName: 'FooDevice' }, |
- { printerName: 'BarName', deviceName: 'BarDevice' } |
- ]; |
- }, |
-}; |
- |
- |
-/** |
- * Verify that |section| visibility matches |visible|. |
- * @param {HTMLDivElement} section The section to check. |
- * @param {boolean} visible The expected state of visibility. |
- */ |
-function checkSectionVisible(section, visible) { |
- assertNotEquals(null, section); |
- expectEquals( |
- visible, section.classList.contains('visible'), 'section=' + section.id); |
-} |
- |
-function checkElementDisplayed(el, isDisplayed) { |
- assertNotEquals(null, el); |
- expectEquals(isDisplayed, |
- !el.hidden, |
- 'element="' + el.id + '" of class "' + el.classList + '"'); |
-} |
- |
-function getCddTemplate(printerId) { |
- return { |
- printerId: printerId, |
- capabilities: { |
- version: '1.0', |
- printer: { |
- supported_content_type: [{content_type: 'application/pdf'}], |
- collate: {}, |
- color: { |
- option: [ |
- {type: 'STANDARD_COLOR', is_default: true}, |
- {type: 'STANDARD_MONOCHROME'} |
- ] |
- }, |
- copies: {}, |
- duplex: { |
- option: [ |
- {type: 'NO_DUPLEX', is_default: true}, |
- {type: 'LONG_EDGE'}, |
- {type: 'SHORT_EDGE'} |
- ] |
- }, |
- page_orientation: { |
- option: [ |
- {type: 'PORTRAIT', is_default: true}, |
- {type: 'LANDSCAPE'}, |
- {type: 'AUTO'} |
- ] |
- }, |
- media_size: { |
- option: [ |
- { name: 'NA_LETTER', |
- width_microns: 215900, |
- height_microns: 279400, |
- is_default: true |
- } |
- ] |
- } |
- } |
- } |
- }; |
-} |
- |
-function isPrintAsImageEnabled() { |
- // Should be enabled by default on non Windows/Mac |
- return (!cr.isWindows && !cr.isMac && |
- loadTimeData.getBoolean('printPdfAsImageEnabled')); |
-} |
- |
-// Test to verify that duplex settings are set according to the printer |
-// capabilities. |
-TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { |
- this.setInitialSettings(); |
- this.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.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); |
- |
- this.expandMoreSettings(); |
- |
- // Now it should be visible. |
- checkSectionVisible(otherOptions, true); |
- expectTrue(otherOptions.querySelector('#duplex-container').hidden); |
- |
- this.waitForAnimationToEnd('more-settings'); |
- }.bind(this)); |
-}); |
- |
-// Test that changing the selected printer updates the preview. |
-TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { |
- this.setInitialSettings(); |
- this.nativeLayer_.whenCalled('getInitialSettings').then( |
- function() { |
- this.setLocalDestinations(); |
- this.setCapabilities(getCddTemplate("FooDevice")); |
- |
- var previewGenerator = mock(print_preview.PreviewGenerator); |
- this.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'); |
- }.bind(this)); |
-}); |
- |
-// Test that error message is displayed when plugin doesn't exist. |
-TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() { |
- this.setInitialSettings(); |
- this.nativeLayer_.whenCalled('getInitialSettings').then( |
- function() { |
- var previewAreaEl = $('preview-area'); |
- |
- 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 printFailedMessageEl = |
- previewAreaEl. |
- getElementsByClassName('preview-area-print-failed')[0]; |
- expectTrue(printFailedMessageEl.hidden); |
- |
- var customMessageEl = |
- previewAreaEl. |
- getElementsByClassName('preview-area-custom-message')[0]; |
- expectFalse(customMessageEl.hidden); |
- |
- testDone(); |
- }); |
-}); |
- |
-// Test custom localized paper names. |
-TEST_F('PrintPreviewWebUITest', 'TestCustomPaperNames', function() { |
- this.setInitialSettings(); |
- this.nativeLayer_.whenCalled('getInitialSettings').then( |
- function() { |
- 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.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) { |
- return { |
- printerId: printerId, |
- capabilities: { |
- version: '1.0', |
- printer: { |
- supported_content_type: [{content_type: 'application/pdf'}], |
- vendor_capability: |
- [ |
- {display_name: 'Print Area', |
- id: 'Print Area', |
- type: 'SELECT', |
- select_cap: { |
- option: [ |
- {display_name: 'A4', value: 4, is_default: true}, |
- {display_name: 'A6', value: 6}, |
- {display_name: 'A7', value: 7} |
- ] |
- } |
- } |
- ], |
- collate: {}, |
- color: { |
- option: [ |
- {type: 'STANDARD_COLOR', is_default: true}, |
- {type: 'STANDARD_MONOCHROME'} |
- ] |
- }, |
- copies: {}, |
- duplex: { |
- option: [ |
- {type: 'NO_DUPLEX', is_default: true}, |
- {type: 'LONG_EDGE'}, |
- {type: 'SHORT_EDGE'} |
- ] |
- }, |
- page_orientation: { |
- option: [ |
- {type: 'PORTRAIT', is_default: true}, |
- {type: 'LANDSCAPE'}, |
- {type: 'AUTO'} |
- ] |
- }, |
- media_size: { |
- option: [ |
- { name: 'NA_LETTER', |
- width_microns: 215900, |
- height_microns: 279400, |
- is_default: true |
- } |
- ] |
- }, |
- } |
- } |
- }; |
-} |
- |
-// Simulates a click of the advanced options settings button to bring up the |
-// advanced settings overlay. |
-function openAdvancedSettings() { |
- // Check for button and click to view advanced settings section. |
- var advancedOptionsSettingsButton = |
- $('advanced-options-settings'). |
- querySelector('.advanced-options-settings-button'); |
- checkElementDisplayed(advancedOptionsSettingsButton, true); |
- // Button is disabled during testing due to test version of |
- // testPluginCompatibility() being set to always return false. Enable button |
- // to send click event. |
- advancedOptionsSettingsButton.disabled = false; |
- advancedOptionsSettingsButton.click(); |
-} |
- |
-// Test advanced settings with 1 capability (should not display settings search |
-// box). |
-TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings1Option', function() { |
- var device = getCddTemplateWithAdvancedSettings("FooDevice"); |
- this.accessibilityIssuesAreErrors = false; |
- this.setInitialSettings(); |
- this.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)); |
-}); |
- |
- |
-// Test advanced settings with 2 capabilities (should have settings search box). |
-TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings2Options', function() { |
- var device = getCddTemplateWithAdvancedSettings("FooDevice"); |
- // Add new capability. |
- device.capabilities.printer.vendor_capability.push({ |
- display_name: 'Paper Type', |
- id: 'Paper Type', |
- type: 'SELECT', |
- select_cap: { |
- option: [ |
- {display_name: 'Standard', value: 0, is_default: true}, |
- {display_name: 'Recycled', value: 1}, |
- {display_name: 'Special', value: 2} |
- ] |
- } |
- }); |
- this.accessibilityIssuesAreErrors = false; |
- this.setInitialSettings(); |
- this.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 = { |
- version: 2, |
- recentDestinations: [1, 2, 3].map(function(i) { |
- return { |
- id: 'ID' + i, origin: origin, account: '', |
- capabilities: getCddTemplate('ID' + i), name: '', |
- extensionId: '', extensionName: '' |
- }; |
- }), |
- }; |
- this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings); |
- this.setCapabilities(getCddTemplate('ID1')); |
- this.setCapabilities(getCddTemplate('ID2')); |
- this.setCapabilities(getCddTemplate('ID3')); |
- |
- // Use a real preview generator. |
- this.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 |
- // make one such call during initialization or there will be a race; see |
- // crbug.com/666595 |
- expectEquals( |
- -1, |
- this.previewArea_.previewGenerator_.inFlightRequestId_); |
- this.setInitialSettings(); |
- this.nativeLayer_.whenCalled('getInitialSettings').then( |
- function() { |
- expectEquals( |
- 0, |
- this.previewArea_.previewGenerator_. |
- inFlightRequestId_); |
- testDone(); |
- }.bind(this)); |
-}); |
- |
-// Test that invalid settings errors disable the print preview and display |
-// an error and that the preview dialog can be recovered by selecting a |
-// new destination. |
-TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() { |
- // Setup |
- this.setInitialSettings(); |
- this.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. |
- this.previewArea_.previewGenerator_ = |
- new print_preview.PreviewGenerator(this.printPreview_.destinationStore_, |
- this.printPreview_.printTicketStore_, this.nativeLayer_, |
- this.printPreview_.documentInfo_); |
- |
- this.setInitialSettings(); |
- this.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()); |
- |
- // 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. |
- this.printPreview_.printTicketStore_.marginsType.updateValue( |
- print_preview.ticket_items.MarginsTypeValue.NO_MARGINS); |
- expectTrue(this.generateDraft()); |
- |
- testDone(); |
- }.bind(this)); |
-}); |