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

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: Clarify comment and change settings construction 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 1ed192e674149d91c9ae2fb8536fb8ebef68a5bd..9ef1745d187c98ea5d1df651243ecee46bc7ed4c 100644
--- a/chrome/test/data/webui/print_preview.js
+++ b/chrome/test/data/webui/print_preview.js
@@ -1253,3 +1253,47 @@ 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 initSettings = {
+ version: 2,
+ recentDestinations: [1, 2, 3].map(function(i) {
+ return {
+ id: 'ID' + i, origin: 'local', account: '',
+ capabilities: JSON.stringify(getCddTemplate('ID' + i)), name: '',
dpapad 2017/01/13 21:37:41 capabilities is JSONified twice now? I would expec
rbpotter 2017/01/13 22:52:19 Done.
+ extensionId: '', extensionName: ''
+ };
+ }),
+ };
+ this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings);
+ this.setCapabilities(getCddTemplate('ID1'));
+ this.setCapabilities(getCddTemplate('ID2'));
+ this.setCapabilities(getCddTemplate('ID3'));
+
+ var previewGenerator = mock(print_preview.PreviewGenerator);
+ printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy();
+
+ // On initialization we expect 18 calls to requestPreview. requestPreview
+ // is called each time a ticket item that updates the preview changes and
+ // each time there is a DocumentInfo.CHANGE event or a CAPABILITIES_CHANGE
+ // event. So we have:
+ // - 1 call from documentInfo initialization (triggers DocumentInfo.CHANGE).
+ // - 10 calls from Ticket item updates triggered by the DocumentInfo.CHANGE.
+ // - 2 calls from HeaderFooter ticket item updates triggered by the updates
+ // to marginsType and customMargins ticket items.
+ // - 1 call from CAPABILITIES_CHANGE event called from setting the
+ // destination.
+ // - 4 calls from ticket item updates that are triggered by the
+ // CAPABILITIES_CHANGE event.
+ // == 18 calls total.
+ // If more calls occur, this indicates that additional CAPABILITIES_CHANGE or
+ // DocumentInfo.CHANGE events may have been fired. This would cause multiple
+ // startPreview calls will be issued from requestPreview, which leads to
+ // a race condition: see crbug.com/666595.
+ previewGenerator.expects(exactly(18)).requestPreview();
+
+ this.setInitialSettings();
+ 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