Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 }); | |
| OLD | NEW |