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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/print_preview.js
diff --git a/chrome/test/data/webui/print_preview.js b/chrome/test/data/webui/print_preview.js
index 4f63f1e48e9f405981d308b7725f25115e569d98..bf411ed8c8c76bfa85bb63d82ff2a9ed7ec2f061 100644
--- a/chrome/test/data/webui/print_preview.js
+++ b/chrome/test/data/webui/print_preview.js
@@ -352,16 +352,65 @@ function getCddTemplate(printerId) {
};
}
+// Test restore settings with one destination.
TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreLocalDestination',
function() {
this.initialSettings_.serializedAppStateStr_ =
- '{"version":2,"selectedDestinationId":"ID",' +
- '"selectedDestinationOrigin":"local"}';
+ '{"version":2,"recentDestinations":[{"id":"ID", "origin":"local",' +
+ '"account":"", "capabilities":0, "name":"", "extensionId":"",' +
+ '"extensionName":""}]}';
this.setInitialSettings();
testDone();
});
+//Test with multiple destinations
+TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations',
+ function() {
+ this.initialSettings_.serializedAppStateStr_ =
+ '{"version":2,"recentDestinations":[{"id":"ID1", "origin":"local",' +
+ '"account":"", "capabilities":0, "name":"", "extensionId":"",' +
+ '"extensionName":""},' +
+ '{"id":"ID2", "origin":"local",' +
+ '"account":"", "capabilities":0, "name":"", "extensionId":"",' +
+ '"extensionName":""},' +
+ '{"id":"ID3", "origin":"local",' +
+ '"account":"", "capabilities":0, "name":"", "extensionId":"",' +
+ '"extensionName":""}]}';
+ this.setInitialSettings();
+
+ // Set capabilities for the three recently used destinations + 1 more
+ this.setCapabilities(getCddTemplate('ID1'));
+ this.setCapabilities(getCddTemplate('ID2'));
+ this.setCapabilities(getCddTemplate('ID3'));
+ this.setCapabilities(getCddTemplate('ID4'));
+
+ // The most recently used destination should be the currently selected one.
+ // This is ID1.
+ assertEquals(
+ 'ID1', printPreview.destinationStore_.selectedDestination.id);
+
+ // Look through the destinations. ID1, ID2, and ID3 should all be recent.
+ var destinations = printPreview.destinationStore_.destinations_;
+ var ids_found = [];
+
+ for (var i = 0; i < destinations.length; i++) {
+ if (!destinations[i])
+ continue;
+ if (destinations[i].isRecent)
+ ids_found.push(destinations[i].id);
+ }
+
+ // Make sure there were 3 recent destinations and that they are the correct
+ // IDs.
+ assertEquals(3, ids_found.length);
+ assertNotEquals(-1, ids_found.indexOf("ID1"));
+ assertNotEquals(-1, ids_found.indexOf("ID2"));
+ assertNotEquals(-1, ids_found.indexOf("ID3"));
+
+ testDone();
+});
+
TEST_F('PrintPreviewWebUITest',
'TestPrintPreviewDefaultDestinationSelectionRules', function() {
// It also makes sure these rules do override system default destination.
« 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