Commit 992806db authored by Michael Checo's avatar Michael Checo Committed by Chromium LUCI CQ

Diagnostics: Add cpu speed data point

Bug: 1125150
Test: browser_tests --gtest_filter=DiagnosticsApp*
Change-Id: Id03a79fa1bdf2fd11d2d590bfcdba12a0e732eda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2565691
Commit-Queue: Michael Checo <michaelcheco@google.com>
Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832557}
parent 4d0e27b9
......@@ -103,8 +103,14 @@ export function cpuCardTestSuite() {
loadTimeData.getStringF('cpuUsageTooltipText', 4));
dx_utils.assertTextContains(
dataPoints[1].value, `${fakeCpuUsage[0].averageCpuTempCelsius}`);
// TODO(michaelcheco): Replace with value for CPU speed.
assertEquals('', dataPoints[2].value);
const convertkhzToGhz = (num) => parseFloat(num / 1000000).toFixed(2);
dx_utils.assertTextContains(
dataPoints[2].value,
`${convertkhzToGhz(fakeCpuUsage[0].scalingCurrentFrequencyKhz)}`);
dx_utils.assertTextContains(
dataPoints[2].value,
`${convertkhzToGhz(cpuElement.cpuMaxClockSpeedKhz_)}`);
dx_utils.assertElementContainsText(
cpuElement.$$('#cpuChipInfo'), `${fakeSystemInfo.cpuModelName}`);
dx_utils.assertElementContainsText(
......
......@@ -778,6 +778,9 @@ Try tapping the mic to ask me anything.
<message name="IDS_DIAGNOSTICS_STOP_TEST_BUTTON_TEXT" desc="The text for the button used to stop a test." translateable="true">
Stop test
</message>
<message name="IDS_DIAGNOSTICS_CPU_SPEED_TEXT" desc="The text that displays the CPU speed. GHz is an SI unit for gigahertz." translateable="true">
<ph name="CURRENT">$1<ex>1.6</ex></ph>GHz / <ph name="MAX">$2<ex>1.9</ex></ph>GHz
</message>
<!-- Quick Answers -->
<message name="IDS_QUICK_ANSWERS_DEFINITION_TITLE_TEXT" desc="The title text format string used for Quick Answers definition result card. The first placeholder contains the source query text and the second placeholder contains the phonetics.">
......
cddc01115773544974e36c8c820090b1dc77af21
\ No newline at end of file
......@@ -53,6 +53,7 @@ void AddDiagnosticsStrings(content::WebUIDataSource* html_source) {
{"cpuPrimeSearchRoutineText",
IDS_DIAGNOSTICS_CPU_PRIME_SEARCH_ROUTINE_TEXT},
{"cpuSpeedLabel", IDS_DIAGNOSTICS_CPU_SPEED_LABEL},
{"cpuSpeedText", IDS_DIAGNOSTICS_CPU_SPEED_TEXT},
{"cpuStressRoutineText", IDS_DIAGNOSTICS_CPU_STRESS_ROUTINE_TEXT},
{"cpuTempLabel", IDS_DIAGNOSTICS_CPU_TEMPERATURE_LABEL},
{"cpuTempText", IDS_DIAGNOSTICS_CPU_TEMPERATURE_TEXT},
......
......@@ -21,10 +21,9 @@
value="[[getCpuTemp_(cpuUsage_.averageCpuTempCelsius)]]">
</data-point>
<div slot="body" class="divider"></div>
<!-- TODO(michaelcheco): Add value for CPU speed. -->
<data-point slot="body" id="cpuTemp" header="[[i18n('cpuSpeedLabel')]]"
value="">
</data-point>
<data-point slot="body" id="cpuSpeed" header="[[i18n('cpuSpeedLabel')]]"
value="[[getCpuSpeed_(cpuUsage_.scalingCurrentFrequencyKhz)]]">
</data-point>
<routine-section slot="routines" routines="[[routines_]]"
is-test-running="{{isTestRunning}}"
run-tests-button-text="[[i18n('runCpuTestText')]]">
......
......@@ -68,6 +68,11 @@ Polymer({
isTestRunning: {
type: Boolean,
notify: true,
},
/** @type {number} */
cpuMaxClockSpeedKhz_: {
type: Number,
}
},
......@@ -128,6 +133,7 @@ Polymer({
// TODO(michaelcheco): Update when number of cores is added to the api.
this.cpuChipInfo_ = loadTimeData.getStringF(
'cpuChipText', systemInfo.cpuModelName, systemInfo.cpuThreadsCount);
this.cpuMaxClockSpeedKhz_ = systemInfo.cpuMaxClockSpeedKhz;
},
/** @protected */
......@@ -141,4 +147,23 @@ Polymer({
// TODO(michaelcheco): Update when number of cores is added to the api.
return loadTimeData.getString('cpuUsageTooltipText');
},
/**
* @param {number} num
* @return {string}
* @private
*/
convertKhzToGhz_(num) {
return parseFloat(num / 1000000).toFixed(2);
},
/** @protected */
getCpuSpeed_() {
if (this.cpuMaxClockSpeedKhz_) {
return loadTimeData.getStringF(
'cpuSpeedText',
this.convertKhzToGhz_(this.cpuUsage_.scalingCurrentFrequencyKhz),
this.convertKhzToGhz_(this.cpuMaxClockSpeedKhz_));
}
},
});
......@@ -61,41 +61,49 @@ export const fakeCpuUsage = [
averageCpuTempCelsius: 107,
percentUsageSystem: 15,
percentUsageUser: 20,
scalingCurrentFrequencyKhz: 900,
},
{
averageCpuTempCelsius: 106,
percentUsageSystem: 30,
percentUsageUser: 40,
scalingCurrentFrequencyKhz: 900,
},
{
averageCpuTempCelsius: 107,
percentUsageSystem: 31,
percentUsageUser: 45,
scalingCurrentFrequencyKhz: 900,
},
{
averageCpuTempCelsius: 109,
percentUsageSystem: 55,
percentUsageUser: 24,
scalingCurrentFrequencyKhz: 900,
},
{
averageCpuTempCelsius: 109,
percentUsageSystem: 49,
percentUsageUser: 10,
scalingCurrentFrequencyKhz: 900,
},
{
averageCpuTempCelsius: 161,
percentUsageSystem: 1,
percentUsageUser: 99,
scalingCurrentFrequencyKhz: 900,
},
{
averageCpuTempCelsius: 118,
percentUsageSystem: 35,
percentUsageUser: 37,
scalingCurrentFrequencyKhz: 900,
},
{
averageCpuTempCelsius: 110,
percentUsageSystem: 26,
percentUsageUser: 30,
scalingCurrentFrequencyKhz: 900,
},
];
......
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