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

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

Issue 2911203003: Print Preview: Migrate JS tests to use Mocha, part 3. (Closed)
Patch Set: Cleanup Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 cr.define('print_preview_test', function() { 5 cr.define('print_preview_test', function() {
6 /** 6 /**
7 * Index of the "Save as PDF" printer. 7 * Index of the "Save as PDF" printer.
8 * @type {number} 8 * @type {number}
9 * @const 9 * @const
10 */ 10 */
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 730
731 checkElementDisplayed(headerFooter, false); 731 checkElementDisplayed(headerFooter, false);
732 732
733 return whenAnimationDone('more-settings'); 733 return whenAnimationDone('more-settings');
734 }); 734 });
735 }); 735 });
736 736
737 // Page layout has half-inch margins. Show header and footer option. 737 // Page layout has half-inch margins. Show header and footer option.
738 test('PageLayoutHasMarginsShowHeaderFooter', function() { 738 test('PageLayoutHasMarginsShowHeaderFooter', function() {
739 setInitialSettings(); 739 setInitialSettings();
740 nativeLayer.whenCalled('getInitialSettings').then( 740 return nativeLayer.whenCalled('getInitialSettings').then(function() {
741 setLocalDestinations();
742 setCapabilities(getCddTemplate('FooDevice'));
743
744 var otherOptions = $('other-options-settings');
745 var headerFooter =
746 otherOptions.querySelector('#header-footer-container');
747
748 // Check that options are collapsed (section is visible, because
749 // duplex is available).
750 checkSectionVisible(otherOptions, true);
751 checkElementDisplayed(headerFooter, false);
752
753 expandMoreSettings();
754
755 checkElementDisplayed(headerFooter, true);
756
757 printPreview.printTicketStore_.marginsType.updateValue(
758 print_preview.ticket_items.MarginsTypeValue.CUSTOM);
759 printPreview.printTicketStore_.customMargins.updateValue(
760 new print_preview.Margins(36, 36, 36, 36));
761
762 checkElementDisplayed(headerFooter, true);
763
764 return whenAnimationDone('more-settings');
765 });
766 });
767
768
769 // Page layout has zero top and bottom margins. Hide header and footer
770 // option.
771 test('ZeroTopAndBottomMarginsHideHeaderFooter', function() {
772 setInitialSettings();
773 return nativeLayer.whenCalled('getInitialSettings').then(function() {
774 setLocalDestinations();
775 setCapabilities(getCddTemplate('FooDevice'));
776
777 var otherOptions = $('other-options-settings');
778 var headerFooter =
779 otherOptions.querySelector('#header-footer-container');
780
781 // Check that options are collapsed (section is visible, because duplex
782 // is available).
783 checkSectionVisible(otherOptions, true);
784 checkElementDisplayed(headerFooter, false);
785
786 expandMoreSettings();
787
788 checkElementDisplayed(headerFooter, true);
789
790 printPreview.printTicketStore_.marginsType.updateValue(
791 print_preview.ticket_items.MarginsTypeValue.CUSTOM);
792 printPreview.printTicketStore_.customMargins.updateValue(
793 new print_preview.Margins(0, 36, 0, 36));
794
795 checkElementDisplayed(headerFooter, false);
796
797 return whenAnimationDone('more-settings');
798 });
799 });
800
801 // Page layout has zero top and half-inch bottom margin. Show header and
802 // footer option.
803 test('ZeroTopAndNonZeroBottomMarginShowHeaderFooter', function() {
804 setInitialSettings();
805 return nativeLayer.whenCalled('getInitialSettings').then(function() {
806 setLocalDestinations();
807 setCapabilities(getCddTemplate('FooDevice'));
808
809 var otherOptions = $('other-options-settings');
810 var headerFooter =
811 otherOptions.querySelector('#header-footer-container');
812
813 // Check that options are collapsed (section is visible, because duplex
814 // is available).
815 checkSectionVisible(otherOptions, true);
816 checkElementDisplayed(headerFooter, false);
817
818 expandMoreSettings();
819
820 checkElementDisplayed(headerFooter, true);
821
822 printPreview.printTicketStore_.marginsType.updateValue(
823 print_preview.ticket_items.MarginsTypeValue.CUSTOM);
824 printPreview.printTicketStore_.customMargins.updateValue(
825 new print_preview.Margins(0, 36, 36, 36));
826
827 checkElementDisplayed(headerFooter, true);
828
829 return whenAnimationDone('more-settings');
830 });
831 });
832
833 // Check header footer availability with small (label) page size.
834 test('SmallPaperSizeHeaderFooter', function() {
835 setInitialSettings();
836 return nativeLayer.whenCalled('getInitialSettings').then(function() {
837 setLocalDestinations();
838 var device = getCddTemplate('FooDevice');
839 device.capabilities.printer.media_size = {
840 'option': [
841 {'name': 'SmallLabel', 'width_microns': 38100,
842 'height_microns': 12700, 'is_default': false},
843 {'name': 'BigLabel', 'width_microns': 50800,
844 'height_microns': 76200, 'is_default': true}
845 ]
846 };
847 setCapabilities(device);
848
849 var otherOptions = $('other-options-settings');
850 var headerFooter =
851 otherOptions.querySelector('#header-footer-container');
852
853 // Check that options are collapsed (section is visible, because duplex
854 // is available).
855 checkSectionVisible(otherOptions, true);
856 checkElementDisplayed(headerFooter, false);
857
858 expandMoreSettings();
859
860 // Big label should have header/footer
861 checkElementDisplayed(headerFooter, true);
862
863 // Small label should not
864 printPreview.printTicketStore_.mediaSize.updateValue(
865 device.capabilities.printer.media_size.option[0]);
866 checkElementDisplayed(headerFooter, false);
867
868 // Oriented in landscape, there should be enough space for
869 // header/footer.
870 printPreview.printTicketStore_.landscape.updateValue(true);
871 checkElementDisplayed(headerFooter, true);
872
873 return whenAnimationDone('more-settings');
874 });
875 });
876
877 // Test that the color settings, one option, standard monochrome.
878 test('TestColorSettingsMonochrome', function() {
879 setInitialSettings();
880 return nativeLayer.whenCalled('getInitialSettings').then(function() {
881 setLocalDestinations();
882
883 // Only one option, standard monochrome.
884 var device = getCddTemplate('FooDevice');
885 device.capabilities.printer.color = {
886 'option': [
887 {'is_default': true, 'type': 'STANDARD_MONOCHROME'}
888 ]
889 };
890 setCapabilities(device);
891
892 checkSectionVisible($('color-settings'), false);
893
894 return whenAnimationDone('more-settings');
895 });
896 });
897
898 // Test that the color settings, one option, custom monochrome.
899 test('TestColorSettingsCustomMonochrome', function() {
900 setInitialSettings();
901 return nativeLayer.whenCalled('getInitialSettings').then(function() {
902 setLocalDestinations();
903
904 // Only one option, standard monochrome.
905 var device = getCddTemplate('FooDevice');
906 device.capabilities.printer.color = {
907 'option': [
908 {'is_default': true, 'type': 'CUSTOM_MONOCHROME',
909 'vendor_id': '42'}
910 ]
911 };
912 setCapabilities(device);
913
914 checkSectionVisible($('color-settings'), false);
915
916 return whenAnimationDone('more-settings');
917 });
918 });
919
920 // Test that the color settings, one option, standard color.
921 test('TestColorSettingsColor', function() {
922 setInitialSettings();
923 return nativeLayer.whenCalled('getInitialSettings').then(function() {
924 setLocalDestinations();
925
926 var device = getCddTemplate('FooDevice');
927 device.capabilities.printer.color = {
928 'option': [
929 {'is_default': true, 'type': 'STANDARD_COLOR'}
930 ]
931 };
932 setCapabilities(device);
933
934 checkSectionVisible($('color-settings'), false);
935
936 return whenAnimationDone('more-settings');
937 });
938 });
939
940 // Test that the color settings, one option, custom color.
941 test('TestColorSettingsCustomColor', function() {
942 setInitialSettings();
943 return nativeLayer.whenCalled('getInitialSettings').then(function() {
944 setLocalDestinations();
945
946 var device = getCddTemplate('FooDevice');
947 device.capabilities.printer.color = {
948 'option': [
949 {'is_default': true, 'type': 'CUSTOM_COLOR', 'vendor_id': '42'}
950 ]
951 };
952 setCapabilities(device);
953
954 checkSectionVisible($('color-settings'), false);
955
956 return whenAnimationDone('more-settings');
957 });
958 });
959
960 // Test that the color settings, two options, both standard, defaults to
961 // color.
962 test('TestColorSettingsBothStandardDefaultColor', function() {
963 setInitialSettings();
964 return nativeLayer.whenCalled('getInitialSettings').then(function() {
965 setLocalDestinations();
966
967 var device = getCddTemplate('FooDevice');
968 device.capabilities.printer.color = {
969 'option': [
970 {'type': 'STANDARD_MONOCHROME'},
971 {'is_default': true, 'type': 'STANDARD_COLOR'}
972 ]
973 };
974 setCapabilities(device);
975
976 checkSectionVisible($('color-settings'), true);
977 expectEquals(
978 'color',
979 $('color-settings').querySelector('.color-settings-select').value);
980
981 return whenAnimationDone('more-settings');
982 });
983 });
984
985 // Test that the color settings, two options, both standard, defaults to
986 // monochrome.
987 test('TestColorSettingsBothStandardDefaultMonochrome', function() {
988 setInitialSettings();
989 return nativeLayer.whenCalled('getInitialSettings').then(function() {
990 setLocalDestinations();
991
992 var device = getCddTemplate('FooDevice');
993 device.capabilities.printer.color = {
994 'option': [
995 {'is_default': true, 'type': 'STANDARD_MONOCHROME'},
996 {'type': 'STANDARD_COLOR'}
997 ]
998 };
999 setCapabilities(device);
1000
1001 checkSectionVisible($('color-settings'), true);
1002 expectEquals(
1003 'bw',
1004 $('color-settings').querySelector('.color-settings-select').value);
1005
1006 return whenAnimationDone('more-settings');
1007 });
1008 });
1009
1010 // Test that the color settings, two options, both custom, defaults to
1011 // color.
1012 test('TestColorSettingsBothCustomDefaultColor', function() {
1013 setInitialSettings();
1014 return nativeLayer.whenCalled('getInitialSettings').then(
741 function() { 1015 function() {
742 setLocalDestinations(); 1016 setLocalDestinations();
743 setCapabilities(getCddTemplate('FooDevice')); 1017
744 1018 var device = getCddTemplate('FooDevice');
745 var otherOptions = $('other-options-settings'); 1019 device.capabilities.printer.color = {
746 var headerFooter = 1020 'option': [
747 otherOptions.querySelector('#header-footer-container'); 1021 {'type': 'CUSTOM_MONOCHROME', 'vendor_id': '42'},
748 1022 {'is_default': true, 'type': 'CUSTOM_COLOR', 'vendor_id': '43'}
749 // Check that options are collapsed (section is visible, because 1023 ]
750 // duplex is available). 1024 };
751 checkSectionVisible(otherOptions, true); 1025 setCapabilities(device);
752 checkElementDisplayed(headerFooter, false); 1026
753 1027 checkSectionVisible($('color-settings'), true);
754 expandMoreSettings(); 1028 expectEquals(
755 1029 'color',
756 checkElementDisplayed(headerFooter, true); 1030 $('color-settings').querySelector(
757 1031 '.color-settings-select').value);
758 printPreview.printTicketStore_.marginsType.updateValue(
759 print_preview.ticket_items.MarginsTypeValue.CUSTOM);
760 printPreview.printTicketStore_.customMargins.updateValue(
761 new print_preview.Margins(36, 36, 36, 36));
762
763 checkElementDisplayed(headerFooter, true);
764 1032
765 return whenAnimationDone('more-settings'); 1033 return whenAnimationDone('more-settings');
766 }); 1034 });
767 }); 1035 });
768
769 1036
770 }); 1037 });
771 }); 1038 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698