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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 /** | 109 /** |
110 * @this {PrintPreviewWebUITest} | 110 * @this {PrintPreviewWebUITest} |
111 * @override | 111 * @override |
112 */ | 112 */ |
113 setUp: function() { | 113 setUp: function() { |
114 Mock4JS.clearMocksToVerify(); | 114 Mock4JS.clearMocksToVerify(); |
115 | 115 |
116 this.initialSettings_ = new print_preview.NativeInitialSettings( | 116 this.initialSettings_ = new print_preview.NativeInitialSettings( |
117 false /*isInKioskAutoPrintMode*/, | 117 false /*isInKioskAutoPrintMode*/, |
| 118 false /*isInAppKioskMode*/, |
118 false /*hidePrintWithSystemDialogLink*/, | 119 false /*hidePrintWithSystemDialogLink*/, |
119 ',' /*thousandsDelimeter*/, | 120 ',' /*thousandsDelimeter*/, |
120 '.' /*decimalDelimeter*/, | 121 '.' /*decimalDelimeter*/, |
121 1 /*unitType*/, | 122 1 /*unitType*/, |
122 true /*isDocumentModifiable*/, | 123 true /*isDocumentModifiable*/, |
123 'title' /*documentTitle*/, | 124 'title' /*documentTitle*/, |
124 true /*documentHasSelection*/, | 125 true /*documentHasSelection*/, |
125 false /*selectionOnly*/, | 126 false /*selectionOnly*/, |
126 'FooDevice' /*systemDefaultDestinationId*/, | 127 'FooDevice' /*systemDefaultDestinationId*/, |
127 null /*serializedAppStateStr*/, | 128 null /*serializedAppStateStr*/, |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { | 469 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { |
469 var control = $('preview-area').querySelector('.margin-control-' + margin); | 470 var control = $('preview-area').querySelector('.margin-control-' + margin); |
470 assertNotEquals(null, control); | 471 assertNotEquals(null, control); |
471 var input = control.querySelector('.margin-control-textbox'); | 472 var input = control.querySelector('.margin-control-textbox'); |
472 assertTrue(input.hasAttribute('aria-label')); | 473 assertTrue(input.hasAttribute('aria-label')); |
473 assertNotEquals('undefined', input.getAttribute('aria-label')); | 474 assertNotEquals('undefined', input.getAttribute('aria-label')); |
474 }); | 475 }); |
475 }); | 476 }); |
476 | 477 |
477 // Page layout has zero margins. Hide header and footer option. | 478 // Page layout has zero margins. Hide header and footer option. |
478 TEST_F('PrintPreviewWebUITest', | 479 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter', |
479 'PageLayoutHasNoMarginsHideHeaderFooter', | 480 function() { |
480 function() { | |
481 var initialSettingsSetEvent = | 481 var initialSettingsSetEvent = |
482 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 482 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
483 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 483 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
484 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 484 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
485 | 485 |
486 var localDestsSetEvent = | 486 var localDestsSetEvent = |
487 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 487 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
488 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 488 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
489 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 489 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
490 | 490 |
(...skipping 10 matching lines...) Expand all Loading... |
501 print_preview.ticket_items.MarginsType.Value.CUSTOM); | 501 print_preview.ticket_items.MarginsType.Value.CUSTOM); |
502 printPreview.printTicketStore_.customMargins.updateValue( | 502 printPreview.printTicketStore_.customMargins.updateValue( |
503 new print_preview.Margins(0, 0, 0, 0)); | 503 new print_preview.Margins(0, 0, 0, 0)); |
504 | 504 |
505 checkElementDisplayed( | 505 checkElementDisplayed( |
506 $('other-options-settings').querySelector('.header-footer-container'), | 506 $('other-options-settings').querySelector('.header-footer-container'), |
507 false); | 507 false); |
508 }); | 508 }); |
509 | 509 |
510 // Page layout has half-inch margins. Show header and footer option. | 510 // Page layout has half-inch margins. Show header and footer option. |
511 TEST_F('PrintPreviewWebUITest', | 511 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter', |
512 'PageLayoutHasMarginsShowHeaderFooter', | 512 function() { |
513 function() { | |
514 var initialSettingsSetEvent = | 513 var initialSettingsSetEvent = |
515 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 514 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); |
516 initialSettingsSetEvent.initialSettings = this.initialSettings_; | 515 initialSettingsSetEvent.initialSettings = this.initialSettings_; |
517 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 516 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
518 | 517 |
519 var localDestsSetEvent = | 518 var localDestsSetEvent = |
520 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 519 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); |
521 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 520 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; |
522 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 521 this.nativeLayer_.dispatchEvent(localDestsSetEvent); |
523 | 522 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 this.nativeLayer_.dispatchEvent(capsSetEvent); | 641 this.nativeLayer_.dispatchEvent(capsSetEvent); |
643 | 642 |
644 checkSectionVisible($('color-settings'), false); | 643 checkSectionVisible($('color-settings'), false); |
645 }); | 644 }); |
646 | 645 |
647 // Test that the color settings, one option, standard color. | 646 // Test that the color settings, one option, standard color. |
648 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() { | 647 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsColor', function() { |
649 this.setUpPreview(); | 648 this.setUpPreview(); |
650 | 649 |
651 var capsSetEvent = | 650 var capsSetEvent = |
652 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 651 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
653 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 652 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
654 capsSetEvent.settingsInfo.capabilities.printer.color = { | 653 capsSetEvent.settingsInfo.capabilities.printer.color = { |
655 "option": [ | 654 "option": [ |
656 {"is_default": true, "type": "STANDARD_COLOR"} | 655 {"is_default": true, "type": "STANDARD_COLOR"} |
657 ] | 656 ] |
658 }; | 657 }; |
659 this.nativeLayer_.dispatchEvent(capsSetEvent); | 658 this.nativeLayer_.dispatchEvent(capsSetEvent); |
660 | 659 |
661 checkSectionVisible($('color-settings'), false); | 660 checkSectionVisible($('color-settings'), false); |
662 }); | 661 }); |
663 | 662 |
664 // Test that the color settings, one option, custom color. | 663 // Test that the color settings, one option, custom color. |
665 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() { | 664 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsCustomColor', function() { |
666 this.setUpPreview(); | 665 this.setUpPreview(); |
667 | 666 |
668 var capsSetEvent = | 667 var capsSetEvent = |
669 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 668 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
670 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 669 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
671 capsSetEvent.settingsInfo.capabilities.printer.color = { | 670 capsSetEvent.settingsInfo.capabilities.printer.color = { |
672 "option": [ | 671 "option": [ |
673 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"} | 672 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "42"} |
674 ] | 673 ] |
675 }; | 674 }; |
676 this.nativeLayer_.dispatchEvent(capsSetEvent); | 675 this.nativeLayer_.dispatchEvent(capsSetEvent); |
677 | 676 |
678 checkSectionVisible($('color-settings'), false); | 677 checkSectionVisible($('color-settings'), false); |
679 }); | 678 }); |
680 | 679 |
681 // Test that the color settings, two options, both standard, defaults to color. | 680 // Test that the color settings, two options, both standard, defaults to color. |
682 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor', | 681 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsBothStandardDefaultColor', |
683 function() { | 682 function() { |
684 this.setUpPreview(); | 683 this.setUpPreview(); |
(...skipping 17 matching lines...) Expand all Loading... |
702 // Test that the color settings, two options, both standard, defaults to | 701 // Test that the color settings, two options, both standard, defaults to |
703 // monochrome. | 702 // monochrome. |
704 TEST_F('PrintPreviewWebUITest', | 703 TEST_F('PrintPreviewWebUITest', |
705 'TestColorSettingsBothStandardDefaultMonochrome', function() { | 704 'TestColorSettingsBothStandardDefaultMonochrome', function() { |
706 this.setUpPreview(); | 705 this.setUpPreview(); |
707 | 706 |
708 var capsSetEvent = | 707 var capsSetEvent = |
709 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 708 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
710 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 709 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
711 capsSetEvent.settingsInfo.capabilities.printer.color = { | 710 capsSetEvent.settingsInfo.capabilities.printer.color = { |
712 "option": [ | 711 "option": [ |
713 {"is_default": true, "type": "STANDARD_MONOCHROME"}, | 712 {"is_default": true, "type": "STANDARD_MONOCHROME"}, |
714 {"type": "STANDARD_COLOR"} | 713 {"type": "STANDARD_COLOR"} |
715 ] | 714 ] |
716 }; | 715 }; |
717 this.nativeLayer_.dispatchEvent(capsSetEvent); | 716 this.nativeLayer_.dispatchEvent(capsSetEvent); |
718 | 717 |
719 checkSectionVisible($('color-settings'), true); | 718 checkSectionVisible($('color-settings'), true); |
720 expectFalse($('color-settings').querySelector('.color-option').checked); | 719 expectFalse($('color-settings').querySelector('.color-option').checked); |
721 expectTrue($('color-settings').querySelector('.bw-option').checked); | 720 expectTrue($('color-settings').querySelector('.bw-option').checked); |
722 }); | 721 }); |
723 | 722 |
724 // Test that the color settings, two options, both custom, defaults to color. | 723 // Test that the color settings, two options, both custom, defaults to color. |
725 TEST_F('PrintPreviewWebUITest', | 724 TEST_F('PrintPreviewWebUITest', |
726 'TestColorSettingsBothCustomDefaultColor', function() { | 725 'TestColorSettingsBothCustomDefaultColor', function() { |
727 this.setUpPreview(); | 726 this.setUpPreview(); |
728 | 727 |
729 var capsSetEvent = | 728 var capsSetEvent = |
730 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 729 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
731 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 730 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
732 capsSetEvent.settingsInfo.capabilities.printer.color = { | 731 capsSetEvent.settingsInfo.capabilities.printer.color = { |
733 "option": [ | 732 "option": [ |
734 {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"}, | 733 {"type": "CUSTOM_MONOCHROME", "vendor_id": "42"}, |
735 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"} | 734 {"is_default": true, "type": "CUSTOM_COLOR", "vendor_id": "43"} |
736 ] | 735 ] |
737 }; | 736 }; |
738 this.nativeLayer_.dispatchEvent(capsSetEvent); | 737 this.nativeLayer_.dispatchEvent(capsSetEvent); |
739 | 738 |
740 checkSectionVisible($('color-settings'), true); | 739 checkSectionVisible($('color-settings'), true); |
741 expectTrue($('color-settings').querySelector('.color-option').checked); | 740 expectTrue($('color-settings').querySelector('.color-option').checked); |
742 expectFalse($('color-settings').querySelector('.bw-option').checked); | 741 expectFalse($('color-settings').querySelector('.bw-option').checked); |
743 }); | 742 }); |
744 | 743 |
745 // Test to verify that duplex settings are set according to the printer | 744 // Test to verify that duplex settings are set according to the printer |
746 // capabilities. | 745 // capabilities. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 expectEquals(true, previewFailedMessageEl.hidden); | 851 expectEquals(true, previewFailedMessageEl.hidden); |
853 | 852 |
854 var printFailedMessageEl = | 853 var printFailedMessageEl = |
855 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; | 854 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; |
856 expectEquals(true, printFailedMessageEl.hidden); | 855 expectEquals(true, printFailedMessageEl.hidden); |
857 | 856 |
858 var customMessageEl = | 857 var customMessageEl = |
859 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; | 858 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; |
860 expectEquals(false, customMessageEl.hidden); | 859 expectEquals(false, customMessageEl.hidden); |
861 }); | 860 }); |
OLD | NEW |