Commit 8f13a697 authored by Claude van der Merwe's avatar Claude van der Merwe Committed by Commit Bot

Migrate os_about_page from Polymer 2 to Polymer 3

Bug: 1045266
Change-Id: Id9424142a6da6137a0a667ab6deb7b00ce123a88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2370603
Commit-Queue: Claude van der Merwe <cvandermerwe@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarJon Mann <jonmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801250}
parent 9cf458f4
......@@ -19,7 +19,7 @@
* url: string,
* }}
*/
let RegulatoryInfo;
/* #export */ let RegulatoryInfo;
/**
* @typedef {{
......@@ -28,7 +28,7 @@ let RegulatoryInfo;
* isLts: boolean,
* }}
*/
let ChannelInfo;
/* #export */ let ChannelInfo;
/**
* @typedef {{
......@@ -37,7 +37,7 @@ let ChannelInfo;
* osVersion: string,
* }}
*/
let VersionInfo;
/* #export */ let VersionInfo;
/**
* @typedef {{
......@@ -45,7 +45,7 @@ let VersionInfo;
* size: (string|undefined),
* }}
*/
let AboutPageUpdateInfo;
/* #export */ let AboutPageUpdateInfo;
/**
* @typedef {{
......@@ -59,7 +59,7 @@ let EndOfLifeInfo;
* Enumeration of all possible browser channels.
* @enum {string}
*/
const BrowserChannel = {
/* #export */ const BrowserChannel = {
BETA: 'beta-channel',
CANARY: 'canary-channel',
DEV: 'dev-channel',
......@@ -71,7 +71,7 @@ const BrowserChannel = {
* updateAvailable: boolean,
* }}
*/
let TPMFirmwareUpdateStatusChangedEvent;
/* #export */ let TPMFirmwareUpdateStatusChangedEvent;
// </if>
/**
......@@ -124,7 +124,7 @@ cr.define('settings', function() {
* @param {boolean} isLts
* @return {string}
*/
function browserChannelToI18nId(channel, isLts) {
/* #export */ function browserChannelToI18nId(channel, isLts) {
if (isLts) {
return 'aboutChannelLongTermStable';
}
......@@ -149,7 +149,8 @@ cr.define('settings', function() {
* @return {boolean} Whether the target channel is more stable than the
* current channel.
*/
function isTargetChannelMoreStable(currentChannel, targetChannel) {
/* #export */ function isTargetChannelMoreStable(
currentChannel, targetChannel) {
// List of channels in increasing stability order.
const channelList = [
BrowserChannel.CANARY,
......
......@@ -272,7 +272,8 @@ group("closure_compile_module") {
"multidevice_page:closure_compile_module",
#"os_a11y_page:closure_compile_module",
#"os_about_page:closure_compile_module",
"os_about_page:closure_compile_module",
#"os_apps_page:closure_compile_module",
#"os_apps_page/app_management_page/plugin_vm_page:closure_compile_module",
"os_files_page:closure_compile_module",
......@@ -435,10 +436,13 @@ group("polymer3_elements") {
"..:modulize",
"..:settings_shared_css_module",
"..:settings_vars_css_module",
"../../settings:settings_page_css_module",
"../about_page:modulize",
"../nearby_share_page:polymer3_elements",
"../prefs:modulize",
"../prefs:prefs_module",
"../settings_page:settings_animated_pages_module",
"../settings_page:settings_section_module",
"../settings_page:settings_subpage_module",
]
}
......
......@@ -5,7 +5,7 @@
let lazyLoadPromise = null;
/** @return {!Promise<void>} Resolves when the lazy load module is imported. */
export function ensureLazyLoadedOs() {
export function ensureLazyLoaded() {
if (!lazyLoadPromise) {
const script = document.createElement('script');
script.type = 'module';
......
......@@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni")
import("../os_settings.gni")
js_type_check("closure_compile") {
deps = [
......@@ -47,21 +48,23 @@ js_library("channel_switcher_dialog") {
]
}
# TODO: Uncomment as the Polymer3 migration makes progress.
#js_type_check("closure_compile_module") {
# is_polymer3 = true
# deps = [
# ":channel_switcher_dialog.m",
# ":detailed_build_info.m",
# ":os_about_page.m",
# ":update_warning_dialog.m"
# ]
#}
js_type_check("closure_compile_module") {
is_polymer3 = true
deps = [
":channel_switcher_dialog.m",
":detailed_build_info.m",
":os_about_page.m",
":update_warning_dialog.m",
]
}
js_library("channel_switcher_dialog.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/os_about_page/channel_switcher_dialog.m.js" ]
deps = [
# TODO: Fill those in.
"../../about_page:about_page_browser_proxy.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:load_time_data.m",
]
extra_deps = [ ":channel_switcher_dialog_module" ]
}
......@@ -69,7 +72,10 @@ js_library("channel_switcher_dialog.m") {
js_library("detailed_build_info.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/os_about_page/detailed_build_info.m.js" ]
deps = [
# TODO: Fill those in.
"../../about_page:about_page_browser_proxy.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/policy:cr_policy_indicator_behavior.m",
"//ui/webui/resources/js:i18n_behavior.m",
]
extra_deps = [ ":detailed_build_info_module" ]
}
......@@ -77,7 +83,17 @@ js_library("detailed_build_info.m") {
js_library("os_about_page.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/os_about_page/os_about_page.m.js" ]
deps = [
# TODO: Fill those in.
"..:os_route.m",
"../..:i18n_setup",
"../..:lifetime_browser_proxy.m",
"../..:router.m",
"../../about_page:about_page_browser_proxy.m",
"../os_settings_page:main_page_behavior.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:i18n_behavior.m",
"//ui/webui/resources/js:load_time_data.m",
"//ui/webui/resources/js:parse_html_subset.m",
"//ui/webui/resources/js:web_ui_listener_behavior.m",
]
extra_deps = [ ":os_about_page_module" ]
}
......@@ -85,7 +101,9 @@ js_library("os_about_page.m") {
js_library("update_warning_dialog.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/os_about_page/update_warning_dialog.m.js" ]
deps = [
# TODO: Fill those in.
"../../about_page:about_page_browser_proxy.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:i18n_behavior.m",
]
extra_deps = [ ":update_warning_dialog_module" ]
}
......@@ -105,22 +123,34 @@ polymer_modulizer("channel_switcher_dialog") {
js_file = "channel_switcher_dialog.js"
html_file = "channel_switcher_dialog.html"
html_type = "dom-module"
migrated_imports = settings_migrated_imports
namespace_rewrites = os_settings_namespace_rewrites
auto_imports = os_settings_auto_imports
}
polymer_modulizer("detailed_build_info") {
js_file = "detailed_build_info.js"
html_file = "detailed_build_info.html"
html_type = "dom-module"
migrated_imports = settings_migrated_imports
namespace_rewrites = os_settings_namespace_rewrites
auto_imports = os_settings_auto_imports
}
polymer_modulizer("os_about_page") {
js_file = "os_about_page.js"
html_file = "os_about_page.html"
html_type = "dom-module"
migrated_imports = settings_migrated_imports
namespace_rewrites = os_settings_namespace_rewrites
auto_imports = os_settings_auto_imports
}
polymer_modulizer("update_warning_dialog") {
js_file = "update_warning_dialog.js"
html_file = "update_warning_dialog.html"
html_type = "dom-module"
migrated_imports = settings_migrated_imports
namespace_rewrites = os_settings_namespace_rewrites
auto_imports = os_settings_auto_imports
}
......@@ -7,6 +7,8 @@
<link rel="import" href="chrome://resources/polymer/v1_0/iron-selector/iron-selector.html">
<link rel="import" href="../../about_page/about_page_browser_proxy.html">
<link rel="import" href="../../settings_shared_css.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<dom-module id="settings-channel-switcher-dialog">
<template>
......
......@@ -9,6 +9,7 @@
<link rel="import" href="../localized_link/localized_link.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator_behavior.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<dom-module id="settings-detailed-build-info">
......
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/html/parse_html_subset.html">
<link rel="import" href="../../about_page/about_page_browser_proxy.html">
<link rel="import" href="../../i18n_setup.html">
<!-- TODO(crbug.com/986596): Don't use browser icons here. Fork them. -->
<link rel="import" href="../../icons.html">
<link rel="import" href="../../lifetime_browser_proxy.html">
<link rel="import" href="../../prefs/prefs.html">
......@@ -62,6 +62,7 @@
text-align: center;
}
/* TODO(crbug.com/986596): Don't use browser icons here. Fork them. */
iron-icon[icon='settings:check-circle'] {
fill: var(--cros-icon-color-prominent);
}
......@@ -102,6 +103,7 @@
when update is done) or set the src (when it's updating). -->
<div class="icon-container"
hidden="[[!shouldShowIcons_(showUpdateStatus_)]]">
<!-- TODO(crbug.com/986596): Don't use browser icons here. Fork them. -->
<iron-icon
icon$="[[getUpdateStatusIcon_(
hasEndOfLife_, currentUpdateStatusEvent_)]]"
......
......@@ -400,6 +400,7 @@ Polymer({
return 'cr:error';
case UpdateStatus.UPDATED:
case UpdateStatus.NEARLY_UPDATED:
// TODO(crbug.com/986596): Don't use browser icons here. Fork them.
return 'settings:check-circle';
default:
return null;
......@@ -464,6 +465,7 @@ Polymer({
return this.i18nAdvanced('aboutRelaunch');
}
}
return '';
},
/** @private */
......
......@@ -40,8 +40,13 @@ Polymer({
/** @private */
onContinueTap_() {
if (!this.updateInfo || !this.updateInfo.version || !this.updateInfo.size){
console.log('ERROR: requestUpdateOverCellular arguments are undefined');
return;
}
this.browserProxy_.requestUpdateOverCellular(
this.updateInfo.version, this.updateInfo.size);
/** @type {!string} */ (this.updateInfo.version),
/** @type {!string} */ (this.updateInfo.size));
this.$.dialog.close();
},
......
......@@ -74,6 +74,9 @@ os_settings_namespace_rewrites = settings_namespace_rewrites +
"settings.printing.isNameAndAddressValid|isNameAndAddressValid",
"settings.printing.isPPDInfoValid|isPPDInfoValid",
"settings.printing.getPrintServerErrorText|getPrintServerErrorText",
"settings.AboutPageBrowserProxyImpl|AboutPageBrowserProxyImpl",
"settings.browserChannelToI18nId|browserChannelToI18nId",
"settings.isTargetChannelMoreStable|isTargetChannelMoreStable",
]
os_settings_auto_imports = settings_auto_imports +
......@@ -120,6 +123,9 @@ os_settings_auto_imports = settings_auto_imports +
"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",
"chrome/browser/resources/settings/about_page/about_page_browser_proxy.html|AboutPageBrowserProxyImpl,AboutPageUpdateInfo,AboutPageBrowserProxy,browserChannelToI18nId,VersionInfo,ChannelInfo,BrowserChannel,isTargetChannelMoreStable,UpdateStatus,UpdateStatusChangedEvent,RegulatoryInfo,TPMFirmwareUpdateStatusChangedEvent",
"chrome/browser/resources/settings/chromeos/os_settings_page/main_page_behavior.html|MainPageBehavior",
"ui/webui/resources/html/parse_html_subset.html|parseHtmlSubset",
]
os_settings_migrated_imports = settings_migrated_imports
......@@ -16,7 +16,12 @@ import './os_people_page/account_manager.m.js';
import './os_people_page/kerberos_accounts.m.js';
import './parental_controls_page/parental_controls_page.m.js';
import './os_people_page/os_people_page.m.js';
import './os_about_page/os_about_page.m.js';
import './os_about_page/channel_switcher_dialog.m.js';
import './os_about_page/detailed_build_info.m.js';
import './os_about_page/update_warning_dialog.m.js';
export {AboutPageBrowserProxyImpl, BrowserChannel, UpdateStatus} from '../about_page/about_page_browser_proxy.m.js';
export {LifetimeBrowserProxy, LifetimeBrowserProxyImpl} from '../lifetime_browser_proxy.m.js';
export {dataUsageStringToEnum, NearbyShareDataUsage} from '../nearby_share_page/types.m.js';
export {pageVisibility} from '../page_visibility.js';
......
......@@ -406,6 +406,49 @@
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_OS_ABOUT_PAGE_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_about_page/os_about_page.m.js"
use_base_dir="false"
compress="false"
preprocess="true"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_CHANNEL_SWITCHER_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_about_page/channel_switcher_dialog.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_DETAILED_BUILD_INFO_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_about_page/detailed_build_info.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_PRINTING_PAGE_UPDATE_WARNING_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_about_page/update_warning_dialog.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_OS_SETTINGS_OS_SETTINGS_PAGE_MAIN_PAGE_BEHAVIOR_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/chromeos/os_settings_page/main_page_behavior.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_SETTINGS_ABOUT_PAGE_ABOUT_PAGE_BROWSER_PROXY_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/about_page/about_page_browser_proxy.m.js"
use_base_dir="false"
compress="false"
preprocess="true"
type="BINDATA" />
<include name="IDR_SETTINGS_SETTINGS_PAGE_SETTINGS_SECTION_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/settings_page/settings_section.m.js"
use_base_dir="false"
compress="false"
type="BINDATA" />
<include name="IDR_SETTINGS_SETTINGS_PAGE_CSS_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/settings_page_css.m.js"
use_base_dir="false"
compress="false"
preprocess="true"
type="BINDATA" />
<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"
use_base_dir="false"
......
......@@ -300,6 +300,8 @@ if (include_js_tests) {
"$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",
"$root_gen_dir/chrome/test/data/webui/settings/chromeos/os_about_page_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/chromeos/test_about_page_browser_proxy_chromeos.m.js",
]
}
defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
......
......@@ -75,6 +75,8 @@ js_modulizer("modulize") {
"cups_printer_test_utils.js",
"cups_printer_landing_page_tests.js",
"cups_printer_entry_tests.js",
"os_about_page_tests.js",
"test_about_page_browser_proxy_chromeos.js",
]
namespace_rewrites =
os_settings_namespace_rewrites + os_test_namespace_rewrites
......
......@@ -2,8 +2,41 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {TestAboutPageBrowserProxyChromeOS} from './test_about_page_browser_proxy_chromeos.m.js';
// #import {BrowserChannel,UpdateStatus,AboutPageBrowserProxyImpl,LifetimeBrowserProxyImpl,Router, routes} from 'chrome://os-settings/chromeos/os_settings.js';
// #import {PromiseResolver} from 'chrome://resources/js/promise_resolver.m.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {TestLifetimeBrowserProxy} from './test_os_lifetime_browser_proxy.m.js';
// #import {eventToPromise,flushTasks} from 'chrome://test/test_util.m.js';
// clang-format on
cr.define('settings_about_page', function() {
function registerAboutPageTests() {
suite('AboutPageTest', function() {
let page = null;
/** @type {?settings.TestAboutPageBrowserProxyChromeOS} */
let aboutBrowserProxy = null;
/** @type {?settings.TestLifetimeBrowserProxy} */
let lifetimeBrowserProxy = null;
const SPINNER_ICON = 'chrome://resources/images/throbber_small.svg';
setup(function() {
lifetimeBrowserProxy = new settings.TestLifetimeBrowserProxy();
settings.LifetimeBrowserProxyImpl.instance_ = lifetimeBrowserProxy;
aboutBrowserProxy = new TestAboutPageBrowserProxyChromeOS();
settings.AboutPageBrowserProxyImpl.instance_ = aboutBrowserProxy;
return initNewPage();
});
teardown(function() {
page.remove();
page = null;
});
/**
* @param {!UpdateStatus} status
* @param {{
......@@ -24,698 +57,659 @@ cr.define('settings_about_page', function() {
});
}
suite('AboutPageTest', function() {
let page = null;
/** @type {?settings.TestAboutPageBrowserProxyChromeOS} */
let aboutBrowserProxy = null;
/** @type {?settings.TestLifetimeBrowserProxy} */
let lifetimeBrowserProxy = null;
/** @return {!Promise} */
function initNewPage() {
aboutBrowserProxy.reset();
lifetimeBrowserProxy.reset();
PolymerTest.clearBody();
page = document.createElement('os-settings-about-page');
settings.Router.getInstance().navigateTo(settings.routes.ABOUT);
document.body.appendChild(page);
return Promise.all([
aboutBrowserProxy.whenCalled('getChannelInfo'),
aboutBrowserProxy.whenCalled('refreshUpdateStatus'),
aboutBrowserProxy.whenCalled('refreshTPMFirmwareUpdateStatus'),
aboutBrowserProxy.whenCalled('getEnabledReleaseNotes'),
aboutBrowserProxy.whenCalled('checkInternetConnection'),
]);
}
const SPINNER_ICON = 'chrome://resources/images/throbber_small.svg';
/**
* Test that the status icon and status message update according to
* incoming 'update-status-changed' events.
*/
test('IconAndMessageUpdates', function() {
const icon = page.$$('iron-icon');
assertTrue(!!icon);
const statusMessageEl = page.$$('#updateStatusMessage div');
let previousMessageText = statusMessageEl.textContent;
fireStatusChanged(UpdateStatus.CHECKING);
assertEquals(SPINNER_ICON, icon.src);
assertEquals(null, icon.getAttribute('icon'));
assertNotEquals(previousMessageText, statusMessageEl.textContent);
previousMessageText = statusMessageEl.textContent;
fireStatusChanged(UpdateStatus.UPDATING, {progress: 0});
assertEquals(SPINNER_ICON, icon.src);
assertEquals(null, icon.getAttribute('icon'));
assertFalse(statusMessageEl.textContent.includes('%'));
assertNotEquals(previousMessageText, statusMessageEl.textContent);
previousMessageText = statusMessageEl.textContent;
fireStatusChanged(UpdateStatus.UPDATING, {progress: 1});
assertNotEquals(previousMessageText, statusMessageEl.textContent);
assertTrue(statusMessageEl.textContent.includes('%'));
previousMessageText = statusMessageEl.textContent;
fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
assertEquals(null, icon.src);
assertEquals('settings:check-circle', icon.icon);
assertNotEquals(previousMessageText, statusMessageEl.textContent);
previousMessageText = statusMessageEl.textContent;
fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN);
assertEquals(null, icon.src);
assertEquals('cr20:domain', icon.icon);
assertEquals(0, statusMessageEl.textContent.trim().length);
fireStatusChanged(UpdateStatus.FAILED);
assertEquals(null, icon.src);
assertEquals('cr:error', icon.icon);
assertEquals(0, statusMessageEl.textContent.trim().length);
fireStatusChanged(UpdateStatus.DISABLED);
assertEquals(null, icon.src);
assertEquals(null, icon.getAttribute('icon'));
assertEquals(0, statusMessageEl.textContent.trim().length);
});
setup(function() {
lifetimeBrowserProxy = new settings.TestLifetimeBrowserProxy();
settings.LifetimeBrowserProxyImpl.instance_ = lifetimeBrowserProxy;
test('ErrorMessageWithHtml', function() {
const htmlError = 'hello<br>there<br>was<pre>an</pre>error';
fireStatusChanged(UpdateStatus.FAILED, {message: htmlError});
const statusMessageEl = page.$$('#updateStatusMessage div');
assertEquals(htmlError, statusMessageEl.innerHTML);
});
aboutBrowserProxy = new TestAboutPageBrowserProxyChromeOS();
settings.AboutPageBrowserProxyImpl.instance_ = aboutBrowserProxy;
return initNewPage();
});
test('FailedLearnMoreLink', function() {
// Check that link is shown when update failed.
fireStatusChanged(UpdateStatus.FAILED, {message: 'foo'});
assertTrue(!!page.$$('#updateStatusMessage a:not([hidden])'));
teardown(function() {
page.remove();
page = null;
});
/** @return {!Promise} */
function initNewPage() {
aboutBrowserProxy.reset();
lifetimeBrowserProxy.reset();
PolymerTest.clearBody();
page = document.createElement('os-settings-about-page');
settings.Router.getInstance().navigateTo(settings.routes.ABOUT);
document.body.appendChild(page);
return Promise.all([
aboutBrowserProxy.whenCalled('getChannelInfo'),
aboutBrowserProxy.whenCalled('refreshUpdateStatus'),
aboutBrowserProxy.whenCalled('refreshTPMFirmwareUpdateStatus'),
aboutBrowserProxy.whenCalled('getEnabledReleaseNotes'),
aboutBrowserProxy.whenCalled('checkInternetConnection'),
]);
}
// Check that link is hidden when update hasn't failed.
fireStatusChanged(UpdateStatus.UPDATED, {message: ''});
assertTrue(!!page.$$('#updateStatusMessage a[hidden]'));
});
/**
* Test that the status icon and status message update according to
* incoming 'update-status-changed' events.
*/
test('IconAndMessageUpdates', function() {
const icon = page.$$('iron-icon');
assertTrue(!!icon);
const statusMessageEl = page.$$('#updateStatusMessage div');
let previousMessageText = statusMessageEl.textContent;
test('Relaunch', function() {
const {relaunch} = page.$;
assertTrue(!!relaunch);
assertTrue(relaunch.hidden);
fireStatusChanged(UpdateStatus.CHECKING);
assertEquals(SPINNER_ICON, icon.src);
assertEquals(null, icon.getAttribute('icon'));
assertNotEquals(previousMessageText, statusMessageEl.textContent);
previousMessageText = statusMessageEl.textContent;
fireStatusChanged(UpdateStatus.UPDATING, {progress: 0});
assertEquals(SPINNER_ICON, icon.src);
assertEquals(null, icon.getAttribute('icon'));
assertFalse(statusMessageEl.textContent.includes('%'));
assertNotEquals(previousMessageText, statusMessageEl.textContent);
previousMessageText = statusMessageEl.textContent;
fireStatusChanged(UpdateStatus.UPDATING, {progress: 1});
assertNotEquals(previousMessageText, statusMessageEl.textContent);
assertTrue(statusMessageEl.textContent.includes('%'));
previousMessageText = statusMessageEl.textContent;
fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
assertEquals(null, icon.src);
assertEquals('settings:check-circle', icon.icon);
assertNotEquals(previousMessageText, statusMessageEl.textContent);
previousMessageText = statusMessageEl.textContent;
fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN);
assertEquals(null, icon.src);
assertEquals('cr20:domain', icon.icon);
assertEquals(0, statusMessageEl.textContent.trim().length);
fireStatusChanged(UpdateStatus.FAILED);
assertEquals(null, icon.src);
assertEquals('cr:error', icon.icon);
assertEquals(0, statusMessageEl.textContent.trim().length);
fireStatusChanged(UpdateStatus.DISABLED);
assertEquals(null, icon.src);
assertEquals(null, icon.getAttribute('icon'));
assertEquals(0, statusMessageEl.textContent.trim().length);
});
fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
assertFalse(relaunch.hidden);
relaunch.click();
return lifetimeBrowserProxy.whenCalled('relaunch');
});
test('ErrorMessageWithHtml', function() {
const htmlError = 'hello<br>there<br>was<pre>an</pre>error';
fireStatusChanged(UpdateStatus.FAILED, {message: htmlError});
const statusMessageEl = page.$$('#updateStatusMessage div');
assertEquals(htmlError, statusMessageEl.innerHTML);
});
test('NoInternet', function() {
assertTrue(page.$.updateStatusMessage.hidden);
aboutBrowserProxy.sendStatusNoInternet();
Polymer.dom.flush();
assertFalse(page.$.updateStatusMessage.hidden);
assertNotEquals(
page.$.updateStatusMessage.innerHTML.includes('no internet'));
});
test('FailedLearnMoreLink', function() {
// Check that link is shown when update failed.
fireStatusChanged(UpdateStatus.FAILED, {message: 'foo'});
assertTrue(!!page.$$('#updateStatusMessage a:not([hidden])'));
/**
* Test that all buttons update according to incoming
* 'update-status-changed' events for the case where target and current
* channel are the same.
*/
test('ButtonsUpdate_SameChannel', function() {
const {checkForUpdates, relaunch} = page.$;
// Check that link is hidden when update hasn't failed.
fireStatusChanged(UpdateStatus.UPDATED, {message: ''});
assertTrue(!!page.$$('#updateStatusMessage a[hidden]'));
});
assertTrue(!!relaunch);
assertTrue(!!checkForUpdates);
test('Relaunch', function() {
const {relaunch} = page.$;
assertTrue(!!relaunch);
function assertAllHidden() {
assertTrue(checkForUpdates.hidden);
assertTrue(relaunch.hidden);
// Ensure that when all buttons are hidden, the container is also
// hidden.
assertTrue(page.$.buttonContainer.hidden);
}
fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
assertFalse(relaunch.hidden);
relaunch.click();
return lifetimeBrowserProxy.whenCalled('relaunch');
});
// Check that |UPDATED| status is ignored if the user has not
// explicitly checked for updates yet.
fireStatusChanged(UpdateStatus.UPDATED);
assertFalse(checkForUpdates.hidden);
assertTrue(relaunch.hidden);
test('NoInternet', function() {
assertTrue(page.$.updateStatusMessage.hidden);
aboutBrowserProxy.sendStatusNoInternet();
Polymer.dom.flush();
assertFalse(page.$.updateStatusMessage.hidden);
assertNotEquals(
page.$.updateStatusMessage.innerHTML.includes('no internet'));
});
// Check that the "Check for updates" button gets hidden for certain
// UpdateStatus values, even if the CHECKING state was never
// encountered (for example triggering update from crosh command
// line).
fireStatusChanged(UpdateStatus.UPDATING);
assertAllHidden();
fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
assertTrue(checkForUpdates.hidden);
assertFalse(relaunch.hidden);
/**
* Test that all buttons update according to incoming
* 'update-status-changed' events for the case where target and current
* channel are the same.
*/
test('ButtonsUpdate_SameChannel', function() {
const {checkForUpdates, relaunch} = page.$;
fireStatusChanged(UpdateStatus.CHECKING);
assertAllHidden();
assertTrue(!!relaunch);
assertTrue(!!checkForUpdates);
fireStatusChanged(UpdateStatus.UPDATING);
assertAllHidden();
function assertAllHidden() {
assertTrue(checkForUpdates.hidden);
assertTrue(relaunch.hidden);
// Ensure that when all buttons are hidden, the container is also
// hidden.
assertTrue(page.$.buttonContainer.hidden);
}
fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
assertTrue(checkForUpdates.hidden);
assertFalse(relaunch.hidden);
// Check that |UPDATED| status is ignored if the user has not
// explicitly checked for updates yet.
fireStatusChanged(UpdateStatus.UPDATED);
assertFalse(checkForUpdates.hidden);
assertTrue(relaunch.hidden);
fireStatusChanged(UpdateStatus.UPDATED);
assertAllHidden();
// Check that the "Check for updates" button gets hidden for certain
// UpdateStatus values, even if the CHECKING state was never
// encountered (for example triggering update from crosh command
// line).
fireStatusChanged(UpdateStatus.UPDATING);
assertAllHidden();
fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
assertTrue(checkForUpdates.hidden);
assertFalse(relaunch.hidden);
fireStatusChanged(UpdateStatus.FAILED);
assertFalse(checkForUpdates.hidden);
assertTrue(relaunch.hidden);
fireStatusChanged(UpdateStatus.CHECKING);
assertAllHidden();
fireStatusChanged(UpdateStatus.DISABLED);
assertAllHidden();
fireStatusChanged(UpdateStatus.UPDATING);
assertAllHidden();
fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN);
assertAllHidden();
});
fireStatusChanged(UpdateStatus.NEARLY_UPDATED);
assertTrue(checkForUpdates.hidden);
assertFalse(relaunch.hidden);
/**
* Test that buttons update according to incoming
* 'update-status-changed' events for the case where the target channel
* is more stable than current channel and update will powerwash.
*/
test('ButtonsUpdate_BetaToStable', async () => {
aboutBrowserProxy.setChannels(BrowserChannel.BETA, BrowserChannel.STABLE);
await initNewPage();
fireStatusChanged(UpdateStatus.UPDATED);
assertAllHidden();
fireStatusChanged(UpdateStatus.NEARLY_UPDATED, {powerwash: true});
fireStatusChanged(UpdateStatus.FAILED);
assertFalse(checkForUpdates.hidden);
assertTrue(relaunch.hidden);
assertTrue(!!page.$.relaunch);
assertFalse(page.$.relaunch.hidden);
fireStatusChanged(UpdateStatus.DISABLED);
assertAllHidden();
assertEquals(
page.$.relaunch.innerText,
loadTimeData.getString('aboutRelaunchAndPowerwash'));
fireStatusChanged(UpdateStatus.DISABLED_BY_ADMIN);
assertAllHidden();
});
page.$.relaunch.click();
await lifetimeBrowserProxy.whenCalled('relaunch');
});
/**
* Test that buttons update according to incoming
* 'update-status-changed' events for the case where the target channel
* is more stable than current channel and update will powerwash.
*/
test('ButtonsUpdate_BetaToStable', async () => {
aboutBrowserProxy.setChannels(
BrowserChannel.BETA, BrowserChannel.STABLE);
await initNewPage();
/**
* Test that buttons update according to incoming
* 'update-status-changed' events for the case where the target channel
* is less stable than current channel.
*/
test('ButtonsUpdate_StableToBeta', async () => {
aboutBrowserProxy.setChannels(BrowserChannel.STABLE, BrowserChannel.BETA);
await initNewPage();
fireStatusChanged(UpdateStatus.NEARLY_UPDATED, {powerwash: true});
fireStatusChanged(UpdateStatus.NEARLY_UPDATED, {powerwash: false});
assertTrue(!!page.$.relaunch);
assertFalse(page.$.relaunch.hidden);
assertTrue(!!page.$.relaunch);
assertFalse(page.$.relaunch.hidden);
assertEquals(
page.$.relaunch.innerText,
loadTimeData.getString('aboutRelaunchAndPowerwash'));
assertEquals(
page.$.relaunch.innerText, loadTimeData.getString('aboutRelaunch'));
page.$.relaunch.click();
await lifetimeBrowserProxy.whenCalled('relaunch');
});
page.$.relaunch.click();
await lifetimeBrowserProxy.whenCalled('relaunch');
});
/**
* Test that buttons update according to incoming
* 'update-status-changed' events for the case where the target channel
* is less stable than current channel.
*/
test('ButtonsUpdate_StableToBeta', async () => {
aboutBrowserProxy.setChannels(
BrowserChannel.STABLE, BrowserChannel.BETA);
await initNewPage();
/**
* The relaunch and powerwash button is shown if the powerwash flag is set
* in the update status.
*/
test('ButtonsUpdate_Powerwash', async () => {
await initNewPage();
fireStatusChanged(UpdateStatus.NEARLY_UPDATED, {powerwash: false});
fireStatusChanged(UpdateStatus.NEARLY_UPDATED, {powerwash: true});
assertTrue(!!page.$.relaunch);
assertFalse(page.$.relaunch.hidden);
assertTrue(!!page.$.relaunch);
assertFalse(page.$.relaunch.hidden);
assertEquals(
page.$.relaunch.innerText, loadTimeData.getString('aboutRelaunch'));
assertEquals(
page.$.relaunch.innerText,
loadTimeData.getString('aboutRelaunchAndPowerwash'));
page.$.relaunch.click();
await lifetimeBrowserProxy.whenCalled('relaunch');
});
page.$.relaunch.click();
await lifetimeBrowserProxy.whenCalled('relaunch');
});
/**
* Test that release notes button can toggled by feature flags.
* Test that release notes button handles offline/online mode properly.
* page.$$("#") is used to access items inside dom-if.
*/
test('ReleaseNotes', async () => {
const releaseNotes = null;
/**
* The relaunch and powerwash button is shown if the powerwash flag is set
* in the update status.
* Checks the visibility of the "release notes" section when online.
* @param {boolean} isShowing Whether the section is expected to be
* visible.
* @return {!Promise}
*/
test('ButtonsUpdate_Powerwash', async () => {
await initNewPage();
async function checkReleaseNotesOnline(isShowing) {
await aboutBrowserProxy.whenCalled('getEnabledReleaseNotes');
const releaseNotesOnlineEl = page.$$('#releaseNotesOnline');
assertTrue(!!releaseNotesOnlineEl);
assertEquals(isShowing, !releaseNotesOnlineEl.hidden);
}
fireStatusChanged(UpdateStatus.NEARLY_UPDATED, {powerwash: true});
/**
* Checks the visibility of the "release notes" for offline mode.
* @param {boolean} isShowing Whether the section is expected to be
* visible.
* @return {!Promise}
*/
async function checkReleaseNotesOffline(isShowing) {
await aboutBrowserProxy.whenCalled('getEnabledReleaseNotes');
const releaseNotesOfflineEl = page.$$('#releaseNotesOffline');
assertTrue(!!releaseNotesOfflineEl);
assertEquals(isShowing, !releaseNotesOfflineEl.hidden);
}
assertTrue(!!page.$.relaunch);
assertFalse(page.$.relaunch.hidden);
/**
* Checks the visibility of the "release notes" section when disabled.
* @return {!Promise}
*/
async function checkReleaseNotesDisabled() {
await aboutBrowserProxy.whenCalled('getEnabledReleaseNotes');
const releaseNotesOnlineEl = page.$$('#releaseNotesOnline');
assertTrue(!releaseNotesOnlineEl);
const releaseNotesOfflineEl = page.$$('#releaseNotesOffline');
assertTrue(!releaseNotesOfflineEl);
}
assertEquals(
page.$.relaunch.innerText,
loadTimeData.getString('aboutRelaunchAndPowerwash'));
aboutBrowserProxy.setReleaseNotes(false);
aboutBrowserProxy.setInternetConnection(false);
await initNewPage();
await checkReleaseNotesDisabled();
aboutBrowserProxy.setReleaseNotes(false);
aboutBrowserProxy.setInternetConnection(true);
await initNewPage();
await checkReleaseNotesDisabled();
aboutBrowserProxy.setReleaseNotes(true);
aboutBrowserProxy.setInternetConnection(false);
await initNewPage();
await checkReleaseNotesOnline(false);
await checkReleaseNotesOffline(true);
aboutBrowserProxy.setReleaseNotes(true);
aboutBrowserProxy.setInternetConnection(true);
await initNewPage();
await checkReleaseNotesOnline(true);
await checkReleaseNotesOffline(false);
page.$$('#releaseNotesOnline').click();
return aboutBrowserProxy.whenCalled('launchReleaseNotes');
});
page.$.relaunch.click();
await lifetimeBrowserProxy.whenCalled('relaunch');
});
test('RegulatoryInfo', async () => {
const regulatoryInfo = {text: 'foo', url: 'bar'};
/**
* Test that release notes button can toggled by feature flags.
* Test that release notes button handles offline/online mode properly.
* page.$$("#") is used to access items inside dom-if.
* Checks the visibility of the "regulatory info" section.
* @param {boolean} isShowing Whether the section is expected to be
* visible.
* @return {!Promise}
*/
test('ReleaseNotes', async () => {
const releaseNotes = null;
/**
* Checks the visibility of the "release notes" section when online.
* @param {boolean} isShowing Whether the section is expected to be
* visible.
* @return {!Promise}
*/
async function checkReleaseNotesOnline(isShowing) {
await aboutBrowserProxy.whenCalled('getEnabledReleaseNotes');
const releaseNotesOnlineEl = page.$$('#releaseNotesOnline');
assertTrue(!!releaseNotesOnlineEl);
assertEquals(isShowing, !releaseNotesOnlineEl.hidden);
}
/**
* Checks the visibility of the "release notes" for offline mode.
* @param {boolean} isShowing Whether the section is expected to be
* visible.
* @return {!Promise}
*/
async function checkReleaseNotesOffline(isShowing) {
await aboutBrowserProxy.whenCalled('getEnabledReleaseNotes');
const releaseNotesOfflineEl = page.$$('#releaseNotesOffline');
assertTrue(!!releaseNotesOfflineEl);
assertEquals(isShowing, !releaseNotesOfflineEl.hidden);
async function checkRegulatoryInfo(isShowing) {
await aboutBrowserProxy.whenCalled('getRegulatoryInfo');
const regulatoryInfoEl = page.$.regulatoryInfo;
assertTrue(!!regulatoryInfoEl);
assertEquals(isShowing, !regulatoryInfoEl.hidden);
if (isShowing) {
const img = regulatoryInfoEl.querySelector('img');
assertTrue(!!img);
assertEquals(regulatoryInfo.text, img.getAttribute('alt'));
assertEquals(regulatoryInfo.url, img.getAttribute('src'));
}
}
/**
* Checks the visibility of the "release notes" section when disabled.
* @return {!Promise}
*/
async function checkReleaseNotesDisabled() {
await aboutBrowserProxy.whenCalled('getEnabledReleaseNotes');
const releaseNotesOnlineEl = page.$$('#releaseNotesOnline');
assertTrue(!releaseNotesOnlineEl);
const releaseNotesOfflineEl = page.$$('#releaseNotesOffline');
assertTrue(!releaseNotesOfflineEl);
}
await checkRegulatoryInfo(false);
aboutBrowserProxy.setRegulatoryInfo(regulatoryInfo);
await initNewPage();
await checkRegulatoryInfo(true);
});
aboutBrowserProxy.setReleaseNotes(false);
aboutBrowserProxy.setInternetConnection(false);
await initNewPage();
await checkReleaseNotesDisabled();
aboutBrowserProxy.setReleaseNotes(false);
aboutBrowserProxy.setInternetConnection(true);
await initNewPage();
await checkReleaseNotesDisabled();
aboutBrowserProxy.setReleaseNotes(true);
aboutBrowserProxy.setInternetConnection(false);
await initNewPage();
await checkReleaseNotesOnline(false);
await checkReleaseNotesOffline(true);
aboutBrowserProxy.setReleaseNotes(true);
aboutBrowserProxy.setInternetConnection(true);
await initNewPage();
await checkReleaseNotesOnline(true);
await checkReleaseNotesOffline(false);
page.$$('#releaseNotesOnline').click();
return aboutBrowserProxy.whenCalled('launchReleaseNotes');
});
test('TPMFirmwareUpdate', async () => {
assertTrue(page.$.aboutTPMFirmwareUpdate.hidden);
aboutBrowserProxy.setTPMFirmwareUpdateStatus({updateAvailable: true});
aboutBrowserProxy.refreshTPMFirmwareUpdateStatus();
assertFalse(page.$.aboutTPMFirmwareUpdate.hidden);
page.$.aboutTPMFirmwareUpdate.click();
await test_util.flushTasks();
const dialog = page.$$('os-settings-powerwash-dialog');
assertTrue(!!dialog);
assertTrue(dialog.$.dialog.open);
dialog.$$('#powerwash').click();
const requestTpmFirmwareUpdate =
await lifetimeBrowserProxy.whenCalled('factoryReset');
assertTrue(requestTpmFirmwareUpdate);
});
test('RegulatoryInfo', async () => {
const regulatoryInfo = {text: 'foo', url: 'bar'};
/**
* Checks the visibility of the "regulatory info" section.
* @param {boolean} isShowing Whether the section is expected to be
* visible.
* @return {!Promise}
*/
async function checkRegulatoryInfo(isShowing) {
await aboutBrowserProxy.whenCalled('getRegulatoryInfo');
const regulatoryInfoEl = page.$.regulatoryInfo;
assertTrue(!!regulatoryInfoEl);
assertEquals(isShowing, !regulatoryInfoEl.hidden);
if (isShowing) {
const img = regulatoryInfoEl.querySelector('img');
assertTrue(!!img);
assertEquals(regulatoryInfo.text, img.getAttribute('alt'));
assertEquals(regulatoryInfo.url, img.getAttribute('src'));
}
}
test('DeviceEndOfLife', async () => {
/**
* Checks the visibility of the end of life message and icon.
* @param {boolean} isShowing Whether the end of life UI is expected
* to be visible.
* @return {!Promise}
*/
async function checkHasEndOfLife(isShowing) {
await aboutBrowserProxy.whenCalled('getEndOfLifeInfo');
const {endOfLifeMessageContainer} = page.$;
assertTrue(!!endOfLifeMessageContainer);
await checkRegulatoryInfo(false);
aboutBrowserProxy.setRegulatoryInfo(regulatoryInfo);
await initNewPage();
await checkRegulatoryInfo(true);
});
assertEquals(isShowing, !endOfLifeMessageContainer.hidden);
test('TPMFirmwareUpdate', async () => {
assertTrue(page.$.aboutTPMFirmwareUpdate.hidden);
aboutBrowserProxy.setTPMFirmwareUpdateStatus({updateAvailable: true});
aboutBrowserProxy.refreshTPMFirmwareUpdateStatus();
assertFalse(page.$.aboutTPMFirmwareUpdate.hidden);
page.$.aboutTPMFirmwareUpdate.click();
await test_util.flushTasks();
const dialog = page.$$('os-settings-powerwash-dialog');
assertTrue(!!dialog);
assertTrue(dialog.$.dialog.open);
dialog.$$('#powerwash').click();
const requestTpmFirmwareUpdate =
await lifetimeBrowserProxy.whenCalled('factoryReset');
assertTrue(requestTpmFirmwareUpdate);
});
// Update status message should be hidden before user has
// checked for updates.
assertTrue(page.$.updateStatusMessage.hidden);
test('DeviceEndOfLife', async () => {
/**
* Checks the visibility of the end of life message and icon.
* @param {boolean} isShowing Whether the end of life UI is expected
* to be visible.
* @return {!Promise}
*/
async function checkHasEndOfLife(isShowing) {
await aboutBrowserProxy.whenCalled('getEndOfLifeInfo');
const {endOfLifeMessageContainer} = page.$;
assertTrue(!!endOfLifeMessageContainer);
assertEquals(isShowing, !endOfLifeMessageContainer.hidden);
// Update status message should be hidden before user has
// checked for updates.
assertTrue(page.$.updateStatusMessage.hidden);
fireStatusChanged(UpdateStatus.CHECKING);
assertEquals(isShowing, page.$.updateStatusMessage.hidden);
if (isShowing) {
const icon = page.$$('iron-icon');
assertTrue(!!icon);
assertEquals(null, icon.src);
assertEquals('os-settings:end-of-life', icon.icon);
const {checkForUpdates} = page.$;
assertTrue(!!checkForUpdates);
assertTrue(checkForUpdates.hidden);
}
}
fireStatusChanged(UpdateStatus.CHECKING);
assertEquals(isShowing, page.$.updateStatusMessage.hidden);
// Force test proxy to not respond to JS requests.
// End of life message should still be hidden in this case.
aboutBrowserProxy.setEndOfLifeInfo(new Promise(function(res, rej) {}));
await initNewPage();
await checkHasEndOfLife(false);
aboutBrowserProxy.setEndOfLifeInfo({
hasEndOfLife: true,
endOfLifeAboutMessage: '',
});
await initNewPage();
await checkHasEndOfLife(true);
aboutBrowserProxy.setEndOfLifeInfo({
hasEndOfLife: false,
endOfLifeAboutMessage: '',
});
await initNewPage();
await checkHasEndOfLife(false);
});
if (isShowing) {
const icon = page.$$('iron-icon');
assertTrue(!!icon);
assertEquals(null, icon.src);
assertEquals('os-settings:end-of-life', icon.icon);
test('detailed build info page', async () => {
async function checkEndOfLifeSection() {
await aboutBrowserProxy.whenCalled('getEndOfLifeInfo');
const buildInfoPage = page.$$('settings-detailed-build-info');
assertTrue(!!buildInfoPage.$['endOfLifeSectionContainer']);
assertFalse(buildInfoPage.$['endOfLifeSectionContainer'].hidden);
const {checkForUpdates} = page.$;
assertTrue(!!checkForUpdates);
assertTrue(checkForUpdates.hidden);
}
}
// Force test proxy to not respond to JS requests.
// End of life message should still be hidden in this case.
aboutBrowserProxy.setEndOfLifeInfo(new Promise(function(res, rej) {}));
await initNewPage();
await checkHasEndOfLife(false);
aboutBrowserProxy.setEndOfLifeInfo({
hasEndOfLife: true,
endOfLifeAboutMessage: '',
});
await initNewPage();
await checkHasEndOfLife(true);
aboutBrowserProxy.setEndOfLifeInfo({
hasEndOfLife: false,
endOfLifeAboutMessage: '',
});
await initNewPage();
await checkHasEndOfLife(false);
});
aboutBrowserProxy.setEndOfLifeInfo({
hasEndOfLife: true,
aboutPageEndOfLifeMessage: '',
});
await initNewPage();
page.scroller = page.offsetParent;
assertTrue(!!page.$['detailed-build-info-trigger']);
page.$['detailed-build-info-trigger'].click();
test('detailed build info page', async () => {
async function checkEndOfLifeSection() {
await aboutBrowserProxy.whenCalled('getEndOfLifeInfo');
const buildInfoPage = page.$$('settings-detailed-build-info');
assertTrue(!!buildInfoPage);
assertTrue(!!buildInfoPage.$['endOfLifeSectionContainer']);
assertTrue(buildInfoPage.$['endOfLifeSectionContainer'].hidden);
aboutBrowserProxy.setEndOfLifeInfo({
hasEndOfLife: true,
aboutPageEndOfLifeMessage: 'message',
});
await initNewPage();
page.scroller = page.offsetParent;
assertTrue(!!page.$['detailed-build-info-trigger']);
page.$['detailed-build-info-trigger'].click();
checkEndOfLifeSection();
});
assertFalse(buildInfoPage.$['endOfLifeSectionContainer'].hidden);
}
test('GetHelp', function() {
assertTrue(!!page.$.help);
page.$.help.click();
return aboutBrowserProxy.whenCalled('openOsHelpPage');
});
aboutBrowserProxy.setEndOfLifeInfo({
hasEndOfLife: true,
aboutPageEndOfLifeMessage: '',
});
await initNewPage();
page.scroller = page.offsetParent;
assertTrue(!!page.$['detailed-build-info-trigger']);
page.$['detailed-build-info-trigger'].click();
const buildInfoPage = page.$$('settings-detailed-build-info');
assertTrue(!!buildInfoPage);
assertTrue(!!buildInfoPage.$['endOfLifeSectionContainer']);
assertTrue(buildInfoPage.$['endOfLifeSectionContainer'].hidden);
aboutBrowserProxy.setEndOfLifeInfo({
hasEndOfLife: true,
aboutPageEndOfLifeMessage: 'message',
});
await initNewPage();
page.scroller = page.offsetParent;
assertTrue(!!page.$['detailed-build-info-trigger']);
page.$['detailed-build-info-trigger'].click();
checkEndOfLifeSection();
});
}
function registerOfficialBuildTests() {
suite('AboutPageTest_OfficialBuild', function() {
test('ReportAnIssue', function() {
const browserProxy = new TestAboutPageBrowserProxyChromeOS();
settings.AboutPageBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody();
const page = document.createElement('os-settings-about-page');
document.body.appendChild(page);
assertTrue(!!page.$.reportIssue);
page.$.reportIssue.click();
return browserProxy.whenCalled('openFeedbackDialog');
});
test('GetHelp', function() {
assertTrue(!!page.$.help);
page.$.help.click();
return aboutBrowserProxy.whenCalled('openOsHelpPage');
});
}
});
function registerDetailedBuildInfoTests() {
suite('DetailedBuildInfoTest', function() {
let page = null;
let browserProxy = null;
suite('DetailedBuildInfoTest', function() {
let page = null;
let browserProxy = null;
setup(function() {
browserProxy = new TestAboutPageBrowserProxyChromeOS();
settings.AboutPageBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody();
});
setup(function() {
browserProxy = new TestAboutPageBrowserProxyChromeOS();
settings.AboutPageBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody();
});
teardown(function() {
page.remove();
page = null;
});
teardown(function() {
page.remove();
page = null;
});
test('Initialization', async () => {
page = document.createElement('settings-detailed-build-info');
document.body.appendChild(page);
test('Initialization', async () => {
page = document.createElement('settings-detailed-build-info');
document.body.appendChild(page);
await Promise.all([
browserProxy.whenCalled('pageReady'),
browserProxy.whenCalled('canChangeChannel'),
browserProxy.whenCalled('getChannelInfo'),
browserProxy.whenCalled('getVersionInfo'),
]);
});
await Promise.all([
browserProxy.whenCalled('pageReady'),
browserProxy.whenCalled('canChangeChannel'),
browserProxy.whenCalled('getChannelInfo'),
browserProxy.whenCalled('getVersionInfo'),
]);
});
/**
* Checks whether the "change channel" button state (enabled/disabled)
* correctly reflects whether the user is allowed to change channel (as
* dictated by the browser via loadTimeData boolean).
* @param {boolean} canChangeChannel Whether to simulate the case where
* changing channels is allowed.
* @return {!Promise}
*/
async function checkChangeChannelButton(canChangeChannel) {
browserProxy.setCanChangeChannel(canChangeChannel);
page = document.createElement('settings-detailed-build-info');
document.body.appendChild(page);
await browserProxy.whenCalled('canChangeChannel');
const changeChannelButton = page.$$('cr-button');
assertTrue(!!changeChannelButton);
assertEquals(canChangeChannel, !changeChannelButton.disabled);
}
/**
* Checks whether the "change channel" button state (enabled/disabled)
* correctly reflects whether the user is allowed to change channel (as
* dictated by the browser via loadTimeData boolean).
* @param {boolean} canChangeChannel Whether to simulate the case where
* changing channels is allowed.
* @return {!Promise}
*/
async function checkChangeChannelButton(canChangeChannel) {
browserProxy.setCanChangeChannel(canChangeChannel);
page = document.createElement('settings-detailed-build-info');
document.body.appendChild(page);
await browserProxy.whenCalled('canChangeChannel');
const changeChannelButton = page.$$('cr-button');
assertTrue(!!changeChannelButton);
assertEquals(canChangeChannel, !changeChannelButton.disabled);
}
test('ChangeChannel_Enabled', function() {
return checkChangeChannelButton(true);
});
test('ChangeChannel_Enabled', function() {
return checkChangeChannelButton(true);
});
test('ChangeChannel_Disabled', function() {
return checkChangeChannelButton(false);
});
test('ChangeChannel_Disabled', function() {
return checkChangeChannelButton(false);
});
/**
* Checks whether the "change channel" button state (enabled/disabled)
* is correct before getChannelInfo() returns
* (see https://crbug.com/848750). Here, getChannelInfo() is blocked
* manually until after the button check.
*/
async function checkChangeChannelButtonWithDelayedChannelState(
canChangeChannel) {
const resolver = new PromiseResolver();
browserProxy.getChannelInfo = async function() {
await resolver.promise;
this.methodCalled('getChannelInfo');
return Promise.resolve(this.channelInfo_);
};
const result = await checkChangeChannelButton(canChangeChannel);
resolver.resolve();
return result;
}
/**
* Checks whether the "change channel" button state (enabled/disabled)
* is correct before getChannelInfo() returns
* (see https://crbug.com/848750). Here, getChannelInfo() is blocked
* manually until after the button check.
*/
async function checkChangeChannelButtonWithDelayedChannelState(
canChangeChannel) {
const resolver = new PromiseResolver();
browserProxy.getChannelInfo = async function() {
await resolver.promise;
this.methodCalled('getChannelInfo');
return Promise.resolve(this.channelInfo_);
};
const result = await checkChangeChannelButton(canChangeChannel);
resolver.resolve();
return result;
}
test('ChangeChannel_EnabledWithDelayedChannelState', function() {
return checkChangeChannelButtonWithDelayedChannelState(true);
});
test('ChangeChannel_EnabledWithDelayedChannelState', function() {
return checkChangeChannelButtonWithDelayedChannelState(true);
});
test('ChangeChannel_DisabledWithDelayedChannelState', function() {
return checkChangeChannelButtonWithDelayedChannelState(false);
});
test('ChangeChannel_DisabledWithDelayedChannelState', function() {
return checkChangeChannelButtonWithDelayedChannelState(false);
});
async function checkCopyBuildDetailsButton() {
page = document.createElement('settings-detailed-build-info');
document.body.appendChild(page);
const copyBuildDetailsButton = page.$$('cr-icon-button');
await browserProxy.whenCalled('getVersionInfo');
await browserProxy.whenCalled('getChannelInfo');
await browserProxy.whenCalled('canChangeChannel');
const expectedClipBoardText =
`${loadTimeData.getString('application_label')}: ` +
`${loadTimeData.getString('aboutBrowserVersion')}\n` +
`Platform: ${browserProxy.versionInfo_.osVersion}\n` +
`Channel: ${browserProxy.channelInfo_.targetChannel}\n` +
`Firmware Version: ${browserProxy.versionInfo_.osFirmware}\n` +
`ARC Enabled: ${loadTimeData.getBoolean('aboutIsArcEnabled')}\n` +
`ARC: ${browserProxy.versionInfo_.arcVersion}\n` +
`Enterprise Enrolled: ` +
`${loadTimeData.getBoolean('aboutEnterpriseManaged')}\n` +
`Developer Mode: ` +
`${loadTimeData.getBoolean('aboutIsDeveloperMode')}`;
assertTrue(!!copyBuildDetailsButton);
await navigator.clipboard.readText().then(text => assertFalse(!!text));
copyBuildDetailsButton.click();
await navigator.clipboard.readText().then(
text => assertEquals(text, expectedClipBoardText));
}
async function checkCopyBuildDetailsButton() {
page = document.createElement('settings-detailed-build-info');
document.body.appendChild(page);
const copyBuildDetailsButton = page.$$('cr-icon-button');
await browserProxy.whenCalled('getVersionInfo');
await browserProxy.whenCalled('getChannelInfo');
await browserProxy.whenCalled('canChangeChannel');
const expectedClipBoardText =
`${loadTimeData.getString('application_label')}: ` +
`${loadTimeData.getString('aboutBrowserVersion')}\n` +
`Platform: ${browserProxy.versionInfo_.osVersion}\n` +
`Channel: ${browserProxy.channelInfo_.targetChannel}\n` +
`Firmware Version: ${browserProxy.versionInfo_.osFirmware}\n` +
`ARC Enabled: ${loadTimeData.getBoolean('aboutIsArcEnabled')}\n` +
`ARC: ${browserProxy.versionInfo_.arcVersion}\n` +
`Enterprise Enrolled: ` +
`${loadTimeData.getBoolean('aboutEnterpriseManaged')}\n` +
`Developer Mode: ` +
`${loadTimeData.getBoolean('aboutIsDeveloperMode')}`;
assertTrue(!!copyBuildDetailsButton);
await navigator.clipboard.readText().then(text => assertFalse(!!text));
copyBuildDetailsButton.click();
await navigator.clipboard.readText().then(
text => assertEquals(text, expectedClipBoardText));
}
test('CheckCopyBuildDetails', function() {
checkCopyBuildDetailsButton();
});
test('CheckCopyBuildDetails', function() {
checkCopyBuildDetailsButton();
});
});
suite('ChannelSwitcherDialogTest', function() {
let dialog = null;
let radioButtons = null;
let browserProxy = null;
let currentChannel;
setup(function() {
currentChannel = BrowserChannel.BETA;
browserProxy = new TestAboutPageBrowserProxyChromeOS();
browserProxy.setChannels(currentChannel, currentChannel);
settings.AboutPageBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody();
dialog = document.createElement('settings-channel-switcher-dialog');
document.body.appendChild(dialog);
radioButtons = dialog.shadowRoot.querySelectorAll('cr-radio-button');
assertEquals(3, radioButtons.length);
return browserProxy.whenCalled('getChannelInfo');
});
}
function registerChannelSwitcherDialogTests() {
suite('ChannelSwitcherDialogTest', function() {
let dialog = null;
let radioButtons = null;
let browserProxy = null;
const currentChannel = BrowserChannel.BETA;
setup(function() {
browserProxy = new TestAboutPageBrowserProxyChromeOS();
browserProxy.setChannels(currentChannel, currentChannel);
settings.AboutPageBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody();
dialog = document.createElement('settings-channel-switcher-dialog');
document.body.appendChild(dialog);
radioButtons = dialog.shadowRoot.querySelectorAll('cr-radio-button');
assertEquals(3, radioButtons.length);
return browserProxy.whenCalled('getChannelInfo');
});
teardown(function() {
dialog.remove();
});
teardown(function() {
dialog.remove();
});
test('Initialization', function() {
const radioGroup = dialog.$$('cr-radio-group');
assertTrue(!!radioGroup);
assertTrue(!!dialog.$.warningSelector);
assertTrue(!!dialog.$.changeChannel);
assertTrue(!!dialog.$.changeChannelAndPowerwash);
// Check that upon initialization the radio button corresponding to
// the current release channel is pre-selected.
assertEquals(currentChannel, radioGroup.selected);
assertEquals(dialog.$.warningSelector.selected, -1);
// Check that action buttons are hidden when current and target
// channel are the same.
assertTrue(dialog.$.changeChannel.hidden);
assertTrue(dialog.$.changeChannelAndPowerwash.hidden);
});
test('Initialization', function() {
const radioGroup = dialog.$$('cr-radio-group');
assertTrue(!!radioGroup);
assertTrue(!!dialog.$.warningSelector);
assertTrue(!!dialog.$.changeChannel);
assertTrue(!!dialog.$.changeChannelAndPowerwash);
// Check that upon initialization the radio button corresponding to
// the current release channel is pre-selected.
assertEquals(currentChannel, radioGroup.selected);
assertEquals(dialog.$.warningSelector.selected, -1);
// Check that action buttons are hidden when current and target
// channel are the same.
assertTrue(dialog.$.changeChannel.hidden);
assertTrue(dialog.$.changeChannelAndPowerwash.hidden);
});
// Test case where user switches to a less stable channel.
test('ChangeChannel_LessStable', async () => {
assertEquals(BrowserChannel.DEV, radioButtons.item(2).name);
radioButtons.item(2).click();
Polymer.dom.flush();
await browserProxy.whenCalled('getChannelInfo');
assertEquals(dialog.$.warningSelector.selected, 2);
// Check that only the "Change channel" button becomes visible.
assertTrue(dialog.$.changeChannelAndPowerwash.hidden);
assertFalse(dialog.$.changeChannel.hidden);
const whenTargetChannelChangedFired =
test_util.eventToPromise('target-channel-changed', dialog);
dialog.$.changeChannel.click();
const [channel, isPowerwashAllowed] =
await browserProxy.whenCalled('setChannel');
assertEquals(BrowserChannel.DEV, channel);
assertFalse(isPowerwashAllowed);
const {detail} = await whenTargetChannelChangedFired;
assertEquals(BrowserChannel.DEV, detail);
});
// Test case where user switches to a less stable channel.
test('ChangeChannel_LessStable', async () => {
assertEquals(BrowserChannel.DEV, radioButtons.item(2).name);
radioButtons.item(2).click();
Polymer.dom.flush();
await browserProxy.whenCalled('getChannelInfo');
assertEquals(dialog.$.warningSelector.selected, 2);
// Check that only the "Change channel" button becomes visible.
assertTrue(dialog.$.changeChannelAndPowerwash.hidden);
assertFalse(dialog.$.changeChannel.hidden);
const whenTargetChannelChangedFired =
test_util.eventToPromise('target-channel-changed', dialog);
dialog.$.changeChannel.click();
const [channel, isPowerwashAllowed] =
await browserProxy.whenCalled('setChannel');
assertEquals(BrowserChannel.DEV, channel);
assertFalse(isPowerwashAllowed);
const {detail} = await whenTargetChannelChangedFired;
assertEquals(BrowserChannel.DEV, detail);
});
// Test case where user switches to a more stable channel.
test('ChangeChannel_MoreStable', async () => {
assertEquals(BrowserChannel.STABLE, radioButtons.item(0).name);
radioButtons.item(0).click();
Polymer.dom.flush();
await browserProxy.whenCalled('getChannelInfo');
assertEquals(dialog.$.warningSelector.selected, 1);
// Check that only the "Change channel and Powerwash" button becomes
// visible.
assertFalse(dialog.$.changeChannelAndPowerwash.hidden);
assertTrue(dialog.$.changeChannel.hidden);
const whenTargetChannelChangedFired =
test_util.eventToPromise('target-channel-changed', dialog);
dialog.$.changeChannelAndPowerwash.click();
const [channel, isPowerwashAllowed] =
await browserProxy.whenCalled('setChannel');
assertEquals(BrowserChannel.STABLE, channel);
assertTrue(isPowerwashAllowed);
const {detail} = await whenTargetChannelChangedFired;
assertEquals(BrowserChannel.STABLE, detail);
});
// Test case where user switches to a more stable channel.
test('ChangeChannel_MoreStable', async () => {
assertEquals(BrowserChannel.STABLE, radioButtons.item(0).name);
radioButtons.item(0).click();
Polymer.dom.flush();
await browserProxy.whenCalled('getChannelInfo');
assertEquals(dialog.$.warningSelector.selected, 1);
// Check that only the "Change channel and Powerwash" button becomes
// visible.
assertFalse(dialog.$.changeChannelAndPowerwash.hidden);
assertTrue(dialog.$.changeChannel.hidden);
const whenTargetChannelChangedFired =
test_util.eventToPromise('target-channel-changed', dialog);
dialog.$.changeChannelAndPowerwash.click();
const [channel, isPowerwashAllowed] =
await browserProxy.whenCalled('setChannel');
assertEquals(BrowserChannel.STABLE, channel);
assertTrue(isPowerwashAllowed);
const {detail} = await whenTargetChannelChangedFired;
assertEquals(BrowserChannel.STABLE, detail);
});
}
return {
registerTests: function() {
registerDetailedBuildInfoTests();
registerChannelSwitcherDialogTests();
registerAboutPageTests();
},
registerOfficialBuildTests: registerOfficialBuildTests,
};
});
suite('AboutPageTest_OfficialBuild', function() {
test('ReportAnIssue', function() {
const browserProxy = new TestAboutPageBrowserProxyChromeOS();
settings.AboutPageBrowserProxyImpl.instance_ = browserProxy;
PolymerTest.clearBody();
const page = document.createElement('os-settings-about-page');
document.body.appendChild(page);
assertTrue(!!page.$.reportIssue);
page.$.reportIssue.click();
return browserProxy.whenCalled('openFeedbackDialog');
});
});
// #cr_define_end
return {};
});
......@@ -82,15 +82,13 @@ var OSSettingsAboutPageTest = class extends OSSettingsBrowserTest {
}
};
TEST_F('OSSettingsAboutPageTest', 'AboutPage', () => {
settings_about_page.registerTests();
mocha.run();
TEST_F('OSSettingsAboutPageTest', 'AllBuilds', () => {
mocha.grep('/^(?!AboutPageTest_OfficialBuild).*$/').run();
});
GEN('#if BUILDFLAG(GOOGLE_CHROME_BRANDING)');
TEST_F('OSSettingsAboutPageTest', 'AboutPage_OfficialBuild', () => {
settings_about_page.registerOfficialBuildTests();
mocha.run();
mocha.grep('AboutPageTest_OfficialBuild').run();
});
GEN('#endif');
......
......@@ -6,6 +6,7 @@
// Polymer BrowserTest fixture.
GEN_INCLUDE(['//chrome/test/data/webui/polymer_browser_test_base.js']);
GEN('#include "chrome/common/buildflags.h"');
GEN('#include "build/branding_buildflags.h"');
GEN('#include "content/public/test/browser_test.h"');
GEN('#include "chromeos/constants/chromeos_features.h"');
......@@ -65,6 +66,7 @@ var OSSettingsV3BrowserTest = class extends PolymerTest {
['CupsPrinterPage', 'cups_printer_page_tests.m.js'],
['CupsPrinterLandingPage', 'cups_printer_landing_page_tests.m.js'],
['CupsPrinterEntry', 'cups_printer_entry_tests.m.js'],
['AboutPage', 'os_about_page_tests.m.js'],
].forEach(test => registerTest(...test));
function registerTest(testName, module, caseName) {
......@@ -76,5 +78,19 @@ function registerTest(testName, module, caseName) {
}
};
TEST_F(className, caseName || 'All', () => mocha.run());
// AboutPage has a test suite that can only succeed on official builds where
// the is_chrome_branded build flag is enabled
if (testName === 'AboutPage') {
TEST_F(className, 'AllBuilds' || 'All', () => {
mocha.grep('/^(?!AboutPageTest_OfficialBuild).*$/').run();
});
GEN('#if BUILDFLAG(GOOGLE_CHROME_BRANDING)');
TEST_F(className, 'OfficialBuild' || 'All', () => {
mocha.grep('AboutPageTest_OfficialBuild').run();
});
GEN('#endif');
} else {
TEST_F(className, caseName || 'All', () => mocha.run());
}
}
......@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// #import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js';
// #import {BrowserChannel, UpdateStatus} from 'chrome://settings/settings.js';
// clang-format off
// #import {TestBrowserProxy} from '../../test_browser_proxy.m.js';
// #import {BrowserChannel,UpdateStatus} from 'chrome://os-settings/chromeos/os_settings.js';
// clang-format on
/** @implements {settings.AboutPageBrowserProxy} */
/* #export */ class TestAboutPageBrowserProxyChromeOS extends TestBrowserProxy {
......
......@@ -12,4 +12,5 @@ cr_elements_chromeos_namespace_rewrites = [
cr_elements_chromeos_auto_imports = [
"ui/webui/resources/cr_elements/chromeos/cr_picture/cr_picture_types.html|CrPicture",
"ui/webui/resources/cr_elements/chromeos/cr_picture/png.html|convertImageSequenceToPng,isEncodedPngDataUrlAnimated",
"ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.html|CrPolicyIndicatorType",
]
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