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() {
routineSectionElement.routines = routines;
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();
}
......@@ -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', () => {
/** @type {!Array<!RoutineType>} */
const routines = [
......
......@@ -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.">
Learn more in the Help Center
</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.">
(<ph name="BOARD_NAME">$1<ex>Atlas</ex></ph>, version <ph name="MILESTONE_VERSION">$2<ex>88</ex></ph>)
</message>
......@@ -723,10 +726,10 @@ Try tapping the mic to ask me anything.
Memory
</message>
<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 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 name="IDS_DIAGNOSTICS_TEST_FAILURE_TEXT" desc="The text displayed when a test fails.">
Test failed
......
d305ca9ee1ae6cb18466a4cd76321a90694a227d
\ No newline at end of file
a35ac611967bf4b7f74da3fc0c6463d3644fe6bd
\ No newline at end of file
09da1b78762d5d96339ce7ca881a89591eb66291
\ No newline at end of file
3258db3e241ceb87198e962d6ddd07e1856bbf99
\ No newline at end of file
bd0aeb13e645c4f35eee43975ba46b2376640ab2
\ No newline at end of file
......@@ -69,6 +69,7 @@ void AddDiagnosticsStrings(content::WebUIDataSource* html_source) {
{"dischargeTestResultText", IDS_DISCHARGE_TEST_RESULT},
{"hideReportText", IDS_DIAGNOSTICS_HIDE_REPORT_TEXT},
{"learnMore", IDS_DIANOSTICS_LEARN_MORE_LABEL},
{"learnMoreShort", IDS_DIAGNOSTICS_LEARN_MORE_LABEL_SHORT},
{"memoryRoutineText", IDS_DIAGNOSTICS_MEMORY_ROUTINE_TEXT},
{"memoryTitle", IDS_DIAGNOSTICS_MEMORY_TITLE},
{"percentageLabel", IDS_DIAGNOSTICS_PERCENTAGE_LABEL},
......
......@@ -31,6 +31,7 @@
<routine-section slot="routines" routines="[[routines_]]"
is-test-running="{{isTestRunning}}"
is-power-routine="true"
run-tests-button-text="[[getRunTestsButtonText_(
batteryChargeStatus_.powerAdapterStatus
)]]">
......
......@@ -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
* 'routine-result-entry' shows the status of a single test routine.
......@@ -73,27 +97,6 @@ Polymer({
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
*/
......@@ -103,7 +106,7 @@ Polymer({
}
if (this.item.result &&
this.getSimpleResult_(this.item.result) ===
getSimpleResult(this.item.result) ===
chromeos.diagnostics.mojom.StandardRoutineResult.kTestPassed) {
return loadTimeData.getString('testSucceededBadgeText');
}
......@@ -120,7 +123,7 @@ Polymer({
}
if (this.item.result &&
this.getSimpleResult_(this.item.result) ===
getSimpleResult(this.item.result) ===
chromeos.diagnostics.mojom.StandardRoutineResult.kTestPassed) {
return BadgeType.SUCCESS;
}
......
<style include="diagnostics-shared">
.learn-more-button {
background-color: rgba(var(--google-blue-600), .06);
border-radius: 5x;
height: 40px;
padding: 5px 10px;
}
.learn-more-button {
background-color: rgba(var(--google-blue-600), .06);
border-radius: 5x;
height: 40px;
padding: 5px 10px;
}
#learnMoreText {
color: var(--google-blue-600);
cursor: pointer;
}
</style>
<div id="routineSection">
......@@ -13,16 +18,20 @@
[[runTestsButtonText]]
</cr-button>
<cr-button id="toggleReportButton" class="action-button" on-click="onToggleReportClicked_"
hidden="[[isResultAndStatusHidden_(executionStatus_)]]">
hidden="[[isResultButtonHidden_(executionStatus_)]]">
[[getReportToggleButtonText_(isReportListHidden_)]]
</cr-button>
<text-badge id="testStatusBadge" badge-type="[[getBadgeType_(executionStatus_)]]"
hidden="[[isResultAndStatusHidden_(executionStatus_)]]"
hidden="[[isStatusHidden_(executionStatus_)]]"
value="[[getBadgeText_(executionStatus_)]]">
</text-badge>
<span id="testStatusText" hidden$="[[isResultAndStatusHidden_(executionStatus_)]]">
<span id="testStatusText" hidden$="[[isStatusHidden_(executionStatus_)]]">
[[getTextStatus_(executionStatus_, currentTestName_)]]
</span>
<span id="learnMoreText" hidden$="[[isLearnMoreHidden_(executionStatus_)]]"
on-click="onLearnMoreClicked_">
[[i18n('learnMoreShort')]]
</span>
<routine-result-list id="resultList" hidden="[[isReportListHidden_]]"></routine-result-list>
<cr-button id="learnMoreButton" class="learn-more-button" on-click="onLearnMoreClicked_"
hidden="[[isReportListHidden_]]">
......
......@@ -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 {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 {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';
/**
......@@ -85,6 +85,18 @@ Polymer({
value: true,
},
/** @type {boolean} */
isPowerRoutine: {
type: Boolean,
value: false,
},
/** @private {?PowerRoutineResult} */
powerRoutineResult_: {
type: Object,
value: null,
},
/** @type {string} */
runTestsButtonText: {
type: String,
......@@ -122,13 +134,17 @@ Polymer({
'routineNameText', getRoutineType(status.routine));
if (status.result &&
status.result.simpleResult !==
getSimpleResult(status.result) !==
chromeos.diagnostics.mojom.StandardRoutineResult
.kTestPassed) {
this.hasTestFailure_ = true;
}
resultListElem.onStatusUpdate.call(resultListElem, status);
if (status.result && status.result.powerResult) {
this.powerRoutineResult_ = status.result.powerResult;
}
})
.then(() => {
this.executionStatus_ = ExecutionProgress.kCompleted;
......@@ -160,7 +176,19 @@ Polymer({
},
/** @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;
},
......@@ -196,8 +224,27 @@ Polymer({
if (this.executionStatus_ === ExecutionProgress.kRunning) {
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 */
......
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