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

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

Issue 324523002: Generalize printer color model handling, get rid of CUPS specific case. Enable supported paper szes… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 6 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 | Annotate | Revision Log
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 cloudprint.CloudPrintInterface = CloudPrintInterfaceStub; 80 cloudprint.CloudPrintInterface = CloudPrintInterfaceStub;
81 cloudprint.CloudPrintInterface.EventType = oldCpInterfaceEventType; 81 cloudprint.CloudPrintInterface.EventType = oldCpInterfaceEventType;
82 82
83 print_preview.PreviewArea.prototype.getPluginType_ = 83 print_preview.PreviewArea.prototype.getPluginType_ =
84 function() { 84 function() {
85 return print_preview.PreviewArea.PluginType_.NONE; 85 return print_preview.PreviewArea.PluginType_.NONE;
86 }; 86 };
87 }.bind(this)); 87 }.bind(this));
88 }, 88 },
89 89
90 setUpPreview: function() {
91 var initialSettingsSetEvent =
92 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
93 initialSettingsSetEvent.initialSettings = this.initialSettings_;
94 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
95
96 var localDestsSetEvent =
97 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
98 localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
99 this.nativeLayer_.dispatchEvent(localDestsSetEvent);
100 },
101
90 /** 102 /**
91 * Generate a real C++ class; don't typedef. 103 * Generate a real C++ class; don't typedef.
92 * @type {?string} 104 * @type {?string}
93 * @override 105 * @override
94 */ 106 */
95 typedefCppFixture: null, 107 typedefCppFixture: null,
96 108
97 /** 109 /**
98 * @this {PrintPreviewWebUITest} 110 * @this {PrintPreviewWebUITest}
99 * @override 111 * @override
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 printPreview.printTicketStore_.marginsType.updateValue( 589 printPreview.printTicketStore_.marginsType.updateValue(
578 print_preview.ticket_items.MarginsType.Value.CUSTOM); 590 print_preview.ticket_items.MarginsType.Value.CUSTOM);
579 printPreview.printTicketStore_.customMargins.updateValue( 591 printPreview.printTicketStore_.customMargins.updateValue(
580 new print_preview.Margins(0, 36, 36, 36)); 592 new print_preview.Margins(0, 36, 36, 36));
581 593
582 checkElementDisplayed( 594 checkElementDisplayed(
583 $('other-options-settings').querySelector('.header-footer-container'), 595 $('other-options-settings').querySelector('.header-footer-container'),
584 true); 596 true);
585 }); 597 });
586 598
587 // Test that the color settings are set according to the printer capabilities. 599 // Test that the color settings, one option, standard monochrome.
588 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsTrue', function() { 600 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() {
589 var initialSettingsSetEvent = 601 this.setUpPreview();
590 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
591 initialSettingsSetEvent.initialSettings = this.initialSettings_;
592 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
593 602
594 var localDestsSetEvent = 603 // Only one option, standard monochrome.
595 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
596 localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
597 this.nativeLayer_.dispatchEvent(localDestsSetEvent);
598
599 var capsSetEvent =
600 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
601 capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
602 this.nativeLayer_.dispatchEvent(capsSetEvent);
603
604 checkSectionVisible($('color-settings'), true);
605
606 var colorOption = $('color-settings').querySelector('.color-option');
607 var bwOption = $('color-settings').querySelector('.bw-option');
608 expectTrue(colorOption.checked);
609 expectFalse(bwOption.checked);
610 });
611
612 //Test that the color settings are set according to the printer capabilities.
613 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsFalse', function() {
614 var initialSettingsSetEvent =
615 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
616 initialSettingsSetEvent.initialSettings = this.initialSettings_;
617 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
618
619 var localDestsSetEvent =
620 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
621 localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
622 this.nativeLayer_.dispatchEvent(localDestsSetEvent);
623
624 var capsSetEvent = 604 var capsSetEvent =
625 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); 605 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
626 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); 606 capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
627 capsSetEvent.settingsInfo.capabilities.printer.color = { 607 capsSetEvent.settingsInfo.capabilities.printer.color = {
628 "option": [ 608 "option": [
629 {"is_default": true, "type": "STANDARD_MONOCHROME"} 609 {"is_default": true, "type": "STANDARD_MONOCHROME"}
630 ] 610 ]
631 }; 611 };
632 this.nativeLayer_.dispatchEvent(capsSetEvent); 612 this.nativeLayer_.dispatchEvent(capsSetEvent);
633 613
634 checkSectionVisible($('color-settings'), false); 614 checkSectionVisible($('color-settings'), false);
615 });
635 616
636 var colorOption = $('color-settings').querySelector('.color-option'); 617 // Test that the color settings, one option, custom monochrome.
637 var bwOption = $('color-settings').querySelector('.bw-option'); 618 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome',
638 expectFalse(colorOption.checked); 619 function() {
639 expectTrue(bwOption.checked); 620 this.setUpPreview();
621
622 // Only one option, standard monochrome.
623 var capsSetEvent =
624 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
625 capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
626 capsSetEvent.settingsInfo.capabilities.printer.color = {
627 "option": [
628 {"is_default": true, "type": "CUSTOM_MONOCHROME", "vendor_id": "42"}
629 ]
630 };
631 this.nativeLayer_.dispatchEvent(capsSetEvent);
632
633 checkSectionVisible($('color-settings'), false);
634 });
635
636 // Test that the color settings, one option, standard color.
637 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() {
638 this.setUpPreview();
639
640 var capsSetEvent =
641 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
642 capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
643 capsSetEvent.settingsInfo.capabilities.printer.color = {
644 "option": [
645 {"is_default": true, "type": "STANDARD_COLOR"}
646 ]
647 };
648 this.nativeLayer_.dispatchEvent(capsSetEvent);
649
650 checkSectionVisible($('color-settings'), false);
651 });
652
653 // Test that the color settings, one option, custom color.
654 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() {
655 this.setUpPreview();
656
657 var capsSetEvent =
658 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
659 capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
660 capsSetEvent.settingsInfo.capabilities.printer.color = {
661 "option": [
662 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"}
663 ]
664 };
665 this.nativeLayer_.dispatchEvent(capsSetEvent);
666
667 checkSectionVisible($('color-settings'), false);
668 });
669
670 // Test that the color settings, two options, both standard, defaults to color.
671 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor',
672 function() {
673 this.setUpPreview();
674
675 var capsSetEvent =
676 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
677 capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
678 capsSetEvent.settingsInfo.capabilities.printer.color = {
679 "option": [
680 {"type": "STANDARD_MONOCHROME"},
681 {"is_default": true, "type": "STANDARD_COLOR"}
682 ]
683 };
684 this.nativeLayer_.dispatchEvent(capsSetEvent);
685
686 checkSectionVisible($('color-settings'), true);
687 expectTrue($('color-settings').querySelector('.color-option').checked);
688 expectFalse($('color-settings').querySelector('.bw-option').checked);
689 });
690
691 // Test that the color settings, two options, both standard, defaults to
692 // monochrome.
693 TEST_F('PrintPreviewWebUITest',
694 'TestColorSettingsBothStandardDefaultMonochrome', function() {
695 this.setUpPreview();
696
697 var capsSetEvent =
698 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
699 capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
700 capsSetEvent.settingsInfo.capabilities.printer.color = {
701 "option": [
702 {"is_default": true, "type": "STANDARD_MONOCHROME"},
703 {"type": "STANDARD_COLOR"}
704 ]
705 };
706 this.nativeLayer_.dispatchEvent(capsSetEvent);
707
708 checkSectionVisible($('color-settings'), true);
709 expectFalse($('color-settings').querySelector('.color-option').checked);
710 expectTrue($('color-settings').querySelector('.bw-option').checked);
711 });
712
713 // Test that the color settings, two options, both custom, defaults to color.
714 TEST_F('PrintPreviewWebUITest',
715 'TestColorSettingsBothCustomDefaultColor', function() {
716 this.setUpPreview();
717
718 var capsSetEvent =
719 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
720 capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
721 capsSetEvent.settingsInfo.capabilities.printer.color = {
722 "option": [
723 {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"},
724 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"}
725 ]
726 };
727 this.nativeLayer_.dispatchEvent(capsSetEvent);
728
729 checkSectionVisible($('color-settings'), true);
730 expectTrue($('color-settings').querySelector('.color-option').checked);
731 expectFalse($('color-settings').querySelector('.bw-option').checked);
640 }); 732 });
641 733
642 // Test to verify that duplex settings are set according to the printer 734 // Test to verify that duplex settings are set according to the printer
643 // capabilities. 735 // capabilities.
644 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { 736 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() {
645 var initialSettingsSetEvent = 737 var initialSettingsSetEvent =
646 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); 738 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
647 initialSettingsSetEvent.initialSettings = this.initialSettings_; 739 initialSettingsSetEvent.initialSettings = this.initialSettings_;
648 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); 740 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
649 741
650 var localDestsSetEvent = 742 var localDestsSetEvent =
651 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); 743 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
652 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; 744 localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
653 this.nativeLayer_.dispatchEvent(localDestsSetEvent); 745 this.nativeLayer_.dispatchEvent(localDestsSetEvent);
654 746
655 var otherOptionsDiv = $('other-options-settings'); 747 var otherOptionsDiv = $('other-options-settings');
656 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); 748 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container');
657 var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox'); 749 var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox');
658 750
659 var capsSetEvent = 751 var capsSetEvent =
660 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); 752 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
661 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); 753 capsSetEvent.settingsInfo = getCddTemplate("FooDevice");
662 this.nativeLayer_.dispatchEvent(capsSetEvent); 754 this.nativeLayer_.dispatchEvent(capsSetEvent);
663 755
664 checkSectionVisible(otherOptionsDiv, true); 756 checkSectionVisible(otherOptionsDiv, true);
665 expectFalse(duplexDiv.hidden); 757 expectFalse(duplexDiv.hidden);
666 expectFalse(duplexCheckbox.checked); 758 expectFalse(duplexCheckbox.checked);
667 }); 759 });
668 760
669 //Test to verify that duplex settings are set according to the printer 761 // Test to verify that duplex settings are set according to the printer
670 //capabilities. 762 // capabilities.
671 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { 763 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() {
672 var initialSettingsSetEvent = 764 var initialSettingsSetEvent =
673 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); 765 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
674 initialSettingsSetEvent.initialSettings = this.initialSettings_; 766 initialSettingsSetEvent.initialSettings = this.initialSettings_;
675 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); 767 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent);
676 768
677 var localDestsSetEvent = 769 var localDestsSetEvent =
678 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); 770 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
679 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; 771 localDestsSetEvent.destinationInfos = this.localDestinationInfos_;
680 this.nativeLayer_.dispatchEvent(localDestsSetEvent); 772 this.nativeLayer_.dispatchEvent(localDestsSetEvent);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 expectEquals(true, previewFailedMessageEl.hidden); 841 expectEquals(true, previewFailedMessageEl.hidden);
750 842
751 var printFailedMessageEl = 843 var printFailedMessageEl =
752 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; 844 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0];
753 expectEquals(true, printFailedMessageEl.hidden); 845 expectEquals(true, printFailedMessageEl.hidden);
754 846
755 var customMessageEl = 847 var customMessageEl =
756 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; 848 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0];
757 expectEquals(false, customMessageEl.hidden); 849 expectEquals(false, customMessageEl.hidden);
758 }); 850 });
OLDNEW
« no previous file with comments | « chrome/common/cloud_print/cloud_print_cdd_conversion.cc ('k') | printing/backend/print_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698