Commit 01b00e24 authored by Michael Checo's avatar Michael Checo Committed by Commit Bot

Diagnostics: Reconcile current data points with those in final mocks

Screenshot: http://shortn/_NrxNEm5iXS

Bug: 1125150
Test: browser_tests --gtest_Filter=DiagnosticsApp*
Change-Id: Ia1b6f2079e659d0bba9726378b37bb5ed62e7c50
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2531054
Commit-Queue: Michael Checo <michaelcheco@google.com>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828533}
parent 2d50600b
......@@ -70,25 +70,13 @@ export function batteryStatusCardTestSuite() {
.then(() => {
const dataPoints =
dx_utils.getDataPointElements(batteryStatusElement);
assertEquals(
fakeBatteryChargeStatus[0].currentNowMilliamps,
dataPoints[0].value);
assertEquals(
fakeBatteryHealth[0].chargeFullDesignMilliampHours,
dataPoints[1].value);
assertEquals(
fakeBatteryHealth[0].chargeFullNowMilliampHours,
dataPoints[2].value);
assertEquals(
fakeBatteryChargeStatus[0].chargeNowMilliampHours,
dataPoints[3].value);
assertEquals(
mojoString16ToString(fakeBatteryChargeStatus[0].powerTime),
dataPoints[4].value);
assertEquals(
fakeBatteryChargeStatus[0].powerAdapterStatus,
dataPoints[5].value);
assertEquals(fakeBatteryHealth[0].cycleCount, dataPoints[6].value);
dx_utils.assertTextContains(
dataPoints[0].value,
`${fakeBatteryHealth[0].batteryWearPercentage}`);
assertEquals(fakeBatteryHealth[0].cycleCount, dataPoints[1].value);
dx_utils.assertTextContains(
dataPoints[2].value,
`${fakeBatteryChargeStatus[0].currentNowMilliamps}`);
dx_utils.assertElementContainsText(
batteryStatusElement.$$('#batteryStatusChipInfo'),
`${fakeBatteryHealth[0].chargeFullDesignMilliampHours}`);
......
......@@ -92,10 +92,15 @@ export function cpuCardTestSuite() {
test('CpuCardPopulated', () => {
return initializeCpuCard(fakeCpuUsage, fakeSystemInfo).then(() => {
const dataPoints = dx_utils.getDataPointElements(cpuElement);
const currentlyUsingValue =
fakeCpuUsage[0].percentUsageUser + fakeCpuUsage[0].percentUsageSystem;
assertEquals(currentlyUsingValue, dataPoints[0].value);
assertEquals(fakeCpuUsage[0].averageCpuTempCelsius, dataPoints[1].value);
dx_utils.assertTextContains(
dataPoints[0].value,
`${
fakeCpuUsage[0].percentUsageUser +
fakeCpuUsage[0].percentUsageSystem}`);
dx_utils.assertTextContains(
dataPoints[1].value, `${fakeCpuUsage[0].averageCpuTempCelsius}`);
// TODO(michaelcheco): Replace with value for CPU speed.
assertEquals('', dataPoints[2].value);
dx_utils.assertElementContainsText(
cpuElement.$$('#cpuChipInfo'), `${fakeSystemInfo.cpuModelName}`);
dx_utils.assertElementContainsText(
......
......@@ -102,5 +102,15 @@ export function getToggleTestReportButtonFromSection(element) {
* @throws {Error}
*/
export function assertElementContainsText(element, text) {
assertTrue(element.textContent.trim().indexOf(text) !== -1);
}
\ No newline at end of file
assertTextContains(element.textContent, text);
}
/**
* Helper function to check if a substring exists in a string.
* @param {string} text
* @param {string} subStr substring to check
* @throws {Error}
*/
export function assertTextContains(text, subStr) {
assertTrue(text.trim().indexOf(subStr) !== -1);
}
......@@ -88,10 +88,6 @@ export function memoryCardTestSuite() {
test('MemoryCardPopulated', () => {
return initializeMemoryCard(fakeMemoryUsage).then(() => {
const dataPoints = dx_utils.getDataPointElements(memoryElement);
assertEquals(fakeMemoryUsage[0].totalMemoryKib, dataPoints[0].value);
assertEquals(fakeMemoryUsage[0].availableMemoryKib, dataPoints[1].value);
const barChart = dx_utils.getPercentBarChartElement(memoryElement);
const memInUse = fakeMemoryUsage[0].totalMemoryKib -
fakeMemoryUsage[0].availableMemoryKib;
......
......@@ -588,8 +588,11 @@ Try tapping the mic to ask me anything.
<message name="IDS_DIAGNOSTICS_CPU_TITLE" desc="The title of the diagnostics CPU section which shows users' information about their computer CPU usage." translateable="false">
CPU
</message>
<message name="IDS_DIAGNOSTICS_CPU_USAGE_LABEL" desc="The label for the percentage of CPU that is currently being used." translateable="false">
Currently using
<message name="IDS_DIAGNOSTICS_CPU_USAGE_LABEL" desc="The label for the percentage of CPU that is currently being used." translateable="true">
Current usage
</message>
<message name="IDS_DIAGNOSTICS_CPU_USAGE_TEXT" desc="The text displaying the percentage of CPU that is currently being used." translateable="true">
<ph name="PERCENTAGE_VALUE">$1<ex>50</ex></ph>%
</message>
<message name="IDS_DIAGNOSTICS_CPU_USAGE_SYSTEM_LABEL" desc="The label for the percentage of CPU that is currently being used by the system." translateable="false">
System
......@@ -618,8 +621,11 @@ Try tapping the mic to ask me anything.
<message name="IDS_DIAGNOSTICS_CHARGE_NOW_LABEL" desc="The label for a battery's current battery level represented in milliamps." translateable="false">
Now charge
</message>
<message name="IDS_DIAGNOSTICS_CURRENT_NOW_LABEL" desc="The label for a battery's current power consumption represented in milliamps." translateable="false">
Now current
<message name="IDS_DIAGNOSTICS_CURRENT_NOW_LABEL" desc="The label for a battery's current power consumption represented in milliamps." translateable="true">
Current
</message>
<message name="IDS_DIAGNOSTICS_CURRENT_NOW_TEXT" desc="The text for a battery's current power consumption represented in milliamps." translateable="true">
<ph name="CURRENT_VALUE">$1<ex>1123</ex></ph>mA
</message>
<message name="IDS_DIAGNOSTICS_DESIGNED_FULL_CHARGE_LABEL" desc="The label for a battery's designed full charge capacity represented in milliamp hours." translateable="false">
Designed full charge
......@@ -645,6 +651,18 @@ Try tapping the mic to ask me anything.
<message name="IDS_DIAGNOSTICS_CPU_CHIP_TEXT" desc="The text that displays the CPU name and thread count." translateable="true">
<ph name="CPU_NAME">$1<ex>Intel(R) Celeron(R) N4020 CPU @ 1,10Ghz</ex></ph> (<ph name="THREAD_COUNT">$2<ex>8</ex></ph> threads)
</message>
<message name="IDS_DIAGNOSTICS_BATTERY_HEALTH_LABEL" desc="The label for a battery's health." translateable="true">
Battery health
</message>
<message name="IDS_DIAGNOSTICS_BATTERY_HEALTH_TEXT" desc="The text for the battery's health percentage." translateable="true">
<ph name="PERCENTAGE_VALUE">$1<ex>92</ex></ph>%
</message>
<message name="IDS_DIAGNOSTICS_CPU_SPEED_LABEL" desc="The label for CPU speed." translateable="true">
CPU Speed
</message>
<message name="IDS_DIAGNOSTICS_CPU_TEMPERATURE_TEXT" desc="The text for the current CPU temperature in Celsius." translateable="true">
<ph name="TEMPERATURE_C">$1<ex>25</ex></ph>° C
</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.">
......
3ee987ade356993192eff4275bc5a5efe633d280
\ No newline at end of file
3ee987ade356993192eff4275bc5a5efe633d280
\ No newline at end of file
5660b29d8a6efd2a02eaf5960a00a9faf685ed52
\ No newline at end of file
5660b29d8a6efd2a02eaf5960a00a9faf685ed52
\ No newline at end of file
5660b29d8a6efd2a02eaf5960a00a9faf685ed52
\ No newline at end of file
5660b29d8a6efd2a02eaf5960a00a9faf685ed52
\ No newline at end of file
91f711800fd89540fea45b218bce8048d77591ff
\ No newline at end of file
91f711800fd89540fea45b218bce8048d77591ff
\ No newline at end of file
......@@ -35,17 +35,23 @@ void AddDiagnosticsStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"adapterStatus", IDS_DIAGNOSTICS_POWER_LABEL},
{"batteryChipText", IDS_DIAGNOSTICS_BATTERY_CHIP_TEXT},
{"batteryHealthLabel", IDS_DIAGNOSTICS_BATTERY_HEALTH_LABEL},
{"batteryHealthText", IDS_DIAGNOSTICS_BATTERY_HEALTH_TEXT},
{"batteryTitle", IDS_DIAGNOSTICS_BATTERY_TITLE},
{"chargeFullDesign", IDS_DIAGNOSTICS_DESIGNED_FULL_CHARGE_LABEL},
{"chargeFullNow", IDS_DIAGNOSTICS_NOW_FULL_CHARGE_LABEL},
{"chargeNow", IDS_DIAGNOSTICS_CHARGE_NOW_LABEL},
{"cpuChipText", IDS_DIAGNOSTICS_CPU_CHIP_TEXT},
{"cpuTemp", IDS_DIAGNOSTICS_CPU_TEMPERATURE_LABEL},
{"cpuSpeedLabel", IDS_DIAGNOSTICS_CPU_SPEED_LABEL},
{"cpuTempLabel", IDS_DIAGNOSTICS_CPU_TEMPERATURE_LABEL},
{"cpuTempText", IDS_DIAGNOSTICS_CPU_TEMPERATURE_TEXT},
{"cpuTitle", IDS_DIAGNOSTICS_CPU_TITLE},
{"cpuUsage", IDS_DIAGNOSTICS_CPU_USAGE_LABEL},
{"cpuUsageLabel", IDS_DIAGNOSTICS_CPU_USAGE_LABEL},
{"cpuUsageText", IDS_DIAGNOSTICS_CPU_USAGE_TEXT},
{"cpuUsageSystem", IDS_DIAGNOSTICS_CPU_USAGE_SYSTEM_LABEL},
{"cpuUsageUser", IDS_DIAGNOSTICS_CPU_USAGE_USER_LABEL},
{"currentNow", IDS_DIAGNOSTICS_CURRENT_NOW_LABEL},
{"currentNowLabel", IDS_DIAGNOSTICS_CURRENT_NOW_LABEL},
{"currentNowText", IDS_DIAGNOSTICS_CURRENT_NOW_TEXT},
{"cycleCount", IDS_DIAGNOSTICS_CYCLE_COUNT_LABEL},
{"diagnosticsTitle", IDS_DIAGNOSTICS_TITLE},
{"memoryAvailable", IDS_DIAGNOSTICS_MEMORY_AVAILABLE_LABEL},
......
......@@ -10,26 +10,14 @@
value="[[batteryChargeStatus_.chargeNowMilliampHours]]"
max="[[batteryHealth_.chargeFullNowMilliampHours]]">
</percent-bar-chart>
<data-point slot="body" id="currentNow" header="[[i18n('currentNow')]]"
value="[[batteryChargeStatus_.currentNowMilliamps]]">
</data-point>
<data-point slot="body" id="chargeFullDesign"
header="[[i18n('chargeFullDesign')]]"
value="[[batteryHealth_.chargeFullDesignMilliampHours]]">
</data-point>
<data-point slot="body" id="chargeFullNow" header="[[i18n('chargeFullNow')]]"
value="[[batteryHealth_.chargeFullNowMilliampHours]]">
</data-point>
<data-point slot="body" id="chargeNow" header="[[i18n('chargeNow')]]"
value="[[batteryChargeStatus_.chargeNowMilliampHours]]">
</data-point>
<data-point slot="body" id="powerTime" header="[[i18n('powerTime')]]"
value="[[powerTimeString_]]">
</data-point>
<data-point slot="body" id="adapterStatus" header="[[i18n('adapterStatus')]]"
value="[[batteryChargeStatus_.powerAdapterStatus]]">
<data-point slot="body" id="batteryHealth"
header="[[i18n('batteryHealthLabel')]]"
value="[[getBatteryHealth_(batteryHealth_.batteryWearPercentage)]]">
</data-point>
<data-point slot="body" id="cycleCount" header="[[i18n('cycleCount')]]"
value="[[batteryHealth_.cycleCount]]">
</data-point>
<data-point slot="body" id="currentNow" header="[[i18n('currentNowLabel')]]"
value="[[getCurrentNow_(batteryChargeStatus_.currentNowMilliamps)]]">
</data-point>
</diagnostics-card>
......@@ -156,4 +156,18 @@ Polymer({
return loadTimeData.getStringF(
'batteryChipText', this.batteryHealth_.chargeFullDesignMilliampHours);
},
/** @protected */
getBatteryHealth_() {
const MAX_PERCENTAGE = 100;
const batteryWearPercentage =
Math.min(this.batteryHealth_.batteryWearPercentage, MAX_PERCENTAGE);
return loadTimeData.getStringF('batteryHealthText', batteryWearPercentage);
},
/** @protected */
getCurrentNow_() {
return loadTimeData.getStringF(
'currentNowText', this.batteryChargeStatus_.currentNowMilliamps);
},
});
......@@ -9,15 +9,17 @@
user="[[cpuUsage_.percentUsageUser]]"
system="[[cpuUsage_.percentUsageSystem]]">
</realtime-cpu-chart>
<data-point slot="body" id="cpuUsageUser" header="[[i18n('cpuUsage')]]"
value="[[computeCurrentlyUsing_(cpuUsage_.percentUsageSystem,
<data-point slot="body" id="cpuUsageUser"
header="[[i18n('cpuUsageLabel')]]"
value="[[getCurrentlyUsing_(cpuUsage_.percentUsageSystem,
cpuUsage_.percentUsageUser)]]">
</data-point>
<!-- TODO(michaelcheco): Investigate whether or not temperature can be
localized. -->
<data-point slot="body" id="cpuTemp" header="[[i18n('cpuTemp')]]"
value="[[cpuUsage_.averageCpuTempCelsius]]">
<data-point slot="body" id="cpuTemp" header="[[i18n('cpuTempLabel')]]"
value="[[getCpuTemp_(cpuUsage_.averageCpuTempCelsius)]]">
</data-point>
<!-- TODO(michaelcheco): Add value for CPU speed. -->
<data-point slot="body" id="cpuTemp" header="[[i18n('cpuSpeedLabel')]]"
value="">
</data-point>
<routine-section slot="routines" routines="[[routines_]]"></routine-section>
</diagnostics-card>
......@@ -95,13 +95,13 @@ Polymer({
this.cpuUsage_ = cpuUsage;
},
/**
* @param {number} percentUsageSystem
* @param {number} percentUsageUser
* @private
*/
computeCurrentlyUsing_(percentUsageSystem, percentUsageUser) {
return percentUsageSystem + percentUsageUser;
/** @protected */
getCurrentlyUsing_() {
const MAX_PERCENTAGE = 100;
const usagePercentage = Math.min(
(this.cpuUsage_.percentUsageSystem + this.cpuUsage_.percentUsageUser),
MAX_PERCENTAGE);
return loadTimeData.getStringF('cpuUsageText', usagePercentage);
},
/** @private */
......@@ -120,4 +120,10 @@ Polymer({
this.cpuChipInfo_ = loadTimeData.getStringF(
'cpuChipText', systemInfo.cpuModelName, systemInfo.cpuThreadsCount);
},
/** @protected */
getCpuTemp_() {
return loadTimeData.getStringF(
'cpuTempText', this.cpuUsage_.averageCpuTempCelsius);
},
});
......@@ -7,13 +7,5 @@
value="[[getTotalUsedMemory_(memoryUsage_)]]"
max="[[memoryUsage_.totalMemoryKib]]">
</percent-bar-chart>
<data-point slot="body" id="memoryTotal" header="[[i18n('totalMemory')]]"
value="[[memoryUsage_.totalMemoryKib]]">
</data-point>
<data-point slot="body" id="memoryAvailable"
header="[[i18n('memoryAvailable')]]"
value="[[memoryUsage_.availableMemoryKib]]">
</data-point>
<routine-section slot="routines" routines="[[routines_]]"></routine-section>
</diagnostics-card>
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