| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 243   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 243   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 244   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 244   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 245 | 245 | 
| 246   checkSectionVisible($('layout-settings'), true); | 246   checkSectionVisible($('layout-settings'), true); | 
| 247   checkSectionVisible($('color-settings'), true); | 247   checkSectionVisible($('color-settings'), true); | 
| 248   checkSectionVisible($('copies-settings'), true); | 248   checkSectionVisible($('copies-settings'), true); | 
| 249 | 249 | 
| 250   var capsSetEvent = | 250   var capsSetEvent = | 
| 251       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 251       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 252   capsSetEvent.settingsInfo = { | 252   capsSetEvent.settingsInfo = { | 
|  | 253     'printerId': 'FooDevice', | 
| 253     'disableColorOption': true, | 254     'disableColorOption': true, | 
| 254     'setColorAsDefault': true, | 255     'setColorAsDefault': true, | 
| 255     'disableCopiesOption': true, | 256     'disableCopiesOption': true, | 
| 256     'disableLandscapeOption': true, | 257     'disableLandscapeOption': true, | 
| 257     'printerDefaultDuplexValue': 0 | 258     'printerDefaultDuplexValue': 0 | 
| 258   }; | 259   }; | 
| 259   this.nativeLayer_.dispatchEvent(capsSetEvent); | 260   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 260 | 261 | 
| 261   checkSectionVisible($('layout-settings'), false); | 262   checkSectionVisible($('layout-settings'), false); | 
| 262   checkSectionVisible($('color-settings'), false); | 263   checkSectionVisible($('color-settings'), false); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 280   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 281   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 
| 281 | 282 | 
| 282   var localDestsSetEvent = | 283   var localDestsSetEvent = | 
| 283       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 284       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 
| 284   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 285   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 285   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 286   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 286 | 287 | 
| 287   var capsSetEvent = | 288   var capsSetEvent = | 
| 288       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 289       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 289   capsSetEvent.settingsInfo = { | 290   capsSetEvent.settingsInfo = { | 
|  | 291     'printerId': 'FooDevice', | 
| 290     'disableColorOption': false, | 292     'disableColorOption': false, | 
| 291     'setColorAsDefault': true, | 293     'setColorAsDefault': true, | 
| 292     'disableCopiesOption': true, | 294     'disableCopiesOption': true, | 
| 293     'disableLandscapeOption': true, | 295     'disableLandscapeOption': true, | 
| 294     'printerDefaultDuplexValue': 0 | 296     'printerDefaultDuplexValue': 0 | 
| 295   }; | 297   }; | 
| 296   this.nativeLayer_.dispatchEvent(capsSetEvent); | 298   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 297 | 299 | 
| 298   checkElementDisplayed( | 300   checkElementDisplayed( | 
| 299       $('other-options-settings').querySelector('.fit-to-page-container'), | 301       $('other-options-settings').querySelector('.fit-to-page-container'), | 
| 300       false); | 302       false); | 
| 301 }); | 303 }); | 
| 302 | 304 | 
| 303 // When the source is 'HTML', we always hide the fit to page option. | 305 // When the source is 'HTML', we always hide the fit to page option. | 
| 304 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLHideFitToPageOption', function() { | 306 TEST_F('PrintPreviewWebUITest', 'SourceIsHTMLHideFitToPageOption', function() { | 
| 305   var initialSettingsSetEvent = | 307   var initialSettingsSetEvent = | 
| 306       new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 308       new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 
| 307   initialSettingsSetEvent.initialSettings = this.initialSettings_; | 309   initialSettingsSetEvent.initialSettings = this.initialSettings_; | 
| 308   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 310   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 
| 309 | 311 | 
| 310   var localDestsSetEvent = | 312   var localDestsSetEvent = | 
| 311       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 313       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 
| 312   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 314   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 313   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 315   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 314 | 316 | 
| 315   var capsSetEvent = | 317   var capsSetEvent = | 
| 316       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 318       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 317   capsSetEvent.settingsInfo = { | 319   capsSetEvent.settingsInfo = { | 
|  | 320     'printerId': 'FooDevice', | 
| 318     'disableColorOption': false, | 321     'disableColorOption': false, | 
| 319     'setColorAsDefault': true, | 322     'setColorAsDefault': true, | 
| 320     'disableCopiesOption': true, | 323     'disableCopiesOption': true, | 
| 321     'disableLandscapeOption': true, | 324     'disableLandscapeOption': true, | 
| 322     'printerDefaultDuplexValue': 0 | 325     'printerDefaultDuplexValue': 0 | 
| 323   }; | 326   }; | 
| 324   this.nativeLayer_.dispatchEvent(capsSetEvent); | 327   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 325 | 328 | 
| 326   checkElementDisplayed( | 329   checkElementDisplayed( | 
| 327       $('other-options-settings').querySelector('.fit-to-page-container'), | 330       $('other-options-settings').querySelector('.fit-to-page-container'), | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 339   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 342   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 
| 340 | 343 | 
| 341   var localDestsSetEvent = | 344   var localDestsSetEvent = | 
| 342       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 345       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 
| 343   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 346   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 344   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 347   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 345 | 348 | 
| 346   var capsSetEvent = | 349   var capsSetEvent = | 
| 347       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 350       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 348   capsSetEvent.settingsInfo = { | 351   capsSetEvent.settingsInfo = { | 
|  | 352     'printerId': 'FooDevice', | 
| 349     'disableColorOption': false, | 353     'disableColorOption': false, | 
| 350     'setColorAsDefault': true, | 354     'setColorAsDefault': true, | 
| 351     'disableCopiesOption': true, | 355     'disableCopiesOption': true, | 
| 352     'disableLandscapeOption': true, | 356     'disableLandscapeOption': true, | 
| 353     'printerDefaultDuplexValue': 0 | 357     'printerDefaultDuplexValue': 0 | 
| 354   }; | 358   }; | 
| 355   this.nativeLayer_.dispatchEvent(capsSetEvent); | 359   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 356 | 360 | 
| 357   checkElementDisplayed( | 361   checkElementDisplayed( | 
| 358       $('other-options-settings').querySelector('.fit-to-page-container'), | 362       $('other-options-settings').querySelector('.fit-to-page-container'), | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 373   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 377   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 
| 374 | 378 | 
| 375   var localDestsSetEvent = | 379   var localDestsSetEvent = | 
| 376       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 380       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 
| 377   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 381   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 378   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 382   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 379 | 383 | 
| 380   var capsSetEvent = | 384   var capsSetEvent = | 
| 381       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 385       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 382   capsSetEvent.settingsInfo = { | 386   capsSetEvent.settingsInfo = { | 
|  | 387     'printerId': 'FooDevice', | 
| 383     'disableColorOption': false, | 388     'disableColorOption': false, | 
| 384     'setColorAsDefault': true, | 389     'setColorAsDefault': true, | 
| 385     'disableCopiesOption': true, | 390     'disableCopiesOption': true, | 
| 386     'disableLandscapeOption': true, | 391     'disableLandscapeOption': true, | 
| 387     'printerDefaultDuplexValue': 0 | 392     'printerDefaultDuplexValue': 0 | 
| 388   }; | 393   }; | 
| 389   this.nativeLayer_.dispatchEvent(capsSetEvent); | 394   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 390 | 395 | 
| 391   // Indicate that the PDF does not support scaling by default. | 396   // Indicate that the PDF does not support scaling by default. | 
| 392   cr.dispatchSimpleEvent( | 397   cr.dispatchSimpleEvent( | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 410   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 415   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 
| 411 | 416 | 
| 412   var localDestsSetEvent = | 417   var localDestsSetEvent = | 
| 413       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 418       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 
| 414   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 419   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 415   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 420   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 416 | 421 | 
| 417   var capsSetEvent = | 422   var capsSetEvent = | 
| 418       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 423       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 419   capsSetEvent.settingsInfo = { | 424   capsSetEvent.settingsInfo = { | 
|  | 425     'printerId': 'FooDevice', | 
| 420     'disableColorOption': false, | 426     'disableColorOption': false, | 
| 421     'setColorAsDefault': true, | 427     'setColorAsDefault': true, | 
| 422     'disableCopiesOption': true, | 428     'disableCopiesOption': true, | 
| 423     'disableLandscapeOption': true, | 429     'disableLandscapeOption': true, | 
| 424     'printerDefaultDuplexValue': 0 | 430     'printerDefaultDuplexValue': 0 | 
| 425   }; | 431   }; | 
| 426   this.nativeLayer_.dispatchEvent(capsSetEvent); | 432   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 427 | 433 | 
| 428   checkElementDisplayed( | 434   checkElementDisplayed( | 
| 429       $('other-options-settings').querySelector('.header-footer-container'), | 435       $('other-options-settings').querySelector('.header-footer-container'), | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 449   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 455   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 
| 450 | 456 | 
| 451   var localDestsSetEvent = | 457   var localDestsSetEvent = | 
| 452       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 458       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 
| 453   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 459   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 454   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 460   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 455 | 461 | 
| 456   var capsSetEvent = | 462   var capsSetEvent = | 
| 457       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 463       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 458   capsSetEvent.settingsInfo = { | 464   capsSetEvent.settingsInfo = { | 
|  | 465     'printerId': 'FooDevice', | 
| 459     'disableColorOption': false, | 466     'disableColorOption': false, | 
| 460     'setColorAsDefault': true, | 467     'setColorAsDefault': true, | 
| 461     'disableCopiesOption': true, | 468     'disableCopiesOption': true, | 
| 462     'disableLandscapeOption': true, | 469     'disableLandscapeOption': true, | 
| 463     'printerDefaultDuplexValue': 0 | 470     'printerDefaultDuplexValue': 0 | 
| 464   }; | 471   }; | 
| 465   this.nativeLayer_.dispatchEvent(capsSetEvent); | 472   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 466 | 473 | 
| 467   checkElementDisplayed( | 474   checkElementDisplayed( | 
| 468       $('other-options-settings').querySelector('.header-footer-container'), | 475       $('other-options-settings').querySelector('.header-footer-container'), | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 488   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 495   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 
| 489 | 496 | 
| 490   var localDestsSetEvent = | 497   var localDestsSetEvent = | 
| 491       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 498       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 
| 492   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 499   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 493   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 500   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 494 | 501 | 
| 495   var capsSetEvent = | 502   var capsSetEvent = | 
| 496       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 503       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 497   capsSetEvent.settingsInfo = { | 504   capsSetEvent.settingsInfo = { | 
|  | 505     'printerId': 'FooDevice', | 
| 498     'disableColorOption': false, | 506     'disableColorOption': false, | 
| 499     'setColorAsDefault': true, | 507     'setColorAsDefault': true, | 
| 500     'disableCopiesOption': true, | 508     'disableCopiesOption': true, | 
| 501     'disableLandscapeOption': true, | 509     'disableLandscapeOption': true, | 
| 502     'printerDefaultDuplexValue': 0 | 510     'printerDefaultDuplexValue': 0 | 
| 503   }; | 511   }; | 
| 504   this.nativeLayer_.dispatchEvent(capsSetEvent); | 512   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 505 | 513 | 
| 506   checkElementDisplayed( | 514   checkElementDisplayed( | 
| 507       $('other-options-settings').querySelector('.header-footer-container'), | 515       $('other-options-settings').querySelector('.header-footer-container'), | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 528   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 536   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 
| 529 | 537 | 
| 530   var localDestsSetEvent = | 538   var localDestsSetEvent = | 
| 531       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 539       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 
| 532   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 540   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 533   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 541   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 534 | 542 | 
| 535   var capsSetEvent = | 543   var capsSetEvent = | 
| 536       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 544       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 537   capsSetEvent.settingsInfo = { | 545   capsSetEvent.settingsInfo = { | 
|  | 546     'printerId': 'FooDevice', | 
| 538     'disableColorOption': false, | 547     'disableColorOption': false, | 
| 539     'setColorAsDefault': true, | 548     'setColorAsDefault': true, | 
| 540     'disableCopiesOption': true, | 549     'disableCopiesOption': true, | 
| 541     'disableLandscapeOption': true, | 550     'disableLandscapeOption': true, | 
| 542     'printerDefaultDuplexValue': 0 | 551     'printerDefaultDuplexValue': 0 | 
| 543   }; | 552   }; | 
| 544   this.nativeLayer_.dispatchEvent(capsSetEvent); | 553   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 545 | 554 | 
| 546   checkElementDisplayed( | 555   checkElementDisplayed( | 
| 547       $('other-options-settings').querySelector('.header-footer-container'), | 556       $('other-options-settings').querySelector('.header-footer-container'), | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 567   var localDestsSetEvent = | 576   var localDestsSetEvent = | 
| 568       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 577       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 
| 569   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 578   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 570   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 579   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 571 | 580 | 
| 572   checkSectionVisible($('color-settings'), true); | 581   checkSectionVisible($('color-settings'), true); | 
| 573 | 582 | 
| 574   var capsSetEvent = | 583   var capsSetEvent = | 
| 575       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 584       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 576   capsSetEvent.settingsInfo = { | 585   capsSetEvent.settingsInfo = { | 
|  | 586     'printerId': 'FooDevice', | 
| 577     'disableColorOption': false, | 587     'disableColorOption': false, | 
| 578     'setColorAsDefault': true, | 588     'setColorAsDefault': true, | 
| 579     'disableCopiesOption': true, | 589     'disableCopiesOption': true, | 
| 580     'disableLandscapeOption': true, | 590     'disableLandscapeOption': true, | 
| 581     'printerDefaultDuplexValue': 0 | 591     'printerDefaultDuplexValue': 0 | 
| 582   }; | 592   }; | 
| 583   this.nativeLayer_.dispatchEvent(capsSetEvent); | 593   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 584 | 594 | 
| 585   checkSectionVisible($('color-settings'), true); | 595   checkSectionVisible($('color-settings'), true); | 
| 586 | 596 | 
| 587   var colorOption = $('color-settings').getElementsByClassName( | 597   var colorOption = $('color-settings').getElementsByClassName( | 
| 588       'color-settings-color-option')[0]; | 598       'color-settings-color-option')[0]; | 
| 589   var bwOption = $('color-settings').getElementsByClassName( | 599   var bwOption = $('color-settings').getElementsByClassName( | 
| 590       'color-settings-bw-option')[0]; | 600       'color-settings-bw-option')[0]; | 
| 591   expectTrue(colorOption.checked); | 601   expectTrue(colorOption.checked); | 
| 592   expectFalse(bwOption.checked); | 602   expectFalse(bwOption.checked); | 
| 593 | 603 | 
| 594   var capsSetEvent = | 604   var capsSetEvent = | 
| 595       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 605       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 596   capsSetEvent.settingsInfo = { | 606   capsSetEvent.settingsInfo = { | 
|  | 607     'printerId': 'FooDevice', | 
| 597     'disableColorOption': false, | 608     'disableColorOption': false, | 
| 598     'setColorAsDefault': false, | 609     'setColorAsDefault': false, | 
| 599     'disableCopiesOption': false, | 610     'disableCopiesOption': false, | 
| 600     'disableLandscapeOption': false, | 611     'disableLandscapeOption': false, | 
| 601     'printerDefaultDuplexValue': 0 | 612     'printerDefaultDuplexValue': 0 | 
| 602   }; | 613   }; | 
| 603   this.nativeLayer_.dispatchEvent(capsSetEvent); | 614   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 604 | 615 | 
| 605   checkSectionVisible($('color-settings'), true); | 616   checkSectionVisible($('color-settings'), true); | 
| 606   expectFalse(colorOption.checked); | 617   expectFalse(colorOption.checked); | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 633   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 644   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 634   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 645   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 635 | 646 | 
| 636   var otherOptionsDiv = $('other-options-settings'); | 647   var otherOptionsDiv = $('other-options-settings'); | 
| 637   var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); | 648   var duplexDiv = otherOptionsDiv.querySelector('.duplex-container'); | 
| 638   var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox'); | 649   var duplexCheckbox = otherOptionsDiv.querySelector('.duplex-checkbox'); | 
| 639 | 650 | 
| 640   var capsSetEvent = | 651   var capsSetEvent = | 
| 641       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 652       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 642   capsSetEvent.settingsInfo = { | 653   capsSetEvent.settingsInfo = { | 
|  | 654     'printerId': 'FooDevice', | 
| 643     'disableColorOption': false, | 655     'disableColorOption': false, | 
| 644     'setColorAsDefault': true, | 656     'setColorAsDefault': true, | 
| 645     'disableCopiesOption': false, | 657     'disableCopiesOption': false, | 
| 646     'disableLandscapeOption': true, | 658     'disableLandscapeOption': true, | 
| 647     'printerDefaultDuplexValue': 0 | 659     'printerDefaultDuplexValue': 0 | 
| 648   }; | 660   }; | 
| 649   this.nativeLayer_.dispatchEvent(capsSetEvent); | 661   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 650 | 662 | 
| 651   checkSectionVisible(otherOptionsDiv, true); | 663   checkSectionVisible(otherOptionsDiv, true); | 
| 652   expectFalse(duplexDiv.hidden); | 664   expectFalse(duplexDiv.hidden); | 
| 653   expectFalse(duplexCheckbox.checked); | 665   expectFalse(duplexCheckbox.checked); | 
| 654 | 666 | 
| 655   // If the printer default duplex value is UNKNOWN_DUPLEX_MODE, hide the | 667   // If the printer default duplex value is UNKNOWN_DUPLEX_MODE, hide the | 
| 656   // two sided option. | 668   // two sided option. | 
| 657   var capsSetEvent = | 669   var capsSetEvent = | 
| 658       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 670       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 659   capsSetEvent.settingsInfo = { | 671   capsSetEvent.settingsInfo = { | 
|  | 672     'printerId': 'FooDevice', | 
| 660     'disableColorOption': false, | 673     'disableColorOption': false, | 
| 661     'setColorAsDefault': false, | 674     'setColorAsDefault': false, | 
| 662     'disableCopiesOption': false, | 675     'disableCopiesOption': false, | 
| 663     'disableLandscapeOption': false, | 676     'disableLandscapeOption': false, | 
| 664     'printerDefaultDuplexValue': -1 | 677     'printerDefaultDuplexValue': -1 | 
| 665   }; | 678   }; | 
| 666   this.nativeLayer_.dispatchEvent(capsSetEvent); | 679   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 667 | 680 | 
| 668   checkSectionVisible(otherOptionsDiv, true); | 681   checkSectionVisible(otherOptionsDiv, true); | 
| 669   expectTrue(duplexDiv.hidden); | 682   expectTrue(duplexDiv.hidden); | 
| 670 | 683 | 
| 671   var capsSetEvent = | 684   var capsSetEvent = | 
| 672       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 685       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 673   capsSetEvent.settingsInfo = { | 686   capsSetEvent.settingsInfo = { | 
|  | 687     'printerId': 'FooDevice', | 
| 674     'disableColorOption': false, | 688     'disableColorOption': false, | 
| 675     'setColorAsDefault': false, | 689     'setColorAsDefault': false, | 
| 676     'disableCopiesOption': false, | 690     'disableCopiesOption': false, | 
| 677     'disableLandscapeOption': false, | 691     'disableLandscapeOption': false, | 
| 678     'printerDefaultDuplexValue': 1 | 692     'printerDefaultDuplexValue': 1 | 
| 679   }; | 693   }; | 
| 680   this.nativeLayer_.dispatchEvent(capsSetEvent); | 694   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 681 | 695 | 
| 682   checkSectionVisible(otherOptionsDiv, true); | 696   checkSectionVisible(otherOptionsDiv, true); | 
| 683   expectFalse(duplexDiv.hidden); | 697   expectFalse(duplexDiv.hidden); | 
| 684   expectTrue(duplexCheckbox.checked); | 698   expectTrue(duplexCheckbox.checked); | 
| 685 }); | 699 }); | 
| 686 | 700 | 
| 687 // Test that changing the selected printer updates the preview. | 701 // Test that changing the selected printer updates the preview. | 
| 688 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { | 702 TEST_F('PrintPreviewWebUITest', 'TestPrinterChangeUpdatesPreview', function() { | 
| 689 | 703 | 
| 690   var initialSettingsSetEvent = | 704   var initialSettingsSetEvent = | 
| 691       new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 705       new cr.Event(print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET); | 
| 692   initialSettingsSetEvent.initialSettings = this.initialSettings_; | 706   initialSettingsSetEvent.initialSettings = this.initialSettings_; | 
| 693   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 707   this.nativeLayer_.dispatchEvent(initialSettingsSetEvent); | 
| 694 | 708 | 
| 695   var localDestsSetEvent = | 709   var localDestsSetEvent = | 
| 696       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 710       new cr.Event(print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET); | 
| 697   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 711   localDestsSetEvent.destinationInfos = this.localDestinationInfos_; | 
| 698   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 712   this.nativeLayer_.dispatchEvent(localDestsSetEvent); | 
| 699 | 713 | 
| 700   var capsSetEvent = | 714   var capsSetEvent = | 
| 701       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 715       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 702   capsSetEvent.settingsInfo = { | 716   capsSetEvent.settingsInfo = { | 
|  | 717     'printerId': 'FooDevice', | 
| 703     'disableColorOption': false, | 718     'disableColorOption': false, | 
| 704     'setColorAsDefault': true, | 719     'setColorAsDefault': true, | 
| 705     'disableCopiesOption': true, | 720     'disableCopiesOption': true, | 
| 706     'disableLandscapeOption': true, | 721     'disableLandscapeOption': true, | 
| 707     'printerDefaultDuplexValue': 0 | 722     'printerDefaultDuplexValue': 0 | 
| 708   }; | 723   }; | 
| 709   this.nativeLayer_.dispatchEvent(capsSetEvent); | 724   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 710 | 725 | 
| 711   var previewGenerator = mock(print_preview.PreviewGenerator); | 726   var previewGenerator = mock(print_preview.PreviewGenerator); | 
| 712   printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); | 727   printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); | 
| 713   previewGenerator.expects(once()).requestPreview(); | 728   previewGenerator.expects(once()).requestPreview(); | 
| 714 | 729 | 
| 715   var barDestination; | 730   var barDestination; | 
| 716   var destinations = printPreview.destinationStore_.destinations; | 731   var destinations = printPreview.destinationStore_.destinations; | 
| 717   for (var destination, i = 0; destination = destinations[i]; i++) { | 732   for (var destination, i = 0; destination = destinations[i]; i++) { | 
| 718     if (destination.id == 'BarDevice') { | 733     if (destination.id == 'BarDevice') { | 
| 719       barDestination = destination; | 734       barDestination = destination; | 
| 720       break; | 735       break; | 
| 721     } | 736     } | 
| 722   } | 737   } | 
| 723 | 738 | 
| 724   printPreview.destinationStore_.selectDestination(barDestination); | 739   printPreview.destinationStore_.selectDestination(barDestination); | 
| 725 | 740 | 
| 726   var capsSetEvent = | 741   var capsSetEvent = | 
| 727       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 742       new cr.Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET); | 
| 728   capsSetEvent.settingsInfo = { | 743   capsSetEvent.settingsInfo = { | 
|  | 744     'printerId': 'BarDevice', | 
| 729     'disableColorOption': true, | 745     'disableColorOption': true, | 
| 730     'setColorAsDefault': false, | 746     'setColorAsDefault': false, | 
| 731     'disableCopiesOption': true, | 747     'disableCopiesOption': true, | 
| 732     'disableLandscapeOption': true, | 748     'disableLandscapeOption': true, | 
| 733     'printerDefaultDuplexValue': 0 | 749     'printerDefaultDuplexValue': 0 | 
| 734   }; | 750   }; | 
| 735   this.nativeLayer_.dispatchEvent(capsSetEvent); | 751   this.nativeLayer_.dispatchEvent(capsSetEvent); | 
| 736 }); | 752 }); | 
| 737 | 753 | 
| 738 // Test that error message is displayed when plugin doesn't exist. | 754 // Test that error message is displayed when plugin doesn't exist. | 
| 739 TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() { | 755 TEST_F('PrintPreviewWebUITest', 'TestNoPDFPluginErrorMessage', function() { | 
| 740   var previewAreaEl = $('preview-area'); | 756   var previewAreaEl = $('preview-area'); | 
| 741 | 757 | 
| 742   var loadingMessageEl = | 758   var loadingMessageEl = | 
| 743       previewAreaEl.getElementsByClassName('preview-area-loading-message')[0]; | 759       previewAreaEl.getElementsByClassName('preview-area-loading-message')[0]; | 
| 744   expectEquals(true, loadingMessageEl.hidden); | 760   expectEquals(true, loadingMessageEl.hidden); | 
| 745 | 761 | 
| 746   var previewFailedMessageEl = previewAreaEl.getElementsByClassName( | 762   var previewFailedMessageEl = previewAreaEl.getElementsByClassName( | 
| 747       'preview-area-preview-failed-message')[0]; | 763       'preview-area-preview-failed-message')[0]; | 
| 748   expectEquals(true, previewFailedMessageEl.hidden); | 764   expectEquals(true, previewFailedMessageEl.hidden); | 
| 749 | 765 | 
| 750   var printFailedMessageEl = | 766   var printFailedMessageEl = | 
| 751       previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; | 767       previewAreaEl.getElementsByClassName('preview-area-print-failed')[0]; | 
| 752   expectEquals(true, printFailedMessageEl.hidden); | 768   expectEquals(true, printFailedMessageEl.hidden); | 
| 753 | 769 | 
| 754   var customMessageEl = | 770   var customMessageEl = | 
| 755       previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; | 771       previewAreaEl.getElementsByClassName('preview-area-custom-message')[0]; | 
| 756   expectEquals(false, customMessageEl.hidden); | 772   expectEquals(false, customMessageEl.hidden); | 
| 757 }); | 773 }); | 
| OLD | NEW | 
|---|