OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 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 Loading... |
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 | |
102 /** | 90 /** |
103 * Generate a real C++ class; don't typedef. | 91 * Generate a real C++ class; don't typedef. |
104 * @type {?string} | 92 * @type {?string} |
105 * @override | 93 * @override |
106 */ | 94 */ |
107 typedefCppFixture: null, | 95 typedefCppFixture: null, |
108 | 96 |
109 /** | 97 /** |
110 * @this {PrintPreviewWebUITest} | 98 * @this {PrintPreviewWebUITest} |
111 * @override | 99 * @override |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 printPreview.printTicketStore_.marginsType.updateValue( | 577 printPreview.printTicketStore_.marginsType.updateValue( |
590 print_preview.ticket_items.MarginsType.Value.CUSTOM); | 578 print_preview.ticket_items.MarginsType.Value.CUSTOM); |
591 printPreview.printTicketStore_.customMargins.updateValue( | 579 printPreview.printTicketStore_.customMargins.updateValue( |
592 new print_preview.Margins(0, 36, 36, 36)); | 580 new print_preview.Margins(0, 36, 36, 36)); |
593 | 581 |
594 checkElementDisplayed( | 582 checkElementDisplayed( |
595 $('other-options-settings').querySelector('.header-footer-container'), | 583 $('other-options-settings').querySelector('.header-footer-container'), |
596 true); | 584 true); |
597 }); | 585 }); |
598 | 586 |
599 // Test that the color settings, one option, standard monochrome. | 587 // Test that the color settings are set according to the printer capabilities. |
600 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() { | 588 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsTrue', function() { |
601 this.setUpPreview(); | 589 var initialSettingsSetEvent = |
| 590 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
| 591 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
| 592 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
602 | 593 |
603 // Only one option, standard monochrome. | 594 var localDestsSetEvent = |
| 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 |
604 var capsSetEvent = | 624 var capsSetEvent = |
605 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 625 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
606 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 626 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
607 capsSetEvent.settingsInfo.capabilities.printer.color = { | 627 capsSetEvent.settingsInfo.capabilities.printer.color = { |
608 "option": [ | 628 "option": [ |
609 {"is_default": true, "type": "STANDARD_MONOCHROME"} | 629 {"is_default": true, "type": "STANDARD_MONOCHROME"} |
610 ] | 630 ] |
611 }; | 631 }; |
612 this.nativeLayer_.dispatchEvent(capsSetEvent); | 632 this.nativeLayer_.dispatchEvent(capsSetEvent); |
613 | 633 |
614 checkSectionVisible($('color-settings'), false); | 634 checkSectionVisible($('color-settings'), false); |
615 }); | |
616 | 635 |
617 // Test that the color settings, one option, custom monochrome. | 636 var colorOption = $('color-settings').querySelector('.color-option'); |
618 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomMonochrome', | 637 var bwOption = $('color-settings').querySelector('.bw-option'); |
619 function() { | 638 expectFalse(colorOption.checked); |
620 this.setUpPreview(); | 639 expectTrue(bwOption.checked); |
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); | |
732 }); | 640 }); |
733 | 641 |
734 // Test to verify that duplex settings are set according to the printer | 642 // Test to verify that duplex settings are set according to the printer |
735 // capabilities. | 643 // capabilities. |
736 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { | 644 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { |
737 var initialSettingsSetEvent = | 645 var initialSettingsSetEvent = |
738 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 646 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
739 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 647 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
740 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 648 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
741 | 649 |
742 var localDestsSetEvent = | 650 var localDestsSetEvent = |
743 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 651 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
744 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 652 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
745 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 653 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
746 | 654 |
747 var otherOptionsDiv = $('other-options-settings'); | 655 var otherOptionsDiv = $('other-options-settings'); |
748 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); | 656 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); |
749 var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox'); | 657 var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox'); |
750 | 658 |
751 var capsSetEvent = | 659 var capsSetEvent = |
752 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 660 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
753 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 661 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
754 this.nativeLayer_.dispatchEvent(capsSetEvent); | 662 this.nativeLayer_.dispatchEvent(capsSetEvent); |
755 | 663 |
756 checkSectionVisible(otherOptionsDiv, true); | 664 checkSectionVisible(otherOptionsDiv, true); |
757 expectFalse(duplexDiv.hidden); | 665 expectFalse(duplexDiv.hidden); |
758 expectFalse(duplexCheckbox.checked); | 666 expectFalse(duplexCheckbox.checked); |
759 }); | 667 }); |
760 | 668 |
761 // Test to verify that duplex settings are set according to the printer | 669 //Test to verify that duplex settings are set according to the printer |
762 // capabilities. | 670 //capabilities. |
763 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { | 671 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { |
764 var initialSettingsSetEvent = | 672 var initialSettingsSetEvent = |
765 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 673 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
766 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 674 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
767 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 675 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
768 | 676 |
769 var localDestsSetEvent = | 677 var localDestsSetEvent = |
770 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 678 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
771 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 679 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
772 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 680 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 expectEquals(true, previewFailedMessageEl.hidden); | 749 expectEquals(true, previewFailedMessageEl.hidden); |
842 | 750 |
843 var printFailedMessageEl = | 751 var printFailedMessageEl = |
844 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; | 752 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; |
845 expectEquals(true, printFailedMessageEl.hidden); | 753 expectEquals(true, printFailedMessageEl.hidden); |
846 | 754 |
847 var customMessageEl = | 755 var customMessageEl = |
848 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; | 756 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; |
849 expectEquals(false, customMessageEl.hidden); | 757 expectEquals(false, customMessageEl.hidden); |
850 }); | 758 }); |
OLD | NEW |