Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6053)

Unified Diff: chrome/browser/chromeos/status/power_menu_button.cc

Issue 1338003: Add test for power_menu_button. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/status/power_menu_button.cc
===================================================================
--- chrome/browser/chromeos/status/power_menu_button.cc (revision 42551)
+++ chrome/browser/chromeos/status/power_menu_button.cc (working copy)
@@ -22,7 +22,8 @@
PowerMenuButton::PowerMenuButton()
: StatusAreaButton(this),
- ALLOW_THIS_IN_INITIALIZER_LIST(power_menu_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(power_menu_(this)),
+ icon_id_(-1) {
UpdateIcon();
CrosLibrary::Get()->GetPowerLibrary()->AddObserver(this);
}
@@ -123,12 +124,12 @@
void PowerMenuButton::UpdateIcon() {
PowerLibrary* cros = CrosLibrary::Get()->GetPowerLibrary();
- int id = IDR_STATUSBAR_BATTERY_UNKNOWN;
+ icon_id_ = IDR_STATUSBAR_BATTERY_UNKNOWN;
if (CrosLibrary::Get()->EnsureLoaded()) {
if (!cros->battery_is_present()) {
- id = IDR_STATUSBAR_BATTERY_MISSING;
+ icon_id_ = IDR_STATUSBAR_BATTERY_MISSING;
} else if (cros->line_power_on() && cros->battery_fully_charged()) {
- id = IDR_STATUSBAR_BATTERY_CHARGED;
+ icon_id_ = IDR_STATUSBAR_BATTERY_CHARGED;
} else {
// If fully charged, always show 100% even if percentage is a bit less.
double percent = cros->battery_fully_charged() ? 100 :
@@ -143,12 +144,12 @@
if (index >= kNumPowerImages)
index = kNumPowerImages - 1;
if (cros->line_power_on())
- id = IDR_STATUSBAR_BATTERY_CHARGING_1 + index;
+ icon_id_ = IDR_STATUSBAR_BATTERY_CHARGING_1 + index;
else
- id = IDR_STATUSBAR_BATTERY_DISCHARGING_1 + index;
+ icon_id_ = IDR_STATUSBAR_BATTERY_DISCHARGING_1 + index;
}
}
- SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed(id));
+ SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed(icon_id_));
SchedulePaint();
}

Powered by Google App Engine
This is Rietveld 408576698