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

Side by Side Diff: ash/common/system/chromeos/power/power_status_unittest.cc

Issue 2770953003: Remove some pre-md code and assets. (Closed)
Patch Set: rebase Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ash/common/system/chromeos/power/power_status.h" 5 #include "ash/common/system/chromeos/power/power_status.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/resources/vector_icons/vector_icons.h"
9 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 11 #include "base/run_loop.h"
11 #include "chromeos/dbus/dbus_thread_manager.h" 12 #include "chromeos/dbus/dbus_thread_manager.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/cros_system_api/dbus/service_constants.h" 14 #include "third_party/cros_system_api/dbus/service_constants.h"
14 15
15 using power_manager::PowerSupplyProperties; 16 using power_manager::PowerSupplyProperties;
16 17
17 namespace ash { 18 namespace ash {
18 namespace { 19 namespace {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 power_status_->SetProtoForTesting(prop); 193 power_status_->SetProtoForTesting(prop);
193 EXPECT_NE(info_charging_98, 194 EXPECT_NE(info_charging_98,
194 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT)); 195 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT));
195 } 196 }
196 197
197 // Tests that the |icon_badge| member of BatteryImageInfo is set correctly 198 // Tests that the |icon_badge| member of BatteryImageInfo is set correctly
198 // with various power supply property values. 199 // with various power supply property values.
199 TEST_F(PowerStatusTest, BatteryImageInfoIconBadge) { 200 TEST_F(PowerStatusTest, BatteryImageInfoIconBadge) {
200 PowerSupplyProperties prop; 201 PowerSupplyProperties prop;
201 202
202 // A charging battery connected to AC power should have an ICON_BADGE_BOLT. 203 // A charging battery connected to AC power should have a bolt badge.
203 prop.set_external_power(PowerSupplyProperties::AC); 204 prop.set_external_power(PowerSupplyProperties::AC);
204 prop.set_battery_state(PowerSupplyProperties::CHARGING); 205 prop.set_battery_state(PowerSupplyProperties::CHARGING);
205 prop.set_battery_percent(98.0); 206 prop.set_battery_percent(98.0);
206 power_status_->SetProtoForTesting(prop); 207 power_status_->SetProtoForTesting(prop);
207 EXPECT_EQ( 208 EXPECT_EQ(
208 PowerStatus::ICON_BADGE_BOLT, 209 &kSystemTrayBatteryBoltIcon,
209 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge); 210 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge);
210 211
211 // A discharging battery connected to AC should also have an ICON_BADGE_BOLT. 212 // A discharging battery connected to AC should also have a bolt badge.
212 prop.set_battery_state(PowerSupplyProperties::DISCHARGING); 213 prop.set_battery_state(PowerSupplyProperties::DISCHARGING);
213 power_status_->SetProtoForTesting(prop); 214 power_status_->SetProtoForTesting(prop);
214 EXPECT_EQ( 215 EXPECT_EQ(
215 PowerStatus::ICON_BADGE_BOLT, 216 &kSystemTrayBatteryBoltIcon,
216 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge); 217 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge);
217 218
218 // A charging battery connected to USB power should have an 219 // A charging battery connected to USB power should have an
219 // ICON_BADGE_UNRELIABLE. 220 // unreliable badge.
220 prop.set_external_power(PowerSupplyProperties::USB); 221 prop.set_external_power(PowerSupplyProperties::USB);
221 prop.set_battery_state(PowerSupplyProperties::CHARGING); 222 prop.set_battery_state(PowerSupplyProperties::CHARGING);
222 power_status_->SetProtoForTesting(prop); 223 power_status_->SetProtoForTesting(prop);
223 EXPECT_EQ( 224 EXPECT_EQ(
224 PowerStatus::ICON_BADGE_UNRELIABLE, 225 &kSystemTrayBatteryUnreliableIcon,
225 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge); 226 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge);
226 227
227 // A discharging battery connected to USB power should also have an 228 // A discharging battery connected to USB power should also have an
228 // ICON_BADGE_UNRELIABLE. 229 // unreliable badge.
229 prop.set_battery_state(PowerSupplyProperties::DISCHARGING); 230 prop.set_battery_state(PowerSupplyProperties::DISCHARGING);
230 power_status_->SetProtoForTesting(prop); 231 power_status_->SetProtoForTesting(prop);
231 EXPECT_EQ( 232 EXPECT_EQ(
232 PowerStatus::ICON_BADGE_UNRELIABLE, 233 &kSystemTrayBatteryUnreliableIcon,
233 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge); 234 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge);
234 235
235 // Show an ICON_BADGE_X when no battery is present. 236 // Show the right icon when no battery is present.
236 prop.set_external_power(PowerSupplyProperties::DISCONNECTED); 237 prop.set_external_power(PowerSupplyProperties::DISCONNECTED);
237 prop.set_battery_state(PowerSupplyProperties::NOT_PRESENT); 238 prop.set_battery_state(PowerSupplyProperties::NOT_PRESENT);
238 power_status_->SetProtoForTesting(prop); 239 power_status_->SetProtoForTesting(prop);
239 EXPECT_EQ( 240 EXPECT_EQ(
240 PowerStatus::ICON_BADGE_X, 241 &kSystemTrayBatteryXIcon,
241 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge); 242 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge);
242 243
243 // Do not show a badge when the battery is discharging. 244 // Do not show a badge when the battery is discharging.
244 prop.set_battery_state(PowerSupplyProperties::DISCHARGING); 245 prop.set_battery_state(PowerSupplyProperties::DISCHARGING);
245 power_status_->SetProtoForTesting(prop); 246 power_status_->SetProtoForTesting(prop);
246 EXPECT_EQ( 247 EXPECT_EQ(
247 PowerStatus::ICON_BADGE_NONE, 248 nullptr,
248 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge); 249 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge);
249 250
250 // Show ICON_BADGE_ALERT for a discharging battery when it falls below 251 // Show the right icon for a discharging battery when it falls below
251 // a charge level of PowerStatus::kCriticalBatteryChargePercentageMd. 252 // a charge level of PowerStatus::kCriticalBatteryChargePercentage.
252 prop.set_battery_percent(PowerStatus::kCriticalBatteryChargePercentageMd); 253 prop.set_battery_percent(PowerStatus::kCriticalBatteryChargePercentage);
253 power_status_->SetProtoForTesting(prop); 254 power_status_->SetProtoForTesting(prop);
254 EXPECT_EQ( 255 EXPECT_EQ(
255 PowerStatus::ICON_BADGE_NONE, 256 nullptr,
256 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge); 257 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge);
257 prop.set_battery_percent(PowerStatus::kCriticalBatteryChargePercentageMd - 1); 258 prop.set_battery_percent(PowerStatus::kCriticalBatteryChargePercentage - 1);
258 power_status_->SetProtoForTesting(prop); 259 power_status_->SetProtoForTesting(prop);
259 EXPECT_EQ( 260 EXPECT_EQ(
260 PowerStatus::ICON_BADGE_ALERT, 261 &kSystemTrayBatteryAlertIcon,
261 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge); 262 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).icon_badge);
262 } 263 }
263 264
264 // Tests that the |charge_level| member of BatteryImageInfo is set correctly 265 // Tests that the |charge_level| member of BatteryImageInfo is set correctly
265 // with various power supply property values. 266 // with various power supply property values.
266 TEST_F(PowerStatusTest, BatteryImageInfoChargeLevel) { 267 TEST_F(PowerStatusTest, BatteryImageInfoChargeLevel) {
267 PowerSupplyProperties prop; 268 PowerSupplyProperties prop;
268 269
269 // No charge level is drawn when the battery is not present. 270 // No charge level is drawn when the battery is not present.
270 prop.set_external_power(PowerSupplyProperties::DISCONNECTED); 271 prop.set_external_power(PowerSupplyProperties::DISCONNECTED);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 11, 311 11,
311 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).charge_level); 312 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).charge_level);
312 prop.set_battery_percent(100.0); 313 prop.set_battery_percent(100.0);
313 power_status_->SetProtoForTesting(prop); 314 power_status_->SetProtoForTesting(prop);
314 EXPECT_EQ( 315 EXPECT_EQ(
315 12, 316 12,
316 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).charge_level); 317 power_status_->GetBatteryImageInfo(PowerStatus::ICON_LIGHT).charge_level);
317 } 318 }
318 319
319 } // namespace ash 320 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/power/power_status.cc ('k') | ash/common/system/chromeos/session/tray_session_length_limit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698