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() { ...@@ -70,25 +70,13 @@ export function batteryStatusCardTestSuite() {
.then(() => { .then(() => {
const dataPoints = const dataPoints =
dx_utils.getDataPointElements(batteryStatusElement); dx_utils.getDataPointElements(batteryStatusElement);
assertEquals( dx_utils.assertTextContains(
fakeBatteryChargeStatus[0].currentNowMilliamps, dataPoints[0].value,
dataPoints[0].value); `${fakeBatteryHealth[0].batteryWearPercentage}`);
assertEquals( assertEquals(fakeBatteryHealth[0].cycleCount, dataPoints[1].value);
fakeBatteryHealth[0].chargeFullDesignMilliampHours, dx_utils.assertTextContains(
dataPoints[1].value); dataPoints[2].value,
assertEquals( `${fakeBatteryChargeStatus[0].currentNowMilliamps}`);
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.assertElementContainsText( dx_utils.assertElementContainsText(
batteryStatusElement.$$('#batteryStatusChipInfo'), batteryStatusElement.$$('#batteryStatusChipInfo'),
`${fakeBatteryHealth[0].chargeFullDesignMilliampHours}`); `${fakeBatteryHealth[0].chargeFullDesignMilliampHours}`);
......
...@@ -92,10 +92,15 @@ export function cpuCardTestSuite() { ...@@ -92,10 +92,15 @@ export function cpuCardTestSuite() {
test('CpuCardPopulated', () => { test('CpuCardPopulated', () => {
return initializeCpuCard(fakeCpuUsage, fakeSystemInfo).then(() => { return initializeCpuCard(fakeCpuUsage, fakeSystemInfo).then(() => {
const dataPoints = dx_utils.getDataPointElements(cpuElement); const dataPoints = dx_utils.getDataPointElements(cpuElement);
const currentlyUsingValue = dx_utils.assertTextContains(
fakeCpuUsage[0].percentUsageUser + fakeCpuUsage[0].percentUsageSystem; dataPoints[0].value,
assertEquals(currentlyUsingValue, dataPoints[0].value); `${
assertEquals(fakeCpuUsage[0].averageCpuTempCelsius, dataPoints[1].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( dx_utils.assertElementContainsText(
cpuElement.$$('#cpuChipInfo'), `${fakeSystemInfo.cpuModelName}`); cpuElement.$$('#cpuChipInfo'), `${fakeSystemInfo.cpuModelName}`);
dx_utils.assertElementContainsText( dx_utils.assertElementContainsText(
......
...@@ -102,5 +102,15 @@ export function getToggleTestReportButtonFromSection(element) { ...@@ -102,5 +102,15 @@ export function getToggleTestReportButtonFromSection(element) {
* @throws {Error} * @throws {Error}
*/ */
export function assertElementContainsText(element, text) { export function assertElementContainsText(element, text) {
assertTrue(element.textContent.trim().indexOf(text) !== -1); assertTextContains(element.textContent, text);
} }
\ No newline at end of file
/**
* 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() { ...@@ -88,10 +88,6 @@ export function memoryCardTestSuite() {
test('MemoryCardPopulated', () => { test('MemoryCardPopulated', () => {
return initializeMemoryCard(fakeMemoryUsage).then(() => { 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 barChart = dx_utils.getPercentBarChartElement(memoryElement);
const memInUse = fakeMemoryUsage[0].totalMemoryKib - const memInUse = fakeMemoryUsage[0].totalMemoryKib -
fakeMemoryUsage[0].availableMemoryKib; fakeMemoryUsage[0].availableMemoryKib;
......
...@@ -588,8 +588,11 @@ Try tapping the mic to ask me anything. ...@@ -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"> <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 CPU
</message> </message>
<message name="IDS_DIAGNOSTICS_CPU_USAGE_LABEL" desc="The label for the percentage of CPU that is currently being used." translateable="false"> <message name="IDS_DIAGNOSTICS_CPU_USAGE_LABEL" desc="The label for the percentage of CPU that is currently being used." translateable="true">
Currently using 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>
<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"> <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 System
...@@ -618,8 +621,11 @@ Try tapping the mic to ask me anything. ...@@ -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"> <message name="IDS_DIAGNOSTICS_CHARGE_NOW_LABEL" desc="The label for a battery's current battery level represented in milliamps." translateable="false">
Now charge Now charge
</message> </message>
<message name="IDS_DIAGNOSTICS_CURRENT_NOW_LABEL" desc="The label for a battery's current power consumption represented in milliamps." translateable="false"> <message name="IDS_DIAGNOSTICS_CURRENT_NOW_LABEL" desc="The label for a battery's current power consumption represented in milliamps." translateable="true">
Now current 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>
<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"> <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 Designed full charge
...@@ -645,6 +651,18 @@ Try tapping the mic to ask me anything. ...@@ -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"> <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) <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>
<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 --> <!-- 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."> <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) { ...@@ -35,17 +35,23 @@ void AddDiagnosticsStrings(content::WebUIDataSource* html_source) {
static constexpr webui::LocalizedString kLocalizedStrings[] = { static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"adapterStatus", IDS_DIAGNOSTICS_POWER_LABEL}, {"adapterStatus", IDS_DIAGNOSTICS_POWER_LABEL},
{"batteryChipText", IDS_DIAGNOSTICS_BATTERY_CHIP_TEXT}, {"batteryChipText", IDS_DIAGNOSTICS_BATTERY_CHIP_TEXT},
{"batteryHealthLabel", IDS_DIAGNOSTICS_BATTERY_HEALTH_LABEL},
{"batteryHealthText", IDS_DIAGNOSTICS_BATTERY_HEALTH_TEXT},
{"batteryTitle", IDS_DIAGNOSTICS_BATTERY_TITLE}, {"batteryTitle", IDS_DIAGNOSTICS_BATTERY_TITLE},
{"chargeFullDesign", IDS_DIAGNOSTICS_DESIGNED_FULL_CHARGE_LABEL}, {"chargeFullDesign", IDS_DIAGNOSTICS_DESIGNED_FULL_CHARGE_LABEL},
{"chargeFullNow", IDS_DIAGNOSTICS_NOW_FULL_CHARGE_LABEL}, {"chargeFullNow", IDS_DIAGNOSTICS_NOW_FULL_CHARGE_LABEL},
{"chargeNow", IDS_DIAGNOSTICS_CHARGE_NOW_LABEL}, {"chargeNow", IDS_DIAGNOSTICS_CHARGE_NOW_LABEL},
{"cpuChipText", IDS_DIAGNOSTICS_CPU_CHIP_TEXT}, {"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}, {"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}, {"cpuUsageSystem", IDS_DIAGNOSTICS_CPU_USAGE_SYSTEM_LABEL},
{"cpuUsageUser", IDS_DIAGNOSTICS_CPU_USAGE_USER_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}, {"cycleCount", IDS_DIAGNOSTICS_CYCLE_COUNT_LABEL},
{"diagnosticsTitle", IDS_DIAGNOSTICS_TITLE}, {"diagnosticsTitle", IDS_DIAGNOSTICS_TITLE},
{"memoryAvailable", IDS_DIAGNOSTICS_MEMORY_AVAILABLE_LABEL}, {"memoryAvailable", IDS_DIAGNOSTICS_MEMORY_AVAILABLE_LABEL},
......
...@@ -10,26 +10,14 @@ ...@@ -10,26 +10,14 @@
value="[[batteryChargeStatus_.chargeNowMilliampHours]]" value="[[batteryChargeStatus_.chargeNowMilliampHours]]"
max="[[batteryHealth_.chargeFullNowMilliampHours]]"> max="[[batteryHealth_.chargeFullNowMilliampHours]]">
</percent-bar-chart> </percent-bar-chart>
<data-point slot="body" id="currentNow" header="[[i18n('currentNow')]]" <data-point slot="body" id="batteryHealth"
value="[[batteryChargeStatus_.currentNowMilliamps]]"> header="[[i18n('batteryHealthLabel')]]"
</data-point> value="[[getBatteryHealth_(batteryHealth_.batteryWearPercentage)]]">
<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> </data-point>
<data-point slot="body" id="cycleCount" header="[[i18n('cycleCount')]]" <data-point slot="body" id="cycleCount" header="[[i18n('cycleCount')]]"
value="[[batteryHealth_.cycleCount]]"> value="[[batteryHealth_.cycleCount]]">
</data-point> </data-point>
<data-point slot="body" id="currentNow" header="[[i18n('currentNowLabel')]]"
value="[[getCurrentNow_(batteryChargeStatus_.currentNowMilliamps)]]">
</data-point>
</diagnostics-card> </diagnostics-card>
...@@ -156,4 +156,18 @@ Polymer({ ...@@ -156,4 +156,18 @@ Polymer({
return loadTimeData.getStringF( return loadTimeData.getStringF(
'batteryChipText', this.batteryHealth_.chargeFullDesignMilliampHours); '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 @@ ...@@ -9,15 +9,17 @@
user="[[cpuUsage_.percentUsageUser]]" user="[[cpuUsage_.percentUsageUser]]"
system="[[cpuUsage_.percentUsageSystem]]"> system="[[cpuUsage_.percentUsageSystem]]">
</realtime-cpu-chart> </realtime-cpu-chart>
<data-point slot="body" id="cpuUsageUser" header="[[i18n('cpuUsage')]]" <data-point slot="body" id="cpuUsageUser"
value="[[computeCurrentlyUsing_(cpuUsage_.percentUsageSystem, header="[[i18n('cpuUsageLabel')]]"
value="[[getCurrentlyUsing_(cpuUsage_.percentUsageSystem,
cpuUsage_.percentUsageUser)]]"> cpuUsage_.percentUsageUser)]]">
</data-point> </data-point>
<!-- TODO(michaelcheco): Investigate whether or not temperature can be <data-point slot="body" id="cpuTemp" header="[[i18n('cpuTempLabel')]]"
localized. --> value="[[getCpuTemp_(cpuUsage_.averageCpuTempCelsius)]]">
<data-point slot="body" id="cpuTemp" header="[[i18n('cpuTemp')]]"
value="[[cpuUsage_.averageCpuTempCelsius]]">
</data-point> </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> <routine-section slot="routines" routines="[[routines_]]"></routine-section>
</diagnostics-card> </diagnostics-card>
...@@ -95,13 +95,13 @@ Polymer({ ...@@ -95,13 +95,13 @@ Polymer({
this.cpuUsage_ = cpuUsage; this.cpuUsage_ = cpuUsage;
}, },
/** /** @protected */
* @param {number} percentUsageSystem getCurrentlyUsing_() {
* @param {number} percentUsageUser const MAX_PERCENTAGE = 100;
* @private const usagePercentage = Math.min(
*/ (this.cpuUsage_.percentUsageSystem + this.cpuUsage_.percentUsageUser),
computeCurrentlyUsing_(percentUsageSystem, percentUsageUser) { MAX_PERCENTAGE);
return percentUsageSystem + percentUsageUser; return loadTimeData.getStringF('cpuUsageText', usagePercentage);
}, },
/** @private */ /** @private */
...@@ -120,4 +120,10 @@ Polymer({ ...@@ -120,4 +120,10 @@ Polymer({
this.cpuChipInfo_ = loadTimeData.getStringF( this.cpuChipInfo_ = loadTimeData.getStringF(
'cpuChipText', systemInfo.cpuModelName, systemInfo.cpuThreadsCount); 'cpuChipText', systemInfo.cpuModelName, systemInfo.cpuThreadsCount);
}, },
/** @protected */
getCpuTemp_() {
return loadTimeData.getStringF(
'cpuTempText', this.cpuUsage_.averageCpuTempCelsius);
},
}); });
...@@ -7,13 +7,5 @@ ...@@ -7,13 +7,5 @@
value="[[getTotalUsedMemory_(memoryUsage_)]]" value="[[getTotalUsedMemory_(memoryUsage_)]]"
max="[[memoryUsage_.totalMemoryKib]]"> max="[[memoryUsage_.totalMemoryKib]]">
</percent-bar-chart> </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> <routine-section slot="routines" routines="[[routines_]]"></routine-section>
</diagnostics-card> </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