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 /** | 5 /** |
6 * Test fixture for print preview WebUI testing. | 6 * Test fixture for print preview WebUI testing. |
7 * @constructor | 7 * @constructor |
8 * @extends {testing.Test} | 8 * @extends {testing.Test} |
9 */ | 9 */ |
10 function PrintPreviewWebUITest() { | 10 function PrintPreviewWebUITest() { |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 | 467 |
468 // When the print scaling is disabled for the source "PDF", we show the fit | 468 // When the print scaling is disabled for the source "PDF", we show the fit |
469 // to page option but the state is unchecked by default. | 469 // to page option but the state is unchecked by default. |
470 TEST_F('PrintPreviewWebUITest', 'PrintScalingDisabledForPlugin', function() { | 470 TEST_F('PrintPreviewWebUITest', 'PrintScalingDisabledForPlugin', function() { |
471 this.initialSettings_.isDocumentModifiable_ = false; | 471 this.initialSettings_.isDocumentModifiable_ = false; |
472 this.setInitialSettings(); | 472 this.setInitialSettings(); |
473 this.setLocalDestinations(); | 473 this.setLocalDestinations(); |
474 this.setCapabilities(getCddTemplate("FooDevice")); | 474 this.setCapabilities(getCddTemplate("FooDevice")); |
475 | 475 |
476 // Indicate that the PDF does not support scaling by default. | 476 // Indicate that the PDF does not support scaling by default. |
477 cr.dispatchSimpleEvent( | 477 var printPresetOptionsEvent = new Event( |
478 this.nativeLayer_, print_preview.NativeLayer.EventType.DISABLE_SCALING); | 478 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
| 479 printPresetOptionsEvent.optionsFromDocument = {disableScaling: true}; |
| 480 this.nativeLayer_.dispatchEvent(printPresetOptionsEvent); |
479 | 481 |
480 var otherOptions = $('other-options-settings'); | 482 var otherOptions = $('other-options-settings'); |
481 checkSectionVisible(otherOptions, true); | 483 checkSectionVisible(otherOptions, true); |
482 checkElementDisplayed( | 484 checkElementDisplayed( |
483 otherOptions.querySelector('.fit-to-page-container'), true); | 485 otherOptions.querySelector('.fit-to-page-container'), true); |
484 expectFalse( | 486 expectFalse( |
485 otherOptions.querySelector('.fit-to-page-checkbox').checked); | 487 otherOptions.querySelector('.fit-to-page-checkbox').checked); |
486 | 488 |
487 this.waitForAnimationToEnd('other-options-collapsible'); | 489 this.waitForAnimationToEnd('other-options-collapsible'); |
488 }); | 490 }); |
489 | 491 |
| 492 // When the number of copies print preset is set for source 'PDF', we update |
| 493 // copies value if capability is supported by printer. |
| 494 TEST_F('PrintPreviewWebUITest', 'CheckNumCopiesPrintPreset', function() { |
| 495 this.initialSettings_.isDocumentModifiable_ = false; |
| 496 this.setInitialSettings(); |
| 497 this.setLocalDestinations(); |
| 498 this.setCapabilities(getCddTemplate("FooDevice")); |
| 499 |
| 500 // Indicate that the number of copies print preset is set for source PDF. |
| 501 var printPresetOptions = { |
| 502 disableScaling: true, |
| 503 copies: 2 |
| 504 }; |
| 505 var printPresetOptionsEvent = new Event( |
| 506 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS); |
| 507 printPresetOptionsEvent.optionsFromDocument = printPresetOptions; |
| 508 this.nativeLayer_.dispatchEvent(printPresetOptionsEvent); |
| 509 |
| 510 checkSectionVisible($('copies-settings'), true); |
| 511 expectEquals( |
| 512 printPresetOptions.copies, |
| 513 parseInt($('copies-settings').querySelector('.copies').value)); |
| 514 |
| 515 this.waitForAnimationToEnd('other-options-collapsible'); |
| 516 }); |
| 517 |
490 // Make sure that custom margins controls are properly set up. | 518 // Make sure that custom margins controls are properly set up. |
491 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { | 519 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { |
492 this.setInitialSettings(); | 520 this.setInitialSettings(); |
493 this.setLocalDestinations(); | 521 this.setLocalDestinations(); |
494 this.setCapabilities(getCddTemplate("FooDevice")); | 522 this.setCapabilities(getCddTemplate("FooDevice")); |
495 | 523 |
496 printPreview.printTicketStore_.marginsType.updateValue( | 524 printPreview.printTicketStore_.marginsType.updateValue( |
497 print_preview.ticket_items.MarginsType.Value.CUSTOM); | 525 print_preview.ticket_items.MarginsType.Value.CUSTOM); |
498 | 526 |
499 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { | 527 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 var printFailedMessageEl = | 881 var printFailedMessageEl = |
854 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; | 882 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; |
855 expectEquals(true, printFailedMessageEl.hidden); | 883 expectEquals(true, printFailedMessageEl.hidden); |
856 | 884 |
857 var customMessageEl = | 885 var customMessageEl = |
858 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; | 886 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; |
859 expectEquals(false, customMessageEl.hidden); | 887 expectEquals(false, customMessageEl.hidden); |
860 | 888 |
861 testDone(); | 889 testDone(); |
862 }); | 890 }); |
OLD | NEW |