OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/status/power_menu_button.h" | 5 #include "chrome/browser/chromeos/status/power_menu_button.h" |
6 | 6 |
7 #include "chrome/browser/browser.h" | 7 #include "chrome/browser/browser.h" |
8 #include "chrome/browser/browser_window.h" | 8 #include "chrome/browser/browser_window.h" |
9 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" | 9 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" |
10 #include "chrome/browser/chromeos/cros/mock_power_library.h" | 10 #include "chrome/browser/chromeos/cros/mock_power_library.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryChargedTest) { | 52 IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryChargedTest) { |
53 EXPECT_CALL(*mock_power_library_, battery_is_present()) | 53 EXPECT_CALL(*mock_power_library_, battery_is_present()) |
54 .WillRepeatedly((Return(true))); | 54 .WillRepeatedly((Return(true))); |
55 EXPECT_CALL(*mock_power_library_, battery_fully_charged()) | 55 EXPECT_CALL(*mock_power_library_, battery_fully_charged()) |
56 .WillRepeatedly((Return(true))); | 56 .WillRepeatedly((Return(true))); |
57 EXPECT_CALL(*mock_power_library_, line_power_on()) | 57 EXPECT_CALL(*mock_power_library_, line_power_on()) |
58 .WillRepeatedly((Return(true))); | 58 .WillRepeatedly((Return(true))); |
59 EXPECT_EQ(IDR_STATUSBAR_BATTERY_CHARGED, CallPowerChangedAndGetIconId()); | 59 EXPECT_EQ(IDR_STATUSBAR_BATTERY_CHARGED, CallPowerChangedAndGetIconId()); |
60 } | 60 } |
61 | 61 |
62 // http://crbug.com/48912 | 62 IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryChargingTest) { |
63 IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, FAILS_BatteryChargingTest) { | |
64 EXPECT_CALL(*mock_power_library_, battery_is_present()) | 63 EXPECT_CALL(*mock_power_library_, battery_is_present()) |
65 .WillRepeatedly((Return(true))); | 64 .WillRepeatedly((Return(true))); |
66 EXPECT_CALL(*mock_power_library_, battery_fully_charged()) | 65 EXPECT_CALL(*mock_power_library_, battery_fully_charged()) |
67 .WillRepeatedly((Return(false))); | 66 .WillRepeatedly((Return(false))); |
68 EXPECT_CALL(*mock_power_library_, line_power_on()) | 67 EXPECT_CALL(*mock_power_library_, line_power_on()) |
69 .WillRepeatedly((Return(true))); | 68 .WillRepeatedly((Return(true))); |
70 | 69 |
71 // Test the 12 battery charging states. | 70 // Test the 12 battery charging states. |
72 int id = IDR_STATUSBAR_BATTERY_CHARGING_1; | 71 // NOTE: Use an array rather than just calculating a resource number to avoid |
73 for (float precent = 6.0; precent < 100.0; precent += 8.0) { | 72 // creating implicit ordering dependencies on the resource values. |
| 73 static const int kChargingImages[] = { |
| 74 IDR_STATUSBAR_BATTERY_CHARGING_1, |
| 75 IDR_STATUSBAR_BATTERY_CHARGING_2, |
| 76 IDR_STATUSBAR_BATTERY_CHARGING_3, |
| 77 IDR_STATUSBAR_BATTERY_CHARGING_4, |
| 78 IDR_STATUSBAR_BATTERY_CHARGING_5, |
| 79 IDR_STATUSBAR_BATTERY_CHARGING_6, |
| 80 IDR_STATUSBAR_BATTERY_CHARGING_7, |
| 81 IDR_STATUSBAR_BATTERY_CHARGING_8, |
| 82 IDR_STATUSBAR_BATTERY_CHARGING_9, |
| 83 IDR_STATUSBAR_BATTERY_CHARGING_10, |
| 84 IDR_STATUSBAR_BATTERY_CHARGING_11, |
| 85 IDR_STATUSBAR_BATTERY_CHARGING_12, |
| 86 }; |
| 87 size_t id = 0; |
| 88 for (float percent = 6.0; percent < 100.0; percent += 8.0) { |
74 EXPECT_CALL(*mock_power_library_, battery_percentage()) | 89 EXPECT_CALL(*mock_power_library_, battery_percentage()) |
75 .WillRepeatedly((Return(precent))); | 90 .WillRepeatedly((Return(percent))); |
76 EXPECT_EQ(id, CallPowerChangedAndGetIconId()); | 91 EXPECT_EQ(kChargingImages[id], CallPowerChangedAndGetIconId()); |
77 id++; | 92 id++; |
| 93 ASSERT_LT(id, arraysize(kChargingImages)); |
78 } | 94 } |
79 } | 95 } |
80 | 96 |
81 // http://crbug.com/48912 | 97 IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, BatteryDischargingTest) { |
82 IN_PROC_BROWSER_TEST_F(PowerMenuButtonTest, FAILS_BatteryDischargingTest) { | |
83 EXPECT_CALL(*mock_power_library_, battery_is_present()) | 98 EXPECT_CALL(*mock_power_library_, battery_is_present()) |
84 .WillRepeatedly((Return(true))); | 99 .WillRepeatedly((Return(true))); |
85 EXPECT_CALL(*mock_power_library_, battery_fully_charged()) | 100 EXPECT_CALL(*mock_power_library_, battery_fully_charged()) |
86 .WillRepeatedly((Return(false))); | 101 .WillRepeatedly((Return(false))); |
87 EXPECT_CALL(*mock_power_library_, line_power_on()) | 102 EXPECT_CALL(*mock_power_library_, line_power_on()) |
88 .WillRepeatedly((Return(false))); | 103 .WillRepeatedly((Return(false))); |
89 | 104 |
90 // Test the 12 battery discharing states. | 105 // Test the 12 battery discharing states. |
91 int id = IDR_STATUSBAR_BATTERY_DISCHARGING_1; | 106 // NOTE: Use an array rather than just calculating a resource number to avoid |
92 for (float precent = 6.0; precent < 100.0; precent += 8.0) { | 107 // creating implicit ordering dependencies on the resource values. |
| 108 static const int kDischargingImages[] = { |
| 109 IDR_STATUSBAR_BATTERY_DISCHARGING_1, |
| 110 IDR_STATUSBAR_BATTERY_DISCHARGING_2, |
| 111 IDR_STATUSBAR_BATTERY_DISCHARGING_3, |
| 112 IDR_STATUSBAR_BATTERY_DISCHARGING_4, |
| 113 IDR_STATUSBAR_BATTERY_DISCHARGING_5, |
| 114 IDR_STATUSBAR_BATTERY_DISCHARGING_6, |
| 115 IDR_STATUSBAR_BATTERY_DISCHARGING_7, |
| 116 IDR_STATUSBAR_BATTERY_DISCHARGING_8, |
| 117 IDR_STATUSBAR_BATTERY_DISCHARGING_9, |
| 118 IDR_STATUSBAR_BATTERY_DISCHARGING_10, |
| 119 IDR_STATUSBAR_BATTERY_DISCHARGING_11, |
| 120 IDR_STATUSBAR_BATTERY_DISCHARGING_12, |
| 121 }; |
| 122 size_t id = 0; |
| 123 for (float percent = 6.0; percent < 100.0; percent += 8.0) { |
93 EXPECT_CALL(*mock_power_library_, battery_percentage()) | 124 EXPECT_CALL(*mock_power_library_, battery_percentage()) |
94 .WillRepeatedly((Return(precent))); | 125 .WillRepeatedly((Return(percent))); |
95 EXPECT_EQ(id, CallPowerChangedAndGetIconId()); | 126 EXPECT_EQ(kDischargingImages[id], CallPowerChangedAndGetIconId()); |
96 id++; | 127 id++; |
| 128 ASSERT_LT(id, arraysize(kDischargingImages)); |
97 } | 129 } |
98 } | 130 } |
99 | 131 |
100 } // namespace chromeos | 132 } // namespace chromeos |
OLD | NEW |