Commit 7af96c8f authored by Jimmy Gong's avatar Jimmy Gong Committed by Commit Bot

Remove AddPrinterDiscoveryDialog and AddPrinterConfiguringDialog

- This is another step in removing deprecated printer settings code.
- This removes unused dialogs.
- Adjusts browser tests to reflect this change.

Bug: 1005905
Test: Browser tests
Change-Id: I674f4436c4bd17351ff9db2c98e8602dd229ca96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1939957
Commit-Queue: jimmy gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729872}
parent 7ac35747
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_searchable_drop_down/cr_searchable_drop_down.html"> <link rel="import" href="chrome://resources/cr_elements/cr_searchable_drop_down/cr_searchable_drop_down.html">
<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> <link rel="import" href="chrome://resources/cr_elements/md_select_css.html">
<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html"> <link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html">
<link rel="import" href="../localized_link/localized_link.html"> <link rel="import" href="../localized_link/localized_link.html">
<link rel="import" href="../../i18n_setup.html"> <link rel="import" href="../../i18n_setup.html">
<link rel="import" href="cups_add_printer_dialog_elements.html"> <link rel="import" href="cups_add_printer_dialog_elements.html">
...@@ -15,66 +13,6 @@ ...@@ -15,66 +13,6 @@
<link rel="import" href="cups_printer_shared_css.html"> <link rel="import" href="cups_printer_shared_css.html">
<link rel="import" href="cups_printers_browser_proxy.html"> <link rel="import" href="cups_printers_browser_proxy.html">
<dom-module id="add-printer-discovery-dialog">
<template>
<style include="cr-shared-style cups-printer-shared">
add-printer-list {
max-height: 310px;
overflow-y: auto;
position: absolute;
width: 100%;
}
#searchSpinner {
position: absolute;
top: 80%;
}
#searchSpinner paper-spinner-lite {
--paper-spinner-stroke-width: 2px;
height: 15px;
margin-inline-end: 3px;
margin-inline-start: 20px;
width: 15px;
}
</style>
<add-printer-dialog>
<div slot="dialog-title">$i18n{addPrintersNearbyTitle}</div>
<div slot="dialog-body">
<add-printer-list printers="[[discoveredPrinters]]"
selected-printer="{{selectedPrinter}}">
</add-printer-list>
<div class="center" id="noPrinterMessage"
hidden="[[discoveredPrinters.length]]">
$i18n{noPrinterNearbyMessage}
</div>
<div id="searchSpinner" hidden="[[!discovering_]]">
<paper-spinner-lite active="[[discovering_]]"></paper-spinner-lite>
<span>$i18n{searchingNearbyPrinters}</span>
</div>
</div>
<div slot="dialog-buttons">
<div> <!-- Left group -->
<cr-button id="manuallyAddPrinterButton"
on-click="switchToManualAddDialog_">
$i18n{manuallyAddPrinterButtonText}
</cr-button>
</div>
<div> <!-- Right group -->
<cr-button class="cancel-button" on-click="onCancelTap_">
$i18n{cancel}
</cr-button>
<cr-button class="action-button" id="addPrinterButton"
disabled="[[!canAddPrinter_(selectedPrinter)]]"
on-click="switchToConfiguringDialog_">
$i18n{addPrinterButtonText}
</cr-button>
</div>
</div>
</add-printer-dialog>
</template>
</dom-module>
<dom-module id="add-printer-manually-dialog"> <dom-module id="add-printer-manually-dialog">
<template> <template>
<style include="cups-printer-shared"></style> <style include="cups-printer-shared"></style>
...@@ -127,16 +65,12 @@ ...@@ -127,16 +65,12 @@
</div> </div>
</div> </div>
<div slot="dialog-buttons"> <div slot="dialog-buttons">
<div> <!-- Left group --> <div>
<cr-button on-click="switchToDiscoveryDialog_"
hidden="[[enableUpdatedUi]]">
$i18n{discoverPrintersButtonText}
</cr-button>
</div>
<div> <!-- Right group -->
<cr-button class="cancel-button" on-click="onCancelTap_"> <cr-button class="cancel-button" on-click="onCancelTap_">
$i18n{cancel} $i18n{cancel}
</cr-button> </cr-button>
</div>
<div>
<cr-button id="addPrinterButton" class="action-button" <cr-button id="addPrinterButton" class="action-button"
on-click="addPressed_" on-click="addPressed_"
disabled="[[!canAddPrinter_(newPrinter.*, disabled="[[!canAddPrinter_(newPrinter.*,
...@@ -230,39 +164,10 @@ ...@@ -230,39 +164,10 @@
</template> </template>
</dom-module> </dom-module>
<dom-module id="add-printer-configuring-dialog">
<template>
<style include="cups-printer-shared">
[slot='dialog-body'] {
padding-top: 140px;
text-align: center;
}
</style>
<add-printer-dialog>
<div slot="dialog-title">[[dialogTitle]]</div>
<div slot="dialog-body">
<paper-spinner-lite active></paper-spinner-lite>
<div id="configuringMessage"></div>
</div>
<div slot="dialog-buttons">
<cr-button class="cancel-button" on-click="onCloseConfiguringTap_">
$i18n{close}
</cr-button>
</div>
</add-printer-dialog>
</template>
</dom-module>
<dom-module id="settings-cups-add-printer-dialog"> <dom-module id="settings-cups-add-printer-dialog">
<template> <template>
<style include="settings-shared"></style> <style include="settings-shared"></style>
<!-- Printer Discovery Dialog -->
<template is="dom-if" if="[[showDiscoveryDialog_]]" restamp>
<add-printer-discovery-dialog selected-printer="{{newPrinter}}">
</add-printer-discovery-dialog>
</template>
<!-- Manually Add Printer Dialog --> <!-- Manually Add Printer Dialog -->
<template is="dom-if" if="[[showManuallyAddDialog_]]" restamp> <template is="dom-if" if="[[showManuallyAddDialog_]]" restamp>
<add-printer-manually-dialog new-printer="{{newPrinter}}" <add-printer-manually-dialog new-printer="{{newPrinter}}"
...@@ -270,14 +175,6 @@ ...@@ -270,14 +175,6 @@
</add-printer-manually-dialog> </add-printer-manually-dialog>
</template> </template>
<!-- Configuring Printer Dialog -->
<template is="dom-if" if="[[showConfiguringDialog_]]" restamp>
<add-printer-configuring-dialog
printer-name="[[newPrinter.printerName]]"
dialog-title="[[configuringDialogTitle]]">
</add-printer-configuring-dialog>
</template>
<!-- Manufacturer and Model Dialog --> <!-- Manufacturer and Model Dialog -->
<template is="dom-if" if="[[showManufacturerDialog_]]" restamp> <template is="dom-if" if="[[showManufacturerDialog_]]" restamp>
<add-printer-manufacturer-model-dialog active-printer="{{newPrinter}}"> <add-printer-manufacturer-model-dialog active-printer="{{newPrinter}}">
......
...@@ -6,11 +6,8 @@ ...@@ -6,11 +6,8 @@
* @fileoverview 'settings-cups-add-printer-dialog' includes multiple dialogs to * @fileoverview 'settings-cups-add-printer-dialog' includes multiple dialogs to
* set up a new CUPS printer. * set up a new CUPS printer.
* Subdialogs include: * Subdialogs include:
* - 'add-printer-discovery-dialog' is a dialog showing discovered printers on
* the network that are available for setup.
* - 'add-printer-manually-dialog' is a dialog in which user can manually enter * - 'add-printer-manually-dialog' is a dialog in which user can manually enter
* the information to set up a new printer. * the information to set up a new printer.
* - 'add-printer-configuring-dialog' is the configuring-in-progress dialog.
* - 'add-printer-manufacturer-model-dialog' is a dialog in which the user can * - 'add-printer-manufacturer-model-dialog' is a dialog in which the user can
* manually select the manufacture and model of the new printer. * manually select the manufacture and model of the new printer.
*/ */
...@@ -20,19 +17,10 @@ ...@@ -20,19 +17,10 @@
* @enum {string} * @enum {string}
*/ */
const AddPrinterDialogs = { const AddPrinterDialogs = {
DISCOVERY: 'add-printer-discovery-dialog',
MANUALLY: 'add-printer-manually-dialog', MANUALLY: 'add-printer-manually-dialog',
CONFIGURING: 'add-printer-configuring-dialog',
MANUFACTURER: 'add-printer-manufacturer-model-dialog', MANUFACTURER: 'add-printer-manufacturer-model-dialog',
}; };
/**
* The maximum height of the discovered printers list when the searching spinner
* is not showing.
* @type {number}
*/
const kPrinterListFullHeight = 350;
/** /**
* Return a reset CupsPrinterInfo object. * Return a reset CupsPrinterInfo object.
* @return {!CupsPrinterInfo} * @return {!CupsPrinterInfo}
...@@ -60,132 +48,6 @@ function getEmptyPrinter_() { ...@@ -60,132 +48,6 @@ function getEmptyPrinter_() {
}; };
} }
Polymer({
is: 'add-printer-discovery-dialog',
behaviors: [WebUIListenerBehavior],
properties: {
/** @type {!Array<!CupsPrinterInfo>|undefined} */
discoveredPrinters: {
type: Array,
value: () => [],
},
/** @type {!CupsPrinterInfo} */
selectedPrinter: {
type: Object,
notify: true,
},
discovering_: {
type: Boolean,
value: true,
},
/**
* TODO(jimmyxgong): Remove this feature flag conditional once feature
* is launched.
* @private
*/
enableUpdatedUi: Boolean,
},
/** @override */
ready: function() {
if (this.enableUpdatedUi) {
return;
}
settings.CupsPrintersBrowserProxyImpl.getInstance()
.startDiscoveringPrinters();
this.addWebUIListener(
'on-nearby-printers-changed', this.onNearbyPrintersChanged_.bind(this));
this.addWebUIListener(
'on-printer-discovery-done', this.onPrinterDiscoveryDone_.bind(this));
},
close: function() {
this.$$('add-printer-dialog').close();
},
/**
* @param {!Array<!CupsPrinterInfo>} automaticPrinters
* @param {!Array<!CupsPrinterInfo>} discoveredPrinters
* @private
*/
onNearbyPrintersChanged_: function(automaticPrinters, discoveredPrinters) {
this.discovering_ = true;
this.set(
'discoveredPrinters', automaticPrinters.concat(discoveredPrinters));
},
/** @private */
onPrinterDiscoveryDone_: function() {
this.discovering_ = false;
this.$$('add-printer-list').style.maxHeight = kPrinterListFullHeight + 'px';
if (!this.discoveredPrinters.length) {
this.selectedPrinter = getEmptyPrinter_();
this.fire('no-detected-printer');
}
},
/** @private */
stopDiscoveringPrinters_: function() {
settings.CupsPrintersBrowserProxyImpl.getInstance()
.stopDiscoveringPrinters();
this.discovering_ = false;
},
/** @private */
switchToManualAddDialog_: function() {
// We're abandoning discovery in favor of manual specification, so
// drop the selection if one exists.
this.selectedPrinter = getEmptyPrinter_();
this.close();
this.fire('open-manually-add-printer-dialog');
if (this.enableUpdatedUi) {
return;
}
this.stopDiscoveringPrinters_();
},
/** @private */
onCancelTap_: function() {
this.close();
if (this.enableUpdatedUi) {
return;
}
this.stopDiscoveringPrinters_();
},
/** @private */
switchToConfiguringDialog_: function() {
this.close();
this.fire('open-configuring-printer-dialog');
if (this.enableUpdatedUi) {
return;
}
this.stopDiscoveringPrinters_();
},
/**
* @param {?CupsPrinterInfo} selectedPrinter
* @return {boolean} Whether the add printer button is enabled.
* @private
*/
canAddPrinter_: function(selectedPrinter) {
return !!selectedPrinter && !!selectedPrinter.printerName;
},
});
Polymer({ Polymer({
is: 'add-printer-manually-dialog', is: 'add-printer-manually-dialog',
...@@ -220,13 +82,6 @@ Polymer({ ...@@ -220,13 +82,6 @@ Polymer({
'printerInfoChanged_(newPrinter.*)', 'printerInfoChanged_(newPrinter.*)',
], ],
/** @private */
switchToDiscoveryDialog_: function() {
this.newPrinter = getEmptyPrinter_();
this.$$('add-printer-dialog').close();
this.fire('open-discovery-printers-dialog');
},
/** @private */ /** @private */
onCancelTap_: function() { onCancelTap_: function() {
this.$$('add-printer-dialog').close(); this.$$('add-printer-dialog').close();
...@@ -607,30 +462,6 @@ Polymer({ ...@@ -607,30 +462,6 @@ Polymer({
}, },
}); });
Polymer({
is: 'add-printer-configuring-dialog',
properties: {
printerName: String,
dialogTitle: String,
},
/** @override */
attached: function() {
this.$.configuringMessage.textContent =
loadTimeData.getStringF('printerConfiguringMessage', this.printerName);
},
/** @private */
onCloseConfiguringTap_: function() {
this.close();
},
close: function() {
this.$$('add-printer-dialog').close();
},
});
Polymer({ Polymer({
is: 'settings-cups-add-printer-dialog', is: 'settings-cups-add-printer-dialog',
...@@ -640,32 +471,18 @@ Polymer({ ...@@ -640,32 +471,18 @@ Polymer({
type: Object, type: Object,
}, },
configuringDialogTitle: String,
/** @private {string} */ /** @private {string} */
previousDialog_: String, previousDialog_: String,
/** @private {string} */ /** @private {string} */
currentDialog_: String, currentDialog_: String,
/** @private {boolean} */
showDiscoveryDialog_: {
type: Boolean,
value: false,
},
/** @private {boolean} */ /** @private {boolean} */
showManuallyAddDialog_: { showManuallyAddDialog_: {
type: Boolean, type: Boolean,
value: false, value: false,
}, },
/** @private {boolean} */
showConfiguringDialog_: {
type: Boolean,
value: false,
},
/** @private {boolean} */ /** @private {boolean} */
showManufacturerDialog_: { showManufacturerDialog_: {
type: Boolean, type: Boolean,
...@@ -682,25 +499,18 @@ Polymer({ ...@@ -682,25 +499,18 @@ Polymer({
listeners: { listeners: {
'open-manually-add-printer-dialog': 'openManuallyAddPrinterDialog_', 'open-manually-add-printer-dialog': 'openManuallyAddPrinterDialog_',
'open-configuring-printer-dialog': 'openConfiguringPrinterDialog_',
'open-discovery-printers-dialog': 'openDiscoveryPrintersDialog_',
'open-manufacturer-model-dialog': 'open-manufacturer-model-dialog':
'openManufacturerModelDialogForCurrentPrinter_', 'openManufacturerModelDialogForCurrentPrinter_',
'no-detected-printer': 'onNoDetectedPrinter_', 'no-detected-printer': 'onNoDetectedPrinter_',
}, },
/** Opens the Add printer discovery dialog. */ /** Opens the Add manual printer dialog. */
open: function() { open: function() {
this.resetData_(); this.resetData_();
if (this.enableUpdatedUi) {
// The updated UI will remove the discovery dialog. Open the manual // The updated UI will remove the discovery dialog. Open the manual
// dialog by default. // dialog by default.
this.switchDialog_( this.switchDialog_(
'', AddPrinterDialogs.MANUALLY, 'showManuallyAddDialog_'); '', AddPrinterDialogs.MANUALLY, 'showManuallyAddDialog_');
} else {
this.switchDialog_(
'', AddPrinterDialogs.DISCOVERY, 'showDiscoveryDialog_');
}
}, },
/** /**
...@@ -720,37 +530,6 @@ Polymer({ ...@@ -720,37 +530,6 @@ Polymer({
'showManuallyAddDialog_'); 'showManuallyAddDialog_');
}, },
/** @private */
openDiscoveryPrintersDialog_: function() {
this.switchDialog_(
this.currentDialog_, AddPrinterDialogs.DISCOVERY,
'showDiscoveryDialog_');
},
/** @private */
switchToManufacturerDialog_: function() {
this.$$('add-printer-configuring-dialog').close();
this.openManufacturerModelDialogForCurrentPrinter_();
},
/** @private */
openConfiguringPrinterDialog_: function() {
this.switchDialog_(
this.currentDialog_, AddPrinterDialogs.CONFIGURING,
'showConfiguringDialog_');
if (this.previousDialog_ == AddPrinterDialogs.DISCOVERY) {
this.configuringDialogTitle =
loadTimeData.getString('addPrintersNearbyTitle');
settings.CupsPrintersBrowserProxyImpl.getInstance()
.addDiscoveredPrinter(this.newPrinter.printerId)
.then(
this.onAddingDiscoveredPrinterSucceeded_.bind(this),
this.manuallyAddDiscoveredPrinter_.bind(this));
} else {
assertNotReached('Opening configuring dialog from invalid place');
}
},
/** @private */ /** @private */
openManufacturerModelDialogForCurrentPrinter_: function() { openManufacturerModelDialogForCurrentPrinter_: function() {
this.switchDialog_( this.switchDialog_(
...@@ -765,18 +544,6 @@ Polymer({ ...@@ -765,18 +544,6 @@ Polymer({
'', AddPrinterDialogs.MANUFACTURER, 'showManufacturerDialog_'); '', AddPrinterDialogs.MANUFACTURER, 'showManufacturerDialog_');
}, },
/** @private */
onNoDetectedPrinter_: function() {
// If there is no detected printer, automatically open manually-add-printer
// dialog only when the user opens the discovery-dialog through the
// "ADD PRINTER" button.
if (!this.previousDialog_) {
this.$$('add-printer-discovery-dialog').close();
this.newPrinter = getEmptyPrinter_();
this.openManuallyAddPrinterDialog_();
}
},
/** /**
* Switch dialog from |fromDialog| to |toDialog|. * Switch dialog from |fromDialog| to |toDialog|.
* @param {string} fromDialog * @param {string} fromDialog
...@@ -797,42 +564,4 @@ Polymer({ ...@@ -797,42 +564,4 @@ Polymer({
}); });
}); });
}, },
/**
* Handler for addDiscoveredPrinter.
* @param {!PrinterSetupResult} result
* @private
* */
onAddingDiscoveredPrinterSucceeded_: function(result) {
this.$$('add-printer-configuring-dialog').close();
this.fire(
'show-cups-printer-toast',
{resultCode: result, printerName: this.newPrinter.printerName});
},
/**
* Use the given printer as the starting point for a user-driven
* add of a printer. This is called if we can't automatically configure
* the printer, and need more information from the user.
*
* @param {*} printer
* @private
*/
manuallyAddDiscoveredPrinter_: function(printer) {
this.newPrinter = /** @type {CupsPrinterInfo} */ (printer);
this.switchToManufacturerDialog_();
},
/**
* @param {boolean} success
* @param {string} printerName
* @private
*/
onAddPrinter_: function(success, printerName) {
// 'on-add-cups-printer' event might be triggered by editing an existing
// printer, in which case there is no configuring dialog.
if (this.$$('add-printer-configuring-dialog')) {
this.$$('add-printer-configuring-dialog').close();
}
},
}); });
...@@ -7,26 +7,6 @@ ...@@ -7,26 +7,6 @@
<link rel="import" href="cups_printer_shared_css.html"> <link rel="import" href="cups_printer_shared_css.html">
<link rel="import" href="cups_printers_browser_proxy.html"> <link rel="import" href="cups_printers_browser_proxy.html">
<dom-module id="add-printer-list">
<template>
<style include="cups-printer-shared">
.list-item {
padding: 0 20px;
}
</style>
<div>
<array-selector id="arraySelector" items="[[printers]]"
selected="{{selectedPrinter}}">
</array-selector>
<template is="dom-repeat" items="[[printers]]" sort="sort_">
<button class="list-item" on-click="onSelect_">
[[item.printerName]]
</button>
</template>
</div>
</template>
</dom-module>
<dom-module id="add-printer-dialog"> <dom-module id="add-printer-dialog">
<template> <template>
<style include="settings-shared"> <style include="settings-shared">
......
...@@ -2,43 +2,6 @@ ...@@ -2,43 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
/** 'add-printers-list' is the list of discovered printers. */
Polymer({
is: 'add-printer-list',
properties: {
/** @type {!Array<!CupsPrinterInfo>} */
printers: {
type: Array,
notify: true,
},
/** @type {!CupsPrinterInfo} */
selectedPrinter: {
type: Object,
notify: true,
},
},
/**
* @param {{model:Object}} event
* @private
*/
onSelect_: function(event) {
this.selectedPrinter = event.model.item;
},
/**
* @param {!CupsPrinterInfo} first
* @param {!CupsPrinterInfo} second
* @return {number} The result of the comparison.
* @private
*/
sort_: function(first, second) {
return settings.printing.alphabeticalSort(first, second);
},
});
/** 'add-printer-dialog' is the template of the Add Printer dialog. */ /** 'add-printer-dialog' is the template of the Add Printer dialog. */
Polymer({ Polymer({
is: 'add-printer-dialog', is: 'add-printer-dialog',
......
...@@ -66,13 +66,7 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -66,13 +66,7 @@ suite('CupsAddPrinterDialogTests', function() {
} }
function mockAddPrinterInputKeyboardPress(crInputId) { function mockAddPrinterInputKeyboardPress(crInputId) {
// Starts in discovery dialog, select add manually button. // Start in add manual dialog.
const discoveryDialog = dialog.$$('add-printer-discovery-dialog');
assertTrue(!!discoveryDialog);
discoveryDialog.$.manuallyAddPrinterButton.click();
Polymer.dom.flush();
// Now we should be in the manually add dialog.
const addDialog = dialog.$$('add-printer-manually-dialog'); const addDialog = dialog.$$('add-printer-manually-dialog');
assertTrue(!!addDialog); assertTrue(!!addDialog);
...@@ -134,26 +128,6 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -134,26 +128,6 @@ suite('CupsAddPrinterDialogTests', function() {
page = null; page = null;
}); });
/**
* Test that the discovery dialog is showing when a user initially asks
* to add a printer.
*/
test('DiscoveryShowing', function() {
return test_util.flushTasks().then(function() {
// Discovery is showing.
assertTrue(dialog.showDiscoveryDialog_);
assertTrue(!!dialog.$$('add-printer-discovery-dialog'));
// All other components are hidden.
assertFalse(dialog.showManufacturerDialog_);
assertFalse(!!dialog.$$('add-printer-manufacturer-model-dialog'));
assertFalse(dialog.showConfiguringDialog_);
assertFalse(!!dialog.$$('add-printer-configuring-dialog'));
assertFalse(dialog.showManuallyAddDialog_);
assertFalse(!!dialog.$$('add-printer-manually-dialog'));
});
});
test('ValidIPV4', function() { test('ValidIPV4', function() {
const dialog = document.createElement('add-printer-manually-dialog'); const dialog = document.createElement('add-printer-manually-dialog');
expectTrue(canAddPrinter(dialog, 'Test printer', '127.0.0.1')); expectTrue(canAddPrinter(dialog, 'Test printer', '127.0.0.1'));
...@@ -215,15 +189,10 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -215,15 +189,10 @@ suite('CupsAddPrinterDialogTests', function() {
* Test that clicking on Add opens the model select page. * Test that clicking on Add opens the model select page.
*/ */
test('ValidAddOpensModelSelection', function() { test('ValidAddOpensModelSelection', function() {
// Starts in discovery dialog, select add manually button. // Starts in add manual dialog.
const discoveryDialog = dialog.$$('add-printer-discovery-dialog');
assertTrue(!!discoveryDialog);
discoveryDialog.$.manuallyAddPrinterButton.click();
Polymer.dom.flush();
// Now we should be in the manually add dialog.
const addDialog = dialog.$$('add-printer-manually-dialog'); const addDialog = dialog.$$('add-printer-manually-dialog');
assertTrue(!!addDialog); assertTrue(!!addDialog);
Polymer.dom.flush();
fillAddManuallyDialog(addDialog); fillAddManuallyDialog(addDialog);
addDialog.$$('.action-button').click(); addDialog.$$('.action-button').click();
...@@ -237,13 +206,10 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -237,13 +206,10 @@ suite('CupsAddPrinterDialogTests', function() {
}) })
.then(function() { .then(function() {
// Showing model selection. // Showing model selection.
assertFalse(!!dialog.$$('add-printer-configuring-dialog'));
assertTrue(!!dialog.$$('add-printer-manufacturer-model-dialog')); assertTrue(!!dialog.$$('add-printer-manufacturer-model-dialog'));
assertTrue(dialog.showManufacturerDialog_); assertTrue(dialog.showManufacturerDialog_);
assertFalse(dialog.showConfiguringDialog_);
assertFalse(dialog.showManuallyAddDialog_); assertFalse(dialog.showManuallyAddDialog_);
assertFalse(dialog.showDiscoveryDialog_);
}); });
}); });
...@@ -252,15 +218,10 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -252,15 +218,10 @@ suite('CupsAddPrinterDialogTests', function() {
* message is shown. * message is shown.
*/ */
test('GetPrinterInfoFailsGeneralError', function() { test('GetPrinterInfoFailsGeneralError', function() {
// Starts in discovery dialog, select add manually button. // Starts in add manual dialog.
const discoveryDialog = dialog.$$('add-printer-discovery-dialog');
assertTrue(!!discoveryDialog);
discoveryDialog.$.manuallyAddPrinterButton.click();
Polymer.dom.flush();
// Now we should be in the manually add dialog.
const addDialog = dialog.$$('add-printer-manually-dialog'); const addDialog = dialog.$$('add-printer-manually-dialog');
assertTrue(!!addDialog); assertTrue(!!addDialog);
Polymer.dom.flush();
fillAddManuallyDialog(addDialog); fillAddManuallyDialog(addDialog);
...@@ -287,15 +248,10 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -287,15 +248,10 @@ suite('CupsAddPrinterDialogTests', function() {
* address field is marked as invalid. * address field is marked as invalid.
*/ */
test('GetPrinterInfoFailsUnreachableError', function() { test('GetPrinterInfoFailsUnreachableError', function() {
// Starts in discovery dialog, select add manually button. // Starts in add manual dialog.
const discoveryDialog = dialog.$$('add-printer-discovery-dialog');
assertTrue(!!discoveryDialog);
discoveryDialog.$.manuallyAddPrinterButton.click();
Polymer.dom.flush();
// Now we should be in the manually add dialog.
const addDialog = dialog.$$('add-printer-manually-dialog'); const addDialog = dialog.$$('add-printer-manually-dialog');
assertTrue(!!addDialog); assertTrue(!!addDialog);
Polymer.dom.flush();
fillAddManuallyDialog(addDialog); fillAddManuallyDialog(addDialog);
...@@ -320,13 +276,10 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -320,13 +276,10 @@ suite('CupsAddPrinterDialogTests', function() {
* Test that getModels isn't called with a blank query. * Test that getModels isn't called with a blank query.
*/ */
test('NoBlankQueries', function() { test('NoBlankQueries', function() {
const discoveryDialog = dialog.$$('add-printer-discovery-dialog'); // Starts in add manual dialog.
assertTrue(!!discoveryDialog);
discoveryDialog.$.manuallyAddPrinterButton.click();
Polymer.dom.flush();
const addDialog = dialog.$$('add-printer-manually-dialog'); const addDialog = dialog.$$('add-printer-manually-dialog');
assertTrue(!!addDialog); assertTrue(!!addDialog);
Polymer.dom.flush();
fillAddManuallyDialog(addDialog); fillAddManuallyDialog(addDialog);
// Verify that getCupsPrinterModelList is not called. // Verify that getCupsPrinterModelList is not called.
...@@ -358,7 +311,7 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -358,7 +311,7 @@ suite('CupsAddPrinterDialogTests', function() {
*/ */
test('LogDialogCancelledIpp', function() { test('LogDialogCancelledIpp', function() {
const makeAndModel = 'Printer Make And Model'; const makeAndModel = 'Printer Make And Model';
// Start on add manually. // Start on add manual dialog.
dialog.fire('open-manually-add-printer-dialog'); dialog.fire('open-manually-add-printer-dialog');
Polymer.dom.flush(); Polymer.dom.flush();
...@@ -396,6 +349,7 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -396,6 +349,7 @@ suite('CupsAddPrinterDialogTests', function() {
// Press the add button to advance dialog. // Press the add button to advance dialog.
const addDialog = dialog.$$('add-printer-manually-dialog'); const addDialog = dialog.$$('add-printer-manually-dialog');
assertTrue(!!addDialog); assertTrue(!!addDialog);
Polymer.dom.flush();
clickAddButton(addDialog); clickAddButton(addDialog);
// Click cancel on the manufacturer dialog when it shows up then verify // Click cancel on the manufacturer dialog when it shows up then verify
...@@ -414,151 +368,15 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -414,151 +368,15 @@ suite('CupsAddPrinterDialogTests', function() {
}); });
}); });
/**
* Test that dialog cancellation is logged from the manufacturer screen for
* USB printers.
*/
test('LogDialogCancelledUSB', function() {
const vendorId = 0x1234;
const modelId = 0xDEAD;
const manufacturer = 'PrinterMFG';
const model = 'Printy Printerson';
const usbInfo = {
usbVendorId: vendorId,
usbProductId: modelId,
usbVendorName: manufacturer,
usbProductName: model,
};
const expectedPrinter = 'PICK_ME!';
const newPrinter = {
ppdManufacturer: '',
ppdModel: '',
printerAddress: 'EEAADDAA',
printerDescription: '',
printerId: expectedPrinter,
printerManufacturer: '',
printerModel: '',
printerMakeAndModel: '',
printerName: 'printer',
printerPPDPath: '',
printerPpdReference: {
userSuppliedPpdUrl: '',
effectiveMakeAndModel: '',
autoconf: false,
},
printerProtocol: 'usb',
printerQueue: 'moreinfohere',
printerStatus: '',
printerUsbInfo: usbInfo,
};
dialog.fire('open-discovery-printers-dialog');
// Make 'addDiscoveredPrinter' fail so we get sent to the make/model dialog.
cupsPrintersBrowserProxy.setAddDiscoveredPrinterFailure(newPrinter);
return cupsPrintersBrowserProxy.whenCalled('startDiscoveringPrinters')
.then(function() {
// Select the printer.
// TODO(skau): Figure out how to select in a dom-repeat.
const discoveryDialog = dialog.$$('add-printer-discovery-dialog');
assertTrue(!!discoveryDialog, 'Cannot find discovery dialog');
discoveryDialog.selectedPrinter = newPrinter;
// Run printer setup.
clickAddButton(discoveryDialog);
return cupsPrintersBrowserProxy.whenCalled('addDiscoveredPrinter');
})
.then(function(printerId) {
assertEquals(expectedPrinter, printerId);
return cupsPrintersBrowserProxy.whenCalled(
'getCupsPrinterManufacturersList');
})
.then(function() {
// Cancel setup with the cancel button.
clickCancelButton(dialog.$$('add-printer-manufacturer-model-dialog'));
return cupsPrintersBrowserProxy.whenCalled('cancelPrinterSetUp');
})
.then(function(printer) {
assertEquals(expectedPrinter, printer.printerId);
assertDeepEquals(usbInfo, printer.printerUsbInfo);
});
});
/**
* Test that the close button exists on the configure dialog.
*/
test('ConfigureDialogCancelDisabled', function() {
const newPrinter = {
ppdManufacturer: '',
ppdModel: '',
printerAddress: 'EEAADDAA',
printerDescription: '',
printerId: 'printerId',
printerManufacturer: '',
printerModel: '',
printerMakeAndModel: '',
printerName: 'printer',
printerPPDPath: '',
printerPpdReference: {
userSuppliedPpdUrl: '',
effectiveMakeAndModel: '',
autoconf: false,
},
printerProtocol: 'usb',
printerQueue: 'moreinfohere',
printerStatus: '',
printerUsbInfo: '',
};
dialog.fire('open-discovery-printers-dialog');
return cupsPrintersBrowserProxy.whenCalled('startDiscoveringPrinters')
.then(function() {
// Select the printer.
const discoveryDialog = dialog.$$('add-printer-discovery-dialog');
assertTrue(!!discoveryDialog, 'Cannot find discovery dialog');
discoveryDialog.selectedPrinter = newPrinter;
// Run printer setup.
clickAddButton(discoveryDialog);
return cupsPrintersBrowserProxy.whenCalled('addDiscoveredPrinter');
})
.then(function(printerId) {
const configureDialog = dialog.$$('add-printer-configuring-dialog');
assertTrue(!!configureDialog);
const closeButton = configureDialog.$$('.cancel-button');
assertTrue(!!closeButton);
assertFalse(closeButton.disabled);
const waitForClose =
test_util.eventToPromise('close', configureDialog);
closeButton.click();
Polymer.dom.flush();
return waitForClose.then(() => {
dialog = page.$$('settings-cups-add-printer-dialog');
assertFalse(dialog.showConfiguringDialog_);
});
});
});
/** /**
* Test that we are checking if a printer model has an EULA upon a model * Test that we are checking if a printer model has an EULA upon a model
* change. * change.
*/ */
test('getEulaUrlGetsCalledOnModelChange', function() { test('getEulaUrlGetsCalledOnModelChange', function() {
const discoveryDialog = dialog.$$('add-printer-discovery-dialog'); // Start in add manual dialog.
assertTrue(!!discoveryDialog);
discoveryDialog.$.manuallyAddPrinterButton.click();
Polymer.dom.flush();
const addDialog = dialog.$$('add-printer-manually-dialog'); const addDialog = dialog.$$('add-printer-manually-dialog');
assertTrue(!!addDialog); assertTrue(!!addDialog);
Polymer.dom.flush();
fillAddManuallyDialog(addDialog); fillAddManuallyDialog(addDialog);
addDialog.$$('.action-button').click(); addDialog.$$('.action-button').click();
...@@ -629,16 +447,11 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -629,16 +447,11 @@ suite('CupsAddPrinterDialogTests', function() {
* clicking it. * clicking it.
*/ */
test('AddButtonDisabledAfterClicking', function() { test('AddButtonDisabledAfterClicking', function() {
// Starting in the discovery dialog, select the add manually button.
const discoveryDialog = dialog.$$('add-printer-discovery-dialog');
assertTrue(!!discoveryDialog);
discoveryDialog.$.manuallyAddPrinterButton.click();
Polymer.dom.flush();
// From the add manually dialog, click the add button to advance to the // From the add manually dialog, click the add button to advance to the
// manufacturer dialog. // manufacturer dialog.
const addDialog = dialog.$$('add-printer-manually-dialog'); const addDialog = dialog.$$('add-printer-manually-dialog');
assertTrue(!!addDialog); assertTrue(!!addDialog);
Polymer.dom.flush();
fillAddManuallyDialog(addDialog); fillAddManuallyDialog(addDialog);
clickAddButton(addDialog); clickAddButton(addDialog);
Polymer.dom.flush(); Polymer.dom.flush();
......
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