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

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

Issue 2955010: Fix browser test broken by resource ID ordering change. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | « no previous file | 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
===================================================================
--- chrome/browser/chromeos/status/power_menu_button_browsertest.cc (revision 52197)
+++ chrome/browser/chromeos/status/power_menu_button_browsertest.cc (working copy)
@@ -59,8 +59,7 @@
EXPECT_EQ(IDR_STATUSBAR_BATTERY_CHARGED, CallPowerChangedAndGetIconId());
}
-// http://crbug.com/48912
-IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, FAILS_BatteryChargingTest) {
+IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryChargingTest) {
EXPECT_CALL(*mock_power_library_, battery_is_present())
.WillRepeatedly((Return(true)));
EXPECT_CALL(*mock_power_library_, battery_fully_charged())
@@ -69,17 +68,33 @@
.WillRepeatedly((Return(true)));
// Test the 12 battery charging states.
- int id = IDR_STATUSBAR_BATTERY_CHARGING_1;
- for (float precent = 6.0; precent < 100.0; precent += 8.0) {
+ // 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[] = {
+ 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,
+ };
+ size_t id = 0;
+ for (float percent = 6.0; percent < 100.0; percent += 8.0) {
EXPECT_CALL(*mock_power_library_, battery_percentage())
- .WillRepeatedly((Return(precent)));
- EXPECT_EQ(id, CallPowerChangedAndGetIconId());
+ .WillRepeatedly((Return(percent)));
+ EXPECT_EQ(kChargingImages[id], CallPowerChangedAndGetIconId());
id++;
+ ASSERT_LT(id, arraysize(kChargingImages));
}
}
-// http://crbug.com/48912
-IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, FAILS_BatteryDischargingTest) {
+IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryDischargingTest) {
EXPECT_CALL(*mock_power_library_, battery_is_present())
.WillRepeatedly((Return(true)));
EXPECT_CALL(*mock_power_library_, battery_fully_charged())
@@ -88,12 +103,29 @@
.WillRepeatedly((Return(false)));
// Test the 12 battery discharing states.
- int id = IDR_STATUSBAR_BATTERY_DISCHARGING_1;
- for (float precent = 6.0; precent < 100.0; precent += 8.0) {
+ // NOTE: Use an array rather than just calculating a resource number to avoid
+ // creating implicit ordering dependencies on the resource values.
+ static const int kDischargingImages[] = {
+ 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,
+ };
+ size_t id = 0;
+ for (float percent = 6.0; percent < 100.0; percent += 8.0) {
EXPECT_CALL(*mock_power_library_, battery_percentage())
- .WillRepeatedly((Return(precent)));
- EXPECT_EQ(id, CallPowerChangedAndGetIconId());
+ .WillRepeatedly((Return(percent)));
+ EXPECT_EQ(kDischargingImages[id], CallPowerChangedAndGetIconId());
id++;
+ ASSERT_LT(id, arraysize(kDischargingImages));
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698