Index: chrome/browser/resources/print_preview/print_preview.js |
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js |
index ac3a0ab789135db2746d6fe3b522398b759867d9..b3dd3b4564b2c0f86ea93c0fea2c06ed1e42fb86 100644 |
--- a/chrome/browser/resources/print_preview/print_preview.js |
+++ b/chrome/browser/resources/print_preview/print_preview.js |
@@ -285,7 +285,10 @@ cr.define('print_preview', function() { |
this.nativeLayer_, |
print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, |
this.onPrivetPrintFailed_.bind(this)); |
- |
+ this.tracker.add( |
+ this.nativeLayer_, |
+ print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST, |
+ this.onManipulateSettingsForTest_.bind(this)); |
this.tracker.add( |
$('system-dialog-link'), |
@@ -691,6 +694,9 @@ cr.define('print_preview', function() { |
onPreviewGenerationDone_: function() { |
this.isPreviewGenerationInProgress_ = false; |
this.printHeader_.isPrintButtonEnabled = true; |
+ if (global['onManipulateSettingsForTest']) { |
+ this.nativeLayer_.doneManipulatingSettings(); |
Aleksey Shlyapnikov
2014/06/18 21:57:35
Call it this.nativeLayer_.previewReady(), call it
ivandavid
2014/06/20 01:00:26
Done.
|
+ } |
this.printIfReady_(); |
}, |
@@ -889,6 +895,71 @@ cr.define('print_preview', function() { |
localStrings.getString('couldNotPrint')); |
}, |
+ onManipulateSettingsForTest_: function(event) { |
+ if (event.messageName == 'SAVE_AS_PDF') { |
+ this.destinationStore_.selectDefaultDestination_(); |
+ } |
+ else if (event.messageName == 'LAYOUT_SETTINGS') { |
+ var layoutChoice = event.isPortrait ? |
+ 'layout-settings-portrait-radio' : |
+ 'layout-settings-landscape-radio'; |
+ |
+ var element = document.getElementsByClassName(layoutChoice)[0]; |
+ if (element) { |
+ element.click(); |
Aleksey Shlyapnikov
2014/06/18 21:57:36
What if it is already selected?
ivandavid
2014/06/20 01:00:25
Done.
ivandavid
2014/06/20 01:00:26
I rewrote it so that if it is already selected, it
|
+ } else { |
+ this.nativeLayer_.doneManipulatingSettings(); |
+ } |
Aleksey Shlyapnikov
2014/06/18 21:57:36
So if element is not there, test assumes that ever
ivandavid
2014/06/20 01:00:25
I rewrote this so that if the element == null, the
ivandavid
2014/06/20 01:00:26
Done.
|
+ } |
+ else if (event.messageName == 'PAGE_NUMBERS') { |
+ if (event.pageNumbers != '') { |
+ var pageSettingsCustomInput = document.getElementsByClassName( |
+ 'page-settings-custom-input')[0]; |
+ if (pageSettingsCustomInput) { |
+ pageSettingsCustomInput.value = event.pageSettings; |
Aleksey Shlyapnikov
2014/06/18 21:57:36
What if it's the same, does it still trigger the p
ivandavid
2014/06/20 01:00:26
I am actually not sure. I rewrote this entire sect
ivandavid
2014/06/20 01:00:26
Done.
|
+ } |
+ } else { |
+ this.nativeLayer_.doneManipulatingSettings(); |
Aleksey Shlyapnikov
2014/06/18 21:57:36
But nothing was actually done, why do we notify he
ivandavid
2014/06/20 01:00:26
Done.
|
+ } |
+ } |
+ else if (event.messageName == 'HEADERS_AND_FOOTERS') { |
+ var checkbox = document.getElementsByClassName( |
+ 'header-footer-checkbox')[0]; |
+ if (checkbox) { |
+ if ((event.headersAndFooters && checkbox.checked) || |
Aleksey Shlyapnikov
2014/06/18 21:57:36
Why this condition is in brackets and other is not
ivandavid
2014/06/20 01:00:26
Fixed it. It was a typo.
ivandavid
2014/06/20 01:00:26
Done.
|
+ !event.headersAndFooters && !checkbox.checked) { |
Aleksey Shlyapnikov
2014/06/18 21:57:36
Why not just (event.headersAndFooters == checkbox.
ivandavid
2014/06/20 01:00:25
Fixed in patch set 13. Same change made for the ot
ivandavid
2014/06/20 01:00:25
Done.
|
+ this.nativeLayer_.doneManipulatingSettings(); |
+ } else { |
+ this.otherOptionsSettings_.headerFooterCheckbox_.click(); |
Aleksey Shlyapnikov
2014/06/18 21:57:35
You have your checkbox already, why refer to this.
ivandavid
2014/06/20 01:00:25
Done.
|
+ } |
+ } |
+ } |
+ else if (event.messageName == 'BACKGROUND_COLORS_AND_IMAGES') { |
+ var checkbox = document.getElementsByClassName( |
+ 'css-background-checkbox')[0]; |
+ if (checkbox) { |
+ if ((event.backgroundColorsAndImages && checkbox.checked) || |
+ !event.backgroundColorsAndImages && !checkbox.checked) { |
+ this.nativeLayer_.doneManipulatingSettings(); |
+ } |
+ else { |
+ this.otherOptionsSettings_.cssBackgroundCheckbox_.click(); |
+ } |
+ } |
+ } |
+ else if (event.messageName == 'MARGINS') { |
Aleksey Shlyapnikov
2014/06/18 21:57:36
Move all elses to the same line with {
ivandavid
2014/06/20 01:00:26
Done.
|
+ var marginSettingsSelect = |
+ document.getElementsByClassName('margin-settings-select')[0]; |
+ var index = parseInt(event.margins, 10); |
+ if (marginSettingsSelect && index != 0) { |
Aleksey Shlyapnikov
2014/06/18 21:57:36
Zero index is still valid. Use isNaN to check for
ivandavid
2014/06/20 01:00:26
Rewrote this entire section to account for this an
|
+ marginSettingsSelect.selectedIndex = index; |
+ this.marginSettings_.onSelectChange_(); |
+ } else { |
+ this.nativeLayer_.doneManipulatingSettings(); |
+ } |
+ } |
+ }, |
+ |
/** |
* Called when the open-cloud-print-dialog link is clicked. Opens the Google |
* Cloud Print web dialog. |