Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 PrintPreviewWebUITest.prototype = { | 38 PrintPreviewWebUITest.prototype = { |
| 39 __proto__: testing.Test.prototype, | 39 __proto__: testing.Test.prototype, |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * Browse to the sample page, cause print preview & call preLoad(). | 42 * Browse to the sample page, cause print preview & call preLoad(). |
| 43 * @type {string} | 43 * @type {string} |
| 44 * @override | 44 * @override |
| 45 */ | 45 */ |
| 46 browsePrintPreload: 'print_preview_hello_world_test.html', | 46 browsePrintPreload: 'print_preview_hello_world_test.html', |
| 47 | 47 |
| 48 /** @override */ | |
| 49 runAccessibilityChecks: true, | |
| 50 | |
| 51 /** @override */ | |
| 52 accessibilityIssuesAreErrors: true, | |
| 53 | |
| 48 /** | 54 /** |
| 49 * Stub out low-level functionality like the NativeLayer and | 55 * Stub out low-level functionality like the NativeLayer and |
| 50 * CloudPrintInterface. | 56 * CloudPrintInterface. |
| 51 * @this {PrintPreviewWebUITest} | 57 * @this {PrintPreviewWebUITest} |
| 52 * @override | 58 * @override |
| 53 */ | 59 */ |
| 54 preLoad: function() { | 60 preLoad: function() { |
| 55 window.addEventListener('DOMContentLoaded', function() { | 61 window.addEventListener('DOMContentLoaded', function() { |
| 56 function NativeLayerStub() { | 62 function NativeLayerStub() { |
| 57 cr.EventTarget.call(this); | 63 cr.EventTarget.call(this); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 { printerName: 'BarName', deviceName: 'BarDevice' } | 138 { printerName: 'BarName', deviceName: 'BarDevice' } |
| 133 ]; | 139 ]; |
| 134 this.nativeLayer_ = printPreview.nativeLayer_; | 140 this.nativeLayer_ = printPreview.nativeLayer_; |
| 135 } | 141 } |
| 136 }; | 142 }; |
| 137 | 143 |
| 138 GEN('#include "chrome/test/data/webui/print_preview.h"'); | 144 GEN('#include "chrome/test/data/webui/print_preview.h"'); |
| 139 | 145 |
| 140 // Test some basic assumptions about the print preview WebUI. | 146 // Test some basic assumptions about the print preview WebUI. |
| 141 TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() { | 147 TEST_F('PrintPreviewWebUITest', 'TestPrinterList', function() { |
| 142 var initialSettingsSetEvent = | 148 this.setUpPreview(); |
| 143 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 144 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 145 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 146 | |
| 147 var localDestsSetEvent = | |
| 148 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 149 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 150 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 151 | 149 |
| 152 var recentList = $('destination-search').querySelector('.recent-list ul'); | 150 var recentList = $('destination-search').querySelector('.recent-list ul'); |
| 153 var localList = $('destination-search').querySelector('.local-list ul'); | 151 var localList = $('destination-search').querySelector('.local-list ul'); |
| 154 assertNotEquals(null, recentList); | 152 assertNotEquals(null, recentList); |
| 155 assertEquals(1, recentList.childNodes.length); | 153 assertEquals(1, recentList.childNodes.length); |
| 156 assertEquals('FooName', | 154 assertEquals('FooName', |
| 157 recentList.childNodes.item(0).querySelector( | 155 recentList.childNodes.item(0).querySelector( |
| 158 '.destination-list-item-name').textContent); | 156 '.destination-list-item-name').textContent); |
| 159 | 157 |
| 160 assertNotEquals(null, localList); | 158 assertNotEquals(null, localList); |
| 161 assertEquals(3, localList.childNodes.length); | 159 assertEquals(3, localList.childNodes.length); |
| 162 assertEquals('Save as PDF', | 160 assertEquals('Save as PDF', |
| 163 localList.childNodes.item(PrintPreviewWebUITest.PDF_INDEX). | 161 localList.childNodes.item(PrintPreviewWebUITest.PDF_INDEX). |
| 164 querySelector('.destination-list-item-name').textContent); | 162 querySelector('.destination-list-item-name').textContent); |
| 165 assertEquals('FooName', | 163 assertEquals('FooName', |
| 166 localList.childNodes.item(PrintPreviewWebUITest.FOO_INDEX). | 164 localList.childNodes.item(PrintPreviewWebUITest.FOO_INDEX). |
| 167 querySelector('.destination-list-item-name').textContent); | 165 querySelector('.destination-list-item-name').textContent); |
| 168 assertEquals('BarName', | 166 assertEquals('BarName', |
| 169 localList.childNodes.item(PrintPreviewWebUITest.BAR_INDEX). | 167 localList.childNodes.item(PrintPreviewWebUITest.BAR_INDEX). |
| 170 querySelector('.destination-list-item-name').textContent); | 168 querySelector('.destination-list-item-name').textContent); |
| 171 }); | 169 }); |
| 172 | 170 |
| 173 // Test that the printer list is structured correctly after calling | 171 // Test that the printer list is structured correctly after calling |
| 174 // addCloudPrinters with an empty list. | 172 // addCloudPrinters with an empty list. |
| 175 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() { | 173 TEST_F('PrintPreviewWebUITest', 'TestPrinterListCloudEmpty', function() { |
| 176 var initialSettingsSetEvent = | 174 this.setUpPreview(); |
| 177 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 178 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 179 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 180 | |
| 181 var localDestsSetEvent = | |
| 182 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 183 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 184 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 185 | 175 |
| 186 var cloudPrintEnableEvent = | 176 var cloudPrintEnableEvent = |
| 187 new Event(print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE); | 177 new Event(print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE); |
| 188 cloudPrintEnableEvent.baseCloudPrintUrl = 'cloudprint url'; | 178 cloudPrintEnableEvent.baseCloudPrintUrl = 'cloudprint url'; |
| 189 this.nativeLayer_.dispatchEvent(cloudPrintEnableEvent); | 179 this.nativeLayer_.dispatchEvent(cloudPrintEnableEvent); |
| 190 | 180 |
| 191 var searchDoneEvent = | 181 var searchDoneEvent = |
| 192 new Event(cloudprint.CloudPrintInterface.EventType.SEARCH_DONE); | 182 new Event(cloudprint.CloudPrintInterface.EventType.SEARCH_DONE); |
| 193 searchDoneEvent.printers = []; | 183 searchDoneEvent.printers = []; |
| 194 searchDoneEvent.isRecent = true; | 184 searchDoneEvent.isRecent = true; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 282 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); |
| 293 | 283 |
| 294 checkElementDisplayed($('system-dialog-link'), false); | 284 checkElementDisplayed($('system-dialog-link'), false); |
| 295 }); | 285 }); |
| 296 | 286 |
| 297 // Test that disabled settings hide the disabled sections. | 287 // Test that disabled settings hide the disabled sections. |
| 298 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { | 288 TEST_F('PrintPreviewWebUITest', 'TestSectionsDisabled', function() { |
| 299 checkSectionVisible($('layout-settings'), false); | 289 checkSectionVisible($('layout-settings'), false); |
| 300 checkSectionVisible($('color-settings'), false); | 290 checkSectionVisible($('color-settings'), false); |
| 301 checkSectionVisible($('copies-settings'), false); | 291 checkSectionVisible($('copies-settings'), false); |
| 302 | 292 this.setUpPreview(); |
| 303 var initialSettingsSetEvent = | |
| 304 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 305 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 306 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 307 | |
| 308 var localDestsSetEvent = | |
| 309 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 310 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 311 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 312 | 293 |
| 313 var capsSetEvent = | 294 var capsSetEvent = |
| 314 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 295 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
| 315 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 296 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
| 316 capsSetEvent.settingsInfo.capabilities.printer.color = { | 297 capsSetEvent.settingsInfo.capabilities.printer.color = { |
| 317 "option": [ | 298 "option": [ |
| 318 {"is_default": true, "type": "STANDARD_COLOR"} | 299 {"is_default": true, "type": "STANDARD_COLOR"} |
| 319 ] | 300 ] |
| 320 }; | 301 }; |
| 321 delete capsSetEvent.settingsInfo.capabilities.printer.copies; | 302 delete capsSetEvent.settingsInfo.capabilities.printer.copies; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 } | 349 } |
| 369 } | 350 } |
| 370 } | 351 } |
| 371 }; | 352 }; |
| 372 this.nativeLayer_.dispatchEvent(capsSetEvent); | 353 this.nativeLayer_.dispatchEvent(capsSetEvent); |
| 373 | 354 |
| 374 checkSectionVisible($('other-options-settings'), false); | 355 checkSectionVisible($('other-options-settings'), false); |
| 375 checkSectionVisible($('media-size-settings'), false); | 356 checkSectionVisible($('media-size-settings'), false); |
| 376 }); | 357 }); |
| 377 | 358 |
| 378 // When the source is 'HTML', we always hide the fit to page option and show | |
| 379 // media size option. | |
| 380 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLCapabilities', function() { | |
| 381 var initialSettingsSetEvent = | |
| 382 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 383 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 384 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 385 | |
| 386 var localDestsSetEvent = | |
| 387 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 388 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 389 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 390 | |
| 391 var capsSetEvent = | |
| 392 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 393 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 394 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 395 | |
| 396 var moreSettingsDiv = $('more-settings'); | |
| 397 var mediaSizeDiv = $('media-size-settings'); | |
| 398 var otherOptionsDiv = $('other-options-settings'); | |
| 399 var fitToPageEl = otherOptionsDiv.querySelector('.fit-to-page-container'); | |
| 400 | |
| 401 // Check that options are collapsed (section is visible, because duplex is | |
| 402 // available). | |
| 403 checkSectionVisible(otherOptionsDiv, true); | |
| 404 checkElementDisplayed(fitToPageEl, false); | |
| 405 checkSectionVisible(mediaSizeDiv, false); | |
| 406 // Expand it. | |
| 407 checkSectionVisible(moreSettingsDiv, true); | |
| 408 moreSettingsDiv.click(); | |
| 409 | |
| 410 checkElementDisplayed(fitToPageEl, false); | |
| 411 checkSectionVisible(mediaSizeDiv, true); | |
| 412 }); | |
| 413 | |
| 414 // When the source is "PDF", depending on the selected destination printer, we | 359 // When the source is "PDF", depending on the selected destination printer, we |
| 415 // show/hide the fit to page option and hide media size selection. | 360 // show/hide the fit to page option and hide media size selection. |
| 416 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { | 361 TEST_F('PrintPreviewWebUITest', 'SourceIsPDFCapabilities', function() { |
| 417 this.initialSettings_.isDocumentModifiable_ = false; | 362 this.initialSettings_.isDocumentModifiable_ = false; |
| 418 | 363 this.setUpPreview(); |
| 419 var initialSettingsSetEvent = | |
| 420 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 421 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 422 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 423 | |
| 424 var localDestsSetEvent = | |
| 425 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 426 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 427 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 428 | 364 |
| 429 var capsSetEvent = | 365 var capsSetEvent = |
| 430 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 366 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
| 431 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 367 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
| 432 this.nativeLayer_.dispatchEvent(capsSetEvent); | 368 this.nativeLayer_.dispatchEvent(capsSetEvent); |
| 433 | 369 |
| 434 var otherOptionsDiv = $('other-options-settings'); | 370 var otherOptionsDiv = $('other-options-settings'); |
| 435 | 371 |
| 436 checkSectionVisible(otherOptionsDiv, true); | 372 checkSectionVisible(otherOptionsDiv, true); |
| 437 checkElementDisplayed( | 373 checkElementDisplayed( |
| 438 otherOptionsDiv.querySelector('.fit-to-page-container'), true); | 374 otherOptionsDiv.querySelector('.fit-to-page-container'), true); |
| 439 expectTrue( | 375 expectTrue( |
| 440 otherOptionsDiv.querySelector('.fit-to-page-checkbox').checked); | 376 otherOptionsDiv.querySelector('.fit-to-page-checkbox').checked); |
| 441 checkSectionVisible($('media-size-settings'), true); | 377 checkSectionVisible($('media-size-settings'), true); |
| 442 }); | 378 }); |
| 443 | 379 |
| 444 // When the print scaling is disabled for the source "PDF", we show the fit | 380 // When the print scaling is disabled for the source "PDF", we show the fit |
| 445 // to page option but the state is unchecked by default. | 381 // to page option but the state is unchecked by default. |
| 446 TEST_F('PrintPreviewWebUITest', 'PrintScalingDisabledForPlugin', function() { | 382 TEST_F('PrintPreviewWebUITest', 'PrintScalingDisabledForPlugin', function() { |
| 447 this.initialSettings_.isDocumentModifiable_ = false; | 383 this.initialSettings_.isDocumentModifiable_ = false; |
| 448 | 384 this.setUpPreview(); |
| 449 var initialSettingsSetEvent = | |
| 450 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 451 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 452 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 453 | |
| 454 var localDestsSetEvent = | |
| 455 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 456 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 457 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 458 | 385 |
| 459 var capsSetEvent = | 386 var capsSetEvent = |
| 460 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 387 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
| 461 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 388 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
| 462 this.nativeLayer_.dispatchEvent(capsSetEvent); | 389 this.nativeLayer_.dispatchEvent(capsSetEvent); |
| 463 | 390 |
| 464 // Indicate that the PDF does not support scaling by default. | 391 // Indicate that the PDF does not support scaling by default. |
| 465 cr.dispatchSimpleEvent( | 392 cr.dispatchSimpleEvent( |
| 466 this.nativeLayer_, print_preview.NativeLayer.EventType.DISABLE_SCALING); | 393 this.nativeLayer_, print_preview.NativeLayer.EventType.DISABLE_SCALING); |
| 467 | 394 |
| 468 var otherOptionsDiv = $('other-options-settings'); | 395 var otherOptionsDiv = $('other-options-settings'); |
| 469 | 396 |
| 470 checkSectionVisible(otherOptionsDiv, true); | 397 checkSectionVisible(otherOptionsDiv, true); |
| 471 | 398 |
| 472 checkElementDisplayed( | 399 checkElementDisplayed( |
| 473 otherOptionsDiv.querySelector('.fit-to-page-container'), true); | 400 otherOptionsDiv.querySelector('.fit-to-page-container'), true); |
| 474 expectFalse( | 401 expectFalse( |
| 475 otherOptionsDiv.querySelector('.fit-to-page-checkbox').checked); | 402 otherOptionsDiv.querySelector('.fit-to-page-checkbox').checked); |
| 476 }); | 403 }); |
| 477 | 404 |
| 478 // Make sure that custom margins controls are properly set up. | 405 // Make sure that custom margins controls are properly set up. |
| 479 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { | 406 TEST_F('PrintPreviewWebUITest', 'CustomMarginsControlsCheck', function() { |
| 480 var initialSettingsSetEvent = | 407 this.setUpPreview(); |
| 481 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 482 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 483 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 484 | |
| 485 var localDestsSetEvent = | |
| 486 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 487 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 488 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 489 | 408 |
| 490 var capsSetEvent = | 409 var capsSetEvent = |
| 491 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 410 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
| 492 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 411 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
| 493 this.nativeLayer_.dispatchEvent(capsSetEvent); | 412 this.nativeLayer_.dispatchEvent(capsSetEvent); |
| 494 | 413 |
| 495 printPreview.printTicketStore_.marginsType.updateValue( | 414 printPreview.printTicketStore_.marginsType.updateValue( |
| 496 print_preview.ticket_items.MarginsType.Value.CUSTOM); | 415 print_preview.ticket_items.MarginsType.Value.CUSTOM); |
| 497 | 416 |
| 498 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { | 417 ['left', 'top', 'right', 'bottom'].forEach(function(margin) { |
| 499 var control = $('preview-area').querySelector('.margin-control-' + margin); | 418 var control = $('preview-area').querySelector('.margin-control-' + margin); |
| 500 assertNotEquals(null, control); | 419 assertNotEquals(null, control); |
| 501 var input = control.querySelector('.margin-control-textbox'); | 420 var input = control.querySelector('.margin-control-textbox'); |
| 502 assertTrue(input.hasAttribute('aria-label')); | 421 assertTrue(input.hasAttribute('aria-label')); |
| 503 assertNotEquals('undefined', input.getAttribute('aria-label')); | 422 assertNotEquals('undefined', input.getAttribute('aria-label')); |
| 504 }); | 423 }); |
| 505 }); | 424 }); |
| 506 | 425 |
| 507 // Page layout has zero margins. Hide header and footer option. | |
| 508 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasNoMarginsHideHeaderFooter', | |
| 509 function() { | |
| 510 var initialSettingsSetEvent = | |
| 511 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 512 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 513 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 514 | |
| 515 var localDestsSetEvent = | |
| 516 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 517 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 518 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 519 | |
| 520 var capsSetEvent = | |
| 521 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 522 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 523 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 524 | |
| 525 var moreSettingsDiv = $('more-settings'); | |
| 526 var otherOptionsDiv = $('other-options-settings'); | |
| 527 var headerFooterEl = | |
| 528 otherOptionsDiv.querySelector('.header-footer-container'); | |
| 529 | |
| 530 // Check that options are collapsed (section is visible, because duplex is | |
| 531 // available). | |
| 532 checkSectionVisible(otherOptionsDiv, true); | |
| 533 checkElementDisplayed(headerFooterEl, false); | |
| 534 // Expand it. | |
| 535 checkSectionVisible(moreSettingsDiv, true); | |
| 536 moreSettingsDiv.click(); | |
| 537 | |
| 538 checkElementDisplayed(headerFooterEl, true); | |
| 539 | |
| 540 printPreview.printTicketStore_.marginsType.updateValue( | |
| 541 print_preview.ticket_items.MarginsType.Value.CUSTOM); | |
| 542 printPreview.printTicketStore_.customMargins.updateValue( | |
| 543 new print_preview.Margins(0, 0, 0, 0)); | |
| 544 | |
| 545 checkElementDisplayed(headerFooterEl, false); | |
| 546 }); | |
| 547 | |
| 548 // Page layout has half-inch margins. Show header and footer option. | |
| 549 TEST_F('PrintPreviewWebUITest', 'PageLayoutHasMarginsShowHeaderFooter', | |
| 550 function() { | |
| 551 var initialSettingsSetEvent = | |
| 552 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 553 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 554 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 555 | |
| 556 var localDestsSetEvent = | |
| 557 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 558 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 559 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 560 | |
| 561 var capsSetEvent = | |
| 562 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 563 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 564 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 565 | |
| 566 var moreSettingsDiv = $('more-settings'); | |
| 567 var otherOptionsDiv = $('other-options-settings'); | |
| 568 var headerFooterEl = | |
| 569 otherOptionsDiv.querySelector('.header-footer-container'); | |
| 570 | |
| 571 // Check that options are collapsed (section is visible, because duplex is | |
| 572 // available). | |
| 573 checkSectionVisible(otherOptionsDiv, true); | |
| 574 checkElementDisplayed(headerFooterEl, false); | |
| 575 // Expand it. | |
| 576 checkSectionVisible(moreSettingsDiv, true); | |
| 577 moreSettingsDiv.click(); | |
| 578 | |
| 579 checkElementDisplayed(headerFooterEl, true); | |
| 580 | |
| 581 printPreview.printTicketStore_.marginsType.updateValue( | |
| 582 print_preview.ticket_items.MarginsType.Value.CUSTOM); | |
| 583 printPreview.printTicketStore_.customMargins.updateValue( | |
| 584 new print_preview.Margins(36, 36, 36, 36)); | |
| 585 | |
| 586 checkElementDisplayed(headerFooterEl, true); | |
| 587 }); | |
| 588 | |
| 589 // Page layout has zero top and bottom margins. Hide header and footer option. | |
| 590 TEST_F('PrintPreviewWebUITest', | |
| 591 'ZeroTopAndBottomMarginsHideHeaderFooter', | |
| 592 function() { | |
| 593 var initialSettingsSetEvent = | |
| 594 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 595 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 596 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 597 | |
| 598 var localDestsSetEvent = | |
| 599 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 600 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 601 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 602 | |
| 603 var capsSetEvent = | |
| 604 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 605 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 606 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 607 | |
| 608 var moreSettingsDiv = $('more-settings'); | |
| 609 var otherOptionsDiv = $('other-options-settings'); | |
| 610 var headerFooterEl = | |
| 611 otherOptionsDiv.querySelector('.header-footer-container'); | |
| 612 | |
| 613 // Check that options are collapsed (section is visible, because duplex is | |
| 614 // available). | |
| 615 checkSectionVisible(otherOptionsDiv, true); | |
| 616 checkElementDisplayed(headerFooterEl, false); | |
| 617 // Expand it. | |
| 618 checkSectionVisible(moreSettingsDiv, true); | |
| 619 moreSettingsDiv.click(); | |
| 620 | |
| 621 checkElementDisplayed(headerFooterEl, true); | |
| 622 | |
| 623 printPreview.printTicketStore_.marginsType.updateValue( | |
| 624 print_preview.ticket_items.MarginsType.Value.CUSTOM); | |
| 625 printPreview.printTicketStore_.customMargins.updateValue( | |
| 626 new print_preview.Margins(0, 36, 0, 36)); | |
| 627 | |
| 628 checkElementDisplayed(headerFooterEl, false); | |
| 629 }); | |
| 630 | |
| 631 // Page layout has zero top and half-inch bottom margin. Show header and footer | |
| 632 // option. | |
| 633 TEST_F('PrintPreviewWebUITest', | |
| 634 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter', | |
| 635 function() { | |
| 636 var initialSettingsSetEvent = | |
| 637 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 638 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 639 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 640 | |
| 641 var localDestsSetEvent = | |
| 642 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 643 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 644 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 645 | |
| 646 var capsSetEvent = | |
| 647 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 648 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 649 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 650 | |
| 651 var moreSettingsDiv = $('more-settings'); | |
| 652 var otherOptionsDiv = $('other-options-settings'); | |
| 653 var headerFooterEl = | |
| 654 otherOptionsDiv.querySelector('.header-footer-container'); | |
| 655 | |
| 656 // Check that options are collapsed (section is visible, because duplex is | |
| 657 // available). | |
| 658 checkSectionVisible(otherOptionsDiv, true); | |
| 659 checkElementDisplayed(headerFooterEl, false); | |
| 660 // Expand it. | |
| 661 checkSectionVisible(moreSettingsDiv, true); | |
| 662 moreSettingsDiv.click(); | |
| 663 | |
| 664 checkElementDisplayed(headerFooterEl, true); | |
| 665 | |
| 666 printPreview.printTicketStore_.marginsType.updateValue( | |
| 667 print_preview.ticket_items.MarginsType.Value.CUSTOM); | |
| 668 printPreview.printTicketStore_.customMargins.updateValue( | |
| 669 new print_preview.Margins(0, 36, 36, 36)); | |
| 670 | |
| 671 checkElementDisplayed(headerFooterEl, true); | |
| 672 }); | |
| 673 | |
| 674 // Test that the color settings, one option, standard monochrome. | 426 // Test that the color settings, one option, standard monochrome. |
| 675 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() { | 427 TEST_F('PrintPreviewWebUITest', 'TestColorSettingsMonochrome', function() { |
| 676 this.setUpPreview(); | 428 this.setUpPreview(); |
| 677 | 429 |
| 678 // Only one option, standard monochrome. | 430 // Only one option, standard monochrome. |
| 679 var capsSetEvent = | 431 var capsSetEvent = |
| 680 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 432 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
| 681 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 433 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
| 682 capsSetEvent.settingsInfo.capabilities.printer.color = { | 434 capsSetEvent.settingsInfo.capabilities.printer.color = { |
| 683 "option": [ | 435 "option": [ |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 804 | 556 |
| 805 checkSectionVisible($('color-settings'), true); | 557 checkSectionVisible($('color-settings'), true); |
| 806 expectEquals( | 558 expectEquals( |
| 807 'color', | 559 'color', |
| 808 $('color-settings').querySelector('.color-settings-select').value); | 560 $('color-settings').querySelector('.color-settings-select').value); |
| 809 }); | 561 }); |
| 810 | 562 |
| 811 // Test to verify that duplex settings are set according to the printer | 563 // Test to verify that duplex settings are set according to the printer |
| 812 // capabilities. | 564 // capabilities. |
| 813 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { | 565 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsTrue', function() { |
| 814 var initialSettingsSetEvent = | 566 this.setUpPreview(); |
| 815 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 816 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 817 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 818 | |
| 819 var localDestsSetEvent = | |
| 820 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 821 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 822 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 823 | 567 |
| 824 var otherOptionsDiv = $('other-options-settings'); | 568 var otherOptionsDiv = $('other-options-settings'); |
| 825 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); | 569 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); |
| 826 var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox'); | 570 var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox'); |
| 827 | 571 |
| 828 var capsSetEvent = | 572 var capsSetEvent = |
| 829 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 573 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
| 830 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 574 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
| 831 this.nativeLayer_.dispatchEvent(capsSetEvent); | 575 this.nativeLayer_.dispatchEvent(capsSetEvent); |
| 832 | 576 |
| 833 checkSectionVisible(otherOptionsDiv, true); | 577 checkSectionVisible(otherOptionsDiv, true); |
| 834 expectFalse(duplexDiv.hidden); | 578 expectFalse(duplexDiv.hidden); |
| 835 expectFalse(duplexCheckbox.checked); | 579 expectFalse(duplexCheckbox.checked); |
| 836 }); | 580 }); |
| 837 | 581 |
| 838 // Test to verify that duplex settings are set according to the printer | |
| 839 // capabilities. | |
| 840 TEST_F('PrintPreviewWebUITest', 'TestDuplexSettingsFalse', function() { | |
| 841 var initialSettingsSetEvent = | |
| 842 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 843 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 844 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 845 | |
| 846 var localDestsSetEvent = | |
| 847 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 848 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 849 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 850 | |
| 851 var moreSettingsDiv = $('more-settings'); | |
| 852 var otherOptionsDiv = $('other-options-settings'); | |
| 853 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); | |
| 854 | |
| 855 var capsSetEvent = | |
| 856 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 857 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 858 delete capsSetEvent.settingsInfo.capabilities.printer.duplex; | |
| 859 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 860 | |
| 861 // Check that it is collapsed. | |
| 862 checkSectionVisible(otherOptionsDiv, false); | |
| 863 // Expand it. | |
| 864 checkSectionVisible(moreSettingsDiv, true); | |
| 865 moreSettingsDiv.click(); | |
| 866 // Now it should be visible. | |
| 867 checkSectionVisible(otherOptionsDiv, true); | |
| 868 expectTrue(duplexDiv.hidden); | |
| 869 }); | |
| 870 | |
| 871 // Test that changing the selected printer updates the preview. | 582 // Test that changing the selected printer updates the preview. |
| 872 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { | 583 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { |
| 873 | 584 this.setUpPreview(); |
| 874 var initialSettingsSetEvent = | |
| 875 new Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | |
| 876 initialSettingsSetEvent.initialSettings = this.initialSettings_; | |
| 877 this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | |
| 878 | |
| 879 var localDestsSetEvent = | |
| 880 new Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | |
| 881 localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | |
| 882 this.nativeLayer_.dispatchEvent(localDestsSetEvent); | |
| 883 | 585 |
| 884 var capsSetEvent = | 586 var capsSetEvent = |
| 885 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 587 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); |
| 886 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | 588 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); |
| 887 this.nativeLayer_.dispatchEvent(capsSetEvent); | 589 this.nativeLayer_.dispatchEvent(capsSetEvent); |
| 888 | 590 |
| 889 var previewGenerator = mock(print_preview.PreviewGenerator); | 591 var previewGenerator = mock(print_preview.PreviewGenerator); |
| 890 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); | 592 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); |
| 891 previewGenerator.expects(exactly(6)).requestPreview(); | 593 previewGenerator.expects(exactly(6)).requestPreview(); |
| 892 | 594 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 expectEquals(true, previewFailedMessageEl.hidden); | 627 expectEquals(true, previewFailedMessageEl.hidden); |
| 926 | 628 |
| 927 var printFailedMessageEl = | 629 var printFailedMessageEl = |
| 928 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; | 630 previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; |
| 929 expectEquals(true, printFailedMessageEl.hidden); | 631 expectEquals(true, printFailedMessageEl.hidden); |
| 930 | 632 |
| 931 var customMessageEl = | 633 var customMessageEl = |
| 932 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; | 634 previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; |
| 933 expectEquals(false, customMessageEl.hidden); | 635 expectEquals(false, customMessageEl.hidden); |
| 934 }); | 636 }); |
| 637 | |
| 638 /** | |
| 639 * Async test fixture for print preview WebUI testing. | |
| 640 * @constructor | |
| 641 * @extends {PrintPreviewWebUITest} | |
| 642 */ | |
| 643 function PrintPreviewWebUIAsyncTest() { | |
| 644 } | |
| 645 | |
| 646 PrintPreviewWebUIAsyncTest.prototype = { | |
| 647 __proto__: PrintPreviewWebUITest.prototype, | |
| 648 | |
| 649 /** @override */ | |
| 650 isAsync: true, | |
| 651 | |
| 652 /** | |
| 653 * @this {PrintPreviewWebUIAsyncTest} | |
| 654 * @override | |
| 655 */ | |
| 656 setUp: function() { | |
| 657 // Setup everything from the base class. | |
| 658 PrintPreviewWebUITest.prototype.setUp.call(this); | |
| 659 | |
| 660 // Do this here because all tests need it. | |
| 661 this.setUpPreview(); | |
| 662 | |
| 663 // Make all transitions and animations take 0ms for testing purposes. | |
| 664 // Animations still happen and we will wait for the webkitAnimationEnd event | |
| 665 // for the "more-settings" element because it is responsible for hiding a | |
| 666 // lot of buttons. | |
| 667 var noAnimationStyle = | |
| 668 document.createElementNS('http://www.w3.org/1999/xhtml', 'style'); | |
|
Dan Beam
2014/10/20 20:15:25
indent off
Dan Beam
2014/10/20 20:15:25
er, why not just document.createElement('style')?
hcarmona
2014/10/21 01:07:18
Changed to document.createElement('style')
hcarmona
2014/10/21 01:07:18
Acknowledged.
| |
| 669 noAnimationStyle.textContent = | |
| 670 '* {' + | |
| 671 ' -webkit-transition-duration: 0s !important;' + | |
| 672 ' -webkit-transition-delay: 0s !important;' + | |
| 673 ' -webkit-animation-duration: 0s !important;' + | |
| 674 ' -webkit-animation-delay: 0s !important;' + | |
| 675 '}'; | |
| 676 var heads = document.getElementsByTagName('head'); | |
|
Dan Beam
2014/10/20 20:15:25
we control the markup, so there should always be a
hcarmona
2014/10/21 01:07:18
Acknowledged.
| |
| 677 if (heads.length) { | |
|
Dan Beam
2014/10/20 20:15:25
no curlies
hcarmona
2014/10/21 01:07:17
Acknowledged.
| |
| 678 heads[0].appendChild(noAnimationStyle); | |
| 679 } | |
| 680 }, | |
| 681 | |
| 682 /** | |
| 683 * Even though animation duration and delay is set to zero, it is necessary to | |
| 684 * wait until the animation has finished. | |
| 685 */ | |
| 686 waitForUI: function() { | |
|
Dan Beam
2014/10/20 20:15:25
waitForAnimationsToEnd()
Dan Beam
2014/10/20 20:15:25
can this be tearDown? (so this.waitForAnimationsTo
hcarmona
2014/10/21 01:07:17
Acknowledged.
hcarmona
2014/10/21 01:07:18
Can't be in tearDown because tearDown happens afte
| |
| 687 // add a listener for the transition end event | |
| 688 document.addEventListener('webkitAnimationEnd', function finishTest(e) { | |
|
Dan Beam
2014/10/20 20:15:25
remove "finishTest"
hcarmona
2014/10/21 01:07:18
Acknowledged.
| |
| 689 if (e.target.id == 'more-settings') | |
| 690 testDone(); | |
| 691 }); | |
| 692 }, | |
| 693 }; | |
| 694 | |
| 695 // When the source is 'HTML', we always hide the fit to page option and show | |
| 696 // media size option. | |
| 697 TEST_F('PrintPreviewWebUIAsyncTest', 'SourceIsHTMLCapabilities', function() { | |
| 698 var capsSetEvent = | |
| 699 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 700 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 701 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 702 | |
| 703 var moreSettingsDiv = $('more-settings'); | |
|
Dan Beam
2014/10/20 20:15:25
no reason for "Div" in these names, also no reason
hcarmona
2014/10/21 01:07:18
Acknowledged.
| |
| 704 var mediaSizeDiv = $('media-size-settings'); | |
| 705 var otherOptionsDiv = $('other-options-settings'); | |
| 706 var fitToPageEl = otherOptionsDiv.querySelector('.fit-to-page-container'); | |
| 707 | |
| 708 // Check that options are collapsed (section is visible, because duplex is | |
| 709 // available). | |
| 710 checkSectionVisible(otherOptionsDiv, true); | |
| 711 checkElementDisplayed(fitToPageEl, false); | |
| 712 checkSectionVisible(mediaSizeDiv, false); | |
| 713 // Expand it. | |
| 714 checkSectionVisible(moreSettingsDiv, true); | |
| 715 moreSettingsDiv.click(); | |
| 716 | |
| 717 checkElementDisplayed(fitToPageEl, false); | |
| 718 checkSectionVisible(mediaSizeDiv, true); | |
| 719 | |
| 720 this.waitForUI(); | |
| 721 }); | |
| 722 | |
| 723 // Page layout has zero margins. Hide header and footer option. | |
| 724 TEST_F('PrintPreviewWebUIAsyncTest', 'PageLayoutHasNoMarginsHideHeaderFooter', | |
| 725 function() { | |
| 726 var capsSetEvent = | |
| 727 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 728 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 729 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 730 | |
| 731 var moreSettingsDiv = $('more-settings'); | |
| 732 var otherOptionsDiv = $('other-options-settings'); | |
| 733 var headerFooterEl = | |
| 734 otherOptionsDiv.querySelector('.header-footer-container'); | |
|
Dan Beam
2014/10/20 20:15:25
ugh, this is a pervasive pattern apparently...
hcarmona
2014/10/21 01:07:18
Acknowledged.
| |
| 735 | |
| 736 // Check that options are collapsed (section is visible, because duplex is | |
| 737 // available). | |
| 738 checkSectionVisible(otherOptionsDiv, true); | |
| 739 checkElementDisplayed(headerFooterEl, false); | |
| 740 // Expand it. | |
| 741 checkSectionVisible(moreSettingsDiv, true); | |
| 742 moreSettingsDiv.click(); | |
| 743 | |
| 744 checkElementDisplayed(headerFooterEl, true); | |
| 745 | |
| 746 printPreview.printTicketStore_.marginsType.updateValue( | |
| 747 print_preview.ticket_items.MarginsType.Value.CUSTOM); | |
| 748 printPreview.printTicketStore_.customMargins.updateValue( | |
| 749 new print_preview.Margins(0, 0, 0, 0)); | |
| 750 | |
| 751 checkElementDisplayed(headerFooterEl, false); | |
| 752 | |
| 753 this.waitForUI(); | |
| 754 }); | |
| 755 | |
| 756 // Page layout has half-inch margins. Show header and footer option. | |
| 757 TEST_F('PrintPreviewWebUIAsyncTest', 'PageLayoutHasMarginsShowHeaderFooter', | |
| 758 function() { | |
| 759 var capsSetEvent = | |
| 760 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 761 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 762 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 763 | |
| 764 var moreSettingsDiv = $('more-settings'); | |
| 765 var otherOptionsDiv = $('other-options-settings'); | |
| 766 var headerFooterEl = | |
| 767 otherOptionsDiv.querySelector('.header-footer-container'); | |
| 768 | |
| 769 // Check that options are collapsed (section is visible, because duplex is | |
| 770 // available). | |
| 771 checkSectionVisible(otherOptionsDiv, true); | |
| 772 checkElementDisplayed(headerFooterEl, false); | |
| 773 // Expand it. | |
| 774 checkSectionVisible(moreSettingsDiv, true); | |
| 775 moreSettingsDiv.click(); | |
| 776 | |
| 777 checkElementDisplayed(headerFooterEl, true); | |
| 778 | |
| 779 printPreview.printTicketStore_.marginsType.updateValue( | |
| 780 print_preview.ticket_items.MarginsType.Value.CUSTOM); | |
| 781 printPreview.printTicketStore_.customMargins.updateValue( | |
| 782 new print_preview.Margins(36, 36, 36, 36)); | |
| 783 | |
| 784 checkElementDisplayed(headerFooterEl, true); | |
| 785 | |
| 786 this.waitForUI(); | |
| 787 }); | |
| 788 | |
| 789 // Page layout has zero top and bottom margins. Hide header and footer option. | |
| 790 TEST_F('PrintPreviewWebUIAsyncTest', | |
| 791 'ZeroTopAndBottomMarginsHideHeaderFooter', | |
| 792 function() { | |
| 793 var capsSetEvent = | |
| 794 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 795 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 796 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 797 | |
| 798 var moreSettingsDiv = $('more-settings'); | |
| 799 var otherOptionsDiv = $('other-options-settings'); | |
| 800 var headerFooterEl = | |
| 801 otherOptionsDiv.querySelector('.header-footer-container'); | |
| 802 | |
| 803 // Check that options are collapsed (section is visible, because duplex is | |
| 804 // available). | |
| 805 checkSectionVisible(otherOptionsDiv, true); | |
| 806 checkElementDisplayed(headerFooterEl, false); | |
| 807 // Expand it. | |
| 808 checkSectionVisible(moreSettingsDiv, true); | |
| 809 moreSettingsDiv.click(); | |
| 810 | |
| 811 checkElementDisplayed(headerFooterEl, true); | |
| 812 | |
| 813 printPreview.printTicketStore_.marginsType.updateValue( | |
| 814 print_preview.ticket_items.MarginsType.Value.CUSTOM); | |
| 815 printPreview.printTicketStore_.customMargins.updateValue( | |
| 816 new print_preview.Margins(0, 36, 0, 36)); | |
| 817 | |
| 818 checkElementDisplayed(headerFooterEl, false); | |
| 819 | |
| 820 this.waitForUI(); | |
| 821 }); | |
| 822 | |
| 823 // Page layout has zero top and half-inch bottom margin. Show header and footer | |
| 824 // option. | |
| 825 TEST_F('PrintPreviewWebUIAsyncTest', | |
| 826 'ZeroTopAndNonZeroBottomMarginShowHeaderFooter', | |
| 827 function() { | |
| 828 var capsSetEvent = | |
| 829 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 830 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 831 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 832 | |
| 833 var moreSettingsDiv = $('more-settings'); | |
| 834 var otherOptionsDiv = $('other-options-settings'); | |
| 835 var headerFooterEl = | |
| 836 otherOptionsDiv.querySelector('.header-footer-container'); | |
| 837 | |
| 838 // Check that options are collapsed (section is visible, because duplex is | |
| 839 // available). | |
| 840 checkSectionVisible(otherOptionsDiv, true); | |
| 841 checkElementDisplayed(headerFooterEl, false); | |
| 842 // Expand it. | |
| 843 checkSectionVisible(moreSettingsDiv, true); | |
| 844 moreSettingsDiv.click(); | |
| 845 | |
| 846 checkElementDisplayed(headerFooterEl, true); | |
| 847 | |
| 848 printPreview.printTicketStore_.marginsType.updateValue( | |
| 849 print_preview.ticket_items.MarginsType.Value.CUSTOM); | |
| 850 printPreview.printTicketStore_.customMargins.updateValue( | |
| 851 new print_preview.Margins(0, 36, 36, 36)); | |
| 852 | |
| 853 checkElementDisplayed(headerFooterEl, true); | |
| 854 | |
| 855 this.waitForUI(); | |
| 856 }); | |
| 857 | |
| 858 // Test to verify that duplex settings are set according to the printer | |
| 859 // capabilities. | |
| 860 TEST_F('PrintPreviewWebUIAsyncTest', 'TestDuplexSettingsFalse', function() { | |
| 861 var moreSettingsDiv = $('more-settings'); | |
| 862 var otherOptionsDiv = $('other-options-settings'); | |
| 863 var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); | |
| 864 | |
| 865 var capsSetEvent = | |
| 866 new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | |
| 867 capsSetEvent.settingsInfo = getCddTemplate("FooDevice"); | |
| 868 delete capsSetEvent.settingsInfo.capabilities.printer.duplex; | |
| 869 this.nativeLayer_.dispatchEvent(capsSetEvent); | |
| 870 | |
| 871 // Check that it is collapsed. | |
| 872 checkSectionVisible(otherOptionsDiv, false); | |
| 873 // Expand it. | |
| 874 checkSectionVisible(moreSettingsDiv, true); | |
| 875 moreSettingsDiv.click(); | |
| 876 // Now it should be visible. | |
| 877 checkSectionVisible(otherOptionsDiv, true); | |
| 878 expectTrue(duplexDiv.hidden); | |
| 879 | |
| 880 this.waitForUI(); | |
| 881 }); | |
| 882 | |
|
Dan Beam
2014/10/20 20:15:25
nit: remove \n
hcarmona
2014/10/21 01:07:18
Acknowledged.
| |
| OLD | NEW |