Commit 7e26ce46 authored by Trent Begin's avatar Trent Begin Committed by Chromium LUCI CQ

connectivity-diagnostics: group routines into categories

This change groups the network diagnostic routines into similar
categories to simplify the UI. This brings the app in closer alignment
to the original Chrome App.

https://screenshot.googleplex.com/9TA8y5z4gDKC3hB

Bug: chromium:1142857
Change-Id: I6336106a0d6b945012d6e6c93b98f1f0a46fca8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2561294
Commit-Queue: Trent Begin <tbegin@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833842}
parent d1bf9b7d
......@@ -108,6 +108,20 @@ constexpr WebUiResource kResources[] = {
IDR_CR_COMPONENTS_CHROMEOS_NETWORK_DIAGNOSTICS_WARNING_ICON},
};
struct StringMap {
const char* name;
const char* value;
};
// TODO(crbug/1142857): Localize these strings after UX approval.
constexpr StringMap kPlaceholderStrings[] = {
{"NetworkDiagnosticsConnectionGroup", "Connection"},
{"NetworkDiagnosticsWifiGroup", "WiFi"},
{"NetworkDiagnosticsGatewayGroup", "Gateway"},
{"NetworkDiagnosticsFirewallGroup", "Firewall"},
{"NetworkDiagnosticsDnsGroup", "DNS"},
};
} // namespace
void AddResources(content::WebUIDataSource* html_source) {
......@@ -116,6 +130,9 @@ void AddResources(content::WebUIDataSource* html_source) {
for (const auto& resource : kResources)
html_source->AddResourcePath(resource.name, resource.id);
for (const auto& str : kPlaceholderStrings)
html_source->AddString(str.name, str.value);
}
} // namespace network_diagnostics
......
......@@ -23,6 +23,7 @@
}
.content {
height: 100%;
overflow: scroll;
}
</style>
......
......@@ -115,6 +115,8 @@ preprocess_if_expr("preprocess_generated") {
"chromeos/cellular_setup/webview_post_util.m.js",
"chromeos/network_health/network_diagnostics.m.js",
"chromeos/network_health/network_diagnostics_mojo.m.js",
"chromeos/network_health/network_diagnostics_types.m.js",
"chromeos/network_health/routine_group.m.js",
"chromeos/network/cr_policy_network_behavior_mojo.m.js",
"chromeos/network/cr_policy_network_indicator_mojo.m.js",
"chromeos/network/mojo_interface_provider.m.js",
......@@ -268,8 +270,12 @@ preprocess_if_expr("preprocess_polymer2") {
"chromeos/network_health/network_diagnostics.js",
"chromeos/network_health/network_diagnostics_mojo.html",
"chromeos/network_health/network_diagnostics_mojo.js",
"chromeos/network_health/network_diagnostics_types.html",
"chromeos/network_health/network_diagnostics_types.js",
"chromeos/network_health/network_health_summary.html",
"chromeos/network_health/network_health_summary.js",
"chromeos/network_health/routine_group.html",
"chromeos/network_health/routine_group.js",
"chromeos/network/mojo_interface_provider.html",
"chromeos/network/mojo_interface_provider.js",
"chromeos/network/network_icon.html",
......
......@@ -13,7 +13,10 @@ assert(is_chromeos, "Only ChromeOS components belong here.")
js_type_check("closure_compile") {
deps = [
":network_diagnostics",
":network_diagnostics_mojo",
":network_diagnostics_types",
":network_health_summary",
":routine_group",
]
}
......@@ -22,7 +25,9 @@ js_type_check("closure_compile_module") {
deps = [
":network_diagnostics.m",
":network_diagnostics_mojo.m",
":network_diagnostics_types.m",
":network_health_summary.m",
":routine_group.m",
]
}
......@@ -38,6 +43,9 @@ js_library("network_health_summary") {
js_library("network_diagnostics") {
deps = [
":network_diagnostics_mojo",
":network_diagnostics_types",
":routine_group",
"//chromeos/services/network_health/public/mojom:mojom_js_library_for_compile",
"//ui/webui/resources/js:i18n_behavior",
]
......@@ -50,6 +58,17 @@ js_library("network_diagnostics_mojo") {
]
}
js_library("network_diagnostics_types") {
deps = [ ":network_diagnostics_mojo" ]
}
js_library("routine_group") {
deps = [
":network_diagnostics_types",
"//ui/webui/resources/js:i18n_behavior",
]
}
js_library("network_health_summary.m") {
sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network_health/network_health_summary.m.js" ]
deps = [
......@@ -65,6 +84,8 @@ js_library("network_diagnostics.m") {
sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network_health/network_diagnostics.m.js" ]
deps = [
":network_diagnostics_mojo.m",
":network_diagnostics_types.m",
":routine_group.m",
"//chromeos/services/network_health/public/mojom:mojom_js_library_for_compile",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:i18n_behavior.m",
......@@ -74,10 +95,27 @@ js_library("network_diagnostics.m") {
js_library("network_diagnostics_mojo.m") {
sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network_health/network_diagnostics_mojo.m.js" ]
deps = [ "//chrome/browser/ui/webui/settings/chromeos/search:mojo_bindings_js_library_for_compile" ]
deps = [ "//chromeos/services/network_health/public/mojom:mojom_js_library_for_compile" ]
extra_deps = [ ":modulize" ]
}
js_library("network_diagnostics_types.m") {
sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network_health/network_diagnostics_types.m.js" ]
deps = [ ":network_diagnostics_mojo.m" ]
extra_deps = [ ":modulize" ]
}
js_library("routine_group.m") {
sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network_health/routine_group.m.js" ]
deps = [
":network_diagnostics_mojo.m",
":network_diagnostics_types.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:i18n_behavior.m",
]
extra_deps = [ ":routine_group_module" ]
}
# polymer_modulizer for converting Polymer2 to Polymer3
polymer_modulizer("network_health_summary") {
......@@ -90,10 +128,21 @@ polymer_modulizer("network_diagnostics") {
js_file = "network_diagnostics.js"
html_file = "network_diagnostics.html"
html_type = "dom-module"
auto_imports = [ "ui/webui/resources/cr_components/chromeos/network_health/network_diagnostics_types.html|Routine,RoutineResponse,RoutineGroup,RoutineType" ]
}
polymer_modulizer("routine_group") {
js_file = "routine_group.js"
html_file = "routine_group.html"
html_type = "dom-module"
auto_imports = [ "ui/webui/resources/cr_components/chromeos/network_health/network_diagnostics_types.html|Icons,Routine,RoutineResponse" ]
}
js_modulizer("modulize") {
input_files = [ "network_diagnostics_mojo.js" ]
input_files = [
"network_diagnostics_mojo.js",
"network_diagnostics_types.js",
]
}
group("polymer3_elements") {
......@@ -101,5 +150,6 @@ group("polymer3_elements") {
":modulize",
":network_diagnostics_module",
":network_health_summary_module",
":routine_group_module",
]
}
<link rel="import" href="../../../html/polymer.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/network_health/network_diagnostics_mojo.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html">
<link rel="import" href="../../../cr_elements/cr_button/cr_button.html">
<link rel="import" href="../../../html/i18n_behavior.html">
<link rel="import" href="network_diagnostics_mojo.html">
<link rel="import" href="network_diagnostics_types.html">
<link rel="import" href="routine_group.html">
<dom-module id="network-diagnostics">
<template>
<style>
.routine-container {
align-items: center;
border: 2px solid rgb(175, 175, 175);
display: flex;
height: 30px;
margin: 10px;
padding: 5px;
}
.routine-icon {
height: 25px;
padding-inline-end: 10px;
width: auto;
}
.routine-name {
flex: 1;
font-size: 1rem;
}
</style>
<template is="dom-repeat" items="[[routines_]]" as="routine">
<div class="routine-container" aria-label="[[i18n(routine.name)]]"
aria-description="[[routine.ariaDescription]]">
<img class="routine-icon" src="[[getRoutineIcon_(routine.result)]]">
<div aria-hidden="true" class="routine-name">
[[i18n(routine.name)]]
</div>
<div aria-hidden="true" hidden="[[!routine.resultMsg]]">
[[routine.resultMsg]]
</div>
<template is="dom-if" if="[[routine.running]]">
<paper-spinner-lite active></paper-spinner-lite>
</template>
</div>
</template>
<routine-group name="[[i18n('NetworkDiagnosticsConnectionGroup')]]"
routines="[[getRoutineGroup_(routines_.*, RoutineGroup_.CONNECTION)]]">
</routine-group>
<routine-group name="[[i18n('NetworkDiagnosticsWifiGroup')]]"
routines="[[getRoutineGroup_(routines_.*, RoutineGroup_.WIFI)]]">
</routine-group>
<routine-group name="[[i18n('NetworkDiagnosticsGatewayGroup')]]"
routines="[[getRoutineGroup_(routines_.*, RoutineGroup_.GATEWAY)]]">
</routine-group>
<routine-group name="[[i18n('NetworkDiagnosticsFirewallGroup')]]"
routines="[[getRoutineGroup_(routines_.*, RoutineGroup_.FIREWALL)]]">
</routine-group>
<routine-group name="[[i18n('NetworkDiagnosticsDnsGroup')]]"
routines="[[getRoutineGroup_(routines_.*, RoutineGroup_.DNS)]]">
</routine-group>
</template>
<script src="network_diagnostics.js"></script>
</dom-module>
// 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.
......@@ -10,58 +9,20 @@
// Namespace to make using the mojom objects more readable.
const diagnosticsMojom = chromeos.networkDiagnostics.mojom;
/**
* A routine response from the Network Diagnostics mojo service.
* @typedef {{
* verdict: chromeos.networkDiagnostics.mojom.RoutineVerdict,
* }}
* RoutineResponse can optionally have a `problems` field, which is an array of
* enums relevant to the routine run. Unfortunately the closure compiler cannot
* handle optional object fields.
*/
let RoutineResponse;
/**
* A network diagnostics routine. Holds descriptive information about the
* routine, and it's transient state.
* @typedef {{
* name: string,
* type: !RoutineType,
* running: boolean,
* resultMsg: string,
* result: ?RoutineResponse,
* }}
*/
let Routine;
/**
* Definition for all Network diagnostic routine types. This enum is intended
* to be used as an index in an array of routines.
* @enum {number}
*/
const RoutineType = {
LAN_CONNECTIVITY: 0,
SIGNAL_STRENGTH: 1,
GATEWAY_PING: 2,
SECURE_WIFI: 3,
DNS_RESOLVER: 4,
DNS_LATENCY: 5,
DNS_RESOLUTION: 6,
HTTP_FIREWALL: 7,
HTTPS_FIREWALL: 8,
HTTPS_LATENCY: 9,
};
/**
* Helper function to create a routine object.
* @param {string} name
* @param {!RoutineType} type
* @param {!RoutineGroup} group
* @param {!function()} func
* @return {!Routine} Routine object
*/
function createRoutine(name, type) {
function createRoutine(name, type, group, func) {
return {
name: name,
type: type,
group: group,
func: func,
running: false,
resultMsg: '',
result: null,
......@@ -84,30 +45,103 @@ Polymer({
routines_: {
type: Array,
value: function() {
const routineGroups = [
{
group: RoutineGroup.CONNECTION,
routines: [
{
name: 'NetworkDiagnosticsLanConnectivity',
type: RoutineType.LAN_CONNECTIVITY,
func: () => this.networkDiagnostics_.lanConnectivity(),
},
]
},
{
group: RoutineGroup.WIFI,
routines: [
{
name: 'NetworkDiagnosticsSignalStrength',
type: RoutineType.SIGNAL_STRENGTH,
func: () => this.networkDiagnostics_.signalStrength(),
},
{
name: 'NetworkDiagnosticsHasSecureWiFiConnection',
type: RoutineType.SECURE_WIFI,
func: () => this.networkDiagnostics_.hasSecureWiFiConnection(),
},
]
},
{
group: RoutineGroup.GATEWAY,
routines: [
{
name: 'NetworkDiagnosticsGatewayCanBePinged',
type: RoutineType.GATEWAY_PING,
func: () => this.networkDiagnostics_.gatewayCanBePinged(),
},
]
},
{
group: RoutineGroup.FIREWALL,
routines: [
{
name: 'NetworkDiagnosticsHttpFirewall',
type: RoutineType.HTTP_FIREWALL,
func: () => this.networkDiagnostics_.httpFirewall(),
},
{
name: 'NetworkDiagnosticsHttpsFirewall',
type: RoutineType.HTTPS_FIREWALL,
func: () => this.networkDiagnostics_.httpsFirewall(),
},
{
name: 'NetworkDiagnosticsHttpsLatency',
type: RoutineType.HTTPS_LATENCY,
func: () => this.networkDiagnostics_.httpsLatency(),
},
]
},
{
group: RoutineGroup.DNS,
routines: [
{
name: 'NetworkDiagnosticsDnsResolverPresent',
type: RoutineType.DNS_RESOLVER,
func: () => this.networkDiagnostics_.dnsResolverPresent(),
},
{
name: 'NetworkDiagnosticsDnsLatency',
type: RoutineType.DNS_LATENCY,
func: () => this.networkDiagnostics_.dnsLatency(),
},
{
name: 'NetworkDiagnosticsDnsResolution',
type: RoutineType.DNS_RESOLUTION,
func: () => this.networkDiagnostics_.dnsResolution(),
},
]
},
];
const routines = [];
routines[RoutineType.LAN_CONNECTIVITY] = createRoutine(
'NetworkDiagnosticsLanConnectivity', RoutineType.LAN_CONNECTIVITY);
routines[RoutineType.SIGNAL_STRENGTH] = createRoutine(
'NetworkDiagnosticsSignalStrength', RoutineType.SIGNAL_STRENGTH);
routines[RoutineType.GATEWAY_PING] = createRoutine(
'NetworkDiagnosticsGatewayCanBePinged', RoutineType.GATEWAY_PING);
routines[RoutineType.SECURE_WIFI] = createRoutine(
'NetworkDiagnosticsHasSecureWiFiConnection',
RoutineType.SECURE_WIFI);
routines[RoutineType.DNS_RESOLVER] = createRoutine(
'NetworkDiagnosticsDnsResolverPresent', RoutineType.DNS_RESOLVER);
routines[RoutineType.DNS_LATENCY] = createRoutine(
'NetworkDiagnosticsDnsLatency', RoutineType.DNS_LATENCY);
routines[RoutineType.DNS_RESOLUTION] = createRoutine(
'NetworkDiagnosticsDnsResolution', RoutineType.DNS_RESOLUTION);
routines[RoutineType.HTTP_FIREWALL] = createRoutine(
'NetworkDiagnosticsHttpFirewall', RoutineType.HTTP_FIREWALL);
routines[RoutineType.HTTPS_FIREWALL] = createRoutine(
'NetworkDiagnosticsHttpsFirewall', RoutineType.HTTPS_FIREWALL);
routines[RoutineType.HTTPS_LATENCY] = createRoutine(
'NetworkDiagnosticsHttpsLatency', RoutineType.HTTPS_LATENCY);
for (const group of routineGroups) {
for (const routine of group.routines) {
routines[routine.type] = createRoutine(
routine.name, routine.type, group.group, routine.func);
}
}
return routines;
}
},
/**
* Enum of Routine Groups
* @private {Object}
*/
RoutineGroup_: {
type: Object,
value: RoutineGroup,
}
},
......@@ -159,6 +193,17 @@ Polymer({
return JSON.stringify(results, undefined, 2);
},
/**
* Runs all supported network diagnostics routines.
* @param {!PolymerDeepPropertyChange} routines
* @param {Number} group
* @return {!Array<!Routine>}
* @private
*/
getRoutineGroup_(routines, group) {
return routines.base.filter(r => r.group === group);
},
/**
* @param {!Event} event
* @private
......@@ -179,48 +224,8 @@ Polymer({
`routines_.${type}.ariaDescription`,
this.i18n('NetworkDiagnosticsRunning'));
switch (type) {
case RoutineType.LAN_CONNECTIVITY:
this.networkDiagnostics_.lanConnectivity().then(
result => this.evaluateRoutine_(type, result));
break;
case RoutineType.SIGNAL_STRENGTH:
this.networkDiagnostics_.signalStrength().then(
result => this.evaluateRoutine_(type, result));
break;
case RoutineType.GATEWAY_PING:
this.networkDiagnostics_.gatewayCanBePinged().then(
result => this.evaluateRoutine_(type, result));
break;
case RoutineType.SECURE_WIFI:
this.networkDiagnostics_.hasSecureWiFiConnection().then(
result => this.evaluateRoutine_(type, result));
break;
case RoutineType.DNS_RESOLVER:
this.networkDiagnostics_.dnsResolverPresent().then(
result => this.evaluateRoutine_(type, result));
break;
case RoutineType.DNS_LATENCY:
this.networkDiagnostics_.dnsLatency().then(
result => this.evaluateRoutine_(type, result));
break;
case RoutineType.DNS_RESOLUTION:
this.networkDiagnostics_.dnsResolution().then(
result => this.evaluateRoutine_(type, result));
break;
case RoutineType.HTTP_FIREWALL:
this.networkDiagnostics_.httpFirewall().then(
result => this.evaluateRoutine_(type, result));
break;
case RoutineType.HTTPS_FIREWALL:
this.networkDiagnostics_.httpsFirewall().then(
result => this.evaluateRoutine_(type, result));
break;
case RoutineType.HTTPS_LATENCY:
this.networkDiagnostics_.httpsLatency().then(
result => this.evaluateRoutine_(type, result));
break;
}
this.routines_[type].func().then(
result => this.evaluateRoutine_(type, result));
},
/**
......@@ -238,29 +243,6 @@ Polymer({
this.set(routine + '.ariaDescription', resultMsg);
},
/**
* Helper function to get the icon for a routine based on the result.
* @param {RoutineResponse} result
* @return {string}
* @private
*/
getRoutineIcon_(result) {
if (!result) {
return 'test_not_run.png';
}
switch (result.verdict) {
case diagnosticsMojom.RoutineVerdict.kNoProblem:
return 'test_passed.png';
case diagnosticsMojom.RoutineVerdict.kProblem:
return 'test_failed.png';
case diagnosticsMojom.RoutineVerdict.kNotRun:
return 'test_canceled.png';
}
return '';
},
/**
* Helper function to generate the routine result string.
* @param {Routine} routine
......
<link rel="import" href="network_diagnostics_mojo.html">
<script src="network_diagnostics_types.js"></script>
// 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.
// clang-format off
// #import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
// #import 'chrome://resources/mojo/chromeos/services/network_health/public/mojom/network_diagnostics.mojom-lite.js';
// clang-format on
/**
* @fileoverview
* This file contains shared types for the network diagnostics components.
*/
/**
* A routine response from the Network Diagnostics mojo service.
* @typedef {{
* verdict: chromeos.networkDiagnostics.mojom.RoutineVerdict,
* }}
* RoutineResponse can optionally have a `problems` field, which is an array of
* enums relevant to the routine run. Unfortunately the closure compiler cannot
* handle optional object fields.
*/
/* #export */ let RoutineResponse;
/**
* A network diagnostics routine. Holds descriptive information about the
* routine, and it's transient state.
* @typedef {{
* name: string,
* type: !RoutineType,
* group: !RoutineGroup,
* func: function(),
* running: boolean,
* resultMsg: string,
* result: ?RoutineResponse,
* }}
*/
/* #export */ let Routine;
/**
* Definition for all Network diagnostic routine types. This enum is intended
* to be used as an index in an array of routines.
* @enum {number}
*/
/* #export */ const RoutineType = {
LAN_CONNECTIVITY: 0,
SIGNAL_STRENGTH: 1,
GATEWAY_PING: 2,
SECURE_WIFI: 3,
DNS_RESOLVER: 4,
DNS_LATENCY: 5,
DNS_RESOLUTION: 6,
HTTP_FIREWALL: 7,
HTTPS_FIREWALL: 8,
HTTPS_LATENCY: 9,
};
/**
* Definition for different groups of network routines.
* @enum {number}
*/
/* #export */ const RoutineGroup = {
CONNECTION: 0,
WIFI: 1,
GATEWAY: 2,
FIREWALL: 3,
DNS: 4,
};
/* #export */ const Icons = {
TEST_FAILED: 'test_failed.png',
TEST_NOT_RUN: 'test_not_run.png',
TEST_PASSED: 'test_passed.png'
};
<link rel="import" href="../../../html/i18n_behavior.html">
<link rel="import" href="../../../html/polymer.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html">
<link rel="import" href="network_diagnostics_mojo.html">
<link rel="import" href="network_diagnostics_types.html">
<dom-module id="routine-group">
<template>
<style>
.group-container {
border: 1.5px solid rgb(175, 175, 175);
border-radius: 10px;
cursor: pointer;
margin: 10px;
padding: 5px;
}
.routine-container {
align-items: center;
display: flex;
height: 20px;
margin: 5px;
padding: 5px;
}
.routine-icon {
height: 25px;
width: auto;
}
.group-name {
flex: 1;
font-size: 1rem;
}
.routine-name {
flex: 1;
font-size: 0.8rem;
padding-inline-start: 10px;
}
.group-header {
align-items: center;
display: flex;
min-height: 30px;
}
</style>
<div class="group-container" on-click="onGroupClick_">
<div class="group-header">
<div class="group-name">[[name]]</div>
<template is="dom-if" if="[[running]]">
<paper-spinner-lite active></paper-spinner-lite>
</template>
<img class="routine-icon" hidden="[[!showGroupIcon]]"
src="[[getGroupIcon_(routines.*)]]">
</div>
<template is="dom-if" if="[[expanded]]">
<template is="dom-repeat" items="[[routines]]" as="routine"
mutable-data>
<div class="routine-container" aria-label="[[i18n(routine.name)]]"
aria-description="[[routine.ariaDescription]]">
<img class="routine-icon" src="[[getRoutineIcon_(routine.result)]]">
<div aria-hidden="true" class="routine-name">
[[i18n(routine.name)]]
</div>
<div aria-hidden="true" hidden="[[!routine.resultMsg]]">
[[routine.resultMsg]]
</div>
</div>
</template>
</template>
</div>
</template>
<script src="routine_group.js"></script>
</dom-module>
// 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.
/**
* @fileoverview Polymer element for a group of diagnostic routines.
*/
Polymer({
is: 'routine-group',
behaviors: [
I18nBehavior,
],
properties: {
/**
* List of routines to display in the group.
* @private {!Array<!Routine>}
*/
routines: {
type: Array,
value: [],
},
/**
* Localized name for the group of routines.
* @private {String}
*/
name: {
type: String,
value: '',
},
/**
* Boolean flag if any routines in the group are running.
* @private {Boolean}
*/
running: {
type: Boolean,
computed: 'routinesRunning_(routines.*)',
},
/**
* Boolean flag if the routine group is expanded.
* @private {Boolean}
*/
expanded: {
type: Boolean,
value: false,
},
/**
* Boolean flag if icon representing the group result should be shown.
* @private {Boolean}
*/
showGroupIcon: {
type: Boolean,
computed: 'showGroupIcon_(running, expanded)',
},
},
/**
* Helper function to get the icon for a group of routines based on all of
* their results.
* @param {!PolymerDeepPropertyChange} routines
* @return {string}
* @private
*/
getGroupIcon_(routines) {
// Assume that all tests are complete and passing until proven otherwise.
let complete = true;
let failed = false;
for (const routine of /** @type {!Array<!Routine>} */ (routines.base)) {
if (!routine.result) {
complete = false;
continue;
}
switch (routine.result.verdict) {
case chromeos.networkDiagnostics.mojom.RoutineVerdict.kNoProblem:
continue;
case chromeos.networkDiagnostics.mojom.RoutineVerdict.kProblem:
failed = true;
break;
case chromeos.networkDiagnostics.mojom.RoutineVerdict.kNotRun:
complete = false;
break;
}
}
if (failed) {
return Icons.TEST_FAILED;
}
if (!complete) {
return Icons.TEST_NOT_RUN;
}
return Icons.TEST_PASSED;
},
/**
* Determine if the group routine icon should be showing.
* @param {boolean} running
* @param {boolean} expanded
* @return {boolean}
* @private
*/
showGroupIcon_(running, expanded) {
return !running && !expanded;
},
/**
* Helper function to get the icon for a routine based on the result.
* @param {!RoutineResponse} result
* @return {string}
* @private
*/
getRoutineIcon_(result) {
if (!result) {
return Icons.TEST_NOT_RUN;
}
switch (result.verdict) {
case chromeos.networkDiagnostics.mojom.RoutineVerdict.kNoProblem:
return Icons.TEST_PASSED;
case chromeos.networkDiagnostics.mojom.RoutineVerdict.kProblem:
return Icons.TEST_FAILED;
case chromeos.networkDiagnostics.mojom.RoutineVerdict.kNotRun:
return Icons.TEST_NOT_RUN;
}
return Icons.TEST_NOT_RUN;
},
/**
* Determine if any routines in the group are running.
* @param {!PolymerDeepPropertyChange} routines
* @return {boolean}
* @private
*/
routinesRunning_(routines) {
for (const routine of /** @type {!Array<!Routine>} */ (routines.base)) {
if (routine.running) {
return true;
}
}
return false;
},
/**
* Helper function to toggle the expanded properties when the routine group
* is clicked.
* @private
*/
onGroupClick_() {
this.set('expanded', !this.expanded);
},
});
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