Commit e89bf6db authored by Joon Ahn's avatar Joon Ahn Committed by Chromium LUCI CQ

diagnostics: power test routines

http://screen/4wX4sJuYUhvc3ub

Bug: 1125150
Change-Id: I88ab06756737b97c39de9c7d409395b0ef55db53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2599425
Commit-Queue: Joon Ahn <joonbug@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842090}
parent 3e475485
...@@ -64,6 +64,13 @@ export function routineSectionTestSuite() { ...@@ -64,6 +64,13 @@ export function routineSectionTestSuite() {
routineSectionElement.routines = routines; routineSectionElement.routines = routines;
routineSectionElement.isTestRunning = false; routineSectionElement.isTestRunning = false;
if (routines.length === 1 && [
chromeos.diagnostics.mojom.RoutineType.kBatteryDischarge,
chromeos.diagnostics.mojom.RoutineType.kBatteryCharge
].includes(routines[0])) {
routineSectionElement.isPowerRoutine = true;
}
return flushTasks(); return flushTasks();
} }
...@@ -220,6 +227,27 @@ export function routineSectionTestSuite() { ...@@ -220,6 +227,27 @@ export function routineSectionTestSuite() {
}); });
}); });
test('PowerResultListToggleButton', () => {
/** @type {!Array<!RoutineType>} */
const routines = [
chromeos.diagnostics.mojom.RoutineType.kBatteryCharge,
];
// TODO(joonbug): Use visibility assert over testing .hidden attr.
return initializeRoutineSection(routines)
.then(() => {
// Hidden by default.
assertTrue(getResultList().hidden);
assertTrue(getToggleTestReportButton().hidden);
return clickRunTestsButton();
})
.then(() => {
// Report is hidden by default and so is toggle button.
assertTrue(getResultList().hidden);
assertTrue(getToggleTestReportButton().hidden);
});
});
test('ClickButtonInitializesResultList', () => { test('ClickButtonInitializesResultList', () => {
/** @type {!Array<!RoutineType>} */ /** @type {!Array<!RoutineType>} */
const routines = [ const routines = [
......
...@@ -683,6 +683,9 @@ Try tapping the mic to ask me anything. ...@@ -683,6 +683,9 @@ Try tapping the mic to ask me anything.
<message name="IDS_DIANOSTICS_LEARN_MORE_LABEL" desc="The label for the button that links to a help support article to learn more about the test routines being run."> <message name="IDS_DIANOSTICS_LEARN_MORE_LABEL" desc="The label for the button that links to a help support article to learn more about the test routines being run.">
Learn more in the Help Center Learn more in the Help Center
</message> </message>
<message name="IDS_DIAGNOSTICS_LEARN_MORE_LABEL_SHORT" desc="The label for the text link that leads to a help support article to learn more about the test routines being run.">
Learn more
</message>
<message name="IDS_DIAGNOSTICS_DEVICE_INFO_TEXT" desc="The text that displays the device's name and milestone version."> <message name="IDS_DIAGNOSTICS_DEVICE_INFO_TEXT" desc="The text that displays the device's name and milestone version.">
(<ph name="BOARD_NAME">$1<ex>Atlas</ex></ph>, version <ph name="MILESTONE_VERSION">$2<ex>88</ex></ph>) (<ph name="BOARD_NAME">$1<ex>Atlas</ex></ph>, version <ph name="MILESTONE_VERSION">$2<ex>88</ex></ph>)
</message> </message>
...@@ -723,10 +726,10 @@ Try tapping the mic to ask me anything. ...@@ -723,10 +726,10 @@ Try tapping the mic to ask me anything.
Memory Memory
</message> </message>
<message name="IDS_CHARGE_TEST_RESULT" desc="The result text for charging routine."> <message name="IDS_CHARGE_TEST_RESULT" desc="The result text for charging routine.">
Charged <ph name="RATE">$1<ex>10%</ex></ph> in <ph name="NUM_SECONDS">$1<ex>10</ex></ph> seconds. Charged <ph name="RATE">$1<ex>10%</ex></ph> in <ph name="NUM_SECONDS">$2<ex>10</ex></ph> seconds.
</message> </message>
<message name="IDS_DISCHARGE_TEST_RESULT" desc="The result text for discharging routine."> <message name="IDS_DISCHARGE_TEST_RESULT" desc="The result text for discharging routine.">
Discharged <ph name="RATE">$1<ex>10%</ex></ph> in <ph name="NUM_SECONDS">$1<ex>10</ex></ph> seconds. Discharged <ph name="RATE">$1<ex>10%</ex></ph> in <ph name="NUM_SECONDS">$2<ex>10</ex></ph> seconds.
</message> </message>
<message name="IDS_DIAGNOSTICS_TEST_FAILURE_TEXT" desc="The text displayed when a test fails."> <message name="IDS_DIAGNOSTICS_TEST_FAILURE_TEXT" desc="The text displayed when a test fails.">
Test failed Test failed
......
d305ca9ee1ae6cb18466a4cd76321a90694a227d a35ac611967bf4b7f74da3fc0c6463d3644fe6bd
\ No newline at end of file \ No newline at end of file
09da1b78762d5d96339ce7ca881a89591eb66291
\ No newline at end of file
3258db3e241ceb87198e962d6ddd07e1856bbf99 bd0aeb13e645c4f35eee43975ba46b2376640ab2
\ No newline at end of file \ No newline at end of file
...@@ -69,6 +69,7 @@ void AddDiagnosticsStrings(content::WebUIDataSource* html_source) { ...@@ -69,6 +69,7 @@ void AddDiagnosticsStrings(content::WebUIDataSource* html_source) {
{"dischargeTestResultText", IDS_DISCHARGE_TEST_RESULT}, {"dischargeTestResultText", IDS_DISCHARGE_TEST_RESULT},
{"hideReportText", IDS_DIAGNOSTICS_HIDE_REPORT_TEXT}, {"hideReportText", IDS_DIAGNOSTICS_HIDE_REPORT_TEXT},
{"learnMore", IDS_DIANOSTICS_LEARN_MORE_LABEL}, {"learnMore", IDS_DIANOSTICS_LEARN_MORE_LABEL},
{"learnMoreShort", IDS_DIAGNOSTICS_LEARN_MORE_LABEL_SHORT},
{"memoryRoutineText", IDS_DIAGNOSTICS_MEMORY_ROUTINE_TEXT}, {"memoryRoutineText", IDS_DIAGNOSTICS_MEMORY_ROUTINE_TEXT},
{"memoryTitle", IDS_DIAGNOSTICS_MEMORY_TITLE}, {"memoryTitle", IDS_DIAGNOSTICS_MEMORY_TITLE},
{"percentageLabel", IDS_DIAGNOSTICS_PERCENTAGE_LABEL}, {"percentageLabel", IDS_DIAGNOSTICS_PERCENTAGE_LABEL},
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
<routine-section slot="routines" routines="[[routines_]]" <routine-section slot="routines" routines="[[routines_]]"
is-test-running="{{isTestRunning}}" is-test-running="{{isTestRunning}}"
is-power-routine="true"
run-tests-button-text="[[getRunTestsButtonText_( run-tests-button-text="[[getRunTestsButtonText_(
batteryChargeStatus_.powerAdapterStatus batteryChargeStatus_.powerAdapterStatus
)]]"> )]]">
......
...@@ -42,6 +42,30 @@ export function getRoutineType(routineType) { ...@@ -42,6 +42,30 @@ export function getRoutineType(routineType) {
} }
} }
/**
* @param {!RoutineResult} result
* @return {?StandardRoutineResult}
*/
export function getSimpleResult(result) {
if (!result) {
return null;
}
if (result.hasOwnProperty('simpleResult')) {
// Ideally we would just return assert(result.simpleResult) but enum
// value 0 fails assert.
return /** @type {!StandardRoutineResult} */ (result.simpleResult);
}
if (result.hasOwnProperty('powerResult')) {
return /** @type {!StandardRoutineResult} */ (
result.powerResult.simpleResult);
}
assertNotReached();
return null;
}
/** /**
* @fileoverview * @fileoverview
* 'routine-result-entry' shows the status of a single test routine. * 'routine-result-entry' shows the status of a single test routine.
...@@ -73,27 +97,6 @@ Polymer({ ...@@ -73,27 +97,6 @@ Polymer({
return loadTimeData.getStringF('routineEntryText', getRoutineType(routine)); return loadTimeData.getStringF('routineEntryText', getRoutineType(routine));
}, },
/**
* @param {!RoutineResult} result
* @return {!StandardRoutineResult}
*/
getSimpleResult_(result) {
assert(result);
if (result.hasOwnProperty('simpleResult')) {
// Ideally we would just return assert(result.simpleResult) but enum
// value 0 fails assert.
return /** @type {!StandardRoutineResult} */ (result.simpleResult);
}
if (result.hasOwnProperty('powerResult')) {
return /** @type {!StandardRoutineResult} */ (
result.powerResult.simpleResult);
}
assertNotReached();
},
/** /**
* @protected * @protected
*/ */
...@@ -103,7 +106,7 @@ Polymer({ ...@@ -103,7 +106,7 @@ Polymer({
} }
if (this.item.result && if (this.item.result &&
this.getSimpleResult_(this.item.result) === getSimpleResult(this.item.result) ===
chromeos.diagnostics.mojom.StandardRoutineResult.kTestPassed) { chromeos.diagnostics.mojom.StandardRoutineResult.kTestPassed) {
return loadTimeData.getString('testSucceededBadgeText'); return loadTimeData.getString('testSucceededBadgeText');
} }
...@@ -120,7 +123,7 @@ Polymer({ ...@@ -120,7 +123,7 @@ Polymer({
} }
if (this.item.result && if (this.item.result &&
this.getSimpleResult_(this.item.result) === getSimpleResult(this.item.result) ===
chromeos.diagnostics.mojom.StandardRoutineResult.kTestPassed) { chromeos.diagnostics.mojom.StandardRoutineResult.kTestPassed) {
return BadgeType.SUCCESS; return BadgeType.SUCCESS;
} }
......
<style include="diagnostics-shared"> <style include="diagnostics-shared">
.learn-more-button { .learn-more-button {
background-color: rgba(var(--google-blue-600), .06); background-color: rgba(var(--google-blue-600), .06);
border-radius: 5x; border-radius: 5x;
height: 40px; height: 40px;
padding: 5px 10px; padding: 5px 10px;
} }
#learnMoreText {
color: var(--google-blue-600);
cursor: pointer;
}
</style> </style>
<div id="routineSection"> <div id="routineSection">
...@@ -13,16 +18,20 @@ ...@@ -13,16 +18,20 @@
[[runTestsButtonText]] [[runTestsButtonText]]
</cr-button> </cr-button>
<cr-button id="toggleReportButton" class="action-button" on-click="onToggleReportClicked_" <cr-button id="toggleReportButton" class="action-button" on-click="onToggleReportClicked_"
hidden="[[isResultAndStatusHidden_(executionStatus_)]]"> hidden="[[isResultButtonHidden_(executionStatus_)]]">
[[getReportToggleButtonText_(isReportListHidden_)]] [[getReportToggleButtonText_(isReportListHidden_)]]
</cr-button> </cr-button>
<text-badge id="testStatusBadge" badge-type="[[getBadgeType_(executionStatus_)]]" <text-badge id="testStatusBadge" badge-type="[[getBadgeType_(executionStatus_)]]"
hidden="[[isResultAndStatusHidden_(executionStatus_)]]" hidden="[[isStatusHidden_(executionStatus_)]]"
value="[[getBadgeText_(executionStatus_)]]"> value="[[getBadgeText_(executionStatus_)]]">
</text-badge> </text-badge>
<span id="testStatusText" hidden$="[[isResultAndStatusHidden_(executionStatus_)]]"> <span id="testStatusText" hidden$="[[isStatusHidden_(executionStatus_)]]">
[[getTextStatus_(executionStatus_, currentTestName_)]] [[getTextStatus_(executionStatus_, currentTestName_)]]
</span> </span>
<span id="learnMoreText" hidden$="[[isLearnMoreHidden_(executionStatus_)]]"
on-click="onLearnMoreClicked_">
[[i18n('learnMoreShort')]]
</span>
<routine-result-list id="resultList" hidden="[[isReportListHidden_]]"></routine-result-list> <routine-result-list id="resultList" hidden="[[isReportListHidden_]]"></routine-result-list>
<cr-button id="learnMoreButton" class="learn-more-button" on-click="onLearnMoreClicked_" <cr-button id="learnMoreButton" class="learn-more-button" on-click="onLearnMoreClicked_"
hidden="[[isReportListHidden_]]"> hidden="[[isReportListHidden_]]">
......
...@@ -13,10 +13,10 @@ import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; ...@@ -13,10 +13,10 @@ import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {RoutineType, StandardRoutineResult, SystemRoutineControllerInterface} from './diagnostics_types.js'; import {PowerRoutineResult, RoutineType, StandardRoutineResult, SystemRoutineControllerInterface} from './diagnostics_types.js';
import {getSystemRoutineController} from './mojo_interface_provider.js'; import {getSystemRoutineController} from './mojo_interface_provider.js';
import {ExecutionProgress, RoutineListExecutor} from './routine_list_executor.js'; import {ExecutionProgress, RoutineListExecutor} from './routine_list_executor.js';
import {getRoutineType} from './routine_result_entry.js'; import {getRoutineType, getSimpleResult} from './routine_result_entry.js';
import {BadgeType} from './text_badge.js'; import {BadgeType} from './text_badge.js';
/** /**
...@@ -85,6 +85,18 @@ Polymer({ ...@@ -85,6 +85,18 @@ Polymer({
value: true, value: true,
}, },
/** @type {boolean} */
isPowerRoutine: {
type: Boolean,
value: false,
},
/** @private {?PowerRoutineResult} */
powerRoutineResult_: {
type: Object,
value: null,
},
/** @type {string} */ /** @type {string} */
runTestsButtonText: { runTestsButtonText: {
type: String, type: String,
...@@ -122,13 +134,17 @@ Polymer({ ...@@ -122,13 +134,17 @@ Polymer({
'routineNameText', getRoutineType(status.routine)); 'routineNameText', getRoutineType(status.routine));
if (status.result && if (status.result &&
status.result.simpleResult !== getSimpleResult(status.result) !==
chromeos.diagnostics.mojom.StandardRoutineResult chromeos.diagnostics.mojom.StandardRoutineResult
.kTestPassed) { .kTestPassed) {
this.hasTestFailure_ = true; this.hasTestFailure_ = true;
} }
resultListElem.onStatusUpdate.call(resultListElem, status); resultListElem.onStatusUpdate.call(resultListElem, status);
if (status.result && status.result.powerResult) {
this.powerRoutineResult_ = status.result.powerResult;
}
}) })
.then(() => { .then(() => {
this.executionStatus_ = ExecutionProgress.kCompleted; this.executionStatus_ = ExecutionProgress.kCompleted;
...@@ -160,7 +176,19 @@ Polymer({ ...@@ -160,7 +176,19 @@ Polymer({
}, },
/** @protected */ /** @protected */
isResultAndStatusHidden_() { isResultButtonHidden_() {
return this.isPowerRoutine ||
this.executionStatus_ === ExecutionProgress.kNotStarted;
},
/** @protected */
isLearnMoreHidden_() {
return this.isPowerRoutine === false ||
this.executionStatus_ !== ExecutionProgress.kCompleted;
},
/** @protected */
isStatusHidden_() {
return this.executionStatus_ === ExecutionProgress.kNotStarted; return this.executionStatus_ === ExecutionProgress.kNotStarted;
}, },
...@@ -196,8 +224,27 @@ Polymer({ ...@@ -196,8 +224,27 @@ Polymer({
if (this.executionStatus_ === ExecutionProgress.kRunning) { if (this.executionStatus_ === ExecutionProgress.kRunning) {
return this.currentTestName_; return this.currentTestName_;
} }
return loadTimeData.getString(
this.hasTestFailure_ ? 'testFailure' : 'testSuccess'); if (this.hasTestFailure_) {
return loadTimeData.getString('testFailure');
}
if (this.isPowerRoutine === false || this.powerRoutineResult_ === null) {
return loadTimeData.getString('testSuccess');
}
const stringId =
this.routines.includes(
chromeos.diagnostics.mojom.RoutineType.kBatteryCharge) ?
'chargeTestResultText' :
'dischargeTestResultText';
const percentText = loadTimeData.getStringF(
'percentageLabel', this.powerRoutineResult_.percentChange.toFixed(2));
return loadTimeData.getStringF(
stringId,
percentText,
this.powerRoutineResult_.timeElapsedSeconds
);
}, },
/** @override */ /** @override */
......
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