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 = '../../../../'; | 8 var ROOT_PATH = '../../../../../'; |
9 | 9 |
10 /** | 10 /** |
11 * Test fixture for print preview WebUI testing. | 11 * Test fixture for print preview WebUI testing. |
12 * @constructor | 12 * @constructor |
13 * @extends {testing.Test} | 13 * @extends {testing.Test} |
14 */ | 14 */ |
15 function PrintPreviewWebUITest() { | 15 function PrintPreviewWebUITest() { |
16 testing.Test.call(this); | 16 testing.Test.call(this); |
17 this.printPreview_ = null; | 17 this.printPreview_ = null; |
18 this.nativeLayer_ = null; | 18 this.nativeLayer_ = null; |
(...skipping 24 matching lines...) Expand all Loading... |
43 PrintPreviewWebUITest.BAR_INDEX = 2; | 43 PrintPreviewWebUITest.BAR_INDEX = 2; |
44 | 44 |
45 PrintPreviewWebUITest.prototype = { | 45 PrintPreviewWebUITest.prototype = { |
46 __proto__: testing.Test.prototype, | 46 __proto__: testing.Test.prototype, |
47 | 47 |
48 /** | 48 /** |
49 * Browse to the sample page, cause print preview & call preLoad(). | 49 * Browse to the sample page, cause print preview & call preLoad(). |
50 * @type {string} | 50 * @type {string} |
51 * @override | 51 * @override |
52 */ | 52 */ |
53 browsePrintPreload: 'print_preview_hello_world_test.html', | 53 browsePrintPreload: 'print_preview/print_preview_hello_world_test.html', |
54 | 54 |
55 /** @override */ | 55 /** @override */ |
56 runAccessibilityChecks: true, | 56 runAccessibilityChecks: true, |
57 | 57 |
58 /** @override */ | 58 /** @override */ |
59 accessibilityIssuesAreErrors: true, | 59 accessibilityIssuesAreErrors: true, |
60 | 60 |
61 /** @override */ | 61 /** @override */ |
62 isAsync: true, | 62 isAsync: true, |
63 | 63 |
(...skipping 14 matching lines...) Expand all Loading... |
78 | 78 |
79 /** | 79 /** |
80 * Stub out low-level functionality like the NativeLayer and | 80 * Stub out low-level functionality like the NativeLayer and |
81 * CloudPrintInterface. | 81 * CloudPrintInterface. |
82 * @this {PrintPreviewWebUITest} | 82 * @this {PrintPreviewWebUITest} |
83 * @override | 83 * @override |
84 */ | 84 */ |
85 preLoad: function() { | 85 preLoad: function() { |
86 window.isTest = true; | 86 window.isTest = true; |
87 window.addEventListener('DOMContentLoaded', function() { | 87 window.addEventListener('DOMContentLoaded', function() { |
88 /** | |
89 * Test version of the native layer. | |
90 * @constructor | |
91 * @extends {settings.TestBrowserProxy} | |
92 */ | |
93 function NativeLayerStub() { | |
94 settings.TestBrowserProxy.call(this, [ 'getInitialSettings' ]); | |
95 this.eventTarget_ = new cr.EventTarget(); | |
96 this.printStarted_ = false; | |
97 this.generateDraft_ = false; | |
98 this.initialSettings_ = null; | |
99 } | |
100 NativeLayerStub.prototype = { | |
101 __proto__: settings.TestBrowserProxy.prototype, | |
102 getEventTarget: function() { return this.eventTarget_; }, | |
103 isPrintStarted: function() { return this.printStarted_; }, | |
104 generateDraft: function() { return this.generateDraft_; }, | |
105 getInitialSettings: function() { | |
106 this.methodCalled('getInitialSettings'); | |
107 return Promise.resolve(this.initialSettings_); | |
108 }, | |
109 previewReadyForTest: function() {}, | |
110 startGetLocalDestinations: function() {}, | |
111 startGetPrivetDestinations: function() {}, | |
112 startGetExtensionDestinations: function() {}, | |
113 startGetLocalDestinationCapabilities: function(destinationId) {}, | |
114 startGetPreview: function(destination, printTicketStore, documentInfo, | |
115 generateDraft, requestId) { | |
116 this.generateDraft_ = generateDraft; | |
117 }, | |
118 startHideDialog: function () {}, | |
119 startPrint: function () { this.printStarted_ = true; } | |
120 }; | |
121 var oldNativeLayerEventType = print_preview.NativeLayer.EventType; | |
122 var oldDuplexMode = print_preview.NativeLayer.DuplexMode; | |
123 print_preview.NativeLayer = NativeLayerStub; | |
124 print_preview.NativeLayer.EventType = oldNativeLayerEventType; | |
125 print_preview.NativeLayer.DuplexMode = oldDuplexMode; | |
126 | |
127 function CloudPrintInterfaceStub() { | 88 function CloudPrintInterfaceStub() { |
128 cr.EventTarget.call(this); | 89 cr.EventTarget.call(this); |
129 } | 90 } |
130 CloudPrintInterfaceStub.prototype = { | 91 CloudPrintInterfaceStub.prototype = { |
131 __proto__: cr.EventTarget.prototype, | 92 __proto__: cr.EventTarget.prototype, |
132 search: function(isRecent) {} | 93 search: function(isRecent) {} |
133 }; | 94 }; |
134 var oldCpInterfaceEventType = cloudprint.CloudPrintInterfaceEventType; | 95 var oldCpInterfaceEventType = cloudprint.CloudPrintInterfaceEventType; |
135 cloudprint.CloudPrintInterface = CloudPrintInterfaceStub; | 96 cloudprint.CloudPrintInterface = CloudPrintInterfaceStub; |
136 cloudprint.CloudPrintInterfaceEventType = oldCpInterfaceEventType; | 97 cloudprint.CloudPrintInterfaceEventType = oldCpInterfaceEventType; |
137 | 98 |
138 print_preview.PreviewArea.prototype.checkPluginCompatibility_ = | 99 print_preview.PreviewArea.prototype.checkPluginCompatibility_ = |
139 function() { | 100 function() { |
140 return false; | 101 return false; |
141 }; | 102 }; |
142 }.bind(this)); | 103 }.bind(this)); |
143 }, | 104 }, |
144 | 105 |
145 extraLibraries: [ | 106 extraLibraries: [ |
146 ROOT_PATH + 'ui/webui/resources/js/cr.js', | 107 ROOT_PATH + 'ui/webui/resources/js/cr.js', |
147 ROOT_PATH + 'ui/webui/resources/js/promise_resolver.js', | 108 ROOT_PATH + 'ui/webui/resources/js/promise_resolver.js', |
148 ROOT_PATH + 'ui/webui/resources/js/util.js', | 109 ROOT_PATH + 'ui/webui/resources/js/util.js', |
149 ROOT_PATH + 'chrome/test/data/webui/settings/test_browser_proxy.js', | 110 ROOT_PATH + 'chrome/test/data/webui/settings/test_browser_proxy.js', |
| 111 'native_layer_stub.js', |
150 ], | 112 ], |
151 | 113 |
152 /** | 114 /** |
153 * Creates an instance of print_preview.PrintPreview and initializes the | 115 * Creates an instance of print_preview.PrintPreview and initializes the |
154 * |nativeLayer_| and |previewArea_|. | 116 * |nativeLayer_| and |previewArea_|. |
155 */ | 117 */ |
156 createPrintPreview: function() { | 118 createPrintPreview: function() { |
| 119 this.nativeLayer_ = new print_preview.NativeLayerStub(); |
| 120 print_preview.NativeLayer.setInstance(this.nativeLayer_); |
157 this.printPreview_ = new print_preview.PrintPreview(); | 121 this.printPreview_ = new print_preview.PrintPreview(); |
158 this.nativeLayer_ = this.printPreview_.nativeLayer_; | 122 this.previewArea_ = this.printPreview_.getPreviewArea(); |
159 this.previewArea_ = this.printPreview_.previewArea_; | |
160 }, | 123 }, |
161 | 124 |
162 /** | 125 /** |
163 * Initialize print preview with the initial settings currently stored in | 126 * Initialize print preview with the initial settings currently stored in |
164 * |this.initialSettings_|. Creates |this.printPreview_| if it does not | 127 * |this.initialSettings_|. Creates |this.printPreview_| if it does not |
165 * already exist. | 128 * already exist. |
166 */ | 129 */ |
167 setInitialSettings: function() { | 130 setInitialSettings: function() { |
168 if (!this.printPreview_) { | 131 if (!this.printPreview_) |
169 this.printPreview_ = new print_preview.PrintPreview(); | 132 this.createPrintPreview(); |
170 this.nativeLayer_ = this.printPreview_.nativeLayer_; | 133 this.nativeLayer_.setInitialSettings(this.initialSettings_); |
171 this.previewArea_ = this.printPreview_.previewArea_; | |
172 } | |
173 this.nativeLayer_.initialSettings_ = this.initialSettings_; | |
174 this.printPreview_.initialize(); | 134 this.printPreview_.initialize(); |
175 testing.Test.disableAnimationsAndTransitions(); | 135 testing.Test.disableAnimationsAndTransitions(); |
176 // Enable when failure is resolved. | 136 // Enable when failure is resolved. |
177 // AX_TEXT_03: http://crbug.com/559209 | 137 // AX_TEXT_03: http://crbug.com/559209 |
178 this.accessibilityAuditConfig.ignoreSelectors( | 138 this.accessibilityAuditConfig.ignoreSelectors( |
179 'multipleLabelableElementsPerLabel', | 139 'multipleLabelableElementsPerLabel', |
180 '#page-settings > .right-column > *'); | 140 '#page-settings > .right-column > *'); |
181 }, | 141 }, |
182 | 142 |
183 /** | 143 /** |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 'FooDevice' /*systemDefaultDestinationId*/, | 266 'FooDevice' /*systemDefaultDestinationId*/, |
307 null /*serializedAppStateStr*/, | 267 null /*serializedAppStateStr*/, |
308 null /*serializedDefaultDestinationSelectionRulesStr*/); | 268 null /*serializedDefaultDestinationSelectionRulesStr*/); |
309 this.localDestinationInfos_ = [ | 269 this.localDestinationInfos_ = [ |
310 { printerName: 'FooName', deviceName: 'FooDevice' }, | 270 { printerName: 'FooName', deviceName: 'FooDevice' }, |
311 { printerName: 'BarName', deviceName: 'BarDevice' } | 271 { printerName: 'BarName', deviceName: 'BarDevice' } |
312 ]; | 272 ]; |
313 }, | 273 }, |
314 }; | 274 }; |
315 | 275 |
316 GEN('#include "chrome/test/data/webui/print_preview.h"'); | 276 GEN('#include "chrome/test/data/webui/print_preview/print_preview.h"'); |
317 | 277 |
318 // Test some basic assumptions about the print preview WebUI. | 278 // Test some basic assumptions about the print preview WebUI. |
319 TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() { | 279 TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() { |
320 this.setInitialSettings(); | 280 this.setInitialSettings(); |
321 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 281 this.nativeLayer_.whenCalled('getInitialSettings').then( |
322 function() { | 282 function() { |
323 this.setLocalDestinations(); | 283 this.setLocalDestinations(); |
324 var recentList = | 284 var recentList = |
325 $('destination-search').querySelector('.recent-list ul'); | 285 $('destination-search').querySelector('.recent-list ul'); |
326 var localList = | 286 var localList = |
327 $('destination-search').querySelector('.local-list ul'); | 287 $('destination-search').querySelector('.local-list ul'); |
328 assertNotEquals(null, recentList); | 288 assertNotEquals(null, recentList); |
329 assertEquals(1, recentList.childNodes.length); | 289 assertEquals(1, recentList.childNodes.length); |
330 assertEquals('FooName', | 290 assertEquals('FooName', |
331 recentList.childNodes.item(0).querySelector( | 291 recentList.childNodes.item(0).querySelector( |
(...skipping 11 matching lines...) Expand all Loading... |
343 querySelector('.destination-list-item-name').textContent); | 303 querySelector('.destination-list-item-name').textContent); |
344 testDone(); | 304 testDone(); |
345 }.bind(this)); | 305 }.bind(this)); |
346 }); | 306 }); |
347 | 307 |
348 // Test that the printer list is structured correctly after calling | 308 // Test that the printer list is structured correctly after calling |
349 // addCloudPrinters with an empty list. | 309 // addCloudPrinters with an empty list. |
350 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() { | 310 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() { |
351 this.setInitialSettings(); | 311 this.setInitialSettings(); |
352 | 312 |
353 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 313 this.nativeLayer_.whenCalled('getInitialSettings').then( |
354 function() { | 314 function() { |
355 this.setLocalDestinations(); | 315 this.setLocalDestinations(); |
356 | 316 |
357 var cloudPrintEnableEvent = | 317 var cloudPrintEnableEvent = |
358 new Event(print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE); | 318 new Event(print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE); |
359 cloudPrintEnableEvent.baseCloudPrintUrl = 'cloudprint url'; | 319 cloudPrintEnableEvent.baseCloudPrintUrl = 'cloudprint url'; |
360 this.nativeLayer_.getEventTarget().dispatchEvent( | 320 this.nativeLayer_.getEventTarget().dispatchEvent( |
361 cloudPrintEnableEvent); | 321 cloudPrintEnableEvent); |
362 | 322 |
363 var searchDoneEvent = | 323 var searchDoneEvent = |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 433 |
474 // Test restore settings with one destination. | 434 // Test restore settings with one destination. |
475 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', | 435 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', |
476 function() { | 436 function() { |
477 this.initialSettings_.serializedAppStateStr_ = | 437 this.initialSettings_.serializedAppStateStr_ = |
478 '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' + | 438 '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' + |
479 '"account":"", "capabilities":0, "name":"", "extensionId":"",' + | 439 '"account":"", "capabilities":0, "name":"", "extensionId":"",' + |
480 '"extensionName":""}]}'; | 440 '"extensionName":""}]}'; |
481 | 441 |
482 this.setInitialSettings(); | 442 this.setInitialSettings(); |
483 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 443 this.nativeLayer_.whenCalled('getInitialSettings').then( |
484 function() { | 444 function() { |
485 testDone(); | 445 testDone(); |
486 }); | 446 }); |
487 }); | 447 }); |
488 | 448 |
489 // Test with multiple destinations | 449 // Test with multiple destinations |
490 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations', | 450 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations', |
491 function() { | 451 function() { |
492 var origin = cr.isChromeOS ? "chrome_os" : "local"; | 452 var origin = cr.isChromeOS ? "chrome_os" : "local"; |
493 | 453 |
(...skipping 26 matching lines...) Expand all Loading... |
520 'name': '', | 480 'name': '', |
521 'extensionId': '', | 481 'extensionId': '', |
522 'extensionName': '' | 482 'extensionName': '' |
523 } | 483 } |
524 ] | 484 ] |
525 }; | 485 }; |
526 | 486 |
527 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(appState); | 487 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(appState); |
528 this.setInitialSettings(); | 488 this.setInitialSettings(); |
529 | 489 |
530 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 490 this.nativeLayer_.whenCalled('getInitialSettings').then( |
531 function() { | 491 function() { |
532 // Set capabilities for the three recently used destinations + 1 more | 492 // Set capabilities for the three recently used destinations + 1 more |
533 this.setCapabilities(getCddTemplate('ID1')); | 493 this.setCapabilities(getCddTemplate('ID1')); |
534 this.setCapabilities(getCddTemplate('ID2')); | 494 this.setCapabilities(getCddTemplate('ID2')); |
535 this.setCapabilities(getCddTemplate('ID3')); | 495 this.setCapabilities(getCddTemplate('ID3')); |
536 this.setCapabilities(getCddTemplate('ID4')); | 496 this.setCapabilities(getCddTemplate('ID4')); |
537 | 497 |
538 // The most recently used destination should be the currently selected | 498 // The most recently used destination should be the currently selected |
539 // one. This is ID1. | 499 // one. This is ID1. |
540 assertEquals( | 500 assertEquals( |
(...skipping 21 matching lines...) Expand all Loading... |
562 testDone(); | 522 testDone(); |
563 }.bind(this)); | 523 }.bind(this)); |
564 }); | 524 }); |
565 | 525 |
566 TEST_F('PrintPreviewWebUITest', | 526 TEST_F('PrintPreviewWebUITest', |
567 'TestPrintPreviewDefaultDestinationSelectionRules', function() { | 527 'TestPrintPreviewDefaultDestinationSelectionRules', function() { |
568 // It also makes sure these rules do override system default destination. | 528 // It also makes sure these rules do override system default destination. |
569 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = | 529 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = |
570 '{"namePattern":".*Bar.*"}'; | 530 '{"namePattern":".*Bar.*"}'; |
571 this.setInitialSettings(); | 531 this.setInitialSettings(); |
572 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 532 this.nativeLayer_.whenCalled('getInitialSettings').then( |
573 function() { | 533 function() { |
574 this.setLocalDestinations(); | 534 this.setLocalDestinations(); |
575 | 535 |
576 assertEquals( | 536 assertEquals( |
577 'BarDevice', | 537 'BarDevice', |
578 this.printPreview_.destinationStore_.selectedDestination.id); | 538 this.printPreview_.destinationStore_.selectedDestination.id); |
579 | 539 |
580 testDone(); | 540 testDone(); |
581 }.bind(this)); | 541 }.bind(this)); |
582 }); | 542 }); |
583 | 543 |
584 TEST_F('PrintPreviewWebUITest', 'TestSystemDialogLinkIsHiddenInAppKioskMode', | 544 TEST_F('PrintPreviewWebUITest', 'TestSystemDialogLinkIsHiddenInAppKioskMode', |
585 function() { | 545 function() { |
586 if (!cr.isChromeOS) | 546 if (!cr.isChromeOS) |
587 this.initialSettings_.isInAppKioskMode_ = true; | 547 this.initialSettings_.isInAppKioskMode_ = true; |
588 | 548 |
589 this.setInitialSettings(); | 549 this.setInitialSettings(); |
590 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 550 this.nativeLayer_.whenCalled('getInitialSettings').then( |
591 function() { | 551 function() { |
592 if (cr.isChromeOS) | 552 if (cr.isChromeOS) |
593 assertEquals(null, $('system-dialog-link')); | 553 assertEquals(null, $('system-dialog-link')); |
594 else | 554 else |
595 checkElementDisplayed($('system-dialog-link'), false); | 555 checkElementDisplayed($('system-dialog-link'), false); |
596 testDone(); | 556 testDone(); |
597 }); | 557 }); |
598 }); | 558 }); |
599 | 559 |
600 // Test that disabled settings hide the disabled sections. | 560 // Test that disabled settings hide the disabled sections. |
601 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { | 561 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { |
602 this.createPrintPreview(); | 562 this.createPrintPreview(); |
603 checkSectionVisible($('layout-settings'), false); | 563 checkSectionVisible($('layout-settings'), false); |
604 checkSectionVisible($('color-settings'), false); | 564 checkSectionVisible($('color-settings'), false); |
605 checkSectionVisible($('copies-settings'), false); | 565 checkSectionVisible($('copies-settings'), false); |
606 | 566 |
607 this.setInitialSettings(); | 567 this.setInitialSettings(); |
608 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 568 this.nativeLayer_.whenCalled('getInitialSettings').then( |
609 function() { | 569 function() { |
610 this.setLocalDestinations(); | 570 this.setLocalDestinations(); |
611 var device = getCddTemplate("FooDevice"); | 571 var device = getCddTemplate("FooDevice"); |
612 device.capabilities.printer.color = { | 572 device.capabilities.printer.color = { |
613 "option": [ | 573 "option": [ |
614 {"is_default": true, "type": "STANDARD_COLOR"} | 574 {"is_default": true, "type": "STANDARD_COLOR"} |
615 ] | 575 ] |
616 }; | 576 }; |
617 delete device.capabilities.printer.copies; | 577 delete device.capabilities.printer.copies; |
618 this.setCapabilities(device); | 578 this.setCapabilities(device); |
619 | 579 |
620 checkSectionVisible($('layout-settings'), true); | 580 checkSectionVisible($('layout-settings'), true); |
621 checkSectionVisible($('color-settings'), false); | 581 checkSectionVisible($('color-settings'), false); |
622 checkSectionVisible($('copies-settings'), false); | 582 checkSectionVisible($('copies-settings'), false); |
623 | 583 |
624 this.waitForAnimationToEnd('other-options-collapsible'); | 584 this.waitForAnimationToEnd('other-options-collapsible'); |
625 }.bind(this)); | 585 }.bind(this)); |
626 }); | 586 }); |
627 | 587 |
628 // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the | 588 // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the |
629 // fit to page option. | 589 // fit to page option. |
630 TEST_F('PrintPreviewWebUITest', 'PrintToPDFSelectedCapabilities', function() { | 590 TEST_F('PrintPreviewWebUITest', 'PrintToPDFSelectedCapabilities', function() { |
631 // Add PDF printer. | 591 // Add PDF printer. |
632 this.initialSettings_.isDocumentModifiable_ = false; | 592 this.initialSettings_.isDocumentModifiable_ = false; |
633 this.initialSettings_.systemDefaultDestinationId_ = 'Save as PDF'; | 593 this.initialSettings_.systemDefaultDestinationId_ = 'Save as PDF'; |
634 this.setInitialSettings(); | 594 this.setInitialSettings(); |
635 | 595 |
636 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 596 this.nativeLayer_.whenCalled('getInitialSettings').then( |
637 function() { | 597 function() { |
638 var device = { | 598 var device = { |
639 printerId: 'Save as PDF', | 599 printerId: 'Save as PDF', |
640 capabilities: { | 600 capabilities: { |
641 version: '1.0', | 601 version: '1.0', |
642 printer: { | 602 printer: { |
643 page_orientation: { | 603 page_orientation: { |
644 option: [ | 604 option: [ |
645 {type: 'AUTO', is_default: true}, | 605 {type: 'AUTO', is_default: true}, |
646 {type: 'PORTRAIT'}, | 606 {type: 'PORTRAIT'}, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 checkSectionVisible($('scaling-settings'), false); | 640 checkSectionVisible($('scaling-settings'), false); |
681 | 641 |
682 testDone(); | 642 testDone(); |
683 }.bind(this)); | 643 }.bind(this)); |
684 }); | 644 }); |
685 | 645 |
686 // When the source is 'HTML', we always hide the fit to page option and show | 646 // When the source is 'HTML', we always hide the fit to page option and show |
687 // media size option. | 647 // media size option. |
688 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { | 648 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { |
689 this.setInitialSettings(); | 649 this.setInitialSettings(); |
690 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 650 this.nativeLayer_.whenCalled('getInitialSettings').then( |
691 function() { | 651 function() { |
692 this.setLocalDestinations(); | 652 this.setLocalDestinations(); |
693 this.setCapabilities(getCddTemplate("FooDevice")); | 653 this.setCapabilities(getCddTemplate("FooDevice")); |
694 | 654 |
695 var otherOptions = $('other-options-settings'); | 655 var otherOptions = $('other-options-settings'); |
696 var fitToPage = otherOptions.querySelector('#fit-to-page-container'); | 656 var fitToPage = otherOptions.querySelector('#fit-to-page-container'); |
697 var rasterize; | 657 var rasterize; |
698 if (isPrintAsImageEnabled()) | 658 if (isPrintAsImageEnabled()) |
699 rasterize = otherOptions.querySelector('#rasterize-container'); | 659 rasterize = otherOptions.querySelector('#rasterize-container'); |
700 var mediaSize = $('media-size-settings'); | 660 var mediaSize = $('media-size-settings'); |
(...skipping 18 matching lines...) Expand all Loading... |
719 | 679 |
720 this.waitForAnimationToEnd('more-settings'); | 680 this.waitForAnimationToEnd('more-settings'); |
721 }.bind(this)); | 681 }.bind(this)); |
722 }); | 682 }); |
723 | 683 |
724 // When the source is "PDF", depending on the selected destination printer, we | 684 // When the source is "PDF", depending on the selected destination printer, we |
725 // show/hide the fit to page option and hide media size selection. | 685 // show/hide the fit to page option and hide media size selection. |
726 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { | 686 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { |
727 this.initialSettings_.isDocumentModifiable_ = false; | 687 this.initialSettings_.isDocumentModifiable_ = false; |
728 this.setInitialSettings(); | 688 this.setInitialSettings(); |
729 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 689 this.nativeLayer_.whenCalled('getInitialSettings').then( |
730 function() { | 690 function() { |
731 this.setLocalDestinations(); | 691 this.setLocalDestinations(); |
732 this.setCapabilities(getCddTemplate("FooDevice")); | 692 this.setCapabilities(getCddTemplate("FooDevice")); |
733 | 693 |
734 var otherOptions = $('other-options-settings'); | 694 var otherOptions = $('other-options-settings'); |
735 var scalingSettings = $('scaling-settings'); | 695 var scalingSettings = $('scaling-settings'); |
736 var fitToPageContainer = | 696 var fitToPageContainer = |
737 otherOptions.querySelector('#fit-to-page-container'); | 697 otherOptions.querySelector('#fit-to-page-container'); |
738 var rasterizeContainer; | 698 var rasterizeContainer; |
739 if (isPrintAsImageEnabled()) { | 699 if (isPrintAsImageEnabled()) { |
(...skipping 18 matching lines...) Expand all Loading... |
758 | 718 |
759 this.waitForAnimationToEnd('other-options-collapsible'); | 719 this.waitForAnimationToEnd('other-options-collapsible'); |
760 }.bind(this)); | 720 }.bind(this)); |
761 }); | 721 }); |
762 | 722 |
763 // When the source is "PDF", depending on the selected destination printer, we | 723 // When the source is "PDF", depending on the selected destination printer, we |
764 // show/hide the fit to page option and hide media size selection. | 724 // show/hide the fit to page option and hide media size selection. |
765 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { | 725 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { |
766 this.initialSettings_.isDocumentModifiable_ = false; | 726 this.initialSettings_.isDocumentModifiable_ = false; |
767 this.setInitialSettings(); | 727 this.setInitialSettings(); |
768 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 728 this.nativeLayer_.whenCalled('getInitialSettings').then( |
769 function() { | 729 function() { |
770 this.setLocalDestinations(); | 730 this.setLocalDestinations(); |
771 this.setCapabilities(getCddTemplate("FooDevice")); | 731 this.setCapabilities(getCddTemplate("FooDevice")); |
772 | 732 |
773 var otherOptions = $('other-options-settings'); | 733 var otherOptions = $('other-options-settings'); |
774 var scalingSettings = $('scaling-settings'); | 734 var scalingSettings = $('scaling-settings'); |
775 | 735 |
776 checkSectionVisible(otherOptions, true); | 736 checkSectionVisible(otherOptions, true); |
777 var fitToPageContainer = | 737 var fitToPageContainer = |
778 otherOptions.querySelector('#fit-to-page-container'); | 738 otherOptions.querySelector('#fit-to-page-container'); |
(...skipping 20 matching lines...) Expand all Loading... |
799 | 759 |
800 this.waitForAnimationToEnd('other-options-collapsible'); | 760 this.waitForAnimationToEnd('other-options-collapsible'); |
801 }.bind(this)); | 761 }.bind(this)); |
802 }); | 762 }); |
803 | 763 |
804 // When the number of copies print preset is set for source 'PDF', we update | 764 // When the number of copies print preset is set for source 'PDF', we update |
805 // the copies value if capability is supported by printer. | 765 // the copies value if capability is supported by printer. |
806 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() { | 766 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() { |
807 this.initialSettings_.isDocumentModifiable_ = false; | 767 this.initialSettings_.isDocumentModifiable_ = false; |
808 this.setInitialSettings(); | 768 this.setInitialSettings(); |
809 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 769 this.nativeLayer_.whenCalled('getInitialSettings').then( |
810 function() { | 770 function() { |
811 this.setLocalDestinations(); | 771 this.setLocalDestinations(); |
812 this.setCapabilities(getCddTemplate("FooDevice")); | 772 this.setCapabilities(getCddTemplate("FooDevice")); |
813 | 773 |
814 // Indicate that the number of copies print preset is set for source | 774 // Indicate that the number of copies print preset is set for source |
815 // PDF. | 775 // PDF. |
816 var printPresetOptions = { | 776 var printPresetOptions = { |
817 disableScaling: true, | 777 disableScaling: true, |
818 copies: 2 | 778 copies: 2 |
819 }; | 779 }; |
(...skipping 11 matching lines...) Expand all Loading... |
831 this.waitForAnimationToEnd('other-options-collapsible'); | 791 this.waitForAnimationToEnd('other-options-collapsible'); |
832 }.bind(this)); | 792 }.bind(this)); |
833 }); | 793 }); |
834 | 794 |
835 // When the duplex print preset is set for source 'PDF', we update the | 795 // When the duplex print preset is set for source 'PDF', we update the |
836 // duplex setting if capability is supported by printer. | 796 // duplex setting if capability is supported by printer. |
837 TEST_F('PrintPreviewWebUITest', 'CheckDuplexPrintPreset', function() { | 797 TEST_F('PrintPreviewWebUITest', 'CheckDuplexPrintPreset', function() { |
838 this.initialSettings_.isDocumentModifiable_ = false; | 798 this.initialSettings_.isDocumentModifiable_ = false; |
839 this.setInitialSettings(); | 799 this.setInitialSettings(); |
840 | 800 |
841 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 801 this.nativeLayer_.whenCalled('getInitialSettings').then( |
842 function() { | 802 function() { |
843 this.setLocalDestinations(); | 803 this.setLocalDestinations(); |
844 this.setCapabilities(getCddTemplate("FooDevice")); | 804 this.setCapabilities(getCddTemplate("FooDevice")); |
845 | 805 |
846 // Indicate that the duplex print preset is set to "long edge" for | 806 // Indicate that the duplex print preset is set to "long edge" for |
847 // source PDF. | 807 // source PDF. |
848 var printPresetOptions = { | 808 var printPresetOptions = { |
849 duplex: 1 | 809 duplex: 1 |
850 }; | 810 }; |
851 var printPresetOptionsEvent = new Event( | 811 var printPresetOptionsEvent = new Event( |
852 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); | 812 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
853 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; | 813 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; |
854 this.nativeLayer_.getEventTarget(). | 814 this.nativeLayer_.getEventTarget(). |
855 dispatchEvent(printPresetOptionsEvent); | 815 dispatchEvent(printPresetOptionsEvent); |
856 | 816 |
857 var otherOptions = $('other-options-settings'); | 817 var otherOptions = $('other-options-settings'); |
858 checkSectionVisible(otherOptions, true); | 818 checkSectionVisible(otherOptions, true); |
859 var duplexContainer = otherOptions.querySelector('#duplex-container'); | 819 var duplexContainer = otherOptions.querySelector('#duplex-container'); |
860 checkElementDisplayed(duplexContainer, true); | 820 checkElementDisplayed(duplexContainer, true); |
861 expectTrue(duplexContainer.querySelector('.checkbox').checked); | 821 expectTrue(duplexContainer.querySelector('.checkbox').checked); |
862 | 822 |
863 this.waitForAnimationToEnd('other-options-collapsible'); | 823 this.waitForAnimationToEnd('other-options-collapsible'); |
864 }.bind(this)); | 824 }.bind(this)); |
865 }); | 825 }); |
866 | 826 |
867 // Make sure that custom margins controls are properly set up. | 827 // Make sure that custom margins controls are properly set up. |
868 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { | 828 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { |
869 this.setInitialSettings(); | 829 this.setInitialSettings(); |
870 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 830 this.nativeLayer_.whenCalled('getInitialSettings').then( |
871 function() { | 831 function() { |
872 this.setLocalDestinations(); | 832 this.setLocalDestinations(); |
873 this.setCapabilities(getCddTemplate("FooDevice")); | 833 this.setCapabilities(getCddTemplate("FooDevice")); |
874 | 834 |
875 this.printPreview_.printTicketStore_.marginsType.updateValue( | 835 this.printPreview_.printTicketStore_.marginsType.updateValue( |
876 print_preview.ticket_items.MarginsTypeValue.CUSTOM); | 836 print_preview.ticket_items.MarginsTypeValue.CUSTOM); |
877 | 837 |
878 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { | 838 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { |
879 var control = | 839 var control = |
880 $('preview-area').querySelector('.margin-control-' + margin); | 840 $('preview-area').querySelector('.margin-control-' + margin); |
881 assertNotEquals(null, control); | 841 assertNotEquals(null, control); |
882 var input = control.querySelector('.margin-control-textbox'); | 842 var input = control.querySelector('.margin-control-textbox'); |
883 assertTrue(input.hasAttribute('aria-label')); | 843 assertTrue(input.hasAttribute('aria-label')); |
884 assertNotEquals('undefined', input.getAttribute('aria-label')); | 844 assertNotEquals('undefined', input.getAttribute('aria-label')); |
885 }); | 845 }); |
886 this.waitForAnimationToEnd('more-settings'); | 846 this.waitForAnimationToEnd('more-settings'); |
887 }.bind(this)); | 847 }.bind(this)); |
888 }); | 848 }); |
889 | 849 |
890 // Page layout has zero margins. Hide header and footer option. | 850 // Page layout has zero margins. Hide header and footer option. |
891 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter', | 851 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter', |
892 function() { | 852 function() { |
893 this.setInitialSettings(); | 853 this.setInitialSettings(); |
894 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 854 this.nativeLayer_.whenCalled('getInitialSettings').then( |
895 function() { | 855 function() { |
896 this.setLocalDestinations(); | 856 this.setLocalDestinations(); |
897 this.setCapabilities(getCddTemplate("FooDevice")); | 857 this.setCapabilities(getCddTemplate("FooDevice")); |
898 | 858 |
899 var otherOptions = $('other-options-settings'); | 859 var otherOptions = $('other-options-settings'); |
900 var headerFooter = | 860 var headerFooter = |
901 otherOptions.querySelector('#header-footer-container'); | 861 otherOptions.querySelector('#header-footer-container'); |
902 | 862 |
903 // Check that options are collapsed (section is visible, because duplex | 863 // Check that options are collapsed (section is visible, because duplex |
904 // is available). | 864 // is available). |
(...skipping 12 matching lines...) Expand all Loading... |
917 checkElementDisplayed(headerFooter, false); | 877 checkElementDisplayed(headerFooter, false); |
918 | 878 |
919 this.waitForAnimationToEnd('more-settings'); | 879 this.waitForAnimationToEnd('more-settings'); |
920 }.bind(this)); | 880 }.bind(this)); |
921 }); | 881 }); |
922 | 882 |
923 // Page layout has half-inch margins. Show header and footer option. | 883 // Page layout has half-inch margins. Show header and footer option. |
924 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter', | 884 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter', |
925 function() { | 885 function() { |
926 this.setInitialSettings(); | 886 this.setInitialSettings(); |
927 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 887 this.nativeLayer_.whenCalled('getInitialSettings').then( |
928 function() { | 888 function() { |
929 this.setLocalDestinations(); | 889 this.setLocalDestinations(); |
930 this.setCapabilities(getCddTemplate("FooDevice")); | 890 this.setCapabilities(getCddTemplate("FooDevice")); |
931 | 891 |
932 var otherOptions = $('other-options-settings'); | 892 var otherOptions = $('other-options-settings'); |
933 var headerFooter = | 893 var headerFooter = |
934 otherOptions.querySelector('#header-footer-container'); | 894 otherOptions.querySelector('#header-footer-container'); |
935 | 895 |
936 // Check that options are collapsed (section is visible, because duplex | 896 // Check that options are collapsed (section is visible, because duplex |
937 // is available). | 897 // is available). |
(...skipping 13 matching lines...) Expand all Loading... |
951 | 911 |
952 this.waitForAnimationToEnd('more-settings'); | 912 this.waitForAnimationToEnd('more-settings'); |
953 }.bind(this)); | 913 }.bind(this)); |
954 }); | 914 }); |
955 | 915 |
956 // Page layout has zero top and bottom margins. Hide header and footer option. | 916 // Page layout has zero top and bottom margins. Hide header and footer option. |
957 TEST_F('PrintPreviewWebUITest', | 917 TEST_F('PrintPreviewWebUITest', |
958 'ZeroTopAndBottomMarginsHideHeaderFooter', | 918 'ZeroTopAndBottomMarginsHideHeaderFooter', |
959 function() { | 919 function() { |
960 this.setInitialSettings(); | 920 this.setInitialSettings(); |
961 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 921 this.nativeLayer_.whenCalled('getInitialSettings').then( |
962 function() { | 922 function() { |
963 this.setLocalDestinations(); | 923 this.setLocalDestinations(); |
964 this.setCapabilities(getCddTemplate("FooDevice")); | 924 this.setCapabilities(getCddTemplate("FooDevice")); |
965 | 925 |
966 var otherOptions = $('other-options-settings'); | 926 var otherOptions = $('other-options-settings'); |
967 var headerFooter = | 927 var headerFooter = |
968 otherOptions.querySelector('#header-footer-container'); | 928 otherOptions.querySelector('#header-footer-container'); |
969 | 929 |
970 // Check that options are collapsed (section is visible, because duplex | 930 // Check that options are collapsed (section is visible, because duplex |
971 // is available). | 931 // is available). |
(...skipping 14 matching lines...) Expand all Loading... |
986 this.waitForAnimationToEnd('more-settings'); | 946 this.waitForAnimationToEnd('more-settings'); |
987 }.bind(this)); | 947 }.bind(this)); |
988 }); | 948 }); |
989 | 949 |
990 // Page layout has zero top and half-inch bottom margin. Show header and footer | 950 // Page layout has zero top and half-inch bottom margin. Show header and footer |
991 // option. | 951 // option. |
992 TEST_F('PrintPreviewWebUITest', | 952 TEST_F('PrintPreviewWebUITest', |
993 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter', | 953 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter', |
994 function() { | 954 function() { |
995 this.setInitialSettings(); | 955 this.setInitialSettings(); |
996 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 956 this.nativeLayer_.whenCalled('getInitialSettings').then( |
997 function() { | 957 function() { |
998 this.setLocalDestinations(); | 958 this.setLocalDestinations(); |
999 this.setCapabilities(getCddTemplate("FooDevice")); | 959 this.setCapabilities(getCddTemplate("FooDevice")); |
1000 | 960 |
1001 var otherOptions = $('other-options-settings'); | 961 var otherOptions = $('other-options-settings'); |
1002 var headerFooter = | 962 var headerFooter = |
1003 otherOptions.querySelector('#header-footer-container'); | 963 otherOptions.querySelector('#header-footer-container'); |
1004 | 964 |
1005 // Check that options are collapsed (section is visible, because duplex | 965 // Check that options are collapsed (section is visible, because duplex |
1006 // is available). | 966 // is available). |
(...skipping 11 matching lines...) Expand all Loading... |
1018 | 978 |
1019 checkElementDisplayed(headerFooter, true); | 979 checkElementDisplayed(headerFooter, true); |
1020 | 980 |
1021 this.waitForAnimationToEnd('more-settings'); | 981 this.waitForAnimationToEnd('more-settings'); |
1022 }.bind(this)); | 982 }.bind(this)); |
1023 }); | 983 }); |
1024 | 984 |
1025 // Check header footer availability with small (label) page size. | 985 // Check header footer availability with small (label) page size. |
1026 TEST_F('PrintPreviewWebUITest', 'SmallPaperSizeHeaderFooter', function() { | 986 TEST_F('PrintPreviewWebUITest', 'SmallPaperSizeHeaderFooter', function() { |
1027 this.setInitialSettings(); | 987 this.setInitialSettings(); |
1028 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 988 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1029 function() { | 989 function() { |
1030 this.setLocalDestinations(); | 990 this.setLocalDestinations(); |
1031 var device = getCddTemplate("FooDevice"); | 991 var device = getCddTemplate("FooDevice"); |
1032 device.capabilities.printer.media_size = { | 992 device.capabilities.printer.media_size = { |
1033 "option": [ | 993 "option": [ |
1034 {"name": "SmallLabel", "width_microns": 38100, | 994 {"name": "SmallLabel", "width_microns": 38100, |
1035 "height_microns": 12700, "is_default": false}, | 995 "height_microns": 12700, "is_default": false}, |
1036 {"name": "BigLabel", "width_microns": 50800, | 996 {"name": "BigLabel", "width_microns": 50800, |
1037 "height_microns": 76200, "is_default": true} | 997 "height_microns": 76200, "is_default": true} |
1038 ] | 998 ] |
(...skipping 24 matching lines...) Expand all Loading... |
1063 this.printPreview_.printTicketStore_.landscape.updateValue(true); | 1023 this.printPreview_.printTicketStore_.landscape.updateValue(true); |
1064 checkElementDisplayed(headerFooter, true); | 1024 checkElementDisplayed(headerFooter, true); |
1065 | 1025 |
1066 this.waitForAnimationToEnd('more-settings'); | 1026 this.waitForAnimationToEnd('more-settings'); |
1067 }.bind(this)); | 1027 }.bind(this)); |
1068 }); | 1028 }); |
1069 | 1029 |
1070 // Test that the color settings, one option, standard monochrome. | 1030 // Test that the color settings, one option, standard monochrome. |
1071 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() { | 1031 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() { |
1072 this.setInitialSettings(); | 1032 this.setInitialSettings(); |
1073 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1033 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1074 function() { | 1034 function() { |
1075 this.setLocalDestinations(); | 1035 this.setLocalDestinations(); |
1076 | 1036 |
1077 // Only one option, standard monochrome. | 1037 // Only one option, standard monochrome. |
1078 var device = getCddTemplate("FooDevice"); | 1038 var device = getCddTemplate("FooDevice"); |
1079 device.capabilities.printer.color = { | 1039 device.capabilities.printer.color = { |
1080 "option": [ | 1040 "option": [ |
1081 {"is_default": true, "type": "STANDARD_MONOCHROME"} | 1041 {"is_default": true, "type": "STANDARD_MONOCHROME"} |
1082 ] | 1042 ] |
1083 }; | 1043 }; |
1084 this.setCapabilities(device); | 1044 this.setCapabilities(device); |
1085 | 1045 |
1086 checkSectionVisible($('color-settings'), false); | 1046 checkSectionVisible($('color-settings'), false); |
1087 | 1047 |
1088 this.waitForAnimationToEnd('more-settings'); | 1048 this.waitForAnimationToEnd('more-settings'); |
1089 }.bind(this)); | 1049 }.bind(this)); |
1090 }); | 1050 }); |
1091 | 1051 |
1092 // Test that the color settings, one option, custom monochrome. | 1052 // Test that the color settings, one option, custom monochrome. |
1093 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome', | 1053 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome', |
1094 function() { | 1054 function() { |
1095 this.setInitialSettings(); | 1055 this.setInitialSettings(); |
1096 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1056 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1097 function() { | 1057 function() { |
1098 this.setLocalDestinations(); | 1058 this.setLocalDestinations(); |
1099 | 1059 |
1100 // Only one option, standard monochrome. | 1060 // Only one option, standard monochrome. |
1101 var device = getCddTemplate("FooDevice"); | 1061 var device = getCddTemplate("FooDevice"); |
1102 device.capabilities.printer.color = { | 1062 device.capabilities.printer.color = { |
1103 "option": [ | 1063 "option": [ |
1104 {"is_default": true, "type": "CUSTOM_MONOCHROME", | 1064 {"is_default": true, "type": "CUSTOM_MONOCHROME", |
1105 "vendor_id": "42"} | 1065 "vendor_id": "42"} |
1106 ] | 1066 ] |
1107 }; | 1067 }; |
1108 this.setCapabilities(device); | 1068 this.setCapabilities(device); |
1109 | 1069 |
1110 checkSectionVisible($('color-settings'), false); | 1070 checkSectionVisible($('color-settings'), false); |
1111 | 1071 |
1112 this.waitForAnimationToEnd('more-settings'); | 1072 this.waitForAnimationToEnd('more-settings'); |
1113 }.bind(this)); | 1073 }.bind(this)); |
1114 }); | 1074 }); |
1115 | 1075 |
1116 // Test that the color settings, one option, standard color. | 1076 // Test that the color settings, one option, standard color. |
1117 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() { | 1077 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() { |
1118 this.setInitialSettings(); | 1078 this.setInitialSettings(); |
1119 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1079 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1120 function() { | 1080 function() { |
1121 this.setLocalDestinations(); | 1081 this.setLocalDestinations(); |
1122 | 1082 |
1123 var device = getCddTemplate("FooDevice"); | 1083 var device = getCddTemplate("FooDevice"); |
1124 device.capabilities.printer.color = { | 1084 device.capabilities.printer.color = { |
1125 "option": [ | 1085 "option": [ |
1126 {"is_default": true, "type": "STANDARD_COLOR"} | 1086 {"is_default": true, "type": "STANDARD_COLOR"} |
1127 ] | 1087 ] |
1128 }; | 1088 }; |
1129 this.setCapabilities(device); | 1089 this.setCapabilities(device); |
1130 | 1090 |
1131 checkSectionVisible($('color-settings'), false); | 1091 checkSectionVisible($('color-settings'), false); |
1132 | 1092 |
1133 this.waitForAnimationToEnd('more-settings'); | 1093 this.waitForAnimationToEnd('more-settings'); |
1134 }.bind(this)); | 1094 }.bind(this)); |
1135 }); | 1095 }); |
1136 | 1096 |
1137 // Test that the color settings, one option, custom color. | 1097 // Test that the color settings, one option, custom color. |
1138 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() { | 1098 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() { |
1139 this.setInitialSettings(); | 1099 this.setInitialSettings(); |
1140 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1100 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1141 function() { | 1101 function() { |
1142 this.setLocalDestinations(); | 1102 this.setLocalDestinations(); |
1143 | 1103 |
1144 var device = getCddTemplate("FooDevice"); | 1104 var device = getCddTemplate("FooDevice"); |
1145 device.capabilities.printer.color = { | 1105 device.capabilities.printer.color = { |
1146 "option": [ | 1106 "option": [ |
1147 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"} | 1107 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"} |
1148 ] | 1108 ] |
1149 }; | 1109 }; |
1150 this.setCapabilities(device); | 1110 this.setCapabilities(device); |
1151 | 1111 |
1152 checkSectionVisible($('color-settings'), false); | 1112 checkSectionVisible($('color-settings'), false); |
1153 | 1113 |
1154 this.waitForAnimationToEnd('more-settings'); | 1114 this.waitForAnimationToEnd('more-settings'); |
1155 }.bind(this)); | 1115 }.bind(this)); |
1156 }); | 1116 }); |
1157 | 1117 |
1158 // Test that the color settings, two options, both standard, defaults to color. | 1118 // Test that the color settings, two options, both standard, defaults to color. |
1159 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor', | 1119 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor', |
1160 function() { | 1120 function() { |
1161 this.setInitialSettings(); | 1121 this.setInitialSettings(); |
1162 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1122 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1163 function() { | 1123 function() { |
1164 this.setLocalDestinations(); | 1124 this.setLocalDestinations(); |
1165 | 1125 |
1166 var device = getCddTemplate("FooDevice"); | 1126 var device = getCddTemplate("FooDevice"); |
1167 device.capabilities.printer.color = { | 1127 device.capabilities.printer.color = { |
1168 "option": [ | 1128 "option": [ |
1169 {"type": "STANDARD_MONOCHROME"}, | 1129 {"type": "STANDARD_MONOCHROME"}, |
1170 {"is_default": true, "type": "STANDARD_COLOR"} | 1130 {"is_default": true, "type": "STANDARD_COLOR"} |
1171 ] | 1131 ] |
1172 }; | 1132 }; |
1173 this.setCapabilities(device); | 1133 this.setCapabilities(device); |
1174 | 1134 |
1175 checkSectionVisible($('color-settings'), true); | 1135 checkSectionVisible($('color-settings'), true); |
1176 expectEquals( | 1136 expectEquals( |
1177 'color', | 1137 'color', |
1178 $('color-settings').querySelector('.color-settings-select').value); | 1138 $('color-settings').querySelector('.color-settings-select').value); |
1179 | 1139 |
1180 this.waitForAnimationToEnd('more-settings'); | 1140 this.waitForAnimationToEnd('more-settings'); |
1181 }.bind(this)); | 1141 }.bind(this)); |
1182 }); | 1142 }); |
1183 | 1143 |
1184 // Test that the color settings, two options, both standard, defaults to | 1144 // Test that the color settings, two options, both standard, defaults to |
1185 // monochrome. | 1145 // monochrome. |
1186 TEST_F('PrintPreviewWebUITest', | 1146 TEST_F('PrintPreviewWebUITest', |
1187 'TestColorSettingsBothStandardDefaultMonochrome', function() { | 1147 'TestColorSettingsBothStandardDefaultMonochrome', function() { |
1188 this.setInitialSettings(); | 1148 this.setInitialSettings(); |
1189 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1149 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1190 function() { | 1150 function() { |
1191 this.setLocalDestinations(); | 1151 this.setLocalDestinations(); |
1192 | 1152 |
1193 var device = getCddTemplate("FooDevice"); | 1153 var device = getCddTemplate("FooDevice"); |
1194 device.capabilities.printer.color = { | 1154 device.capabilities.printer.color = { |
1195 "option": [ | 1155 "option": [ |
1196 {"is_default": true, "type": "STANDARD_MONOCHROME"}, | 1156 {"is_default": true, "type": "STANDARD_MONOCHROME"}, |
1197 {"type": "STANDARD_COLOR"} | 1157 {"type": "STANDARD_COLOR"} |
1198 ] | 1158 ] |
1199 }; | 1159 }; |
1200 this.setCapabilities(device); | 1160 this.setCapabilities(device); |
1201 | 1161 |
1202 checkSectionVisible($('color-settings'), true); | 1162 checkSectionVisible($('color-settings'), true); |
1203 expectEquals( | 1163 expectEquals( |
1204 'bw', | 1164 'bw', |
1205 $('color-settings').querySelector('.color-settings-select').value); | 1165 $('color-settings').querySelector('.color-settings-select').value); |
1206 | 1166 |
1207 this.waitForAnimationToEnd('more-settings'); | 1167 this.waitForAnimationToEnd('more-settings'); |
1208 }.bind(this)); | 1168 }.bind(this)); |
1209 }); | 1169 }); |
1210 | 1170 |
1211 // Test that the color settings, two options, both custom, defaults to color. | 1171 // Test that the color settings, two options, both custom, defaults to color. |
1212 TEST_F('PrintPreviewWebUITest', | 1172 TEST_F('PrintPreviewWebUITest', |
1213 'TestColorSettingsBothCustomDefaultColor', function() { | 1173 'TestColorSettingsBothCustomDefaultColor', function() { |
1214 this.setInitialSettings(); | 1174 this.setInitialSettings(); |
1215 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1175 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1216 function() { | 1176 function() { |
1217 this.setLocalDestinations(); | 1177 this.setLocalDestinations(); |
1218 | 1178 |
1219 var device = getCddTemplate("FooDevice"); | 1179 var device = getCddTemplate("FooDevice"); |
1220 device.capabilities.printer.color = { | 1180 device.capabilities.printer.color = { |
1221 "option": [ | 1181 "option": [ |
1222 {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"}, | 1182 {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"}, |
1223 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"} | 1183 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"} |
1224 ] | 1184 ] |
1225 }; | 1185 }; |
1226 this.setCapabilities(device); | 1186 this.setCapabilities(device); |
1227 | 1187 |
1228 checkSectionVisible($('color-settings'), true); | 1188 checkSectionVisible($('color-settings'), true); |
1229 expectEquals( | 1189 expectEquals( |
1230 'color', | 1190 'color', |
1231 $('color-settings').querySelector('.color-settings-select').value); | 1191 $('color-settings').querySelector('.color-settings-select').value); |
1232 | 1192 |
1233 this.waitForAnimationToEnd('more-settings'); | 1193 this.waitForAnimationToEnd('more-settings'); |
1234 }.bind(this)); | 1194 }.bind(this)); |
1235 }); | 1195 }); |
1236 | 1196 |
1237 // Test to verify that duplex settings are set according to the printer | 1197 // Test to verify that duplex settings are set according to the printer |
1238 // capabilities. | 1198 // capabilities. |
1239 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { | 1199 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { |
1240 this.setInitialSettings(); | 1200 this.setInitialSettings(); |
1241 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1201 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1242 function() { | 1202 function() { |
1243 this.setLocalDestinations(); | 1203 this.setLocalDestinations(); |
1244 this.setCapabilities(getCddTemplate("FooDevice")); | 1204 this.setCapabilities(getCddTemplate("FooDevice")); |
1245 | 1205 |
1246 var otherOptions = $('other-options-settings'); | 1206 var otherOptions = $('other-options-settings'); |
1247 checkSectionVisible(otherOptions, true); | 1207 checkSectionVisible(otherOptions, true); |
1248 duplexContainer = otherOptions.querySelector('#duplex-container'); | 1208 duplexContainer = otherOptions.querySelector('#duplex-container'); |
1249 expectFalse(duplexContainer.hidden); | 1209 expectFalse(duplexContainer.hidden); |
1250 expectFalse(duplexContainer.querySelector('.checkbox').checked); | 1210 expectFalse(duplexContainer.querySelector('.checkbox').checked); |
1251 | 1211 |
1252 this.waitForAnimationToEnd('more-settings'); | 1212 this.waitForAnimationToEnd('more-settings'); |
1253 }.bind(this)); | 1213 }.bind(this)); |
1254 }); | 1214 }); |
1255 | 1215 |
1256 // Test to verify that duplex settings are set according to the printer | 1216 // Test to verify that duplex settings are set according to the printer |
1257 // capabilities. | 1217 // capabilities. |
1258 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { | 1218 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { |
1259 this.setInitialSettings(); | 1219 this.setInitialSettings(); |
1260 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1220 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1261 function() { | 1221 function() { |
1262 this.setLocalDestinations(); | 1222 this.setLocalDestinations(); |
1263 var device = getCddTemplate("FooDevice"); | 1223 var device = getCddTemplate("FooDevice"); |
1264 delete device.capabilities.printer.duplex; | 1224 delete device.capabilities.printer.duplex; |
1265 this.setCapabilities(device); | 1225 this.setCapabilities(device); |
1266 | 1226 |
1267 // Check that it is collapsed. | 1227 // Check that it is collapsed. |
1268 var otherOptions = $('other-options-settings'); | 1228 var otherOptions = $('other-options-settings'); |
1269 checkSectionVisible(otherOptions, false); | 1229 checkSectionVisible(otherOptions, false); |
1270 | 1230 |
1271 this.expandMoreSettings(); | 1231 this.expandMoreSettings(); |
1272 | 1232 |
1273 // Now it should be visible. | 1233 // Now it should be visible. |
1274 checkSectionVisible(otherOptions, true); | 1234 checkSectionVisible(otherOptions, true); |
1275 expectTrue(otherOptions.querySelector('#duplex-container').hidden); | 1235 expectTrue(otherOptions.querySelector('#duplex-container').hidden); |
1276 | 1236 |
1277 this.waitForAnimationToEnd('more-settings'); | 1237 this.waitForAnimationToEnd('more-settings'); |
1278 }.bind(this)); | 1238 }.bind(this)); |
1279 }); | 1239 }); |
1280 | 1240 |
1281 // Test that changing the selected printer updates the preview. | 1241 // Test that changing the selected printer updates the preview. |
1282 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { | 1242 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { |
1283 this.setInitialSettings(); | 1243 this.setInitialSettings(); |
1284 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1244 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1285 function() { | 1245 function() { |
1286 this.setLocalDestinations(); | 1246 this.setLocalDestinations(); |
1287 this.setCapabilities(getCddTemplate("FooDevice")); | 1247 this.setCapabilities(getCddTemplate("FooDevice")); |
1288 | 1248 |
1289 var previewGenerator = mock(print_preview.PreviewGenerator); | 1249 var previewGenerator = mock(print_preview.PreviewGenerator); |
1290 this.printPreview_.previewArea_.previewGenerator_ = | 1250 this.previewArea_.previewGenerator_ = |
1291 previewGenerator.proxy(); | 1251 previewGenerator.proxy(); |
1292 | 1252 |
1293 // The number of settings that can change due to a change in the | 1253 // The number of settings that can change due to a change in the |
1294 // destination that will therefore dispatch ticket item change events. | 1254 // destination that will therefore dispatch ticket item change events. |
1295 previewGenerator.expects(exactly(9)).requestPreview(); | 1255 previewGenerator.expects(exactly(9)).requestPreview(); |
1296 | 1256 |
1297 var barDestination = | 1257 var barDestination = |
1298 this.printPreview_.destinationStore_.destinations().find( | 1258 this.printPreview_.destinationStore_.destinations().find( |
1299 function(d) { | 1259 function(d) { |
1300 return d.id == 'BarDevice'; | 1260 return d.id == 'BarDevice'; |
1301 }); | 1261 }); |
1302 | 1262 |
1303 this.printPreview_.destinationStore_.selectDestination(barDestination); | 1263 this.printPreview_.destinationStore_.selectDestination(barDestination); |
1304 | 1264 |
1305 var device = getCddTemplate("BarDevice"); | 1265 var device = getCddTemplate("BarDevice"); |
1306 device.capabilities.printer.color = { | 1266 device.capabilities.printer.color = { |
1307 "option": [ | 1267 "option": [ |
1308 {"is_default": true, "type": "STANDARD_MONOCHROME"} | 1268 {"is_default": true, "type": "STANDARD_MONOCHROME"} |
1309 ] | 1269 ] |
1310 }; | 1270 }; |
1311 this.setCapabilities(device); | 1271 this.setCapabilities(device); |
1312 | 1272 |
1313 this.waitForAnimationToEnd('more-settings'); | 1273 this.waitForAnimationToEnd('more-settings'); |
1314 }.bind(this)); | 1274 }.bind(this)); |
1315 }); | 1275 }); |
1316 | 1276 |
1317 // Test that error message is displayed when plugin doesn't exist. | 1277 // Test that error message is displayed when plugin doesn't exist. |
1318 TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() { | 1278 TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() { |
1319 this.setInitialSettings(); | 1279 this.setInitialSettings(); |
1320 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1280 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1321 function() { | 1281 function() { |
1322 var previewAreaEl = $('preview-area'); | 1282 var previewAreaEl = $('preview-area'); |
1323 | 1283 |
1324 var loadingMessageEl = | 1284 var loadingMessageEl = |
1325 previewAreaEl. | 1285 previewAreaEl. |
1326 getElementsByClassName('preview-area-loading-message')[0]; | 1286 getElementsByClassName('preview-area-loading-message')[0]; |
1327 expectTrue(loadingMessageEl.hidden); | 1287 expectTrue(loadingMessageEl.hidden); |
1328 | 1288 |
1329 var previewFailedMessageEl = previewAreaEl.getElementsByClassName( | 1289 var previewFailedMessageEl = previewAreaEl.getElementsByClassName( |
1330 'preview-area-preview-failed-message')[0]; | 1290 'preview-area-preview-failed-message')[0]; |
1331 expectTrue(previewFailedMessageEl.hidden); | 1291 expectTrue(previewFailedMessageEl.hidden); |
1332 | 1292 |
1333 var printFailedMessageEl = | 1293 var printFailedMessageEl = |
1334 previewAreaEl. | 1294 previewAreaEl. |
1335 getElementsByClassName('preview-area-print-failed')[0]; | 1295 getElementsByClassName('preview-area-print-failed')[0]; |
1336 expectTrue(printFailedMessageEl.hidden); | 1296 expectTrue(printFailedMessageEl.hidden); |
1337 | 1297 |
1338 var customMessageEl = | 1298 var customMessageEl = |
1339 previewAreaEl. | 1299 previewAreaEl. |
1340 getElementsByClassName('preview-area-custom-message')[0]; | 1300 getElementsByClassName('preview-area-custom-message')[0]; |
1341 expectFalse(customMessageEl.hidden); | 1301 expectFalse(customMessageEl.hidden); |
1342 | 1302 |
1343 testDone(); | 1303 testDone(); |
1344 }); | 1304 }); |
1345 }); | 1305 }); |
1346 | 1306 |
1347 // Test custom localized paper names. | 1307 // Test custom localized paper names. |
1348 TEST_F('PrintPreviewWebUITest', 'TestCustomPaperNames', function() { | 1308 TEST_F('PrintPreviewWebUITest', 'TestCustomPaperNames', function() { |
1349 this.setInitialSettings(); | 1309 this.setInitialSettings(); |
1350 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1310 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1351 function() { | 1311 function() { |
1352 this.setLocalDestinations(); | 1312 this.setLocalDestinations(); |
1353 | 1313 |
1354 var customLocalizedMediaName = 'Vendor defined localized media name'; | 1314 var customLocalizedMediaName = 'Vendor defined localized media name'; |
1355 var customMediaName = 'Vendor defined media name'; | 1315 var customMediaName = 'Vendor defined media name'; |
1356 | 1316 |
1357 var device = getCddTemplate("FooDevice"); | 1317 var device = getCddTemplate("FooDevice"); |
1358 device.capabilities.printer.media_size = { | 1318 device.capabilities.printer.media_size = { |
1359 option: [ | 1319 option: [ |
1360 { name: 'CUSTOM', | 1320 { name: 'CUSTOM', |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 advancedOptionsSettingsButton.disabled = false; | 1426 advancedOptionsSettingsButton.disabled = false; |
1467 advancedOptionsSettingsButton.click(); | 1427 advancedOptionsSettingsButton.click(); |
1468 } | 1428 } |
1469 | 1429 |
1470 // Test advanced settings with 1 capability (should not display settings search | 1430 // Test advanced settings with 1 capability (should not display settings search |
1471 // box). | 1431 // box). |
1472 TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings1Option', function() { | 1432 TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings1Option', function() { |
1473 var device = getCddTemplateWithAdvancedSettings("FooDevice"); | 1433 var device = getCddTemplateWithAdvancedSettings("FooDevice"); |
1474 this.accessibilityIssuesAreErrors = false; | 1434 this.accessibilityIssuesAreErrors = false; |
1475 this.setInitialSettings(); | 1435 this.setInitialSettings(); |
1476 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1436 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1477 function() { | 1437 function() { |
1478 this.setupAdvancedSettingsTest(device); | 1438 this.setupAdvancedSettingsTest(device); |
1479 | 1439 |
1480 // Open the advanced settings overlay. | 1440 // Open the advanced settings overlay. |
1481 openAdvancedSettings(); | 1441 openAdvancedSettings(); |
1482 | 1442 |
1483 // Check that advanced settings close button is now visible, | 1443 // Check that advanced settings close button is now visible, |
1484 // but not the search box (only 1 capability). | 1444 // but not the search box (only 1 capability). |
1485 var advancedSettingsCloseButton = $('advanced-settings'). | 1445 var advancedSettingsCloseButton = $('advanced-settings'). |
1486 querySelector('.close-button'); | 1446 querySelector('.close-button'); |
(...skipping 17 matching lines...) Expand all Loading... |
1504 select_cap: { | 1464 select_cap: { |
1505 option: [ | 1465 option: [ |
1506 {display_name: 'Standard', value: 0, is_default: true}, | 1466 {display_name: 'Standard', value: 0, is_default: true}, |
1507 {display_name: 'Recycled', value: 1}, | 1467 {display_name: 'Recycled', value: 1}, |
1508 {display_name: 'Special', value: 2} | 1468 {display_name: 'Special', value: 2} |
1509 ] | 1469 ] |
1510 } | 1470 } |
1511 }); | 1471 }); |
1512 this.accessibilityIssuesAreErrors = false; | 1472 this.accessibilityIssuesAreErrors = false; |
1513 this.setInitialSettings(); | 1473 this.setInitialSettings(); |
1514 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1474 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1515 function() { | 1475 function() { |
1516 this.setupAdvancedSettingsTest(device); | 1476 this.setupAdvancedSettingsTest(device); |
1517 | 1477 |
1518 // Open the advanced settings overlay. | 1478 // Open the advanced settings overlay. |
1519 openAdvancedSettings(); | 1479 openAdvancedSettings(); |
1520 | 1480 |
1521 // Check advanced settings is visible and that the search box now | 1481 // Check advanced settings is visible and that the search box now |
1522 // appears. | 1482 // appears. |
1523 var advancedSettingsCloseButton = $('advanced-settings'). | 1483 var advancedSettingsCloseButton = $('advanced-settings'). |
1524 querySelector('.close-button'); | 1484 querySelector('.close-button'); |
(...skipping 20 matching lines...) Expand all Loading... |
1545 extensionId: '', extensionName: '' | 1505 extensionId: '', extensionName: '' |
1546 }; | 1506 }; |
1547 }), | 1507 }), |
1548 }; | 1508 }; |
1549 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings); | 1509 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings); |
1550 this.setCapabilities(getCddTemplate('ID1')); | 1510 this.setCapabilities(getCddTemplate('ID1')); |
1551 this.setCapabilities(getCddTemplate('ID2')); | 1511 this.setCapabilities(getCddTemplate('ID2')); |
1552 this.setCapabilities(getCddTemplate('ID3')); | 1512 this.setCapabilities(getCddTemplate('ID3')); |
1553 | 1513 |
1554 // Use a real preview generator. | 1514 // Use a real preview generator. |
1555 this.printPreview_.previewArea_.previewGenerator_ = | 1515 this.previewArea_.previewGenerator_ = |
1556 new print_preview.PreviewGenerator(this.printPreview_.destinationStore_, | 1516 new print_preview.PreviewGenerator(this.printPreview_.destinationStore_, |
1557 this.printPreview_.printTicketStore_, this.nativeLayer_, | 1517 this.printPreview_.printTicketStore_, this.nativeLayer_, |
1558 this.printPreview_.documentInfo_); | 1518 this.printPreview_.documentInfo_); |
1559 | 1519 |
1560 // Preview generator starts out with inFlightRequestId_ == -1. The id | 1520 // Preview generator starts out with inFlightRequestId_ == -1. The id |
1561 // increments by 1 for each startGetPreview call it makes. It should only | 1521 // increments by 1 for each startGetPreview call it makes. It should only |
1562 // make one such call during initialization or there will be a race; see | 1522 // make one such call during initialization or there will be a race; see |
1563 // crbug.com/666595 | 1523 // crbug.com/666595 |
1564 expectEquals( | 1524 expectEquals( |
1565 -1, | 1525 -1, |
1566 this.printPreview_.previewArea_.previewGenerator_.inFlightRequestId_); | 1526 this.previewArea_.previewGenerator_.inFlightRequestId_); |
1567 this.setInitialSettings(); | 1527 this.setInitialSettings(); |
1568 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1528 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1569 function() { | 1529 function() { |
1570 expectEquals( | 1530 expectEquals( |
1571 0, | 1531 0, |
1572 this.printPreview_.previewArea_.previewGenerator_. | 1532 this.previewArea_.previewGenerator_. |
1573 inFlightRequestId_); | 1533 inFlightRequestId_); |
1574 testDone(); | 1534 testDone(); |
1575 }.bind(this)); | 1535 }.bind(this)); |
1576 }); | 1536 }); |
1577 | 1537 |
1578 // Test that invalid settings errors disable the print preview and display | 1538 // Test that invalid settings errors disable the print preview and display |
1579 // an error and that the preview dialog can be recovered by selecting a | 1539 // an error and that the preview dialog can be recovered by selecting a |
1580 // new destination. | 1540 // new destination. |
1581 TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() { | 1541 TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() { |
1582 // Setup | 1542 // Setup |
1583 this.setInitialSettings(); | 1543 this.setInitialSettings(); |
1584 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1544 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1585 function() { | 1545 function() { |
1586 this.setLocalDestinations(); | 1546 this.setLocalDestinations(); |
1587 this.setCapabilities(getCddTemplate("FooDevice")); | 1547 this.setCapabilities(getCddTemplate("FooDevice")); |
1588 | 1548 |
1589 // Manually enable the print header. This is needed since there is no | 1549 // Manually enable the print header. This is needed since there is no |
1590 // plugin during test, so it will be set as disabled normally. | 1550 // plugin during test, so it will be set as disabled normally. |
1591 this.printPreview_.printHeader_.isEnabled = true; | 1551 this.printPreview_.printHeader_.isEnabled = true; |
1592 | 1552 |
1593 // There will be an error message in the preview area since the plugin | 1553 // There will be an error message in the preview area since the plugin |
1594 // is not running. However, it should not be the invalid settings error. | 1554 // is not running. However, it should not be the invalid settings error. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 testDone(); | 1599 testDone(); |
1640 }.bind(this)); | 1600 }.bind(this)); |
1641 }); | 1601 }); |
1642 | 1602 |
1643 // Test the preview generator to make sure the generate draft parameter is set | 1603 // Test the preview generator to make sure the generate draft parameter is set |
1644 // correctly. It should be false if the only change is the page range. | 1604 // correctly. It should be false if the only change is the page range. |
1645 TEST_F('PrintPreviewWebUITest', 'TestGenerateDraft', function() { | 1605 TEST_F('PrintPreviewWebUITest', 'TestGenerateDraft', function() { |
1646 this.createPrintPreview(); | 1606 this.createPrintPreview(); |
1647 | 1607 |
1648 // Use a real preview generator. | 1608 // Use a real preview generator. |
1649 this.printPreview_.previewArea_.previewGenerator_ = | 1609 this.previewArea_.previewGenerator_ = |
1650 new print_preview.PreviewGenerator(this.printPreview_.destinationStore_, | 1610 new print_preview.PreviewGenerator(this.printPreview_.destinationStore_, |
1651 this.printPreview_.printTicketStore_, this.nativeLayer_, | 1611 this.printPreview_.printTicketStore_, this.nativeLayer_, |
1652 this.printPreview_.documentInfo_); | 1612 this.printPreview_.documentInfo_); |
1653 | 1613 |
1654 this.setInitialSettings(); | 1614 this.setInitialSettings(); |
1655 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( | 1615 this.nativeLayer_.whenCalled('getInitialSettings').then( |
1656 function() { | 1616 function() { |
1657 this.setLocalDestinations(); | 1617 this.setLocalDestinations(); |
1658 this.setCapabilities(getCddTemplate("FooDevice")); | 1618 this.setCapabilities(getCddTemplate("FooDevice")); |
1659 | 1619 |
1660 // The first request should generate draft because there was no | 1620 // The first request should generate draft because there was no |
1661 // previous print preview draft. | 1621 // previous print preview draft. |
1662 expectTrue(this.generateDraft()); | 1622 expectTrue(this.generateDraft()); |
1663 | 1623 |
1664 // Change the page range - no new draft needed. | 1624 // Change the page range - no new draft needed. |
1665 this.printPreview_.printTicketStore_.pageRange.updateValue("2"); | 1625 this.printPreview_.printTicketStore_.pageRange.updateValue("2"); |
1666 expectFalse(this.generateDraft()); | 1626 expectFalse(this.generateDraft()); |
1667 | 1627 |
1668 // Change the margin type - need to regenerate again. | 1628 // Change the margin type - need to regenerate again. |
1669 this.printPreview_.printTicketStore_.marginsType.updateValue( | 1629 this.printPreview_.printTicketStore_.marginsType.updateValue( |
1670 print_preview.ticket_items.MarginsTypeValue.NO_MARGINS); | 1630 print_preview.ticket_items.MarginsTypeValue.NO_MARGINS); |
1671 expectTrue(this.generateDraft()); | 1631 expectTrue(this.generateDraft()); |
1672 | 1632 |
1673 testDone(); | 1633 testDone(); |
1674 }.bind(this)); | 1634 }.bind(this)); |
1675 }); | 1635 }); |
OLD | NEW |