Chromium Code Reviews| 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..d69ec668b0b9cddb3b3a0dd2142cf5b1a8b352c8 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' |
| }; |
| /** |
| @@ -373,6 +377,10 @@ cr.define('print_preview', function() { |
| chrome.send('forceOpenNewTab', [url]); |
| }, |
| + doneManipulatingSettings: function() { |
| + chrome.send('UILoadedForTest'); |
| + }, |
| + |
| /** |
| * @param {!Object} initialSettings Object containing all initial settings. |
| */ |
| @@ -672,6 +680,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. |
| + */ |
| + onEnableManipulateSettingsForTest_: function() { |
| + global['onManipulateSettingsForTest'] = |
| + this.onManipulateSettingsForTest_.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. |
| + */ |
| + onManipulateSettingsForTest_: function(messageName, parameter) { |
| + var manipulateSettingsEvent = |
| + new Event(NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST); |
| + manipulateSettingsEvent.messageName = messageName; |
| + if (messageName == 'SAVE_AS_PDF') { |
| + } |
| + else if (messageName == 'LAYOUT_SETTINGS') { |
| + manipulateSettingsEvent.isPortrait = 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') { |
|
Aleksey Shlyapnikov
2014/06/18 21:57:35
Move all elses on the same line with }
ivandavid
2014/06/20 01:00:25
Done.
|
| + manipulateSettingsEvent.margins = parameter; |
| + } |
|
Aleksey Shlyapnikov
2014/06/18 21:57:35
Why not pass a dictionary here (for example, simil
ivandavid
2014/06/20 01:00:25
Done.
|
| + this.dispatchEvent(manipulateSettingsEvent); |
| } |
| }; |