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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 GEN('#include "base/feature_list.h"'); 5 GEN('#include "base/feature_list.h"');
6 GEN('#include "chrome/common/chrome_features.h"'); 6 GEN('#include "chrome/common/chrome_features.h"');
7 7
8 /** 8 /**
9 * Test fixture for print preview WebUI testing. 9 * Test fixture for print preview WebUI testing.
10 * @constructor 10 * @constructor
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 // appears. 1246 // appears.
1247 var advancedSettingsCloseButton = $('advanced-settings'). 1247 var advancedSettingsCloseButton = $('advanced-settings').
1248 querySelector('.close-button'); 1248 querySelector('.close-button');
1249 checkElementDisplayed(advancedSettingsCloseButton, true); 1249 checkElementDisplayed(advancedSettingsCloseButton, true);
1250 checkElementDisplayed($('advanced-settings'). 1250 checkElementDisplayed($('advanced-settings').
1251 querySelector('.search-box-area'), true); 1251 querySelector('.search-box-area'), true);
1252 1252
1253 this.waitForAnimationToEnd('more-settings'); 1253 this.waitForAnimationToEnd('more-settings');
1254 }); 1254 });
1255 1255
1256 // Test that initialization with saved destination only issues one call
1257 // to startPreview.
1258 TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() {
1259 // Load in a bunch of recent destinations with non null capabilities.
1260 var initSettings = {
1261 version: 2,
1262 recentDestinations: [1, 2, 3].map(function(i) {
1263 return {
1264 id: 'ID' + i, origin: 'local', account: '',
1265 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.
1266 extensionId: '', extensionName: ''
1267 };
1268 }),
1269 };
1270 this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings);
1271 this.setCapabilities(getCddTemplate('ID1'));
1272 this.setCapabilities(getCddTemplate('ID2'));
1273 this.setCapabilities(getCddTemplate('ID3'));
1274
1275 var previewGenerator = mock(print_preview.PreviewGenerator);
1276 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy();
1277
1278 // On initialization we expect 18 calls to requestPreview. requestPreview
1279 // is called each time a ticket item that updates the preview changes and
1280 // each time there is a DocumentInfo.CHANGE event or a CAPABILITIES_CHANGE
1281 // event. So we have:
1282 // - 1 call from documentInfo initialization (triggers DocumentInfo.CHANGE).
1283 // - 10 calls from Ticket item updates triggered by the DocumentInfo.CHANGE.
1284 // - 2 calls from HeaderFooter ticket item updates triggered by the updates
1285 // to marginsType and customMargins ticket items.
1286 // - 1 call from CAPABILITIES_CHANGE event called from setting the
1287 // destination.
1288 // - 4 calls from ticket item updates that are triggered by the
1289 // CAPABILITIES_CHANGE event.
1290 // == 18 calls total.
1291 // If more calls occur, this indicates that additional CAPABILITIES_CHANGE or
1292 // DocumentInfo.CHANGE events may have been fired. This would cause multiple
1293 // startPreview calls will be issued from requestPreview, which leads to
1294 // a race condition: see crbug.com/666595.
1295 previewGenerator.expects(exactly(18)).requestPreview();
1296
1297 this.setInitialSettings();
1298 testDone();
1299 });
OLDNEW
« 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