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

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

Issue 2616783002: Remove Print As Image for Mac and Win (Closed)
Patch Set: Fix conditions Created 3 years, 11 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 (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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 /** 60 /**
61 * @override 61 * @override
62 */ 62 */
63 testGenPreamble: function() { 63 testGenPreamble: function() {
64 // Enable print scaling and print as image for tests. 64 // Enable print scaling and print as image for tests.
65 GEN(' base::FeatureList::ClearInstanceForTesting();'); 65 GEN(' base::FeatureList::ClearInstanceForTesting();');
66 GEN(' std::unique_ptr<base::FeatureList>'); 66 GEN(' std::unique_ptr<base::FeatureList>');
67 GEN(' feature_list(new base::FeatureList);'); 67 GEN(' feature_list(new base::FeatureList);');
68 GEN(' char enabled_features[128] = {0};'); 68 GEN(' char enabled_features[128] = {0};');
69 GEN(' strcpy(enabled_features, features::kPrintScaling.name);'); 69 GEN(' strcpy(enabled_features, features::kPrintScaling.name);');
70 GEN('#if defined(OS_CHROMEOS) || defined(OS_LINUX)');
dpapad 2017/01/06 17:09:40 This needs to be changed too, right?
rbpotter 2017/01/06 19:32:34 Done.
70 GEN(' strcat(strcat(enabled_features, ","), '); 71 GEN(' strcat(strcat(enabled_features, ","), ');
71 GEN(' features::kPrintPdfAsImage.name);'); 72 GEN(' features::kPrintPdfAsImage.name);');
73 GEN('#endif');
72 GEN(' feature_list->InitializeFromCommandLine('); 74 GEN(' feature_list->InitializeFromCommandLine(');
73 GEN(' enabled_features, std::string());'); 75 GEN(' enabled_features, std::string());');
74 GEN(' base::FeatureList::SetInstance(std::move(feature_list));'); 76 GEN(' base::FeatureList::SetInstance(std::move(feature_list));');
75 }, 77 },
76 78
77 /** 79 /**
78 * Stub out low-level functionality like the NativeLayer and 80 * Stub out low-level functionality like the NativeLayer and
79 * CloudPrintInterface. 81 * CloudPrintInterface.
80 * @this {PrintPreviewWebUITest} 82 * @this {PrintPreviewWebUITest}
81 * @override 83 * @override
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 is_default: true 518 is_default: true
517 } 519 }
518 ] 520 ]
519 } 521 }
520 } 522 }
521 } 523 }
522 }; 524 };
523 this.setCapabilities(device); 525 this.setCapabilities(device);
524 526
525 var otherOptions = $('other-options-settings'); 527 var otherOptions = $('other-options-settings');
526 checkSectionVisible(otherOptions, true); 528 // If rasterization is an option, other options should be visible. If not,
527 checkElementDisplayed( 529 // there should be no available other options.
528 otherOptions.querySelector('#fit-to-page-container'), false); 530 checkSectionVisible(otherOptions, !cr.isWindows && !cr.isMac);
529 checkElementDisplayed( 531 if (!cr.isWindows && !cr.isMac) {
530 otherOptions.querySelector('#rasterize-container'), true); 532 checkElementDisplayed(
533 otherOptions.querySelector('#fit-to-page-container'), false);
534 checkElementDisplayed(
535 otherOptions.querySelector('#rasterize-container'), true);
536 }
531 checkSectionVisible($('media-size-settings'), false); 537 checkSectionVisible($('media-size-settings'), false);
532 checkSectionVisible($('scaling-settings'), false); 538 checkSectionVisible($('scaling-settings'), false);
533 539
534 testDone(); 540 testDone();
535 }); 541 });
536 542
537 // When the source is 'HTML', we always hide the fit to page option and show 543 // When the source is 'HTML', we always hide the fit to page option and show
538 // media size option. 544 // media size option.
539 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { 545 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() {
540 this.setInitialSettings(); 546 this.setInitialSettings();
541 this.setLocalDestinations(); 547 this.setLocalDestinations();
542 this.setCapabilities(getCddTemplate("FooDevice")); 548 this.setCapabilities(getCddTemplate("FooDevice"));
543 549
544 var otherOptions = $('other-options-settings'); 550 var otherOptions = $('other-options-settings');
545 var fitToPage = otherOptions.querySelector('#fit-to-page-container'); 551 var fitToPage = otherOptions.querySelector('#fit-to-page-container');
546 var rasterize = otherOptions.querySelector('#rasterize-container'); 552 var rasterize;
553 var rasterizeEnabled = !cr.isWindows && !cr.isMac;
dpapad 2017/01/06 17:09:40 Can this be moved in the constructor of PrintPrevi
rbpotter 2017/01/06 19:32:34 cr is not defined at that point.
554 if (rasterizeEnabled)
555 rasterize = otherOptions.querySelector('#rasterize-container');
547 var mediaSize = $('media-size-settings'); 556 var mediaSize = $('media-size-settings');
548 var scalingSettings = $('scaling-settings'); 557 var scalingSettings = $('scaling-settings');
549 558
550 // Check that options are collapsed (section is visible, because duplex is 559 // Check that options are collapsed (section is visible, because duplex is
551 // available). 560 // available).
552 checkSectionVisible(otherOptions, true); 561 checkSectionVisible(otherOptions, true);
553 checkElementDisplayed(fitToPage, false); 562 checkElementDisplayed(fitToPage, false);
554 checkElementDisplayed(rasterize, false); 563 if (rasterizeEnabled)
564 checkElementDisplayed(rasterize, false);
555 checkSectionVisible(mediaSize, false); 565 checkSectionVisible(mediaSize, false);
556 checkSectionVisible(scalingSettings, false); 566 checkSectionVisible(scalingSettings, false);
557 567
558 this.expandMoreSettings(); 568 this.expandMoreSettings();
559 569
560 checkElementDisplayed(fitToPage, false); 570 checkElementDisplayed(fitToPage, false);
561 checkElementDisplayed(rasterize, false); 571 if (rasterizeEnabled)
572 checkElementDisplayed(rasterize, false);
562 checkSectionVisible(mediaSize, true); 573 checkSectionVisible(mediaSize, true);
563 checkSectionVisible(scalingSettings, true); 574 checkSectionVisible(scalingSettings, true);
564 575
565 this.waitForAnimationToEnd('more-settings'); 576 this.waitForAnimationToEnd('more-settings');
566 }); 577 });
567 578
568 // When the source is "PDF", depending on the selected destination printer, we 579 // When the source is "PDF", depending on the selected destination printer, we
569 // show/hide the fit to page option and hide media size selection. 580 // show/hide the fit to page option and hide media size selection.
570 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { 581 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() {
571 this.initialSettings_.isDocumentModifiable_ = false; 582 this.initialSettings_.isDocumentModifiable_ = false;
572 this.setInitialSettings(); 583 this.setInitialSettings();
573 this.setLocalDestinations(); 584 this.setLocalDestinations();
574 this.setCapabilities(getCddTemplate("FooDevice")); 585 this.setCapabilities(getCddTemplate("FooDevice"));
575 586
576 var otherOptions = $('other-options-settings'); 587 var otherOptions = $('other-options-settings');
577 var scalingSettings = $('scaling-settings'); 588 var scalingSettings = $('scaling-settings');
578 var fitToPageContainer = 589 var fitToPageContainer =
579 otherOptions.querySelector('#fit-to-page-container'); 590 otherOptions.querySelector('#fit-to-page-container');
580 var rasterizeContainer = 591 var rasterizeEnabled = !cr.isWindows && !cr.isMac;
592 var rasterizeContainer;
593 if (rasterizeEnabled) {
594 rasterizeContainer =
581 otherOptions.querySelector('#rasterize-container'); 595 otherOptions.querySelector('#rasterize-container');
596 }
582 597
583 checkSectionVisible(otherOptions, true); 598 checkSectionVisible(otherOptions, true);
584 checkElementDisplayed(fitToPageContainer, true); 599 checkElementDisplayed(fitToPageContainer, true);
585 checkElementDisplayed(rasterizeContainer, false); 600 if (rasterizeEnabled)
601 checkElementDisplayed(rasterizeContainer, false);
586 expectTrue( 602 expectTrue(
587 fitToPageContainer.querySelector('.checkbox').checked); 603 fitToPageContainer.querySelector('.checkbox').checked);
588 this.expandMoreSettings(); 604 this.expandMoreSettings();
589 checkElementDisplayed(rasterizeContainer, true); 605 if (rasterizeEnabled) {
590 expectFalse( 606 checkElementDisplayed(rasterizeContainer, true);
591 rasterizeContainer.querySelector('.checkbox').checked); 607 expectFalse(
608 rasterizeContainer.querySelector('.checkbox').checked);
609 }
592 checkSectionVisible($('media-size-settings'), true); 610 checkSectionVisible($('media-size-settings'), true);
593 checkSectionVisible(scalingSettings, true); 611 checkSectionVisible(scalingSettings, true);
594 612
595 this.waitForAnimationToEnd('other-options-collapsible'); 613 this.waitForAnimationToEnd('other-options-collapsible');
596 }); 614 });
597 615
598 // When the source is "PDF", depending on the selected destination printer, we 616 // When the source is "PDF", depending on the selected destination printer, we
599 // show/hide the fit to page option and hide media size selection. 617 // show/hide the fit to page option and hide media size selection.
600 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { 618 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() {
601 this.initialSettings_.isDocumentModifiable_ = false; 619 this.initialSettings_.isDocumentModifiable_ = false;
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 // appears. 1246 // appears.
1229 var advancedSettingsCloseButton = $('advanced-settings'). 1247 var advancedSettingsCloseButton = $('advanced-settings').
1230 querySelector('.close-button'); 1248 querySelector('.close-button');
1231 checkElementDisplayed(advancedSettingsCloseButton, true); 1249 checkElementDisplayed(advancedSettingsCloseButton, true);
1232 checkElementDisplayed($('advanced-settings'). 1250 checkElementDisplayed($('advanced-settings').
1233 querySelector('.search-box-area'), true); 1251 querySelector('.search-box-area'), true);
1234 1252
1235 this.waitForAnimationToEnd('more-settings'); 1253 this.waitForAnimationToEnd('more-settings');
1236 }); 1254 });
1237 1255
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698