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

Print Preview Componentization: Use destination updates

Listen for destination events and update UI when destination changes.

Bug: 773928
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I1c9aff4f5e6fd1d856727064ab76058c30b12125
Reviewed-on: https://chromium-review.googlesource.com/823579
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524473}
parent 249dc2fe
...@@ -26,24 +26,6 @@ print_preview.AppStateField = { ...@@ -26,24 +26,6 @@ print_preview.AppStateField = {
VENDOR_OPTIONS: 'vendorOptions' VENDOR_OPTIONS: 'vendorOptions'
}; };
/**
* Creates a |RecentDestination| to represent |destination| in the app
* state.
* @param {!print_preview.Destination} destination The destination to store.
* @return {!print_preview.RecentDestination}
*/
function makeRecentDestination(destination) {
return {
id: destination.id,
origin: destination.origin,
account: destination.account || '',
capabilities: destination.capabilities,
displayName: destination.displayName || '',
extensionId: destination.extensionId || '',
extensionName: destination.extensionName || '',
};
}
cr.define('print_preview', function() { cr.define('print_preview', function() {
'use strict'; 'use strict';
class AppState extends cr.EventTarget { class AppState extends cr.EventTarget {
...@@ -221,7 +203,8 @@ cr.define('print_preview', function() { ...@@ -221,7 +203,8 @@ cr.define('print_preview', function() {
// Determine if this destination is already in the recent destinations, // Determine if this destination is already in the recent destinations,
// and where in the array it is located. // and where in the array it is located.
const newDestination = makeRecentDestination(assert(destination)); const newDestination =
print_preview.makeRecentDestination(assert(destination));
let indexFound = let indexFound =
this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] this.state_[print_preview.AppStateField.RECENT_DESTINATIONS]
.findIndex(function(recent) { .findIndex(function(recent) {
......
...@@ -108,9 +108,38 @@ print_preview.CddCapabilities; ...@@ -108,9 +108,38 @@ print_preview.CddCapabilities;
*/ */
print_preview.Cdd; print_preview.Cdd;
/**
* @typedef {{id: string,
* origin: print_preview.DestinationOrigin,
* account: string,
* capabilities: ?print_preview.Cdd,
* displayName: string,
* extensionId: string,
* extensionName: string}}
*/
print_preview.RecentDestination;
cr.define('print_preview', function() { cr.define('print_preview', function() {
'use strict'; 'use strict';
/**
* Creates a |RecentDestination| to represent |destination| in the app
* state.
* @param {!print_preview.Destination} destination The destination to store.
* @return {!print_preview.RecentDestination}
*/
function makeRecentDestination(destination) {
return {
id: destination.id,
origin: destination.origin,
account: destination.account || '',
capabilities: destination.capabilities,
displayName: destination.displayName || '',
extensionId: destination.extensionId || '',
extensionName: destination.extensionName || '',
};
}
class Destination { class Destination {
/** /**
* Print destination data object that holds data for both local and cloud * Print destination data object that holds data for both local and cloud
...@@ -599,5 +628,6 @@ cr.define('print_preview', function() { ...@@ -599,5 +628,6 @@ cr.define('print_preview', function() {
// Export // Export
return { return {
Destination: Destination, Destination: Destination,
makeRecentDestination: makeRecentDestination,
}; };
}); });
...@@ -4,17 +4,6 @@ ...@@ -4,17 +4,6 @@
cr.exportPath('print_preview'); cr.exportPath('print_preview');
/**
* @typedef {{id: string,
* origin: print_preview.DestinationOrigin,
* account: string,
* capabilities: ?print_preview.Cdd,
* displayName: string,
* extensionId: string,
* extensionName: string}}
*/
print_preview.RecentDestination;
/** /**
* Printer search statuses used by the destination store. * Printer search statuses used by the destination store.
* @enum {string} * @enum {string}
......
<link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/html/cr.html"> <link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/event_tracker.html">
<link rel="import" href="chrome://resources/html/webui_listener_tracker.html"> <link rel="import" href="chrome://resources/html/webui_listener_tracker.html">
<link rel="import" href="../native_layer.html"> <link rel="import" href="../native_layer.html">
<link rel="import" href="../data/destination.html"> <link rel="import" href="../data/destination.html">
......
...@@ -59,63 +59,6 @@ Polymer({ ...@@ -59,63 +59,6 @@ Polymer({
destination_: { destination_: {
type: Object, type: Object,
notify: true, notify: true,
value: function() {
const dest = new print_preview.Destination(
'Foo Printer', print_preview.DestinationType.LOCAL,
print_preview.DestinationOrigin.LOCAL, 'Foo Printer', true,
print_preview.DestinationConnectionStatus.ONLINE,
{description: 'PrinterBrandAA 12345'});
dest.capabilities = {
version: '1.0',
printer: {
collate: {default: true},
color: {
option: [
{type: 'STANDARD_COLOR', is_default: true},
{type: 'STANDARD_MONOCHROME'}
]
},
copies: {default: 1, max: 1000},
dpi: {
option: [
{horizontal_dpi: 200, vertical_dpi: 200, is_default: true},
{horizontal_dpi: 100, vertical_dpi: 100},
]
},
duplex: {
option: [
{type: 'NO_DUPLEX', is_default: true}, {type: 'LONG_EDGE'},
{type: 'SHORT_EDGE'}
]
},
page_orientation: {
option: [
{type: 'PORTRAIT', is_default: true}, {type: 'LANDSCAPE'},
{type: 'AUTO'}
]
},
media_size: {
option: [
{
name: 'NA_LETTER',
width_microns: 215900,
height_microns: 279400,
is_default: true,
custom_display_name: 'Letter',
},
{
name: 'CUSTOM_SQUARE',
width_microns: 215900,
height_microns: 215900,
custom_display_name: 'CUSTOM_SQUARE',
}
]
},
vendor_capability: [],
}
};
return dest;
},
}, },
/** @private {!print_preview_new.State} */ /** @private {!print_preview_new.State} */
...@@ -132,6 +75,16 @@ Polymer({ ...@@ -132,6 +75,16 @@ Polymer({
}, },
}, },
observers: [
'updateRecentDestinations_(destination_, destination_.capabilities)',
],
/**
* @private {number} Number of recent destinations to save.
* @const
*/
NUM_DESTINATIONS_: 3,
/** @private {?print_preview.NativeLayer} */ /** @private {?print_preview.NativeLayer} */
nativeLayer_: null, nativeLayer_: null,
...@@ -141,6 +94,12 @@ Polymer({ ...@@ -141,6 +94,12 @@ Polymer({
/** @private {?WebUIListenerTracker} */ /** @private {?WebUIListenerTracker} */
listenerTracker_: null, listenerTracker_: null,
/** @private {?print_preview.DestinationStore} */
destinationStore_: null,
/** @private {!EventTracker} */
tracker_: new EventTracker(),
/** @type {!print_preview.MeasurementSystem} */ /** @type {!print_preview.MeasurementSystem} */
measurementSystem_: new print_preview.MeasurementSystem( measurementSystem_: new print_preview.MeasurementSystem(
',', '.', print_preview.MeasurementSystemUnitType.IMPERIAL), ',', '.', print_preview.MeasurementSystemUnitType.IMPERIAL),
...@@ -156,6 +115,15 @@ Polymer({ ...@@ -156,6 +115,15 @@ Polymer({
this.listenerTracker_ = new WebUIListenerTracker(); this.listenerTracker_ = new WebUIListenerTracker();
this.destinationStore_ = new print_preview.DestinationStore( this.destinationStore_ = new print_preview.DestinationStore(
this.userInfo_, this.listenerTracker_); this.userInfo_, this.listenerTracker_);
this.tracker_.add(
this.destinationStore_,
print_preview.DestinationStore.EventType.DESTINATION_SELECT,
this.onDestinationSelect_.bind(this));
this.tracker_.add(
this.destinationStore_,
print_preview.DestinationStore.EventType
.SELECTED_DESTINATION_CAPABILITIES_READY,
this.onDestinationUpdated_.bind(this));
this.nativeLayer_.getInitialSettings().then( this.nativeLayer_.getInitialSettings().then(
this.onInitialSettingsSet_.bind(this)); this.onInitialSettingsSet_.bind(this));
}, },
...@@ -163,6 +131,7 @@ Polymer({ ...@@ -163,6 +131,7 @@ Polymer({
/** @override */ /** @override */
detached: function() { detached: function() {
this.listenerTracker_.removeAll(); this.listenerTracker_.removeAll();
this.tracker_.removeAll();
}, },
/** /**
...@@ -193,6 +162,53 @@ Polymer({ ...@@ -193,6 +162,53 @@ Polymer({
this.recentDestinations_); this.recentDestinations_);
}, },
/** @private */
onDestinationSelect_: function() {
this.destination_ = this.destinationStore_.selectedDestination;
},
/** @private */
onDestinationUpdated_: function() {
this.set(
'destination_.capabilities',
this.destinationStore_.selectedDestination.capabilities);
},
/** @private */
updateRecentDestinations_: function() {
if (!this.destination_)
return;
// Determine if this destination is already in the recent destinations,
// and where in the array it is located.
const newDestination =
print_preview.makeRecentDestination(assert(this.destination_));
let indexFound = this.recentDestinations_.findIndex(function(recent) {
return (
newDestination.id == recent.id &&
newDestination.origin == recent.origin);
});
// No change
if (indexFound == 0 &&
this.recentDestinations_[0].capabilities ==
newDestination.capabilities) {
return;
}
// Shift the array so that the nth most recent destination is located at
// index n.
if (indexFound == -1 &&
this.recentDestinations_.length == this.NUM_DESTINATIONS_) {
indexFound = this.NUM_DESTINATIONS_ - 1;
}
if (indexFound != -1)
this.recentDestinations_.splice(indexFound, 1);
// Add the most recent destination
this.recentDestinations_.splice(0, 0, newDestination);
},
/** /**
* @param {?string} savedSettingsStr The sticky settings from native layer * @param {?string} savedSettingsStr The sticky settings from native layer
* @private * @private
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
'../data/compiled_resources2.gyp:document_info', '../data/compiled_resources2.gyp:document_info',
'../data/compiled_resources2.gyp:measurement_system', '../data/compiled_resources2.gyp:measurement_system',
'../data/compiled_resources2.gyp:user_info', '../data/compiled_resources2.gyp:user_info',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:event_tracker',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:webui_listener_tracker', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:webui_listener_tracker',
], ],
'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'],
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
align-items: center; align-items: center;
display: flex; display: flex;
min-height: 28px; min-height: 28px;
overflow: hidden;
} }
.destination-icon { .destination-icon {
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
display: flex; display: flex;
flex: 1; flex: 1;
flex-direction: column; flex-direction: column;
overflow: hidden;
width: 100%; width: 100%;
} }
......
...@@ -175,6 +175,7 @@ Polymer({ ...@@ -175,6 +175,7 @@ Polymer({
'destination.id, destination.capabilities, ' + 'destination.id, destination.capabilities, ' +
'documentInfo.isModifiable, documentInfo.hasCssMediaStyles,' + 'documentInfo.isModifiable, documentInfo.hasCssMediaStyles,' +
'documentInfo.hasSelection)'], 'documentInfo.hasSelection)'],
/** /**
* @private {!Array<string>} List of capability types considered color. * @private {!Array<string>} List of capability types considered color.
* @const * @const
......
...@@ -12,13 +12,15 @@ ...@@ -12,13 +12,15 @@
::slotted([slot=controls]) { ::slotted([slot=controls]) {
flex: 1; flex: 1;
overflow: hidden;
} }
::slotted([slot=title]) { ::slotted([slot=title]) {
-webkit-padding-end: 20px; -webkit-padding-end: 20px;
color: #646464; color: #646464;
font-size: 1em; font-size: 1em;
width: 70px; max-width: 70px;
min-width: 70px;
word-break: break-word; word-break: break-word;
} }
......
...@@ -50,6 +50,7 @@ PrintPreviewSettingsSectionsTest = class extends NewPrintPreviewTest { ...@@ -50,6 +50,7 @@ PrintPreviewSettingsSectionsTest = class extends NewPrintPreviewTest {
/** @override */ /** @override */
get extraLibraries() { get extraLibraries() {
return super.extraLibraries.concat([ return super.extraLibraries.concat([
'print_preview_test_utils.js',
'settings_section_test.js', 'settings_section_test.js',
]); ]);
} }
...@@ -103,7 +104,7 @@ PrintPreviewRestoreStateTest = class extends NewPrintPreviewTest { ...@@ -103,7 +104,7 @@ PrintPreviewRestoreStateTest = class extends NewPrintPreviewTest {
return super.extraLibraries.concat([ return super.extraLibraries.concat([
'../test_browser_proxy.js', '../test_browser_proxy.js',
'native_layer_stub.js', 'native_layer_stub.js',
'print_preview_tests.js', 'print_preview_test_utils.js',
'restore_state_test.js', 'restore_state_test.js',
]); ]);
} }
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
cr.define('print_preview_test_utils', function() {
/**
* @param {string} printerId
* @param {string=} opt_printerName Defaults to an empty string.
* @return {!print_preview.PrinterCapabilitiesResponse}
*/
function getCddTemplate(printerId, opt_printerName) {
return {
printer: {
deviceName: printerId,
printerName: opt_printerName || '',
},
capabilities: {
version: '1.0',
printer: {
supported_content_type: [{content_type: 'application/pdf'}],
collate: {default: true},
copies: {default: 1, max: 1000},
color: {
option: [
{type: 'STANDARD_COLOR', is_default: true},
{type: 'STANDARD_MONOCHROME'}
]
},
dpi: {
option: [
{horizontal_dpi: 200, vertical_dpi: 200, is_default: true},
{horizontal_dpi: 100, vertical_dpi: 100},
]
},
duplex: {
option: [
{type: 'NO_DUPLEX', is_default: true},
{type: 'LONG_EDGE'},
{type: 'SHORT_EDGE'}
]
},
page_orientation: {
option: [
{type: 'PORTRAIT', is_default: true},
{type: 'LANDSCAPE'},
{type: 'AUTO'}
]
},
media_size: {
option: [
{ name: 'NA_LETTER',
width_microns: 215900,
height_microns: 279400,
is_default: true,
custom_display_name: "Letter",
},
{
name: 'CUSTOM_SQUARE',
width_microns: 215900,
height_microns: 215900,
custom_display_name: "CUSTOM_SQUARE",
}
]
}
}
}
};
}
return {
getCddTemplate: getCddTemplate,
};
});
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
/** @fileoverview Runs the Print Preview tests. */ /** @fileoverview Runs the Print Preview tests. */
var ROOT_PATH = '../../../../../'; const ROOT_PATH = '../../../../../';
/** /**
* @constructor * @constructor
...@@ -59,6 +59,7 @@ PrintPreviewUIBrowserTest.prototype = { ...@@ -59,6 +59,7 @@ PrintPreviewUIBrowserTest.prototype = {
'print_preview_tests.js', 'print_preview_tests.js',
'native_layer_stub.js', 'native_layer_stub.js',
'plugin_stub.js', 'plugin_stub.js',
'print_preview_test_utils.js',
], ],
}; };
......
...@@ -72,7 +72,7 @@ cr.define('restore_state_test', function() { ...@@ -72,7 +72,7 @@ cr.define('restore_state_test', function() {
nativeLayer.setInitialSettings(initialSettings); nativeLayer.setInitialSettings(initialSettings);
nativeLayer.setLocalDestinationCapabilities( nativeLayer.setLocalDestinationCapabilities(
print_preview_test.getCddTemplate(initialSettings.printerName)); print_preview_test_utils.getCddTemplate(initialSettings.printerName));
page = document.createElement('print-preview-app'); page = document.createElement('print-preview-app');
document.body.appendChild(page); document.body.appendChild(page);
......
...@@ -24,60 +24,16 @@ cr.define('settings_sections_tests', function() { ...@@ -24,60 +24,16 @@ cr.define('settings_sections_tests', function() {
PolymerTest.clearBody(); PolymerTest.clearBody();
page = document.createElement('print-preview-app'); page = document.createElement('print-preview-app');
document.body.appendChild(page); document.body.appendChild(page);
});
/** @return {!print_preview.Cdd} */ const fooDestination = new print_preview.Destination(
function getCdd() { 'FooPrinter', print_preview.DestinationType.LOCAL,
return { print_preview.DestinationOrigin.LOCAL, 'Foo Printer',
version: '1.0', false /*isRecent*/, print_preview.DestinationConnectionStatus.ONLINE);
printer: { fooDestination.capabilities =
collate: {default: true}, print_preview_test_utils.getCddTemplate(fooDestination.id)
copies: {default: 1, max: 1000}, .capabilities;
color: { page.set('destination_', fooDestination);
option: [ });
{type: 'STANDARD_COLOR', is_default: true},
{type: 'STANDARD_MONOCHROME'}
]
},
dpi: {
option: [
{horizontal_dpi: 200, vertical_dpi: 200, is_default: true},
{horizontal_dpi: 100, vertical_dpi: 100},
]
},
duplex: {
option: [
{type: 'NO_DUPLEX', is_default: true}, {type: 'LONG_EDGE'},
{type: 'SHORT_EDGE'}
]
},
page_orientation: {
option: [
{type: 'PORTRAIT', is_default: true}, {type: 'LANDSCAPE'},
{type: 'AUTO'}
]
},
media_size: {
option: [
{
name: 'NA_LETTER',
width_microns: 215900,
height_microns: 279400,
is_default: true,
custom_display_name: 'Letter',
},
{
name: 'CUSTOM_SQUARE',
width_microns: 215900,
height_microns: 215900,
custom_display_name: 'CUSTOM_SQUARE',
}
]
},
vendor_capability: [],
},
};
}
/** @param {boolean} isPdf Whether the document should be a PDF. */ /** @param {boolean} isPdf Whether the document should be a PDF. */
function setPdfDocument(isPdf) { function setPdfDocument(isPdf) {
...@@ -93,7 +49,9 @@ cr.define('settings_sections_tests', function() { ...@@ -93,7 +49,9 @@ cr.define('settings_sections_tests', function() {
print_preview.DestinationOrigin.LOCAL, print_preview.DestinationOrigin.LOCAL,
loadTimeData.getString('printToPDF'), false /*isRecent*/, loadTimeData.getString('printToPDF'), false /*isRecent*/,
print_preview.DestinationConnectionStatus.ONLINE); print_preview.DestinationConnectionStatus.ONLINE);
saveAsPdfDestination.capabilities = getCdd(); saveAsPdfDestination.capabilities =
print_preview_test_utils.getCddTemplate(saveAsPdfDestination.id)
.capabilities;
page.set('destination_', saveAsPdfDestination); page.set('destination_', saveAsPdfDestination);
} }
...@@ -102,7 +60,8 @@ cr.define('settings_sections_tests', function() { ...@@ -102,7 +60,8 @@ cr.define('settings_sections_tests', function() {
expectEquals(false, copiesElement.hidden); expectEquals(false, copiesElement.hidden);
// Remove copies capability. // Remove copies capability.
const capabilities = getCdd(); let capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
delete capabilities.printer.copies; delete capabilities.printer.copies;
// Copies section should now be hidden. // Copies section should now be hidden.
...@@ -118,16 +77,16 @@ cr.define('settings_sections_tests', function() { ...@@ -118,16 +77,16 @@ cr.define('settings_sections_tests', function() {
expectEquals(false, layoutElement.hidden); expectEquals(false, layoutElement.hidden);
// Remove layout capability. // Remove layout capability.
let capabilities = getCdd(); let capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
delete capabilities.printer.page_orientation; delete capabilities.printer.page_orientation;
// Each of these settings should not show the capability. // Each of these settings should not show the capability.
[ [null, {option: [{type: 'PORTRAIT', is_default: true}]},
null, {option: [{type: 'LANDSCAPE', is_default: true}]},
{option: [{ type: 'PORTRAIT', is_default: true }]},
{option: [{ type: 'LANDSCAPE', is_default: true}]},
].forEach(layoutCap => { ].forEach(layoutCap => {
capabilities = getCdd(); capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
capabilities.printer.page_orientation = layoutCap; capabilities.printer.page_orientation = layoutCap;
// Layout section should now be hidden. // Layout section should now be hidden.
page.set('destination_.capabilities', capabilities); page.set('destination_.capabilities', capabilities);
...@@ -135,7 +94,8 @@ cr.define('settings_sections_tests', function() { ...@@ -135,7 +94,8 @@ cr.define('settings_sections_tests', function() {
}); });
// Reset full capabilities // Reset full capabilities
capabilities = getCdd(); capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
page.set('destination_.capabilities', capabilities); page.set('destination_.capabilities', capabilities);
expectEquals(false, layoutElement.hidden); expectEquals(false, layoutElement.hidden);
...@@ -149,20 +109,26 @@ cr.define('settings_sections_tests', function() { ...@@ -149,20 +109,26 @@ cr.define('settings_sections_tests', function() {
expectEquals(false, colorElement.hidden); expectEquals(false, colorElement.hidden);
// Remove color capability. // Remove color capability.
let capabilities = getCdd(); let capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
delete capabilities.printer.color; delete capabilities.printer.color;
// Each of these settings should not show the capability. // Each of these settings should not show the capability.
[ [null, {option: [{type: 'STANDARD_COLOR', is_default: true}]}, {
null, option: [
{option: [{ type: 'STANDARD_COLOR', is_default: true }]}, {type: 'STANDARD_COLOR', is_default: true}, {type: 'CUSTOM_COLOR'}
{option: [{ type: 'STANDARD_COLOR', is_default: true }, ]
{ type: 'CUSTOM_COLOR'}]}, },
{option: [{ type: 'STANDARD_MONOCHROME', is_default: true }, {
{ type: 'CUSTOM_MONOCHROME' }]}, option: [
{option: [{ type: 'STANDARD_MONOCHROME', is_default: true}]}, {type: 'STANDARD_MONOCHROME', is_default: true},
{type: 'CUSTOM_MONOCHROME'}
]
},
{option: [{type: 'STANDARD_MONOCHROME', is_default: true}]},
].forEach(colorCap => { ].forEach(colorCap => {
capabilities = getCdd(); capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
capabilities.printer.color = colorCap; capabilities.printer.color = colorCap;
// Layout section should now be hidden. // Layout section should now be hidden.
page.set('destination_.capabilities', capabilities); page.set('destination_.capabilities', capabilities);
...@@ -170,7 +136,8 @@ cr.define('settings_sections_tests', function() { ...@@ -170,7 +136,8 @@ cr.define('settings_sections_tests', function() {
}); });
// Custom color and monochrome options should make the section visible. // Custom color and monochrome options should make the section visible.
capabilities = getCdd(); capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
capabilities.printer.color = capabilities.printer.color =
{option: [{ type: 'CUSTOM_COLOR', is_default: true }, {option: [{ type: 'CUSTOM_COLOR', is_default: true },
{ type: 'CUSTOM_MONOCHROME' }]}; { type: 'CUSTOM_MONOCHROME' }]};
...@@ -183,7 +150,8 @@ cr.define('settings_sections_tests', function() { ...@@ -183,7 +150,8 @@ cr.define('settings_sections_tests', function() {
expectEquals(false, mediaSizeElement.hidden); expectEquals(false, mediaSizeElement.hidden);
// Remove capability. // Remove capability.
let capabilities = getCdd(); let capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
delete capabilities.printer.media_size; delete capabilities.printer.media_size;
// Section should now be hidden. // Section should now be hidden.
...@@ -191,7 +159,8 @@ cr.define('settings_sections_tests', function() { ...@@ -191,7 +159,8 @@ cr.define('settings_sections_tests', function() {
expectEquals(true, mediaSizeElement.hidden); expectEquals(true, mediaSizeElement.hidden);
// Reset // Reset
capabilities = getCdd(); capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
page.set('destination_.capabilities', capabilities); page.set('destination_.capabilities', capabilities);
// Set PDF document type. // Set PDF document type.
...@@ -224,7 +193,8 @@ cr.define('settings_sections_tests', function() { ...@@ -224,7 +193,8 @@ cr.define('settings_sections_tests', function() {
expectEquals(false, dpiElement.hidden); expectEquals(false, dpiElement.hidden);
// Remove capability. // Remove capability.
let capabilities = getCdd(); let capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
delete capabilities.printer.dpi; delete capabilities.printer.dpi;
// Section should now be hidden. // Section should now be hidden.
...@@ -232,7 +202,8 @@ cr.define('settings_sections_tests', function() { ...@@ -232,7 +202,8 @@ cr.define('settings_sections_tests', function() {
expectEquals(true, dpiElement.hidden); expectEquals(true, dpiElement.hidden);
// Does not show up for only 1 option. // Does not show up for only 1 option.
capabilities = getCdd(); capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
capabilities.printer.dpi.option.pop(); capabilities.printer.dpi.option.pop();
page.set('destination_.capabilities', capabilities); page.set('destination_.capabilities', capabilities);
expectEquals(true, dpiElement.hidden); expectEquals(true, dpiElement.hidden);
...@@ -273,7 +244,8 @@ cr.define('settings_sections_tests', function() { ...@@ -273,7 +244,8 @@ cr.define('settings_sections_tests', function() {
// Start with HTML + duplex capability. // Start with HTML + duplex capability.
setPdfDocument(false); setPdfDocument(false);
let capabilities = getCdd(); let capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
page.set('destination_.capabilities', capabilities); page.set('destination_.capabilities', capabilities);
expectEquals(false, optionsElement.hidden); expectEquals(false, optionsElement.hidden);
expectEquals(false, headerFooter.hidden); expectEquals(false, headerFooter.hidden);
...@@ -290,7 +262,8 @@ cr.define('settings_sections_tests', function() { ...@@ -290,7 +262,8 @@ cr.define('settings_sections_tests', function() {
expectEquals(false, selectionOnly.hidden); expectEquals(false, selectionOnly.hidden);
// Remove duplex capability. // Remove duplex capability.
capabilities = getCdd(); capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
delete capabilities.printer.duplex; delete capabilities.printer.duplex;
page.set('destination_.capabilities', capabilities); page.set('destination_.capabilities', capabilities);
expectEquals(false, optionsElement.hidden); expectEquals(false, optionsElement.hidden);
...@@ -313,7 +286,8 @@ cr.define('settings_sections_tests', function() { ...@@ -313,7 +286,8 @@ cr.define('settings_sections_tests', function() {
expectEquals(true, selectionOnly.hidden); expectEquals(true, selectionOnly.hidden);
// Add duplex. // Add duplex.
capabilities = getCdd(); capabilities =
print_preview_test_utils.getCddTemplate('FooPrinter').capabilities;
page.set('destination_.capabilities', capabilities); page.set('destination_.capabilities', capabilities);
expectEquals(false, optionsElement.hidden); expectEquals(false, optionsElement.hidden);
expectEquals(false, duplex.hidden); expectEquals(false, duplex.hidden);
......
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