Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: chrome/test/data/webui/print_preview/print_preview_tests.js

Issue 2962983002: Print Preview: change getPreview to cr.sendWithPromise (Closed)
Patch Set: Re-comment test Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 9af4ebd350e6e2dff3a1b83f49099b8dd6b7aa65..586203be15df1af419effe91c2dcdd121cf40acf 100644
--- a/chrome/test/data/webui/print_preview/print_preview_tests.js
+++ b/chrome/test/data/webui/print_preview/print_preview_tests.js
@@ -1059,13 +1059,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');
@@ -1075,7 +1080,6 @@ cr.define('print_preview_test', function() {
]
};
nativeLayer.setLocalDestinationCapabilities(device);
-
// Select BarDevice
var barDestination =
printPreview.destinationStore_.destinations().find(
@@ -1085,7 +1089,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);
});
});
@@ -1233,16 +1241,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.
rbpotter 2017/06/29 01:13:53 Note: This always catches the bug linked, as the c
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);
});
});
@@ -1323,18 +1336,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);
});
});
« no previous file with comments | « chrome/test/data/webui/print_preview/native_layer_stub.js ('k') | components/printing/common/print_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698