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

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

Issue 3158014: Added tooltips to stats bar items. (Closed)
Patch Set: Fixed browser tests. Created 10 years, 4 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
« no previous file with comments | « chrome/browser/chromeos/status/power_menu_button.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/status/power_menu_button_browsertest.cc
diff --git a/chrome/browser/chromeos/status/power_menu_button_browsertest.cc b/chrome/browser/chromeos/status/power_menu_button_browsertest.cc
index d9d34c26a1d0de4f472447231ae0974c0d7ebcd3..66042fd1bb69c01fff39ccc2905df2cb070244ab 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++;
« no previous file with comments | « chrome/browser/chromeos/status/power_menu_button.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698