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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 height_microns: 279400, | 368 height_microns: 279400, |
369 is_default: true | 369 is_default: true |
370 } | 370 } |
371 ] | 371 ] |
372 } | 372 } |
373 } | 373 } |
374 } | 374 } |
375 }; | 375 }; |
376 } | 376 } |
377 | 377 |
| 378 function isPrintAsImageEnabled() { |
| 379 return !cr.isWindows && !cr.isMac; |
| 380 } |
| 381 |
378 // Test restore settings with one destination. | 382 // Test restore settings with one destination. |
379 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', | 383 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', |
380 function() { | 384 function() { |
381 this.initialSettings_.serializedAppStateStr_ = | 385 this.initialSettings_.serializedAppStateStr_ = |
382 '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' + | 386 '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' + |
383 '"account":"", "capabilities":0, "name":"", "extensionId":"",' + | 387 '"account":"", "capabilities":0, "name":"", "extensionId":"",' + |
384 '"extensionName":""}]}'; | 388 '"extensionName":""}]}'; |
385 this.setInitialSettings(); | 389 this.setInitialSettings(); |
386 | 390 |
387 testDone(); | 391 testDone(); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 ] | 552 ] |
549 } | 553 } |
550 } | 554 } |
551 } | 555 } |
552 }; | 556 }; |
553 this.setCapabilities(device); | 557 this.setCapabilities(device); |
554 | 558 |
555 var otherOptions = $('other-options-settings'); | 559 var otherOptions = $('other-options-settings'); |
556 // If rasterization is an option, other options should be visible. If not, | 560 // If rasterization is an option, other options should be visible. If not, |
557 // there should be no available other options. | 561 // there should be no available other options. |
558 checkSectionVisible(otherOptions, !cr.isWindows && !cr.isMac); | 562 checkSectionVisible(otherOptions, isPrintAsImageEnabled()); |
559 if (!cr.isWindows && !cr.isMac) { | 563 if (isPrintAsImageEnabled()) { |
560 checkElementDisplayed( | 564 checkElementDisplayed( |
561 otherOptions.querySelector('#fit-to-page-container'), false); | 565 otherOptions.querySelector('#fit-to-page-container'), false); |
562 checkElementDisplayed( | 566 checkElementDisplayed( |
563 otherOptions.querySelector('#rasterize-container'), true); | 567 otherOptions.querySelector('#rasterize-container'), true); |
564 } | 568 } |
565 checkSectionVisible($('media-size-settings'), false); | 569 checkSectionVisible($('media-size-settings'), false); |
566 checkSectionVisible($('scaling-settings'), false); | 570 checkSectionVisible($('scaling-settings'), false); |
567 | 571 |
568 testDone(); | 572 testDone(); |
569 }); | 573 }); |
570 | 574 |
571 // When the source is 'HTML', we always hide the fit to page option and show | 575 // When the source is 'HTML', we always hide the fit to page option and show |
572 // media size option. | 576 // media size option. |
573 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { | 577 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { |
574 this.setInitialSettings(); | 578 this.setInitialSettings(); |
575 this.setLocalDestinations(); | 579 this.setLocalDestinations(); |
576 this.setCapabilities(getCddTemplate("FooDevice")); | 580 this.setCapabilities(getCddTemplate("FooDevice")); |
577 | 581 |
578 var otherOptions = $('other-options-settings'); | 582 var otherOptions = $('other-options-settings'); |
579 var fitToPage = otherOptions.querySelector('#fit-to-page-container'); | 583 var fitToPage = otherOptions.querySelector('#fit-to-page-container'); |
580 var rasterize; | 584 var rasterize; |
581 var rasterizeEnabled = !cr.isWindows && !cr.isMac; | 585 if (isPrintAsImageEnabled()) |
582 if (rasterizeEnabled) | |
583 rasterize = otherOptions.querySelector('#rasterize-container'); | 586 rasterize = otherOptions.querySelector('#rasterize-container'); |
584 var mediaSize = $('media-size-settings'); | 587 var mediaSize = $('media-size-settings'); |
585 var scalingSettings = $('scaling-settings'); | 588 var scalingSettings = $('scaling-settings'); |
586 | 589 |
587 // Check that options are collapsed (section is visible, because duplex is | 590 // Check that options are collapsed (section is visible, because duplex is |
588 // available). | 591 // available). |
589 checkSectionVisible(otherOptions, true); | 592 checkSectionVisible(otherOptions, true); |
590 checkElementDisplayed(fitToPage, false); | 593 checkElementDisplayed(fitToPage, false); |
591 if (rasterizeEnabled) | 594 if (isPrintAsImageEnabled()) |
592 checkElementDisplayed(rasterize, false); | 595 checkElementDisplayed(rasterize, false); |
593 checkSectionVisible(mediaSize, false); | 596 checkSectionVisible(mediaSize, false); |
594 checkSectionVisible(scalingSettings, false); | 597 checkSectionVisible(scalingSettings, false); |
595 | 598 |
596 this.expandMoreSettings(); | 599 this.expandMoreSettings(); |
597 | 600 |
598 checkElementDisplayed(fitToPage, false); | 601 checkElementDisplayed(fitToPage, false); |
599 if (rasterizeEnabled) | 602 if (isPrintAsImageEnabled()) |
600 checkElementDisplayed(rasterize, false); | 603 checkElementDisplayed(rasterize, false); |
601 checkSectionVisible(mediaSize, true); | 604 checkSectionVisible(mediaSize, true); |
602 checkSectionVisible(scalingSettings, true); | 605 checkSectionVisible(scalingSettings, true); |
603 | 606 |
604 this.waitForAnimationToEnd('more-settings'); | 607 this.waitForAnimationToEnd('more-settings'); |
605 }); | 608 }); |
606 | 609 |
607 // When the source is "PDF", depending on the selected destination printer, we | 610 // When the source is "PDF", depending on the selected destination printer, we |
608 // show/hide the fit to page option and hide media size selection. | 611 // show/hide the fit to page option and hide media size selection. |
609 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { | 612 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { |
610 this.initialSettings_.isDocumentModifiable_ = false; | 613 this.initialSettings_.isDocumentModifiable_ = false; |
611 this.setInitialSettings(); | 614 this.setInitialSettings(); |
612 this.setLocalDestinations(); | 615 this.setLocalDestinations(); |
613 this.setCapabilities(getCddTemplate("FooDevice")); | 616 this.setCapabilities(getCddTemplate("FooDevice")); |
614 | 617 |
615 var otherOptions = $('other-options-settings'); | 618 var otherOptions = $('other-options-settings'); |
616 var scalingSettings = $('scaling-settings'); | 619 var scalingSettings = $('scaling-settings'); |
617 var fitToPageContainer = | 620 var fitToPageContainer = |
618 otherOptions.querySelector('#fit-to-page-container'); | 621 otherOptions.querySelector('#fit-to-page-container'); |
619 var rasterizeEnabled = !cr.isWindows && !cr.isMac; | |
620 var rasterizeContainer; | 622 var rasterizeContainer; |
621 if (rasterizeEnabled) { | 623 if (isPrintAsImageEnabled()) { |
622 rasterizeContainer = | 624 rasterizeContainer = |
623 otherOptions.querySelector('#rasterize-container'); | 625 otherOptions.querySelector('#rasterize-container'); |
624 } | 626 } |
625 | 627 |
626 checkSectionVisible(otherOptions, true); | 628 checkSectionVisible(otherOptions, true); |
627 checkElementDisplayed(fitToPageContainer, true); | 629 checkElementDisplayed(fitToPageContainer, true); |
628 if (rasterizeEnabled) | 630 if (isPrintAsImageEnabled()) |
629 checkElementDisplayed(rasterizeContainer, false); | 631 checkElementDisplayed(rasterizeContainer, false); |
630 expectTrue( | 632 expectTrue( |
631 fitToPageContainer.querySelector('.checkbox').checked); | 633 fitToPageContainer.querySelector('.checkbox').checked); |
632 this.expandMoreSettings(); | 634 this.expandMoreSettings(); |
633 if (rasterizeEnabled) { | 635 if (isPrintAsImageEnabled()) { |
634 checkElementDisplayed(rasterizeContainer, true); | 636 checkElementDisplayed(rasterizeContainer, true); |
635 expectFalse( | 637 expectFalse( |
636 rasterizeContainer.querySelector('.checkbox').checked); | 638 rasterizeContainer.querySelector('.checkbox').checked); |
637 } | 639 } |
638 checkSectionVisible($('media-size-settings'), true); | 640 checkSectionVisible($('media-size-settings'), true); |
639 checkSectionVisible(scalingSettings, true); | 641 checkSectionVisible(scalingSettings, true); |
640 | 642 |
641 this.waitForAnimationToEnd('other-options-collapsible'); | 643 this.waitForAnimationToEnd('other-options-collapsible'); |
642 }); | 644 }); |
643 | 645 |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 // increments by 1 for each startGetPreview call it makes. It should only | 1313 // increments by 1 for each startGetPreview call it makes. It should only |
1312 // make one such call during initialization or there will be a race; see | 1314 // make one such call during initialization or there will be a race; see |
1313 // crbug.com/666595 | 1315 // crbug.com/666595 |
1314 expectEquals(printPreview.previewArea_.previewGenerator_.inFlightRequestId_, | 1316 expectEquals(printPreview.previewArea_.previewGenerator_.inFlightRequestId_, |
1315 -1); | 1317 -1); |
1316 this.setInitialSettings(); | 1318 this.setInitialSettings(); |
1317 expectEquals(printPreview.previewArea_.previewGenerator_.inFlightRequestId_, | 1319 expectEquals(printPreview.previewArea_.previewGenerator_.inFlightRequestId_, |
1318 0); | 1320 0); |
1319 testDone(); | 1321 testDone(); |
1320 }); | 1322 }); |
OLD | NEW |