Commit e8b1efa3 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Make fit to page in ticket match old UI

Currently, the new print preview always sends fit to page = false for
HTML documents where this setting is not available. Instead, send true
unless the destination is Save as PDF, to match the old UI behavior.

Bug: None
Change-Id: I6f303aa176dd87fe90f6bde3a603800e9617b831
Reviewed-on: https://chromium-review.googlesource.com/1180590Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585691}
parent 8698158a
...@@ -360,10 +360,12 @@ Polymer({ ...@@ -360,10 +360,12 @@ Polymer({
/** @private */ /** @private */
updateSettingsAvailabilityFromDestinationAndDocumentInfo_: function() { updateSettingsAvailabilityFromDestinationAndDocumentInfo_: function() {
const knownSizeToSaveAsPdf = this.destination.id == const isSaveAsPDF = this.destination.id ==
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF && print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
const knownSizeToSaveAsPdf = isSaveAsPDF &&
(!this.documentInfo.isModifiable || (!this.documentInfo.isModifiable ||
this.documentInfo.hasCssMediaStyles); this.documentInfo.hasCssMediaStyles);
this.set('settings.fitToPage.unavailableValue', !isSaveAsPDF);
this.set( this.set(
'settings.fitToPage.available', 'settings.fitToPage.available',
!knownSizeToSaveAsPdf && !this.documentInfo.isModifiable); !knownSizeToSaveAsPdf && !this.documentInfo.isModifiable);
......
...@@ -28,9 +28,6 @@ cr.define('preview_generation_test', function() { ...@@ -28,9 +28,6 @@ cr.define('preview_generation_test', function() {
/** @type {?print_preview.NativeLayer} */ /** @type {?print_preview.NativeLayer} */
let nativeLayer = null; let nativeLayer = null;
/** @type {?print_preview.DocumentInfo} */
let documentInfo = null;
/** @type {!print_preview.NativeInitialSettings} */ /** @type {!print_preview.NativeInitialSettings} */
const initialSettings = const initialSettings =
print_preview_test_utils.getDefaultInitialSettings(); print_preview_test_utils.getDefaultInitialSettings();
...@@ -43,9 +40,8 @@ cr.define('preview_generation_test', function() { ...@@ -43,9 +40,8 @@ cr.define('preview_generation_test', function() {
}); });
/** /**
* Initializes the UI with a default local destination. |documentInfo| is * Initializes the UI with a default local destination and a 3 page document
* initialized to a 3 page HTML document with no selection if it has not * length.
* been set yet.
* @return {!Promise} Promise that resolves when initialization is done, * @return {!Promise} Promise that resolves when initialization is done,
* destination is set, and initial preview request is complete. * destination is set, and initial preview request is complete.
*/ */
...@@ -68,27 +64,13 @@ cr.define('preview_generation_test', function() { ...@@ -68,27 +64,13 @@ cr.define('preview_generation_test', function() {
nativeLayer.whenCalled('getPrinterCapabilities'), nativeLayer.whenCalled('getPrinterCapabilities'),
]) ])
.then(function() { .then(function() {
if (!documentInfo) if (!page.documentInfo_.isModifiable)
initDocumentInfo(false, false); page.documentInfo_.updateFitToPageScaling(98);
page.set('documentInfo_', documentInfo); page.documentInfo_.updatePageCount(3);
page.notifyPath('documentInfo_.isModifiable');
return nativeLayer.whenCalled('getPreview'); return nativeLayer.whenCalled('getPreview');
}); });
} }
/**
* Initializes |documentInfo| with a 3 page document.
* @param {boolean} isPdf Whether the document should be a PDF.
* @param {boolean} hasSelection Whether the document has a selection.
*/
function initDocumentInfo(isPdf, hasSelection) {
documentInfo = new print_preview.DocumentInfo();
documentInfo.init(!isPdf, 'title', hasSelection);
if (isPdf)
documentInfo.updateFitToPageScaling(98);
documentInfo.updatePageCount(3);
}
/** /**
* @param {string} settingName The name of the setting to test. * @param {string} settingName The name of the setting to test.
* @param {boolean | string} initialSettingValue The default setting value. * @param {boolean | string} initialSettingValue The default setting value.
...@@ -143,7 +125,7 @@ cr.define('preview_generation_test', function() { ...@@ -143,7 +125,7 @@ cr.define('preview_generation_test', function() {
/** Validate changing the fit to page setting updates the preview. */ /** Validate changing the fit to page setting updates the preview. */
test(assert(TestNames.FitToPage), function() { test(assert(TestNames.FitToPage), function() {
// Set PDF document so setting is available. // Set PDF document so setting is available.
initDocumentInfo(true, false); initialSettings.previewModifiable = false;
return testSimpleSetting( return testSimpleSetting(
'fitToPage', false, true, 'fitToPageEnabled', false, true); 'fitToPage', false, true, 'fitToPageEnabled', false, true);
}); });
...@@ -239,7 +221,7 @@ cr.define('preview_generation_test', function() { ...@@ -239,7 +221,7 @@ cr.define('preview_generation_test', function() {
/** Validate changing the selection only setting updates the preview. */ /** Validate changing the selection only setting updates the preview. */
test(assert(TestNames.SelectionOnly), function() { test(assert(TestNames.SelectionOnly), function() {
// Set has selection to true so that the setting is available. // Set has selection to true so that the setting is available.
initDocumentInfo(false, true); initialSettings.hasSelection = true;
return testSimpleSetting( return testSimpleSetting(
'selectionOnly', false, true, 'shouldPrintSelectionOnly', false, 'selectionOnly', false, true, 'shouldPrintSelectionOnly', false,
true); true);
...@@ -261,7 +243,7 @@ cr.define('preview_generation_test', function() { ...@@ -261,7 +243,7 @@ cr.define('preview_generation_test', function() {
*/ */
test(assert(TestNames.Rasterize), function() { test(assert(TestNames.Rasterize), function() {
// Set PDF document so setting is available. // Set PDF document so setting is available.
initDocumentInfo(true, false); initialSettings.previewModifiable = false;
return testSimpleSetting( return testSimpleSetting(
'rasterize', false, true, 'rasterizePDF', false, true); 'rasterize', false, true, 'rasterizePDF', false, true);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment