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

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 some whitespace issues and rewrote lines that were over 80 characters long. 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..633309f5668a1d99996cda86e161ddb2560b32d2 100644
--- a/chrome/browser/resources/print_preview/native_layer.js
+++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -46,6 +46,8 @@ cr.define('print_preview', function() {
global['onPrivetCapabilitiesSet'] =
this.onPrivetCapabilitiesSet_.bind(this);
global['onPrivetPrintFailed'] = this.onPrivetPrintFailed_.bind(this);
+ global['onEnableManipulateSettingsForTest'] =
+ this.onEnableManipulateSettingsForTest_.bind(this);
};
/**
@@ -77,7 +79,9 @@ 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_FOR_TEST:
+ 'print_preview.NativeLayer.MANIPULATE_SETTINGS_FOR_TEST'
};
/**
@@ -672,6 +676,47 @@ 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.
+ */
+ onEnableManipulateSettingsForTest_: function() {
+ global['onManipulateSettingsForTest'] =
+ this.onManipulateSettingsForTest_.bind(this);
+ },
+
+ /**
+ * Function that dispatches an event to print_preview.js to change
+ * a particular setting for print preview.
+ * @param {Dictionary} settings Dictionary containing the value to be
+ * changed and that value should be set to.
+ */
+ onManipulateSettingsForTest_: function(settings) {
+ var manipulateSettingsEvent =
+ new Event(NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST);
+ manipulateSettingsEvent.settings = settings;
+ this.dispatchEvent(manipulateSettingsEvent);
+ },
+
+ /**
+ * Function that sends a message to the test, letting it know that an
+ * option has been set to a particular value and that the change has
+ * finished modifying the preview area.
+ */
+ previewReady: function() {
+ if (global['onManipulateSettingsForTest']) {
+ chrome.send('UILoadedForTest');
+ }
+ },
+
+ /**
+ * Function that notifies the test that the option it tried to change
+ * had not been changed successfully.
+ */
+ previewFailed: function() {
ivandavid 2014/06/20 01:00:26 Test will assert false when this happens, causing
+ chrome.send('UIFailedLoadingForTest');
}
};

Powered by Google App Engine
This is Rietveld 408576698