Skip to content

Commit

Permalink
Diagnostics: Fully charged battery warning state
Browse files Browse the repository at this point in the history
(cherry picked from commit a0c82ca)

Bug: 1183986
Test: browser_tests --gtest_filter=DiagnosticsApp*
Change-Id: I620497ba343e140fa9f768fae9d5d6a3840856da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2736971
Commit-Queue: Joon Ahn <joonbug@chromium.org>
Commit-Queue: Michael Checo <michaelcheco@google.com>
Reviewed-by: Joon Ahn <joonbug@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#859988}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2739306
Reviewed-by: Zentaro Kavanagh <zentaro@chromium.org>
Auto-Submit: Michael Checo <michaelcheco@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/4430@{#177}
Cr-Branched-From: e5ce7dc-refs/heads/master@{#857950}
  • Loading branch information
Michael Checo authored and Chromium LUCI CQ committed Mar 5, 2021
1 parent 0f76040 commit 4a21b97
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ export function batteryStatusCardTestSuite() {
routineSectionElement.additionalMessage,
loadTimeData.getString('batteryChargeTestFullMessage'));
assertTrue(isRunTestsButtonDisabled());
assertFalse(isVisible(getStatusBadge()));
assertFalse(isVisible(getStatusTextElement()));
assertTrue(isVisible(/** @type {!HTMLElement} */ (
routineSectionElement.$$('#messageIcon'))));
});
});

Expand Down
2 changes: 1 addition & 1 deletion chromeos/chromeos_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ Try tapping the mic to ask me anything.
<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_MAX_CLOCK_SPEED">$3<ex>3.90</ex></ph>GHz)
</message>
<message name="IDS_DIAGNOSTICS_BATTERY_FULL_MESSAGE" desc="The message shown when the battery is full and the charge test can not be run.">
Battery charge test cannot be conducted when full
To test battery charging rate, let your battery drain for a short period
</message>
<message name="IDS_DIAGNOSTICS_BATTERY_HEALTH_LABEL" desc="The label for a battery's health.">
Battery health
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5b528aea65cc7bedc36fa822a35464271622310a
fbbac56438e680794402341c202f17a5a4e6734d
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
batteryChargeStatus_.powerAdapterStatus
)]]"
additional-message="[[getRunTestsAdditionalMessage(
batteryChargeStatus_.batteryState)]]">
batteryChargeStatus_.chargeNowMilliampHours,
batteryHealth_.chargeFullNowMilliampHours)]]">
</routine-section>
</diagnostics-card>
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,20 @@ Polymer({

/** @protected */
getRunTestsAdditionalMessage() {
return this.batteryChargeStatus_.batteryState ===
chromeos.diagnostics.mojom.BatteryState.kFull ?
const batteryInfoMissing =
!this.batteryChargeStatus_ || !this.batteryHealth_;
const notCharging = this.batteryChargeStatus_.powerAdapterStatus ===
chromeos.diagnostics.mojom.ExternalPowerSource.kDisconnected;
if (notCharging || batteryInfoMissing) {
return '';
}

const disableRunButtonThreshold = 98;
const percentage = Math.round(
100 * this.batteryChargeStatus_.chargeNowMilliampHours /
this.batteryHealth_.chargeFullNowMilliampHours);

return percentage >= disableRunButtonThreshold ?
loadTimeData.getString('batteryChargeTestFullMessage') :
'';
},
Expand Down
5 changes: 0 additions & 5 deletions chromeos/components/diagnostics_ui/resources/icons.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@
<path d="M11 9.2L13.5 6.5L15 8L10 13L5 8L6.5 6.5L9 9.2V3H11V9.2Z" />
<path d="M6 15V13H4V15.375C4 16.2688 4.73125 17 5.625 17H14.375C15.2688 17 16 16.2688 16 15.375V13H14V15H6Z" />
</g>
<g id="warning">
<path d="M9 12H11V8H9V12Z" />
<path d="M11 15H9V13H11V15Z" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.13177 2.50386C9.51566 1.83205 10.4844 1.83205 10.8683 2.50386L18.8683 16.5039C19.2492 17.1705 18.7678 18 18 18H2.00001C1.23219 18 0.750823 17.1705 1.13177 16.5039L9.13177 2.50386ZM10 5.01556L3.72321 16H16.2768L10 5.01556Z" />
</g>
</defs>
</svg>
</iron-iconset-svg>
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,31 @@
margin-right: 8px;
}
</style>

<div class="routine-section-container">
<div id="routineSection" class="routine-container">
<div class="routine-status-container">
<text-badge id="testStatusBadge"
badge-type="[[badgeType_]]"
hidden="[[isStatusHidden_(executionStatus_, additionalMessage)]]"
hidden="[[isStatusHidden_(executionStatus_)]]"
value="[[badgeText_]]">
</text-badge>
<span id="testStatusText"
hidden$="[[isStatusHidden_(executionStatus_, additionalMessage)]]">
hidden$="[[isStatusHidden_(executionStatus_)]]">
[[statusText_]]
<span id="learnMoreText"
hidden$="[[isLearnMoreHidden_(executionStatus_)]]"
on-click="onLearnMoreClicked_">
[[i18n('learnMoreShort')]]
</span>
</span>
<div hidden$=[[isAdditionalMessageHidden_(additionalMessage)]]>
<iron-icon id="messageIcon" icon="diagnostics:warning"></iron-icon>
<span id="additionalMessage">
[[additionalMessage]]
</span>
</div>
</div>
<div class="button-container">
<iron-icon id="messageIcon" icon="cr:info-outline"
hidden$="[[isAdditionalMessageHidden_(additionalMessage)]]">
</iron-icon>
<paper-tooltip for="messageIcon" aria-hidden="true" id="additionalMessage">
[[additionalMessage]]
</paper-tooltip>
<cr-button id="toggleReportButton" on-click="onToggleReportClicked_"
hidden="[[isResultButtonHidden_(executionStatus_, routines.*)]]">
[[getReportToggleButtonText_(opened)]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'chrome://resources/cr_elements/icons.m.js';
import 'chrome://resources/polymer/v3_0/iron-collapse/iron-collapse.js';
import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';
import 'chrome://resources/polymer/v3_0/paper-tooltip/paper-tooltip.js';
import './diagnostics_card.js';
import './diagnostics_shared_css.js';
import './routine_result_list.js';
Expand Down Expand Up @@ -261,8 +263,7 @@ Polymer({

/** @protected */
isStatusHidden_() {
return this.executionStatus_ === ExecutionProgress.kNotStarted ||
this.additionalMessage != '';
return this.executionStatus_ === ExecutionProgress.kNotStarted;
},

/**
Expand Down Expand Up @@ -305,10 +306,6 @@ Polymer({

/** @protected */
routineStatusChanged_() {
if (this.additionalMessage != '') {
this.executionStatus_ = ExecutionProgress.kNotStarted;
}

switch (this.executionStatus_) {
case ExecutionProgress.kNotStarted:
// Do nothing since status is hidden when tests have not been started.
Expand Down

0 comments on commit 4a21b97

Please sign in to comment.