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

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

Issue 10909124: Improves application state persistance. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updates unit tests. Created 8 years, 3 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
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * Test fixture for print preview WebUI testing. 6 * Test fixture for print preview WebUI testing.
7 * @constructor 7 * @constructor
8 * @extends {testing.Test} 8 * @extends {testing.Test}
9 */ 9 */
10 function PrintPreviewWebUITest() { 10 function PrintPreviewWebUITest() {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 setUp: function() { 100 setUp: function() {
101 Mock4JS.clearMocksToVerify(); 101 Mock4JS.clearMocksToVerify();
102 102
103 this.initialSettings_ = new print_preview.NativeInitialSettings( 103 this.initialSettings_ = new print_preview.NativeInitialSettings(
104 false /*isInKioskAutoPrintMode*/, 104 false /*isInKioskAutoPrintMode*/,
105 ',' /*thousandsDelimeter*/, 105 ',' /*thousandsDelimeter*/,
106 '.' /*decimalDelimeter*/, 106 '.' /*decimalDelimeter*/,
107 1 /*unitType*/, 107 1 /*unitType*/,
108 true /*isDocumentModifiable*/, 108 true /*isDocumentModifiable*/,
109 'title' /*documentTitle*/, 109 'title' /*documentTitle*/,
110 0 /*marginsType*/, 110 'FooDevice' /*systemDefaultDestinationId*/,
111 null /*customMargins*/, 111 null /*serializedAppStateStr*/);
112 true /*isDuplexEnabled*/,
113 false /*isHeaderFooterEnabled*/,
114 'FooDevice' /*initialDestinationId*/);
115 this.localDestinationInfos_ = [ 112 this.localDestinationInfos_ = [
116 { printerName: 'FooName', deviceName: 'FooDevice' }, 113 { printerName: 'FooName', deviceName: 'FooDevice' },
117 { printerName: 'BarName', deviceName: 'BarDevice' } 114 { printerName: 'BarName', deviceName: 'BarDevice' }
118 ]; 115 ];
119 this.nativeLayer_ = printPreview.nativeLayer_; 116 this.nativeLayer_ = printPreview.nativeLayer_;
120 } 117 }
121 }; 118 };
122 119
123 GEN('#include "chrome/test/data/webui/print_preview.h"'); 120 GEN('#include "chrome/test/data/webui/print_preview.h"');
124 121
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 checkSectionVisible($('copies-settings'), false); 252 checkSectionVisible($('copies-settings'), false);
256 }); 253 });
257 254
258 // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the 255 // When the source is 'PDF' and 'Save as PDF' option is selected, we hide the
259 // fit to page option. 256 // fit to page option.
260 TEST_F('PrintPreviewWebUITest', 257 TEST_F('PrintPreviewWebUITest',
261 'PrintToPDFSelectedHideFitToPageOption', 258 'PrintToPDFSelectedHideFitToPageOption',
262 function() { 259 function() {
263 // Add PDF printer. 260 // Add PDF printer.
264 this.initialSettings_.isDocumentModifiable_ = false; 261 this.initialSettings_.isDocumentModifiable_ = false;
265 this.initialSettings_.initialDestinationId_ = 'Save as PDF'; 262 this.initialSettings_.systemDefaultDestinationId_ = 'Save as PDF';
266 this.localDestinationInfos_.push( 263 this.localDestinationInfos_.push(
267 {printerName: 'Save as PDF', deviceName: 'Save as PDF'}); 264 {printerName: 'Save as PDF', deviceName: 'Save as PDF'});
268 265
269 var initialSettingsSetEvent = 266 var initialSettingsSetEvent =
270 new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); 267 new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
271 initialSettingsSetEvent.initialSettings = this.initialSettings_; 268 initialSettingsSetEvent.initialSettings = this.initialSettings_;
272 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); 269 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
273 270
274 var localDestsSetEvent = 271 var localDestsSetEvent =
275 new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); 272 new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 print_preview.ticket_items.MarginsType.Value.CUSTOM); 548 print_preview.ticket_items.MarginsType.Value.CUSTOM);
552 printPreview.printTicketStore_.updateCustomMargins( 549 printPreview.printTicketStore_.updateCustomMargins(
553 new print_preview.Margins(0, 36, 36, 36)); 550 new print_preview.Margins(0, 36, 36, 36));
554 551
555 checkElementDisplayed( 552 checkElementDisplayed(
556 $('other-options-settings').querySelector('.header-footer-container'), 553 $('other-options-settings').querySelector('.header-footer-container'),
557 true); 554 true);
558 }); 555 });
559 556
560 // Test that the color settings are set according to the printer capabilities. 557 // Test that the color settings are set according to the printer capabilities.
561 TEST_F('PrintPreviewWebUITest', 'TestColorSettings', function() { 558 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsTrue', function() {
562 var initialSettingsSetEvent = 559 var initialSettingsSetEvent =
563 new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); 560 new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
564 initialSettingsSetEvent.initialSettings = this.initialSettings_; 561 initialSettingsSetEvent.initialSettings = this.initialSettings_;
565 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); 562 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
566 563
567 var localDestsSetEvent = 564 var localDestsSetEvent =
568 new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); 565 new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
569 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; 566 localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
570 this.nativeLayer_.dispatchEvent(localDestsSetEvent); 567 this.nativeLayer_.dispatchEvent(localDestsSetEvent);
571 568
572 checkSectionVisible($('color-settings'), true); 569 checkSectionVisible($('color-settings'), true);
573 570
574 var capsSetEvent = 571 var capsSetEvent =
575 new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); 572 new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
576 capsSetEvent.settingsInfo = { 573 capsSetEvent.settingsInfo = {
577 'printerId': 'FooDevice', 574 'printerId': 'FooDevice',
578 'disableColorOption': false, 575 'disableColorOption': false,
579 'setColorAsDefault': true, 576 'setColorAsDefault': true,
580 'disableCopiesOption': true, 577 'disableCopiesOption': false,
581 'disableLandscapeOption': true, 578 'disableLandscapeOption': true,
582 'printerDefaultDuplexValue': 0 579 'printerDefaultDuplexValue': 0
583 }; 580 };
584 this.nativeLayer_.dispatchEvent(capsSetEvent); 581 this.nativeLayer_.dispatchEvent(capsSetEvent);
585 582
586 checkSectionVisible($('color-settings'), true); 583 checkSectionVisible($('color-settings'), true);
587 584
588 var colorOption = $('color-settings').getElementsByClassName( 585 var colorOption = $('color-settings').getElementsByClassName(
589 'color-settings-color-option')[0]; 586 'color-settings-color-option')[0];
590 var bwOption = $('color-settings').getElementsByClassName( 587 var bwOption = $('color-settings').getElementsByClassName(
591 'color-settings-bw-option')[0]; 588 'color-settings-bw-option')[0];
592 expectTrue(colorOption.checked); 589 expectTrue(colorOption.checked);
593 expectFalse(bwOption.checked); 590 expectFalse(bwOption.checked);
591 });
592
593 //Test that the color settings are set according to the printer capabilities.
594 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsFalse', function() {
595 var initialSettingsSetEvent =
596 new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
597 initialSettingsSetEvent.initialSettings = this.initialSettings_;
598 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
599
600 var localDestsSetEvent =
601 new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
602 localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
603 this.nativeLayer_.dispatchEvent(localDestsSetEvent);
604
605 checkSectionVisible($('color-settings'), true);
594 606
595 var capsSetEvent = 607 var capsSetEvent =
596 new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); 608 new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
597 capsSetEvent.settingsInfo = { 609 capsSetEvent.settingsInfo = {
598 'printerId': 'FooDevice', 610 'printerId': 'FooDevice',
599 'disableColorOption': false, 611 'disableColorOption': true,
600 'setColorAsDefault': false, 612 'setColorAsDefault': false,
601 'disableCopiesOption': false, 613 'disableCopiesOption': false,
602 'disableLandscapeOption': false, 614 'disableLandscapeOption': true,
603 'printerDefaultDuplexValue': 0 615 'printerDefaultDuplexValue': 0
604 }; 616 };
605 this.nativeLayer_.dispatchEvent(capsSetEvent); 617 this.nativeLayer_.dispatchEvent(capsSetEvent);
606 618
607 checkSectionVisible($('color-settings'), true); 619 checkSectionVisible($('color-settings'), false);
620
621 var colorOption = $('color-settings').getElementsByClassName(
622 'color-settings-color-option')[0];
623 var bwOption = $('color-settings').getElementsByClassName(
624 'color-settings-bw-option')[0];
608 expectFalse(colorOption.checked); 625 expectFalse(colorOption.checked);
609 expectTrue(bwOption.checked); 626 expectTrue(bwOption.checked);
610 }); 627 });
611 628
612 // Test to verify that duplex settings are set according to the printer 629 // Test to verify that duplex settings are set according to the printer
613 // capabilities. 630 // capabilities.
614 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettings', function() { 631 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() {
615 var initialSettingsSetEvent = 632 var initialSettingsSetEvent =
616 new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); 633 new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
617 // Need to override test defaults for the initial settings, because initial 634 initialSettingsSetEvent.initialSettings = this.initialSettings_;
618 // duplex value needs to be unspecified.
619 initialSettingsSetEvent.initialSettings =
620 new print_preview.NativeInitialSettings(
621 false /*isInKioskAutoPrintMode*/,
622 ',' /*thousandsDelimeter*/,
623 '.' /*decimalDelimeter*/,
624 1 /*unitType*/,
625 true /*isDocumentModifiable*/,
626 'title' /*documentTitle*/,
627 0 /*marginsType*/,
628 null /*customMargins*/,
629 null /*isDuplexEnabled*/,
630 false /*isHeaderFooterEnabled*/,
631 'FooDevice' /*initialDestinationId*/);
632 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); 635 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
633 636
634 var localDestsSetEvent = 637 var localDestsSetEvent =
635 new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); 638 new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
636 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; 639 localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
637 this.nativeLayer_.dispatchEvent(localDestsSetEvent); 640 this.nativeLayer_.dispatchEvent(localDestsSetEvent);
638 641
639 var otherOptionsDiv = $('other-options-settings'); 642 var otherOptionsDiv = $('other-options-settings');
640 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); 643 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container');
641 var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox'); 644 var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox');
642 645
643 var capsSetEvent = 646 var capsSetEvent =
644 new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); 647 new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
645 capsSetEvent.settingsInfo = { 648 capsSetEvent.settingsInfo = {
646 'printerId': 'FooDevice', 649 'printerId': 'FooDevice',
647 'disableColorOption': false, 650 'disableColorOption': false,
648 'setColorAsDefault': true, 651 'setColorAsDefault': true,
649 'disableCopiesOption': false, 652 'disableCopiesOption': false,
650 'disableLandscapeOption': true, 653 'disableLandscapeOption': true,
651 'printerDefaultDuplexValue': 0, 654 'printerDefaultDuplexValue': 0,
652 'setDuplexAsDefault': false 655 'setDuplexAsDefault': false
653 }; 656 };
654 this.nativeLayer_.dispatchEvent(capsSetEvent); 657 this.nativeLayer_.dispatchEvent(capsSetEvent);
655 658
656 checkSectionVisible(otherOptionsDiv, true); 659 checkSectionVisible(otherOptionsDiv, true);
657 expectFalse(duplexDiv.hidden); 660 expectFalse(duplexDiv.hidden);
658 expectFalse(duplexCheckbox.checked); 661 expectFalse(duplexCheckbox.checked);
662 });
659 663
660 // If the printer default duplex value is UNKNOWN_DUPLEX_MODE, hide the 664 //Test to verify that duplex settings are set according to the printer
661 // two sided option. 665 //capabilities.
666 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() {
667 var initialSettingsSetEvent =
668 new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
669 initialSettingsSetEvent.initialSettings = this.initialSettings_;
670 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
671
672 var localDestsSetEvent =
673 new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
674 localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
675 this.nativeLayer_.dispatchEvent(localDestsSetEvent);
676
677 var otherOptionsDiv = $('other-options-settings');
678 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container');
679
662 var capsSetEvent = 680 var capsSetEvent =
663 new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); 681 new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
664 capsSetEvent.settingsInfo = { 682 capsSetEvent.settingsInfo = {
665 'printerId': 'FooDevice', 683 'printerId': 'FooDevice',
666 'disableColorOption': false, 684 'disableColorOption': false,
667 'setColorAsDefault': false, 685 'setColorAsDefault': true,
668 'disableCopiesOption': false, 686 'disableCopiesOption': false,
669 'disableLandscapeOption': false, 687 'disableLandscapeOption': true,
670 'printerDefaultDuplexValue': -1 688 'printerDefaultDuplexValue': -1,
689 'setDuplexAsDefault': false
671 }; 690 };
672 this.nativeLayer_.dispatchEvent(capsSetEvent); 691 this.nativeLayer_.dispatchEvent(capsSetEvent);
673 692
674 checkSectionVisible(otherOptionsDiv, true); 693 checkSectionVisible(otherOptionsDiv, true);
675 expectTrue(duplexDiv.hidden); 694 expectTrue(duplexDiv.hidden);
676
677 var capsSetEvent =
678 new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
679 capsSetEvent.settingsInfo = {
680 'printerId': 'FooDevice',
681 'disableColorOption': false,
682 'setColorAsDefault': false,
683 'disableCopiesOption': false,
684 'disableLandscapeOption': false,
685 'printerDefaultDuplexValue': 1,
686 'setDuplexAsDefault': true
687 };
688 this.nativeLayer_.dispatchEvent(capsSetEvent);
689
690 checkSectionVisible(otherOptionsDiv, true);
691 expectFalse(duplexDiv.hidden);
692 expectTrue(duplexCheckbox.checked);
693 }); 695 });
694 696
695 // Test that changing the selected printer updates the preview. 697 // Test that changing the selected printer updates the preview.
696 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { 698 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() {
697 699
698 var initialSettingsSetEvent = 700 var initialSettingsSetEvent =
699 new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); 701 new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
700 initialSettingsSetEvent.initialSettings = this.initialSettings_; 702 initialSettingsSetEvent.initialSettings = this.initialSettings_;
701 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); 703 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
702 704
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 expectEquals(true, previewFailedMessageEl.hidden); 760 expectEquals(true, previewFailedMessageEl.hidden);
759 761
760 var printFailedMessageEl = 762 var printFailedMessageEl =
761 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; 763 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0];
762 expectEquals(true, printFailedMessageEl.hidden); 764 expectEquals(true, printFailedMessageEl.hidden);
763 765
764 var customMessageEl = 766 var customMessageEl =
765 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; 767 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0];
766 expectEquals(false, customMessageEl.hidden); 768 expectEquals(false, customMessageEl.hidden);
767 }); 769 });
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698