OLD | NEW |
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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 }); | 686 }); |
687 }); | 687 }); |
688 | 688 |
689 // When the number of copies print preset is set for source 'PDF', we update | 689 // When the number of copies print preset is set for source 'PDF', we update |
690 // the copies value if capability is supported by printer. | 690 // the copies value if capability is supported by printer. |
691 test('CheckNumCopiesPrintPreset', function() { | 691 test('CheckNumCopiesPrintPreset', function() { |
692 initialSettings.isDocumentModifiable_ = false; | 692 initialSettings.isDocumentModifiable_ = false; |
693 return setupSettingsAndDestinationsWithCapabilities().then(function() { | 693 return setupSettingsAndDestinationsWithCapabilities().then(function() { |
694 // Indicate that the number of copies print preset is set for source | 694 // Indicate that the number of copies print preset is set for source |
695 // PDF. | 695 // PDF. |
696 var printPresetOptions = { | 696 var copies = 2; |
697 disableScaling: true, | 697 cr.webUIListenerCallback('print-preset-options', true, copies); |
698 copies: 2 | |
699 }; | |
700 var printPresetOptionsEvent = new Event( | |
701 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); | |
702 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; | |
703 nativeLayer.getEventTarget(). | |
704 dispatchEvent(printPresetOptionsEvent); | |
705 | |
706 checkSectionVisible($('copies-settings'), true); | 698 checkSectionVisible($('copies-settings'), true); |
707 expectEquals( | 699 expectEquals( |
708 printPresetOptions.copies, | 700 copies, |
709 parseInt($('copies-settings'). | 701 parseInt($('copies-settings').querySelector('.user-value').value)); |
710 querySelector('.user-value').value)); | |
711 | 702 |
712 return whenAnimationDone('other-options-collapsible'); | 703 return whenAnimationDone('other-options-collapsible'); |
713 }); | 704 }); |
714 }); | 705 }); |
715 | 706 |
716 // When the duplex print preset is set for source 'PDF', we update the | 707 // When the duplex print preset is set for source 'PDF', we update the |
717 // duplex setting if capability is supported by printer. | 708 // duplex setting if capability is supported by printer. |
718 test('CheckDuplexPrintPreset', function() { | 709 test('CheckDuplexPrintPreset', function() { |
719 initialSettings.isDocumentModifiable_ = false; | 710 initialSettings.isDocumentModifiable_ = false; |
720 return setupSettingsAndDestinationsWithCapabilities().then(function() { | 711 return setupSettingsAndDestinationsWithCapabilities().then(function() { |
721 // Indicate that the duplex print preset is set to 'long edge' for | 712 // Indicate that the duplex print preset is set to 'long edge' for |
722 // source PDF. | 713 // source PDF. |
723 var printPresetOptions = { | 714 cr.webUIListenerCallback('print-preset-options', false, 1, 1); |
724 duplex: 1 | |
725 }; | |
726 var printPresetOptionsEvent = new Event( | |
727 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); | |
728 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; | |
729 nativeLayer.getEventTarget(). | |
730 dispatchEvent(printPresetOptionsEvent); | |
731 | |
732 var otherOptions = $('other-options-settings'); | 715 var otherOptions = $('other-options-settings'); |
733 checkSectionVisible(otherOptions, true); | 716 checkSectionVisible(otherOptions, true); |
734 var duplexContainer = | 717 var duplexContainer = |
735 otherOptions.querySelector('#duplex-container'); | 718 otherOptions.querySelector('#duplex-container'); |
736 checkElementDisplayed(duplexContainer, true); | 719 checkElementDisplayed(duplexContainer, true); |
737 expectTrue(duplexContainer.querySelector('.checkbox').checked); | 720 expectTrue(duplexContainer.querySelector('.checkbox').checked); |
738 | 721 |
739 return whenAnimationDone('other-options-collapsible'); | 722 return whenAnimationDone('other-options-collapsible'); |
740 }); | 723 }); |
741 }); | 724 }); |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 return setupSettingsAndDestinationsWithCapabilities().then(function() { | 1400 return setupSettingsAndDestinationsWithCapabilities().then(function() { |
1418 // The system default destination should be used instead of the | 1401 // The system default destination should be used instead of the |
1419 // most recent destination. | 1402 // most recent destination. |
1420 assertEquals( | 1403 assertEquals( |
1421 'FooDevice', | 1404 'FooDevice', |
1422 printPreview.destinationStore_.selectedDestination.id); | 1405 printPreview.destinationStore_.selectedDestination.id); |
1423 }); | 1406 }); |
1424 }); | 1407 }); |
1425 }); | 1408 }); |
1426 }); | 1409 }); |
OLD | NEW |