Diagnostics: Update wifi-info displayed content
- Reorder wifi-info data-points to match requirements doc - Remove duplicate Network name field (SSID) - Updates tests to ensure correct wifi-info ui population - Add utility to convert frequency to 2.4GHz channel - Adds test coverage for frequency conversion function - Adds todo for IP configuration element work Screenshot 1 (w/ calculable channel): http://shortn/_LGmRlEe8vP Screenshot 2 (w/ non-calculable channel): http://shortn/_hbfIIcYbpp Bug: 1197335 Test: browser_tests --gtest_filter=DiagnosticsApp* Change-Id: I19b9e6d58c38cce72b011f710eef02d0eae18ac4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3017672 Reviewed-by: Zentaro Kavanagh <zentaro@chromium.org> Commit-Queue: Ashley Prasad <ashleydp@google.com> Cr-Commit-Position: refs/heads/master@{#900605}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
5dbd50d9c4
commit
1702f8676a
ash/webui/diagnostics_ui/resources
chrome/test/data/webui/chromeos/diagnostics
@ -16,6 +16,25 @@ export function convertKibToGibDecimalString(value, numDecimalPlaces) {
|
||||
return (value / 2 ** 20).toFixed(numDecimalPlaces);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a MHz frequency into channel number. Should the frequency requested
|
||||
* not fall into the algorithm range null is returned.
|
||||
* @param {number} frequency Given in MHz.
|
||||
* @return {?number} channel
|
||||
*/
|
||||
export function convertFrequencyToChannel(frequency) {
|
||||
// Handle 2.4GHz channel calculation for channel 1-13.
|
||||
if (frequency >= 2412 && frequency <= 2483) {
|
||||
return Math.ceil(1 + ((frequency - 2412) / 5));
|
||||
}
|
||||
// Handle 2.4GHz channel 14 which is a special case for Japan.
|
||||
if (frequency >= 2484 && frequency <= 2495) {
|
||||
return 14;
|
||||
}
|
||||
// TODO(ashleydp): Add algorithm for 5GHz.
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an icon from the diagnostics icon set.
|
||||
* @param {string} id
|
||||
|
@ -4,31 +4,32 @@
|
||||
<div hidden$="[[showIpConfigProperties]]"
|
||||
class="horizontal-data-point-container">
|
||||
<div class="data-point-container">
|
||||
<data-point id="name" header="Network Name"
|
||||
value="[[network.name]]"
|
||||
orientation="horizontal">
|
||||
</data-point>
|
||||
<data-point id="ipAddress" header="IP Address"
|
||||
value="[[network.ipConfig.ipAddress]]"
|
||||
orientation="horizontal">
|
||||
</data-point>
|
||||
<data-point id="name" header="name"
|
||||
value="[[network.name]]"
|
||||
orientation="horizontal">
|
||||
<data-point id="bssid" header="BSSID"
|
||||
value="[[network.typeProperties.wifi.bssid]]"
|
||||
orientation="horizontal">
|
||||
</data-point>
|
||||
</div>
|
||||
<div class="divider-horizontal"></div>
|
||||
<div class="data-point-container">
|
||||
<data-point id="bssid" header="bssid"
|
||||
value="[[network.typeProperties.wifi.bssid]]"
|
||||
<data-point id="signalStrength" header="Signal Strength"
|
||||
value="[[network.typeProperties.wifi.signalStrength]]"
|
||||
orientation="horizontal">
|
||||
</data-point>
|
||||
<data-point id="ssid" header="ssid"
|
||||
value="[[network.typeProperties.wifi.ssid]]"
|
||||
orientation="horizontal">
|
||||
</data-point>
|
||||
<data-point id="ipAddress" header="IP Address"
|
||||
value="[[network.ipConfig.ipAddress]]"
|
||||
<data-point id="channel" header="Channel"
|
||||
value="[[getChannelDescription_(network.typeProperties.wifi.frequency)]]"
|
||||
orientation="horizontal">
|
||||
</data-point>
|
||||
</div>
|
||||
</div>
|
||||
<!-- TODO(ashleydp): Move IP configuration data into distinct element. -->
|
||||
<div hidden$="[[!showIpConfigProperties]]"
|
||||
class="horizontal-data-point-container">
|
||||
<div class="data-point-container">
|
||||
|
@ -9,7 +9,7 @@ import './diagnostics_shared_css.js';
|
||||
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
|
||||
|
||||
import {Network} from './diagnostics_types.js';
|
||||
import {getSubnetMaskFromRoutingPrefix} from './diagnostics_utils.js';
|
||||
import {convertFrequencyToChannel, getSubnetMaskFromRoutingPrefix} from './diagnostics_utils.js';
|
||||
|
||||
/**
|
||||
* @fileoverview
|
||||
@ -44,6 +44,20 @@ Polymer({
|
||||
return nameServers ? nameServers.join(', ') : '';
|
||||
},
|
||||
|
||||
/**
|
||||
* Builds channel text based frequency conversion. If value returned by
|
||||
* conversion function is null then we display a question mark for channel
|
||||
* value. Frequency used to calculate converted from MHz to GHz for display.
|
||||
* @protected
|
||||
* @param {number} frequency Given in MHz.
|
||||
* @return {string}
|
||||
*/
|
||||
getChannelDescription_(frequency) {
|
||||
const channel = convertFrequencyToChannel(frequency);
|
||||
const ghz = (frequency / 1000).toFixed(3);
|
||||
return `${channel || '?'} (${ghz} GHz)`;
|
||||
},
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @param {number} prefix
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import {convertKibToGibDecimalString, getSubnetMaskFromRoutingPrefix} from 'chrome://diagnostics/diagnostics_utils.js';
|
||||
import {convertFrequencyToChannel, convertKibToGibDecimalString, getSubnetMaskFromRoutingPrefix} from 'chrome://diagnostics/diagnostics_utils.js';
|
||||
import {assertEquals} from '../../chai_assert.js';
|
||||
|
||||
export function diagnosticsUtilsTestSuite() {
|
||||
@ -53,4 +53,28 @@ export function diagnosticsUtilsTestSuite() {
|
||||
assertEquals(getSubnetMaskFromRoutingPrefix(31), '255.255.255.254');
|
||||
assertEquals(getSubnetMaskFromRoutingPrefix(32), '255.255.255.255');
|
||||
});
|
||||
}
|
||||
|
||||
test('ConvertFrequencyToChannel', () => {
|
||||
assertEquals(convertFrequencyToChannel(0), null);
|
||||
assertEquals(convertFrequencyToChannel(2411), null);
|
||||
// Calculates 2.4GHz channels.
|
||||
assertEquals(convertFrequencyToChannel(2412), 1);
|
||||
assertEquals(convertFrequencyToChannel(2417), 2);
|
||||
assertEquals(convertFrequencyToChannel(2422), 3);
|
||||
assertEquals(convertFrequencyToChannel(2427), 4);
|
||||
assertEquals(convertFrequencyToChannel(2432), 5);
|
||||
assertEquals(convertFrequencyToChannel(2437), 6);
|
||||
assertEquals(convertFrequencyToChannel(2442), 7);
|
||||
assertEquals(convertFrequencyToChannel(2447), 8);
|
||||
assertEquals(convertFrequencyToChannel(2452), 9);
|
||||
assertEquals(convertFrequencyToChannel(2457), 10);
|
||||
assertEquals(convertFrequencyToChannel(2462), 11);
|
||||
assertEquals(convertFrequencyToChannel(2467), 12);
|
||||
assertEquals(convertFrequencyToChannel(2472), 13);
|
||||
// Special 2.4GHz channel range for Japan
|
||||
assertEquals(convertFrequencyToChannel(2484), 14);
|
||||
assertEquals(convertFrequencyToChannel(2495), 14);
|
||||
// TODO(ashleydp): Fix expectation when 5GHz algorithm is ready.
|
||||
assertEquals(convertFrequencyToChannel(2496), null);
|
||||
});
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'chrome://diagnostics/wifi_info.js';
|
||||
import {Network} from 'chrome://diagnostics/diagnostics_types.js';
|
||||
import {fakeWifiNetwork} from 'chrome://diagnostics/fake_data.js';
|
||||
|
||||
import {assertFalse, assertTrue} from '../../chai_assert.js';
|
||||
@ -23,33 +24,67 @@ export function wifiInfoTestSuite() {
|
||||
wifiInfoElement = null;
|
||||
});
|
||||
|
||||
function initializeWifiInfo() {
|
||||
/*
|
||||
* @param {Network=}
|
||||
*/
|
||||
function initializeWifiInfo(network = fakeWifiNetwork) {
|
||||
assertFalse(!!wifiInfoElement);
|
||||
|
||||
// Add the wifi info to the DOM.
|
||||
wifiInfoElement =
|
||||
/** @type {!WifiInfoElement} */ (document.createElement('wifi-info'));
|
||||
assertTrue(!!wifiInfoElement);
|
||||
wifiInfoElement.network = fakeWifiNetwork;
|
||||
wifiInfoElement.network = network;
|
||||
document.body.appendChild(wifiInfoElement);
|
||||
|
||||
return flushTasks();
|
||||
}
|
||||
|
||||
test('WifiInfoPopulated', () => {
|
||||
const expectedGhz = 5.745;
|
||||
return initializeWifiInfo().then(() => {
|
||||
assertTextContains(
|
||||
getDataPointValue(wifiInfoElement, '#name'),
|
||||
`${fakeWifiNetwork.name}`);
|
||||
assertTextContains(
|
||||
getDataPointValue(wifiInfoElement, '#ipAddress'),
|
||||
`${fakeWifiNetwork.ipConfig.ipAddress}`);
|
||||
assertTextContains(
|
||||
getDataPointValue(wifiInfoElement, '#bssid'),
|
||||
fakeWifiNetwork.typeProperties.wifi.bssid);
|
||||
assertTextContains(
|
||||
getDataPointValue(wifiInfoElement, '#ssid'),
|
||||
fakeWifiNetwork.typeProperties.wifi.ssid);
|
||||
getDataPointValue(wifiInfoElement, '#signalStrength'),
|
||||
`${fakeWifiNetwork.typeProperties.wifi.signalStrength}`);
|
||||
// TODO(ashleydp): Update test expectation when 5 GHz channel conversion
|
||||
// algorithm provided.
|
||||
assertTextContains(
|
||||
getDataPointValue(wifiInfoElement, '#ipAddress'),
|
||||
`${fakeWifiNetwork.ipConfig.ipAddress}`);
|
||||
getDataPointValue(wifiInfoElement, '#channel'),
|
||||
`? (${expectedGhz} GHz)`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test('FrequencyConvertibleToChannel', () => {
|
||||
const networkOverride =
|
||||
/** @type {!Network} */ (Object.assign({}, fakeWifiNetwork));
|
||||
networkOverride.typeProperties.wifi.frequency = 2412;
|
||||
const expectedGhz = 2.412;
|
||||
return initializeWifiInfo().then(() => {
|
||||
assertTextContains(
|
||||
getDataPointValue(wifiInfoElement, '#channel'),
|
||||
`1 (${expectedGhz} GHz)`);
|
||||
});
|
||||
});
|
||||
|
||||
test('FrequencyNotConvertibleToChannel', () => {
|
||||
const networkOverride =
|
||||
/** @type {!Network} */ (Object.assign({}, fakeWifiNetwork));
|
||||
// 2411 MHz is below 2.4 GHz frequency range.
|
||||
networkOverride.typeProperties.wifi.frequency = 2411;
|
||||
const expectedGhz = 2.411;
|
||||
return initializeWifiInfo().then(() => {
|
||||
assertTextContains(
|
||||
getDataPointValue(wifiInfoElement, '#channel'),
|
||||
`? (${expectedGhz} GHz)`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user