Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: chrome/test/data/webui/print_preview/print_preview.js

Issue 2893003003: Print Preview: Merge NativeLayerStubs for tests (Closed)
Patch Set: Address comments, rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 var ROOT_PATH = '../../../../../';
6 GEN('#include "chrome/common/chrome_features.h"');
7
8 var ROOT_PATH = '../../../../';
9 6
10 /** 7 /**
11 * Test fixture for print preview WebUI testing. 8 * Test fixture for print preview WebUI testing.
12 * @constructor 9 * @constructor
13 * @extends {testing.Test} 10 * @extends {testing.Test}
14 */ 11 */
15 function PrintPreviewWebUITest() { 12 function PrintPreviewWebUITest() {
16 testing.Test.call(this); 13 testing.Test.call(this);
17 this.printPreview_ = null; 14 this.printPreview_ = null;
18 this.nativeLayer_ = null; 15 this.nativeLayer_ = null;
(...skipping 24 matching lines...) Expand all
43 PrintPreviewWebUITest.BAR_INDEX = 2; 40 PrintPreviewWebUITest.BAR_INDEX = 2;
44 41
45 PrintPreviewWebUITest.prototype = { 42 PrintPreviewWebUITest.prototype = {
46 __proto__: testing.Test.prototype, 43 __proto__: testing.Test.prototype,
47 44
48 /** 45 /**
49 * Browse to the sample page, cause print preview & call preLoad(). 46 * Browse to the sample page, cause print preview & call preLoad().
50 * @type {string} 47 * @type {string}
51 * @override 48 * @override
52 */ 49 */
53 browsePrintPreload: 'print_preview_hello_world_test.html', 50 browsePrintPreload: 'print_preview/print_preview_hello_world_test.html',
54 51
55 /** @override */ 52 /** @override */
56 runAccessibilityChecks: true, 53 runAccessibilityChecks: true,
57 54
58 /** @override */ 55 /** @override */
59 accessibilityIssuesAreErrors: true, 56 accessibilityIssuesAreErrors: true,
60 57
61 /** @override */ 58 /** @override */
62 isAsync: true, 59 isAsync: true,
63 60
64 /** 61 /**
65 * Stub out low-level functionality like the NativeLayer and 62 * Stub out low-level functionality like the NativeLayer and
66 * CloudPrintInterface. 63 * CloudPrintInterface.
67 * @this {PrintPreviewWebUITest} 64 * @this {PrintPreviewWebUITest}
68 * @override 65 * @override
69 */ 66 */
70 preLoad: function() { 67 preLoad: function() {
71 window.isTest = true; 68 window.isTest = true;
72 window.addEventListener('DOMContentLoaded', function() { 69 window.addEventListener('DOMContentLoaded', function() {
73 /**
74 * Test version of the native layer.
75 * @constructor
76 * @extends {settings.TestBrowserProxy}
77 */
78 function NativeLayerStub() {
79 settings.TestBrowserProxy.call(this, [ 'getInitialSettings' ]);
80 this.eventTarget_ = new cr.EventTarget();
81 this.printStarted_ = false;
82 this.generateDraft_ = false;
83 this.initialSettings_ = null;
84 }
85 NativeLayerStub.prototype = {
86 __proto__: settings.TestBrowserProxy.prototype,
87 getEventTarget: function() { return this.eventTarget_; },
88 isPrintStarted: function() { return this.printStarted_; },
89 generateDraft: function() { return this.generateDraft_; },
90 getInitialSettings: function() {
91 this.methodCalled('getInitialSettings');
92 return Promise.resolve(this.initialSettings_);
93 },
94 previewReadyForTest: function() {},
95 startGetLocalDestinations: function() {},
96 startGetPrivetDestinations: function() {},
97 startGetExtensionDestinations: function() {},
98 startGetLocalDestinationCapabilities: function(destinationId) {},
99 startGetPreview: function(destination, printTicketStore, documentInfo,
100 generateDraft, requestId) {
101 this.generateDraft_ = generateDraft;
102 },
103 startHideDialog: function () {},
104 startPrint: function () { this.printStarted_ = true; }
105 };
106 var oldNativeLayerEventType = print_preview.NativeLayer.EventType;
107 var oldDuplexMode = print_preview.NativeLayer.DuplexMode;
108 print_preview.NativeLayer = NativeLayerStub;
109 print_preview.NativeLayer.EventType = oldNativeLayerEventType;
110 print_preview.NativeLayer.DuplexMode = oldDuplexMode;
111
112 function CloudPrintInterfaceStub() { 70 function CloudPrintInterfaceStub() {
113 cr.EventTarget.call(this); 71 cr.EventTarget.call(this);
114 } 72 }
115 CloudPrintInterfaceStub.prototype = { 73 CloudPrintInterfaceStub.prototype = {
116 __proto__: cr.EventTarget.prototype, 74 __proto__: cr.EventTarget.prototype,
117 search: function(isRecent) {} 75 search: function(isRecent) {}
118 }; 76 };
119 var oldCpInterfaceEventType = cloudprint.CloudPrintInterfaceEventType; 77 var oldCpInterfaceEventType = cloudprint.CloudPrintInterfaceEventType;
120 cloudprint.CloudPrintInterface = CloudPrintInterfaceStub; 78 cloudprint.CloudPrintInterface = CloudPrintInterfaceStub;
121 cloudprint.CloudPrintInterfaceEventType = oldCpInterfaceEventType; 79 cloudprint.CloudPrintInterfaceEventType = oldCpInterfaceEventType;
122 80
123 print_preview.PreviewArea.prototype.checkPluginCompatibility_ = 81 print_preview.PreviewArea.prototype.checkPluginCompatibility_ =
124 function() { 82 function() {
125 return false; 83 return false;
126 }; 84 };
127 }.bind(this)); 85 }.bind(this));
128 }, 86 },
129 87
130 extraLibraries: [ 88 extraLibraries: [
131 ROOT_PATH + 'ui/webui/resources/js/cr.js', 89 ROOT_PATH + 'ui/webui/resources/js/cr.js',
132 ROOT_PATH + 'ui/webui/resources/js/promise_resolver.js', 90 ROOT_PATH + 'ui/webui/resources/js/promise_resolver.js',
133 ROOT_PATH + 'ui/webui/resources/js/util.js', 91 ROOT_PATH + 'ui/webui/resources/js/util.js',
134 ROOT_PATH + 'chrome/test/data/webui/settings/test_browser_proxy.js', 92 ROOT_PATH + 'chrome/test/data/webui/settings/test_browser_proxy.js',
93 'native_layer_stub.js',
135 ], 94 ],
136 95
137 /** 96 /**
138 * Creates an instance of print_preview.PrintPreview and initializes the 97 * Creates an instance of print_preview.PrintPreview and initializes the
139 * |nativeLayer_| and |previewArea_|. 98 * |nativeLayer_| and |previewArea_|.
140 */ 99 */
141 createPrintPreview: function() { 100 createPrintPreview: function() {
101 this.nativeLayer_ = new print_preview.NativeLayerStub();
102 print_preview.NativeLayer.setInstance(this.nativeLayer_);
142 this.printPreview_ = new print_preview.PrintPreview(); 103 this.printPreview_ = new print_preview.PrintPreview();
143 this.nativeLayer_ = this.printPreview_.nativeLayer_; 104 this.previewArea_ = this.printPreview_.getPreviewArea();
144 this.previewArea_ = this.printPreview_.previewArea_;
145 }, 105 },
146 106
147 /** 107 /**
148 * Initialize print preview with the initial settings currently stored in 108 * Initialize print preview with the initial settings currently stored in
149 * |this.initialSettings_|. Creates |this.printPreview_| if it does not 109 * |this.initialSettings_|. Creates |this.printPreview_| if it does not
150 * already exist. 110 * already exist.
151 */ 111 */
152 setInitialSettings: function() { 112 setInitialSettings: function() {
153 if (!this.printPreview_) { 113 if (!this.printPreview_)
154 this.printPreview_ = new print_preview.PrintPreview(); 114 this.createPrintPreview();
155 this.nativeLayer_ = this.printPreview_.nativeLayer_; 115 this.nativeLayer_.setInitialSettings(this.initialSettings_);
156 this.previewArea_ = this.printPreview_.previewArea_;
157 }
158 this.nativeLayer_.initialSettings_ = this.initialSettings_;
159 this.printPreview_.initialize(); 116 this.printPreview_.initialize();
160 testing.Test.disableAnimationsAndTransitions(); 117 testing.Test.disableAnimationsAndTransitions();
161 // Enable when failure is resolved. 118 // Enable when failure is resolved.
162 // AX_TEXT_03: http://crbug.com/559209 119 // AX_TEXT_03: http://crbug.com/559209
163 this.accessibilityAuditConfig.ignoreSelectors( 120 this.accessibilityAuditConfig.ignoreSelectors(
164 'multipleLabelableElementsPerLabel', 121 'multipleLabelableElementsPerLabel',
165 '#page-settings > .right-column > *'); 122 '#page-settings > .right-column > *');
166 }, 123 },
167 124
168 /** 125 /**
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // Need to disable this since overlay animation will not fully complete. 214 // Need to disable this since overlay animation will not fully complete.
258 this.setLocalDestinations(); 215 this.setLocalDestinations();
259 this.setCapabilities(device); 216 this.setCapabilities(device);
260 this.expandMoreSettings(); 217 this.expandMoreSettings();
261 218
262 // Check that the advanced options settings section is visible. 219 // Check that the advanced options settings section is visible.
263 checkSectionVisible($('advanced-options-settings'), true); 220 checkSectionVisible($('advanced-options-settings'), true);
264 }, 221 },
265 222
266 /** 223 /**
267 * Generate a real C++ class; don't typedef.
268 * @type {?string}
269 * @override
270 */
271 typedefCppFixture: null,
272
273 /**
274 * @this {PrintPreviewWebUITest} 224 * @this {PrintPreviewWebUITest}
275 * @override 225 * @override
276 */ 226 */
277 setUp: function() { 227 setUp: function() {
278 testing.Test.prototype.setUp.call(this); 228 testing.Test.prototype.setUp.call(this);
279 Mock4JS.clearMocksToVerify(); 229 Mock4JS.clearMocksToVerify();
280 230
281 this.initialSettings_ = new print_preview.NativeInitialSettings( 231 this.initialSettings_ = new print_preview.NativeInitialSettings(
282 false /*isInKioskAutoPrintMode*/, 232 false /*isInKioskAutoPrintMode*/,
283 false /*isInAppKioskMode*/, 233 false /*isInAppKioskMode*/,
284 ',' /*thousandsDelimeter*/, 234 ',' /*thousandsDelimeter*/,
285 '.' /*decimalDelimeter*/, 235 '.' /*decimalDelimeter*/,
286 1 /*unitType*/, 236 1 /*unitType*/,
287 true /*isDocumentModifiable*/, 237 true /*isDocumentModifiable*/,
288 'title' /*documentTitle*/, 238 'title' /*documentTitle*/,
289 true /*documentHasSelection*/, 239 true /*documentHasSelection*/,
290 false /*selectionOnly*/, 240 false /*selectionOnly*/,
291 'FooDevice' /*systemDefaultDestinationId*/, 241 'FooDevice' /*systemDefaultDestinationId*/,
292 null /*serializedAppStateStr*/, 242 null /*serializedAppStateStr*/,
293 null /*serializedDefaultDestinationSelectionRulesStr*/); 243 null /*serializedDefaultDestinationSelectionRulesStr*/);
294 this.localDestinationInfos_ = [ 244 this.localDestinationInfos_ = [
295 { printerName: 'FooName', deviceName: 'FooDevice' }, 245 { printerName: 'FooName', deviceName: 'FooDevice' },
296 { printerName: 'BarName', deviceName: 'BarDevice' } 246 { printerName: 'BarName', deviceName: 'BarDevice' }
297 ]; 247 ];
298 }, 248 },
299 }; 249 };
300 250
301 GEN('#include "chrome/test/data/webui/print_preview.h"');
302
303 // Test some basic assumptions about the print preview WebUI. 251 // Test some basic assumptions about the print preview WebUI.
304 TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() { 252 TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() {
305 this.setInitialSettings(); 253 this.setInitialSettings();
306 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 254 this.nativeLayer_.whenCalled('getInitialSettings').then(
307 function() { 255 function() {
308 this.setLocalDestinations(); 256 this.setLocalDestinations();
309 var recentList = 257 var recentList =
310 $('destination-search').querySelector('.recent-list ul'); 258 $('destination-search').querySelector('.recent-list ul');
311 var localList = 259 var localList =
312 $('destination-search').querySelector('.local-list ul'); 260 $('destination-search').querySelector('.local-list ul');
313 assertNotEquals(null, recentList); 261 assertNotEquals(null, recentList);
314 assertEquals(1, recentList.childNodes.length); 262 assertEquals(1, recentList.childNodes.length);
315 assertEquals('FooName', 263 assertEquals('FooName',
316 recentList.childNodes.item(0).querySelector( 264 recentList.childNodes.item(0).querySelector(
(...skipping 11 matching lines...) Expand all
328 querySelector('.destination-list-item-name').textContent); 276 querySelector('.destination-list-item-name').textContent);
329 testDone(); 277 testDone();
330 }.bind(this)); 278 }.bind(this));
331 }); 279 });
332 280
333 // Test that the printer list is structured correctly after calling 281 // Test that the printer list is structured correctly after calling
334 // addCloudPrinters with an empty list. 282 // addCloudPrinters with an empty list.
335 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() { 283 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() {
336 this.setInitialSettings(); 284 this.setInitialSettings();
337 285
338 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 286 this.nativeLayer_.whenCalled('getInitialSettings').then(
339 function() { 287 function() {
340 this.setLocalDestinations(); 288 this.setLocalDestinations();
341 289
342 var cloudPrintEnableEvent = 290 var cloudPrintEnableEvent =
343 new Event(print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE); 291 new Event(print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE);
344 cloudPrintEnableEvent.baseCloudPrintUrl = 'cloudprint url'; 292 cloudPrintEnableEvent.baseCloudPrintUrl = 'cloudprint url';
345 this.nativeLayer_.getEventTarget().dispatchEvent( 293 this.nativeLayer_.getEventTarget().dispatchEvent(
346 cloudPrintEnableEvent); 294 cloudPrintEnableEvent);
347 295
348 var searchDoneEvent = 296 var searchDoneEvent =
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 408
461 // Test restore settings with one destination. 409 // Test restore settings with one destination.
462 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', 410 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination',
463 function() { 411 function() {
464 this.initialSettings_.serializedAppStateStr_ = 412 this.initialSettings_.serializedAppStateStr_ =
465 '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' + 413 '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' +
466 '"account":"", "capabilities":0, "name":"", "extensionId":"",' + 414 '"account":"", "capabilities":0, "name":"", "extensionId":"",' +
467 '"extensionName":""}]}'; 415 '"extensionName":""}]}';
468 416
469 this.setInitialSettings(); 417 this.setInitialSettings();
470 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 418 this.nativeLayer_.whenCalled('getInitialSettings').then(
471 function() { 419 function() {
472 testDone(); 420 testDone();
473 }); 421 });
474 }); 422 });
475 423
476 // Test with multiple destinations 424 // Test with multiple destinations
477 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations', 425 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations',
478 function() { 426 function() {
479 var origin = cr.isChromeOS ? "chrome_os" : "local"; 427 var origin = cr.isChromeOS ? "chrome_os" : "local";
480 428
(...skipping 26 matching lines...) Expand all
507 'name': '', 455 'name': '',
508 'extensionId': '', 456 'extensionId': '',
509 'extensionName': '' 457 'extensionName': ''
510 } 458 }
511 ] 459 ]
512 }; 460 };
513 461
514 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(appState); 462 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(appState);
515 this.setInitialSettings(); 463 this.setInitialSettings();
516 464
517 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 465 this.nativeLayer_.whenCalled('getInitialSettings').then(
518 function() { 466 function() {
519 // Set capabilities for the three recently used destinations + 1 more 467 // Set capabilities for the three recently used destinations + 1 more
520 this.setCapabilities(getCddTemplate('ID1')); 468 this.setCapabilities(getCddTemplate('ID1'));
521 this.setCapabilities(getCddTemplate('ID2')); 469 this.setCapabilities(getCddTemplate('ID2'));
522 this.setCapabilities(getCddTemplate('ID3')); 470 this.setCapabilities(getCddTemplate('ID3'));
523 this.setCapabilities(getCddTemplate('ID4')); 471 this.setCapabilities(getCddTemplate('ID4'));
524 472
525 // The most recently used destination should be the currently selected 473 // The most recently used destination should be the currently selected
526 // one. This is ID1. 474 // one. This is ID1.
527 assertEquals( 475 assertEquals(
(...skipping 21 matching lines...) Expand all
549 testDone(); 497 testDone();
550 }.bind(this)); 498 }.bind(this));
551 }); 499 });
552 500
553 TEST_F('PrintPreviewWebUITest', 501 TEST_F('PrintPreviewWebUITest',
554 'TestPrintPreviewDefaultDestinationSelectionRules', function() { 502 'TestPrintPreviewDefaultDestinationSelectionRules', function() {
555 // It also makes sure these rules do override system default destination. 503 // It also makes sure these rules do override system default destination.
556 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = 504 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ =
557 '{"namePattern":".*Bar.*"}'; 505 '{"namePattern":".*Bar.*"}';
558 this.setInitialSettings(); 506 this.setInitialSettings();
559 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 507 this.nativeLayer_.whenCalled('getInitialSettings').then(
560 function() { 508 function() {
561 this.setLocalDestinations(); 509 this.setLocalDestinations();
562 510
563 assertEquals( 511 assertEquals(
564 'BarDevice', 512 'BarDevice',
565 this.printPreview_.destinationStore_.selectedDestination.id); 513 this.printPreview_.destinationStore_.selectedDestination.id);
566 514
567 testDone(); 515 testDone();
568 }.bind(this)); 516 }.bind(this));
569 }); 517 });
570 518
571 TEST_F('PrintPreviewWebUITest', 'TestSystemDialogLinkIsHiddenInAppKioskMode', 519 TEST_F('PrintPreviewWebUITest', 'TestSystemDialogLinkIsHiddenInAppKioskMode',
572 function() { 520 function() {
573 if (!cr.isChromeOS) 521 if (!cr.isChromeOS)
574 this.initialSettings_.isInAppKioskMode_ = true; 522 this.initialSettings_.isInAppKioskMode_ = true;
575 523
576 this.setInitialSettings(); 524 this.setInitialSettings();
577 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 525 this.nativeLayer_.whenCalled('getInitialSettings').then(
578 function() { 526 function() {
579 if (cr.isChromeOS) 527 if (cr.isChromeOS)
580 assertEquals(null, $('system-dialog-link')); 528 assertEquals(null, $('system-dialog-link'));
581 else 529 else
582 checkElementDisplayed($('system-dialog-link'), false); 530 checkElementDisplayed($('system-dialog-link'), false);
583 testDone(); 531 testDone();
584 }); 532 });
585 }); 533 });
586 534
587 // Test that disabled settings hide the disabled sections. 535 // Test that disabled settings hide the disabled sections.
588 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { 536 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() {
589 this.createPrintPreview(); 537 this.createPrintPreview();
590 checkSectionVisible($('layout-settings'), false); 538 checkSectionVisible($('layout-settings'), false);
591 checkSectionVisible($('color-settings'), false); 539 checkSectionVisible($('color-settings'), false);
592 checkSectionVisible($('copies-settings'), false); 540 checkSectionVisible($('copies-settings'), false);
593 541
594 this.setInitialSettings(); 542 this.setInitialSettings();
595 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 543 this.nativeLayer_.whenCalled('getInitialSettings').then(
596 function() { 544 function() {
597 this.setLocalDestinations(); 545 this.setLocalDestinations();
598 var device = getCddTemplate("FooDevice"); 546 var device = getCddTemplate("FooDevice");
599 device.capabilities.printer.color = { 547 device.capabilities.printer.color = {
600 "option": [ 548 "option": [
601 {"is_default": true, "type": "STANDARD_COLOR"} 549 {"is_default": true, "type": "STANDARD_COLOR"}
602 ] 550 ]
603 }; 551 };
604 delete device.capabilities.printer.copies; 552 delete device.capabilities.printer.copies;
605 this.setCapabilities(device); 553 this.setCapabilities(device);
606 554
607 checkSectionVisible($('layout-settings'), true); 555 checkSectionVisible($('layout-settings'), true);
608 checkSectionVisible($('color-settings'), false); 556 checkSectionVisible($('color-settings'), false);
609 checkSectionVisible($('copies-settings'), false); 557 checkSectionVisible($('copies-settings'), false);
610 558
611 this.waitForAnimationToEnd('other-options-collapsible'); 559 this.waitForAnimationToEnd('other-options-collapsible');
612 }.bind(this)); 560 }.bind(this));
613 }); 561 });
614 562
615 // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the 563 // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the
616 // fit to page option. 564 // fit to page option.
617 TEST_F('PrintPreviewWebUITest', 'PrintToPDFSelectedCapabilities', function() { 565 TEST_F('PrintPreviewWebUITest', 'PrintToPDFSelectedCapabilities', function() {
618 // Add PDF printer. 566 // Add PDF printer.
619 this.initialSettings_.isDocumentModifiable_ = false; 567 this.initialSettings_.isDocumentModifiable_ = false;
620 this.initialSettings_.systemDefaultDestinationId_ = 'Save as PDF'; 568 this.initialSettings_.systemDefaultDestinationId_ = 'Save as PDF';
621 this.setInitialSettings(); 569 this.setInitialSettings();
622 570
623 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 571 this.nativeLayer_.whenCalled('getInitialSettings').then(
624 function() { 572 function() {
625 var device = { 573 var device = {
626 printerId: 'Save as PDF', 574 printerId: 'Save as PDF',
627 capabilities: { 575 capabilities: {
628 version: '1.0', 576 version: '1.0',
629 printer: { 577 printer: {
630 page_orientation: { 578 page_orientation: {
631 option: [ 579 option: [
632 {type: 'AUTO', is_default: true}, 580 {type: 'AUTO', is_default: true},
633 {type: 'PORTRAIT'}, 581 {type: 'PORTRAIT'},
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 checkSectionVisible($('scaling-settings'), false); 615 checkSectionVisible($('scaling-settings'), false);
668 616
669 testDone(); 617 testDone();
670 }.bind(this)); 618 }.bind(this));
671 }); 619 });
672 620
673 // When the source is 'HTML', we always hide the fit to page option and show 621 // When the source is 'HTML', we always hide the fit to page option and show
674 // media size option. 622 // media size option.
675 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { 623 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() {
676 this.setInitialSettings(); 624 this.setInitialSettings();
677 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 625 this.nativeLayer_.whenCalled('getInitialSettings').then(
678 function() { 626 function() {
679 this.setLocalDestinations(); 627 this.setLocalDestinations();
680 this.setCapabilities(getCddTemplate("FooDevice")); 628 this.setCapabilities(getCddTemplate("FooDevice"));
681 629
682 var otherOptions = $('other-options-settings'); 630 var otherOptions = $('other-options-settings');
683 var fitToPage = otherOptions.querySelector('#fit-to-page-container'); 631 var fitToPage = otherOptions.querySelector('#fit-to-page-container');
684 var rasterize; 632 var rasterize;
685 if (isPrintAsImageEnabled()) 633 if (isPrintAsImageEnabled())
686 rasterize = otherOptions.querySelector('#rasterize-container'); 634 rasterize = otherOptions.querySelector('#rasterize-container');
687 var mediaSize = $('media-size-settings'); 635 var mediaSize = $('media-size-settings');
(...skipping 18 matching lines...) Expand all
706 654
707 this.waitForAnimationToEnd('more-settings'); 655 this.waitForAnimationToEnd('more-settings');
708 }.bind(this)); 656 }.bind(this));
709 }); 657 });
710 658
711 // When the source is "PDF", depending on the selected destination printer, we 659 // When the source is "PDF", depending on the selected destination printer, we
712 // show/hide the fit to page option and hide media size selection. 660 // show/hide the fit to page option and hide media size selection.
713 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { 661 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() {
714 this.initialSettings_.isDocumentModifiable_ = false; 662 this.initialSettings_.isDocumentModifiable_ = false;
715 this.setInitialSettings(); 663 this.setInitialSettings();
716 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 664 this.nativeLayer_.whenCalled('getInitialSettings').then(
717 function() { 665 function() {
718 this.setLocalDestinations(); 666 this.setLocalDestinations();
719 this.setCapabilities(getCddTemplate("FooDevice")); 667 this.setCapabilities(getCddTemplate("FooDevice"));
720 668
721 var otherOptions = $('other-options-settings'); 669 var otherOptions = $('other-options-settings');
722 var scalingSettings = $('scaling-settings'); 670 var scalingSettings = $('scaling-settings');
723 var fitToPageContainer = 671 var fitToPageContainer =
724 otherOptions.querySelector('#fit-to-page-container'); 672 otherOptions.querySelector('#fit-to-page-container');
725 var rasterizeContainer; 673 var rasterizeContainer;
726 if (isPrintAsImageEnabled()) { 674 if (isPrintAsImageEnabled()) {
(...skipping 18 matching lines...) Expand all
745 693
746 this.waitForAnimationToEnd('other-options-collapsible'); 694 this.waitForAnimationToEnd('other-options-collapsible');
747 }.bind(this)); 695 }.bind(this));
748 }); 696 });
749 697
750 // When the source is "PDF", depending on the selected destination printer, we 698 // When the source is "PDF", depending on the selected destination printer, we
751 // show/hide the fit to page option and hide media size selection. 699 // show/hide the fit to page option and hide media size selection.
752 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { 700 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() {
753 this.initialSettings_.isDocumentModifiable_ = false; 701 this.initialSettings_.isDocumentModifiable_ = false;
754 this.setInitialSettings(); 702 this.setInitialSettings();
755 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 703 this.nativeLayer_.whenCalled('getInitialSettings').then(
756 function() { 704 function() {
757 this.setLocalDestinations(); 705 this.setLocalDestinations();
758 this.setCapabilities(getCddTemplate("FooDevice")); 706 this.setCapabilities(getCddTemplate("FooDevice"));
759 707
760 var otherOptions = $('other-options-settings'); 708 var otherOptions = $('other-options-settings');
761 var scalingSettings = $('scaling-settings'); 709 var scalingSettings = $('scaling-settings');
762 710
763 checkSectionVisible(otherOptions, true); 711 checkSectionVisible(otherOptions, true);
764 var fitToPageContainer = 712 var fitToPageContainer =
765 otherOptions.querySelector('#fit-to-page-container'); 713 otherOptions.querySelector('#fit-to-page-container');
(...skipping 20 matching lines...) Expand all
786 734
787 this.waitForAnimationToEnd('other-options-collapsible'); 735 this.waitForAnimationToEnd('other-options-collapsible');
788 }.bind(this)); 736 }.bind(this));
789 }); 737 });
790 738
791 // When the number of copies print preset is set for source 'PDF', we update 739 // When the number of copies print preset is set for source 'PDF', we update
792 // the copies value if capability is supported by printer. 740 // the copies value if capability is supported by printer.
793 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() { 741 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() {
794 this.initialSettings_.isDocumentModifiable_ = false; 742 this.initialSettings_.isDocumentModifiable_ = false;
795 this.setInitialSettings(); 743 this.setInitialSettings();
796 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 744 this.nativeLayer_.whenCalled('getInitialSettings').then(
797 function() { 745 function() {
798 this.setLocalDestinations(); 746 this.setLocalDestinations();
799 this.setCapabilities(getCddTemplate("FooDevice")); 747 this.setCapabilities(getCddTemplate("FooDevice"));
800 748
801 // Indicate that the number of copies print preset is set for source 749 // Indicate that the number of copies print preset is set for source
802 // PDF. 750 // PDF.
803 var printPresetOptions = { 751 var printPresetOptions = {
804 disableScaling: true, 752 disableScaling: true,
805 copies: 2 753 copies: 2
806 }; 754 };
(...skipping 11 matching lines...) Expand all
818 this.waitForAnimationToEnd('other-options-collapsible'); 766 this.waitForAnimationToEnd('other-options-collapsible');
819 }.bind(this)); 767 }.bind(this));
820 }); 768 });
821 769
822 // When the duplex print preset is set for source 'PDF', we update the 770 // When the duplex print preset is set for source 'PDF', we update the
823 // duplex setting if capability is supported by printer. 771 // duplex setting if capability is supported by printer.
824 TEST_F('PrintPreviewWebUITest', 'CheckDuplexPrintPreset', function() { 772 TEST_F('PrintPreviewWebUITest', 'CheckDuplexPrintPreset', function() {
825 this.initialSettings_.isDocumentModifiable_ = false; 773 this.initialSettings_.isDocumentModifiable_ = false;
826 this.setInitialSettings(); 774 this.setInitialSettings();
827 775
828 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 776 this.nativeLayer_.whenCalled('getInitialSettings').then(
829 function() { 777 function() {
830 this.setLocalDestinations(); 778 this.setLocalDestinations();
831 this.setCapabilities(getCddTemplate("FooDevice")); 779 this.setCapabilities(getCddTemplate("FooDevice"));
832 780
833 // Indicate that the duplex print preset is set to "long edge" for 781 // Indicate that the duplex print preset is set to "long edge" for
834 // source PDF. 782 // source PDF.
835 var printPresetOptions = { 783 var printPresetOptions = {
836 duplex: 1 784 duplex: 1
837 }; 785 };
838 var printPresetOptionsEvent = new Event( 786 var printPresetOptionsEvent = new Event(
839 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); 787 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS);
840 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; 788 printPresetOptionsEvent.optionsFromDocument = printPresetOptions;
841 this.nativeLayer_.getEventTarget(). 789 this.nativeLayer_.getEventTarget().
842 dispatchEvent(printPresetOptionsEvent); 790 dispatchEvent(printPresetOptionsEvent);
843 791
844 var otherOptions = $('other-options-settings'); 792 var otherOptions = $('other-options-settings');
845 checkSectionVisible(otherOptions, true); 793 checkSectionVisible(otherOptions, true);
846 var duplexContainer = otherOptions.querySelector('#duplex-container'); 794 var duplexContainer = otherOptions.querySelector('#duplex-container');
847 checkElementDisplayed(duplexContainer, true); 795 checkElementDisplayed(duplexContainer, true);
848 expectTrue(duplexContainer.querySelector('.checkbox').checked); 796 expectTrue(duplexContainer.querySelector('.checkbox').checked);
849 797
850 this.waitForAnimationToEnd('other-options-collapsible'); 798 this.waitForAnimationToEnd('other-options-collapsible');
851 }.bind(this)); 799 }.bind(this));
852 }); 800 });
853 801
854 // Make sure that custom margins controls are properly set up. 802 // Make sure that custom margins controls are properly set up.
855 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { 803 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() {
856 this.setInitialSettings(); 804 this.setInitialSettings();
857 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 805 this.nativeLayer_.whenCalled('getInitialSettings').then(
858 function() { 806 function() {
859 this.setLocalDestinations(); 807 this.setLocalDestinations();
860 this.setCapabilities(getCddTemplate("FooDevice")); 808 this.setCapabilities(getCddTemplate("FooDevice"));
861 809
862 this.printPreview_.printTicketStore_.marginsType.updateValue( 810 this.printPreview_.printTicketStore_.marginsType.updateValue(
863 print_preview.ticket_items.MarginsTypeValue.CUSTOM); 811 print_preview.ticket_items.MarginsTypeValue.CUSTOM);
864 812
865 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { 813 ['left', 'top', 'right', 'bottom'].forEach(function(margin) {
866 var control = 814 var control =
867 $('preview-area').querySelector('.margin-control-' + margin); 815 $('preview-area').querySelector('.margin-control-' + margin);
868 assertNotEquals(null, control); 816 assertNotEquals(null, control);
869 var input = control.querySelector('.margin-control-textbox'); 817 var input = control.querySelector('.margin-control-textbox');
870 assertTrue(input.hasAttribute('aria-label')); 818 assertTrue(input.hasAttribute('aria-label'));
871 assertNotEquals('undefined', input.getAttribute('aria-label')); 819 assertNotEquals('undefined', input.getAttribute('aria-label'));
872 }); 820 });
873 this.waitForAnimationToEnd('more-settings'); 821 this.waitForAnimationToEnd('more-settings');
874 }.bind(this)); 822 }.bind(this));
875 }); 823 });
876 824
877 // Page layout has zero margins. Hide header and footer option. 825 // Page layout has zero margins. Hide header and footer option.
878 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter', 826 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter',
879 function() { 827 function() {
880 this.setInitialSettings(); 828 this.setInitialSettings();
881 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 829 this.nativeLayer_.whenCalled('getInitialSettings').then(
882 function() { 830 function() {
883 this.setLocalDestinations(); 831 this.setLocalDestinations();
884 this.setCapabilities(getCddTemplate("FooDevice")); 832 this.setCapabilities(getCddTemplate("FooDevice"));
885 833
886 var otherOptions = $('other-options-settings'); 834 var otherOptions = $('other-options-settings');
887 var headerFooter = 835 var headerFooter =
888 otherOptions.querySelector('#header-footer-container'); 836 otherOptions.querySelector('#header-footer-container');
889 837
890 // Check that options are collapsed (section is visible, because duplex 838 // Check that options are collapsed (section is visible, because duplex
891 // is available). 839 // is available).
(...skipping 12 matching lines...) Expand all
904 checkElementDisplayed(headerFooter, false); 852 checkElementDisplayed(headerFooter, false);
905 853
906 this.waitForAnimationToEnd('more-settings'); 854 this.waitForAnimationToEnd('more-settings');
907 }.bind(this)); 855 }.bind(this));
908 }); 856 });
909 857
910 // Page layout has half-inch margins. Show header and footer option. 858 // Page layout has half-inch margins. Show header and footer option.
911 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter', 859 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter',
912 function() { 860 function() {
913 this.setInitialSettings(); 861 this.setInitialSettings();
914 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 862 this.nativeLayer_.whenCalled('getInitialSettings').then(
915 function() { 863 function() {
916 this.setLocalDestinations(); 864 this.setLocalDestinations();
917 this.setCapabilities(getCddTemplate("FooDevice")); 865 this.setCapabilities(getCddTemplate("FooDevice"));
918 866
919 var otherOptions = $('other-options-settings'); 867 var otherOptions = $('other-options-settings');
920 var headerFooter = 868 var headerFooter =
921 otherOptions.querySelector('#header-footer-container'); 869 otherOptions.querySelector('#header-footer-container');
922 870
923 // Check that options are collapsed (section is visible, because duplex 871 // Check that options are collapsed (section is visible, because duplex
924 // is available). 872 // is available).
(...skipping 13 matching lines...) Expand all
938 886
939 this.waitForAnimationToEnd('more-settings'); 887 this.waitForAnimationToEnd('more-settings');
940 }.bind(this)); 888 }.bind(this));
941 }); 889 });
942 890
943 // Page layout has zero top and bottom margins. Hide header and footer option. 891 // Page layout has zero top and bottom margins. Hide header and footer option.
944 TEST_F('PrintPreviewWebUITest', 892 TEST_F('PrintPreviewWebUITest',
945 'ZeroTopAndBottomMarginsHideHeaderFooter', 893 'ZeroTopAndBottomMarginsHideHeaderFooter',
946 function() { 894 function() {
947 this.setInitialSettings(); 895 this.setInitialSettings();
948 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 896 this.nativeLayer_.whenCalled('getInitialSettings').then(
949 function() { 897 function() {
950 this.setLocalDestinations(); 898 this.setLocalDestinations();
951 this.setCapabilities(getCddTemplate("FooDevice")); 899 this.setCapabilities(getCddTemplate("FooDevice"));
952 900
953 var otherOptions = $('other-options-settings'); 901 var otherOptions = $('other-options-settings');
954 var headerFooter = 902 var headerFooter =
955 otherOptions.querySelector('#header-footer-container'); 903 otherOptions.querySelector('#header-footer-container');
956 904
957 // Check that options are collapsed (section is visible, because duplex 905 // Check that options are collapsed (section is visible, because duplex
958 // is available). 906 // is available).
(...skipping 14 matching lines...) Expand all
973 this.waitForAnimationToEnd('more-settings'); 921 this.waitForAnimationToEnd('more-settings');
974 }.bind(this)); 922 }.bind(this));
975 }); 923 });
976 924
977 // Page layout has zero top and half-inch bottom margin. Show header and footer 925 // Page layout has zero top and half-inch bottom margin. Show header and footer
978 // option. 926 // option.
979 TEST_F('PrintPreviewWebUITest', 927 TEST_F('PrintPreviewWebUITest',
980 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter', 928 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter',
981 function() { 929 function() {
982 this.setInitialSettings(); 930 this.setInitialSettings();
983 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 931 this.nativeLayer_.whenCalled('getInitialSettings').then(
984 function() { 932 function() {
985 this.setLocalDestinations(); 933 this.setLocalDestinations();
986 this.setCapabilities(getCddTemplate("FooDevice")); 934 this.setCapabilities(getCddTemplate("FooDevice"));
987 935
988 var otherOptions = $('other-options-settings'); 936 var otherOptions = $('other-options-settings');
989 var headerFooter = 937 var headerFooter =
990 otherOptions.querySelector('#header-footer-container'); 938 otherOptions.querySelector('#header-footer-container');
991 939
992 // Check that options are collapsed (section is visible, because duplex 940 // Check that options are collapsed (section is visible, because duplex
993 // is available). 941 // is available).
(...skipping 11 matching lines...) Expand all
1005 953
1006 checkElementDisplayed(headerFooter, true); 954 checkElementDisplayed(headerFooter, true);
1007 955
1008 this.waitForAnimationToEnd('more-settings'); 956 this.waitForAnimationToEnd('more-settings');
1009 }.bind(this)); 957 }.bind(this));
1010 }); 958 });
1011 959
1012 // Check header footer availability with small (label) page size. 960 // Check header footer availability with small (label) page size.
1013 TEST_F('PrintPreviewWebUITest', 'SmallPaperSizeHeaderFooter', function() { 961 TEST_F('PrintPreviewWebUITest', 'SmallPaperSizeHeaderFooter', function() {
1014 this.setInitialSettings(); 962 this.setInitialSettings();
1015 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 963 this.nativeLayer_.whenCalled('getInitialSettings').then(
1016 function() { 964 function() {
1017 this.setLocalDestinations(); 965 this.setLocalDestinations();
1018 var device = getCddTemplate("FooDevice"); 966 var device = getCddTemplate("FooDevice");
1019 device.capabilities.printer.media_size = { 967 device.capabilities.printer.media_size = {
1020 "option": [ 968 "option": [
1021 {"name": "SmallLabel", "width_microns": 38100, 969 {"name": "SmallLabel", "width_microns": 38100,
1022 "height_microns": 12700, "is_default": false}, 970 "height_microns": 12700, "is_default": false},
1023 {"name": "BigLabel", "width_microns": 50800, 971 {"name": "BigLabel", "width_microns": 50800,
1024 "height_microns": 76200, "is_default": true} 972 "height_microns": 76200, "is_default": true}
1025 ] 973 ]
(...skipping 24 matching lines...) Expand all
1050 this.printPreview_.printTicketStore_.landscape.updateValue(true); 998 this.printPreview_.printTicketStore_.landscape.updateValue(true);
1051 checkElementDisplayed(headerFooter, true); 999 checkElementDisplayed(headerFooter, true);
1052 1000
1053 this.waitForAnimationToEnd('more-settings'); 1001 this.waitForAnimationToEnd('more-settings');
1054 }.bind(this)); 1002 }.bind(this));
1055 }); 1003 });
1056 1004
1057 // Test that the color settings, one option, standard monochrome. 1005 // Test that the color settings, one option, standard monochrome.
1058 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() { 1006 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() {
1059 this.setInitialSettings(); 1007 this.setInitialSettings();
1060 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1008 this.nativeLayer_.whenCalled('getInitialSettings').then(
1061 function() { 1009 function() {
1062 this.setLocalDestinations(); 1010 this.setLocalDestinations();
1063 1011
1064 // Only one option, standard monochrome. 1012 // Only one option, standard monochrome.
1065 var device = getCddTemplate("FooDevice"); 1013 var device = getCddTemplate("FooDevice");
1066 device.capabilities.printer.color = { 1014 device.capabilities.printer.color = {
1067 "option": [ 1015 "option": [
1068 {"is_default": true, "type": "STANDARD_MONOCHROME"} 1016 {"is_default": true, "type": "STANDARD_MONOCHROME"}
1069 ] 1017 ]
1070 }; 1018 };
1071 this.setCapabilities(device); 1019 this.setCapabilities(device);
1072 1020
1073 checkSectionVisible($('color-settings'), false); 1021 checkSectionVisible($('color-settings'), false);
1074 1022
1075 this.waitForAnimationToEnd('more-settings'); 1023 this.waitForAnimationToEnd('more-settings');
1076 }.bind(this)); 1024 }.bind(this));
1077 }); 1025 });
1078 1026
1079 // Test that the color settings, one option, custom monochrome. 1027 // Test that the color settings, one option, custom monochrome.
1080 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome', 1028 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome',
1081 function() { 1029 function() {
1082 this.setInitialSettings(); 1030 this.setInitialSettings();
1083 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1031 this.nativeLayer_.whenCalled('getInitialSettings').then(
1084 function() { 1032 function() {
1085 this.setLocalDestinations(); 1033 this.setLocalDestinations();
1086 1034
1087 // Only one option, standard monochrome. 1035 // Only one option, standard monochrome.
1088 var device = getCddTemplate("FooDevice"); 1036 var device = getCddTemplate("FooDevice");
1089 device.capabilities.printer.color = { 1037 device.capabilities.printer.color = {
1090 "option": [ 1038 "option": [
1091 {"is_default": true, "type": "CUSTOM_MONOCHROME", 1039 {"is_default": true, "type": "CUSTOM_MONOCHROME",
1092 "vendor_id": "42"} 1040 "vendor_id": "42"}
1093 ] 1041 ]
1094 }; 1042 };
1095 this.setCapabilities(device); 1043 this.setCapabilities(device);
1096 1044
1097 checkSectionVisible($('color-settings'), false); 1045 checkSectionVisible($('color-settings'), false);
1098 1046
1099 this.waitForAnimationToEnd('more-settings'); 1047 this.waitForAnimationToEnd('more-settings');
1100 }.bind(this)); 1048 }.bind(this));
1101 }); 1049 });
1102 1050
1103 // Test that the color settings, one option, standard color. 1051 // Test that the color settings, one option, standard color.
1104 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() { 1052 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() {
1105 this.setInitialSettings(); 1053 this.setInitialSettings();
1106 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1054 this.nativeLayer_.whenCalled('getInitialSettings').then(
1107 function() { 1055 function() {
1108 this.setLocalDestinations(); 1056 this.setLocalDestinations();
1109 1057
1110 var device = getCddTemplate("FooDevice"); 1058 var device = getCddTemplate("FooDevice");
1111 device.capabilities.printer.color = { 1059 device.capabilities.printer.color = {
1112 "option": [ 1060 "option": [
1113 {"is_default": true, "type": "STANDARD_COLOR"} 1061 {"is_default": true, "type": "STANDARD_COLOR"}
1114 ] 1062 ]
1115 }; 1063 };
1116 this.setCapabilities(device); 1064 this.setCapabilities(device);
1117 1065
1118 checkSectionVisible($('color-settings'), false); 1066 checkSectionVisible($('color-settings'), false);
1119 1067
1120 this.waitForAnimationToEnd('more-settings'); 1068 this.waitForAnimationToEnd('more-settings');
1121 }.bind(this)); 1069 }.bind(this));
1122 }); 1070 });
1123 1071
1124 // Test that the color settings, one option, custom color. 1072 // Test that the color settings, one option, custom color.
1125 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() { 1073 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() {
1126 this.setInitialSettings(); 1074 this.setInitialSettings();
1127 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1075 this.nativeLayer_.whenCalled('getInitialSettings').then(
1128 function() { 1076 function() {
1129 this.setLocalDestinations(); 1077 this.setLocalDestinations();
1130 1078
1131 var device = getCddTemplate("FooDevice"); 1079 var device = getCddTemplate("FooDevice");
1132 device.capabilities.printer.color = { 1080 device.capabilities.printer.color = {
1133 "option": [ 1081 "option": [
1134 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"} 1082 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"}
1135 ] 1083 ]
1136 }; 1084 };
1137 this.setCapabilities(device); 1085 this.setCapabilities(device);
1138 1086
1139 checkSectionVisible($('color-settings'), false); 1087 checkSectionVisible($('color-settings'), false);
1140 1088
1141 this.waitForAnimationToEnd('more-settings'); 1089 this.waitForAnimationToEnd('more-settings');
1142 }.bind(this)); 1090 }.bind(this));
1143 }); 1091 });
1144 1092
1145 // Test that the color settings, two options, both standard, defaults to color. 1093 // Test that the color settings, two options, both standard, defaults to color.
1146 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor', 1094 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor',
1147 function() { 1095 function() {
1148 this.setInitialSettings(); 1096 this.setInitialSettings();
1149 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1097 this.nativeLayer_.whenCalled('getInitialSettings').then(
1150 function() { 1098 function() {
1151 this.setLocalDestinations(); 1099 this.setLocalDestinations();
1152 1100
1153 var device = getCddTemplate("FooDevice"); 1101 var device = getCddTemplate("FooDevice");
1154 device.capabilities.printer.color = { 1102 device.capabilities.printer.color = {
1155 "option": [ 1103 "option": [
1156 {"type": "STANDARD_MONOCHROME"}, 1104 {"type": "STANDARD_MONOCHROME"},
1157 {"is_default": true, "type": "STANDARD_COLOR"} 1105 {"is_default": true, "type": "STANDARD_COLOR"}
1158 ] 1106 ]
1159 }; 1107 };
1160 this.setCapabilities(device); 1108 this.setCapabilities(device);
1161 1109
1162 checkSectionVisible($('color-settings'), true); 1110 checkSectionVisible($('color-settings'), true);
1163 expectEquals( 1111 expectEquals(
1164 'color', 1112 'color',
1165 $('color-settings').querySelector('.color-settings-select').value); 1113 $('color-settings').querySelector('.color-settings-select').value);
1166 1114
1167 this.waitForAnimationToEnd('more-settings'); 1115 this.waitForAnimationToEnd('more-settings');
1168 }.bind(this)); 1116 }.bind(this));
1169 }); 1117 });
1170 1118
1171 // Test that the color settings, two options, both standard, defaults to 1119 // Test that the color settings, two options, both standard, defaults to
1172 // monochrome. 1120 // monochrome.
1173 TEST_F('PrintPreviewWebUITest', 1121 TEST_F('PrintPreviewWebUITest',
1174 'TestColorSettingsBothStandardDefaultMonochrome', function() { 1122 'TestColorSettingsBothStandardDefaultMonochrome', function() {
1175 this.setInitialSettings(); 1123 this.setInitialSettings();
1176 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1124 this.nativeLayer_.whenCalled('getInitialSettings').then(
1177 function() { 1125 function() {
1178 this.setLocalDestinations(); 1126 this.setLocalDestinations();
1179 1127
1180 var device = getCddTemplate("FooDevice"); 1128 var device = getCddTemplate("FooDevice");
1181 device.capabilities.printer.color = { 1129 device.capabilities.printer.color = {
1182 "option": [ 1130 "option": [
1183 {"is_default": true, "type": "STANDARD_MONOCHROME"}, 1131 {"is_default": true, "type": "STANDARD_MONOCHROME"},
1184 {"type": "STANDARD_COLOR"} 1132 {"type": "STANDARD_COLOR"}
1185 ] 1133 ]
1186 }; 1134 };
1187 this.setCapabilities(device); 1135 this.setCapabilities(device);
1188 1136
1189 checkSectionVisible($('color-settings'), true); 1137 checkSectionVisible($('color-settings'), true);
1190 expectEquals( 1138 expectEquals(
1191 'bw', 1139 'bw',
1192 $('color-settings').querySelector('.color-settings-select').value); 1140 $('color-settings').querySelector('.color-settings-select').value);
1193 1141
1194 this.waitForAnimationToEnd('more-settings'); 1142 this.waitForAnimationToEnd('more-settings');
1195 }.bind(this)); 1143 }.bind(this));
1196 }); 1144 });
1197 1145
1198 // Test that the color settings, two options, both custom, defaults to color. 1146 // Test that the color settings, two options, both custom, defaults to color.
1199 TEST_F('PrintPreviewWebUITest', 1147 TEST_F('PrintPreviewWebUITest',
1200 'TestColorSettingsBothCustomDefaultColor', function() { 1148 'TestColorSettingsBothCustomDefaultColor', function() {
1201 this.setInitialSettings(); 1149 this.setInitialSettings();
1202 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1150 this.nativeLayer_.whenCalled('getInitialSettings').then(
1203 function() { 1151 function() {
1204 this.setLocalDestinations(); 1152 this.setLocalDestinations();
1205 1153
1206 var device = getCddTemplate("FooDevice"); 1154 var device = getCddTemplate("FooDevice");
1207 device.capabilities.printer.color = { 1155 device.capabilities.printer.color = {
1208 "option": [ 1156 "option": [
1209 {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"}, 1157 {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"},
1210 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"} 1158 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"}
1211 ] 1159 ]
1212 }; 1160 };
1213 this.setCapabilities(device); 1161 this.setCapabilities(device);
1214 1162
1215 checkSectionVisible($('color-settings'), true); 1163 checkSectionVisible($('color-settings'), true);
1216 expectEquals( 1164 expectEquals(
1217 'color', 1165 'color',
1218 $('color-settings').querySelector('.color-settings-select').value); 1166 $('color-settings').querySelector('.color-settings-select').value);
1219 1167
1220 this.waitForAnimationToEnd('more-settings'); 1168 this.waitForAnimationToEnd('more-settings');
1221 }.bind(this)); 1169 }.bind(this));
1222 }); 1170 });
1223 1171
1224 // Test to verify that duplex settings are set according to the printer 1172 // Test to verify that duplex settings are set according to the printer
1225 // capabilities. 1173 // capabilities.
1226 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { 1174 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() {
1227 this.setInitialSettings(); 1175 this.setInitialSettings();
1228 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1176 this.nativeLayer_.whenCalled('getInitialSettings').then(
1229 function() { 1177 function() {
1230 this.setLocalDestinations(); 1178 this.setLocalDestinations();
1231 this.setCapabilities(getCddTemplate("FooDevice")); 1179 this.setCapabilities(getCddTemplate("FooDevice"));
1232 1180
1233 var otherOptions = $('other-options-settings'); 1181 var otherOptions = $('other-options-settings');
1234 checkSectionVisible(otherOptions, true); 1182 checkSectionVisible(otherOptions, true);
1235 duplexContainer = otherOptions.querySelector('#duplex-container'); 1183 duplexContainer = otherOptions.querySelector('#duplex-container');
1236 expectFalse(duplexContainer.hidden); 1184 expectFalse(duplexContainer.hidden);
1237 expectFalse(duplexContainer.querySelector('.checkbox').checked); 1185 expectFalse(duplexContainer.querySelector('.checkbox').checked);
1238 1186
1239 this.waitForAnimationToEnd('more-settings'); 1187 this.waitForAnimationToEnd('more-settings');
1240 }.bind(this)); 1188 }.bind(this));
1241 }); 1189 });
1242 1190
1243 // Test to verify that duplex settings are set according to the printer 1191 // Test to verify that duplex settings are set according to the printer
1244 // capabilities. 1192 // capabilities.
1245 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { 1193 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() {
1246 this.setInitialSettings(); 1194 this.setInitialSettings();
1247 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1195 this.nativeLayer_.whenCalled('getInitialSettings').then(
1248 function() { 1196 function() {
1249 this.setLocalDestinations(); 1197 this.setLocalDestinations();
1250 var device = getCddTemplate("FooDevice"); 1198 var device = getCddTemplate("FooDevice");
1251 delete device.capabilities.printer.duplex; 1199 delete device.capabilities.printer.duplex;
1252 this.setCapabilities(device); 1200 this.setCapabilities(device);
1253 1201
1254 // Check that it is collapsed. 1202 // Check that it is collapsed.
1255 var otherOptions = $('other-options-settings'); 1203 var otherOptions = $('other-options-settings');
1256 checkSectionVisible(otherOptions, false); 1204 checkSectionVisible(otherOptions, false);
1257 1205
1258 this.expandMoreSettings(); 1206 this.expandMoreSettings();
1259 1207
1260 // Now it should be visible. 1208 // Now it should be visible.
1261 checkSectionVisible(otherOptions, true); 1209 checkSectionVisible(otherOptions, true);
1262 expectTrue(otherOptions.querySelector('#duplex-container').hidden); 1210 expectTrue(otherOptions.querySelector('#duplex-container').hidden);
1263 1211
1264 this.waitForAnimationToEnd('more-settings'); 1212 this.waitForAnimationToEnd('more-settings');
1265 }.bind(this)); 1213 }.bind(this));
1266 }); 1214 });
1267 1215
1268 // Test that changing the selected printer updates the preview. 1216 // Test that changing the selected printer updates the preview.
1269 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { 1217 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() {
1270 this.setInitialSettings(); 1218 this.setInitialSettings();
1271 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1219 this.nativeLayer_.whenCalled('getInitialSettings').then(
1272 function() { 1220 function() {
1273 this.setLocalDestinations(); 1221 this.setLocalDestinations();
1274 this.setCapabilities(getCddTemplate("FooDevice")); 1222 this.setCapabilities(getCddTemplate("FooDevice"));
1275 1223
1276 var previewGenerator = mock(print_preview.PreviewGenerator); 1224 var previewGenerator = mock(print_preview.PreviewGenerator);
1277 this.printPreview_.previewArea_.previewGenerator_ = 1225 this.previewArea_.previewGenerator_ =
1278 previewGenerator.proxy(); 1226 previewGenerator.proxy();
1279 1227
1280 // The number of settings that can change due to a change in the 1228 // The number of settings that can change due to a change in the
1281 // destination that will therefore dispatch ticket item change events. 1229 // destination that will therefore dispatch ticket item change events.
1282 previewGenerator.expects(exactly(9)).requestPreview(); 1230 previewGenerator.expects(exactly(9)).requestPreview();
1283 1231
1284 var barDestination = 1232 var barDestination =
1285 this.printPreview_.destinationStore_.destinations().find( 1233 this.printPreview_.destinationStore_.destinations().find(
1286 function(d) { 1234 function(d) {
1287 return d.id == 'BarDevice'; 1235 return d.id == 'BarDevice';
1288 }); 1236 });
1289 1237
1290 this.printPreview_.destinationStore_.selectDestination(barDestination); 1238 this.printPreview_.destinationStore_.selectDestination(barDestination);
1291 1239
1292 var device = getCddTemplate("BarDevice"); 1240 var device = getCddTemplate("BarDevice");
1293 device.capabilities.printer.color = { 1241 device.capabilities.printer.color = {
1294 "option": [ 1242 "option": [
1295 {"is_default": true, "type": "STANDARD_MONOCHROME"} 1243 {"is_default": true, "type": "STANDARD_MONOCHROME"}
1296 ] 1244 ]
1297 }; 1245 };
1298 this.setCapabilities(device); 1246 this.setCapabilities(device);
1299 1247
1300 this.waitForAnimationToEnd('more-settings'); 1248 this.waitForAnimationToEnd('more-settings');
1301 }.bind(this)); 1249 }.bind(this));
1302 }); 1250 });
1303 1251
1304 // Test that error message is displayed when plugin doesn't exist. 1252 // Test that error message is displayed when plugin doesn't exist.
1305 TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() { 1253 TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() {
1306 this.setInitialSettings(); 1254 this.setInitialSettings();
1307 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1255 this.nativeLayer_.whenCalled('getInitialSettings').then(
1308 function() { 1256 function() {
1309 var previewAreaEl = $('preview-area'); 1257 var previewAreaEl = $('preview-area');
1310 1258
1311 var loadingMessageEl = 1259 var loadingMessageEl =
1312 previewAreaEl. 1260 previewAreaEl.
1313 getElementsByClassName('preview-area-loading-message')[0]; 1261 getElementsByClassName('preview-area-loading-message')[0];
1314 expectTrue(loadingMessageEl.hidden); 1262 expectTrue(loadingMessageEl.hidden);
1315 1263
1316 var previewFailedMessageEl = previewAreaEl.getElementsByClassName( 1264 var previewFailedMessageEl = previewAreaEl.getElementsByClassName(
1317 'preview-area-preview-failed-message')[0]; 1265 'preview-area-preview-failed-message')[0];
1318 expectTrue(previewFailedMessageEl.hidden); 1266 expectTrue(previewFailedMessageEl.hidden);
1319 1267
1320 var printFailedMessageEl = 1268 var printFailedMessageEl =
1321 previewAreaEl. 1269 previewAreaEl.
1322 getElementsByClassName('preview-area-print-failed')[0]; 1270 getElementsByClassName('preview-area-print-failed')[0];
1323 expectTrue(printFailedMessageEl.hidden); 1271 expectTrue(printFailedMessageEl.hidden);
1324 1272
1325 var customMessageEl = 1273 var customMessageEl =
1326 previewAreaEl. 1274 previewAreaEl.
1327 getElementsByClassName('preview-area-custom-message')[0]; 1275 getElementsByClassName('preview-area-custom-message')[0];
1328 expectFalse(customMessageEl.hidden); 1276 expectFalse(customMessageEl.hidden);
1329 1277
1330 testDone(); 1278 testDone();
1331 }); 1279 });
1332 }); 1280 });
1333 1281
1334 // Test custom localized paper names. 1282 // Test custom localized paper names.
1335 TEST_F('PrintPreviewWebUITest', 'TestCustomPaperNames', function() { 1283 TEST_F('PrintPreviewWebUITest', 'TestCustomPaperNames', function() {
1336 this.setInitialSettings(); 1284 this.setInitialSettings();
1337 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1285 this.nativeLayer_.whenCalled('getInitialSettings').then(
1338 function() { 1286 function() {
1339 this.setLocalDestinations(); 1287 this.setLocalDestinations();
1340 1288
1341 var customLocalizedMediaName = 'Vendor defined localized media name'; 1289 var customLocalizedMediaName = 'Vendor defined localized media name';
1342 var customMediaName = 'Vendor defined media name'; 1290 var customMediaName = 'Vendor defined media name';
1343 1291
1344 var device = getCddTemplate("FooDevice"); 1292 var device = getCddTemplate("FooDevice");
1345 device.capabilities.printer.media_size = { 1293 device.capabilities.printer.media_size = {
1346 option: [ 1294 option: [
1347 { name: 'CUSTOM', 1295 { name: 'CUSTOM',
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 advancedOptionsSettingsButton.disabled = false; 1401 advancedOptionsSettingsButton.disabled = false;
1454 advancedOptionsSettingsButton.click(); 1402 advancedOptionsSettingsButton.click();
1455 } 1403 }
1456 1404
1457 // Test advanced settings with 1 capability (should not display settings search 1405 // Test advanced settings with 1 capability (should not display settings search
1458 // box). 1406 // box).
1459 TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings1Option', function() { 1407 TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings1Option', function() {
1460 var device = getCddTemplateWithAdvancedSettings("FooDevice"); 1408 var device = getCddTemplateWithAdvancedSettings("FooDevice");
1461 this.accessibilityIssuesAreErrors = false; 1409 this.accessibilityIssuesAreErrors = false;
1462 this.setInitialSettings(); 1410 this.setInitialSettings();
1463 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1411 this.nativeLayer_.whenCalled('getInitialSettings').then(
1464 function() { 1412 function() {
1465 this.setupAdvancedSettingsTest(device); 1413 this.setupAdvancedSettingsTest(device);
1466 1414
1467 // Open the advanced settings overlay. 1415 // Open the advanced settings overlay.
1468 openAdvancedSettings(); 1416 openAdvancedSettings();
1469 1417
1470 // Check that advanced settings close button is now visible, 1418 // Check that advanced settings close button is now visible,
1471 // but not the search box (only 1 capability). 1419 // but not the search box (only 1 capability).
1472 var advancedSettingsCloseButton = $('advanced-settings'). 1420 var advancedSettingsCloseButton = $('advanced-settings').
1473 querySelector('.close-button'); 1421 querySelector('.close-button');
(...skipping 17 matching lines...) Expand all
1491 select_cap: { 1439 select_cap: {
1492 option: [ 1440 option: [
1493 {display_name: 'Standard', value: 0, is_default: true}, 1441 {display_name: 'Standard', value: 0, is_default: true},
1494 {display_name: 'Recycled', value: 1}, 1442 {display_name: 'Recycled', value: 1},
1495 {display_name: 'Special', value: 2} 1443 {display_name: 'Special', value: 2}
1496 ] 1444 ]
1497 } 1445 }
1498 }); 1446 });
1499 this.accessibilityIssuesAreErrors = false; 1447 this.accessibilityIssuesAreErrors = false;
1500 this.setInitialSettings(); 1448 this.setInitialSettings();
1501 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1449 this.nativeLayer_.whenCalled('getInitialSettings').then(
1502 function() { 1450 function() {
1503 this.setupAdvancedSettingsTest(device); 1451 this.setupAdvancedSettingsTest(device);
1504 1452
1505 // Open the advanced settings overlay. 1453 // Open the advanced settings overlay.
1506 openAdvancedSettings(); 1454 openAdvancedSettings();
1507 1455
1508 // Check advanced settings is visible and that the search box now 1456 // Check advanced settings is visible and that the search box now
1509 // appears. 1457 // appears.
1510 var advancedSettingsCloseButton = $('advanced-settings'). 1458 var advancedSettingsCloseButton = $('advanced-settings').
1511 querySelector('.close-button'); 1459 querySelector('.close-button');
(...skipping 20 matching lines...) Expand all
1532 extensionId: '', extensionName: '' 1480 extensionId: '', extensionName: ''
1533 }; 1481 };
1534 }), 1482 }),
1535 }; 1483 };
1536 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings); 1484 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings);
1537 this.setCapabilities(getCddTemplate('ID1')); 1485 this.setCapabilities(getCddTemplate('ID1'));
1538 this.setCapabilities(getCddTemplate('ID2')); 1486 this.setCapabilities(getCddTemplate('ID2'));
1539 this.setCapabilities(getCddTemplate('ID3')); 1487 this.setCapabilities(getCddTemplate('ID3'));
1540 1488
1541 // Use a real preview generator. 1489 // Use a real preview generator.
1542 this.printPreview_.previewArea_.previewGenerator_ = 1490 this.previewArea_.previewGenerator_ =
1543 new print_preview.PreviewGenerator(this.printPreview_.destinationStore_, 1491 new print_preview.PreviewGenerator(this.printPreview_.destinationStore_,
1544 this.printPreview_.printTicketStore_, this.nativeLayer_, 1492 this.printPreview_.printTicketStore_, this.nativeLayer_,
1545 this.printPreview_.documentInfo_); 1493 this.printPreview_.documentInfo_);
1546 1494
1547 // Preview generator starts out with inFlightRequestId_ == -1. The id 1495 // Preview generator starts out with inFlightRequestId_ == -1. The id
1548 // increments by 1 for each startGetPreview call it makes. It should only 1496 // increments by 1 for each startGetPreview call it makes. It should only
1549 // make one such call during initialization or there will be a race; see 1497 // make one such call during initialization or there will be a race; see
1550 // crbug.com/666595 1498 // crbug.com/666595
1551 expectEquals( 1499 expectEquals(
1552 -1, 1500 -1,
1553 this.printPreview_.previewArea_.previewGenerator_.inFlightRequestId_); 1501 this.previewArea_.previewGenerator_.inFlightRequestId_);
1554 this.setInitialSettings(); 1502 this.setInitialSettings();
1555 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1503 this.nativeLayer_.whenCalled('getInitialSettings').then(
1556 function() { 1504 function() {
1557 expectEquals( 1505 expectEquals(
1558 0, 1506 0,
1559 this.printPreview_.previewArea_.previewGenerator_. 1507 this.previewArea_.previewGenerator_.
1560 inFlightRequestId_); 1508 inFlightRequestId_);
1561 testDone(); 1509 testDone();
1562 }.bind(this)); 1510 }.bind(this));
1563 }); 1511 });
1564 1512
1565 // Test that invalid settings errors disable the print preview and display 1513 // Test that invalid settings errors disable the print preview and display
1566 // an error and that the preview dialog can be recovered by selecting a 1514 // an error and that the preview dialog can be recovered by selecting a
1567 // new destination. 1515 // new destination.
1568 TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() { 1516 TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() {
1569 // Setup 1517 // Setup
1570 this.setInitialSettings(); 1518 this.setInitialSettings();
1571 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1519 this.nativeLayer_.whenCalled('getInitialSettings').then(
1572 function() { 1520 function() {
1573 this.setLocalDestinations(); 1521 this.setLocalDestinations();
1574 this.setCapabilities(getCddTemplate("FooDevice")); 1522 this.setCapabilities(getCddTemplate("FooDevice"));
1575 1523
1576 // Manually enable the print header. This is needed since there is no 1524 // Manually enable the print header. This is needed since there is no
1577 // plugin during test, so it will be set as disabled normally. 1525 // plugin during test, so it will be set as disabled normally.
1578 this.printPreview_.printHeader_.isEnabled = true; 1526 this.printPreview_.printHeader_.isEnabled = true;
1579 1527
1580 // There will be an error message in the preview area since the plugin 1528 // There will be an error message in the preview area since the plugin
1581 // is not running. However, it should not be the invalid settings error. 1529 // is not running. However, it should not be the invalid settings error.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 testDone(); 1574 testDone();
1627 }.bind(this)); 1575 }.bind(this));
1628 }); 1576 });
1629 1577
1630 // Test the preview generator to make sure the generate draft parameter is set 1578 // Test the preview generator to make sure the generate draft parameter is set
1631 // correctly. It should be false if the only change is the page range. 1579 // correctly. It should be false if the only change is the page range.
1632 TEST_F('PrintPreviewWebUITest', 'TestGenerateDraft', function() { 1580 TEST_F('PrintPreviewWebUITest', 'TestGenerateDraft', function() {
1633 this.createPrintPreview(); 1581 this.createPrintPreview();
1634 1582
1635 // Use a real preview generator. 1583 // Use a real preview generator.
1636 this.printPreview_.previewArea_.previewGenerator_ = 1584 this.previewArea_.previewGenerator_ =
1637 new print_preview.PreviewGenerator(this.printPreview_.destinationStore_, 1585 new print_preview.PreviewGenerator(this.printPreview_.destinationStore_,
1638 this.printPreview_.printTicketStore_, this.nativeLayer_, 1586 this.printPreview_.printTicketStore_, this.nativeLayer_,
1639 this.printPreview_.documentInfo_); 1587 this.printPreview_.documentInfo_);
1640 1588
1641 this.setInitialSettings(); 1589 this.setInitialSettings();
1642 this.printPreview_.nativeLayer_.whenCalled('getInitialSettings').then( 1590 this.nativeLayer_.whenCalled('getInitialSettings').then(
1643 function() { 1591 function() {
1644 this.setLocalDestinations(); 1592 this.setLocalDestinations();
1645 this.setCapabilities(getCddTemplate("FooDevice")); 1593 this.setCapabilities(getCddTemplate("FooDevice"));
1646 1594
1647 // The first request should generate draft because there was no 1595 // The first request should generate draft because there was no
1648 // previous print preview draft. 1596 // previous print preview draft.
1649 expectTrue(this.generateDraft()); 1597 expectTrue(this.generateDraft());
1650 1598
1651 // Change the page range - no new draft needed. 1599 // Change the page range - no new draft needed.
1652 this.printPreview_.printTicketStore_.pageRange.updateValue("2"); 1600 this.printPreview_.printTicketStore_.pageRange.updateValue("2");
1653 expectFalse(this.generateDraft()); 1601 expectFalse(this.generateDraft());
1654 1602
1655 // Change the margin type - need to regenerate again. 1603 // Change the margin type - need to regenerate again.
1656 this.printPreview_.printTicketStore_.marginsType.updateValue( 1604 this.printPreview_.printTicketStore_.marginsType.updateValue(
1657 print_preview.ticket_items.MarginsTypeValue.NO_MARGINS); 1605 print_preview.ticket_items.MarginsTypeValue.NO_MARGINS);
1658 expectTrue(this.generateDraft()); 1606 expectTrue(this.generateDraft());
1659 1607
1660 testDone(); 1608 testDone();
1661 }.bind(this)); 1609 }.bind(this));
1662 }); 1610 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698