Commit 567580e2 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview Componentization: Correctly update other options

Also add a test to verify, and only show rasterize checkbox on non-
Windows/Mac.

Bug: 773928
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I430f138db14cbe2e456023ba93292ddbd5c49dbe
Reviewed-on: https://chromium-review.googlesource.com/802356
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521011}
parent 0d5005df
......@@ -82,7 +82,8 @@
document-info="[[documentInfo]]"
hidden$="[[!settings.scaling.available]]">
</print-preview-scaling-settings>
<print-preview-other-options-settings settings="{{settings}}">
<print-preview-other-options-settings settings="{{settings}}"
hidden$="[[!settings.otherOptions.available]]">
</print-preview-other-options-settings>
<print-preview-advanced-options-settings settings="{{settings}}"
hidden$="[[!settings.vendorItems.available]]">
......
......@@ -49,6 +49,7 @@ Polymer({
* headerFooter: !print_preview_new.Setting,
* rasterize: !print_preview_new.Setting,
* vendorItems: !print_preview_new.Setting,
* otherOptions: !print_preview_new.Setting,
* }}
*/
settings: {
......@@ -154,6 +155,14 @@ Polymer({
available: true,
updatesPreview: false,
},
// This does not represent a real setting value, and is used only to
// expose the availability of the other options settings section.
otherOptions: {
value: null,
valid: true,
available: true,
updatesPreview: false,
},
},
},
......@@ -301,7 +310,16 @@ Polymer({
'settings.selectionOnly.available',
this.documentInfo.isModifiable && this.documentInfo.hasSelection);
this.set('settings.headerFooter.available', this.documentInfo.isModifiable);
this.set('settings.rasterize.available', !this.documentInfo.isModifiable);
this.set(
'settings.rasterize.available',
!this.documentInfo.isModifiable && !cr.isWindows && !cr.isMac);
this.set(
'settings.otherOptions.available',
this.settings.duplex.available ||
this.settings.cssBackground.available ||
this.settings.selectionOnly.available ||
this.settings.headerFooter.available ||
this.settings.rasterize.available);
},
/** @param {?print_preview.CddCapabilities} caps The printer capabilities. */
......
......@@ -11,31 +11,35 @@
<print-preview-settings-section class="multirow-controls">
<span slot="title" id="options-label">$i18n{optionsLabel}</span>
<div slot="controls" class="checkbox">
<div id="header-footer-container">
<div id="header-footer-container"
hidden$="[[!settings.headerFooter.available]]">
<label aria-live="polite">
<input type="checkbox">
<span>$i18n{optionHeaderFooter}</span>
</label>
</div>
<div id="duplex-container">
<div id="duplex-container" hidden$="[[!settings.duplex.available]]">
<label aria-live="polite">
<input type="checkbox" checked="{{duplexValue_::change}}">
<span>$i18n{optionTwoSided}</span>
</label>
</div>
<div id="css-background-container">
<div id="css-background-container"
hidden$="[[!settings.cssBackground.available]]">
<label aria-live="polite">
<input type="checkbox">
<span>$i18n{optionBackgroundColorsAndImages}</span>
</label>
</div>
<div id="rasterize-container">
<div id="rasterize-container"
hidden$="[[!settings.rasterize.available]]">
<label aria-live="polite">
<input type="checkbox">
<span>$i18n{optionRasterize}</span>
</label>
</div>
<div id="selection-only-container">
<div id="selection-only-container"
hidden$="[[!settings.selectionOnly.available]]">
<label aria-live="polite">
<input type="checkbox">
<span>$i18n{optionSelectionOnly}</span>
......
......@@ -87,3 +87,7 @@ TEST_F('PrintPreviewSettingsSectionsTest', 'Dpi', function() {
TEST_F('PrintPreviewSettingsSectionsTest', 'Scaling', function() {
this.runMochaTest(settings_sections_tests.TestNames.Scaling);
});
TEST_F('PrintPreviewSettingsSectionsTest', 'Other', function() {
this.runMochaTest(settings_sections_tests.TestNames.Other);
});
......@@ -12,6 +12,7 @@ cr.define('settings_sections_tests', function() {
Margins: 'margins',
Dpi: 'dpi',
Scaling: 'scaling',
Other: 'other',
};
const suiteName = 'SettingsSectionsTests';
......@@ -261,6 +262,62 @@ cr.define('settings_sections_tests', function() {
setPdfDestination();
expectEquals(true, scalingElement.hidden);
});
test(assert(TestNames.Other), function() {
const optionsElement = page.$$('print-preview-other-options-settings');
const headerFooter = optionsElement.$$('#header-footer-container');
const duplex = optionsElement.$$('#duplex-container');
const cssBackground = optionsElement.$$('#css-background-container');
const rasterize = optionsElement.$$('#rasterize-container');
const selectionOnly = optionsElement.$$('#selection-only-container');
// Start with HTML + duplex capability.
setPdfDocument(false);
let capabilities = getCdd();
page.set('destination.capabilities', capabilities);
expectEquals(false, optionsElement.hidden);
expectEquals(false, headerFooter.hidden);
expectEquals(false, duplex.hidden);
expectEquals(false, cssBackground.hidden);
expectEquals(true, rasterize.hidden);
expectEquals(true, selectionOnly.hidden);
// Add a selection.
let info = new print_preview.DocumentInfo();
info.init(true, 'title', true);
page.set('documentInfo', info);
expectEquals(false, optionsElement.hidden);
expectEquals(false, selectionOnly.hidden);
// Remove duplex capability.
capabilities = getCdd();
delete capabilities.printer.duplex;
page.set('destination.capabilities', capabilities);
expectEquals(false, optionsElement.hidden);
expectEquals(true, duplex.hidden);
// PDF
setPdfDocument(true);
expectEquals(cr.isWindows || cr.isMac, optionsElement.hidden);
expectEquals(true, headerFooter.hidden);
expectEquals(true, duplex.hidden);
expectEquals(true, cssBackground.hidden);
expectEquals(cr.isWindows || cr.isMac, rasterize.hidden);
expectEquals(true, selectionOnly.hidden);
// Add a selection - should do nothing for PDFs.
info = new print_preview.DocumentInfo();
info.init(false, 'title', true);
page.set('documentInfo', info);
expectEquals(cr.isWindows || cr.isMac, optionsElement.hidden);
expectEquals(true, selectionOnly.hidden);
// Add duplex.
capabilities = getCdd();
page.set('destination.capabilities', capabilities);
expectEquals(false, optionsElement.hidden);
expectEquals(false, duplex.hidden);
});
});
return {
......
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