Chromium Code Reviews| 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..6dbeb06b277f8fd2bf48f6537c2c81ff30edbc98 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. |
| + 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.
|
| + '{"version":2,"recentDestinations":[{"id":"ID1", "origin":"local",' + |
| + '"account":"",' + |
| + '"capabilities":' + JSON.stringify(getCddTemplate("ID1")) + |
| + ', "name":"", "extensionId":"",' + |
| + '"extensionName":""},' + |
| + '{"id":"ID2", "origin":"local","account":"",' + |
| + '"capabilities":' + JSON.stringify(getCddTemplate("ID2")) + |
| + ', "name":"", "extensionId":"","extensionName":""},' + |
| + '{"id":"ID3", "origin":"local","account":"",' + |
| + '"capabilities":' + JSON.stringify(getCddTemplate("ID3")) + |
| + ', "name":"", "extensionId":"", "extensionName":""}]}'; |
| + this.setCapabilities(getCddTemplate('ID1')); |
| + this.setCapabilities(getCddTemplate('ID2')); |
| + this.setCapabilities(getCddTemplate('ID3')); |
| + |
| + var previewGenerator = mock(print_preview.PreviewGenerator); |
| + printPreview.previewArea_.previewGenerator_ = previewGenerator.proxy(); |
| + |
| + // 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
|
| + // TicketItem.CHANGE events from all 10 ticket items that depend on |
| + // documentInfo. 2 additional TicketItem.CHANGE events are dispatched by the |
| + // headerFooter ticket item since it issues a change event each time |
| + // marginsType and customMargins do. A documentInfo.CHANGE event is also |
| + // dispatched. All these events trigger a call to requestPreview = 13 total. |
| + // When the initial destination is selected, this triggers a |
| + // CAPABILITIES_CHANGE event and 4 TicketItem.CHANGE events from the 4 ticket |
| + // items that depend on destinationStore = 5 additional requestPreview calls. |
| + // These 18 calls result in 1 startPreview call as the destination must be |
| + // initialized before it will be called. |
| + // This checks that only 1 CAPABILITIES_CHANGE event is issued in print |
| + // preview initialization so that we do not end up with 2 startPreview calls. |
| + // If more events are triggered, there will be additional calls to |
| + // requestPreview that will trigger additional calls to startPreview. |
| + // Multiple startPreview creates a race condition: see crbug.com/666595. |
| + previewGenerator.expects(exactly(18)).requestPreview(); |
| + |
| + this.setInitialSettings(); |
| + testDone(); |
| +}); |