Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/test/data/webui/print_preview.js

Issue 2346153002: Save most recent 3 destinations across multiple sessions (Closed)
Patch Set: Add check for bad struct read in Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/print_preview/data/destination_store.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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,"recentDestinations":[{"id":"ID", "origin":"local",' +
359 '"selectedDestinationOrigin":"local"}'; 360 '"account":"", "capabilities":0, "name":"", "extensionId":"",' +
361 '"extensionName":""}]}';
360 this.setInitialSettings(); 362 this.setInitialSettings();
361 363
362 testDone(); 364 testDone();
363 }); 365 });
364 366
367 //Test with multiple destinations
368 TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations',
369 function() {
370 this.initialSettings_.serializedAppStateStr_ =
371 '{"version":2,"recentDestinations":[{"id":"ID1", "origin":"local",' +
372 '"account":"", "capabilities":0, "name":"", "extensionId":"",' +
373 '"extensionName":""},' +
374 '{"id":"ID2", "origin":"local",' +
375 '"account":"", "capabilities":0, "name":"", "extensionId":"",' +
376 '"extensionName":""},' +
377 '{"id":"ID3", "origin":"local",' +
378 '"account":"", "capabilities":0, "name":"", "extensionId":"",' +
379 '"extensionName":""}]}';
380 this.setInitialSettings();
381
382 // Set capabilities for the three recently used destinations + 1 more
383 this.setCapabilities(getCddTemplate('ID1'));
384 this.setCapabilities(getCddTemplate('ID2'));
385 this.setCapabilities(getCddTemplate('ID3'));
386 this.setCapabilities(getCddTemplate('ID4'));
387
388 // The most recently used destination should be the currently selected one.
389 // This is ID1.
390 assertEquals(
391 'ID1', printPreview.destinationStore_.selectedDestination.id);
392
393 // Look through the destinations. ID1, ID2, and ID3 should all be recent.
394 var destinations = printPreview.destinationStore_.destinations_;
395 var ids_found = [];
396
397 for (var i = 0; i < destinations.length; i++) {
398 if (!destinations[i])
399 continue;
400 if (destinations[i].isRecent)
401 ids_found.push(destinations[i].id);
402 }
403
404 // Make sure there were 3 recent destinations and that they are the correct
405 // IDs.
406 assertEquals(3, ids_found.length);
407 assertNotEquals(-1, ids_found.indexOf("ID1"));
408 assertNotEquals(-1, ids_found.indexOf("ID2"));
409 assertNotEquals(-1, ids_found.indexOf("ID3"));
410
411 testDone();
412 });
413
365 TEST_F('PrintPreviewWebUITest', 414 TEST_F('PrintPreviewWebUITest',
366 'TestPrintPreviewDefaultDestinationSelectionRules', function() { 415 'TestPrintPreviewDefaultDestinationSelectionRules', function() {
367 // It also makes sure these rules do override system default destination. 416 // It also makes sure these rules do override system default destination.
368 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ = 417 this.initialSettings_.serializedDefaultDestinationSelectionRulesStr_ =
369 '{"namePattern":".*Bar.*"}'; 418 '{"namePattern":".*Bar.*"}';
370 this.setInitialSettings(); 419 this.setInitialSettings();
371 this.setLocalDestinations(); 420 this.setLocalDestinations();
372 421
373 assertEquals( 422 assertEquals(
374 'BarDevice', printPreview.destinationStore_.selectedDestination.id); 423 'BarDevice', printPreview.destinationStore_.selectedDestination.id);
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 // appears. 1142 // appears.
1094 var advancedSettingsCloseButton = $('advanced-settings'). 1143 var advancedSettingsCloseButton = $('advanced-settings').
1095 querySelector('.close-button'); 1144 querySelector('.close-button');
1096 checkElementDisplayed(advancedSettingsCloseButton, true); 1145 checkElementDisplayed(advancedSettingsCloseButton, true);
1097 checkElementDisplayed($('advanced-settings'). 1146 checkElementDisplayed($('advanced-settings').
1098 querySelector('.search-box-area'), true); 1147 querySelector('.search-box-area'), true);
1099 1148
1100 this.waitForAnimationToEnd('more-settings'); 1149 this.waitForAnimationToEnd('more-settings');
1101 }); 1150 });
1102 1151
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/data/destination_store.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698