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

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

Issue 2576233003: Print Preview: Simplify other_options_settings javascript code. (Closed)
Patch Set: Fix tests Created 4 years 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 (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
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, false);
522 checkSectionVisible($('media-size-settings'), false); 523 checkSectionVisible($('media-size-settings'), false);
523 checkSectionVisible($('scaling-settings'), false); 524 checkSectionVisible($('scaling-settings'), false);
524 525
525 testDone(); 526 testDone();
526 }); 527 });
527 528
528 // When the source is 'HTML', we always hide the fit to page option and show 529 // When the source is 'HTML', we always hide the fit to page option and show
529 // media size option. 530 // media size option.
530 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { 531 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() {
531 this.setInitialSettings(); 532 this.setInitialSettings();
(...skipping 24 matching lines...) Expand all
556 // When the source is "PDF", depending on the selected destination printer, we 557 // 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. 558 // show/hide the fit to page option and hide media size selection.
558 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { 559 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() {
559 this.initialSettings_.isDocumentModifiable_ = false; 560 this.initialSettings_.isDocumentModifiable_ = false;
560 this.setInitialSettings(); 561 this.setInitialSettings();
561 this.setLocalDestinations(); 562 this.setLocalDestinations();
562 this.setCapabilities(getCddTemplate("FooDevice")); 563 this.setCapabilities(getCddTemplate("FooDevice"));
563 564
564 var otherOptions = $('other-options-settings'); 565 var otherOptions = $('other-options-settings');
565 var scalingSettings = $('scaling-settings'); 566 var scalingSettings = $('scaling-settings');
567 var fitToPageContainer =
568 otherOptions.querySelector('.fit-to-page-container');
566 569
567 checkSectionVisible(otherOptions, true); 570 checkSectionVisible(otherOptions, true);
568 checkElementDisplayed( 571 checkElementDisplayed(fitToPageContainer, true);
569 otherOptions.querySelector('.fit-to-page-container'), true);
570 expectTrue( 572 expectTrue(
571 otherOptions.querySelector('.fit-to-page-checkbox').checked); 573 fitToPageContainer.querySelector('.checkbox').checked);
572 this.expandMoreSettings(); 574 this.expandMoreSettings();
573 checkSectionVisible($('media-size-settings'), true); 575 checkSectionVisible($('media-size-settings'), true);
574 checkSectionVisible(scalingSettings, true); 576 checkSectionVisible(scalingSettings, true);
575 577
576 this.waitForAnimationToEnd('other-options-collapsible'); 578 this.waitForAnimationToEnd('other-options-collapsible');
577 }); 579 });
578 580
579 // When the source is "PDF", depending on the selected destination printer, we 581 // 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. 582 // show/hide the fit to page option and hide media size selection.
581 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { 583 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() {
582 this.initialSettings_.isDocumentModifiable_ = false; 584 this.initialSettings_.isDocumentModifiable_ = false;
583 this.setInitialSettings(); 585 this.setInitialSettings();
584 this.setLocalDestinations(); 586 this.setLocalDestinations();
585 this.setCapabilities(getCddTemplate("FooDevice")); 587 this.setCapabilities(getCddTemplate("FooDevice"));
586 588
587 var otherOptions = $('other-options-settings'); 589 var otherOptions = $('other-options-settings');
588 var scalingSettings = $('scaling-settings'); 590 var scalingSettings = $('scaling-settings');
589 591
590 checkSectionVisible(otherOptions, true); 592 checkSectionVisible(otherOptions, true);
591 checkElementDisplayed( 593 var fitToPageContainer =
592 otherOptions.querySelector('.fit-to-page-container'), true); 594 otherOptions.querySelector('.fit-to-page-container');
595 checkElementDisplayed(fitToPageContainer, true);
593 expectTrue( 596 expectTrue(
594 otherOptions.querySelector('.fit-to-page-checkbox').checked); 597 fitToPageContainer.querySelector('.checkbox').checked);
595 this.expandMoreSettings(); 598 this.expandMoreSettings();
596 checkSectionVisible($('media-size-settings'), true); 599 checkSectionVisible($('media-size-settings'), true);
597 checkSectionVisible(scalingSettings, true); 600 checkSectionVisible(scalingSettings, true);
598 601
599 //Change scaling input 602 //Change scaling input
600 var scalingInput = scalingSettings.querySelector('.user-value'); 603 var scalingInput = scalingSettings.querySelector('.user-value');
601 expectEquals(scalingInput.value, '100'); 604 expectEquals(scalingInput.value, '100');
602 scalingInput.stepUp(5); 605 scalingInput.stepUp(5);
603 expectEquals(scalingInput.value, '105'); 606 expectEquals(scalingInput.value, '105');
604 607
605 // Trigger the event 608 // Trigger the event
606 var enter = document.createEvent('Event'); 609 var enter = document.createEvent('Event');
607 enter.initEvent('keydown'); 610 enter.initEvent('keydown');
608 enter.keyCode = 'Enter'; 611 enter.keyCode = 'Enter';
609 scalingInput.dispatchEvent(enter); 612 scalingInput.dispatchEvent(enter);
610 expectFalse( 613 expectFalse(
611 otherOptions.querySelector('.fit-to-page-checkbox').checked); 614 fitToPageContainer.querySelector('.checkbox').checked);
612 615
613 this.waitForAnimationToEnd('other-options-collapsible'); 616 this.waitForAnimationToEnd('other-options-collapsible');
614 }); 617 });
615 618
616 // When the number of copies print preset is set for source 'PDF', we update 619 // When the number of copies print preset is set for source 'PDF', we update
617 // the copies value if capability is supported by printer. 620 // the copies value if capability is supported by printer.
618 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() { 621 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() {
619 this.initialSettings_.isDocumentModifiable_ = false; 622 this.initialSettings_.isDocumentModifiable_ = false;
620 this.setInitialSettings(); 623 this.setInitialSettings();
621 this.setLocalDestinations(); 624 this.setLocalDestinations();
(...skipping 29 matching lines...) Expand all
651 var printPresetOptions = { 654 var printPresetOptions = {
652 duplex: 1 655 duplex: 1
653 }; 656 };
654 var printPresetOptionsEvent = new Event( 657 var printPresetOptionsEvent = new Event(
655 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); 658 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS);
656 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; 659 printPresetOptionsEvent.optionsFromDocument = printPresetOptions;
657 this.nativeLayer_.dispatchEvent(printPresetOptionsEvent); 660 this.nativeLayer_.dispatchEvent(printPresetOptionsEvent);
658 661
659 var otherOptions = $('other-options-settings'); 662 var otherOptions = $('other-options-settings');
660 checkSectionVisible(otherOptions, true); 663 checkSectionVisible(otherOptions, true);
661 checkElementDisplayed(otherOptions.querySelector('.duplex-container'), true); 664 var duplexContainer = otherOptions.querySelector('.duplex-container');
662 expectTrue(otherOptions.querySelector('.duplex-checkbox').checked); 665 checkElementDisplayed(duplexContainer, true);
666 expectTrue(duplexContainer.querySelector('.checkbox').checked);
663 667
664 this.waitForAnimationToEnd('other-options-collapsible'); 668 this.waitForAnimationToEnd('other-options-collapsible');
665 }); 669 });
666 670
667 // Make sure that custom margins controls are properly set up. 671 // Make sure that custom margins controls are properly set up.
668 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { 672 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() {
669 this.setInitialSettings(); 673 this.setInitialSettings();
670 this.setLocalDestinations(); 674 this.setLocalDestinations();
671 this.setCapabilities(getCddTemplate("FooDevice")); 675 this.setCapabilities(getCddTemplate("FooDevice"));
672 676
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 952
949 // Test to verify that duplex settings are set according to the printer 953 // Test to verify that duplex settings are set according to the printer
950 // capabilities. 954 // capabilities.
951 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { 955 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() {
952 this.setInitialSettings(); 956 this.setInitialSettings();
953 this.setLocalDestinations(); 957 this.setLocalDestinations();
954 this.setCapabilities(getCddTemplate("FooDevice")); 958 this.setCapabilities(getCddTemplate("FooDevice"));
955 959
956 var otherOptions = $('other-options-settings'); 960 var otherOptions = $('other-options-settings');
957 checkSectionVisible(otherOptions, true); 961 checkSectionVisible(otherOptions, true);
958 expectFalse(otherOptions.querySelector('.duplex-container').hidden); 962 duplexContainer = otherOptions.querySelector('.duplex-container');
959 expectFalse(otherOptions.querySelector('.duplex-checkbox').checked); 963 expectFalse(duplexContainer.hidden);
964 expectFalse(duplexContainer.querySelector('.checkbox').checked);
960 965
961 this.waitForAnimationToEnd('more-settings'); 966 this.waitForAnimationToEnd('more-settings');
962 }); 967 });
963 968
964 // Test to verify that duplex settings are set according to the printer 969 // Test to verify that duplex settings are set according to the printer
965 // capabilities. 970 // capabilities.
966 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { 971 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() {
967 this.setInitialSettings(); 972 this.setInitialSettings();
968 this.setLocalDestinations(); 973 this.setLocalDestinations();
969 var device = getCddTemplate("FooDevice"); 974 var device = getCddTemplate("FooDevice");
(...skipping 15 matching lines...) Expand all
985 990
986 // Test that changing the selected printer updates the preview. 991 // Test that changing the selected printer updates the preview.
987 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { 992 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() {
988 this.setInitialSettings(); 993 this.setInitialSettings();
989 this.setLocalDestinations(); 994 this.setLocalDestinations();
990 this.setCapabilities(getCddTemplate("FooDevice")); 995 this.setCapabilities(getCddTemplate("FooDevice"));
991 996
992 var previewGenerator = mock(print_preview.PreviewGenerator); 997 var previewGenerator = mock(print_preview.PreviewGenerator);
993 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); 998 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy();
994 999
995 // TODO (rbpotter): Figure out why this is 7 with the addition of scaling, 1000 // The number of settings that can change due to a change in the destination
996 // and if it is a problem. 1001 // that will therefore dispatch ticket item change events.
997 previewGenerator.expects(exactly(7)).requestPreview(); 1002 previewGenerator.expects(exactly(7)).requestPreview();
998 1003
999 var barDestination; 1004 var barDestination;
1000 var destinations = printPreview.destinationStore_.destinations(); 1005 var destinations = printPreview.destinationStore_.destinations();
1001 for (var destination, i = 0; destination = destinations[i]; i++) { 1006 for (var destination, i = 0; destination = destinations[i]; i++) {
1002 if (destination.id == 'BarDevice') { 1007 if (destination.id == 'BarDevice') {
1003 barDestination = destination; 1008 barDestination = destination;
1004 break; 1009 break;
1005 } 1010 }
1006 } 1011 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 // appears. 1211 // appears.
1207 var advancedSettingsCloseButton = $('advanced-settings'). 1212 var advancedSettingsCloseButton = $('advanced-settings').
1208 querySelector('.close-button'); 1213 querySelector('.close-button');
1209 checkElementDisplayed(advancedSettingsCloseButton, true); 1214 checkElementDisplayed(advancedSettingsCloseButton, true);
1210 checkElementDisplayed($('advanced-settings'). 1215 checkElementDisplayed($('advanced-settings').
1211 querySelector('.search-box-area'), true); 1216 querySelector('.search-box-area'), true);
1212 1217
1213 this.waitForAnimationToEnd('more-settings'); 1218 this.waitForAnimationToEnd('more-settings');
1214 }); 1219 });
1215 1220
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698