| 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..767082358a853c09fb502da8a827993b7a012b95 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.
|
| + var origin = cr.isChromeOS ? 'chrome_os' : 'local';
|
| + 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_,
|
| + 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();
|
| +});
|
|
|