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

Unified Diff: chrome/test/data/webui/print_preview.js

Issue 2346153002: Save most recent 3 destinations across multiple sessions (Closed)
Patch Set: 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
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..ad2afdebac1158cc7a2292a0450fe539cf4bd269 100644
--- a/chrome/test/data/webui/print_preview.js
+++ b/chrome/test/data/webui/print_preview.js
@@ -352,16 +352,57 @@ 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,"recentDestinationIds":["ID"],' +
+ '"recentDestinationOrigins":["local"]}';
this.setInitialSettings();
testDone();
});
+//Test with multiple destinations
+TEST_F('PrintPreviewWebUITest', 'TestPrintPreviewRestoreMultipleDestinations',
+ function() {
+ this.initialSettings_.serializedAppStateStr_ =
+ '{"version":2,"recentDestinationIds":["ID1", "ID2", "ID3"],' +
+ '"recentDestinationOrigins":["local", "local", "local"]}';
+ 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.

Powered by Google App Engine
This is Rietveld 408576698