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 this.initialSettings_.serializedAppStateStr_ = | |
|
dpapad
2017/01/13 19:55:10
Let's simplify how serializedAppStateStr_ is popul
rbpotter
2017/01/13 21:25:01
Done.
| |
| 1261 '{"version":2,"recentDestinations":[{"id":"ID1", "origin":"local",' + | |
| 1262 '"account":"",' + | |
| 1263 '"capabilities":' + JSON.stringify(getCddTemplate("ID1")) + | |
| 1264 ', "name":"", "extensionId":"",' + | |
| 1265 '"extensionName":""},' + | |
| 1266 '{"id":"ID2", "origin":"local","account":"",' + | |
| 1267 '"capabilities":' + JSON.stringify(getCddTemplate("ID2")) + | |
| 1268 ', "name":"", "extensionId":"","extensionName":""},' + | |
| 1269 '{"id":"ID3", "origin":"local","account":"",' + | |
| 1270 '"capabilities":' + JSON.stringify(getCddTemplate("ID3")) + | |
| 1271 ', "name":"", "extensionId":"", "extensionName":""}]}'; | |
| 1272 this.setCapabilities(getCddTemplate('ID1')); | |
| 1273 this.setCapabilities(getCddTemplate('ID2')); | |
| 1274 this.setCapabilities(getCddTemplate('ID3')); | |
| 1275 | |
| 1276 var previewGenerator = mock(print_preview.PreviewGenerator); | |
| 1277 printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); | |
| 1278 | |
| 1279 // Initializing print preview initializes documentInfo. This triggers | |
|
dpapad
2017/01/13 19:55:10
This wall of text is a bit hard to read. Can you a
rbpotter
2017/01/13 21:25:02
Done. Let me know if it is still unclear or should
dpapad
2017/01/13 21:37:40
The text is fine now, I can read it with less effo
rbpotter
2017/01/13 22:52:19
Yes. requestPreview() checks a number of condition
| |
| 1280 // TicketItem.CHANGE events from all 10 ticket items that depend on | |
| 1281 // documentInfo. 2 additional TicketItem.CHANGE events are dispatched by the | |
| 1282 // headerFooter ticket item since it issues a change event each time | |
| 1283 // marginsType and customMargins do. A documentInfo.CHANGE event is also | |
| 1284 // dispatched. All these events trigger a call to requestPreview = 13 total. | |
| 1285 // When the initial destination is selected, this triggers a | |
| 1286 // CAPABILITIES_CHANGE event and 4 TicketItem.CHANGE events from the 4 ticket | |
| 1287 // items that depend on destinationStore = 5 additional requestPreview calls. | |
| 1288 // These 18 calls result in 1 startPreview call as the destination must be | |
| 1289 // initialized before it will be called. | |
| 1290 // This checks that only 1 CAPABILITIES_CHANGE event is issued in print | |
| 1291 // preview initialization so that we do not end up with 2 startPreview calls. | |
| 1292 // If more events are triggered, there will be additional calls to | |
| 1293 // requestPreview that will trigger additional calls to startPreview. | |
| 1294 // Multiple startPreview creates a race condition: see crbug.com/666595. | |
| 1295 previewGenerator.expects(exactly(18)).requestPreview(); | |
| 1296 | |
| 1297 this.setInitialSettings(); | |
| 1298 testDone(); | |
| 1299 }); | |
| OLD | NEW |