| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 height_microns: 279400, | 345 height_microns: 279400, |
| 346 is_default: true | 346 is_default: true |
| 347 } | 347 } |
| 348 ] | 348 ] |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 }; | 352 }; |
| 353 } | 353 } |
| 354 | 354 |
| 355 // Test restore settings with one destination. |
| 355 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', | 356 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination', |
| 356 function() { | 357 function() { |
| 357 this.initialSettings_.serializedAppStateStr_ = | 358 this.initialSettings_.serializedAppStateStr_ = |
| 358 '{"version":2,"selectedDestinationId":"ID",' + | 359 '{"version":2,"recentDestinationIds":["ID"],' + |
| 359 '"selectedDestinationOrigin":"local"}'; | 360 '"recentDestinationOrigins":["local"]}'; |
| 360 this.setInitialSettings(); | 361 this.setInitialSettings(); |
| 361 | 362 |
| 362 testDone(); | 363 testDone(); |
| 363 }); | 364 }); |
| 364 | 365 |
| 366 //Test with multiple destinations |
| 367 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations', |
| 368 function() { |
| 369 this.initialSettings_.serializedAppStateStr_ = |
| 370 '{"version":2,"recentDestinationIds":["ID1", "ID2", "ID3"],' + |
| 371 '"recentDestinationOrigins":["local", "local", "local"]}'; |
| 372 this.setInitialSettings(); |
| 373 |
| 374 // Set capabilities for the three recently used destinations + 1 more |
| 375 this.setCapabilities(getCddTemplate('ID1')); |
| 376 this.setCapabilities(getCddTemplate('ID2')); |
| 377 this.setCapabilities(getCddTemplate('ID3')); |
| 378 this.setCapabilities(getCddTemplate('ID4')); |
| 379 |
| 380 // The most recently used destination should be the currently selected one. |
| 381 // This is ID1. |
| 382 assertEquals( |
| 383 'ID1', printPreview.destinationStore_.selectedDestination.id); |
| 384 |
| 385 // Look through the destinations. ID1, ID2, and ID3 should all be recent. |
| 386 var destinations = printPreview.destinationStore_.destinations_; |
| 387 var ids_found = []; |
| 388 |
| 389 for (var i = 0; i < destinations.length; i++) { |
| 390 if (!destinations[i]) |
| 391 continue; |
| 392 if (destinations[i].isRecent) |
| 393 ids_found.push(destinations[i].id); |
| 394 } |
| 395 |
| 396 // Make sure there were 3 recent destinations and that they are the correct |
| 397 // IDs. |
| 398 assertEquals(3, ids_found.length); |
| 399 assertNotEquals(-1, ids_found.indexOf("ID1")); |
| 400 assertNotEquals(-1, ids_found.indexOf("ID2")); |
| 401 assertNotEquals(-1, ids_found.indexOf("ID3")); |
| 402 |
| 403 testDone(); |
| 404 }); |
| 405 |
| 365 TEST_F('PrintPreviewWebUITest', | 406 TEST_F('PrintPreviewWebUITest', |
| 366 'TestPrintPreviewDefaultDestinationSelectionRules', function() { | 407 'TestPrintPreviewDefaultDestinationSelectionRules', function() { |
| 367 // It also makes sure these rules do override system default destination. | 408 // It also makes sure these rules do override system default destination. |
| 368 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = | 409 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = |
| 369 '{"namePattern":".*Bar.*"}'; | 410 '{"namePattern":".*Bar.*"}'; |
| 370 this.setInitialSettings(); | 411 this.setInitialSettings(); |
| 371 this.setLocalDestinations(); | 412 this.setLocalDestinations(); |
| 372 | 413 |
| 373 assertEquals( | 414 assertEquals( |
| 374 'BarDevice', printPreview.destinationStore_.selectedDestination.id); | 415 'BarDevice', printPreview.destinationStore_.selectedDestination.id); |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 // appears. | 1134 // appears. |
| 1094 var advancedSettingsCloseButton = $('advanced-settings'). | 1135 var advancedSettingsCloseButton = $('advanced-settings'). |
| 1095 querySelector('.close-button'); | 1136 querySelector('.close-button'); |
| 1096 checkElementDisplayed(advancedSettingsCloseButton, true); | 1137 checkElementDisplayed(advancedSettingsCloseButton, true); |
| 1097 checkElementDisplayed($('advanced-settings'). | 1138 checkElementDisplayed($('advanced-settings'). |
| 1098 querySelector('.search-box-area'), true); | 1139 querySelector('.search-box-area'), true); |
| 1099 | 1140 |
| 1100 this.waitForAnimationToEnd('more-settings'); | 1141 this.waitForAnimationToEnd('more-settings'); |
| 1101 }); | 1142 }); |
| 1102 | 1143 |
| OLD | NEW |