Commit 37e2d2f6 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Rename MarginsTypeValue->MarginsType

There's no reason for the longer name, and we want to be consistent
when we add ScalingType in a future CL.

Change-Id: Ieeb4e00fb9faeea03a6b82ac46627d175b181e54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832471Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701430}
parent 6f182069
...@@ -21,7 +21,7 @@ cr.define('print_preview', function() { ...@@ -21,7 +21,7 @@ cr.define('print_preview', function() {
* printing/print_job_constants.h. * printing/print_job_constants.h.
* @enum {number} * @enum {number}
*/ */
const MarginsTypeValue = { const MarginsType = {
DEFAULT: 0, DEFAULT: 0,
NO_MARGINS: 1, NO_MARGINS: 1,
MINIMUM: 2, MINIMUM: 2,
...@@ -30,7 +30,7 @@ cr.define('print_preview', function() { ...@@ -30,7 +30,7 @@ cr.define('print_preview', function() {
return { return {
CustomMarginsOrientation: CustomMarginsOrientation, CustomMarginsOrientation: CustomMarginsOrientation,
MarginsTypeValue: MarginsTypeValue, MarginsType: MarginsType,
}; };
}); });
......
...@@ -60,7 +60,7 @@ cr.define('print_preview', function() { ...@@ -60,7 +60,7 @@ cr.define('print_preview', function() {
* width_microns: number, * width_microns: number,
* custom_display_name: (string | undefined), * custom_display_name: (string | undefined),
* is_default: (boolean | undefined)} | undefined), * is_default: (boolean | undefined)} | undefined),
* marginsType: (print_preview.MarginsTypeValue | undefined), * marginsType: (print_preview.MarginsType | undefined),
* customMargins: (print_preview.MarginsSetting | undefined), * customMargins: (print_preview.MarginsSetting | undefined),
* isColorEnabled: (boolean | undefined), * isColorEnabled: (boolean | undefined),
* isDuplexEnabled: (boolean | undefined), * isDuplexEnabled: (boolean | undefined),
...@@ -262,8 +262,8 @@ Polymer({ ...@@ -262,8 +262,8 @@ Polymer({
updatesPreview: true, updatesPreview: true,
}, },
margins: { margins: {
value: print_preview.MarginsTypeValue.DEFAULT, value: print_preview.MarginsType.DEFAULT,
unavailableValue: print_preview.MarginsTypeValue.DEFAULT, unavailableValue: print_preview.MarginsType.DEFAULT,
valid: true, valid: true,
available: true, available: true,
setByPolicy: false, setByPolicy: false,
...@@ -790,20 +790,20 @@ Polymer({ ...@@ -790,20 +790,20 @@ Polymer({
// Otherwise, availability depends on the margins. // Otherwise, availability depends on the margins.
let available = false; let available = false;
const marginsType = const marginsType =
/** @type {!print_preview.MarginsTypeValue} */ ( /** @type {!print_preview.MarginsType} */ (
this.getSettingValue('margins')); this.getSettingValue('margins'));
switch (marginsType) { switch (marginsType) {
case print_preview.MarginsTypeValue.DEFAULT: case print_preview.MarginsType.DEFAULT:
available = !this.margins || available = !this.margins ||
this.margins.get(print_preview.CustomMarginsOrientation.TOP) > 0 || this.margins.get(print_preview.CustomMarginsOrientation.TOP) > 0 ||
this.margins.get(print_preview.CustomMarginsOrientation.BOTTOM) > 0; this.margins.get(print_preview.CustomMarginsOrientation.BOTTOM) > 0;
break; break;
case print_preview.MarginsTypeValue.NO_MARGINS: case print_preview.MarginsType.NO_MARGINS:
break; break;
case print_preview.MarginsTypeValue.MINIMUM: case print_preview.MarginsType.MINIMUM:
available = true; available = true;
break; break;
case print_preview.MarginsTypeValue.CUSTOM: case print_preview.MarginsType.CUSTOM:
const margins = this.getSettingValue('customMargins'); const margins = this.getSettingValue('customMargins');
available = margins.marginTop > 0 || margins.marginBottom > 0; available = margins.marginTop > 0 || margins.marginBottom > 0;
break; break;
...@@ -1236,8 +1236,7 @@ Polymer({ ...@@ -1236,8 +1236,7 @@ Polymer({
ticket.cloudPrintID = destination.id; ticket.cloudPrintID = destination.id;
} }
if (this.getSettingValue('margins') == if (this.getSettingValue('margins') == print_preview.MarginsType.CUSTOM) {
print_preview.MarginsTypeValue.CUSTOM) {
ticket.marginsCustom = this.getSettingValue('customMargins'); ticket.marginsCustom = this.getSettingValue('customMargins');
} }
......
...@@ -136,8 +136,7 @@ cr.define('print_preview', function() { ...@@ -136,8 +136,7 @@ cr.define('print_preview', function() {
*/ */
computeAvailable_: function() { computeAvailable_: function() {
return this.previewLoaded && !!this.clipSize_ && return this.previewLoaded && !!this.clipSize_ &&
this.getSettingValue('margins') == this.getSettingValue('margins') == print_preview.MarginsType.CUSTOM &&
print_preview.MarginsTypeValue.CUSTOM &&
!!this.pageSize; !!this.pageSize;
}, },
...@@ -185,9 +184,9 @@ cr.define('print_preview', function() { ...@@ -185,9 +184,9 @@ cr.define('print_preview', function() {
this.resetMargins_ = true; this.resetMargins_ = true;
const marginsSetting = this.getSetting('margins'); const marginsSetting = this.getSetting('margins');
if (marginsSetting.value == print_preview.MarginsTypeValue.CUSTOM) { if (marginsSetting.value == print_preview.MarginsType.CUSTOM) {
// Set the margins value to default first. // Set the margins value to default first.
this.setSetting('margins', print_preview.MarginsTypeValue.DEFAULT); this.setSetting('margins', print_preview.MarginsType.DEFAULT);
} }
// Reset custom margins so that the sticky value is not restored for the // Reset custom margins so that the sticky value is not restored for the
// new paper size. // new paper size.
......
...@@ -19,15 +19,19 @@ ...@@ -19,15 +19,19 @@
settings.pagesPerSheet.value)]]" settings.pagesPerSheet.value)]]"
value="{{selectedValue::change}}"> value="{{selectedValue::change}}">
<!-- The order of these options must match the natural order of their <!-- The order of these options must match the natural order of their
values, which come from print_preview.MarginsTypeValue. --> values, which come from print_preview.MarginsType. -->
<option value="[[MarginsValue.DEFAULT]]" selected> <option value="[[MarginsTypeEnum.DEFAULT]]" selected>
$i18n{defaultMargins} $i18n{defaultMargins}
</option> </option>
<option value="[[MarginsValue.NO_MARGINS]]">$i18n{noMargins}</option> <option value="[[MarginsTypeEnum.NO_MARGINS]]">
<option value="[[MarginsValue.MINIMUM]]"> $i18n{noMargins}
</option>
<option value="[[MarginsTypeEnum.MINIMUM]]">
$i18n{minimumMargins} $i18n{minimumMargins}
</option> </option>
<option value="[[MarginsValue.CUSTOM]]">$i18n{customMargins}</option> <option value="[[MarginsTypeEnum.CUSTOM]]">
$i18n{customMargins}
</option>
</select> </select>
</div> </div>
</print-preview-settings-section> </print-preview-settings-section>
......
...@@ -11,14 +11,14 @@ Polymer({ ...@@ -11,14 +11,14 @@ Polymer({
disabled: Boolean, disabled: Boolean,
/** Mirroring the enum so that it can be used from HTML bindings. */ /** Mirroring the enum so that it can be used from HTML bindings. */
MarginsValue: Object, MarginsTypeEnum: Object,
}, },
observers: ['onMarginsSettingChange_(settings.margins.value)'], observers: ['onMarginsSettingChange_(settings.margins.value)'],
/** @override */ /** @override */
ready: function() { ready: function() {
this.MarginsValue = print_preview.MarginsTypeValue; this.MarginsTypeEnum = print_preview.MarginsType;
}, },
/** /**
...@@ -27,7 +27,7 @@ Polymer({ ...@@ -27,7 +27,7 @@ Polymer({
*/ */
onMarginsSettingChange_: function(newValue) { onMarginsSettingChange_: function(newValue) {
this.selectedValue = this.selectedValue =
/** @type {!print_preview.MarginsTypeValue} */ (newValue).toString(); /** @type {!print_preview.MarginsType} */ (newValue).toString();
}, },
/** @param {string} value The new select value. */ /** @param {string} value The new select value. */
......
...@@ -19,7 +19,7 @@ Polymer({ ...@@ -19,7 +19,7 @@ Polymer({
*/ */
onPagesPerSheetSettingChange_: function(newValue) { onPagesPerSheetSettingChange_: function(newValue) {
this.selectedValue = /** @type {number} */ (newValue).toString(); this.selectedValue = /** @type {number} */ (newValue).toString();
this.setSetting('margins', print_preview.MarginsTypeValue.DEFAULT); this.setSetting('margins', print_preview.MarginsType.DEFAULT);
}, },
/** @param {string} value The new select value. */ /** @param {string} value The new select value. */
......
...@@ -529,12 +529,12 @@ Polymer({ ...@@ -529,12 +529,12 @@ Polymer({
*/ */
marginsValid_: function() { marginsValid_: function() {
const type = this.getSettingValue('margins'); const type = this.getSettingValue('margins');
if (!Object.values(print_preview.MarginsTypeValue).includes(type)) { if (!Object.values(print_preview.MarginsType).includes(type)) {
// Unrecognized margins type. // Unrecognized margins type.
return false; return false;
} }
if (type !== print_preview.MarginsTypeValue.CUSTOM) { if (type !== print_preview.MarginsType.CUSTOM) {
return true; return true;
} }
...@@ -566,11 +566,11 @@ Polymer({ ...@@ -566,11 +566,11 @@ Polymer({
// Margins // Margins
const newMarginsType = this.getSettingValue('margins'); const newMarginsType = this.getSettingValue('margins');
if (newMarginsType !== lastTicket.marginsType && if (newMarginsType !== lastTicket.marginsType &&
newMarginsType !== print_preview.MarginsTypeValue.CUSTOM) { newMarginsType !== print_preview.MarginsType.CUSTOM) {
return true; return true;
} }
if (newMarginsType === print_preview.MarginsTypeValue.CUSTOM) { if (newMarginsType === print_preview.MarginsType.CUSTOM) {
const customMargins = const customMargins =
/** @type {!print_preview.MarginsSetting} */ ( /** @type {!print_preview.MarginsSetting} */ (
this.getSettingValue('customMargins')); this.getSettingValue('customMargins'));
...@@ -626,8 +626,7 @@ Polymer({ ...@@ -626,8 +626,7 @@ Polymer({
// Pages per sheet. If margins are non-default, wait for the return to // Pages per sheet. If margins are non-default, wait for the return to
// default margins to trigger a request. // default margins to trigger a request.
if (this.getSettingValue('pagesPerSheet') !== lastTicket.pagesPerSheet && if (this.getSettingValue('pagesPerSheet') !== lastTicket.pagesPerSheet &&
this.getSettingValue('margins') === this.getSettingValue('margins') === print_preview.MarginsType.DEFAULT) {
print_preview.MarginsTypeValue.DEFAULT) {
return true; return true;
} }
...@@ -639,7 +638,7 @@ Polymer({ ...@@ -639,7 +638,7 @@ Polymer({
newValue.width_microns != lastTicket.mediaSize.width_microns || newValue.width_microns != lastTicket.mediaSize.width_microns ||
(this.destination.id !== lastTicket.deviceName && (this.destination.id !== lastTicket.deviceName &&
this.getSettingValue('margins') === this.getSettingValue('margins') ===
print_preview.MarginsTypeValue.MINIMUM)) { print_preview.MarginsType.MINIMUM)) {
return true; return true;
} }
...@@ -731,8 +730,7 @@ Polymer({ ...@@ -731,8 +730,7 @@ Polymer({
ticket.cloudPrintID = this.destination.id; ticket.cloudPrintID = this.destination.id;
} }
if (this.getSettingValue('margins') == if (this.getSettingValue('margins') == print_preview.MarginsType.CUSTOM) {
print_preview.MarginsTypeValue.CUSTOM) {
ticket.marginsCustom = this.getSettingValue('customMargins'); ticket.marginsCustom = this.getSettingValue('customMargins');
} }
this.lastTicket_ = ticket; this.lastTicket_ = ticket;
......
...@@ -231,8 +231,7 @@ cr.define('custom_margins_test', function() { ...@@ -231,8 +231,7 @@ cr.define('custom_margins_test', function() {
const marginValues = setupCustomMargins(); const marginValues = setupCustomMargins();
return finishSetup().then(() => { return finishSetup().then(() => {
// Simulate setting custom margins. // Simulate setting custom margins.
model.set( model.set('settings.margins.value', print_preview.MarginsType.CUSTOM);
'settings.margins.value', print_preview.MarginsTypeValue.CUSTOM);
// Validate control positions are set based on the custom values. // Validate control positions are set based on the custom values.
const controls = getControls(); const controls = getControls();
...@@ -249,7 +248,7 @@ cr.define('custom_margins_test', function() { ...@@ -249,7 +248,7 @@ cr.define('custom_margins_test', function() {
// Margins should be reset to default and custom margins values should // Margins should be reset to default and custom margins values should
// be cleared. // be cleared.
expectEquals( expectEquals(
print_preview.MarginsTypeValue.DEFAULT, print_preview.MarginsType.DEFAULT,
container.getSettingValue('margins')); container.getSettingValue('margins'));
expectEquals( expectEquals(
'{}', JSON.stringify(container.getSettingValue('customMargins'))); '{}', JSON.stringify(container.getSettingValue('customMargins')));
...@@ -279,8 +278,7 @@ cr.define('custom_margins_test', function() { ...@@ -279,8 +278,7 @@ cr.define('custom_margins_test', function() {
let onTransitionEnd = getAllTransitions(controls); let onTransitionEnd = getAllTransitions(controls);
// Controls become visible when margin type CUSTOM is selected. // Controls become visible when margin type CUSTOM is selected.
model.set( model.set(
'settings.margins.value', 'settings.margins.value', print_preview.MarginsType.CUSTOM);
print_preview.MarginsTypeValue.CUSTOM);
// Wait for the opacity transitions to finish. // Wait for the opacity transitions to finish.
return onTransitionEnd; return onTransitionEnd;
...@@ -336,8 +334,7 @@ cr.define('custom_margins_test', function() { ...@@ -336,8 +334,7 @@ cr.define('custom_margins_test', function() {
const controls = getControls(); const controls = getControls();
// Simulate setting custom margins from sticky settings. // Simulate setting custom margins from sticky settings.
model.set( model.set('settings.margins.value', print_preview.MarginsType.CUSTOM);
'settings.margins.value', print_preview.MarginsTypeValue.CUSTOM);
const marginValues = setupCustomMargins(); const marginValues = setupCustomMargins();
model.notifyPath('settings.customMargins.value'); model.notifyPath('settings.customMargins.value');
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -382,8 +379,7 @@ cr.define('custom_margins_test', function() { ...@@ -382,8 +379,7 @@ cr.define('custom_margins_test', function() {
return finishSetup().then(() => { return finishSetup().then(() => {
const controls = getControls(); const controls = getControls();
model.set( model.set('settings.margins.value', print_preview.MarginsType.CUSTOM);
'settings.margins.value', print_preview.MarginsTypeValue.CUSTOM);
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -441,8 +437,7 @@ cr.define('custom_margins_test', function() { ...@@ -441,8 +437,7 @@ cr.define('custom_margins_test', function() {
controls.forEach(c => { controls.forEach(c => {
c.getInput().setAttribute('data-timeout-delay', 1); c.getInput().setAttribute('data-timeout-delay', 1);
}); });
model.set( model.set('settings.margins.value', print_preview.MarginsType.CUSTOM);
'settings.margins.value', print_preview.MarginsTypeValue.CUSTOM);
Polymer.dom.flush(); Polymer.dom.flush();
// Verify entering a new value updates the settings. // Verify entering a new value updates the settings.
...@@ -487,8 +482,7 @@ cr.define('custom_margins_test', function() { ...@@ -487,8 +482,7 @@ cr.define('custom_margins_test', function() {
controls.forEach(c => { controls.forEach(c => {
c.getInput().setAttribute('data-timeout-delay', 1); c.getInput().setAttribute('data-timeout-delay', 1);
}); });
model.set( model.set('settings.margins.value', print_preview.MarginsType.CUSTOM);
'settings.margins.value', print_preview.MarginsTypeValue.CUSTOM);
Polymer.dom.flush(); Polymer.dom.flush();
// Verify entering a new value updates the settings. // Verify entering a new value updates the settings.
...@@ -538,8 +532,7 @@ cr.define('custom_margins_test', function() { ...@@ -538,8 +532,7 @@ cr.define('custom_margins_test', function() {
return finishSetup().then(() => { return finishSetup().then(() => {
// Simulate setting custom margins. // Simulate setting custom margins.
const controls = getControls(); const controls = getControls();
model.set( model.set('settings.margins.value', print_preview.MarginsType.CUSTOM);
'settings.margins.value', print_preview.MarginsTypeValue.CUSTOM);
// Validate control positions are set based on the custom values. // Validate control positions are set based on the custom values.
controls.forEach((control, index) => { controls.forEach((control, index) => {
...@@ -549,8 +542,7 @@ cr.define('custom_margins_test', function() { ...@@ -549,8 +542,7 @@ cr.define('custom_margins_test', function() {
}); });
// Simulate setting minimum margins. // Simulate setting minimum margins.
model.set( model.set('settings.margins.value', print_preview.MarginsType.MINIMUM);
'settings.margins.value', print_preview.MarginsTypeValue.MINIMUM);
// Validate control positions still reflect the custom values. // Validate control positions still reflect the custom values.
controls.forEach((control, index) => { controls.forEach((control, index) => {
...@@ -568,8 +560,7 @@ cr.define('custom_margins_test', function() { ...@@ -568,8 +560,7 @@ cr.define('custom_margins_test', function() {
.then(() => { .then(() => {
// Simulate setting custom margins again. // Simulate setting custom margins again.
model.set( model.set(
'settings.margins.value', 'settings.margins.value', print_preview.MarginsType.CUSTOM);
print_preview.MarginsTypeValue.CUSTOM);
// Validate control positions are initialized based on the default // Validate control positions are initialized based on the default
// values. // values.
...@@ -586,8 +577,7 @@ cr.define('custom_margins_test', function() { ...@@ -586,8 +577,7 @@ cr.define('custom_margins_test', function() {
test(assert(TestNames.LayoutClearsCustomMargins), function() { test(assert(TestNames.LayoutClearsCustomMargins), function() {
return validateMarginsClearedForSetting('layout', true).then(() => { return validateMarginsClearedForSetting('layout', true).then(() => {
// Simulate setting custom margins again // Simulate setting custom margins again
model.set( model.set('settings.margins.value', print_preview.MarginsType.CUSTOM);
'settings.margins.value', print_preview.MarginsTypeValue.CUSTOM);
// Validate control positions are initialized based on the default // Validate control positions are initialized based on the default
// values. // values.
...@@ -637,8 +627,7 @@ cr.define('custom_margins_test', function() { ...@@ -637,8 +627,7 @@ cr.define('custom_margins_test', function() {
// Controls become visible when margin type CUSTOM is selected. // Controls become visible when margin type CUSTOM is selected.
model.set( model.set(
'settings.margins.value', 'settings.margins.value', print_preview.MarginsType.CUSTOM);
print_preview.MarginsTypeValue.CUSTOM);
container.notifyPath('settings.customMargins.value'); container.notifyPath('settings.customMargins.value');
Polymer.dom.flush(); Polymer.dom.flush();
return onTransitionEnd; return onTransitionEnd;
...@@ -683,8 +672,7 @@ cr.define('custom_margins_test', function() { ...@@ -683,8 +672,7 @@ cr.define('custom_margins_test', function() {
test(assert(TestNames.ControlsDisabledOnError), function() { test(assert(TestNames.ControlsDisabledOnError), function() {
return finishSetup().then(() => { return finishSetup().then(() => {
// Simulate setting custom margins. // Simulate setting custom margins.
model.set( model.set('settings.margins.value', print_preview.MarginsType.CUSTOM);
'settings.margins.value', print_preview.MarginsTypeValue.CUSTOM);
const controls = getControls(); const controls = getControls();
controls.forEach(control => assertFalse(control.disabled)); controls.forEach(control => assertFalse(control.disabled));
......
...@@ -19,7 +19,7 @@ cr.define('margins_settings_test', function() { ...@@ -19,7 +19,7 @@ cr.define('margins_settings_test', function() {
marginsSection.settings = model.settings; marginsSection.settings = model.settings;
marginsSection.disabled = false; marginsSection.disabled = false;
test_util.fakeDataBind(model, marginsSection, 'settings'); test_util.fakeDataBind(model, marginsSection, 'settings');
marginsTypeEnum = print_preview.MarginsTypeValue; marginsTypeEnum = print_preview.MarginsType;
}); });
// Tests that setting the setting updates the UI. // Tests that setting the setting updates the UI.
......
...@@ -375,13 +375,11 @@ cr.define('model_settings_availability_test', function() { ...@@ -375,13 +375,11 @@ cr.define('model_settings_availability_test', function() {
assertTrue(model.settings.headerFooter.available); assertTrue(model.settings.headerFooter.available);
// Set margins to NONE // Set margins to NONE
model.set( model.set('settings.margins.value', print_preview.MarginsType.NO_MARGINS);
'settings.margins.value', print_preview.MarginsTypeValue.NO_MARGINS);
assertFalse(model.settings.headerFooter.available); assertFalse(model.settings.headerFooter.available);
// Custom margins of 0. // Custom margins of 0.
model.set( model.set('settings.margins.value', print_preview.MarginsType.CUSTOM);
'settings.margins.value', print_preview.MarginsTypeValue.CUSTOM);
model.set( model.set(
'settings.customMargins.value', 'settings.customMargins.value',
{marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0}); {marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0});
...@@ -426,8 +424,7 @@ cr.define('model_settings_availability_test', function() { ...@@ -426,8 +424,7 @@ cr.define('model_settings_availability_test', function() {
] ]
}; };
model.set('destination.capabilities', capabilities); model.set('destination.capabilities', capabilities);
model.set( model.set('settings.margins.value', print_preview.MarginsType.DEFAULT);
'settings.margins.value', print_preview.MarginsTypeValue.DEFAULT);
// Header/footer should be available for default big label with // Header/footer should be available for default big label with
// default margins. // default margins.
......
...@@ -188,7 +188,7 @@ cr.define('model_test', function() { ...@@ -188,7 +188,7 @@ cr.define('model_test', function() {
layout: true, layout: true,
color: false, color: false,
mediaSize: testDestination.capabilities.printer.media_size.option[1], mediaSize: testDestination.capabilities.printer.media_size.option[1],
margins: print_preview.MarginsTypeValue.CUSTOM, margins: print_preview.MarginsType.CUSTOM,
customMargins: { customMargins: {
marginTop: 100, marginTop: 100,
marginRight: 200, marginRight: 200,
...@@ -278,7 +278,7 @@ cr.define('model_test', function() { ...@@ -278,7 +278,7 @@ cr.define('model_test', function() {
landscape: false, landscape: false,
color: testDestination.getNativeColorModel(true), color: testDestination.getNativeColorModel(true),
headerFooterEnabled: false, // Only used in print preview headerFooterEnabled: false, // Only used in print preview
marginsType: print_preview.MarginsTypeValue.DEFAULT, marginsType: print_preview.MarginsType.DEFAULT,
duplex: print_preview.DuplexMode.SIMPLEX, duplex: print_preview.DuplexMode.SIMPLEX,
copies: 1, copies: 1,
collate: true, collate: true,
...@@ -319,7 +319,7 @@ cr.define('model_test', function() { ...@@ -319,7 +319,7 @@ cr.define('model_test', function() {
landscape: true, landscape: true,
color: testDestination.getNativeColorModel(false), color: testDestination.getNativeColorModel(false),
headerFooterEnabled: false, headerFooterEnabled: false,
marginsType: print_preview.MarginsTypeValue.CUSTOM, marginsType: print_preview.MarginsType.CUSTOM,
duplex: print_preview.DuplexMode.SHORT_EDGE, duplex: print_preview.DuplexMode.SHORT_EDGE,
copies: 2, copies: 2,
collate: false, collate: false,
......
...@@ -34,14 +34,14 @@ cr.define('pages_per_sheet_settings_test', function() { ...@@ -34,14 +34,14 @@ cr.define('pages_per_sheet_settings_test', function() {
// Tests that setting the pages per sheet setting resets margins to DEFAULT. // Tests that setting the pages per sheet setting resets margins to DEFAULT.
test('resets margins setting', async () => { test('resets margins setting', async () => {
pagesPerSheetSection.setSetting( pagesPerSheetSection.setSetting(
'margins', print_preview.MarginsTypeValue.NO_MARGINS); 'margins', print_preview.MarginsType.NO_MARGINS);
assertEquals(1, pagesPerSheetSection.getSettingValue('pagesPerSheet')); assertEquals(1, pagesPerSheetSection.getSettingValue('pagesPerSheet'));
pagesPerSheetSection.setSetting('pagesPerSheet', 4); pagesPerSheetSection.setSetting('pagesPerSheet', 4);
await test_util.eventToPromise( await test_util.eventToPromise(
'process-select-change', pagesPerSheetSection); 'process-select-change', pagesPerSheetSection);
assertEquals(4, pagesPerSheetSection.getSettingValue('pagesPerSheet')); assertEquals(4, pagesPerSheetSection.getSettingValue('pagesPerSheet'));
assertEquals( assertEquals(
print_preview.MarginsTypeValue.DEFAULT, print_preview.MarginsType.DEFAULT,
pagesPerSheetSection.getSettingValue('margins')); pagesPerSheetSection.getSettingValue('margins'));
}); });
......
...@@ -151,10 +151,9 @@ cr.define('preview_generation_test', function() { ...@@ -151,10 +151,9 @@ cr.define('preview_generation_test', function() {
/** Validate changing the margins updates the preview. */ /** Validate changing the margins updates the preview. */
test(assert(TestNames.Margins), function() { test(assert(TestNames.Margins), function() {
return testSimpleSetting( return testSimpleSetting(
'margins', print_preview.MarginsTypeValue.DEFAULT, 'margins', print_preview.MarginsType.DEFAULT,
print_preview.MarginsTypeValue.MINIMUM, 'marginsType', print_preview.MarginsType.MINIMUM, 'marginsType',
print_preview.MarginsTypeValue.DEFAULT, print_preview.MarginsType.DEFAULT, print_preview.MarginsType.MINIMUM);
print_preview.MarginsTypeValue.MINIMUM);
}); });
/** /**
...@@ -166,14 +165,13 @@ cr.define('preview_generation_test', function() { ...@@ -166,14 +165,13 @@ cr.define('preview_generation_test', function() {
.then(function(args) { .then(function(args) {
const originalTicket = JSON.parse(args.printTicket); const originalTicket = JSON.parse(args.printTicket);
assertEquals( assertEquals(
print_preview.MarginsTypeValue.DEFAULT, print_preview.MarginsType.DEFAULT, originalTicket.marginsType);
originalTicket.marginsType);
// Custom margins should not be set in the ticket. // Custom margins should not be set in the ticket.
assertEquals(undefined, originalTicket.marginsCustom); assertEquals(undefined, originalTicket.marginsCustom);
assertEquals(0, originalTicket.requestID); assertEquals(0, originalTicket.requestID);
// This should do nothing. // This should do nothing.
page.setSetting('margins', print_preview.MarginsTypeValue.CUSTOM); page.setSetting('margins', print_preview.MarginsType.CUSTOM);
// Sets only 1 side, not valid. // Sets only 1 side, not valid.
page.setSetting('customMargins', {marginTop: 25}); page.setSetting('customMargins', {marginTop: 25});
// 2 sides, still not valid. // 2 sides, still not valid.
...@@ -190,17 +188,16 @@ cr.define('preview_generation_test', function() { ...@@ -190,17 +188,16 @@ cr.define('preview_generation_test', function() {
}) })
.then(function(args) { .then(function(args) {
const ticket = JSON.parse(args.printTicket); const ticket = JSON.parse(args.printTicket);
assertEquals( assertEquals(print_preview.MarginsType.CUSTOM, ticket.marginsType);
print_preview.MarginsTypeValue.CUSTOM, ticket.marginsType);
assertEquals(25, ticket.marginsCustom.marginTop); assertEquals(25, ticket.marginsCustom.marginTop);
assertEquals(40, ticket.marginsCustom.marginRight); assertEquals(40, ticket.marginsCustom.marginRight);
assertEquals(20, ticket.marginsCustom.marginBottom); assertEquals(20, ticket.marginsCustom.marginBottom);
assertEquals(50, ticket.marginsCustom.marginLeft); assertEquals(50, ticket.marginsCustom.marginLeft);
assertEquals(1, ticket.requestID); assertEquals(1, ticket.requestID);
page.setSetting('margins', print_preview.MarginsTypeValue.DEFAULT); page.setSetting('margins', print_preview.MarginsType.DEFAULT);
// Set setting to something invalid and then set margins to CUSTOM. // Set setting to something invalid and then set margins to CUSTOM.
page.setSetting('customMargins', {marginTop: 25, marginRight: 40}); page.setSetting('customMargins', {marginTop: 25, marginRight: 40});
page.setSetting('margins', print_preview.MarginsTypeValue.CUSTOM); page.setSetting('margins', print_preview.MarginsType.CUSTOM);
nativeLayer.resetResolver('getPreview'); nativeLayer.resetResolver('getPreview');
page.setSetting('customMargins', { page.setSetting('customMargins', {
marginTop: 25, marginTop: 25,
...@@ -212,8 +209,7 @@ cr.define('preview_generation_test', function() { ...@@ -212,8 +209,7 @@ cr.define('preview_generation_test', function() {
}) })
.then(function(args) { .then(function(args) {
const ticket = JSON.parse(args.printTicket); const ticket = JSON.parse(args.printTicket);
assertEquals( assertEquals(print_preview.MarginsType.CUSTOM, ticket.marginsType);
print_preview.MarginsTypeValue.CUSTOM, ticket.marginsType);
assertEquals(25, ticket.marginsCustom.marginTop); assertEquals(25, ticket.marginsCustom.marginTop);
assertEquals(40, ticket.marginsCustom.marginRight); assertEquals(40, ticket.marginsCustom.marginRight);
assertEquals(20, ticket.marginsCustom.marginBottom); assertEquals(20, ticket.marginsCustom.marginBottom);
...@@ -227,10 +223,10 @@ cr.define('preview_generation_test', function() { ...@@ -227,10 +223,10 @@ cr.define('preview_generation_test', function() {
/** /**
* Validate changing the pages per sheet updates the preview, and resets * Validate changing the pages per sheet updates the preview, and resets
* margins to print_preview.MarginsTypeValue.DEFAULT. * margins to print_preview.MarginsType.DEFAULT.
*/ */
test(assert(TestNames.ChangeMarginsByPagesPerSheet), function() { test(assert(TestNames.ChangeMarginsByPagesPerSheet), function() {
const MarginsTypeEnum = print_preview.MarginsTypeValue; const MarginsTypeEnum = print_preview.MarginsType;
return initialize() return initialize()
.then(function(args) { .then(function(args) {
const originalTicket = JSON.parse(args.printTicket); const originalTicket = JSON.parse(args.printTicket);
...@@ -466,7 +462,7 @@ cr.define('preview_generation_test', function() { ...@@ -466,7 +462,7 @@ cr.define('preview_generation_test', function() {
/** /**
* @param {Object} ticket The parsed print ticket * @param {Object} ticket The parsed print ticket
* @param {number} expectedId The expected ticket request ID * @param {number} expectedId The expected ticket request ID
* @param {!print_preview.MarginsTypeValue} expectedMargins * @param {!print_preview.MarginsType} expectedMargins
* The expected ticket margins type * The expected ticket margins type
* @param {boolean} expectedHeaderFooter The expected ticket * @param {boolean} expectedHeaderFooter The expected ticket
* header/footer value * header/footer value
...@@ -491,7 +487,7 @@ cr.define('preview_generation_test', function() { ...@@ -491,7 +487,7 @@ cr.define('preview_generation_test', function() {
printableAreaHeight: 792, printableAreaHeight: 792,
}); });
const MarginsTypeEnum = print_preview.MarginsTypeValue; const MarginsTypeEnum = print_preview.MarginsType;
let previewArgs = await initialize(); let previewArgs = await initialize();
let ticket = JSON.parse(previewArgs.printTicket); let ticket = JSON.parse(previewArgs.printTicket);
......
...@@ -219,7 +219,7 @@ cr.define('restore_state_test', function() { ...@@ -219,7 +219,7 @@ cr.define('restore_state_test', function() {
section: 'print-preview-margins-settings', section: 'print-preview-margins-settings',
settingName: 'margins', settingName: 'margins',
key: 'marginsType', key: 'marginsType',
value: print_preview.MarginsTypeValue.MINIMUM, value: print_preview.MarginsType.MINIMUM,
}, },
{ {
section: 'print-preview-dpi-settings', section: 'print-preview-dpi-settings',
......
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