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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 /** @override */ | 54 /** @override */ |
55 accessibilityIssuesAreErrors: true, | 55 accessibilityIssuesAreErrors: true, |
56 | 56 |
57 /** @override */ | 57 /** @override */ |
58 isAsync: true, | 58 isAsync: true, |
59 | 59 |
60 /** | 60 /** |
61 * @override | 61 * @override |
62 */ | 62 */ |
63 testGenPreamble: function() { | 63 testGenPreamble: function() { |
64 // Enable print scaling 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};'); |
| 69 GEN(' strcpy(enabled_features, features::kPrintScaling.name);'); |
| 70 GEN(' strcat(strcat(enabled_features, ","), '); |
| 71 GEN(' features::kPrintPdfAsImage.name);'); |
68 GEN(' feature_list->InitializeFromCommandLine('); | 72 GEN(' feature_list->InitializeFromCommandLine('); |
69 GEN(' features::kPrintScaling.name, std::string());'); | 73 GEN(' enabled_features, std::string());'); |
70 GEN(' base::FeatureList::SetInstance(std::move(feature_list));'); | 74 GEN(' base::FeatureList::SetInstance(std::move(feature_list));'); |
71 }, | 75 }, |
72 | 76 |
73 /** | 77 /** |
74 * Stub out low-level functionality like the NativeLayer and | 78 * Stub out low-level functionality like the NativeLayer and |
75 * CloudPrintInterface. | 79 * CloudPrintInterface. |
76 * @this {PrintPreviewWebUITest} | 80 * @this {PrintPreviewWebUITest} |
77 * @override | 81 * @override |
78 */ | 82 */ |
79 preLoad: function() { | 83 preLoad: function() { |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 is_default: true | 516 is_default: true |
513 } | 517 } |
514 ] | 518 ] |
515 } | 519 } |
516 } | 520 } |
517 } | 521 } |
518 }; | 522 }; |
519 this.setCapabilities(device); | 523 this.setCapabilities(device); |
520 | 524 |
521 var otherOptions = $('other-options-settings'); | 525 var otherOptions = $('other-options-settings'); |
522 checkSectionVisible(otherOptions, false); | 526 checkSectionVisible(otherOptions, true); |
| 527 checkElementDisplayed( |
| 528 otherOptions.querySelector('#fit-to-page-container'), false); |
| 529 checkElementDisplayed( |
| 530 otherOptions.querySelector('#rasterize-container'), true); |
523 checkSectionVisible($('media-size-settings'), false); | 531 checkSectionVisible($('media-size-settings'), false); |
524 checkSectionVisible($('scaling-settings'), false); | 532 checkSectionVisible($('scaling-settings'), false); |
525 | 533 |
526 testDone(); | 534 testDone(); |
527 }); | 535 }); |
528 | 536 |
529 // When the source is 'HTML', we always hide the fit to page option and show | 537 // When the source is 'HTML', we always hide the fit to page option and show |
530 // media size option. | 538 // media size option. |
531 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { | 539 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { |
532 this.setInitialSettings(); | 540 this.setInitialSettings(); |
533 this.setLocalDestinations(); | 541 this.setLocalDestinations(); |
534 this.setCapabilities(getCddTemplate("FooDevice")); | 542 this.setCapabilities(getCddTemplate("FooDevice")); |
535 | 543 |
536 var otherOptions = $('other-options-settings'); | 544 var otherOptions = $('other-options-settings'); |
537 var fitToPage = otherOptions.querySelector('#fit-to-page-container'); | 545 var fitToPage = otherOptions.querySelector('#fit-to-page-container'); |
| 546 var rasterize = otherOptions.querySelector('#rasterize-container'); |
538 var mediaSize = $('media-size-settings'); | 547 var mediaSize = $('media-size-settings'); |
539 var scalingSettings = $('scaling-settings'); | 548 var scalingSettings = $('scaling-settings'); |
540 | 549 |
541 // Check that options are collapsed (section is visible, because duplex is | 550 // Check that options are collapsed (section is visible, because duplex is |
542 // available). | 551 // available). |
543 checkSectionVisible(otherOptions, true); | 552 checkSectionVisible(otherOptions, true); |
544 checkElementDisplayed(fitToPage, false); | 553 checkElementDisplayed(fitToPage, false); |
| 554 checkElementDisplayed(rasterize, false); |
545 checkSectionVisible(mediaSize, false); | 555 checkSectionVisible(mediaSize, false); |
546 checkSectionVisible(scalingSettings, false); | 556 checkSectionVisible(scalingSettings, false); |
547 | 557 |
548 this.expandMoreSettings(); | 558 this.expandMoreSettings(); |
549 | 559 |
550 checkElementDisplayed(fitToPage, false); | 560 checkElementDisplayed(fitToPage, false); |
| 561 checkElementDisplayed(rasterize, false); |
551 checkSectionVisible(mediaSize, true); | 562 checkSectionVisible(mediaSize, true); |
552 checkSectionVisible(scalingSettings, true); | 563 checkSectionVisible(scalingSettings, true); |
553 | 564 |
554 this.waitForAnimationToEnd('more-settings'); | 565 this.waitForAnimationToEnd('more-settings'); |
555 }); | 566 }); |
556 | 567 |
557 // When the source is "PDF", depending on the selected destination printer, we | 568 // When the source is "PDF", depending on the selected destination printer, we |
558 // show/hide the fit to page option and hide media size selection. | 569 // show/hide the fit to page option and hide media size selection. |
559 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { | 570 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { |
560 this.initialSettings_.isDocumentModifiable_ = false; | 571 this.initialSettings_.isDocumentModifiable_ = false; |
561 this.setInitialSettings(); | 572 this.setInitialSettings(); |
562 this.setLocalDestinations(); | 573 this.setLocalDestinations(); |
563 this.setCapabilities(getCddTemplate("FooDevice")); | 574 this.setCapabilities(getCddTemplate("FooDevice")); |
564 | 575 |
565 var otherOptions = $('other-options-settings'); | 576 var otherOptions = $('other-options-settings'); |
566 var scalingSettings = $('scaling-settings'); | 577 var scalingSettings = $('scaling-settings'); |
567 var fitToPageContainer = | 578 var fitToPageContainer = |
568 otherOptions.querySelector('#fit-to-page-container'); | 579 otherOptions.querySelector('#fit-to-page-container'); |
| 580 var rasterizeContainer = |
| 581 otherOptions.querySelector('#rasterize-container'); |
569 | 582 |
570 checkSectionVisible(otherOptions, true); | 583 checkSectionVisible(otherOptions, true); |
571 checkElementDisplayed(fitToPageContainer, true); | 584 checkElementDisplayed(fitToPageContainer, true); |
| 585 checkElementDisplayed(rasterizeContainer, false); |
572 expectTrue( | 586 expectTrue( |
573 fitToPageContainer.querySelector('.checkbox').checked); | 587 fitToPageContainer.querySelector('.checkbox').checked); |
574 this.expandMoreSettings(); | 588 this.expandMoreSettings(); |
| 589 checkElementDisplayed(rasterizeContainer, true); |
| 590 expectFalse( |
| 591 rasterizeContainer.querySelector('.checkbox').checked); |
575 checkSectionVisible($('media-size-settings'), true); | 592 checkSectionVisible($('media-size-settings'), true); |
576 checkSectionVisible(scalingSettings, true); | 593 checkSectionVisible(scalingSettings, true); |
577 | 594 |
578 this.waitForAnimationToEnd('other-options-collapsible'); | 595 this.waitForAnimationToEnd('other-options-collapsible'); |
579 }); | 596 }); |
580 | 597 |
581 // When the source is "PDF", depending on the selected destination printer, we | 598 // When the source is "PDF", depending on the selected destination printer, we |
582 // show/hide the fit to page option and hide media size selection. | 599 // show/hide the fit to page option and hide media size selection. |
583 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { | 600 TEST_F('PrintPreviewWebUITest', 'ScalingUnchecksFitToPage', function() { |
584 this.initialSettings_.isDocumentModifiable_ = false; | 601 this.initialSettings_.isDocumentModifiable_ = false; |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 // appears. | 1228 // appears. |
1212 var advancedSettingsCloseButton = $('advanced-settings'). | 1229 var advancedSettingsCloseButton = $('advanced-settings'). |
1213 querySelector('.close-button'); | 1230 querySelector('.close-button'); |
1214 checkElementDisplayed(advancedSettingsCloseButton, true); | 1231 checkElementDisplayed(advancedSettingsCloseButton, true); |
1215 checkElementDisplayed($('advanced-settings'). | 1232 checkElementDisplayed($('advanced-settings'). |
1216 querySelector('.search-box-area'), true); | 1233 querySelector('.search-box-area'), true); |
1217 | 1234 |
1218 this.waitForAnimationToEnd('more-settings'); | 1235 this.waitForAnimationToEnd('more-settings'); |
1219 }); | 1236 }); |
1220 | 1237 |
OLD | NEW |