Commit 3d1278f8 authored by Claude van der Merwe's avatar Claude van der Merwe Committed by Commit Bot

OS Settings: Convert Printing page from Polymer2 to Polymer3

Bug: 1045266
Change-Id: Ibb0b121d814795aa5b513c740cb32cdac3332188
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2355555
Commit-Queue: Claude van der Merwe <cvandermerwe@google.com>
Reviewed-by: default avatarJimmy Gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799939}
parent 2ff8b40f
...@@ -278,8 +278,7 @@ group("closure_compile_module") { ...@@ -278,8 +278,7 @@ group("closure_compile_module") {
"os_files_page:closure_compile_module", "os_files_page:closure_compile_module",
"os_languages_page:closure_compile_module", "os_languages_page:closure_compile_module",
"os_people_page:closure_compile_module", "os_people_page:closure_compile_module",
"os_printing_page:closure_compile_module",
#"os_printing_page:closure_compile_module",
"os_privacy_page:closure_compile_module", "os_privacy_page:closure_compile_module",
"os_reset_page:closure_compile_module", "os_reset_page:closure_compile_module",
......
...@@ -18,6 +18,7 @@ export function ensureLazyLoadedOs() { ...@@ -18,6 +18,7 @@ export function ensureLazyLoadedOs() {
'os-settings-reset-page', 'os-settings-reset-page',
'os-settings-files-page', 'os-settings-files-page',
'settings-smb-shares-page', 'settings-smb-shares-page',
'os-printing-page',
].map(name => customElements.whenDefined(name))); ].map(name => customElements.whenDefined(name)));
} }
return lazyLoadPromise; return lazyLoadPromise;
......
...@@ -13,16 +13,32 @@ import './os_languages_page/os_languages_page.m.js'; ...@@ -13,16 +13,32 @@ import './os_languages_page/os_languages_page.m.js';
import './os_languages_page/os_languages_page_v2.m.js'; import './os_languages_page/os_languages_page_v2.m.js';
import './os_languages_page/os_languages_section.m.js'; import './os_languages_page/os_languages_section.m.js';
import './os_languages_page/smart_inputs_page.m.js'; import './os_languages_page/smart_inputs_page.m.js';
// import './os_printing_page/os_printing_page.m.js'; import './os_printing_page/os_printing_page.m.js';
import './os_printing_page/os_printing_page.m.js';
import './os_printing_page/cups_add_print_server_dialog.m.js';
import './os_printing_page/cups_add_printer_dialog.m.js';
import './os_printing_page/cups_add_printer_manually_dialog.m.js';
import './os_printing_page/cups_add_printer_manufacturer_model_dialog.m.js';
import './os_printing_page/cups_edit_printer_dialog.m.js';
import './os_printing_page/cups_nearby_printers.m.js';
import './os_printing_page/cups_printer_dialog_error.m.js';
import './os_printing_page/cups_printer_shared_css.m.js';
import './os_printing_page/cups_printers_entry.m.js';
import './os_printing_page/cups_printers.m.js';
import './os_printing_page/cups_saved_printers.m.js';
import './os_printing_page/cups_settings_add_printer_dialog.m.js';
import './os_privacy_page/os_privacy_page.m.js'; import './os_privacy_page/os_privacy_page.m.js';
import './os_reset_page/os_reset_page.m.js'; import './os_reset_page/os_reset_page.m.js';
import './os_reset_page/os_powerwash_dialog.m.js'; import './os_reset_page/os_powerwash_dialog.m.js';
import './os_reset_page/os_reset_page.m.js'; import './os_reset_page/os_reset_page.m.js';
import './os_files_page/smb_shares_page.m.js'; import './os_files_page/smb_shares_page.m.js';
export {SmbBrowserProxyImpl, SmbMountResult} from 'chrome://resources/cr_components/chromeos/smb_shares/smb_browser_proxy.m.js';
export {LanguagesBrowserProxy, LanguagesBrowserProxyImpl} from '../languages_page/languages_browser_proxy.m.js'; export {LanguagesBrowserProxy, LanguagesBrowserProxyImpl} from '../languages_page/languages_browser_proxy.m.js';
export {TimeZoneAutoDetectMethod} from './date_time_page/date_time_types.m.js'; export {TimeZoneAutoDetectMethod} from './date_time_page/date_time_types.m.js';
export {TimeZoneBrowserProxyImpl} from './date_time_page/timezone_browser_proxy.m.js'; export {TimeZoneBrowserProxyImpl} from './date_time_page/timezone_browser_proxy.m.js';
export {LanguagesMetricsProxy, LanguagesMetricsProxyImpl, LanguagesPageInteraction} from './os_languages_page/languages_metrics_proxy.m.js'; export {LanguagesMetricsProxy, LanguagesMetricsProxyImpl, LanguagesPageInteraction} from './os_languages_page/languages_metrics_proxy.m.js';
export {PrinterType} from './os_printing_page/cups_printer_types.m.js';
export {CupsPrintersBrowserProxy, CupsPrintersBrowserProxyImpl, PrinterSetupResult, PrintServerResult} from './os_printing_page/cups_printers_browser_proxy.m.js';
export {CupsPrintersEntryManager} from './os_printing_page/cups_printers_entry_manager.m.js';
export {OsResetBrowserProxyImpl} from './os_reset_page/os_reset_browser_proxy.m.js'; export {OsResetBrowserProxyImpl} from './os_reset_page/os_reset_browser_proxy.m.js';
export {SmbMountResult, SmbBrowserProxyImpl} from 'chrome://resources/cr_components/chromeos/smb_shares/smb_browser_proxy.m.js';
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<link rel="import" href="cups_printers_entry_list_behavior.html"> <link rel="import" href="cups_printers_entry_list_behavior.html">
<link rel="import" href="cups_printers_entry.html"> <link rel="import" href="cups_printers_entry.html">
<link rel="import" href="cups_printers_entry_manager.html"> <link rel="import" href="cups_printers_entry_manager.html">
<link rel="import" href="cups_printer_dialog_util.html">
<link rel="import" href="../../settings_shared_css.html"> <link rel="import" href="../../settings_shared_css.html">
<link rel="import" href="../metrics_recorder.html"> <link rel="import" href="../metrics_recorder.html">
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
// 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.
// clang-format off
// #import {PrinterSetupResult, PrintServerResult, CupsPrinterInfo} from './cups_printers_browser_proxy.m.js';
// #import {PrinterListEntry} from './cups_printer_types.m.js';
// #import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
// #import {assertNotReached} from 'chrome://resources/js/assert.m.js';
// clang-format on
/** /**
* @fileoverview Utility functions that are used in Cups printer setup dialogs. * @fileoverview Utility functions that are used in Cups printer setup dialogs.
*/ */
...@@ -11,7 +18,7 @@ cr.define('settings.printing', function() { ...@@ -11,7 +18,7 @@ cr.define('settings.printing', function() {
* @param {string} protocol * @param {string} protocol
* @return {boolean} Whether |protocol| is a network protocol * @return {boolean} Whether |protocol| is a network protocol
*/ */
function isNetworkProtocol(protocol) { /* #export */ function isNetworkProtocol(protocol) {
return ['ipp', 'ipps', 'http', 'https', 'socket', 'lpd'].includes(protocol); return ['ipp', 'ipps', 'http', 'https', 'socket', 'lpd'].includes(protocol);
} }
...@@ -25,7 +32,7 @@ cr.define('settings.printing', function() { ...@@ -25,7 +32,7 @@ cr.define('settings.printing', function() {
* @param {CupsPrinterInfo} printer * @param {CupsPrinterInfo} printer
* @return {boolean} * @return {boolean}
*/ */
function isNameAndAddressValid(printer) { /* #export */ function isNameAndAddressValid(printer) {
if (!printer) { if (!printer) {
return false; return false;
} }
...@@ -80,7 +87,7 @@ cr.define('settings.printing', function() { ...@@ -80,7 +87,7 @@ cr.define('settings.printing', function() {
* @param {string} ppdPath * @param {string} ppdPath
* @return {boolean} * @return {boolean}
*/ */
function isPPDInfoValid(manufacturer, model, ppdPath) { /* #export */ function isPPDInfoValid(manufacturer, model, ppdPath) {
return !!((manufacturer && model) || ppdPath); return !!((manufacturer && model) || ppdPath);
} }
...@@ -89,7 +96,7 @@ cr.define('settings.printing', function() { ...@@ -89,7 +96,7 @@ cr.define('settings.printing', function() {
* @param {string} path The full path of the file * @param {string} path The full path of the file
* @return {string} The base name of the file * @return {string} The base name of the file
*/ */
function getBaseName(path) { /* #export */ function getBaseName(path) {
if (path && path.length > 0) { if (path && path.length > 0) {
return path.substring(path.lastIndexOf('/') + 1); return path.substring(path.lastIndexOf('/') + 1);
} }
...@@ -113,7 +120,7 @@ cr.define('settings.printing', function() { ...@@ -113,7 +120,7 @@ cr.define('settings.printing', function() {
* @param {!PrinterSetupResult} result * @param {!PrinterSetupResult} result
* @return {string} * @return {string}
*/ */
function getErrorText(result) { /* #export */ function getErrorText(result) {
switch (result) { switch (result) {
case PrinterSetupResult.FATAL_ERROR: case PrinterSetupResult.FATAL_ERROR:
return loadTimeData.getString('printerAddedFatalErrorMessage'); return loadTimeData.getString('printerAddedFatalErrorMessage');
...@@ -146,7 +153,7 @@ cr.define('settings.printing', function() { ...@@ -146,7 +153,7 @@ cr.define('settings.printing', function() {
* @param {!PrintServerResult} result * @param {!PrintServerResult} result
* @return {string} * @return {string}
*/ */
function getPrintServerErrorText(result) { /* #export */ function getPrintServerErrorText(result) {
switch (result) { switch (result) {
case PrintServerResult.CONNECTION_ERROR: case PrintServerResult.CONNECTION_ERROR:
return loadTimeData.getString('printServerConnectionError'); return loadTimeData.getString('printServerConnectionError');
...@@ -165,7 +172,7 @@ cr.define('settings.printing', function() { ...@@ -165,7 +172,7 @@ cr.define('settings.printing', function() {
* @param {!PrinterListEntry} second * @param {!PrinterListEntry} second
* @return {number} * @return {number}
*/ */
function sortPrinters(first, second) { /* #export */ function sortPrinters(first, second) {
if (first.printerType == second.printerType) { if (first.printerType == second.printerType) {
return settings.printing.alphabeticalSort( return settings.printing.alphabeticalSort(
first.printerInfo, second.printerInfo); first.printerInfo, second.printerInfo);
...@@ -179,7 +186,7 @@ cr.define('settings.printing', function() { ...@@ -179,7 +186,7 @@ cr.define('settings.printing', function() {
* @param {string} searchTerm * @param {string} searchTerm
* @return {boolean} True if the printer has |searchTerm| in its name. * @return {boolean} True if the printer has |searchTerm| in its name.
*/ */
function matchesSearchTerm(printer, searchTerm) { /* #export */ function matchesSearchTerm(printer, searchTerm) {
return printer.printerName.toLowerCase().includes(searchTerm.toLowerCase()); return printer.printerName.toLowerCase().includes(searchTerm.toLowerCase());
} }
...@@ -198,7 +205,7 @@ cr.define('settings.printing', function() { ...@@ -198,7 +205,7 @@ cr.define('settings.printing', function() {
* @param {!Array<!PrinterListEntry>} secondArr * @param {!Array<!PrinterListEntry>} secondArr
* @return {!Array<!PrinterListEntry>} * @return {!Array<!PrinterListEntry>}
*/ */
function findDifference(firstArr, secondArr) { /* #export */ function findDifference(firstArr, secondArr) {
return firstArr.filter(p1 => { return firstArr.filter(p1 => {
return !secondArr.some( return !secondArr.some(
p2 => p2.printerInfo.printerId == p1.printerInfo.printerId); p2 => p2.printerInfo.printerId == p1.printerInfo.printerId);
......
...@@ -2,13 +2,15 @@ ...@@ -2,13 +2,15 @@
// 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.
// #import {CupsPrinterInfo} from './cups_printers_browser_proxy.m.js';
/** /**
* @typedef {{ * @typedef {{
* printerInfo: !CupsPrinterInfo, * printerInfo: !CupsPrinterInfo,
* printerType: number, * printerType: number,
* }} * }}
*/ */
let PrinterListEntry; /* #export */ let PrinterListEntry;
/** /**
* @enum {number} * @enum {number}
...@@ -18,7 +20,7 @@ let PrinterListEntry; ...@@ -18,7 +20,7 @@ let PrinterListEntry;
* *
* The types are numbered in desired sorting order for display. * The types are numbered in desired sorting order for display.
*/ */
const PrinterType = { /* #export */ const PrinterType = {
SAVED: 0, SAVED: 0,
PRINTSERVER: 1, PRINTSERVER: 1,
AUTOMATIC: 2, AUTOMATIC: 2,
......
<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/load_time_data.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/network/mojo_interface_provider.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/network/mojo_interface_provider.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/network/network_listener_behavior.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/network/network_listener_behavior.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/network/onc_mojo.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/network/onc_mojo.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html"> <link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html">
...@@ -22,6 +25,9 @@ ...@@ -22,6 +25,9 @@
<link rel="import" href="../localized_link/localized_link.html"> <link rel="import" href="../localized_link/localized_link.html">
<link rel="import" href="../../icons.html"> <link rel="import" href="../../icons.html">
<link rel="import" href="../os_route.html"> <link rel="import" href="../os_route.html">
<link rel="import" href="../../router.html">
<link rel="import" href="./cups_printers_browser_proxy.html">
<link rel="import" href="./cups_printer_types.html">
<dom-module id="settings-cups-printers"> <dom-module id="settings-cups-printers">
<template> <template>
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
// 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.
// clang-format off
// #import {sendWithPromise, addSingletonGetter} from 'chrome://resources/js/cr.m.js';
// clang-format on
/** /**
* @fileoverview A helper object used from the "CUPS printing" section to * @fileoverview A helper object used from the "CUPS printing" section to
* interact with the browser. Used only on Chrome OS. * interact with the browser. Used only on Chrome OS.
...@@ -34,14 +38,14 @@ ...@@ -34,14 +38,14 @@
* add-printer-manufacturer-model-dialog. |printerPpdReference| refers to either * add-printer-manufacturer-model-dialog. |printerPpdReference| refers to either
* information retrieved from the printer or resolved via ppd_provider. * information retrieved from the printer or resolved via ppd_provider.
*/ */
let CupsPrinterInfo; /* #export */ let CupsPrinterInfo;
/** /**
* @typedef {{ * @typedef {{
* printerList: !Array<!CupsPrinterInfo>, * printerList: !Array<!CupsPrinterInfo>,
* }} * }}
*/ */
let CupsPrintersList; /* #export */ let CupsPrintersList;
/** /**
* @typedef {{ * @typedef {{
...@@ -49,7 +53,7 @@ let CupsPrintersList; ...@@ -49,7 +53,7 @@ let CupsPrintersList;
* manufacturers: Array<string> * manufacturers: Array<string>
* }} * }}
*/ */
let ManufacturersInfo; /* #export */ let ManufacturersInfo;
/** /**
* @typedef {{ * @typedef {{
...@@ -57,7 +61,7 @@ let ManufacturersInfo; ...@@ -57,7 +61,7 @@ let ManufacturersInfo;
* models: Array<string> * models: Array<string>
* }} * }}
*/ */
let ModelsInfo; /* #export */ let ModelsInfo;
/** /**
* @typedef {{ * @typedef {{
...@@ -70,7 +74,7 @@ let ModelsInfo; ...@@ -70,7 +74,7 @@ let ModelsInfo;
* ppdReferenceResolved: boolean * ppdReferenceResolved: boolean
* }} * }}
*/ */
let PrinterMakeModel; /* #export */ let PrinterMakeModel;
/** /**
* @typedef {{ * @typedef {{
...@@ -78,14 +82,14 @@ let PrinterMakeModel; ...@@ -78,14 +82,14 @@ let PrinterMakeModel;
* ppdModel: string * ppdModel: string
* }} * }}
*/ */
let PrinterPpdMakeModel; /* #export */ let PrinterPpdMakeModel;
/** /**
* @enum {number} * @enum {number}
* These values must be kept in sync with the PrinterSetupResult enum in * These values must be kept in sync with the PrinterSetupResult enum in
* chrome/browser/chromeos/printing/printer_configurer.h. * chrome/browser/chromeos/printing/printer_configurer.h.
*/ */
const PrinterSetupResult = { /* #export */ const PrinterSetupResult = {
FATAL_ERROR: 0, FATAL_ERROR: 0,
SUCCESS: 1, SUCCESS: 1,
PRINTER_UNREACHABLE: 2, PRINTER_UNREACHABLE: 2,
...@@ -107,7 +111,7 @@ const PrinterSetupResult = { ...@@ -107,7 +111,7 @@ const PrinterSetupResult = {
* These values must be kept in sync with the PrintServerQueryResult enum in * These values must be kept in sync with the PrintServerQueryResult enum in
* /chrome/browser/chromeos/printing/server_printers_fetcher.h * /chrome/browser/chromeos/printing/server_printers_fetcher.h
*/ */
const PrintServerResult = { /* #export */ const PrintServerResult = {
NO_ERRORS: 0, NO_ERRORS: 0,
INCORRECT_URL: 1, INCORRECT_URL: 1,
CONNECTION_ERROR: 2, CONNECTION_ERROR: 2,
...@@ -124,7 +128,7 @@ let QueryFailure; ...@@ -124,7 +128,7 @@ let QueryFailure;
cr.define('settings', function() { cr.define('settings', function() {
/** @interface */ /** @interface */
class CupsPrintersBrowserProxy { /* #export */ class CupsPrintersBrowserProxy {
/** /**
* @return {!Promise<!CupsPrintersList>} * @return {!Promise<!CupsPrintersList>}
*/ */
...@@ -222,7 +226,7 @@ cr.define('settings', function() { ...@@ -222,7 +226,7 @@ cr.define('settings', function() {
/** /**
* @implements {settings.CupsPrintersBrowserProxy} * @implements {settings.CupsPrintersBrowserProxy}
*/ */
class CupsPrintersBrowserProxyImpl { /* #export */ class CupsPrintersBrowserProxyImpl {
/** @override */ /** @override */
getCupsPrintersList() { getCupsPrintersList() {
return cr.sendWithPromise('getCupsPrintersList'); return cr.sendWithPromise('getCupsPrintersList');
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<link rel="import" href="cups_printer_types.html"> <link rel="import" href="cups_printer_types.html">
<link rel="import" href="cups_printers_browser_proxy.html"> <link rel="import" href="cups_printers_browser_proxy.html">
<link rel="import" href="../../settings_shared_css.html"> <link rel="import" href="../../settings_shared_css.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<dom-module id="settings-cups-printers-entry"> <dom-module id="settings-cups-printers-entry">
<template> <template>
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
// 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.
// #import {assert} from 'chrome://resources/js/assert.m.js';
// #import {PrinterListEntry} from './cups_printer_types.m.js';
// #import {CupsPrintersEntryManager} from './cups_printers_entry_manager.m.js';
// #import {findDifference} from './cups_printer_dialog_util.m.js';
/** /**
* @fileoverview Polymer behavior for observing CupsPrintersEntryManager events. * @fileoverview Polymer behavior for observing CupsPrintersEntryManager events.
* Use this behavior if you want to receive a dynamically updated list of both * Use this behavior if you want to receive a dynamically updated list of both
...@@ -9,7 +14,7 @@ ...@@ -9,7 +14,7 @@
*/ */
/** @polymerBehavior */ /** @polymerBehavior */
const CupsPrintersEntryListBehavior = { /* #export */ const CupsPrintersEntryListBehavior = {
properties: { properties: {
/** @private {!settings.printing.CupsPrintersEntryManager} */ /** @private {!settings.printing.CupsPrintersEntryManager} */
entryManager_: Object, entryManager_: Object,
......
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
// 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.
// clang-format off
// #import {addWebUIListener, addSingletonGetter, removeWebUIListener} from 'chrome://resources/js/cr.m.js';
// #import {WebUIListener} from 'chrome://resources/js/cr.m.js';
// #import {CupsPrintersBrowserProxyImpl, CupsPrintersList, CupsPrinterInfo} from './cups_printers_browser_proxy.m.js';
// #import {findDifference} from './cups_printer_dialog_util.m.js';
// #import {PrinterType, PrinterListEntry} from './cups_printer_types.m.js';
// clang-format on
/** /**
* Function which provides the client with metadata about a change * Function which provides the client with metadata about a change
* to a list of saved printers. The first parameter is the updated list of * to a list of saved printers. The first parameter is the updated list of
...@@ -27,7 +35,7 @@ cr.define('settings.printing', function() { ...@@ -27,7 +35,7 @@ cr.define('settings.printing', function() {
* printers and notifies observers of any applicable changes to either printer * printers and notifies observers of any applicable changes to either printer
* lists. * lists.
*/ */
class CupsPrintersEntryManager { /* #export */ class CupsPrintersEntryManager {
constructor() { constructor() {
/** @private {!Array<!PrinterListEntry>} */ /** @private {!Array<!PrinterListEntry>} */
this.savedPrinters_ = []; this.savedPrinters_ = [];
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<link rel="import" href="cups_printers_browser_proxy.html"> <link rel="import" href="cups_printers_browser_proxy.html">
<link rel="import" href="cups_printers_entry_list_behavior.html"> <link rel="import" href="cups_printers_entry_list_behavior.html">
<link rel="import" href="cups_printers_entry.html"> <link rel="import" href="cups_printers_entry.html">
<link rel="import" href="cups_printer_dialog_util.html">
<link rel="import" href="../metrics_recorder.html"> <link rel="import" href="../metrics_recorder.html">
<link rel="import" href="../../settings_shared_css.html"> <link rel="import" href="../../settings_shared_css.html">
......
<link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/js/assert.js"> <link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/load_time_data.html"> <link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="../os_route.html"> <link rel="import" href="../os_route.html">
<link rel="import" href="../../router.html"> <link rel="import" href="../../router.html">
......
...@@ -61,6 +61,19 @@ os_settings_namespace_rewrites = settings_namespace_rewrites + ...@@ -61,6 +61,19 @@ os_settings_namespace_rewrites = settings_namespace_rewrites +
"settings.ValidateKerberosConfigResult|ValidateKerberosConfigResult", "settings.ValidateKerberosConfigResult|ValidateKerberosConfigResult",
"settings.WallpaperBrowserProxy|WallpaperBrowserProxy", "settings.WallpaperBrowserProxy|WallpaperBrowserProxy",
"smb_shares.SmbBrowserProxy|SmbBrowserProxy", "smb_shares.SmbBrowserProxy|SmbBrowserProxy",
"settings.CupsPrintersBrowserProxy|CupsPrintersBrowserProxy",
"settings.CupsPrintersBrowserProxyImpl|CupsPrintersBrowserProxyImpl",
"settings.printing.alphabeticalSort|alphabeticalSort",
"settings.printing.CupsPrintersEntryManager|CupsPrintersEntryManager",
"settings.printing.matchesSearchTerm|matchesSearchTerm",
"settings.printing.sortPrinters|sortPrinters",
"settings.printing.findDifference|findDifference",
"settings.printing.getBaseName|getBaseName",
"settings.printing.getErrorText|getErrorText",
"settings.printing.isNetworkProtocol|isNetworkProtocol",
"settings.printing.isNameAndAddressValid|isNameAndAddressValid",
"settings.printing.isPPDInfoValid|isPPDInfoValid",
"settings.printing.getPrintServerErrorText|getPrintServerErrorText",
] ]
os_settings_auto_imports = settings_auto_imports + os_settings_auto_imports = settings_auto_imports +
...@@ -96,9 +109,17 @@ os_settings_auto_imports = settings_auto_imports + ...@@ -96,9 +109,17 @@ os_settings_auto_imports = settings_auto_imports +
"chrome/browser/resources/settings/route.html|routes", "chrome/browser/resources/settings/route.html|routes",
"chrome/browser/resources/settings/router.html|Router,Route,RouteObserverBehavior", "chrome/browser/resources/settings/router.html|Router,Route,RouteObserverBehavior",
"ui/webui/resources/html/assert.html|assert,assertNotReached", "ui/webui/resources/html/assert.html|assert,assertNotReached",
"ui/webui/resources/html/cr.html|sendWithPromise", "ui/webui/resources/html/cr.html|sendWithPromise,removeWebUIListener,addWebUIListener,WebUIListener",
"ui/webui/resources/html/icon.html|getImage", "ui/webui/resources/html/icon.html|getImage",
"ui/webui/resources/html/polymer.html|afterNextRender,Polymer,html,flush", "ui/webui/resources/html/polymer.html|afterNextRender,Polymer,html,flush",
"chrome/browser/resources/settings/chromeos/os_printing_page/cups_printers_browser_proxy.html|CupsPrintersBrowserProxy,CupsPrintersBrowserProxyImpl,CupsPrinterInfo,PrinterSetupResult,CupsPrintersList,PrinterPpdMakeModel,ManufacturersInfo,ModelsInfo,PrintServerResult,PrinterMakeModel",
"chrome/browser/resources/settings/chromeos/os_printing_page/cups_printers_entry_list_behavior.html|CupsPrintersEntryListBehavior",
"chrome/browser/resources/settings/chromeos/os_printing_page/cups_printers_entry_manager.html|CupsPrintersEntryManager",
"chrome/browser/resources/settings/chromeos/os_printing_page/cups_printer_dialog_util.html|sortPrinters,matchesSearchTerm,getBaseName,getErrorText,isNetworkProtocol,isNameAndAddressValid,isPPDInfoValid,getPrintServerErrorText",
"ui/webui/resources/html/list_property_update_behavior.html|ListPropertyUpdateBehavior",
"ui/webui/resources/html/web_ui_listener_behavior.html|WebUIListenerBehavior",
"ui/webui/resources/cr_components/chromeos/network/network_listener_behavior.html|NetworkListenerBehavior",
"chrome/browser/resources/settings/chromeos/os_printing_page/cups_printer_types.html|PrinterListEntry,PrinterType",
] ]
os_settings_migrated_imports = settings_migrated_imports os_settings_migrated_imports = settings_migrated_imports
...@@ -311,6 +311,96 @@ ...@@ -311,6 +311,96 @@
use_base_dir="false" use_base_dir="false"
compress="false" compress="false"
type="BINDATA" /> type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_ADD_PRINT_SERVER_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_add_print_server_dialog.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_ADD_PRINTER_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_add_printer_dialog.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_ADD_PRINTER_MANUALLY_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_add_printer_manually_dialog.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_ADD_PRINTER_MANUFACTURER_MODEL_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_add_printer_manufacturer_model_dialog.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_EDIT_PRINTER_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_edit_printer_dialog.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_NEARBY_PRINTERS_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_nearby_printers.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_PRINTER_DIALOG_ERROR_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_printer_dialog_error.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_PRINTER_DIALOG_UTIL_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_printer_dialog_util.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_PRINTER_SHARED_CSS_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_printer_shared_css.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_PRINTER_TYPES_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_printer_types.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_PRINTERS_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_printers.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_PRINTERS_BROWSER_PROXY_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_printers_browser_proxy.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_PRINTERS_ENTRY_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_printers_entry.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_PRINTERS_ENTRY_LIST_BEHAVIOR_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_printers_entry_list_behavior.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_PRINTERS_ENTRY_MANAGER_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_printers_entry_manager.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_SAVED_PRINTERS_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_saved_printers.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CUPS_SETTINGS_ADD_PRINTER_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/cups_settings_add_printer_dialog.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_OS_PRINTING_PAGE_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_printing_page/os_printing_page.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_FILES_PAGE_OS_FILES_PAGE_M_JS" <include name="IDR_OS_SETTINGS_OS_FILES_PAGE_OS_FILES_PAGE_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_files_page/os_files_page.m.js" file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_files_page/os_files_page.m.js"
use_base_dir="false" use_base_dir="false"
......
...@@ -288,6 +288,11 @@ if (include_js_tests) { ...@@ -288,6 +288,11 @@ if (include_js_tests) {
"$root_gen_dir/chrome/test/data/webui/settings/chromeos/test_wallpaper_browser_proxy.m.js", "$root_gen_dir/chrome/test/data/webui/settings/chromeos/test_wallpaper_browser_proxy.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/chromeos/timezone_selector_test.m.js", "$root_gen_dir/chrome/test/data/webui/settings/chromeos/timezone_selector_test.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/chromeos/timezone_subpage_test.m.js", "$root_gen_dir/chrome/test/data/webui/settings/chromeos/timezone_subpage_test.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/chromeos/test_cups_printers_browser_proxy.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/chromeos/cups_printer_page_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/chromeos/cups_printer_test_utils.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/chromeos/cups_printer_landing_page_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/chromeos/cups_printer_entry_tests.m.js",
] ]
} }
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
......
...@@ -70,6 +70,11 @@ js_modulizer("modulize") { ...@@ -70,6 +70,11 @@ js_modulizer("modulize") {
"test_os_sync_browser_proxy.js", "test_os_sync_browser_proxy.js",
"timezone_selector_test.js", "timezone_selector_test.js",
"timezone_subpage_test.js", "timezone_subpage_test.js",
"test_cups_printers_browser_proxy.js",
"cups_printer_page_tests.js",
"cups_printer_test_utils.js",
"cups_printer_landing_page_tests.js",
"cups_printer_entry_tests.js",
] ]
namespace_rewrites = namespace_rewrites =
os_settings_namespace_rewrites + os_test_namespace_rewrites os_settings_namespace_rewrites + os_test_namespace_rewrites
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
// 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.
// clang-format off
// #import 'chrome://os-settings/chromeos/lazy_load.js';
// #import {PrinterType} from 'chrome://os-settings/chromeos/lazy_load.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// clang-format on
/** /**
* Helper function to verify that printers in |printerListEntries| that contain * Helper function to verify that printers in |printerListEntries| that contain
* |searchTerm| are not in |hiddenEntries|. * |searchTerm| are not in |hiddenEntries|.
......
...@@ -2,6 +2,21 @@ ...@@ -2,6 +2,21 @@
// 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.
// clang-format off
// #import 'chrome://os-settings/chromeos/lazy_load.js';
// #import {Router, routes} from 'chrome://os-settings/chromeos/os_settings.js';
// #import {CupsPrintersBrowserProxyImpl,PrinterSetupResult,CupsPrintersEntryManager,PrintServerResult,PrinterType} from 'chrome://os-settings/chromeos/lazy_load.js';
// #import {TestCupsPrintersBrowserProxy} from './test_cups_printers_browser_proxy.m.js';
// #import {createCupsPrinterInfo,createPrinterListEntry} from './cups_printer_test_utils.m.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {assertEquals, assertFalse, assertNotEquals, assertTrue} from '../../chai_assert.js';
// #import {flushTasks} from '../../test_util.m.js';
// #import {MojoInterfaceProviderImpl, MojoInterfaceProvider} from '//resources/cr_components/chromeos/network/mojo_interface_provider.m.js';
// #import {keyEventOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
// #import {OncMojo} from 'chrome://resources/cr_components/chromeos/network/onc_mojo.m.js';
// clang-format on
/* /*
* Helper function that waits for |getEulaUrl| to get called and then verifies * Helper function that waits for |getEulaUrl| to get called and then verifies
* its arguments. * its arguments.
...@@ -244,7 +259,8 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -244,7 +259,8 @@ suite('CupsAddPrinterDialogTests', function() {
}); });
/** /**
* Test that when getPrinterInfo fails for an unreachable printer, the printer * Test that when getPrinterInfo fails for an unreachable printer, the
printer
* address field is marked as invalid. * address field is marked as invalid.
*/ */
test('GetPrinterInfoFailsUnreachableError', function() { test('GetPrinterInfoFailsUnreachableError', function() {
...@@ -476,7 +492,8 @@ suite('CupsAddPrinterDialogTests', function() { ...@@ -476,7 +492,8 @@ suite('CupsAddPrinterDialogTests', function() {
}); });
/** /**
* The following tests check that clicking Enter button on the keyboard from * The following tests check that clicking Enter button on the keyboard
from
* each input text field on the add-printer-manually-dialog will advance to * each input text field on the add-printer-manually-dialog will advance to
* the next dialog. * the next dialog.
*/ */
...@@ -599,13 +616,8 @@ suite('EditPrinterDialog', function() { ...@@ -599,13 +616,8 @@ suite('EditPrinterDialog', function() {
/** @type {?settings.TestCupsPrintersBrowserProxy} */ /** @type {?settings.TestCupsPrintersBrowserProxy} */
let cupsPrintersBrowserProxy = null; let cupsPrintersBrowserProxy = null;
/** @type {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} */ /** @type {!chromeos.networkConfig.mojom.NetworkStateProperties|undefined} */
let mojoApi; let wifi1;
suiteSetup(function() {
mojoApi = new FakeNetworkConfig();
network_config.MojoInterfaceProviderImpl.getInstance().remote_ = mojoApi;
});
setup(function() { setup(function() {
const mojom = chromeos.networkConfig.mojom; const mojom = chromeos.networkConfig.mojom;
...@@ -616,11 +628,8 @@ suite('EditPrinterDialog', function() { ...@@ -616,11 +628,8 @@ suite('EditPrinterDialog', function() {
settings.CupsPrintersBrowserProxyImpl.instance_ = cupsPrintersBrowserProxy; settings.CupsPrintersBrowserProxyImpl.instance_ = cupsPrintersBrowserProxy;
// Simulate internet connection. // Simulate internet connection.
mojoApi.resetForTest(); wifi1 = OncMojo.getDefaultNetworkState(mojom.NetworkType.kWiFi, 'wifi1');
const wifi1 =
OncMojo.getDefaultNetworkState(mojom.NetworkType.kWiFi, 'wifi1');
wifi1.connectionState = mojom.ConnectionStateType.kOnline; wifi1.connectionState = mojom.ConnectionStateType.kOnline;
mojoApi.addNetworksForTest([wifi1]);
PolymerTest.clearBody(); PolymerTest.clearBody();
settings.Router.getInstance().navigateTo(settings.routes.CUPS_PRINTERS); settings.Router.getInstance().navigateTo(settings.routes.CUPS_PRINTERS);
...@@ -628,11 +637,11 @@ suite('EditPrinterDialog', function() { ...@@ -628,11 +637,11 @@ suite('EditPrinterDialog', function() {
page = document.createElement('settings-cups-printers'); page = document.createElement('settings-cups-printers');
document.body.appendChild(page); document.body.appendChild(page);
assertTrue(!!page); assertTrue(!!page);
page.onActiveNetworksChanged([wifi1]);
Polymer.dom.flush(); Polymer.dom.flush();
}); });
teardown(function() { teardown(function() {
mojoApi.resetForTest();
cupsPrintersBrowserProxy.reset(); cupsPrintersBrowserProxy.reset();
page.remove(); page.remove();
dialog = null; dialog = null;
...@@ -738,7 +747,7 @@ suite('EditPrinterDialog', function() { ...@@ -738,7 +747,7 @@ suite('EditPrinterDialog', function() {
assertTrue(saveButton.disabled); assertTrue(saveButton.disabled);
// Change printer name to something valid. // Change printer name to something valid.
printerName = dialog.$.printerName; const printerName = dialog.$.printerName;
printerName.value = 'new printer name'; printerName.value = 'new printer name';
printerName.fire('input'); printerName.fire('input');
assertFalse(saveButton.disabled); assertFalse(saveButton.disabled);
...@@ -1011,7 +1020,7 @@ suite('EditPrinterDialog', function() { ...@@ -1011,7 +1020,7 @@ suite('EditPrinterDialog', function() {
assertTrue(!!saveButton); assertTrue(!!saveButton);
assertTrue(saveButton.disabled); assertTrue(saveButton.disabled);
makeDropDown = dialog.$$('#printerPPDManufacturer'); const makeDropDown = dialog.$$('#printerPPDManufacturer');
makeDropDown.value = 'HP'; makeDropDown.value = 'HP';
makeDropDown.dispatchEvent( makeDropDown.dispatchEvent(
new CustomEvent('change'), {'bubbles': true}); new CustomEvent('change'), {'bubbles': true});
...@@ -1023,7 +1032,7 @@ suite('EditPrinterDialog', function() { ...@@ -1023,7 +1032,7 @@ suite('EditPrinterDialog', function() {
// Saving is disabled until a model is selected. // Saving is disabled until a model is selected.
assertTrue(saveButton.disabled); assertTrue(saveButton.disabled);
modelDropDown = dialog.$$('#printerPPDModel'); const modelDropDown = dialog.$$('#printerPPDModel');
modelDropDown.value = 'HP 910'; modelDropDown.value = 'HP 910';
modelDropDown.dispatchEvent( modelDropDown.dispatchEvent(
new CustomEvent('change'), {'bubbles': true}); new CustomEvent('change'), {'bubbles': true});
...@@ -1099,9 +1108,10 @@ suite('EditPrinterDialog', function() { ...@@ -1099,9 +1108,10 @@ suite('EditPrinterDialog', function() {
*/ */
test('OfflineEdit', function() { test('OfflineEdit', function() {
// Simulate connecting to a network with no internet connection. // Simulate connecting to a network with no internet connection.
mojoApi.setNetworkConnectionStateForTest( wifi1.connectionState =
'wifi1_guid', chromeos.networkConfig.mojom.ConnectionStateType.kConnected;
chromeos.networkConfig.mojom.ConnectionStateType.kConnected); page.onActiveNetworksChanged([wifi1]);
Polymer.dom.flush();
const expectedName = 'editedName'; const expectedName = 'editedName';
return initializeAndOpenEditDialog( return initializeAndOpenEditDialog(
/*name=*/ 'name', /*address=*/ 'address', /*id=*/ 'id', /*name=*/ 'name', /*address=*/ 'address', /*id=*/ 'id',
...@@ -1172,16 +1182,8 @@ suite('PrintServerTests', function() { ...@@ -1172,16 +1182,8 @@ suite('PrintServerTests', function() {
/** @type {?settings.TestCupsPrintersBrowserProxy} */ /** @type {?settings.TestCupsPrintersBrowserProxy} */
let cupsPrintersBrowserProxy = null; let cupsPrintersBrowserProxy = null;
/** @type {?chromeos.networkConfig.mojom.CrosNetworkConfigRemote} */
let mojoApi_;
suiteSetup(function() {
mojoApi_ = new FakeNetworkConfig();
network_config.MojoInterfaceProviderImpl.getInstance().remote_ = mojoApi_;
});
setup(function() { setup(function() {
const mojom = chromeos.networkConfig.mojom;
entryManager = settings.printing.CupsPrintersEntryManager.getInstance(); entryManager = settings.printing.CupsPrintersEntryManager.getInstance();
setEntryManagerPrinters( setEntryManagerPrinters(
/*savedPrinters=*/[], /*automaticPrinters=*/[], /*savedPrinters=*/[], /*automaticPrinters=*/[],
...@@ -1192,13 +1194,6 @@ suite('PrintServerTests', function() { ...@@ -1192,13 +1194,6 @@ suite('PrintServerTests', function() {
settings.CupsPrintersBrowserProxyImpl.instance_ = cupsPrintersBrowserProxy; settings.CupsPrintersBrowserProxyImpl.instance_ = cupsPrintersBrowserProxy;
// Simulate internet connection.
mojoApi_.resetForTest();
const wifi1 =
OncMojo.getDefaultNetworkState(mojom.NetworkType.kWiFi, 'wifi1');
wifi1.connectionState = mojom.ConnectionStateType.kOnline;
mojoApi_.addNetworksForTest([wifi1]);
PolymerTest.clearBody(); PolymerTest.clearBody();
settings.Router.getInstance().navigateTo(settings.routes.CUPS_PRINTERS); settings.Router.getInstance().navigateTo(settings.routes.CUPS_PRINTERS);
...@@ -1212,7 +1207,6 @@ suite('PrintServerTests', function() { ...@@ -1212,7 +1207,6 @@ suite('PrintServerTests', function() {
}); });
teardown(function() { teardown(function() {
mojoApi_.resetForTest();
cupsPrintersBrowserProxy.reset(); cupsPrintersBrowserProxy.reset();
page.remove(); page.remove();
dialog = null; dialog = null;
......
...@@ -10,7 +10,8 @@ cr.define('cups_printer_test_util', function() { ...@@ -10,7 +10,8 @@ cr.define('cups_printer_test_util', function() {
* @return {!CupsPrinterInfo} * @return {!CupsPrinterInfo}
* @private * @private
*/ */
function createCupsPrinterInfo(printerName, printerAddress, printerId) { /* #export */ function createCupsPrinterInfo(
printerName, printerAddress, printerId) {
const printer = { const printer = {
ppdManufacturer: '', ppdManufacturer: '',
ppdModel: '', ppdModel: '',
...@@ -43,7 +44,7 @@ cr.define('cups_printer_test_util', function() { ...@@ -43,7 +44,7 @@ cr.define('cups_printer_test_util', function() {
* @param {string} printerType * @param {string} printerType
* @return {!PrinterListEntry} * @return {!PrinterListEntry}
*/ */
function createPrinterListEntry( /* #export */ function createPrinterListEntry(
printerName, printerAddress, printerId, printerType) { printerName, printerAddress, printerId, printerType) {
const entry = { const entry = {
printerInfo: { printerInfo: {
...@@ -79,12 +80,12 @@ cr.define('cups_printer_test_util', function() { ...@@ -79,12 +80,12 @@ cr.define('cups_printer_test_util', function() {
* @return {!Array<!HTMLElement>} * @return {!Array<!HTMLElement>}
* @private * @private
*/ */
function getPrinterEntries(printersElement) { /* #export */ function getPrinterEntries(printersElement) {
const entryList = printersElement.$$('#printerEntryList'); const entryList = printersElement.$$('#printerEntryList');
return entryList.querySelectorAll( return entryList.querySelectorAll(
'settings-cups-printers-entry:not([hidden])'); 'settings-cups-printers-entry:not([hidden])');
} }
// #cr_define_end
return { return {
createCupsPrinterInfo: createCupsPrinterInfo, createCupsPrinterInfo: createCupsPrinterInfo,
getPrinterEntries: getPrinterEntries, getPrinterEntries: getPrinterEntries,
......
...@@ -18,8 +18,13 @@ os_test_namespace_rewrites = os_settings_namespace_rewrites + [ ...@@ -18,8 +18,13 @@ os_test_namespace_rewrites = os_settings_namespace_rewrites + [
"settings.TestLanguagesMetricsProxy|TestLanguagesMetricsProxy", "settings.TestLanguagesMetricsProxy|TestLanguagesMetricsProxy",
"settings.TestLifetimeBrowserProxy|TestLifetimeBrowserProxy", "settings.TestLifetimeBrowserProxy|TestLifetimeBrowserProxy",
"settings.TestWallpaperBrowserProxy|TestWallpaperBrowserProxy", "settings.TestWallpaperBrowserProxy|TestWallpaperBrowserProxy",
"printerBrowserProxy.TestCupsPrintersBrowserProxy|TestCupsPrintersBrowserProxy",
"test_util.eventToPromise|eventToPromise", "test_util.eventToPromise|eventToPromise",
"test_util.fakeDataBind|fakeDataBind", "test_util.fakeDataBind|fakeDataBind",
"test_util.flushTasks|flushTasks", "test_util.flushTasks|flushTasks",
"test_util.waitAfterNextRender|waitAfterNextRender", "test_util.waitAfterNextRender|waitAfterNextRender",
"MockInteractions.keyEventOn|keyEventOn",
"cups_printer_test_util.createCupsPrinterInfo|createCupsPrinterInfo",
"cups_printer_test_util.createPrinterListEntry|createPrinterListEntry",
"cups_printer_test_util.getPrinterEntries|getPrinterEntries",
] ]
...@@ -64,6 +64,9 @@ var OSSettingsV3BrowserTest = class extends PolymerTest { ...@@ -64,6 +64,9 @@ var OSSettingsV3BrowserTest = class extends PolymerTest {
['SmartInputsPage', 'smart_inputs_page_test.m.js'], ['SmartInputsPage', 'smart_inputs_page_test.m.js'],
['TimezoneSelector', 'timezone_selector_test.m.js'], ['TimezoneSelector', 'timezone_selector_test.m.js'],
['TimezoneSubpage', 'timezone_subpage_test.m.js'], ['TimezoneSubpage', 'timezone_subpage_test.m.js'],
['CupsPrinterPage', 'cups_printer_page_tests.m.js'],
['CupsPrinterLandingPage', 'cups_printer_landing_page_tests.m.js'],
['CupsPrinterEntry', 'cups_printer_entry_tests.m.js'],
].forEach(test => registerTest(...test)); ].forEach(test => registerTest(...test));
function registerTest(testName, module, caseName) { function registerTest(testName, module, caseName) {
......
...@@ -2,9 +2,14 @@ ...@@ -2,9 +2,14 @@
// 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.
// clang-format off
// #import {TestBrowserProxy} from '../../test_browser_proxy.m.js';
// #import {CupsPrintersBrowserProxy,PrinterSetupResult,PrintServerResult} from 'chrome://os-settings/chromeos/lazy_load.js';
// clang-format on
cr.define('printerBrowserProxy', function() { cr.define('printerBrowserProxy', function() {
/** @implements {settings.CupsPrintersBrowserProxy} */ /** @implements {settings.CupsPrintersBrowserProxy} */
class TestCupsPrintersBrowserProxy extends TestBrowserProxy { /* #export */ class TestCupsPrintersBrowserProxy extends TestBrowserProxy {
constructor() { constructor() {
super([ super([
'addCupsPrinter', 'addCupsPrinter',
...@@ -181,6 +186,7 @@ cr.define('printerBrowserProxy', function() { ...@@ -181,6 +186,7 @@ cr.define('printerBrowserProxy', function() {
this.addDiscoveredFailedPrinter_ = printer; this.addDiscoveredFailedPrinter_ = printer;
} }
} }
// #cr_define_end
return { return {
TestCupsPrintersBrowserProxy: TestCupsPrintersBrowserProxy, TestCupsPrintersBrowserProxy: TestCupsPrintersBrowserProxy,
}; };
......
...@@ -2,8 +2,11 @@ ...@@ -2,8 +2,11 @@
// 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.
// clang-format off
// #import {TestBrowserProxy} from '../../test_browser_proxy.m.js'; // #import {TestBrowserProxy} from '../../test_browser_proxy.m.js';
// #import {MultiDeviceSettingsMode, MultiDeviceFeature, MultiDevicePageContentData} from 'chrome://os-settings/chromeos/os_settings.js'; // #import {MultiDeviceSettingsMode, MultiDeviceFeature, MultiDevicePageContentData} from 'chrome://os-settings/chromeos/os_settings.js';
// #import {PrintServerResult} from 'chrome://os-settings/chromeos/lazy_load.js';
// clang-format on
cr.define('multidevice', function() { cr.define('multidevice', function() {
/** /**
......
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