summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd15
-rw-r--r--chrome/browser/chromeos/cros/cros_mock.cc12
-rw-r--r--chrome/browser/chromeos/login/login_browsertest.cc2
-rw-r--r--chrome/browser/chromeos/status/clock_menu_button.cc4
-rw-r--r--chrome/browser/chromeos/status/feedback_menu_button.cc2
-rw-r--r--chrome/browser/chromeos/status/network_menu_button.cc28
-rw-r--r--chrome/browser/chromeos/status/power_menu_button.cc141
-rw-r--r--chrome/browser/chromeos/status/power_menu_button.h16
-rw-r--r--chrome/browser/chromeos/status/power_menu_button_browsertest.cc84
9 files changed, 218 insertions, 86 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 86ed366..141fcbf 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -9180,6 +9180,21 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_STATUSBAR_BATTERY_IS_CHARGED" desc="In the power menu button, the battery is charged message.">
Battery is charged
</message>
+ <message name="IDS_STATUSBAR_FEEDBACK_TOOLTIP" desc="Tooltip for the feedback status bar icon.">
+ Report a bug.
+ </message>
+ <message name="IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP" desc="Tooltip for the network menu status bar icon when no network is connected.">
+ No network
+ </message>
+ <message name="IDS_STATUSBAR_NETWORK_CONNECTING_TOOLTIP" desc="Tooltip for the network menu status bar icon when connecting to a network.">
+ Connecting to: <ph name="NAME">$1<ex>GoogleGuest</ex></ph>
+ </message>
+ <message name="IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP" desc="Tooltip for the network menu status bar icon when connected to a network.">
+ Network: <ph name="NAME">$1<ex>GoogleGuest</ex></ph>
+ </message>
+ <message name="IDS_STATUSBAR_CLOCK_TOOLTIP" desc="Tooltip for the clock in the status bar.">
+ <ph name="DATE">$1<ex>Aug 16, 2010</ex></ph>
+ </message>
<message name="IDS_VERSION_FIELD_PREFIX" desc="Display the OS version to the user.">
OS version
</message>
diff --git a/chrome/browser/chromeos/cros/cros_mock.cc b/chrome/browser/chromeos/cros/cros_mock.cc
index e1e4d52..74e3048 100644
--- a/chrome/browser/chromeos/cros/cros_mock.cc
+++ b/chrome/browser/chromeos/cros/cros_mock.cc
@@ -308,7 +308,7 @@ void CrosMock::SetPowerLibraryStatusAreaExpectations() {
.Times(1)
.RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, battery_fully_charged())
- .Times(3)
+ .Times(1)
.WillRepeatedly((Return(false)))
.RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, battery_is_present())
@@ -316,16 +316,20 @@ void CrosMock::SetPowerLibraryStatusAreaExpectations() {
.WillOnce((Return(true)))
.RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, battery_percentage())
- .Times(2)
+ .Times(1)
.WillRepeatedly((Return(42.0)))
.RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, line_power_on())
- .Times(4)
+ .Times(1)
.WillRepeatedly((Return(false)))
.RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, battery_time_to_empty())
.Times(1)
- .WillOnce((Return(base::TimeDelta::FromMinutes(42))))
+ .WillRepeatedly((Return(base::TimeDelta::FromMinutes(42))))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_time_to_full())
+ .Times(1)
+ .WillRepeatedly((Return(base::TimeDelta::FromMinutes(24))))
.RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, RemoveObserver(_))
.Times(1)
diff --git a/chrome/browser/chromeos/login/login_browsertest.cc b/chrome/browser/chromeos/login/login_browsertest.cc
index a4c4804..003261f 100644
--- a/chrome/browser/chromeos/login/login_browsertest.cc
+++ b/chrome/browser/chromeos/login/login_browsertest.cc
@@ -50,6 +50,8 @@ class LoginTestBase : public InProcessBrowserTest {
testApi_->SetPowerLibrary(&mock_power_library_, false);
EXPECT_CALL(mock_power_library_, battery_time_to_empty())
.WillRepeatedly((Return(base::TimeDelta::FromMinutes(42))));
+ EXPECT_CALL(mock_power_library_, battery_time_to_full())
+ .WillRepeatedly((Return(base::TimeDelta::FromMinutes(24))));
testApi_->SetSynapticsLibrary(&mock_synaptics_library_, false);
testApi_->SetCryptohomeLibrary(&mock_cryptohome_library_, false);
diff --git a/chrome/browser/chromeos/status/clock_menu_button.cc b/chrome/browser/chromeos/status/clock_menu_button.cc
index 434f323..f63593f 100644
--- a/chrome/browser/chromeos/status/clock_menu_button.cc
+++ b/chrome/browser/chromeos/status/clock_menu_button.cc
@@ -70,7 +70,9 @@ void ClockMenuButton::UpdateTextAndSetNextTimer() {
}
void ClockMenuButton::UpdateText() {
- SetText(base::TimeFormatTimeOfDay(base::Time::Now()));
+ base::Time time(base::Time::Now());
+ SetText(base::TimeFormatTimeOfDay(time));
+ SetTooltipText(base::TimeFormatShortDate(time));
SchedulePaint();
}
diff --git a/chrome/browser/chromeos/status/feedback_menu_button.cc b/chrome/browser/chromeos/status/feedback_menu_button.cc
index 1b8ead6..d3b14d3 100644
--- a/chrome/browser/chromeos/status/feedback_menu_button.cc
+++ b/chrome/browser/chromeos/status/feedback_menu_button.cc
@@ -6,6 +6,7 @@
#include <string>
+#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/chromeos/status/status_area_host.h"
@@ -22,6 +23,7 @@ FeedbackMenuButton::FeedbackMenuButton(StatusAreaHost* host)
: StatusAreaButton(this),
host_(host) {
DCHECK(host_);
+ SetTooltipText(l10n_util::GetString(IDS_STATUSBAR_FEEDBACK_TOOLTIP));
}
FeedbackMenuButton::~FeedbackMenuButton() {
diff --git a/chrome/browser/chromeos/status/network_menu_button.cc b/chrome/browser/chromeos/status/network_menu_button.cc
index 0070038..11e39fb 100644
--- a/chrome/browser/chromeos/status/network_menu_button.cc
+++ b/chrome/browser/chromeos/status/network_menu_button.cc
@@ -236,19 +236,37 @@ void NetworkMenuButton::NetworkChanged(NetworkLibrary* cros) {
animation_connecting_.StartThrobbing(std::numeric_limits<int>::max());
SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS1));
}
+ std::string network_name = cros->wifi_connecting() ?
+ cros->wifi_name() : cros->cellular_name();
+ SetTooltipText(
+ l10n_util::GetStringF(IDS_STATUSBAR_NETWORK_CONNECTING_TOOLTIP,
+ UTF8ToWide(network_name)));
} else {
// Stop connecting animation since we are not connecting.
animation_connecting_.Stop();
// Always show the higher priority connection first. Ethernet then wifi.
- if (cros->ethernet_connected())
+ if (cros->ethernet_connected()) {
SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED));
- else if (cros->wifi_connected())
+ SetTooltipText(
+ l10n_util::GetStringF(
+ IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP,
+ l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET)));
+ } else if (cros->wifi_connected()) {
SetIcon(IconForNetworkStrength(cros->wifi_strength(), false));
- else if (cros->cellular_connected())
+ SetTooltipText(l10n_util::GetStringF(
+ IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP,
+ UTF8ToWide(cros->wifi_name())));
+ } else if (cros->cellular_connected()) {
SetIcon(IconForNetworkStrength(cros->cellular_strength(), false));
- else
+ SetTooltipText(l10n_util::GetStringF(
+ IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP,
+ UTF8ToWide(cros->cellular_name())));
+ } else {
SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0));
+ SetTooltipText(l10n_util::GetString(
+ IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP));
+ }
}
if (!cros->Connected() && !cros->Connecting()) {
@@ -264,6 +282,8 @@ void NetworkMenuButton::NetworkChanged(NetworkLibrary* cros) {
} else {
SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0));
SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_WARNING));
+ SetTooltipText(l10n_util::GetString(
+ IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP));
}
SchedulePaint();
diff --git a/chrome/browser/chromeos/status/power_menu_button.cc b/chrome/browser/chromeos/status/power_menu_button.cc
index 98fb75e..98cda08 100644
--- a/chrome/browser/chromeos/status/power_menu_button.cc
+++ b/chrome/browser/chromeos/status/power_menu_button.cc
@@ -25,8 +25,12 @@ const int PowerMenuButton::kNumPowerImages = 12;
PowerMenuButton::PowerMenuButton()
: StatusAreaButton(this),
ALLOW_THIS_IN_INITIALIZER_LIST(power_menu_(this)),
+ battery_is_present_(false),
+ line_power_on_(false),
+ battery_fully_charged_(false),
+ battery_percentage_(0.0),
icon_id_(-1) {
- UpdateIcon();
+ UpdateIconAndLabelInfo();
CrosLibrary::Get()->GetPowerLibrary()->AddObserver(this);
}
@@ -46,28 +50,24 @@ menus::MenuModel::ItemType PowerMenuButton::GetTypeAt(int index) const {
}
string16 PowerMenuButton::GetLabelAt(int index) const {
- PowerLibrary* cros = CrosLibrary::Get()->GetPowerLibrary();
// The first item shows the percentage of battery left.
if (index == 0) {
- // If fully charged, always show 100% even if internal number is a bit less.
- double percent = cros->battery_fully_charged() ? 100 :
- cros->battery_percentage();
return l10n_util::GetStringFUTF16(IDS_STATUSBAR_BATTERY_PERCENTAGE,
- base::IntToString16(static_cast<int>(percent)));
+ base::IntToString16(static_cast<int>(battery_percentage_)));
}
// The second item shows the battery is charged if it is.
- if (cros->battery_fully_charged())
+ if (battery_fully_charged_)
return l10n_util::GetStringUTF16(IDS_STATUSBAR_BATTERY_IS_CHARGED);
// If battery is in an intermediate charge state, we show how much time left.
- base::TimeDelta time = cros->line_power_on() ? cros->battery_time_to_full() :
- cros->battery_time_to_empty();
+ base::TimeDelta time = line_power_on_ ? battery_time_to_full_ :
+ battery_time_to_empty_;
if (time.InSeconds() == 0) {
// If time is 0, then that means we are still calculating how much time.
// Depending if line power is on, we either show a message saying that we
// are calculating time until full or calculating remaining time.
- int msg = cros->line_power_on() ?
+ int msg = line_power_on_ ?
IDS_STATUSBAR_BATTERY_CALCULATING_TIME_UNTIL_FULL :
IDS_STATUSBAR_BATTERY_CALCULATING_TIME_UNTIL_EMPTY;
return l10n_util::GetStringUTF16(msg);
@@ -75,8 +75,8 @@ string16 PowerMenuButton::GetLabelAt(int index) const {
// Depending if line power is on, we either show a message saying XX:YY
// until full or XX:YY remaining where XX is number of hours and YY is
// number of minutes.
- int msg = cros->line_power_on() ? IDS_STATUSBAR_BATTERY_TIME_UNTIL_FULL :
- IDS_STATUSBAR_BATTERY_TIME_UNTIL_EMPTY;
+ int msg = line_power_on_ ? IDS_STATUSBAR_BATTERY_TIME_UNTIL_FULL :
+ IDS_STATUSBAR_BATTERY_TIME_UNTIL_EMPTY;
int hour = time.InHours();
int min = (time - base::TimeDelta::FromHours(hour)).InMinutes();
string16 hour_str = base::IntToString16(hour);
@@ -101,7 +101,7 @@ void PowerMenuButton::RunMenu(views::View* source, const gfx::Point& pt) {
// PowerMenuButton, PowerLibrary::Observer implementation:
void PowerMenuButton::PowerChanged(PowerLibrary* obj) {
- UpdateIcon();
+ UpdateIconAndLabelInfo();
}
////////////////////////////////////////////////////////////////////////////////
@@ -122,59 +122,74 @@ void PowerMenuButton::DrawPowerIcon(gfx::Canvas* canvas, SkBitmap icon) {
canvas->DrawBitmapInt(icon, 0, kIconVerticalPadding);
}
-void PowerMenuButton::UpdateIcon() {
+void PowerMenuButton::UpdateIconAndLabelInfo() {
PowerLibrary* cros = CrosLibrary::Get()->GetPowerLibrary();
- icon_id_ = IDR_STATUSBAR_BATTERY_UNKNOWN;
- if (CrosLibrary::Get()->EnsureLoaded()) {
- if (!cros->battery_is_present()) {
- icon_id_ = IDR_STATUSBAR_BATTERY_MISSING;
- } else if (cros->line_power_on() && cros->battery_fully_charged()) {
- icon_id_ = IDR_STATUSBAR_BATTERY_CHARGED;
- } else {
- // Get the power image depending on battery percentage. Percentage is
- // from 0 to 100, so we need to convert that to 0 to kNumPowerImages - 1.
- // NOTE: Use an array rather than just calculating a resource number to
- // avoid creating implicit ordering dependencies on the resource values.
- static const int kChargingImages[kNumPowerImages] = {
- IDR_STATUSBAR_BATTERY_CHARGING_1,
- IDR_STATUSBAR_BATTERY_CHARGING_2,
- IDR_STATUSBAR_BATTERY_CHARGING_3,
- IDR_STATUSBAR_BATTERY_CHARGING_4,
- IDR_STATUSBAR_BATTERY_CHARGING_5,
- IDR_STATUSBAR_BATTERY_CHARGING_6,
- IDR_STATUSBAR_BATTERY_CHARGING_7,
- IDR_STATUSBAR_BATTERY_CHARGING_8,
- IDR_STATUSBAR_BATTERY_CHARGING_9,
- IDR_STATUSBAR_BATTERY_CHARGING_10,
- IDR_STATUSBAR_BATTERY_CHARGING_11,
- IDR_STATUSBAR_BATTERY_CHARGING_12,
- };
- static const int kDischargingImages[kNumPowerImages] = {
- IDR_STATUSBAR_BATTERY_DISCHARGING_1,
- IDR_STATUSBAR_BATTERY_DISCHARGING_2,
- IDR_STATUSBAR_BATTERY_DISCHARGING_3,
- IDR_STATUSBAR_BATTERY_DISCHARGING_4,
- IDR_STATUSBAR_BATTERY_DISCHARGING_5,
- IDR_STATUSBAR_BATTERY_DISCHARGING_6,
- IDR_STATUSBAR_BATTERY_DISCHARGING_7,
- IDR_STATUSBAR_BATTERY_DISCHARGING_8,
- IDR_STATUSBAR_BATTERY_DISCHARGING_9,
- IDR_STATUSBAR_BATTERY_DISCHARGING_10,
- IDR_STATUSBAR_BATTERY_DISCHARGING_11,
- IDR_STATUSBAR_BATTERY_DISCHARGING_12,
- };
-
- // If fully charged, always show 100% even if percentage is a bit less.
- double percent = cros->battery_fully_charged() ?
- 100 : cros->battery_percentage();
- int index = static_cast<int>(percent / 100.0 *
- nextafter(static_cast<float>(kNumPowerImages), 0));
- index = std::max(std::min(index, kNumPowerImages - 1), 0);
- icon_id_ = cros->line_power_on() ?
- kChargingImages[index] : kDischargingImages[index];
- }
+ if (!cros)
+ return;
+
+ bool cros_loaded = CrosLibrary::Get()->EnsureLoaded();
+ if (cros_loaded) {
+ battery_is_present_ = cros->battery_is_present();
+ line_power_on_ = cros->line_power_on();
+ battery_fully_charged_ = cros->battery_fully_charged();
+ battery_percentage_ = cros->battery_percentage();
+ // If fully charged, always show 100% even if internal number is a bit less.
+ // Note: we always call cros->battery_percentage() for test predictability.
+ if (battery_fully_charged_)
+ battery_percentage_ = 100.0;
+ battery_time_to_full_ = cros->battery_time_to_full();
+ battery_time_to_empty_ = cros->battery_time_to_empty();
}
+
+ if (!cros_loaded) {
+ icon_id_ = IDR_STATUSBAR_BATTERY_UNKNOWN;
+ } else if (!battery_is_present_) {
+ icon_id_ = IDR_STATUSBAR_BATTERY_MISSING;
+ } else if (line_power_on_ && battery_fully_charged_) {
+ icon_id_ = IDR_STATUSBAR_BATTERY_CHARGED;
+ } else {
+ // Get the power image depending on battery percentage. Percentage is
+ // from 0 to 100, so we need to convert that to 0 to kNumPowerImages - 1.
+ // NOTE: Use an array rather than just calculating a resource number to
+ // avoid creating implicit ordering dependencies on the resource values.
+ static const int kChargingImages[kNumPowerImages] = {
+ IDR_STATUSBAR_BATTERY_CHARGING_1,
+ IDR_STATUSBAR_BATTERY_CHARGING_2,
+ IDR_STATUSBAR_BATTERY_CHARGING_3,
+ IDR_STATUSBAR_BATTERY_CHARGING_4,
+ IDR_STATUSBAR_BATTERY_CHARGING_5,
+ IDR_STATUSBAR_BATTERY_CHARGING_6,
+ IDR_STATUSBAR_BATTERY_CHARGING_7,
+ IDR_STATUSBAR_BATTERY_CHARGING_8,
+ IDR_STATUSBAR_BATTERY_CHARGING_9,
+ IDR_STATUSBAR_BATTERY_CHARGING_10,
+ IDR_STATUSBAR_BATTERY_CHARGING_11,
+ IDR_STATUSBAR_BATTERY_CHARGING_12,
+ };
+ static const int kDischargingImages[kNumPowerImages] = {
+ IDR_STATUSBAR_BATTERY_DISCHARGING_1,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_2,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_3,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_4,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_5,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_6,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_7,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_8,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_9,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_10,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_11,
+ IDR_STATUSBAR_BATTERY_DISCHARGING_12,
+ };
+
+ int index = static_cast<int>(battery_percentage_ / 100.0 *
+ nextafter(static_cast<float>(kNumPowerImages), 0));
+ index = std::max(std::min(index, kNumPowerImages - 1), 0);
+ icon_id_ = line_power_on_ ?
+ kChargingImages[index] : kDischargingImages[index];
+ }
+
SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed(icon_id_));
+ SetTooltipText(UTF16ToWide(GetLabelAt(0)));
SchedulePaint();
}
diff --git a/chrome/browser/chromeos/status/power_menu_button.h b/chrome/browser/chromeos/status/power_menu_button.h
index 7cc5520..abf758a 100644
--- a/chrome/browser/chromeos/status/power_menu_button.h
+++ b/chrome/browser/chromeos/status/power_menu_button.h
@@ -12,6 +12,10 @@
#include "views/controls/menu/menu_2.h"
#include "views/controls/menu/view_menu_delegate.h"
+namespace base {
+class TimeDelta;
+}
+
class SkBitmap;
namespace chromeos {
@@ -64,8 +68,8 @@ class PowerMenuButton : public StatusAreaButton,
// This method will draw the |icon| in the appropriate place on the |canvas|.
void DrawPowerIcon(gfx::Canvas* canvas, SkBitmap icon);
- // Update the power icon depending on the power status.
- void UpdateIcon();
+ // Update the power icon and menu label info depending on the power status.
+ void UpdateIconAndLabelInfo();
// The number of power images.
static const int kNumPowerImages;
@@ -73,6 +77,14 @@ class PowerMenuButton : public StatusAreaButton,
// The power menu.
views::Menu2 power_menu_;
+ // Stored data gathered CrosLibrary::PowerLibrary.
+ bool battery_is_present_;
+ bool line_power_on_;
+ bool battery_fully_charged_;
+ double battery_percentage_;
+ base::TimeDelta battery_time_to_full_;
+ base::TimeDelta battery_time_to_empty_;
+
// The currently showing icon bitmap id.
int icon_id_;
diff --git a/chrome/browser/chromeos/status/power_menu_button_browsertest.cc b/chrome/browser/chromeos/status/power_menu_button_browsertest.cc
index d9d34c2..66042fd 100644
--- a/chrome/browser/chromeos/status/power_menu_button_browsertest.cc
+++ b/chrome/browser/chromeos/status/power_menu_button_browsertest.cc
@@ -50,27 +50,70 @@ class PowerMenuButtonTest : public CrosInProcessBrowserTest {
IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryMissingTest) {
EXPECT_CALL(*mock_power_library_, battery_is_present())
- .WillRepeatedly((Return(false)));
+ .WillOnce((Return(false))) // no battery
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_percentage())
+ .WillOnce((Return(42.0)))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_fully_charged())
+ .WillOnce((Return(false)))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, line_power_on())
+ .WillOnce((Return(false)))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_time_to_empty())
+ .WillOnce((Return(base::TimeDelta::FromMinutes(42))))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_time_to_full())
+ .WillOnce((Return(base::TimeDelta::FromMinutes(24))))
+ .RetiresOnSaturation();
EXPECT_EQ(IDR_STATUSBAR_BATTERY_MISSING, CallPowerChangedAndGetIconId());
}
IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryChargedTest) {
EXPECT_CALL(*mock_power_library_, battery_is_present())
- .WillRepeatedly((Return(true)));
+ .WillOnce((Return(true)))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_percentage())
+ .WillOnce((Return(42.0)))
+ .RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, battery_fully_charged())
- .WillRepeatedly((Return(true)));
+ .WillOnce((Return(true))) // fully charged
+ .RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, line_power_on())
- .WillRepeatedly((Return(true)));
+ .WillOnce((Return(true))) // plugged in
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_time_to_empty())
+ .WillOnce((Return(base::TimeDelta::FromMinutes(42))))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_time_to_full())
+ .WillOnce((Return(base::TimeDelta::FromMinutes(0))))
+ .RetiresOnSaturation();
EXPECT_EQ(IDR_STATUSBAR_BATTERY_CHARGED, CallPowerChangedAndGetIconId());
}
IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryChargingTest) {
+ const int NUM_TIMES = 12; // 6 + 8*12 = 102
EXPECT_CALL(*mock_power_library_, battery_is_present())
- .WillRepeatedly((Return(true)));
+ .Times(NUM_TIMES)
+ .WillRepeatedly((Return(true)))
+ .RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, battery_fully_charged())
- .WillRepeatedly((Return(false)));
+ .Times(NUM_TIMES)
+ .WillRepeatedly((Return(false)))
+ .RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, line_power_on())
- .WillRepeatedly((Return(true)));
+ .Times(NUM_TIMES)
+ .WillRepeatedly((Return(true))) // plugged in
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_time_to_empty())
+ .Times(NUM_TIMES)
+ .WillRepeatedly((Return(base::TimeDelta::FromMinutes(42))))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_time_to_full())
+ .Times(NUM_TIMES)
+ .WillRepeatedly((Return(base::TimeDelta::FromMinutes(24))))
+ .RetiresOnSaturation();
// Test the 12 battery charging states.
// NOTE: Use an array rather than just calculating a resource number to avoid
@@ -92,7 +135,8 @@ IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryChargingTest) {
size_t id = 0;
for (float percent = 6.0; percent < 100.0; percent += 8.0) {
EXPECT_CALL(*mock_power_library_, battery_percentage())
- .WillRepeatedly((Return(percent)));
+ .WillOnce((Return(percent)))
+ .RetiresOnSaturation();
ASSERT_LT(id, arraysize(kChargingImages));
EXPECT_EQ(kChargingImages[id], CallPowerChangedAndGetIconId());
id++;
@@ -100,12 +144,27 @@ IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryChargingTest) {
}
IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryDischargingTest) {
+ const int NUM_TIMES = 12; // 6 + 8*12 = 102
EXPECT_CALL(*mock_power_library_, battery_is_present())
- .WillRepeatedly((Return(true)));
+ .Times(NUM_TIMES)
+ .WillRepeatedly((Return(true)))
+ .RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, battery_fully_charged())
- .WillRepeatedly((Return(false)));
+ .Times(NUM_TIMES)
+ .WillRepeatedly((Return(false)))
+ .RetiresOnSaturation();
EXPECT_CALL(*mock_power_library_, line_power_on())
- .WillRepeatedly((Return(false)));
+ .Times(NUM_TIMES)
+ .WillRepeatedly((Return(false)))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_time_to_empty())
+ .Times(NUM_TIMES)
+ .WillRepeatedly((Return(base::TimeDelta::FromMinutes(42))))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*mock_power_library_, battery_time_to_full())
+ .Times(NUM_TIMES)
+ .WillRepeatedly((Return(base::TimeDelta::FromMinutes(24))))
+ .RetiresOnSaturation();
// Test the 12 battery discharing states.
// NOTE: Use an array rather than just calculating a resource number to avoid
@@ -127,7 +186,8 @@ IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryDischargingTest) {
size_t id = 0;
for (float percent = 6.0; percent < 100.0; percent += 8.0) {
EXPECT_CALL(*mock_power_library_, battery_percentage())
- .WillRepeatedly((Return(percent)));
+ .WillOnce((Return(percent)))
+ .RetiresOnSaturation();
ASSERT_LT(id, arraysize(kDischargingImages));
EXPECT_EQ(kDischargingImages[id], CallPowerChangedAndGetIconId());
id++;