Commit c072c278 authored by Jimmy Gong's avatar Jimmy Gong Committed by Commit Bot

Move CUPS printers test functions to test utils

- Moving these test util functions allows shared access to
  the functions.

Bug: 1015628
Test: browser test
Change-Id: I3332b6e477222eba590725165569beb2715942ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1998819
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@{#731725}
parent d0d6fc4e
// Copyright 2020 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('cups_printer_test_util', function() {
/**
* @param {string} printerName
* @param {string} printerAddress
* @param {string} printerId
* @return {!CupsPrinterInfo}
* @private
*/
function createCupsPrinterInfo(printerName, printerAddress, printerId) {
const printer = {
ppdManufacturer: '',
ppdModel: '',
printerAddress: printerAddress,
printerDescription: '',
printerId: printerId,
printerManufacturer: '',
printerModel: '',
printerMakeAndModel: '',
printerName: printerName,
printerPPDPath: '',
printerPpdReference: {
userSuppliedPpdUrl: '',
effectiveMakeAndModel: '',
autoconf: false,
},
printerProtocol: 'ipp',
printerQueue: 'moreinfohere',
printerStatus: '',
};
return printer;
}
/**
* Helper function that creates a new PrinterListEntry.
* @param {string} printerName
* @param {string} printerAddress
* @param {string} printerId
* @param {string} printerType
* @return {!PrinterListEntry}
*/
function createPrinterListEntry(
printerName, printerAddress, printerId, printerType) {
const entry = {
printerInfo: {
ppdManufacturer: '',
ppdModel: '',
printerAddress: printerAddress,
printerDescription: '',
printerId: printerId,
printerManufacturer: '',
printerModel: '',
printerMakeAndModel: '',
printerName: printerName,
printerPPDPath: '',
printerPpdReference: {
userSuppliedPpdUrl: '',
effectiveMakeAndModel: '',
autoconf: false,
},
printerProtocol: 'ipp',
printerQueue: 'moreinfohere',
printerStatus: '',
},
printerType: printerType,
};
return entry;
}
/**
* Helper method to pull an array of CupsPrinterEntry out of a
* |printersElement|.
* @param {!HTMLElement} printersElement
* @return {!Array<!HTMLElement>}
* @private
*/
function getPrinterEntries(printersElement) {
const entryList = printersElement.$$('#printerEntryList');
return entryList.querySelectorAll(
'settings-cups-printers-entry:not([hidden])');
}
return {
createCupsPrinterInfo: createCupsPrinterInfo,
getPrinterEntries: getPrinterEntries,
createPrinterListEntry: createPrinterListEntry,
};
});
......@@ -1010,6 +1010,7 @@ var OSSettingsPrinterLandingPageTest = class extends OSSettingsBrowserTest {
BROWSER_SETTINGS_PATH + '../test_browser_proxy.js',
BROWSER_SETTINGS_PATH + '../fake_chrome_event.js',
BROWSER_SETTINGS_PATH + '../chromeos/fake_network_config_mojom.js',
'cups_printer_test_utils.js',
'test_cups_printers_browser_proxy.js',
'cups_printer_landing_page_tests.js',
]);
......@@ -1035,6 +1036,7 @@ var OSSettingsPrintingPageTest = class extends OSSettingsBrowserTest {
BROWSER_SETTINGS_PATH + '../test_util.js',
BROWSER_SETTINGS_PATH + '../test_browser_proxy.js',
'test_cups_printers_browser_proxy.js',
'cups_printer_test_utils.js',
'cups_printer_page_tests.js',
]);
}
......
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