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

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

Issue 2961773003: Print Preview: Update test to check parameters sent to print() (Closed)
Patch Set: Address comments 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..3a928392bc82ed30f9c2fc9d13963b631a3ddd94 100644
--- a/chrome/test/data/webui/print_preview/print_preview_tests.js
+++ b/chrome/test/data/webui/print_preview/print_preview_tests.js
@@ -144,6 +144,31 @@ cr.define('print_preview_test', function() {
};
}
+ /**
+ * Get the default media size for |device|.
+ * @param {!print_preview.PrinterCapabilitiesResponse} device
+ * @return {width_microns: number,
dpapad 2017/06/28 01:28:34 Nit: return {{...}} I think there is a set of bra
rbpotter 2017/06/28 02:36:27 Done.
+ * height_microns: number} The width and height of the default
+ * media.
+ */
+ function getDefaultMediaSize(device) {
+ var size = device.capabilities.printer.media_size.option.find(
+ function(opt) { return opt.is_default; });
+ return { width_microns: size.width_microns,
+ height_microns: size.height_microns };
+ }
+
+ /**
+ * Get the default page orientation for |device|.
+ * @param {!print_preview.PrinterCapabilitiesResponse} device
+ * @return {string} The default orientation.
+ */
+ function getDefaultOrientation(device) {
+ return device.capabilities.printer.page_orientation.option.find(
+ function(opt) { return opt.is_default; }).type;
+ }
+
+
/**
* @param {string} printerId
* @return {!Object}
@@ -1293,8 +1318,8 @@ cr.define('print_preview_test', function() {
return d.id == 'BarDevice';
});
- nativeLayer.setLocalDestinationCapabilities(
- getCddTemplate('BarDevice'));
+ var barDevice = getCddTemplate('BarDevice');
+ nativeLayer.setLocalDestinationCapabilities(barDevice);
printPreview.destinationStore_.selectDestination(barDestination);
return nativeLayer.whenCalled('getPrinterCapabilities', 'BarDevice')
@@ -1309,7 +1334,30 @@ cr.define('print_preview_test', function() {
expectFalse(printButton.disabled);
printButton.click();
// This should result in a call to print.
- return nativeLayer.whenCalled('print');
+ return nativeLayer.whenCalled('print').then(
+ /**
+ * @param {destination: !print_preview.Destination,
+ * printTicketStore: !print_preview.PrintTicketStore,
+ * cloudPrintInterface: print_preview
+ * .CloudPrintInterface,
+ * documentInfo: print_preview.DocumentInfo} args
+ * The arguments that print() was called with.
+ */
+ function(args) {
+ // Sanity check some printing argument values.
+ var printTicketStore = args.printTicketStore;
+ expectEquals(args.destination.id, barDevice.printerId);
+ expectEquals(printTicketStore.landscape.getValue(),
dpapad 2017/06/28 01:28:34 Nit: According to the docs, expected value goes fi
rbpotter 2017/06/28 02:36:27 Done.
+ getDefaultOrientation(barDevice) == 'LANDSCAPE');
+ expectEquals(printTicketStore.copies.getValueAsNumber(), 1);
+ var media_default = getDefaultMediaSize(barDevice);
dpapad 2017/06/28 01:28:34 s/media_default/mediaDefault
rbpotter 2017/06/28 02:36:27 Done.
+ expectEquals(
+ printTicketStore.mediaSize.getValue().width_microns,
+ media_default.width_microns);
+ expectEquals(
+ printTicketStore.mediaSize.getValue().height_microns,
+ media_default.height_microns);
+ });
});
});
});

Powered by Google App Engine
This is Rietveld 408576698