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

Unified Diff: chrome/browser/resources/print_preview/native_layer.js

Issue 335583004: Added a test that currently is able to print to pdf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed style issues and made the testing functionality optional Created 6 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/browser/resources/print_preview/native_layer.js
diff --git a/chrome/browser/resources/print_preview/native_layer.js b/chrome/browser/resources/print_preview/native_layer.js
index efdd55b36073695ca5a34c475a299e408e7ea0a9..522915110a475a9abb82a6c9480178b75f0b76d1 100644
--- a/chrome/browser/resources/print_preview/native_layer.js
+++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -46,6 +46,9 @@ cr.define('print_preview', function() {
global['onPrivetCapabilitiesSet'] =
this.onPrivetCapabilitiesSet_.bind(this);
global['onPrivetPrintFailed'] = this.onPrivetPrintFailed_.bind(this);
+ global['onEnableManipulateSettings'] =
ivandavid 2014/06/17 22:59:16 Allows the native layer to send a message to print
+ this.onEnableManipulateSettings_.bind(this);
+ //global['onManipulateSettings'] = this.onManipulateSettings_.bind(this);
};
/**
@@ -77,7 +80,8 @@ cr.define('print_preview', function() {
PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED',
PRIVET_CAPABILITIES_SET:
'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET',
- PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED'
+ PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED',
+ MANIPULATE_SETTINGS: 'print_preview.NativeLayer.MANIPULATE_SETTINGS'
};
/**
@@ -672,6 +676,49 @@ cr.define('print_preview', function() {
new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED);
privetPrintFailedEvent.httpError = http_error;
this.dispatchEvent(privetPrintFailedEvent);
+ },
+
+ /**
+ * Function that allows for onManipulateSettings to be called
+ * from the native layer, specifically during testing.
Lei Zhang 2014/06/17 23:22:20 specifically -> only? Maybe onEnableManipulateSett
+ */
+ onEnableManipulateSettings_: function() {
ivandavid 2014/06/17 22:59:16 See comment for line 49.
+ global['onManipulateSettings'] =
+ this.onManipulateSettings_.bind(this);
+ },
+
+ /**
+ * Function call from browsertest to start clicking certain buttons.
+ * @param {string} messageName The setting that is to be manipulated,
+ * such as the layout settings, or page numbers
+ * @param {string, boolean, undefined} Is the value that we want to
+ * set the particular setting to. For layout settings, page numbers,
+ * and margins, its a string. For 'headers and footers' and
+ * 'background colors and images,' its a boolean. For Save as PDF,
+ * its undefined as it isn't needed.
+ */
+ onManipulateSettings_: function(messageName, parameter) {
+ var manipulateSettingsEvent =
+ new Event(NativeLayer.EventType.MANIPULATE_SETTINGS);
+ manipulateSettingsEvent.messageName = messageName;
+ if (messageName == 'SAVE_AS_PDF') {
+ }
+ else if (messageName == 'LAYOUT_SETTINGS') {
+ manipulateSettingsEvent.layoutSettings = parameter;
+ }
+ else if (messageName == 'PAGE_NUMBERS') {
+ manipulateSettingsEvent.pageNumbers = parameter;
+ }
+ else if (messageName == 'HEADERS_AND_FOOTERS') {
+ manipulateSettingsEvent.headersAndFooters = parameter;
+ }
+ else if (messageName == 'BACKGROUND_COLORS_AND_IMAGES') {
+ manipulateSettingsEvent.backgroundColorsAndImages = parameter;
+ }
+ else if (messageName == 'MARGINS') {
+ manipulateSettingsEvent.margins = parameter;
+ }
+ this.dispatchEvent(manipulateSettingsEvent);
}
};

Powered by Google App Engine
This is Rietveld 408576698