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

Unified Diff: chrome/browser/resources/print_preview/print_preview.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: Made browsertest assume layout test launched it. Fixed style and consistency issues in javascript files. 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/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..00aec0ad2ba9b3133c6896f003d5b9561be0f2e5 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,7 @@ cr.define('print_preview', function() {
onPreviewGenerationDone_: function() {
this.isPreviewGenerationInProgress_ = false;
this.printHeader_.isPrintButtonEnabled = true;
+ this.nativeLayer_.previewReadyForTest();
this.printIfReady_();
},
@@ -890,6 +894,70 @@ cr.define('print_preview', function() {
},
/**
+ * Called when the print preview settings need to be changed for testing.
+ * @param {Event} event Event object that contains the option that is to
+ * be changed and what to set that option.
+ * @private
+ */
+ onManipulateSettingsForTest_: function(event) {
+ if ('selectSaveAsPdfDestination' in event.settings) {
+ var destinations = this.destinationStore_.destinations();
+ var pdfDestination = null;
+ for (var i = 0; i < destinations.length; i++) {
+ if (destinations[i].id ==
+ print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) {
+ pdfDestination = destinations[i];
+ break;
+ }
+ }
+ if (pdfDestination)
+ this.destinationStore_.selectDestination(pdfDestination);
+ else
+ this.nativeLayer_.previewFailedForTest();
+ } else if ('layoutSettings' in event.settings) {
+ var element = document.querySelector(
+ event.settings.layoutSettings.portrait ?
+ '.layout-settings-portrait-radio' :
+ '.layout-settings-landscape-radio');
+ if (element.clicked)
+ this.nativeLayer_.previewReadyForTest();
+ else
+ element.click();
+ } else if ('pageRange' in event.settings) {
+ var textbox = document.querySelector('.page-settings-custom-input');
+ if (textbox.value == event.settings.pageRange) {
+ this.nativeLayer_.previewReadyForTest();
+ } else {
+ textbox.value = event.settings.pageRange;
+ document.querySelector('.page-settings-custom-radio').click();
+ }
+ } else if ('headersAndFooters' in event.settings) {
+ var checkbox = document.querySelector('.header-footer-checkbox');
+ if (event.settings.headersAndFooters == checkbox.checked)
+ this.nativeLayer_.previewReadyForTest();
+ else
+ checkbox.click();
+ } else if ('backgroundColorsAndImages' in event.settings) {
+ var checkbox = document.querySelector('.css-background-checkbox');
+ if (event.settings.backgroundColorsAndImages == checkbox.checked)
+ this.nativeLayer_.previewReadyForTest();
+ else
+ checkbox.click();
+ } else if ('margins' in event.settings) {
+ var combobox = document.querySelector('.margin-settings-select');
+ if (event.settings.margins == combobox.selectedIndex) {
+ this.nativeLayer_.previewReadyForTest();
+ } else if (event.settings.margins >= 0 &&
+ event.settings.margins < combobox.length) {
+ combobox.selectedIndex = event.settings.margins;
+ this.marginSettings_.onSelectChange_();
+ } else {
+ this.nativeLayer_.previewFailedForTest();
+ }
+ }
+ },
Dan Beam 2014/06/24 23:13:01 "much code, no newlines, ow" - my eyes
ivandavid 2014/06/25 00:02:22 Ha. I am not sure where to put new lines though. I
ivandavid 2014/06/25 00:04:08 And those new lines don't conform to the style gui
+
+ /**
* Called when the open-cloud-print-dialog link is clicked. Opens the Google
* Cloud Print web dialog.
* @private

Powered by Google App Engine
This is Rietveld 408576698