Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 GEN('#include "base/feature_list.h"'); | 5 GEN('#include "base/feature_list.h"'); |
| 6 GEN('#include "chrome/common/chrome_features.h"'); | 6 GEN('#include "chrome/common/chrome_features.h"'); |
| 7 | 7 |
| 8 var ROOT_PATH = '../../../../'; | |
| 9 /* | |
| 10 * Global print preview instance. | |
| 11 * @type {print_preview.PrintPreview} | |
| 12 */ | |
| 13 var printPreview = null; | |
|
dpapad
2017/05/18 19:11:26
Can this be defined inside PrintPreviewWebUITest c
rbpotter
2017/05/18 23:40:57
Done.
| |
| 14 | |
| 8 /** | 15 /** |
| 9 * Test fixture for print preview WebUI testing. | 16 * Test fixture for print preview WebUI testing. |
| 10 * @constructor | 17 * @constructor |
| 11 * @extends {testing.Test} | 18 * @extends {testing.Test} |
| 12 */ | 19 */ |
| 13 function PrintPreviewWebUITest() { | 20 function PrintPreviewWebUITest() { |
| 14 testing.Test.call(this); | 21 testing.Test.call(this); |
| 15 this.nativeLayer_ = null; | 22 this.nativeLayer_ = null; |
| 16 this.initialSettings_ = null; | 23 this.initialSettings_ = null; |
| 17 this.localDestinationInfos_ = null; | 24 this.localDestinationInfos_ = null; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 GEN('#endif'); | 80 GEN('#endif'); |
| 74 }, | 81 }, |
| 75 | 82 |
| 76 /** | 83 /** |
| 77 * Stub out low-level functionality like the NativeLayer and | 84 * Stub out low-level functionality like the NativeLayer and |
| 78 * CloudPrintInterface. | 85 * CloudPrintInterface. |
| 79 * @this {PrintPreviewWebUITest} | 86 * @this {PrintPreviewWebUITest} |
| 80 * @override | 87 * @override |
| 81 */ | 88 */ |
| 82 preLoad: function() { | 89 preLoad: function() { |
| 90 window.isTest = true; | |
| 83 window.addEventListener('DOMContentLoaded', function() { | 91 window.addEventListener('DOMContentLoaded', function() { |
| 92 /** | |
| 93 * Test version of the native layer. | |
| 94 * @constructor | |
| 95 * @extends {settings.TestBrowserProxy} | |
| 96 */ | |
| 84 function NativeLayerStub() { | 97 function NativeLayerStub() { |
| 85 cr.EventTarget.call(this); | 98 settings.TestBrowserProxy.call(this, [ 'getInitialSettings' ]); |
| 99 this.eventTarget_ = new cr.EventTarget(); | |
| 86 this.printStarted_ = false; | 100 this.printStarted_ = false; |
| 87 this.generateDraft_ = false; | 101 this.generateDraft_ = false; |
| 102 this.initialSettings_ = null; | |
| 88 } | 103 } |
| 89 NativeLayerStub.prototype = { | 104 NativeLayerStub.prototype = { |
| 90 __proto__: cr.EventTarget.prototype, | 105 __proto__: settings.TestBrowserProxy.prototype, |
| 106 getEventTarget: function() { return this.eventTarget_; }, | |
| 91 isPrintStarted: function() { return this.printStarted_; }, | 107 isPrintStarted: function() { return this.printStarted_; }, |
| 92 generateDraft: function() { return this.generateDraft_; }, | 108 generateDraft: function() { return this.generateDraft_; }, |
| 109 getInitialSettings: function() { | |
| 110 this.methodCalled('getInitialSettings'); | |
| 111 return Promise.resolve(this.initialSettings_); | |
| 112 }, | |
| 93 previewReadyForTest: function() {}, | 113 previewReadyForTest: function() {}, |
| 94 startGetInitialSettings: function() {}, | |
| 95 startGetLocalDestinations: function() {}, | 114 startGetLocalDestinations: function() {}, |
| 96 startGetPrivetDestinations: function() {}, | 115 startGetPrivetDestinations: function() {}, |
| 97 startGetExtensionDestinations: function() {}, | 116 startGetExtensionDestinations: function() {}, |
| 98 startGetLocalDestinationCapabilities: function(destinationId) {}, | 117 startGetLocalDestinationCapabilities: function(destinationId) {}, |
| 99 startGetPreview: function(destination, printTicketStore, documentInfo, | 118 startGetPreview: function(destination, printTicketStore, documentInfo, |
| 100 generateDraft, requestId) { | 119 generateDraft, requestId) { |
| 101 this.generateDraft_ = generateDraft; | 120 this.generateDraft_ = generateDraft; |
| 102 }, | 121 }, |
| 103 startHideDialog: function () {}, | 122 startHideDialog: function () {}, |
| 104 startPrint: function () { this.printStarted_ = true; } | 123 startPrint: function () { this.printStarted_ = true; } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 120 cloudprint.CloudPrintInterface = CloudPrintInterfaceStub; | 139 cloudprint.CloudPrintInterface = CloudPrintInterfaceStub; |
| 121 cloudprint.CloudPrintInterfaceEventType = oldCpInterfaceEventType; | 140 cloudprint.CloudPrintInterfaceEventType = oldCpInterfaceEventType; |
| 122 | 141 |
| 123 print_preview.PreviewArea.prototype.checkPluginCompatibility_ = | 142 print_preview.PreviewArea.prototype.checkPluginCompatibility_ = |
| 124 function() { | 143 function() { |
| 125 return false; | 144 return false; |
| 126 }; | 145 }; |
| 127 }.bind(this)); | 146 }.bind(this)); |
| 128 }, | 147 }, |
| 129 | 148 |
| 149 extraLibraries: [ | |
| 150 ROOT_PATH + 'ui/webui/resources/js/cr.js', | |
|
dpapad
2017/05/18 19:11:26
Nit, within array the indentation should be 2 inst
rbpotter
2017/05/18 23:40:57
Done.
| |
| 151 ROOT_PATH + 'ui/webui/resources/js/promise_resolver.js', | |
| 152 ROOT_PATH + 'ui/webui/resources/js/util.js', | |
| 153 ROOT_PATH + 'chrome/test/data/webui/settings/test_browser_proxy.js', | |
| 154 ], | |
| 155 | |
| 130 /** | 156 /** |
| 131 * Dispatch the INITIAL_SETTINGS_SET event. This call is NOT async and will | 157 * Creates an instance of print_preview.PrintPreview and initializes the |
| 132 * happen in the same thread. | 158 * |nativeLayer_| and |previewArea_|. |
| 133 */ | 159 */ |
| 134 setInitialSettings: function() { | 160 createPrintPreview: function() { |
| 135 var initialSettingsSetEvent = | 161 printPreview = new print_preview.PrintPreview(); |
|
dpapad
2017/05/18 19:11:26
It does not have to be in this CL, but eventually
rbpotter
2017/05/18 23:40:57
Will do this in a follow-up CL. Do we want to chan
dpapad
2017/05/19 00:10:18
For previewGenerator_, printTicketStore_ and desti
| |
| 136 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 162 this.nativeLayer_ = printPreview.nativeLayer_; |
| 137 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 163 this.previewArea_ = printPreview.previewArea_; |
| 138 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 139 }, | 164 }, |
| 140 | 165 |
| 141 /** | 166 /** |
| 167 * Initialize print preview with the initial settings currently stored in | |
| 168 * |this.initialSettings_|. Creates printPreview if it does not already | |
| 169 * exist. | |
| 170 */ | |
| 171 setInitialSettings: function() { | |
| 172 if (!printPreview) { | |
| 173 printPreview = new print_preview.PrintPreview(); | |
| 174 this.nativeLayer_ = printPreview.nativeLayer_; | |
| 175 this.previewArea_ = printPreview.previewArea_; | |
| 176 } | |
| 177 this.nativeLayer_.initialSettings_ = this.initialSettings_; | |
| 178 printPreview.initialize(); | |
| 179 testing.Test.disableAnimationsAndTransitions(); | |
| 180 // Enable when failure is resolved. | |
| 181 // AX_TEXT_03: http://crbug.com/559209 | |
| 182 this.accessibilityAuditConfig.ignoreSelectors( | |
| 183 'multipleLabelableElementsPerLabel', | |
| 184 '#page-settings > .right-column > *'); | |
| 185 }, | |
| 186 | |
| 187 /** | |
| 142 * Dispatch the LOCAL_DESTINATIONS_SET event. This call is NOT async and will | 188 * Dispatch the LOCAL_DESTINATIONS_SET event. This call is NOT async and will |
| 143 * happen in the same thread. | 189 * happen in the same thread. |
| 144 */ | 190 */ |
| 145 setLocalDestinations: function() { | 191 setLocalDestinations: function() { |
| 146 var localDestsSetEvent = | 192 var localDestsSetEvent = |
| 147 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 193 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
| 148 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 194 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
| 149 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 195 this.nativeLayer_.getEventTarget().dispatchEvent(localDestsSetEvent); |
| 150 }, | 196 }, |
| 151 | 197 |
| 152 /** | 198 /** |
| 153 * Dispatch the CAPABILITIES_SET event. This call is NOT async and will | 199 * Dispatch the CAPABILITIES_SET event. This call is NOT async and will |
| 154 * happen in the same thread. | 200 * happen in the same thread. |
| 155 * @device - The device whose capabilities should be dispatched. | 201 * @device - The device whose capabilities should be dispatched. |
| 156 */ | 202 */ |
| 157 setCapabilities: function(device) { | 203 setCapabilities: function(device) { |
| 158 var capsSetEvent = | 204 var capsSetEvent = |
| 159 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 205 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
| 160 capsSetEvent.settingsInfo = device; | 206 capsSetEvent.settingsInfo = device; |
| 161 this.nativeLayer_.dispatchEvent(capsSetEvent); | 207 this.nativeLayer_.getEventTarget().dispatchEvent(capsSetEvent); |
| 162 }, | 208 }, |
| 163 | 209 |
| 164 /** | 210 /** |
| 165 * Dispatch the PREVIEW_GENERATION_DONE event. This call is NOT async and | 211 * Dispatch the PREVIEW_GENERATION_DONE event. This call is NOT async and |
| 166 * will happen in the same thread. | 212 * will happen in the same thread. |
| 167 */ | 213 */ |
| 168 dispatchPreviewDone: function() { | 214 dispatchPreviewDone: function() { |
| 169 var previewDoneEvent = | 215 var previewDoneEvent = |
| 170 new Event(print_preview.PreviewArea.EventType.PREVIEW_GENERATION_DONE); | 216 new Event(print_preview.PreviewArea.EventType.PREVIEW_GENERATION_DONE); |
| 171 this.previewArea_.dispatchEvent(previewDoneEvent); | 217 this.previewArea_.dispatchEvent(previewDoneEvent); |
| 172 }, | 218 }, |
| 173 | 219 |
| 174 /** | 220 /** |
| 175 * Dispatch the SETTINGS_INVALID event. This call is NOT async and will | 221 * Dispatch the SETTINGS_INVALID event. This call is NOT async and will |
| 176 * happen in the same thread. | 222 * happen in the same thread. |
| 177 */ | 223 */ |
| 178 dispatchInvalidSettings: function() { | 224 dispatchInvalidSettings: function() { |
| 179 var invalidSettingsEvent = | 225 var invalidSettingsEvent = |
| 180 new Event(print_preview.NativeLayer.EventType.SETTINGS_INVALID); | 226 new Event(print_preview.NativeLayer.EventType.SETTINGS_INVALID); |
| 181 this.nativeLayer_.dispatchEvent(invalidSettingsEvent); | 227 this.nativeLayer_.getEventTarget().dispatchEvent(invalidSettingsEvent); |
| 182 }, | 228 }, |
| 183 | 229 |
| 184 /** | 230 /** |
| 185 * @return {boolean} Whether the UI has "printed" or not. (called startPrint | 231 * @return {boolean} Whether the UI has "printed" or not. (called startPrint |
| 186 * on the native layer) | 232 * on the native layer) |
| 187 */ | 233 */ |
| 188 hasPrinted: function() { | 234 hasPrinted: function() { |
| 189 return this.nativeLayer_.isPrintStarted(); | 235 return this.nativeLayer_.isPrintStarted(); |
| 190 }, | 236 }, |
| 191 | 237 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 221 moreSettings.click(); | 267 moreSettings.click(); |
| 222 }, | 268 }, |
| 223 | 269 |
| 224 /** | 270 /** |
| 225 * Repeated setup steps for the advanced settings tests. | 271 * Repeated setup steps for the advanced settings tests. |
| 226 * Disables accessiblity errors, sets initial settings, and verifies | 272 * Disables accessiblity errors, sets initial settings, and verifies |
| 227 * advanced options section is visible after expanding more settings. | 273 * advanced options section is visible after expanding more settings. |
| 228 */ | 274 */ |
| 229 setupAdvancedSettingsTest: function(device) { | 275 setupAdvancedSettingsTest: function(device) { |
| 230 // Need to disable this since overlay animation will not fully complete. | 276 // Need to disable this since overlay animation will not fully complete. |
| 231 this.accessibilityIssuesAreErrors = false; | |
| 232 this.setInitialSettings(); | |
| 233 this.setLocalDestinations(); | 277 this.setLocalDestinations(); |
| 234 this.setCapabilities(device); | 278 this.setCapabilities(device); |
| 235 this.expandMoreSettings(); | 279 this.expandMoreSettings(); |
| 236 | 280 |
| 237 // Check that the advanced options settings section is visible. | 281 // Check that the advanced options settings section is visible. |
| 238 checkSectionVisible($('advanced-options-settings'), true); | 282 checkSectionVisible($('advanced-options-settings'), true); |
| 239 }, | 283 }, |
| 240 | 284 |
| 241 /** | 285 /** |
| 242 * Generate a real C++ class; don't typedef. | 286 * Generate a real C++ class; don't typedef. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 263 'title' /*documentTitle*/, | 307 'title' /*documentTitle*/, |
| 264 true /*documentHasSelection*/, | 308 true /*documentHasSelection*/, |
| 265 false /*selectionOnly*/, | 309 false /*selectionOnly*/, |
| 266 'FooDevice' /*systemDefaultDestinationId*/, | 310 'FooDevice' /*systemDefaultDestinationId*/, |
| 267 null /*serializedAppStateStr*/, | 311 null /*serializedAppStateStr*/, |
| 268 null /*serializedDefaultDestinationSelectionRulesStr*/); | 312 null /*serializedDefaultDestinationSelectionRulesStr*/); |
| 269 this.localDestinationInfos_ = [ | 313 this.localDestinationInfos_ = [ |
| 270 { printerName: 'FooName', deviceName: 'FooDevice' }, | 314 { printerName: 'FooName', deviceName: 'FooDevice' }, |
| 271 { printerName: 'BarName', deviceName: 'BarDevice' } | 315 { printerName: 'BarName', deviceName: 'BarDevice' } |
| 272 ]; | 316 ]; |
| 273 this.nativeLayer_ = printPreview.nativeLayer_; | 317 }, |
| 274 this.previewArea_ = printPreview.previewArea_; | |
| 275 | |
| 276 testing.Test.disableAnimationsAndTransitions(); | |
| 277 | |
| 278 // Enable when failure is resolved. | |
| 279 // AX_TEXT_03: http://crbug.com/559209 | |
| 280 this.accessibilityAuditConfig.ignoreSelectors( | |
| 281 'multipleLabelableElementsPerLabel', | |
| 282 '#page-settings > .right-column > *'); | |
| 283 } | |
| 284 }; | 318 }; |
| 285 | 319 |
| 286 GEN('#include "chrome/test/data/webui/print_preview.h"'); | 320 GEN('#include "chrome/test/data/webui/print_preview.h"'); |
| 287 | 321 |
| 288 // Test some basic assumptions about the print preview WebUI. | 322 // Test some basic assumptions about the print preview WebUI. |
| 289 TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() { | 323 TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() { |
| 290 this.setInitialSettings(); | 324 this.setInitialSettings(); |
| 291 this.setLocalDestinations(); | 325 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 292 | 326 function() { |
| 293 var recentList = $('destination-search').querySelector('.recent-list ul'); | 327 this.setLocalDestinations(); |
| 294 var localList = $('destination-search').querySelector('.local-list ul'); | 328 var recentList = |
| 295 assertNotEquals(null, recentList); | 329 $('destination-search').querySelector('.recent-list ul'); |
| 296 assertEquals(1, recentList.childNodes.length); | 330 var localList = |
| 297 assertEquals('FooName', | 331 $('destination-search').querySelector('.local-list ul'); |
| 298 recentList.childNodes.item(0).querySelector( | 332 assertNotEquals(null, recentList); |
| 299 '.destination-list-item-name').textContent); | 333 assertEquals(1, recentList.childNodes.length); |
| 300 | 334 assertEquals('FooName', |
| 301 assertNotEquals(null, localList); | 335 recentList.childNodes.item(0).querySelector( |
| 302 assertEquals(3, localList.childNodes.length); | 336 '.destination-list-item-name').textContent); |
| 303 assertEquals('Save as PDF', | 337 assertNotEquals(null, localList); |
| 304 localList.childNodes.item(PrintPreviewWebUITest.PDF_INDEX). | 338 assertEquals(3, localList.childNodes.length); |
| 305 querySelector('.destination-list-item-name').textContent); | 339 assertEquals('Save as PDF', |
| 306 assertEquals('FooName', | 340 localList.childNodes.item(PrintPreviewWebUITest.PDF_INDEX). |
| 307 localList.childNodes.item(PrintPreviewWebUITest.FOO_INDEX). | 341 querySelector('.destination-list-item-name').textContent); |
| 308 querySelector('.destination-list-item-name').textContent); | 342 assertEquals('FooName', |
| 309 assertEquals('BarName', | 343 localList.childNodes.item(PrintPreviewWebUITest.FOO_INDEX). |
| 310 localList.childNodes.item(PrintPreviewWebUITest.BAR_INDEX). | 344 querySelector('.destination-list-item-name').textContent); |
| 311 querySelector('.destination-list-item-name').textContent); | 345 assertEquals('BarName', |
| 312 | 346 localList.childNodes.item(PrintPreviewWebUITest.BAR_INDEX). |
| 313 testDone(); | 347 querySelector('.destination-list-item-name').textContent); |
| 348 testDone(); | |
| 349 }.bind(this)); | |
| 314 }); | 350 }); |
| 315 | 351 |
| 316 // Test that the printer list is structured correctly after calling | 352 // Test that the printer list is structured correctly after calling |
| 317 // addCloudPrinters with an empty list. | 353 // addCloudPrinters with an empty list. |
| 318 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() { | 354 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() { |
| 319 this.setInitialSettings(); | 355 this.setInitialSettings(); |
| 320 this.setLocalDestinations(); | |
| 321 | 356 |
| 322 var cloudPrintEnableEvent = | 357 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 323 new Event(print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE); | 358 function() { |
| 324 cloudPrintEnableEvent.baseCloudPrintUrl = 'cloudprint url'; | 359 this.setLocalDestinations(); |
| 325 this.nativeLayer_.dispatchEvent(cloudPrintEnableEvent); | |
| 326 | 360 |
| 327 var searchDoneEvent = | 361 var cloudPrintEnableEvent = |
| 328 new Event(cloudprint.CloudPrintInterfaceEventType.SEARCH_DONE); | 362 new Event(print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE); |
| 329 searchDoneEvent.printers = []; | 363 cloudPrintEnableEvent.baseCloudPrintUrl = 'cloudprint url'; |
| 330 searchDoneEvent.isRecent = true; | 364 this.nativeLayer_.getEventTarget().dispatchEvent( |
| 331 searchDoneEvent.email = 'foo@chromium.org'; | 365 cloudPrintEnableEvent); |
| 332 printPreview.cloudPrintInterface_.dispatchEvent(searchDoneEvent); | |
| 333 | 366 |
| 334 var recentList = $('destination-search').querySelector('.recent-list ul'); | 367 var searchDoneEvent = |
| 335 var localList = $('destination-search').querySelector('.local-list ul'); | 368 new Event(cloudprint.CloudPrintInterfaceEventType.SEARCH_DONE); |
| 336 var cloudList = $('destination-search').querySelector('.cloud-list ul'); | 369 searchDoneEvent.printers = []; |
| 370 searchDoneEvent.isRecent = true; | |
| 371 searchDoneEvent.email = 'foo@chromium.org'; | |
| 372 printPreview.cloudPrintInterface_.dispatchEvent(searchDoneEvent); | |
| 337 | 373 |
| 338 assertNotEquals(null, recentList); | 374 var recentList = |
| 339 assertEquals(1, recentList.childNodes.length); | 375 $('destination-search').querySelector('.recent-list ul'); |
| 340 assertEquals('FooName', | 376 var localList = |
| 341 recentList.childNodes.item(0).querySelector( | 377 $('destination-search').querySelector('.local-list ul'); |
| 342 '.destination-list-item-name').textContent); | 378 var cloudList = |
| 379 $('destination-search').querySelector('.cloud-list ul'); | |
| 343 | 380 |
| 344 assertNotEquals(null, localList); | 381 assertNotEquals(null, recentList); |
| 345 assertEquals(3, localList.childNodes.length); | 382 assertEquals(1, recentList.childNodes.length); |
| 346 assertEquals('Save as PDF', | 383 assertEquals('FooName', |
| 347 localList.childNodes.item(PrintPreviewWebUITest.PDF_INDEX). | 384 recentList.childNodes.item(0). |
| 348 querySelector('.destination-list-item-name').textContent); | 385 querySelector('.destination-list-item-name'). |
| 349 assertEquals('FooName', | 386 textContent); |
| 350 localList.childNodes.item(PrintPreviewWebUITest.FOO_INDEX). | |
| 351 querySelector('.destination-list-item-name').textContent); | |
| 352 assertEquals('BarName', | |
| 353 localList.childNodes.item(PrintPreviewWebUITest.BAR_INDEX). | |
| 354 querySelector('.destination-list-item-name').textContent); | |
| 355 | 387 |
| 356 assertNotEquals(null, cloudList); | 388 assertNotEquals(null, localList); |
| 357 assertEquals(0, cloudList.childNodes.length); | 389 assertEquals(3, localList.childNodes.length); |
| 390 assertEquals('Save as PDF', | |
| 391 localList.childNodes.item( | |
| 392 PrintPreviewWebUITest.PDF_INDEX). | |
| 393 querySelector('.destination-list-item-name'). | |
| 394 textContent); | |
| 395 assertEquals('FooName', | |
| 396 localList.childNodes. | |
| 397 item(PrintPreviewWebUITest.FOO_INDEX). | |
| 398 querySelector('.destination-list-item-name'). | |
| 399 textContent); | |
| 400 assertEquals('BarName', | |
| 401 localList.childNodes. | |
| 402 item(PrintPreviewWebUITest.BAR_INDEX). | |
| 403 querySelector('.destination-list-item-name'). | |
| 404 textContent); | |
| 358 | 405 |
| 359 testDone(); | 406 assertNotEquals(null, cloudList); |
| 407 assertEquals(0, cloudList.childNodes.length); | |
| 408 | |
| 409 testDone(); | |
| 410 }.bind(this)); | |
| 360 }); | 411 }); |
| 361 | 412 |
| 362 /** | 413 /** |
| 363 * Verify that |section| visibility matches |visible|. | 414 * Verify that |section| visibility matches |visible|. |
| 364 * @param {HTMLDivElement} section The section to check. | 415 * @param {HTMLDivElement} section The section to check. |
| 365 * @param {boolean} visible The expected state of visibility. | 416 * @param {boolean} visible The expected state of visibility. |
| 366 */ | 417 */ |
| 367 function checkSectionVisible(section, visible) { | 418 function checkSectionVisible(section, visible) { |
| 368 assertNotEquals(null, section); | 419 assertNotEquals(null, section); |
| 369 expectEquals( | 420 expectEquals( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 return !cr.isWindows && !cr.isMac; | 475 return !cr.isWindows && !cr.isMac; |
| 425 } | 476 } |
| 426 | 477 |
| 427 // Test restore settings with one destination. | 478 // Test restore settings with one destination. |
| 428 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', | 479 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', |
| 429 function() { | 480 function() { |
| 430 this.initialSettings_.serializedAppStateStr_ = | 481 this.initialSettings_.serializedAppStateStr_ = |
| 431 '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' + | 482 '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' + |
| 432 '"account":"", "capabilities":0, "name":"", "extensionId":"",' + | 483 '"account":"", "capabilities":0, "name":"", "extensionId":"",' + |
| 433 '"extensionName":""}]}'; | 484 '"extensionName":""}]}'; |
| 485 | |
| 434 this.setInitialSettings(); | 486 this.setInitialSettings(); |
| 435 | 487 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 436 testDone(); | 488 function() { |
| 489 testDone(); | |
| 490 }); | |
| 437 }); | 491 }); |
| 438 | 492 |
| 439 // Test with multiple destinations | 493 // Test with multiple destinations |
| 440 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations', | 494 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations', |
| 441 function() { | 495 function() { |
| 442 var origin = cr.isChromeOS ? "chrome_os" : "local"; | 496 var origin = cr.isChromeOS ? "chrome_os" : "local"; |
| 443 | 497 |
| 444 var appState = { | 498 var appState = { |
| 445 'version': 2, | 499 'version': 2, |
| 446 'recentDestinations': [ | 500 'recentDestinations': [ |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 468 'account': '', | 522 'account': '', |
| 469 'capabilities': 0, | 523 'capabilities': 0, |
| 470 'name': '', | 524 'name': '', |
| 471 'extensionId': '', | 525 'extensionId': '', |
| 472 'extensionName': '' | 526 'extensionName': '' |
| 473 } | 527 } |
| 474 ] | 528 ] |
| 475 }; | 529 }; |
| 476 | 530 |
| 477 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(appState); | 531 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(appState); |
| 478 | |
| 479 this.setInitialSettings(); | 532 this.setInitialSettings(); |
| 480 | 533 |
| 481 // Set capabilities for the three recently used destinations + 1 more | 534 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 482 this.setCapabilities(getCddTemplate('ID1')); | 535 function() { |
| 483 this.setCapabilities(getCddTemplate('ID2')); | 536 // Set capabilities for the three recently used destinations + 1 more |
| 484 this.setCapabilities(getCddTemplate('ID3')); | 537 this.setCapabilities(getCddTemplate('ID1')); |
| 485 this.setCapabilities(getCddTemplate('ID4')); | 538 this.setCapabilities(getCddTemplate('ID2')); |
| 539 this.setCapabilities(getCddTemplate('ID3')); | |
| 540 this.setCapabilities(getCddTemplate('ID4')); | |
| 486 | 541 |
| 487 // The most recently used destination should be the currently selected one. | 542 // The most recently used destination should be the currently selected |
| 488 // This is ID1. | 543 // one. This is ID1. |
| 489 assertEquals( | 544 assertEquals( |
| 490 'ID1', printPreview.destinationStore_.selectedDestination.id); | 545 'ID1', printPreview.destinationStore_.selectedDestination.id); |
| 491 | 546 |
| 492 // Look through the destinations. ID1, ID2, and ID3 should all be recent. | 547 // Look through the destinations. ID1, ID2, and ID3 should all be |
| 493 var destinations = printPreview.destinationStore_.destinations_; | 548 // recent. |
| 494 var ids_found = []; | 549 var destinations = printPreview.destinationStore_.destinations_; |
| 550 var ids_found = []; | |
| 495 | 551 |
| 496 for (var i = 0; i < destinations.length; i++) { | 552 for (var i = 0; i < destinations.length; i++) { |
| 497 if (!destinations[i]) | 553 if (!destinations[i]) |
| 498 continue; | 554 continue; |
| 499 if (destinations[i].isRecent) | 555 if (destinations[i].isRecent) |
| 500 ids_found.push(destinations[i].id); | 556 ids_found.push(destinations[i].id); |
| 501 } | 557 } |
| 502 | 558 |
| 503 // Make sure there were 3 recent destinations and that they are the correct | 559 // Make sure there were 3 recent destinations and that they are the |
| 504 // IDs. | 560 // correct IDs. |
| 505 assertEquals(3, ids_found.length); | 561 assertEquals(3, ids_found.length); |
| 506 assertNotEquals(-1, ids_found.indexOf("ID1")); | 562 assertNotEquals(-1, ids_found.indexOf("ID1")); |
| 507 assertNotEquals(-1, ids_found.indexOf("ID2")); | 563 assertNotEquals(-1, ids_found.indexOf("ID2")); |
| 508 assertNotEquals(-1, ids_found.indexOf("ID3")); | 564 assertNotEquals(-1, ids_found.indexOf("ID3")); |
| 509 | 565 |
| 510 testDone(); | 566 testDone(); |
| 567 }.bind(this)); | |
| 511 }); | 568 }); |
| 512 | 569 |
| 513 TEST_F('PrintPreviewWebUITest', | 570 TEST_F('PrintPreviewWebUITest', |
| 514 'TestPrintPreviewDefaultDestinationSelectionRules', function() { | 571 'TestPrintPreviewDefaultDestinationSelectionRules', function() { |
| 515 // It also makes sure these rules do override system default destination. | 572 // It also makes sure these rules do override system default destination. |
| 516 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = | 573 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = |
| 517 '{"namePattern":".*Bar.*"}'; | 574 '{"namePattern":".*Bar.*"}'; |
| 518 this.setInitialSettings(); | 575 this.setInitialSettings(); |
| 519 this.setLocalDestinations(); | 576 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 577 function() { | |
| 578 this.setLocalDestinations(); | |
| 520 | 579 |
| 521 assertEquals( | 580 assertEquals( |
| 522 'BarDevice', printPreview.destinationStore_.selectedDestination.id); | 581 'BarDevice', |
| 582 printPreview.destinationStore_.selectedDestination.id); | |
| 523 | 583 |
| 524 testDone(); | 584 testDone(); |
| 585 }.bind(this)); | |
| 525 }); | 586 }); |
| 526 | 587 |
| 527 TEST_F('PrintPreviewWebUITest', 'TestSystemDialogLinkIsHiddenInAppKioskMode', | 588 TEST_F('PrintPreviewWebUITest', 'TestSystemDialogLinkIsHiddenInAppKioskMode', |
| 528 function() { | 589 function() { |
| 529 if (cr.isChromeOS) { | 590 if (cr.isChromeOS) { |
| 530 assertEquals(null, $('system-dialog-link')); | 591 assertEquals(null, $('system-dialog-link')); |
| 592 testDone(); | |
| 531 } else { | 593 } else { |
| 532 this.initialSettings_.isInAppKioskMode_ = true; | 594 this.initialSettings_.isInAppKioskMode_ = true; |
| 533 this.setInitialSettings(); | 595 this.setInitialSettings(); |
| 534 | 596 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 535 checkElementDisplayed($('system-dialog-link'), false); | 597 function() { |
| 598 checkElementDisplayed($('system-dialog-link'), false); | |
| 599 testDone(); | |
| 600 }); | |
| 536 } | 601 } |
| 537 | |
| 538 testDone(); | |
| 539 }); | 602 }); |
| 540 | 603 |
| 541 // Test that disabled settings hide the disabled sections. | 604 // Test that disabled settings hide the disabled sections. |
| 542 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { | 605 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { |
| 606 this.createPrintPreview(); | |
| 543 checkSectionVisible($('layout-settings'), false); | 607 checkSectionVisible($('layout-settings'), false); |
| 544 checkSectionVisible($('color-settings'), false); | 608 checkSectionVisible($('color-settings'), false); |
| 545 checkSectionVisible($('copies-settings'), false); | 609 checkSectionVisible($('copies-settings'), false); |
| 546 | 610 |
| 547 this.setInitialSettings(); | 611 this.setInitialSettings(); |
|
dpapad
2017/05/19 00:10:18
Is getInitialSettisgs() called twice here? Once be
| |
| 548 this.setLocalDestinations(); | 612 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 549 var device = getCddTemplate("FooDevice"); | 613 function() { |
| 550 device.capabilities.printer.color = { | 614 this.setLocalDestinations(); |
| 551 "option": [ | 615 var device = getCddTemplate("FooDevice"); |
| 552 {"is_default": true, "type": "STANDARD_COLOR"} | 616 device.capabilities.printer.color = { |
| 553 ] | 617 "option": [ |
| 554 }; | 618 {"is_default": true, "type": "STANDARD_COLOR"} |
| 555 delete device.capabilities.printer.copies; | 619 ] |
| 556 this.setCapabilities(device); | 620 }; |
| 621 delete device.capabilities.printer.copies; | |
| 622 this.setCapabilities(device); | |
| 557 | 623 |
| 558 checkSectionVisible($('layout-settings'), true); | 624 checkSectionVisible($('layout-settings'), true); |
| 559 checkSectionVisible($('color-settings'), false); | 625 checkSectionVisible($('color-settings'), false); |
| 560 checkSectionVisible($('copies-settings'), false); | 626 checkSectionVisible($('copies-settings'), false); |
| 561 | 627 |
| 562 this.waitForAnimationToEnd('other-options-collapsible'); | 628 this.waitForAnimationToEnd('other-options-collapsible'); |
| 629 }.bind(this)); | |
| 563 }); | 630 }); |
| 564 | 631 |
| 565 // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the | 632 // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the |
| 566 // fit to page option. | 633 // fit to page option. |
| 567 TEST_F('PrintPreviewWebUITest', 'PrintToPDFSelectedCapabilities', function() { | 634 TEST_F('PrintPreviewWebUITest', 'PrintToPDFSelectedCapabilities', function() { |
| 568 // Add PDF printer. | 635 // Add PDF printer. |
| 569 this.initialSettings_.isDocumentModifiable_ = false; | 636 this.initialSettings_.isDocumentModifiable_ = false; |
| 570 this.initialSettings_.systemDefaultDestinationId_ = 'Save as PDF'; | 637 this.initialSettings_.systemDefaultDestinationId_ = 'Save as PDF'; |
| 571 this.setInitialSettings(); | 638 this.setInitialSettings(); |
| 572 | 639 |
| 573 var device = { | 640 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 574 printerId: 'Save as PDF', | 641 function() { |
| 575 capabilities: { | 642 var device = { |
| 576 version: '1.0', | 643 printerId: 'Save as PDF', |
| 577 printer: { | 644 capabilities: { |
| 578 page_orientation: { | 645 version: '1.0', |
| 579 option: [ | 646 printer: { |
| 580 {type: 'AUTO', is_default: true}, | 647 page_orientation: { |
| 581 {type: 'PORTRAIT'}, | 648 option: [ |
| 582 {type: 'LANDSCAPE'} | 649 {type: 'AUTO', is_default: true}, |
| 583 ] | 650 {type: 'PORTRAIT'}, |
| 584 }, | 651 {type: 'LANDSCAPE'} |
| 585 color: { | 652 ] |
| 586 option: [ | 653 }, |
| 587 {type: 'STANDARD_COLOR', is_default: true} | 654 color: { |
| 588 ] | 655 option: [ |
| 589 }, | 656 {type: 'STANDARD_COLOR', is_default: true} |
| 590 media_size: { | 657 ] |
| 591 option: [ | 658 }, |
| 592 { name: 'NA_LETTER', | 659 media_size: { |
| 593 width_microns: 0, | 660 option: [ |
| 594 height_microns: 0, | 661 { name: 'NA_LETTER', |
| 595 is_default: true | 662 width_microns: 0, |
| 663 height_microns: 0, | |
| 664 is_default: true | |
| 665 } | |
| 666 ] | |
| 667 } | |
| 596 } | 668 } |
| 597 ] | 669 } |
| 670 }; | |
| 671 this.setCapabilities(device); | |
| 672 | |
| 673 var otherOptions = $('other-options-settings'); | |
| 674 // If rasterization is an option, other options should be visible. If | |
| 675 // not, there should be no available other options. | |
| 676 checkSectionVisible(otherOptions, isPrintAsImageEnabled()); | |
| 677 if (isPrintAsImageEnabled()) { | |
| 678 checkElementDisplayed( | |
| 679 otherOptions.querySelector('#fit-to-page-container'), false); | |
| 680 checkElementDisplayed( | |
| 681 otherOptions.querySelector('#rasterize-container'), true); | |
| 598 } | 682 } |
| 599 } | 683 checkSectionVisible($('media-size-settings'), false); |
| 600 } | 684 checkSectionVisible($('scaling-settings'), false); |
| 601 }; | |
| 602 this.setCapabilities(device); | |
| 603 | 685 |
| 604 var otherOptions = $('other-options-settings'); | 686 testDone(); |
| 605 // If rasterization is an option, other options should be visible. If not, | 687 }.bind(this)); |
| 606 // there should be no available other options. | |
| 607 checkSectionVisible(otherOptions, isPrintAsImageEnabled()); | |
| 608 if (isPrintAsImageEnabled()) { | |
| 609 checkElementDisplayed( | |
| 610 otherOptions.querySelector('#fit-to-page-container'), false); | |
| 611 checkElementDisplayed( | |
| 612 otherOptions.querySelector('#rasterize-container'), true); | |
| 613 } | |
| 614 checkSectionVisible($('media-size-settings'), false); | |
| 615 checkSectionVisible($('scaling-settings'), false); | |
| 616 | |
| 617 testDone(); | |
| 618 }); | 688 }); |
| 619 | 689 |
| 620 // When the source is 'HTML', we always hide the fit to page option and show | 690 // When the source is 'HTML', we always hide the fit to page option and show |
| 621 // media size option. | 691 // media size option. |
| 622 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { | 692 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { |
| 623 this.setInitialSettings(); | 693 this.setInitialSettings(); |
| 624 this.setLocalDestinations(); | 694 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 625 this.setCapabilities(getCddTemplate("FooDevice")); | 695 function() { |
| 696 this.setLocalDestinations(); | |
| 697 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 626 | 698 |
| 627 var otherOptions = $('other-options-settings'); | 699 var otherOptions = $('other-options-settings'); |
| 628 var fitToPage = otherOptions.querySelector('#fit-to-page-container'); | 700 var fitToPage = otherOptions.querySelector('#fit-to-page-container'); |
| 629 var rasterize; | 701 var rasterize; |
| 630 if (isPrintAsImageEnabled()) | 702 if (isPrintAsImageEnabled()) |
| 631 rasterize = otherOptions.querySelector('#rasterize-container'); | 703 rasterize = otherOptions.querySelector('#rasterize-container'); |
| 632 var mediaSize = $('media-size-settings'); | 704 var mediaSize = $('media-size-settings'); |
| 633 var scalingSettings = $('scaling-settings'); | 705 var scalingSettings = $('scaling-settings'); |
| 634 | 706 |
| 635 // Check that options are collapsed (section is visible, because duplex is | 707 // Check that options are collapsed (section is visible, because duplex |
| 636 // available). | 708 // is available). |
| 637 checkSectionVisible(otherOptions, true); | 709 checkSectionVisible(otherOptions, true); |
| 638 checkElementDisplayed(fitToPage, false); | 710 checkElementDisplayed(fitToPage, false); |
| 639 if (isPrintAsImageEnabled()) | 711 if (isPrintAsImageEnabled()) |
| 640 checkElementDisplayed(rasterize, false); | 712 checkElementDisplayed(rasterize, false); |
| 641 checkSectionVisible(mediaSize, false); | 713 checkSectionVisible(mediaSize, false); |
| 642 checkSectionVisible(scalingSettings, false); | 714 checkSectionVisible(scalingSettings, false); |
| 643 | 715 |
| 644 this.expandMoreSettings(); | 716 this.expandMoreSettings(); |
| 645 | 717 |
| 646 checkElementDisplayed(fitToPage, false); | 718 checkElementDisplayed(fitToPage, false); |
| 647 if (isPrintAsImageEnabled()) | 719 if (isPrintAsImageEnabled()) |
| 648 checkElementDisplayed(rasterize, false); | 720 checkElementDisplayed(rasterize, false); |
| 649 checkSectionVisible(mediaSize, true); | 721 checkSectionVisible(mediaSize, true); |
| 650 checkSectionVisible(scalingSettings, true); | 722 checkSectionVisible(scalingSettings, true); |
| 651 | 723 |
| 652 this.waitForAnimationToEnd('more-settings'); | 724 this.waitForAnimationToEnd('more-settings'); |
| 725 }.bind(this)); | |
| 653 }); | 726 }); |
| 654 | 727 |
| 655 // When the source is "PDF", depending on the selected destination printer, we | 728 // When the source is "PDF", depending on the selected destination printer, we |
| 656 // show/hide the fit to page option and hide media size selection. | 729 // show/hide the fit to page option and hide media size selection. |
| 657 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { | 730 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { |
| 658 this.initialSettings_.isDocumentModifiable_ = false; | 731 this.initialSettings_.isDocumentModifiable_ = false; |
| 659 this.setInitialSettings(); | 732 this.setInitialSettings(); |
| 660 this.setLocalDestinations(); | 733 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 661 this.setCapabilities(getCddTemplate("FooDevice")); | 734 function() { |
| 735 this.setLocalDestinations(); | |
| 736 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 662 | 737 |
| 663 var otherOptions = $('other-options-settings'); | 738 var otherOptions = $('other-options-settings'); |
| 664 var scalingSettings = $('scaling-settings'); | 739 var scalingSettings = $('scaling-settings'); |
| 665 var fitToPageContainer = | 740 var fitToPageContainer = |
| 666 otherOptions.querySelector('#fit-to-page-container'); | 741 otherOptions.querySelector('#fit-to-page-container'); |
| 667 var rasterizeContainer; | 742 var rasterizeContainer; |
| 668 if (isPrintAsImageEnabled()) { | 743 if (isPrintAsImageEnabled()) { |
| 669 rasterizeContainer = | 744 rasterizeContainer = |
| 670 otherOptions.querySelector('#rasterize-container'); | 745 otherOptions.querySelector('#rasterize-container'); |
| 671 } | 746 } |
| 672 | 747 |
| 673 checkSectionVisible(otherOptions, true); | 748 checkSectionVisible(otherOptions, true); |
| 674 checkElementDisplayed(fitToPageContainer, true); | 749 checkElementDisplayed(fitToPageContainer, true); |
| 675 if (isPrintAsImageEnabled()) | 750 if (isPrintAsImageEnabled()) |
| 676 checkElementDisplayed(rasterizeContainer, false); | 751 checkElementDisplayed(rasterizeContainer, false); |
| 677 expectTrue( | 752 expectTrue( |
| 678 fitToPageContainer.querySelector('.checkbox').checked); | 753 fitToPageContainer.querySelector('.checkbox').checked); |
| 679 this.expandMoreSettings(); | 754 this.expandMoreSettings(); |
| 680 if (isPrintAsImageEnabled()) { | 755 if (isPrintAsImageEnabled()) { |
| 681 checkElementDisplayed(rasterizeContainer, true); | 756 checkElementDisplayed(rasterizeContainer, true); |
| 682 expectFalse( | 757 expectFalse( |
| 683 rasterizeContainer.querySelector('.checkbox').checked); | 758 rasterizeContainer.querySelector('.checkbox').checked); |
| 684 } | 759 } |
| 685 checkSectionVisible($('media-size-settings'), true); | 760 checkSectionVisible($('media-size-settings'), true); |
| 686 checkSectionVisible(scalingSettings, true); | 761 checkSectionVisible(scalingSettings, true); |
| 687 | 762 |
| 688 this.waitForAnimationToEnd('other-options-collapsible'); | 763 this.waitForAnimationToEnd('other-options-collapsible'); |
| 764 }.bind(this)); | |
| 689 }); | 765 }); |
| 690 | 766 |
| 691 // When the source is "PDF", depending on the selected destination printer, we | 767 // When the source is "PDF", depending on the selected destination printer, we |
| 692 // show/hide the fit to page option and hide media size selection. | 768 // show/hide the fit to page option and hide media size selection. |
| 693 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { | 769 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { |
| 694 this.initialSettings_.isDocumentModifiable_ = false; | 770 this.initialSettings_.isDocumentModifiable_ = false; |
| 695 this.setInitialSettings(); | 771 this.setInitialSettings(); |
| 696 this.setLocalDestinations(); | 772 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 697 this.setCapabilities(getCddTemplate("FooDevice")); | 773 function() { |
| 774 this.setLocalDestinations(); | |
| 775 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 698 | 776 |
| 699 var otherOptions = $('other-options-settings'); | 777 var otherOptions = $('other-options-settings'); |
| 700 var scalingSettings = $('scaling-settings'); | 778 var scalingSettings = $('scaling-settings'); |
| 701 | 779 |
| 702 checkSectionVisible(otherOptions, true); | 780 checkSectionVisible(otherOptions, true); |
| 703 var fitToPageContainer = | 781 var fitToPageContainer = |
| 704 otherOptions.querySelector('#fit-to-page-container'); | 782 otherOptions.querySelector('#fit-to-page-container'); |
| 705 checkElementDisplayed(fitToPageContainer, true); | 783 checkElementDisplayed(fitToPageContainer, true); |
| 706 expectTrue( | 784 expectTrue( |
| 707 fitToPageContainer.querySelector('.checkbox').checked); | 785 fitToPageContainer.querySelector('.checkbox').checked); |
| 708 this.expandMoreSettings(); | 786 this.expandMoreSettings(); |
| 709 checkSectionVisible($('media-size-settings'), true); | 787 checkSectionVisible($('media-size-settings'), true); |
| 710 checkSectionVisible(scalingSettings, true); | 788 checkSectionVisible(scalingSettings, true); |
| 711 | 789 |
| 712 // Change scaling input | 790 // Change scaling input |
| 713 var scalingInput = scalingSettings.querySelector('.user-value'); | 791 var scalingInput = scalingSettings.querySelector('.user-value'); |
| 714 expectEquals('100', scalingInput.value); | 792 expectEquals('100', scalingInput.value); |
| 715 scalingInput.stepUp(5); | 793 scalingInput.stepUp(5); |
| 716 expectEquals('105', scalingInput.value); | 794 expectEquals('105', scalingInput.value); |
| 717 | 795 |
| 718 // Trigger the event | 796 // Trigger the event |
| 719 var enterEvent = document.createEvent('Event'); | 797 var enterEvent = document.createEvent('Event'); |
| 720 enterEvent.initEvent('keydown'); | 798 enterEvent.initEvent('keydown'); |
| 721 enterEvent.keyCode = 'Enter'; | 799 enterEvent.keyCode = 'Enter'; |
| 722 scalingInput.dispatchEvent(enterEvent); | 800 scalingInput.dispatchEvent(enterEvent); |
| 723 expectFalse( | 801 expectFalse( |
| 724 fitToPageContainer.querySelector('.checkbox').checked); | 802 fitToPageContainer.querySelector('.checkbox').checked); |
| 725 | 803 |
| 726 this.waitForAnimationToEnd('other-options-collapsible'); | 804 this.waitForAnimationToEnd('other-options-collapsible'); |
| 805 }.bind(this)); | |
| 727 }); | 806 }); |
| 728 | 807 |
| 729 // When the number of copies print preset is set for source 'PDF', we update | 808 // When the number of copies print preset is set for source 'PDF', we update |
| 730 // the copies value if capability is supported by printer. | 809 // the copies value if capability is supported by printer. |
| 731 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() { | 810 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() { |
| 732 this.initialSettings_.isDocumentModifiable_ = false; | 811 this.initialSettings_.isDocumentModifiable_ = false; |
| 733 this.setInitialSettings(); | 812 this.setInitialSettings(); |
| 734 this.setLocalDestinations(); | 813 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 735 this.setCapabilities(getCddTemplate("FooDevice")); | 814 function() { |
| 815 this.setLocalDestinations(); | |
| 816 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 736 | 817 |
| 737 // Indicate that the number of copies print preset is set for source PDF. | 818 // Indicate that the number of copies print preset is set for source |
| 738 var printPresetOptions = { | 819 // PDF. |
| 739 disableScaling: true, | 820 var printPresetOptions = { |
| 740 copies: 2 | 821 disableScaling: true, |
| 741 }; | 822 copies: 2 |
| 742 var printPresetOptionsEvent = new Event( | 823 }; |
| 743 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); | 824 var printPresetOptionsEvent = new Event( |
| 744 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; | 825 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
| 745 this.nativeLayer_.dispatchEvent(printPresetOptionsEvent); | 826 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; |
| 827 this.nativeLayer_.getEventTarget(). | |
| 828 dispatchEvent(printPresetOptionsEvent); | |
| 746 | 829 |
| 747 checkSectionVisible($('copies-settings'), true); | 830 checkSectionVisible($('copies-settings'), true); |
| 748 expectEquals( | 831 expectEquals( |
| 749 printPresetOptions.copies, | 832 printPresetOptions.copies, |
| 750 parseInt($('copies-settings').querySelector('.user-value').value)); | 833 parseInt($('copies-settings').querySelector('.user-value').value)); |
| 751 | 834 |
| 752 this.waitForAnimationToEnd('other-options-collapsible'); | 835 this.waitForAnimationToEnd('other-options-collapsible'); |
| 836 }.bind(this)); | |
| 753 }); | 837 }); |
| 754 | 838 |
| 755 // When the duplex print preset is set for source 'PDF', we update the | 839 // When the duplex print preset is set for source 'PDF', we update the |
| 756 // duplex setting if capability is supported by printer. | 840 // duplex setting if capability is supported by printer. |
| 757 TEST_F('PrintPreviewWebUITest', 'CheckDuplexPrintPreset', function() { | 841 TEST_F('PrintPreviewWebUITest', 'CheckDuplexPrintPreset', function() { |
| 758 this.initialSettings_.isDocumentModifiable_ = false; | 842 this.initialSettings_.isDocumentModifiable_ = false; |
| 759 this.setInitialSettings(); | 843 this.setInitialSettings(); |
| 760 this.setLocalDestinations(); | |
| 761 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 762 | 844 |
| 763 // Indicate that the duplex print preset is set to "long edge" for source PDF. | 845 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 764 var printPresetOptions = { | 846 function() { |
| 765 duplex: 1 | 847 this.setLocalDestinations(); |
| 766 }; | 848 this.setCapabilities(getCddTemplate("FooDevice")); |
| 767 var printPresetOptionsEvent = new Event( | |
| 768 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); | |
| 769 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; | |
| 770 this.nativeLayer_.dispatchEvent(printPresetOptionsEvent); | |
| 771 | 849 |
| 772 var otherOptions = $('other-options-settings'); | 850 // Indicate that the duplex print preset is set to "long edge" for |
| 773 checkSectionVisible(otherOptions, true); | 851 // source PDF. |
| 774 var duplexContainer = otherOptions.querySelector('#duplex-container'); | 852 var printPresetOptions = { |
| 775 checkElementDisplayed(duplexContainer, true); | 853 duplex: 1 |
| 776 expectTrue(duplexContainer.querySelector('.checkbox').checked); | 854 }; |
| 855 var printPresetOptionsEvent = new Event( | |
| 856 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); | |
| 857 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; | |
| 858 this.nativeLayer_.getEventTarget(). | |
| 859 dispatchEvent(printPresetOptionsEvent); | |
| 777 | 860 |
| 778 this.waitForAnimationToEnd('other-options-collapsible'); | 861 var otherOptions = $('other-options-settings'); |
| 862 checkSectionVisible(otherOptions, true); | |
| 863 var duplexContainer = otherOptions.querySelector('#duplex-container'); | |
| 864 checkElementDisplayed(duplexContainer, true); | |
| 865 expectTrue(duplexContainer.querySelector('.checkbox').checked); | |
| 866 | |
| 867 this.waitForAnimationToEnd('other-options-collapsible'); | |
| 868 }.bind(this)); | |
| 779 }); | 869 }); |
| 780 | 870 |
| 781 // Make sure that custom margins controls are properly set up. | 871 // Make sure that custom margins controls are properly set up. |
| 782 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { | 872 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { |
| 783 this.setInitialSettings(); | 873 this.setInitialSettings(); |
| 784 this.setLocalDestinations(); | 874 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 785 this.setCapabilities(getCddTemplate("FooDevice")); | 875 function() { |
| 876 this.setLocalDestinations(); | |
| 877 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 786 | 878 |
| 787 printPreview.printTicketStore_.marginsType.updateValue( | 879 printPreview.printTicketStore_.marginsType.updateValue( |
| 788 print_preview.ticket_items.MarginsTypeValue.CUSTOM); | 880 print_preview.ticket_items.MarginsTypeValue.CUSTOM); |
| 789 | 881 |
| 790 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { | 882 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { |
| 791 var control = $('preview-area').querySelector('.margin-control-' + margin); | 883 var control = |
| 792 assertNotEquals(null, control); | 884 $('preview-area').querySelector('.margin-control-' + margin); |
| 793 var input = control.querySelector('.margin-control-textbox'); | 885 assertNotEquals(null, control); |
| 794 assertTrue(input.hasAttribute('aria-label')); | 886 var input = control.querySelector('.margin-control-textbox'); |
| 795 assertNotEquals('undefined', input.getAttribute('aria-label')); | 887 assertTrue(input.hasAttribute('aria-label')); |
| 796 }); | 888 assertNotEquals('undefined', input.getAttribute('aria-label')); |
| 797 this.waitForAnimationToEnd('more-settings'); | 889 }); |
| 890 this.waitForAnimationToEnd('more-settings'); | |
| 891 }.bind(this)); | |
| 798 }); | 892 }); |
| 799 | 893 |
| 800 // Page layout has zero margins. Hide header and footer option. | 894 // Page layout has zero margins. Hide header and footer option. |
| 801 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter', | 895 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter', |
| 802 function() { | 896 function() { |
| 803 this.setInitialSettings(); | 897 this.setInitialSettings(); |
| 804 this.setLocalDestinations(); | 898 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 805 this.setCapabilities(getCddTemplate("FooDevice")); | 899 function() { |
| 900 this.setLocalDestinations(); | |
| 901 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 806 | 902 |
| 807 var otherOptions = $('other-options-settings'); | 903 var otherOptions = $('other-options-settings'); |
| 808 var headerFooter = otherOptions.querySelector('#header-footer-container'); | 904 var headerFooter = |
| 905 otherOptions.querySelector('#header-footer-container'); | |
| 809 | 906 |
| 810 // Check that options are collapsed (section is visible, because duplex is | 907 // Check that options are collapsed (section is visible, because duplex |
| 811 // available). | 908 // is available). |
| 812 checkSectionVisible(otherOptions, true); | 909 checkSectionVisible(otherOptions, true); |
| 813 checkElementDisplayed(headerFooter, false); | 910 checkElementDisplayed(headerFooter, false); |
| 814 | 911 |
| 815 this.expandMoreSettings(); | 912 this.expandMoreSettings(); |
| 816 | 913 |
| 817 checkElementDisplayed(headerFooter, true); | 914 checkElementDisplayed(headerFooter, true); |
| 818 | 915 |
| 819 printPreview.printTicketStore_.marginsType.updateValue( | 916 printPreview.printTicketStore_.marginsType.updateValue( |
| 820 print_preview.ticket_items.MarginsTypeValue.CUSTOM); | 917 print_preview.ticket_items.MarginsTypeValue.CUSTOM); |
| 821 printPreview.printTicketStore_.customMargins.updateValue( | 918 printPreview.printTicketStore_.customMargins.updateValue( |
| 822 new print_preview.Margins(0, 0, 0, 0)); | 919 new print_preview.Margins(0, 0, 0, 0)); |
| 823 | 920 |
| 824 checkElementDisplayed(headerFooter, false); | 921 checkElementDisplayed(headerFooter, false); |
| 825 | 922 |
| 826 this.waitForAnimationToEnd('more-settings'); | 923 this.waitForAnimationToEnd('more-settings'); |
| 924 }.bind(this)); | |
| 827 }); | 925 }); |
| 828 | 926 |
| 829 // Page layout has half-inch margins. Show header and footer option. | 927 // Page layout has half-inch margins. Show header and footer option. |
| 830 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter', | 928 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter', |
| 831 function() { | 929 function() { |
| 832 this.setInitialSettings(); | 930 this.setInitialSettings(); |
| 833 this.setLocalDestinations(); | 931 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 834 this.setCapabilities(getCddTemplate("FooDevice")); | 932 function() { |
| 933 this.setLocalDestinations(); | |
| 934 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 835 | 935 |
| 836 var otherOptions = $('other-options-settings'); | 936 var otherOptions = $('other-options-settings'); |
| 837 var headerFooter = otherOptions.querySelector('#header-footer-container'); | 937 var headerFooter = |
| 938 otherOptions.querySelector('#header-footer-container'); | |
| 838 | 939 |
| 839 // Check that options are collapsed (section is visible, because duplex is | 940 // Check that options are collapsed (section is visible, because duplex |
| 840 // available). | 941 // is available). |
| 841 checkSectionVisible(otherOptions, true); | 942 checkSectionVisible(otherOptions, true); |
| 842 checkElementDisplayed(headerFooter, false); | 943 checkElementDisplayed(headerFooter, false); |
| 843 | 944 |
| 844 this.expandMoreSettings(); | 945 this.expandMoreSettings(); |
| 845 | 946 |
| 846 checkElementDisplayed(headerFooter, true); | 947 checkElementDisplayed(headerFooter, true); |
| 847 | 948 |
| 848 printPreview.printTicketStore_.marginsType.updateValue( | 949 printPreview.printTicketStore_.marginsType.updateValue( |
| 849 print_preview.ticket_items.MarginsTypeValue.CUSTOM); | 950 print_preview.ticket_items.MarginsTypeValue.CUSTOM); |
| 850 printPreview.printTicketStore_.customMargins.updateValue( | 951 printPreview.printTicketStore_.customMargins.updateValue( |
| 851 new print_preview.Margins(36, 36, 36, 36)); | 952 new print_preview.Margins(36, 36, 36, 36)); |
| 852 | 953 |
| 853 checkElementDisplayed(headerFooter, true); | 954 checkElementDisplayed(headerFooter, true); |
| 854 | 955 |
| 855 this.waitForAnimationToEnd('more-settings'); | 956 this.waitForAnimationToEnd('more-settings'); |
| 957 }.bind(this)); | |
| 856 }); | 958 }); |
| 857 | 959 |
| 858 // Page layout has zero top and bottom margins. Hide header and footer option. | 960 // Page layout has zero top and bottom margins. Hide header and footer option. |
| 859 TEST_F('PrintPreviewWebUITest', | 961 TEST_F('PrintPreviewWebUITest', |
| 860 'ZeroTopAndBottomMarginsHideHeaderFooter', | 962 'ZeroTopAndBottomMarginsHideHeaderFooter', |
| 861 function() { | 963 function() { |
| 862 this.setInitialSettings(); | 964 this.setInitialSettings(); |
| 863 this.setLocalDestinations(); | 965 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 864 this.setCapabilities(getCddTemplate("FooDevice")); | 966 function() { |
| 967 this.setLocalDestinations(); | |
| 968 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 865 | 969 |
| 866 var otherOptions = $('other-options-settings'); | 970 var otherOptions = $('other-options-settings'); |
| 867 var headerFooter = otherOptions.querySelector('#header-footer-container'); | 971 var headerFooter = |
| 972 otherOptions.querySelector('#header-footer-container'); | |
| 868 | 973 |
| 869 // Check that options are collapsed (section is visible, because duplex is | 974 // Check that options are collapsed (section is visible, because duplex |
| 870 // available). | 975 // is available). |
| 871 checkSectionVisible(otherOptions, true); | 976 checkSectionVisible(otherOptions, true); |
| 872 checkElementDisplayed(headerFooter, false); | 977 checkElementDisplayed(headerFooter, false); |
| 873 | 978 |
| 874 this.expandMoreSettings(); | 979 this.expandMoreSettings(); |
| 875 | 980 |
| 876 checkElementDisplayed(headerFooter, true); | 981 checkElementDisplayed(headerFooter, true); |
| 877 | 982 |
| 878 printPreview.printTicketStore_.marginsType.updateValue( | 983 printPreview.printTicketStore_.marginsType.updateValue( |
| 879 print_preview.ticket_items.MarginsTypeValue.CUSTOM); | 984 print_preview.ticket_items.MarginsTypeValue.CUSTOM); |
| 880 printPreview.printTicketStore_.customMargins.updateValue( | 985 printPreview.printTicketStore_.customMargins.updateValue( |
| 881 new print_preview.Margins(0, 36, 0, 36)); | 986 new print_preview.Margins(0, 36, 0, 36)); |
| 882 | 987 |
| 883 checkElementDisplayed(headerFooter, false); | 988 checkElementDisplayed(headerFooter, false); |
| 884 | 989 |
| 885 this.waitForAnimationToEnd('more-settings'); | 990 this.waitForAnimationToEnd('more-settings'); |
| 991 }.bind(this)); | |
| 886 }); | 992 }); |
| 887 | 993 |
| 888 // Page layout has zero top and half-inch bottom margin. Show header and footer | 994 // Page layout has zero top and half-inch bottom margin. Show header and footer |
| 889 // option. | 995 // option. |
| 890 TEST_F('PrintPreviewWebUITest', | 996 TEST_F('PrintPreviewWebUITest', |
| 891 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter', | 997 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter', |
| 892 function() { | 998 function() { |
| 893 this.setInitialSettings(); | 999 this.setInitialSettings(); |
| 894 this.setLocalDestinations(); | 1000 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 895 this.setCapabilities(getCddTemplate("FooDevice")); | 1001 function() { |
| 1002 this.setLocalDestinations(); | |
| 1003 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 896 | 1004 |
| 897 var otherOptions = $('other-options-settings'); | 1005 var otherOptions = $('other-options-settings'); |
| 898 var headerFooter = otherOptions.querySelector('#header-footer-container'); | 1006 var headerFooter = |
| 1007 otherOptions.querySelector('#header-footer-container'); | |
| 899 | 1008 |
| 900 // Check that options are collapsed (section is visible, because duplex is | 1009 // Check that options are collapsed (section is visible, because duplex |
| 901 // available). | 1010 // is available). |
| 902 checkSectionVisible(otherOptions, true); | 1011 checkSectionVisible(otherOptions, true); |
| 903 checkElementDisplayed(headerFooter, false); | 1012 checkElementDisplayed(headerFooter, false); |
| 904 | 1013 |
| 905 this.expandMoreSettings(); | 1014 this.expandMoreSettings(); |
| 906 | 1015 |
| 907 checkElementDisplayed(headerFooter, true); | 1016 checkElementDisplayed(headerFooter, true); |
| 908 | 1017 |
| 909 printPreview.printTicketStore_.marginsType.updateValue( | 1018 printPreview.printTicketStore_.marginsType.updateValue( |
| 910 print_preview.ticket_items.MarginsTypeValue.CUSTOM); | 1019 print_preview.ticket_items.MarginsTypeValue.CUSTOM); |
| 911 printPreview.printTicketStore_.customMargins.updateValue( | 1020 printPreview.printTicketStore_.customMargins.updateValue( |
| 912 new print_preview.Margins(0, 36, 36, 36)); | 1021 new print_preview.Margins(0, 36, 36, 36)); |
| 913 | 1022 |
| 914 checkElementDisplayed(headerFooter, true); | 1023 checkElementDisplayed(headerFooter, true); |
| 915 | 1024 |
| 916 this.waitForAnimationToEnd('more-settings'); | 1025 this.waitForAnimationToEnd('more-settings'); |
| 1026 }.bind(this)); | |
| 917 }); | 1027 }); |
| 918 | 1028 |
| 919 // Check header footer availability with small (label) page size. | 1029 // Check header footer availability with small (label) page size. |
| 920 TEST_F('PrintPreviewWebUITest', 'SmallPaperSizeHeaderFooter', function() { | 1030 TEST_F('PrintPreviewWebUITest', 'SmallPaperSizeHeaderFooter', function() { |
| 921 this.setInitialSettings(); | 1031 this.setInitialSettings(); |
| 922 this.setLocalDestinations(); | 1032 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 923 var device = getCddTemplate("FooDevice"); | 1033 function() { |
| 924 device.capabilities.printer.media_size = { | 1034 this.setLocalDestinations(); |
| 925 "option": [ | 1035 var device = getCddTemplate("FooDevice"); |
| 926 {"name": "SmallLabel", "width_microns": 38100, "height_microns": 12700, | 1036 device.capabilities.printer.media_size = { |
| 927 "is_default": false}, | 1037 "option": [ |
| 928 {"name": "BigLabel", "width_microns": 50800, "height_microns": 76200, | 1038 {"name": "SmallLabel", "width_microns": 38100, |
| 929 "is_default": true} | 1039 "height_microns": 12700, "is_default": false}, |
| 930 ] | 1040 {"name": "BigLabel", "width_microns": 50800, |
| 931 }; | 1041 "height_microns": 76200, "is_default": true} |
| 932 this.setCapabilities(device); | 1042 ] |
| 1043 }; | |
| 1044 this.setCapabilities(device); | |
| 933 | 1045 |
| 934 var otherOptions = $('other-options-settings'); | 1046 var otherOptions = $('other-options-settings'); |
| 935 var headerFooter = otherOptions.querySelector('#header-footer-container'); | 1047 var headerFooter = |
| 1048 otherOptions.querySelector('#header-footer-container'); | |
| 936 | 1049 |
| 937 // Check that options are collapsed (section is visible, because duplex is | 1050 // Check that options are collapsed (section is visible, because duplex |
| 938 // available). | 1051 // is available). |
| 939 checkSectionVisible(otherOptions, true); | 1052 checkSectionVisible(otherOptions, true); |
| 940 checkElementDisplayed(headerFooter, false); | 1053 checkElementDisplayed(headerFooter, false); |
| 941 | 1054 |
| 942 this.expandMoreSettings(); | 1055 this.expandMoreSettings(); |
| 943 | 1056 |
| 944 // Big label should have header/footer | 1057 // Big label should have header/footer |
| 945 checkElementDisplayed(headerFooter, true); | 1058 checkElementDisplayed(headerFooter, true); |
| 946 | 1059 |
| 947 // Small label should not | 1060 // Small label should not |
| 948 printPreview.printTicketStore_.mediaSize.updateValue( | 1061 printPreview.printTicketStore_.mediaSize.updateValue( |
| 949 device.capabilities.printer.media_size.option[0]); | 1062 device.capabilities.printer.media_size.option[0]); |
| 950 checkElementDisplayed(headerFooter, false); | 1063 checkElementDisplayed(headerFooter, false); |
| 951 | 1064 |
| 952 // Oriented in landscape, there should be enough space for header/footer. | 1065 // Oriented in landscape, there should be enough space for |
| 953 printPreview.printTicketStore_.landscape.updateValue(true); | 1066 // header/footer. |
| 954 checkElementDisplayed(headerFooter, true); | 1067 printPreview.printTicketStore_.landscape.updateValue(true); |
| 1068 checkElementDisplayed(headerFooter, true); | |
| 955 | 1069 |
| 956 this.waitForAnimationToEnd('more-settings'); | 1070 this.waitForAnimationToEnd('more-settings'); |
| 1071 }.bind(this)); | |
| 957 }); | 1072 }); |
| 958 | 1073 |
| 959 // Test that the color settings, one option, standard monochrome. | 1074 // Test that the color settings, one option, standard monochrome. |
| 960 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() { | 1075 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() { |
| 961 this.setInitialSettings(); | 1076 this.setInitialSettings(); |
| 962 this.setLocalDestinations(); | 1077 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1078 function() { | |
| 1079 this.setLocalDestinations(); | |
| 963 | 1080 |
| 964 // Only one option, standard monochrome. | 1081 // Only one option, standard monochrome. |
| 965 var device = getCddTemplate("FooDevice"); | 1082 var device = getCddTemplate("FooDevice"); |
| 966 device.capabilities.printer.color = { | 1083 device.capabilities.printer.color = { |
| 967 "option": [ | 1084 "option": [ |
| 968 {"is_default": true, "type": "STANDARD_MONOCHROME"} | 1085 {"is_default": true, "type": "STANDARD_MONOCHROME"} |
| 969 ] | 1086 ] |
| 970 }; | 1087 }; |
| 971 this.setCapabilities(device); | 1088 this.setCapabilities(device); |
| 972 | 1089 |
| 973 checkSectionVisible($('color-settings'), false); | 1090 checkSectionVisible($('color-settings'), false); |
| 974 | 1091 |
| 975 this.waitForAnimationToEnd('more-settings'); | 1092 this.waitForAnimationToEnd('more-settings'); |
| 1093 }.bind(this)); | |
| 976 }); | 1094 }); |
| 977 | 1095 |
| 978 // Test that the color settings, one option, custom monochrome. | 1096 // Test that the color settings, one option, custom monochrome. |
| 979 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome', | 1097 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome', |
| 980 function() { | 1098 function() { |
| 981 this.setInitialSettings(); | 1099 this.setInitialSettings(); |
| 982 this.setLocalDestinations(); | 1100 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1101 function() { | |
| 1102 this.setLocalDestinations(); | |
| 983 | 1103 |
| 984 // Only one option, standard monochrome. | 1104 // Only one option, standard monochrome. |
| 985 var device = getCddTemplate("FooDevice"); | 1105 var device = getCddTemplate("FooDevice"); |
| 986 device.capabilities.printer.color = { | 1106 device.capabilities.printer.color = { |
| 987 "option": [ | 1107 "option": [ |
| 988 {"is_default": true, "type": "CUSTOM_MONOCHROME", "vendor_id": "42"} | 1108 {"is_default": true, "type": "CUSTOM_MONOCHROME", |
| 989 ] | 1109 "vendor_id": "42"} |
| 990 }; | 1110 ] |
| 991 this.setCapabilities(device); | 1111 }; |
| 1112 this.setCapabilities(device); | |
| 992 | 1113 |
| 993 checkSectionVisible($('color-settings'), false); | 1114 checkSectionVisible($('color-settings'), false); |
| 994 | 1115 |
| 995 this.waitForAnimationToEnd('more-settings'); | 1116 this.waitForAnimationToEnd('more-settings'); |
| 1117 }.bind(this)); | |
| 996 }); | 1118 }); |
| 997 | 1119 |
| 998 // Test that the color settings, one option, standard color. | 1120 // Test that the color settings, one option, standard color. |
| 999 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() { | 1121 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() { |
| 1000 this.setInitialSettings(); | 1122 this.setInitialSettings(); |
| 1001 this.setLocalDestinations(); | 1123 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1124 function() { | |
| 1125 this.setLocalDestinations(); | |
| 1002 | 1126 |
| 1003 var device = getCddTemplate("FooDevice"); | 1127 var device = getCddTemplate("FooDevice"); |
| 1004 device.capabilities.printer.color = { | 1128 device.capabilities.printer.color = { |
| 1005 "option": [ | 1129 "option": [ |
| 1006 {"is_default": true, "type": "STANDARD_COLOR"} | 1130 {"is_default": true, "type": "STANDARD_COLOR"} |
| 1007 ] | 1131 ] |
| 1008 }; | 1132 }; |
| 1009 this.setCapabilities(device); | 1133 this.setCapabilities(device); |
| 1010 | 1134 |
| 1011 checkSectionVisible($('color-settings'), false); | 1135 checkSectionVisible($('color-settings'), false); |
| 1012 | 1136 |
| 1013 this.waitForAnimationToEnd('more-settings'); | 1137 this.waitForAnimationToEnd('more-settings'); |
| 1138 }.bind(this)); | |
| 1014 }); | 1139 }); |
| 1015 | 1140 |
| 1016 // Test that the color settings, one option, custom color. | 1141 // Test that the color settings, one option, custom color. |
| 1017 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() { | 1142 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() { |
| 1018 this.setInitialSettings(); | 1143 this.setInitialSettings(); |
| 1019 this.setLocalDestinations(); | 1144 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1145 function() { | |
| 1146 this.setLocalDestinations(); | |
| 1020 | 1147 |
| 1021 var device = getCddTemplate("FooDevice"); | 1148 var device = getCddTemplate("FooDevice"); |
| 1022 device.capabilities.printer.color = { | 1149 device.capabilities.printer.color = { |
| 1023 "option": [ | 1150 "option": [ |
| 1024 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"} | 1151 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"} |
| 1025 ] | 1152 ] |
| 1026 }; | 1153 }; |
| 1027 this.setCapabilities(device); | 1154 this.setCapabilities(device); |
| 1028 | 1155 |
| 1029 checkSectionVisible($('color-settings'), false); | 1156 checkSectionVisible($('color-settings'), false); |
| 1030 | 1157 |
| 1031 this.waitForAnimationToEnd('more-settings'); | 1158 this.waitForAnimationToEnd('more-settings'); |
| 1159 }.bind(this)); | |
| 1032 }); | 1160 }); |
| 1033 | 1161 |
| 1034 // Test that the color settings, two options, both standard, defaults to color. | 1162 // Test that the color settings, two options, both standard, defaults to color. |
| 1035 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor', | 1163 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor', |
| 1036 function() { | 1164 function() { |
| 1037 this.setInitialSettings(); | 1165 this.setInitialSettings(); |
| 1038 this.setLocalDestinations(); | 1166 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1167 function() { | |
| 1168 this.setLocalDestinations(); | |
| 1039 | 1169 |
| 1040 var device = getCddTemplate("FooDevice"); | 1170 var device = getCddTemplate("FooDevice"); |
| 1041 device.capabilities.printer.color = { | 1171 device.capabilities.printer.color = { |
| 1042 "option": [ | 1172 "option": [ |
| 1043 {"type": "STANDARD_MONOCHROME"}, | 1173 {"type": "STANDARD_MONOCHROME"}, |
| 1044 {"is_default": true, "type": "STANDARD_COLOR"} | 1174 {"is_default": true, "type": "STANDARD_COLOR"} |
| 1045 ] | 1175 ] |
| 1046 }; | 1176 }; |
| 1047 this.setCapabilities(device); | 1177 this.setCapabilities(device); |
| 1048 | 1178 |
| 1049 checkSectionVisible($('color-settings'), true); | 1179 checkSectionVisible($('color-settings'), true); |
| 1050 expectEquals( | 1180 expectEquals( |
| 1051 'color', | 1181 'color', |
| 1052 $('color-settings').querySelector('.color-settings-select').value); | 1182 $('color-settings').querySelector('.color-settings-select').value); |
| 1053 | 1183 |
| 1054 this.waitForAnimationToEnd('more-settings'); | 1184 this.waitForAnimationToEnd('more-settings'); |
| 1185 }.bind(this)); | |
| 1055 }); | 1186 }); |
| 1056 | 1187 |
| 1057 // Test that the color settings, two options, both standard, defaults to | 1188 // Test that the color settings, two options, both standard, defaults to |
| 1058 // monochrome. | 1189 // monochrome. |
| 1059 TEST_F('PrintPreviewWebUITest', | 1190 TEST_F('PrintPreviewWebUITest', |
| 1060 'TestColorSettingsBothStandardDefaultMonochrome', function() { | 1191 'TestColorSettingsBothStandardDefaultMonochrome', function() { |
| 1061 this.setInitialSettings(); | 1192 this.setInitialSettings(); |
| 1062 this.setLocalDestinations(); | 1193 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1063 | 1194 function() { |
| 1064 var device = getCddTemplate("FooDevice"); | 1195 this.setLocalDestinations(); |
| 1065 device.capabilities.printer.color = { | 1196 |
| 1066 "option": [ | 1197 var device = getCddTemplate("FooDevice"); |
| 1067 {"is_default": true, "type": "STANDARD_MONOCHROME"}, | 1198 device.capabilities.printer.color = { |
| 1068 {"type": "STANDARD_COLOR"} | 1199 "option": [ |
| 1069 ] | 1200 {"is_default": true, "type": "STANDARD_MONOCHROME"}, |
| 1070 }; | 1201 {"type": "STANDARD_COLOR"} |
| 1071 this.setCapabilities(device); | 1202 ] |
| 1072 | 1203 }; |
| 1073 checkSectionVisible($('color-settings'), true); | 1204 this.setCapabilities(device); |
| 1074 expectEquals( | 1205 |
| 1075 'bw', $('color-settings').querySelector('.color-settings-select').value); | 1206 checkSectionVisible($('color-settings'), true); |
| 1076 | 1207 expectEquals( |
| 1077 this.waitForAnimationToEnd('more-settings'); | 1208 'bw', |
| 1209 $('color-settings').querySelector('.color-settings-select').value); | |
| 1210 | |
| 1211 this.waitForAnimationToEnd('more-settings'); | |
| 1212 }.bind(this)); | |
| 1078 }); | 1213 }); |
| 1079 | 1214 |
| 1080 // Test that the color settings, two options, both custom, defaults to color. | 1215 // Test that the color settings, two options, both custom, defaults to color. |
| 1081 TEST_F('PrintPreviewWebUITest', | 1216 TEST_F('PrintPreviewWebUITest', |
| 1082 'TestColorSettingsBothCustomDefaultColor', function() { | 1217 'TestColorSettingsBothCustomDefaultColor', function() { |
| 1083 this.setInitialSettings(); | 1218 this.setInitialSettings(); |
| 1084 this.setLocalDestinations(); | 1219 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1085 | 1220 function() { |
| 1086 var device = getCddTemplate("FooDevice"); | 1221 this.setLocalDestinations(); |
| 1087 device.capabilities.printer.color = { | 1222 |
| 1088 "option": [ | 1223 var device = getCddTemplate("FooDevice"); |
| 1089 {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"}, | 1224 device.capabilities.printer.color = { |
| 1090 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"} | 1225 "option": [ |
| 1091 ] | 1226 {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"}, |
| 1092 }; | 1227 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"} |
| 1093 this.setCapabilities(device); | 1228 ] |
| 1094 | 1229 }; |
| 1095 checkSectionVisible($('color-settings'), true); | 1230 this.setCapabilities(device); |
| 1096 expectEquals( | 1231 |
| 1097 'color', | 1232 checkSectionVisible($('color-settings'), true); |
| 1098 $('color-settings').querySelector('.color-settings-select').value); | 1233 expectEquals( |
| 1099 | 1234 'color', |
| 1100 this.waitForAnimationToEnd('more-settings'); | 1235 $('color-settings').querySelector('.color-settings-select').value); |
| 1236 | |
| 1237 this.waitForAnimationToEnd('more-settings'); | |
| 1238 }.bind(this)); | |
| 1101 }); | 1239 }); |
| 1102 | 1240 |
| 1103 // Test to verify that duplex settings are set according to the printer | 1241 // Test to verify that duplex settings are set according to the printer |
| 1104 // capabilities. | 1242 // capabilities. |
| 1105 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { | 1243 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { |
| 1106 this.setInitialSettings(); | 1244 this.setInitialSettings(); |
| 1107 this.setLocalDestinations(); | 1245 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1108 this.setCapabilities(getCddTemplate("FooDevice")); | 1246 function() { |
| 1109 | 1247 this.setLocalDestinations(); |
| 1110 var otherOptions = $('other-options-settings'); | 1248 this.setCapabilities(getCddTemplate("FooDevice")); |
| 1111 checkSectionVisible(otherOptions, true); | 1249 |
| 1112 duplexContainer = otherOptions.querySelector('#duplex-container'); | 1250 var otherOptions = $('other-options-settings'); |
| 1113 expectFalse(duplexContainer.hidden); | 1251 checkSectionVisible(otherOptions, true); |
| 1114 expectFalse(duplexContainer.querySelector('.checkbox').checked); | 1252 duplexContainer = otherOptions.querySelector('#duplex-container'); |
| 1115 | 1253 expectFalse(duplexContainer.hidden); |
| 1116 this.waitForAnimationToEnd('more-settings'); | 1254 expectFalse(duplexContainer.querySelector('.checkbox').checked); |
| 1255 | |
| 1256 this.waitForAnimationToEnd('more-settings'); | |
| 1257 }.bind(this)); | |
| 1117 }); | 1258 }); |
| 1118 | 1259 |
| 1119 // Test to verify that duplex settings are set according to the printer | 1260 // Test to verify that duplex settings are set according to the printer |
| 1120 // capabilities. | 1261 // capabilities. |
| 1121 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { | 1262 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { |
| 1122 this.setInitialSettings(); | 1263 this.setInitialSettings(); |
| 1123 this.setLocalDestinations(); | 1264 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1124 var device = getCddTemplate("FooDevice"); | 1265 function() { |
| 1125 delete device.capabilities.printer.duplex; | 1266 this.setLocalDestinations(); |
| 1126 this.setCapabilities(device); | 1267 var device = getCddTemplate("FooDevice"); |
| 1127 | 1268 delete device.capabilities.printer.duplex; |
| 1128 // Check that it is collapsed. | 1269 this.setCapabilities(device); |
| 1129 var otherOptions = $('other-options-settings'); | 1270 |
| 1130 checkSectionVisible(otherOptions, false); | 1271 // Check that it is collapsed. |
| 1131 | 1272 var otherOptions = $('other-options-settings'); |
| 1132 this.expandMoreSettings(); | 1273 checkSectionVisible(otherOptions, false); |
| 1133 | 1274 |
| 1134 // Now it should be visible. | 1275 this.expandMoreSettings(); |
| 1135 checkSectionVisible(otherOptions, true); | 1276 |
| 1136 expectTrue(otherOptions.querySelector('#duplex-container').hidden); | 1277 // Now it should be visible. |
| 1137 | 1278 checkSectionVisible(otherOptions, true); |
| 1138 this.waitForAnimationToEnd('more-settings'); | 1279 expectTrue(otherOptions.querySelector('#duplex-container').hidden); |
| 1280 | |
| 1281 this.waitForAnimationToEnd('more-settings'); | |
| 1282 }.bind(this)); | |
| 1139 }); | 1283 }); |
| 1140 | 1284 |
| 1141 // Test that changing the selected printer updates the preview. | 1285 // Test that changing the selected printer updates the preview. |
| 1142 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { | 1286 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { |
| 1143 this.setInitialSettings(); | 1287 this.setInitialSettings(); |
| 1144 this.setLocalDestinations(); | 1288 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1145 this.setCapabilities(getCddTemplate("FooDevice")); | 1289 function() { |
| 1146 | 1290 this.setLocalDestinations(); |
| 1147 var previewGenerator = mock(print_preview.PreviewGenerator); | 1291 this.setCapabilities(getCddTemplate("FooDevice")); |
| 1148 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); | 1292 |
| 1149 | 1293 var previewGenerator = mock(print_preview.PreviewGenerator); |
| 1150 // The number of settings that can change due to a change in the destination | 1294 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); |
| 1151 // that will therefore dispatch ticket item change events. | 1295 |
| 1152 previewGenerator.expects(exactly(9)).requestPreview(); | 1296 // The number of settings that can change due to a change in the |
| 1153 | 1297 // destination that will therefore dispatch ticket item change events. |
| 1154 var barDestination = | 1298 previewGenerator.expects(exactly(9)).requestPreview(); |
| 1155 printPreview.destinationStore_.destinations().find(function(d) { | 1299 |
| 1156 return d.id == 'BarDevice'; | 1300 var barDestination = |
| 1157 }); | 1301 printPreview.destinationStore_.destinations().find(function(d) { |
| 1158 | 1302 return d.id == 'BarDevice'; |
| 1159 printPreview.destinationStore_.selectDestination(barDestination); | 1303 }); |
| 1160 | 1304 |
| 1161 var device = getCddTemplate("BarDevice"); | 1305 printPreview.destinationStore_.selectDestination(barDestination); |
| 1162 device.capabilities.printer.color = { | 1306 |
| 1163 "option": [ | 1307 var device = getCddTemplate("BarDevice"); |
| 1164 {"is_default": true, "type": "STANDARD_MONOCHROME"} | 1308 device.capabilities.printer.color = { |
| 1165 ] | 1309 "option": [ |
| 1166 }; | 1310 {"is_default": true, "type": "STANDARD_MONOCHROME"} |
| 1167 this.setCapabilities(device); | 1311 ] |
| 1168 | 1312 }; |
| 1169 this.waitForAnimationToEnd('more-settings'); | 1313 this.setCapabilities(device); |
| 1314 | |
| 1315 this.waitForAnimationToEnd('more-settings'); | |
| 1316 }.bind(this)); | |
| 1170 }); | 1317 }); |
| 1171 | 1318 |
| 1172 // Test that error message is displayed when plugin doesn't exist. | 1319 // Test that error message is displayed when plugin doesn't exist. |
| 1173 TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() { | 1320 TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() { |
| 1174 var previewAreaEl = $('preview-area'); | 1321 this.setInitialSettings(); |
| 1175 | 1322 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1176 var loadingMessageEl = | 1323 function() { |
| 1177 previewAreaEl.getElementsByClassName('preview-area-loading-message')[0]; | 1324 var previewAreaEl = $('preview-area'); |
| 1178 expectTrue(loadingMessageEl.hidden); | 1325 |
| 1179 | 1326 var loadingMessageEl = |
| 1180 var previewFailedMessageEl = previewAreaEl.getElementsByClassName( | 1327 previewAreaEl. |
| 1181 'preview-area-preview-failed-message')[0]; | 1328 getElementsByClassName('preview-area-loading-message')[0]; |
| 1182 expectTrue(previewFailedMessageEl.hidden); | 1329 expectTrue(loadingMessageEl.hidden); |
| 1183 | 1330 |
| 1184 var printFailedMessageEl = | 1331 var previewFailedMessageEl = previewAreaEl.getElementsByClassName( |
| 1185 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; | 1332 'preview-area-preview-failed-message')[0]; |
| 1186 expectTrue(printFailedMessageEl.hidden); | 1333 expectTrue(previewFailedMessageEl.hidden); |
| 1187 | 1334 |
| 1188 var customMessageEl = | 1335 var printFailedMessageEl = |
| 1189 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; | 1336 previewAreaEl. |
| 1190 expectFalse(customMessageEl.hidden); | 1337 getElementsByClassName('preview-area-print-failed')[0]; |
| 1191 | 1338 expectTrue(printFailedMessageEl.hidden); |
| 1192 testDone(); | 1339 |
| 1340 var customMessageEl = | |
| 1341 previewAreaEl. | |
| 1342 getElementsByClassName('preview-area-custom-message')[0]; | |
| 1343 expectFalse(customMessageEl.hidden); | |
| 1344 | |
| 1345 testDone(); | |
| 1346 }); | |
| 1193 }); | 1347 }); |
| 1194 | 1348 |
| 1195 // Test custom localized paper names. | 1349 // Test custom localized paper names. |
| 1196 TEST_F('PrintPreviewWebUITest', 'TestCustomPaperNames', function() { | 1350 TEST_F('PrintPreviewWebUITest', 'TestCustomPaperNames', function() { |
| 1197 this.setInitialSettings(); | 1351 this.setInitialSettings(); |
| 1198 this.setLocalDestinations(); | 1352 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1199 | 1353 function() { |
| 1200 var customLocalizedMediaName = 'Vendor defined localized media name'; | 1354 this.setLocalDestinations(); |
| 1201 var customMediaName = 'Vendor defined media name'; | 1355 |
| 1202 | 1356 var customLocalizedMediaName = 'Vendor defined localized media name'; |
| 1203 var device = getCddTemplate("FooDevice"); | 1357 var customMediaName = 'Vendor defined media name'; |
| 1204 device.capabilities.printer.media_size = { | 1358 |
| 1205 option: [ | 1359 var device = getCddTemplate("FooDevice"); |
| 1206 { name: 'CUSTOM', | 1360 device.capabilities.printer.media_size = { |
| 1207 width_microns: 15900, | 1361 option: [ |
| 1208 height_microns: 79400, | 1362 { name: 'CUSTOM', |
| 1209 is_default: true, | 1363 width_microns: 15900, |
| 1210 custom_display_name_localized: [ | 1364 height_microns: 79400, |
| 1211 { locale: navigator.language, | 1365 is_default: true, |
| 1212 value: customLocalizedMediaName | 1366 custom_display_name_localized: [ |
| 1213 } | 1367 { locale: navigator.language, |
| 1214 ] | 1368 value: customLocalizedMediaName |
| 1215 }, | 1369 } |
| 1216 { name: 'CUSTOM', | 1370 ] |
| 1217 width_microns: 15900, | 1371 }, |
| 1218 height_microns: 79400, | 1372 { name: 'CUSTOM', |
| 1219 custom_display_name: customMediaName | 1373 width_microns: 15900, |
| 1220 } | 1374 height_microns: 79400, |
| 1221 ] | 1375 custom_display_name: customMediaName |
| 1222 }; | 1376 } |
| 1223 | 1377 ] |
| 1224 this.setCapabilities(device); | 1378 }; |
| 1225 | 1379 |
| 1226 this.expandMoreSettings(); | 1380 this.setCapabilities(device); |
| 1227 | 1381 |
| 1228 checkSectionVisible($('media-size-settings'), true); | 1382 this.expandMoreSettings(); |
| 1229 var mediaSelect = $('media-size-settings').querySelector('.settings-select'); | 1383 |
| 1230 // Check the default media item. | 1384 checkSectionVisible($('media-size-settings'), true); |
| 1231 expectEquals( | 1385 var mediaSelect = |
| 1232 customLocalizedMediaName, | 1386 $('media-size-settings').querySelector('.settings-select'); |
| 1233 mediaSelect.options[mediaSelect.selectedIndex].text); | 1387 // Check the default media item. |
| 1234 // Check the other media item. | 1388 expectEquals( |
| 1235 expectEquals( | 1389 customLocalizedMediaName, |
| 1236 customMediaName, | 1390 mediaSelect.options[mediaSelect.selectedIndex].text); |
| 1237 mediaSelect.options[mediaSelect.selectedIndex == 0 ? 1 : 0].text); | 1391 // Check the other media item. |
| 1238 | 1392 expectEquals( |
| 1239 this.waitForAnimationToEnd('more-settings'); | 1393 customMediaName, |
| 1394 mediaSelect.options[mediaSelect.selectedIndex == 0 ? 1 : 0].text); | |
| 1395 | |
| 1396 this.waitForAnimationToEnd('more-settings'); | |
| 1397 }.bind(this)); | |
| 1240 }); | 1398 }); |
| 1241 | 1399 |
| 1242 function getCddTemplateWithAdvancedSettings(printerId) { | 1400 function getCddTemplateWithAdvancedSettings(printerId) { |
| 1243 return { | 1401 return { |
| 1244 printerId: printerId, | 1402 printerId: printerId, |
| 1245 capabilities: { | 1403 capabilities: { |
| 1246 version: '1.0', | 1404 version: '1.0', |
| 1247 printer: { | 1405 printer: { |
| 1248 supported_content_type: [{content_type: 'application/pdf'}], | 1406 supported_content_type: [{content_type: 'application/pdf'}], |
| 1249 vendor_capability: | 1407 vendor_capability: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1308 // testPluginCompatibility() being set to always return false. Enable button | 1466 // testPluginCompatibility() being set to always return false. Enable button |
| 1309 // to send click event. | 1467 // to send click event. |
| 1310 advancedOptionsSettingsButton.disabled = false; | 1468 advancedOptionsSettingsButton.disabled = false; |
| 1311 advancedOptionsSettingsButton.click(); | 1469 advancedOptionsSettingsButton.click(); |
| 1312 } | 1470 } |
| 1313 | 1471 |
| 1314 // Test advanced settings with 1 capability (should not display settings search | 1472 // Test advanced settings with 1 capability (should not display settings search |
| 1315 // box). | 1473 // box). |
| 1316 TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings1Option', function() { | 1474 TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings1Option', function() { |
| 1317 var device = getCddTemplateWithAdvancedSettings("FooDevice"); | 1475 var device = getCddTemplateWithAdvancedSettings("FooDevice"); |
| 1318 this.setupAdvancedSettingsTest(device); | 1476 this.accessibilityIssuesAreErrors = false; |
| 1477 this.setInitialSettings(); | |
| 1478 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( | |
| 1479 function() { | |
| 1480 this.setupAdvancedSettingsTest(device); | |
| 1319 | 1481 |
| 1320 // Open the advanced settings overlay. | 1482 // Open the advanced settings overlay. |
| 1321 openAdvancedSettings(); | 1483 openAdvancedSettings(); |
| 1322 | 1484 |
| 1323 // Check that advanced settings close button is now visible, | 1485 // Check that advanced settings close button is now visible, |
| 1324 // but not the search box (only 1 capability). | 1486 // but not the search box (only 1 capability). |
| 1325 var advancedSettingsCloseButton = $('advanced-settings'). | 1487 var advancedSettingsCloseButton = $('advanced-settings'). |
| 1326 querySelector('.close-button'); | 1488 querySelector('.close-button'); |
| 1327 checkElementDisplayed(advancedSettingsCloseButton, true); | 1489 checkElementDisplayed(advancedSettingsCloseButton, true); |
| 1328 checkElementDisplayed($('advanced-settings'). | 1490 checkElementDisplayed($('advanced-settings'). |
| 1329 querySelector('.search-box-area'), false); | 1491 querySelector('.search-box-area'), false); |
| 1330 | 1492 |
| 1331 this.waitForAnimationToEnd('more-settings'); | 1493 this.waitForAnimationToEnd('more-settings'); |
| 1494 }.bind(this)); | |
| 1332 }); | 1495 }); |
| 1333 | 1496 |
| 1334 | 1497 |
| 1335 // Test advanced settings with 2 capabilities (should have settings search box). | 1498 // Test advanced settings with 2 capabilities (should have settings search box). |
| 1336 TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings2Options', function() { | 1499 TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings2Options', function() { |
| 1337 var device = getCddTemplateWithAdvancedSettings("FooDevice"); | 1500 var device = getCddTemplateWithAdvancedSettings("FooDevice"); |
| 1338 // Add new capability. | 1501 // Add new capability. |
| 1339 device.capabilities.printer.vendor_capability.push({ | 1502 device.capabilities.printer.vendor_capability.push({ |
| 1340 display_name: 'Paper Type', | 1503 display_name: 'Paper Type', |
| 1341 id: 'Paper Type', | 1504 id: 'Paper Type', |
| 1342 type: 'SELECT', | 1505 type: 'SELECT', |
| 1343 select_cap: { | 1506 select_cap: { |
| 1344 option: [ | 1507 option: [ |
| 1345 {display_name: 'Standard', value: 0, is_default: true}, | 1508 {display_name: 'Standard', value: 0, is_default: true}, |
| 1346 {display_name: 'Recycled', value: 1}, | 1509 {display_name: 'Recycled', value: 1}, |
| 1347 {display_name: 'Special', value: 2} | 1510 {display_name: 'Special', value: 2} |
| 1348 ] | 1511 ] |
| 1349 } | 1512 } |
| 1350 }); | 1513 }); |
| 1351 this.setupAdvancedSettingsTest(device); | 1514 this.accessibilityIssuesAreErrors = false; |
| 1515 this.setInitialSettings(); | |
| 1516 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( | |
| 1517 function() { | |
| 1518 this.setupAdvancedSettingsTest(device); | |
| 1352 | 1519 |
| 1353 // Open the advanced settings overlay. | 1520 // Open the advanced settings overlay. |
| 1354 openAdvancedSettings(); | 1521 openAdvancedSettings(); |
| 1355 | 1522 |
| 1356 // Check advanced settings is visible and that the search box now | 1523 // Check advanced settings is visible and that the search box now |
| 1357 // appears. | 1524 // appears. |
| 1358 var advancedSettingsCloseButton = $('advanced-settings'). | 1525 var advancedSettingsCloseButton = $('advanced-settings'). |
| 1359 querySelector('.close-button'); | 1526 querySelector('.close-button'); |
| 1360 checkElementDisplayed(advancedSettingsCloseButton, true); | 1527 checkElementDisplayed(advancedSettingsCloseButton, true); |
| 1361 checkElementDisplayed($('advanced-settings'). | 1528 checkElementDisplayed($('advanced-settings'). |
| 1362 querySelector('.search-box-area'), true); | 1529 querySelector('.search-box-area'), true); |
| 1363 | 1530 |
| 1364 this.waitForAnimationToEnd('more-settings'); | 1531 this.waitForAnimationToEnd('more-settings'); |
| 1532 }.bind(this)); | |
| 1365 }); | 1533 }); |
| 1366 | 1534 |
| 1367 // Test that initialization with saved destination only issues one call | 1535 // Test that initialization with saved destination only issues one call |
| 1368 // to startPreview. | 1536 // to startPreview. |
| 1369 TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() { | 1537 TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() { |
| 1538 this.createPrintPreview(); | |
| 1370 // Load in a bunch of recent destinations with non null capabilities. | 1539 // Load in a bunch of recent destinations with non null capabilities. |
| 1371 var origin = cr.isChromeOS ? 'chrome_os' : 'local'; | 1540 var origin = cr.isChromeOS ? 'chrome_os' : 'local'; |
| 1372 var initSettings = { | 1541 var initSettings = { |
| 1373 version: 2, | 1542 version: 2, |
| 1374 recentDestinations: [1, 2, 3].map(function(i) { | 1543 recentDestinations: [1, 2, 3].map(function(i) { |
| 1375 return { | 1544 return { |
| 1376 id: 'ID' + i, origin: origin, account: '', | 1545 id: 'ID' + i, origin: origin, account: '', |
| 1377 capabilities: getCddTemplate('ID' + i), name: '', | 1546 capabilities: getCddTemplate('ID' + i), name: '', |
| 1378 extensionId: '', extensionName: '' | 1547 extensionId: '', extensionName: '' |
| 1379 }; | 1548 }; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1391 printPreview.documentInfo_); | 1560 printPreview.documentInfo_); |
| 1392 | 1561 |
| 1393 // Preview generator starts out with inFlightRequestId_ == -1. The id | 1562 // Preview generator starts out with inFlightRequestId_ == -1. The id |
| 1394 // increments by 1 for each startGetPreview call it makes. It should only | 1563 // increments by 1 for each startGetPreview call it makes. It should only |
| 1395 // make one such call during initialization or there will be a race; see | 1564 // make one such call during initialization or there will be a race; see |
| 1396 // crbug.com/666595 | 1565 // crbug.com/666595 |
| 1397 expectEquals( | 1566 expectEquals( |
| 1398 -1, | 1567 -1, |
| 1399 printPreview.previewArea_.previewGenerator_.inFlightRequestId_); | 1568 printPreview.previewArea_.previewGenerator_.inFlightRequestId_); |
| 1400 this.setInitialSettings(); | 1569 this.setInitialSettings(); |
| 1401 expectEquals( | 1570 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1402 0, | 1571 function() { |
| 1403 printPreview.previewArea_.previewGenerator_.inFlightRequestId_); | 1572 expectEquals( |
| 1404 testDone(); | 1573 0, |
| 1574 printPreview.previewArea_.previewGenerator_.inFlightRequestId_); | |
| 1575 testDone(); | |
| 1576 }); | |
| 1405 }); | 1577 }); |
| 1406 | 1578 |
| 1407 // Test that invalid settings errors disable the print preview and display | 1579 // Test that invalid settings errors disable the print preview and display |
| 1408 // an error and that the preview dialog can be recovered by selecting a | 1580 // an error and that the preview dialog can be recovered by selecting a |
| 1409 // new destination. | 1581 // new destination. |
| 1410 TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() { | 1582 TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() { |
| 1411 // Setup | 1583 // Setup |
| 1412 this.setInitialSettings(); | 1584 this.setInitialSettings(); |
| 1413 this.setLocalDestinations(); | 1585 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1414 this.setCapabilities(getCddTemplate("FooDevice")); | 1586 function() { |
| 1587 this.setLocalDestinations(); | |
| 1588 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 1415 | 1589 |
| 1416 // Manually enable the print header. This is needed since there is no | 1590 // Manually enable the print header. This is needed since there is no |
| 1417 // plugin during test, so it will be set as disabled normally. | 1591 // plugin during test, so it will be set as disabled normally. |
| 1418 printPreview.printHeader_.isEnabled = true; | 1592 printPreview.printHeader_.isEnabled = true; |
| 1419 | 1593 |
| 1420 // There will be an error message in the preview area since the plugin is | 1594 // There will be an error message in the preview area since the plugin |
| 1421 // not running. However, it should not be the invalid settings error. | 1595 // is not running. However, it should not be the invalid settings error. |
| 1422 var previewAreaEl = $('preview-area'); | 1596 var previewAreaEl = $('preview-area'); |
| 1423 var customMessageEl = | 1597 var customMessageEl = |
| 1424 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; | 1598 previewAreaEl. |
| 1425 expectFalse(customMessageEl.hidden); | 1599 getElementsByClassName('preview-area-custom-message')[0]; |
| 1426 var expectedMessageStart = 'The selected printer is not available or not ' + | 1600 expectFalse(customMessageEl.hidden); |
| 1427 'installed correctly.' | 1601 var expectedMessageStart = 'The selected printer is not available or ' |
| 1428 expectFalse(customMessageEl.textContent.includes(expectedMessageStart)); | 1602 + 'not installed correctly.' |
| 1603 expectFalse(customMessageEl.textContent.includes(expectedMessageStart)); | |
| 1429 | 1604 |
| 1430 // Verify that the print button is enabled. | 1605 // Verify that the print button is enabled. |
| 1431 var printHeader = $('print-header'); | 1606 var printHeader = $('print-header'); |
| 1432 var printButton = printHeader.querySelector('button.print'); | 1607 var printButton = printHeader.querySelector('button.print'); |
| 1433 checkElementDisplayed(printButton, true); | 1608 checkElementDisplayed(printButton, true); |
| 1434 expectFalse(printButton.disabled); | 1609 expectFalse(printButton.disabled); |
| 1435 | 1610 |
| 1436 // Report invalid settings error. | 1611 // Report invalid settings error. |
| 1437 this.dispatchInvalidSettings(); | 1612 this.dispatchInvalidSettings(); |
| 1438 | 1613 |
| 1439 // Should be in an error state, print button disabled, invalid custom error | 1614 // Should be in an error state, print button disabled, invalid custom |
| 1440 // message shown. | 1615 // error message shown. |
| 1441 expectFalse(customMessageEl.hidden); | 1616 expectFalse(customMessageEl.hidden); |
| 1442 expectTrue(customMessageEl.textContent.includes(expectedMessageStart)); | 1617 expectTrue(customMessageEl.textContent.includes(expectedMessageStart)); |
| 1443 expectTrue(printButton.disabled); | 1618 expectTrue(printButton.disabled); |
| 1444 | 1619 |
| 1445 // Select a new destination | 1620 // Select a new destination |
| 1446 var barDestination = | 1621 var barDestination = |
| 1447 printPreview.destinationStore_.destinations().find(function(d) { | 1622 printPreview.destinationStore_.destinations().find(function(d) { |
| 1448 return d.id == 'BarDevice'; | 1623 return d.id == 'BarDevice'; |
| 1449 }); | 1624 }); |
| 1450 | 1625 |
| 1451 printPreview.destinationStore_.selectDestination(barDestination); | 1626 printPreview.destinationStore_.selectDestination(barDestination); |
| 1452 | 1627 |
| 1453 // Dispatch events indicating capabilities were fetched and new preview has | 1628 // Dispatch events indicating capabilities were fetched and new preview |
| 1454 // loaded. | 1629 // has loaded. |
| 1455 this.setCapabilities(getCddTemplate("BarDevice")); | 1630 this.setCapabilities(getCddTemplate("BarDevice")); |
| 1456 this.dispatchPreviewDone(); | 1631 this.dispatchPreviewDone(); |
| 1457 | 1632 |
| 1458 // Has active print button and successfully "prints", indicating recovery | 1633 // Has active print button and successfully "prints", indicating |
| 1459 // from error state. | 1634 // recovery from error state. |
| 1460 expectFalse(printButton.disabled); | 1635 expectFalse(printButton.disabled); |
| 1461 expectFalse(this.hasPrinted()); | 1636 expectFalse(this.hasPrinted()); |
| 1462 printButton.click(); | 1637 printButton.click(); |
| 1463 expectTrue(this.hasPrinted()); | 1638 expectTrue(this.hasPrinted()); |
| 1464 testDone(); | 1639 testDone(); |
| 1640 }.bind(this)); | |
| 1465 }); | 1641 }); |
| 1466 | 1642 |
| 1467 // Test the preview generator to make sure the generate draft parameter is set | 1643 // Test the preview generator to make sure the generate draft parameter is set |
| 1468 // correctly. It should be false if the only change is the page range. | 1644 // correctly. It should be false if the only change is the page range. |
| 1469 TEST_F('PrintPreviewWebUITest', 'TestGenerateDraft', function() { | 1645 TEST_F('PrintPreviewWebUITest', 'TestGenerateDraft', function() { |
| 1646 this.createPrintPreview(); | |
| 1647 | |
| 1470 // Use a real preview generator. | 1648 // Use a real preview generator. |
| 1471 printPreview.previewArea_.previewGenerator_ = | 1649 printPreview.previewArea_.previewGenerator_ = |
| 1472 new print_preview.PreviewGenerator(printPreview.destinationStore_, | 1650 new print_preview.PreviewGenerator(printPreview.destinationStore_, |
| 1473 printPreview.printTicketStore_, this.nativeLayer_, | 1651 printPreview.printTicketStore_, this.nativeLayer_, |
| 1474 printPreview.documentInfo_); | 1652 printPreview.documentInfo_); |
| 1475 | 1653 |
| 1476 this.setInitialSettings(); | 1654 this.setInitialSettings(); |
| 1477 this.setLocalDestinations(); | 1655 printPreview.nativeLayer_.whenCalled('getInitialSettings').then( |
| 1478 this.setCapabilities(getCddTemplate("FooDevice")); | 1656 function() { |
| 1657 this.setLocalDestinations(); | |
| 1658 this.setCapabilities(getCddTemplate("FooDevice")); | |
| 1479 | 1659 |
| 1480 // The first request should generate draft because there was no previous print | 1660 // The first request should generate draft because there was no |
| 1481 // preview draft. | 1661 // previous print preview draft. |
| 1482 expectTrue(this.generateDraft()); | 1662 expectTrue(this.generateDraft()); |
| 1483 | 1663 |
| 1484 // Change the page range - no new draft needed. | 1664 // Change the page range - no new draft needed. |
| 1485 printPreview.printTicketStore_.pageRange.updateValue("2"); | 1665 printPreview.printTicketStore_.pageRange.updateValue("2"); |
| 1486 expectFalse(this.generateDraft()); | 1666 expectFalse(this.generateDraft()); |
| 1487 | 1667 |
| 1488 // Change the margin type - need to regenerate again. | 1668 // Change the margin type - need to regenerate again. |
| 1489 printPreview.printTicketStore_.marginsType.updateValue( | 1669 printPreview.printTicketStore_.marginsType.updateValue( |
| 1490 print_preview.ticket_items.MarginsTypeValue.NO_MARGINS); | 1670 print_preview.ticket_items.MarginsTypeValue.NO_MARGINS); |
| 1491 expectTrue(this.generateDraft()); | 1671 expectTrue(this.generateDraft()); |
| 1492 | 1672 |
| 1493 testDone(); | 1673 testDone(); |
| 1674 }.bind(this)); | |
| 1494 }); | 1675 }); |
| OLD | NEW |