| Index: chrome/test/data/webui/print_preview/print_preview_tests.js
|
| diff --git a/chrome/test/data/webui/print_preview/print_preview_tests.js b/chrome/test/data/webui/print_preview/print_preview_tests.js
|
| index e06412d99c6407c2405f337f36cab1141d0bc5a4..0a394ab8afa941df7e3ac8f41a5707c045fe46d5 100644
|
| --- a/chrome/test/data/webui/print_preview/print_preview_tests.js
|
| +++ b/chrome/test/data/webui/print_preview/print_preview_tests.js
|
| @@ -1079,13 +1079,18 @@ cr.define('print_preview_test', function() {
|
|
|
| // Test that changing the selected printer updates the preview.
|
| test('PrinterChangeUpdatesPreview', function() {
|
| - return setupSettingsAndDestinationsWithCapabilities().then(function() {
|
| - var previewGenerator = mock(print_preview.PreviewGenerator);
|
| - previewArea.previewGenerator_ = previewGenerator.proxy();
|
| + // Preview generator
|
| + previewArea.previewGenerator_ =
|
| + new print_preview.PreviewGenerator(printPreview.destinationStore_,
|
| + printPreview.printTicketStore_, nativeLayer,
|
| + printPreview.documentInfo_);
|
|
|
| - // The number of settings that can change due to a change in the
|
| - // destination that will therefore dispatch ticket item change events.
|
| - previewGenerator.expects(exactly(9)).requestPreview();
|
| + return setupSettingsAndDestinationsWithCapabilities().then(function() {
|
| + return nativeLayer.whenCalled('getPreview');
|
| + }).then(function(args0) {
|
| + expectEquals(0, args0.requestId);
|
| + expectEquals('FooDevice', args0.destination.id);
|
| + nativeLayer.resetResolver('getPreview');
|
|
|
| // Setup capabilities for BarDevice.
|
| var device = getCddTemplate('BarDevice');
|
| @@ -1095,7 +1100,6 @@ cr.define('print_preview_test', function() {
|
| ]
|
| };
|
| nativeLayer.setLocalDestinationCapabilities(device);
|
| -
|
| // Select BarDevice
|
| var barDestination =
|
| printPreview.destinationStore_.destinations().find(
|
| @@ -1105,7 +1109,11 @@ cr.define('print_preview_test', function() {
|
| printPreview.destinationStore_.selectDestination(barDestination);
|
| return nativeLayer.whenCalled('getPrinterCapabilities', 'BarDevice');
|
| }).then(function(){
|
| - return whenAnimationDone('more-settings');
|
| + // Verify new preview is requested with new ID and destination.
|
| + return nativeLayer.whenCalled('getPreview');
|
| + }).then(function(args1) {
|
| + expectEquals(1, args1.requestId);
|
| + expectEquals('BarDevice', args1.destination.id);
|
| });
|
| });
|
|
|
| @@ -1253,16 +1261,21 @@ cr.define('print_preview_test', function() {
|
| printPreview.printTicketStore_, 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(-1, previewArea.previewGenerator_.inFlightRequestId_);
|
| + // For crbug.com/666595. If multiple destinations are fetched there may
|
| + // be multiple preview requests. This verifies the first fetch is for
|
| + // ID1, which ensures no other destinations are fetched earlier. The last
|
| + // destination retrieved before timeout will end up in the preview
|
| + // request. Ensure this is also ID1.
|
| setInitialSettings();
|
| - return nativeLayer.whenCalled('getInitialSettings').then(function() {
|
| - return nativeLayer.whenCalled('getPrinterCapabilities', 'ID1');
|
| - }).then(function() {
|
| - expectEquals(0, previewArea.previewGenerator_.inFlightRequestId_);
|
| + var initialSettingsSet = nativeLayer.whenCalled('getInitialSettings');
|
| + return initialSettingsSet.then(function() {
|
| + return nativeLayer.whenCalled('getPrinterCapabilities');
|
| + }).then(function(id) {
|
| + expectEquals('ID1', id);
|
| + return nativeLayer.whenCalled('getPreview');
|
| + }).then(function(preview_args) {
|
| + expectEquals(0, preview_args.requestId);
|
| + expectEquals('ID1', preview_args.destination.id);
|
| });
|
| });
|
|
|
| @@ -1367,18 +1380,29 @@ cr.define('print_preview_test', function() {
|
| printPreview.printTicketStore_, nativeLayer,
|
| printPreview.documentInfo_);
|
| return setupSettingsAndDestinationsWithCapabilities().then(function() {
|
| + return nativeLayer.whenCalled('getPreview');
|
| + }).then(function(args0) {
|
| // The first request should generate draft because there was no
|
| // previous print preview draft.
|
| - expectTrue(nativeLayer.generateDraft());
|
| + expectTrue(args0.generateDraft);
|
| + expectEquals(0, args0.requestId);
|
| + nativeLayer.resetResolver('getPreview');
|
|
|
| // Change the page range - no new draft needed.
|
| printPreview.printTicketStore_.pageRange.updateValue('2');
|
| - expectFalse(nativeLayer.generateDraft());
|
| + return nativeLayer.whenCalled('getPreview');
|
| + }).then(function(args1) {
|
| + expectFalse(args1.generateDraft);
|
| + expectEquals(1, args1.requestId);
|
| + nativeLayer.resetResolver('getPreview');
|
|
|
| // Change the margin type - need to regenerate again.
|
| printPreview.printTicketStore_.marginsType.updateValue(
|
| print_preview.ticket_items.MarginsTypeValue.NO_MARGINS);
|
| - expectTrue(nativeLayer.generateDraft());
|
| + return nativeLayer.whenCalled('getPreview');
|
| + }).then(function(args2) {
|
| + expectTrue(args2.generateDraft);
|
| + expectEquals(2, args2.requestId);
|
| });
|
| });
|
|
|
|
|