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

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

Issue 2628393002: Print Preview: Add test to ensure only 1 preview is started at init (Closed)
Patch Set: Fix nits Created 3 years, 11 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 | « no previous file | 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 4d7659bcd3d5f27e054e495e7ae05ad776920dd5..767082358a853c09fb502da8a827993b7a012b95 100644
--- a/chrome/test/data/webui/print_preview.js
+++ b/chrome/test/data/webui/print_preview.js
@@ -93,7 +93,8 @@ PrintPreviewWebUITest.prototype = {
startGetLocalDestinations: function() {},
startGetPrivetDestinations: function() {},
startGetExtensionDestinations: function() {},
- startGetLocalDestinationCapabilities: function(destinationId) {}
+ startGetLocalDestinationCapabilities: function(destinationId) {},
+ startGetPreview: function() {},
};
var oldNativeLayerEventType = print_preview.NativeLayer.EventType;
var oldDuplexMode = print_preview.NativeLayer.DuplexMode;
@@ -1279,3 +1280,41 @@ TEST_F('PrintPreviewWebUITest', 'TestAdvancedSettings2Options', function() {
this.waitForAnimationToEnd('more-settings');
});
+
+// Test that initialization with saved destination only issues one call
+// to startPreview.
+TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() {
+ // Load in a bunch of recent destinations with non null capabilities.
+ var origin = cr.isChromeOS ? 'chrome_os' : 'local';
+ var initSettings = {
+ version: 2,
+ recentDestinations: [1, 2, 3].map(function(i) {
+ return {
+ id: 'ID' + i, origin: origin, account: '',
+ capabilities: getCddTemplate('ID' + i), name: '',
+ extensionId: '', extensionName: ''
+ };
+ }),
+ };
+ this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings);
+ this.setCapabilities(getCddTemplate('ID1'));
+ this.setCapabilities(getCddTemplate('ID2'));
+ this.setCapabilities(getCddTemplate('ID3'));
+
+ // Use a real preview generator.
+ printPreview.previewArea_.previewGenerator_ =
+ new print_preview.PreviewGenerator(printPreview.destinationStore_,
+ printPreview.printTicketStore_, this.nativeLayer_,
+ printPreview.documentInfo_);
+
+ // Preview generator starts out with inFlightRequestId_ == -1. The id
+ // increments by 1 for each startGetPreview call it makes. It should only
+ // make one such call during initialization or there will be a race; see
+ // crbug.com/666595
+ expectEquals(printPreview.previewArea_.previewGenerator_.inFlightRequestId_,
+ -1);
+ this.setInitialSettings();
+ expectEquals(printPreview.previewArea_.previewGenerator_.inFlightRequestId_,
+ 0);
+ testDone();
+});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698