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({
/** @private */
updateSettingsAvailabilityFromDestinationAndDocumentInfo_: function() {
const knownSizeToSaveAsPdf = this.destination.id ==
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF &&
const isSaveAsPDF = this.destination.id ==
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
const knownSizeToSaveAsPdf = isSaveAsPDF &&
(!this.documentInfo.isModifiable ||
this.documentInfo.hasCssMediaStyles);
this.set('settings.fitToPage.unavailableValue', !isSaveAsPDF);
this.set(
'settings.fitToPage.available',
!knownSizeToSaveAsPdf && !this.documentInfo.isModifiable);
......
......@@ -28,9 +28,6 @@ cr.define('preview_generation_test', function() {
/** @type {?print_preview.NativeLayer} */
let nativeLayer = null;
/** @type {?print_preview.DocumentInfo} */
let documentInfo = null;
/** @type {!print_preview.NativeInitialSettings} */
const initialSettings =
print_preview_test_utils.getDefaultInitialSettings();
......@@ -43,9 +40,8 @@ cr.define('preview_generation_test', function() {
});
/**
* Initializes the UI with a default local destination. |documentInfo| is
* initialized to a 3 page HTML document with no selection if it has not
* been set yet.
* Initializes the UI with a default local destination and a 3 page document
* length.
* @return {!Promise} Promise that resolves when initialization is done,
* destination is set, and initial preview request is complete.
*/
......@@ -68,27 +64,13 @@ cr.define('preview_generation_test', function() {
nativeLayer.whenCalled('getPrinterCapabilities'),
])
.then(function() {
if (!documentInfo)
initDocumentInfo(false, false);
page.set('documentInfo_', documentInfo);
page.notifyPath('documentInfo_.isModifiable');
if (!page.documentInfo_.isModifiable)
page.documentInfo_.updateFitToPageScaling(98);
page.documentInfo_.updatePageCount(3);
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 {boolean | string} initialSettingValue The default setting value.
......@@ -143,7 +125,7 @@ cr.define('preview_generation_test', function() {
/** Validate changing the fit to page setting updates the preview. */
test(assert(TestNames.FitToPage), function() {
// Set PDF document so setting is available.
initDocumentInfo(true, false);
initialSettings.previewModifiable = false;
return testSimpleSetting(
'fitToPage', false, true, 'fitToPageEnabled', false, true);
});
......@@ -239,7 +221,7 @@ cr.define('preview_generation_test', function() {
/** Validate changing the selection only setting updates the preview. */
test(assert(TestNames.SelectionOnly), function() {
// Set has selection to true so that the setting is available.
initDocumentInfo(false, true);
initialSettings.hasSelection = true;
return testSimpleSetting(
'selectionOnly', false, true, 'shouldPrintSelectionOnly', false,
true);
......@@ -261,7 +243,7 @@ cr.define('preview_generation_test', function() {
*/
test(assert(TestNames.Rasterize), function() {
// Set PDF document so setting is available.
initDocumentInfo(true, false);
initialSettings.previewModifiable = false;
return testSimpleSetting(
'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