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,
};
});
...@@ -59,7 +59,8 @@ cr.define('print_preview_test', function() { ...@@ -59,7 +59,8 @@ cr.define('print_preview_test', function() {
function setupSettingsAndDestinationsWithCapabilities(opt_device) { function setupSettingsAndDestinationsWithCapabilities(opt_device) {
nativeLayer.setInitialSettings(initialSettings); nativeLayer.setInitialSettings(initialSettings);
nativeLayer.setLocalDestinations(localDestinationInfos); nativeLayer.setLocalDestinations(localDestinationInfos);
opt_device = opt_device || getCddTemplate('FooDevice', 'FooName'); opt_device = opt_device ||
print_preview_test_utils.getCddTemplate('FooDevice', 'FooName');
nativeLayer.setLocalDestinationCapabilities(opt_device); nativeLayer.setLocalDestinationCapabilities(opt_device);
printPreview.initialize(); printPreview.initialize();
...@@ -106,70 +107,6 @@ cr.define('print_preview_test', function() { ...@@ -106,70 +107,6 @@ cr.define('print_preview_test', function() {
'element="' + el.id + '" of class "' + el.classList + '"'); 'element="' + el.id + '" of class "' + el.classList + '"');
} }
/**
* @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: {},
color: {
option: [
{type: 'STANDARD_COLOR', is_default: true},
{type: 'STANDARD_MONOCHROME'}
]
},
copies: {},
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 {!print_preview.PrinterCapabilitiesResponse} The capabilities of * @return {!print_preview.PrinterCapabilitiesResponse} The capabilities of
* the Save as PDF destination. * the Save as PDF destination.
...@@ -214,7 +151,8 @@ cr.define('print_preview_test', function() { ...@@ -214,7 +151,8 @@ cr.define('print_preview_test', function() {
*/ */
function getAppStateString() { function getAppStateString() {
const origin = cr.isChromeOS ? 'chrome_os' : 'local'; const origin = cr.isChromeOS ? 'chrome_os' : 'local';
const cdd = getCddTemplate('ID1', 'One').capabilities; const cdd =
print_preview_test_utils.getCddTemplate('ID1', 'One').capabilities;
return JSON.stringify({ return JSON.stringify({
version: 2, version: 2,
recentDestinations: [ recentDestinations: [
...@@ -293,7 +231,7 @@ cr.define('print_preview_test', function() { ...@@ -293,7 +231,7 @@ cr.define('print_preview_test', function() {
* @return {!Object} * @return {!Object}
*/ */
function getCddTemplateWithAdvancedSettings(printerId) { function getCddTemplateWithAdvancedSettings(printerId) {
const template = getCddTemplate(printerId); const template = print_preview_test_utils.getCddTemplate(printerId);
template.capabilities.printer.vendor_capability = [{ template.capabilities.printer.vendor_capability = [{
display_name: 'Print Area', display_name: 'Print Area',
id: 'Print Area', id: 'Print Area',
...@@ -517,7 +455,8 @@ cr.define('print_preview_test', function() { ...@@ -517,7 +455,8 @@ cr.define('print_preview_test', function() {
}, },
], ],
}); });
nativeLayer.setLocalDestinationCapabilities(getCddTemplate('ID')); nativeLayer.setLocalDestinationCapabilities(
print_preview_test_utils.getCddTemplate('ID'));
setInitialSettings(); setInitialSettings();
return nativeLayer.whenCalled('getInitialSettings'); return nativeLayer.whenCalled('getInitialSettings');
}); });
...@@ -536,7 +475,7 @@ cr.define('print_preview_test', function() { ...@@ -536,7 +475,7 @@ cr.define('print_preview_test', function() {
// Set up capabilities for ID1. This should be the device that should hav // Set up capabilities for ID1. This should be the device that should hav
// its capabilities fetched, since it is the most recent. If another // its capabilities fetched, since it is the most recent. If another
// device is selected the native layer will reject the callback. // device is selected the native layer will reject the callback.
const device = getCddTemplate('ID1', 'One'); const device = print_preview_test_utils.getCddTemplate('ID1', 'One');
return setupSettingsAndDestinationsWithCapabilities(device).then( return setupSettingsAndDestinationsWithCapabilities(device).then(
function() { function() {
...@@ -578,10 +517,12 @@ cr.define('print_preview_test', function() { ...@@ -578,10 +517,12 @@ cr.define('print_preview_test', function() {
]; ];
initialSettings.printerName = 'ID3'; initialSettings.printerName = 'ID3';
const device = getCddTemplate('ID3', 'Three'); const device = print_preview_test_utils.getCddTemplate('ID3', 'Three');
nativeLayer.setLocalDestinationCapabilities(getCddTemplate('ID1', 'One')); nativeLayer.setLocalDestinationCapabilities(
nativeLayer.setLocalDestinationCapabilities(getCddTemplate('ID2', 'Two')); print_preview_test_utils.getCddTemplate('ID1', 'One'));
nativeLayer.setLocalDestinationCapabilities(
print_preview_test_utils.getCddTemplate('ID2', 'Two'));
return setupSettingsAndDestinationsWithCapabilities(device).then( return setupSettingsAndDestinationsWithCapabilities(device).then(
function() { function() {
nativeLayer.reset(); nativeLayer.reset();
...@@ -634,7 +575,7 @@ cr.define('print_preview_test', function() { ...@@ -634,7 +575,7 @@ cr.define('print_preview_test', function() {
{ printerName: 'Two', deviceName: 'ID2' }, { printerName: 'Two', deviceName: 'ID2' },
{ printerName: 'Three', deviceName: 'ID3' }, { printerName: 'Three', deviceName: 'ID3' },
]; ];
const device = getCddTemplate('ID1', 'One'); const device = print_preview_test_utils.getCddTemplate('ID1', 'One');
return Promise.all([ return Promise.all([
setupSettingsAndDestinationsWithCapabilities(device), setupSettingsAndDestinationsWithCapabilities(device),
...@@ -689,7 +630,9 @@ cr.define('print_preview_test', function() { ...@@ -689,7 +630,9 @@ cr.define('print_preview_test', function() {
initialSettings.serializedDefaultDestinationSelectionRulesStr = initialSettings.serializedDefaultDestinationSelectionRulesStr =
JSON.stringify({namePattern: '.*Bar.*'}); JSON.stringify({namePattern: '.*Bar.*'});
return setupSettingsAndDestinationsWithCapabilities( return setupSettingsAndDestinationsWithCapabilities(
getCddTemplate('BarDevice', 'BarName')).then(function() { print_preview_test_utils.getCddTemplate(
'BarDevice', 'BarName'))
.then(function() {
assertEquals('BarDevice', assertEquals('BarDevice',
printPreview.destinationStore_.selectedDestination.id); printPreview.destinationStore_.selectedDestination.id);
}); });
...@@ -698,7 +641,8 @@ cr.define('print_preview_test', function() { ...@@ -698,7 +641,8 @@ cr.define('print_preview_test', function() {
test('SystemDialogLinkIsHiddenInAppKioskMode', function() { test('SystemDialogLinkIsHiddenInAppKioskMode', function() {
if (!cr.isChromeOS) if (!cr.isChromeOS)
initialSettings.isInAppKioskMode = true; initialSettings.isInAppKioskMode = true;
nativeLayer.setLocalDestinationCapabilities(getCddTemplate('FooDevice')); nativeLayer.setLocalDestinationCapabilities(
print_preview_test_utils.getCddTemplate('FooDevice'));
setInitialSettings(); setInitialSettings();
return nativeLayer.whenCalled('getInitialSettings').then( return nativeLayer.whenCalled('getInitialSettings').then(
function() { function() {
...@@ -713,7 +657,7 @@ cr.define('print_preview_test', function() { ...@@ -713,7 +657,7 @@ cr.define('print_preview_test', function() {
checkSectionVisible($('layout-settings'), false); checkSectionVisible($('layout-settings'), false);
checkSectionVisible($('color-settings'), false); checkSectionVisible($('color-settings'), false);
checkSectionVisible($('copies-settings'), false); checkSectionVisible($('copies-settings'), false);
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
device.capabilities.printer.color = { device.capabilities.printer.color = {
option: [{is_default: true, type: 'STANDARD_COLOR'}] option: [{is_default: true, type: 'STANDARD_COLOR'}]
}; };
...@@ -1041,7 +985,7 @@ cr.define('print_preview_test', function() { ...@@ -1041,7 +985,7 @@ cr.define('print_preview_test', function() {
// Check header footer availability with small (label) page size. // Check header footer availability with small (label) page size.
test('SmallPaperSizeHeaderFooter', function() { test('SmallPaperSizeHeaderFooter', function() {
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
device.capabilities.printer.media_size = { device.capabilities.printer.media_size = {
'option': [ 'option': [
{'name': 'SmallLabel', 'width_microns': 38100, {'name': 'SmallLabel', 'width_microns': 38100,
...@@ -1083,7 +1027,7 @@ cr.define('print_preview_test', function() { ...@@ -1083,7 +1027,7 @@ cr.define('print_preview_test', function() {
// Test that the color settings, one option, standard monochrome. // Test that the color settings, one option, standard monochrome.
test('ColorSettingsMonochrome', function() { test('ColorSettingsMonochrome', function() {
// Only one option, standard monochrome. // Only one option, standard monochrome.
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
device.capabilities.printer.color = { device.capabilities.printer.color = {
'option': [ 'option': [
{'is_default': true, 'type': 'STANDARD_MONOCHROME'} {'is_default': true, 'type': 'STANDARD_MONOCHROME'}
...@@ -1101,7 +1045,7 @@ cr.define('print_preview_test', function() { ...@@ -1101,7 +1045,7 @@ cr.define('print_preview_test', function() {
// Test that the color settings, one option, custom monochrome. // Test that the color settings, one option, custom monochrome.
test('ColorSettingsCustomMonochrome', function() { test('ColorSettingsCustomMonochrome', function() {
// Only one option, standard monochrome. // Only one option, standard monochrome.
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
device.capabilities.printer.color = { device.capabilities.printer.color = {
'option': [ 'option': [
{'is_default': true, 'type': 'CUSTOM_MONOCHROME', {'is_default': true, 'type': 'CUSTOM_MONOCHROME',
...@@ -1119,7 +1063,7 @@ cr.define('print_preview_test', function() { ...@@ -1119,7 +1063,7 @@ cr.define('print_preview_test', function() {
// Test that the color settings, one option, standard color. // Test that the color settings, one option, standard color.
test('ColorSettingsColor', function() { test('ColorSettingsColor', function() {
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
device.capabilities.printer.color = { device.capabilities.printer.color = {
'option': [ 'option': [
{'is_default': true, 'type': 'STANDARD_COLOR'} {'is_default': true, 'type': 'STANDARD_COLOR'}
...@@ -1136,7 +1080,7 @@ cr.define('print_preview_test', function() { ...@@ -1136,7 +1080,7 @@ cr.define('print_preview_test', function() {
// Test that the color settings, one option, custom color. // Test that the color settings, one option, custom color.
test('ColorSettingsCustomColor', function() { test('ColorSettingsCustomColor', function() {
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
device.capabilities.printer.color = { device.capabilities.printer.color = {
'option': [ 'option': [
{'is_default': true, 'type': 'CUSTOM_COLOR', 'vendor_id': '42'} {'is_default': true, 'type': 'CUSTOM_COLOR', 'vendor_id': '42'}
...@@ -1153,7 +1097,7 @@ cr.define('print_preview_test', function() { ...@@ -1153,7 +1097,7 @@ cr.define('print_preview_test', function() {
// Test that the color settings, two options, both standard, defaults to // Test that the color settings, two options, both standard, defaults to
// color. // color.
test('ColorSettingsBothStandardDefaultColor', function() { test('ColorSettingsBothStandardDefaultColor', function() {
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
device.capabilities.printer.color = { device.capabilities.printer.color = {
'option': [ 'option': [
{'type': 'STANDARD_MONOCHROME'}, {'type': 'STANDARD_MONOCHROME'},
...@@ -1175,7 +1119,7 @@ cr.define('print_preview_test', function() { ...@@ -1175,7 +1119,7 @@ cr.define('print_preview_test', function() {
// Test that the color settings, two options, both standard, defaults to // Test that the color settings, two options, both standard, defaults to
// monochrome. // monochrome.
test('ColorSettingsBothStandardDefaultMonochrome', function() { test('ColorSettingsBothStandardDefaultMonochrome', function() {
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
device.capabilities.printer.color = { device.capabilities.printer.color = {
'option': [ 'option': [
{'is_default': true, 'type': 'STANDARD_MONOCHROME'}, {'is_default': true, 'type': 'STANDARD_MONOCHROME'},
...@@ -1197,7 +1141,7 @@ cr.define('print_preview_test', function() { ...@@ -1197,7 +1141,7 @@ cr.define('print_preview_test', function() {
// Test that the color settings, two options, both custom, defaults to // Test that the color settings, two options, both custom, defaults to
// color. // color.
test('ColorSettingsBothCustomDefaultColor', function() { test('ColorSettingsBothCustomDefaultColor', function() {
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
device.capabilities.printer.color = { device.capabilities.printer.color = {
'option': [ 'option': [
{'type': 'CUSTOM_MONOCHROME', 'vendor_id': '42'}, {'type': 'CUSTOM_MONOCHROME', 'vendor_id': '42'},
...@@ -1233,7 +1177,7 @@ cr.define('print_preview_test', function() { ...@@ -1233,7 +1177,7 @@ cr.define('print_preview_test', function() {
// Test to verify that duplex settings are set according to the printer // Test to verify that duplex settings are set according to the printer
// capabilities. // capabilities.
test('DuplexSettingsFalse', function() { test('DuplexSettingsFalse', function() {
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
delete device.capabilities.printer.duplex; delete device.capabilities.printer.duplex;
return setupSettingsAndDestinationsWithCapabilities(device) return setupSettingsAndDestinationsWithCapabilities(device)
.then(function() { .then(function() {
...@@ -1263,7 +1207,7 @@ cr.define('print_preview_test', function() { ...@@ -1263,7 +1207,7 @@ cr.define('print_preview_test', function() {
nativeLayer.reset(); nativeLayer.reset();
// Setup capabilities for BarDevice. // Setup capabilities for BarDevice.
const device = getCddTemplate('BarDevice'); const device = print_preview_test_utils.getCddTemplate('BarDevice');
device.capabilities.printer.color = { device.capabilities.printer.color = {
'option': [ 'option': [
{'is_default': true, 'type': 'STANDARD_MONOCHROME'} {'is_default': true, 'type': 'STANDARD_MONOCHROME'}
...@@ -1288,7 +1232,8 @@ cr.define('print_preview_test', function() { ...@@ -1288,7 +1232,8 @@ cr.define('print_preview_test', function() {
previewArea.checkPluginCompatibility_ = function() { previewArea.checkPluginCompatibility_ = function() {
return false; return false;
}; };
nativeLayer.setLocalDestinationCapabilities(getCddTemplate('FooDevice')); nativeLayer.setLocalDestinationCapabilities(
print_preview_test_utils.getCddTemplate('FooDevice'));
setInitialSettings(); setInitialSettings();
return nativeLayer.whenCalled('getInitialSettings').then(function() { return nativeLayer.whenCalled('getInitialSettings').then(function() {
const previewAreaEl = $('preview-area'); const previewAreaEl = $('preview-area');
...@@ -1319,7 +1264,7 @@ cr.define('print_preview_test', function() { ...@@ -1319,7 +1264,7 @@ cr.define('print_preview_test', function() {
const customLocalizedMediaName = 'Vendor defined localized media name'; const customLocalizedMediaName = 'Vendor defined localized media name';
const customMediaName = 'Vendor defined media name'; const customMediaName = 'Vendor defined media name';
const device = getCddTemplate('FooDevice'); const device = print_preview_test_utils.getCddTemplate('FooDevice');
device.capabilities.printer.media_size = { device.capabilities.printer.media_size = {
option: [ option: [
{ name: 'CUSTOM', { name: 'CUSTOM',
...@@ -1412,17 +1357,24 @@ cr.define('print_preview_test', function() { ...@@ -1412,17 +1357,24 @@ cr.define('print_preview_test', function() {
version: 2, version: 2,
recentDestinations: [1, 2, 3].map(function(i) { recentDestinations: [1, 2, 3].map(function(i) {
return { return {
id: 'ID' + i, origin: origin, account: '', id: 'ID' + i,
capabilities: getCddTemplate('ID' + i), displayName: '', origin: origin,
extensionId: '', extensionName: '' account: '',
capabilities: print_preview_test_utils.getCddTemplate('ID' + i),
displayName: '',
extensionId: '',
extensionName: ''
}; };
}), }),
}); });
// Ensure all capabilities are available for fetch. // Ensure all capabilities are available for fetch.
nativeLayer.setLocalDestinationCapabilities(getCddTemplate('ID1')); nativeLayer.setLocalDestinationCapabilities(
nativeLayer.setLocalDestinationCapabilities(getCddTemplate('ID2')); print_preview_test_utils.getCddTemplate('ID1'));
nativeLayer.setLocalDestinationCapabilities(getCddTemplate('ID3')); nativeLayer.setLocalDestinationCapabilities(
print_preview_test_utils.getCddTemplate('ID2'));
nativeLayer.setLocalDestinationCapabilities(
print_preview_test_utils.getCddTemplate('ID3'));
// For crbug.com/666595. If multiple destinations are fetched there may // For crbug.com/666595. If multiple destinations are fetched there may
// be multiple preview requests. This verifies the first fetch is for // be multiple preview requests. This verifies the first fetch is for
...@@ -1447,7 +1399,7 @@ cr.define('print_preview_test', function() { ...@@ -1447,7 +1399,7 @@ cr.define('print_preview_test', function() {
// an error and that the preview dialog can be recovered by selecting a // an error and that the preview dialog can be recovered by selecting a
// new destination. // new destination.
test('InvalidSettingsError', function() { test('InvalidSettingsError', function() {
const barDevice = getCddTemplate('BarDevice'); const barDevice = print_preview_test_utils.getCddTemplate('BarDevice');
nativeLayer.setLocalDestinationCapabilities(barDevice); nativeLayer.setLocalDestinationCapabilities(barDevice);
// FooDevice is the default printer, so will be selected for the initial // FooDevice is the default printer, so will be selected for the initial
...@@ -1572,7 +1524,7 @@ cr.define('print_preview_test', function() { ...@@ -1572,7 +1524,7 @@ cr.define('print_preview_test', function() {
{ printerName: 'FooName', deviceName: 'FooDevice' } { printerName: 'FooName', deviceName: 'FooDevice' }
]; ];
nativeLayer.setLocalDestinationCapabilities( nativeLayer.setLocalDestinationCapabilities(
getCddTemplate('ID1', 'One')); print_preview_test_utils.getCddTemplate('ID1', 'One'));
return setupSettingsAndDestinationsWithCapabilities().then(function() { return setupSettingsAndDestinationsWithCapabilities().then(function() {
// The system default destination should be used instead of the // The system default destination should be used instead of the
...@@ -1712,6 +1664,5 @@ cr.define('print_preview_test', function() { ...@@ -1712,6 +1664,5 @@ cr.define('print_preview_test', function() {
return { return {
suiteName: suiteName, suiteName: suiteName,
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