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 4d7659bcd3d5f27e054e495e7ae05ad776920dd5..72799562b21f3a88cacf64c45d6302673fdc92b0 100644 |
| --- a/chrome/test/data/webui/print_preview.js |
| +++ b/chrome/test/data/webui/print_preview.js |
| @@ -93,7 +93,8 @@ PrintPreviewWebUITest.prototype = { |
| startGetLocalDestinations: function() {}, |
| startGetPrivetDestinations: function() {}, |
| startGetExtensionDestinations: function() {}, |
| - startGetLocalDestinationCapabilities: function(destinationId) {} |
| + startGetLocalDestinationCapabilities: function(destinationId) {}, |
| + startGetPreview: function() {}, |
| }; |
| var oldNativeLayerEventType = print_preview.NativeLayer.EventType; |
| var oldDuplexMode = print_preview.NativeLayer.DuplexMode; |
| @@ -1279,3 +1280,41 @@ 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. |
| + origin = cr.isChromeOS ? 'chrome_os' : 'local'; |
|
dpapad
2017/01/14 02:37:00
var origin
rbpotter
2017/01/17 19:51:24
Done.
|
| + var initSettings = { |
| + version: 2, |
| + recentDestinations: [1, 2, 3].map(function(i) { |
| + return { |
| + id: 'ID' + i, origin: origin, account: '', |
| + capabilities: getCddTemplate('ID' + i), name: '', |
| + extensionId: '', extensionName: '' |
| + }; |
| + }), |
| + }; |
| + this.initialSettings_.serializedAppStateStr_ = JSON.stringify(initSettings); |
| + this.setCapabilities(getCddTemplate('ID1')); |
| + this.setCapabilities(getCddTemplate('ID2')); |
| + this.setCapabilities(getCddTemplate('ID3')); |
| + |
| + // Use a real preview generator. |
| + printPreview.previewArea_.previewGenerator_ = |
| + new print_preview.PreviewGenerator(printPreview.destinationStore_, |
|
dpapad
2017/01/14 02:37:00
indent off by -2
rbpotter
2017/01/17 19:51:24
Done.
|
| + printPreview.printTicketStore_, this.nativeLayer_, |
| + printPreview.documentInfo_); |
| + |
| + // Preview generator starts out with inFlightRequestId_ == -1. The id |
| + // increments by 1 for each startGetPreview call it makes. It should only |
| + // make one such call during initialization or there will be a race; see |
| + // crbug.com/666595 |
| + expectEquals(printPreview.previewArea_.previewGenerator_.inFlightRequestId_, |
| + -1); |
| + this.setInitialSettings(); |
| + expectEquals(printPreview.previewArea_.previewGenerator_.inFlightRequestId_, |
| + 0); |
| + testDone(); |
| +}); |