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 GEN('#include "base/feature_list.h"'); | 5 GEN('#include "base/feature_list.h"'); |
6 GEN('#include "chrome/common/chrome_features.h"'); | 6 GEN('#include "chrome/common/chrome_features.h"'); |
7 | 7 |
8 /** | 8 /** |
9 * Test fixture for print preview WebUI testing. | 9 * Test fixture for print preview WebUI testing. |
10 * @constructor | 10 * @constructor |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 height_microns: 0, | 511 height_microns: 0, |
512 is_default: true | 512 is_default: true |
513 } | 513 } |
514 ] | 514 ] |
515 } | 515 } |
516 } | 516 } |
517 } | 517 } |
518 }; | 518 }; |
519 this.setCapabilities(device); | 519 this.setCapabilities(device); |
520 | 520 |
521 checkSectionVisible($('other-options-settings'), false); | 521 var otherOptions = $('other-options-settings'); |
| 522 checkSectionVisible(otherOptions, true); |
| 523 checkElementDisplayed( |
| 524 otherOptions.querySelector('.fit-to-page-container'), false); |
| 525 checkElementDisplayed( |
| 526 otherOptions.querySelector('.rasterize-container'), true); |
522 checkSectionVisible($('media-size-settings'), false); | 527 checkSectionVisible($('media-size-settings'), false); |
523 checkSectionVisible($('scaling-settings'), false); | 528 checkSectionVisible($('scaling-settings'), false); |
524 | 529 |
525 testDone(); | 530 testDone(); |
526 }); | 531 }); |
527 | 532 |
528 // When the source is 'HTML', we always hide the fit to page option and show | 533 // When the source is 'HTML', we always hide the fit to page option and show |
529 // media size option. | 534 // media size option. |
530 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { | 535 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { |
531 this.setInitialSettings(); | 536 this.setInitialSettings(); |
532 this.setLocalDestinations(); | 537 this.setLocalDestinations(); |
533 this.setCapabilities(getCddTemplate("FooDevice")); | 538 this.setCapabilities(getCddTemplate("FooDevice")); |
534 | 539 |
535 var otherOptions = $('other-options-settings'); | 540 var otherOptions = $('other-options-settings'); |
536 var fitToPage = otherOptions.querySelector('.fit-to-page-container'); | 541 var fitToPage = otherOptions.querySelector('.fit-to-page-container'); |
| 542 var rasterize = otherOptions.querySelector('.rasterize-container'); |
537 var mediaSize = $('media-size-settings'); | 543 var mediaSize = $('media-size-settings'); |
538 var scalingSettings = $('scaling-settings'); | 544 var scalingSettings = $('scaling-settings'); |
539 | 545 |
540 // Check that options are collapsed (section is visible, because duplex is | 546 // Check that options are collapsed (section is visible, because duplex is |
541 // available). | 547 // available). |
542 checkSectionVisible(otherOptions, true); | 548 checkSectionVisible(otherOptions, true); |
543 checkElementDisplayed(fitToPage, false); | 549 checkElementDisplayed(fitToPage, false); |
| 550 checkElementDisplayed(rasterize, false); |
544 checkSectionVisible(mediaSize, false); | 551 checkSectionVisible(mediaSize, false); |
545 checkSectionVisible(scalingSettings, false); | 552 checkSectionVisible(scalingSettings, false); |
546 | 553 |
547 this.expandMoreSettings(); | 554 this.expandMoreSettings(); |
548 | 555 |
549 checkElementDisplayed(fitToPage, false); | 556 checkElementDisplayed(fitToPage, false); |
| 557 checkElementDisplayed(rasterize, false); |
550 checkSectionVisible(mediaSize, true); | 558 checkSectionVisible(mediaSize, true); |
551 checkSectionVisible(scalingSettings, true); | 559 checkSectionVisible(scalingSettings, true); |
552 | 560 |
553 this.waitForAnimationToEnd('more-settings'); | 561 this.waitForAnimationToEnd('more-settings'); |
554 }); | 562 }); |
555 | 563 |
556 // When the source is "PDF", depending on the selected destination printer, we | 564 // When the source is "PDF", depending on the selected destination printer, we |
557 // show/hide the fit to page option and hide media size selection. | 565 // show/hide the fit to page option and hide media size selection. |
558 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { | 566 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { |
559 this.initialSettings_.isDocumentModifiable_ = false; | 567 this.initialSettings_.isDocumentModifiable_ = false; |
560 this.setInitialSettings(); | 568 this.setInitialSettings(); |
561 this.setLocalDestinations(); | 569 this.setLocalDestinations(); |
562 this.setCapabilities(getCddTemplate("FooDevice")); | 570 this.setCapabilities(getCddTemplate("FooDevice")); |
563 | 571 |
564 var otherOptions = $('other-options-settings'); | 572 var otherOptions = $('other-options-settings'); |
565 var scalingSettings = $('scaling-settings'); | 573 var scalingSettings = $('scaling-settings'); |
| 574 var fitToPageContainer = |
| 575 otherOptions.querySelector('.fit-to-page-container'); |
| 576 var rasterizeContainer = |
| 577 otherOptions.querySelector('.rasterize-container'); |
566 | 578 |
567 checkSectionVisible(otherOptions, true); | 579 checkSectionVisible(otherOptions, true); |
568 checkElementDisplayed( | 580 checkElementDisplayed(fitToPageContainer, true); |
569 otherOptions.querySelector('.fit-to-page-container'), true); | 581 checkElementDisplayed(rasterizeContainer, false); |
570 expectTrue( | 582 expectTrue( |
571 otherOptions.querySelector('.fit-to-page-checkbox').checked); | 583 fitToPageContainer.querySelector('.checkbox').checked); |
572 this.expandMoreSettings(); | 584 this.expandMoreSettings(); |
| 585 checkElementDisplayed(rasterizeContainer, true); |
| 586 expectFalse( |
| 587 rasterizeContainer.querySelector('.checkbox').checked); |
573 checkSectionVisible($('media-size-settings'), true); | 588 checkSectionVisible($('media-size-settings'), true); |
574 checkSectionVisible(scalingSettings, true); | 589 checkSectionVisible(scalingSettings, true); |
575 | 590 |
576 this.waitForAnimationToEnd('other-options-collapsible'); | 591 this.waitForAnimationToEnd('other-options-collapsible'); |
577 }); | 592 }); |
578 | 593 |
579 // When the source is "PDF", depending on the selected destination printer, we | 594 // When the source is "PDF", depending on the selected destination printer, we |
580 // show/hide the fit to page option and hide media size selection. | 595 // show/hide the fit to page option and hide media size selection. |
581 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { | 596 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { |
582 this.initialSettings_.isDocumentModifiable_ = false; | 597 this.initialSettings_.isDocumentModifiable_ = false; |
583 this.setInitialSettings(); | 598 this.setInitialSettings(); |
584 this.setLocalDestinations(); | 599 this.setLocalDestinations(); |
585 this.setCapabilities(getCddTemplate("FooDevice")); | 600 this.setCapabilities(getCddTemplate("FooDevice")); |
586 | 601 |
587 var otherOptions = $('other-options-settings'); | 602 var otherOptions = $('other-options-settings'); |
588 var scalingSettings = $('scaling-settings'); | 603 var scalingSettings = $('scaling-settings'); |
589 | 604 |
590 checkSectionVisible(otherOptions, true); | 605 checkSectionVisible(otherOptions, true); |
591 checkElementDisplayed( | 606 var fitToPageContainer = |
592 otherOptions.querySelector('.fit-to-page-container'), true); | 607 otherOptions.querySelector('.fit-to-page-container'); |
| 608 checkElementDisplayed(fitToPageContainer, true); |
593 expectTrue( | 609 expectTrue( |
594 otherOptions.querySelector('.fit-to-page-checkbox').checked); | 610 fitToPageContainer.querySelector('.checkbox').checked); |
595 this.expandMoreSettings(); | 611 this.expandMoreSettings(); |
596 checkSectionVisible($('media-size-settings'), true); | 612 checkSectionVisible($('media-size-settings'), true); |
597 checkSectionVisible(scalingSettings, true); | 613 checkSectionVisible(scalingSettings, true); |
598 | 614 |
599 //Change scaling input | 615 //Change scaling input |
600 var scalingInput = scalingSettings.querySelector('.user-value'); | 616 var scalingInput = scalingSettings.querySelector('.user-value'); |
601 expectEquals(scalingInput.value, '100'); | 617 expectEquals(scalingInput.value, '100'); |
602 scalingInput.stepUp(5); | 618 scalingInput.stepUp(5); |
603 expectEquals(scalingInput.value, '105'); | 619 expectEquals(scalingInput.value, '105'); |
604 | 620 |
605 // Trigger the event | 621 // Trigger the event |
606 var enter = document.createEvent('Event'); | 622 var enter = document.createEvent('Event'); |
607 enter.initEvent('keydown'); | 623 enter.initEvent('keydown'); |
608 enter.keyCode = 'Enter'; | 624 enter.keyCode = 'Enter'; |
609 scalingInput.dispatchEvent(enter); | 625 scalingInput.dispatchEvent(enter); |
610 expectFalse( | 626 expectFalse( |
611 otherOptions.querySelector('.fit-to-page-checkbox').checked); | 627 fitToPageContainer.querySelector('.checkbox').checked); |
612 | 628 |
613 this.waitForAnimationToEnd('other-options-collapsible'); | 629 this.waitForAnimationToEnd('other-options-collapsible'); |
614 }); | 630 }); |
615 | 631 |
616 // When the number of copies print preset is set for source 'PDF', we update | 632 // When the number of copies print preset is set for source 'PDF', we update |
617 // the copies value if capability is supported by printer. | 633 // the copies value if capability is supported by printer. |
618 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() { | 634 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() { |
619 this.initialSettings_.isDocumentModifiable_ = false; | 635 this.initialSettings_.isDocumentModifiable_ = false; |
620 this.setInitialSettings(); | 636 this.setInitialSettings(); |
621 this.setLocalDestinations(); | 637 this.setLocalDestinations(); |
(...skipping 29 matching lines...) Expand all Loading... |
651 var printPresetOptions = { | 667 var printPresetOptions = { |
652 duplex: 1 | 668 duplex: 1 |
653 }; | 669 }; |
654 var printPresetOptionsEvent = new Event( | 670 var printPresetOptionsEvent = new Event( |
655 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); | 671 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
656 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; | 672 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; |
657 this.nativeLayer_.dispatchEvent(printPresetOptionsEvent); | 673 this.nativeLayer_.dispatchEvent(printPresetOptionsEvent); |
658 | 674 |
659 var otherOptions = $('other-options-settings'); | 675 var otherOptions = $('other-options-settings'); |
660 checkSectionVisible(otherOptions, true); | 676 checkSectionVisible(otherOptions, true); |
661 checkElementDisplayed(otherOptions.querySelector('.duplex-container'), true); | 677 var duplexContainer = otherOptions.querySelector('.duplex-container'); |
662 expectTrue(otherOptions.querySelector('.duplex-checkbox').checked); | 678 checkElementDisplayed(duplexContainer, true); |
| 679 expectTrue(duplexContainer.querySelector('.checkbox').checked); |
663 | 680 |
664 this.waitForAnimationToEnd('other-options-collapsible'); | 681 this.waitForAnimationToEnd('other-options-collapsible'); |
665 }); | 682 }); |
666 | 683 |
667 // Make sure that custom margins controls are properly set up. | 684 // Make sure that custom margins controls are properly set up. |
668 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { | 685 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { |
669 this.setInitialSettings(); | 686 this.setInitialSettings(); |
670 this.setLocalDestinations(); | 687 this.setLocalDestinations(); |
671 this.setCapabilities(getCddTemplate("FooDevice")); | 688 this.setCapabilities(getCddTemplate("FooDevice")); |
672 | 689 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 | 965 |
949 // Test to verify that duplex settings are set according to the printer | 966 // Test to verify that duplex settings are set according to the printer |
950 // capabilities. | 967 // capabilities. |
951 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { | 968 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { |
952 this.setInitialSettings(); | 969 this.setInitialSettings(); |
953 this.setLocalDestinations(); | 970 this.setLocalDestinations(); |
954 this.setCapabilities(getCddTemplate("FooDevice")); | 971 this.setCapabilities(getCddTemplate("FooDevice")); |
955 | 972 |
956 var otherOptions = $('other-options-settings'); | 973 var otherOptions = $('other-options-settings'); |
957 checkSectionVisible(otherOptions, true); | 974 checkSectionVisible(otherOptions, true); |
958 expectFalse(otherOptions.querySelector('.duplex-container').hidden); | 975 duplexContainer = otherOptions.querySelector('.duplex-container'); |
959 expectFalse(otherOptions.querySelector('.duplex-checkbox').checked); | 976 expectFalse(duplexContainer.hidden); |
| 977 expectFalse(duplexContainer.querySelector('.checkbox').checked); |
960 | 978 |
961 this.waitForAnimationToEnd('more-settings'); | 979 this.waitForAnimationToEnd('more-settings'); |
962 }); | 980 }); |
963 | 981 |
964 // Test to verify that duplex settings are set according to the printer | 982 // Test to verify that duplex settings are set according to the printer |
965 // capabilities. | 983 // capabilities. |
966 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { | 984 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { |
967 this.setInitialSettings(); | 985 this.setInitialSettings(); |
968 this.setLocalDestinations(); | 986 this.setLocalDestinations(); |
969 var device = getCddTemplate("FooDevice"); | 987 var device = getCddTemplate("FooDevice"); |
(...skipping 15 matching lines...) Expand all Loading... |
985 | 1003 |
986 // Test that changing the selected printer updates the preview. | 1004 // Test that changing the selected printer updates the preview. |
987 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { | 1005 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { |
988 this.setInitialSettings(); | 1006 this.setInitialSettings(); |
989 this.setLocalDestinations(); | 1007 this.setLocalDestinations(); |
990 this.setCapabilities(getCddTemplate("FooDevice")); | 1008 this.setCapabilities(getCddTemplate("FooDevice")); |
991 | 1009 |
992 var previewGenerator = mock(print_preview.PreviewGenerator); | 1010 var previewGenerator = mock(print_preview.PreviewGenerator); |
993 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); | 1011 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); |
994 | 1012 |
995 // TODO (rbpotter): Figure out why this is 7 with the addition of scaling, | 1013 // The number of settings that can change due to a change in the destination |
996 // and if it is a problem. | 1014 // that will therefore dispatch ticket item change events. |
997 previewGenerator.expects(exactly(7)).requestPreview(); | 1015 previewGenerator.expects(exactly(7)).requestPreview(); |
998 | 1016 |
999 var barDestination; | 1017 var barDestination; |
1000 var destinations = printPreview.destinationStore_.destinations(); | 1018 var destinations = printPreview.destinationStore_.destinations(); |
1001 for (var destination, i = 0; destination = destinations[i]; i++) { | 1019 for (var destination, i = 0; destination = destinations[i]; i++) { |
1002 if (destination.id == 'BarDevice') { | 1020 if (destination.id == 'BarDevice') { |
1003 barDestination = destination; | 1021 barDestination = destination; |
1004 break; | 1022 break; |
1005 } | 1023 } |
1006 } | 1024 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 // appears. | 1224 // appears. |
1207 var advancedSettingsCloseButton = $('advanced-settings'). | 1225 var advancedSettingsCloseButton = $('advanced-settings'). |
1208 querySelector('.close-button'); | 1226 querySelector('.close-button'); |
1209 checkElementDisplayed(advancedSettingsCloseButton, true); | 1227 checkElementDisplayed(advancedSettingsCloseButton, true); |
1210 checkElementDisplayed($('advanced-settings'). | 1228 checkElementDisplayed($('advanced-settings'). |
1211 querySelector('.search-box-area'), true); | 1229 querySelector('.search-box-area'), true); |
1212 | 1230 |
1213 this.waitForAnimationToEnd('more-settings'); | 1231 this.waitForAnimationToEnd('more-settings'); |
1214 }); | 1232 }); |
1215 | 1233 |
OLD | NEW |