GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / device / battery / battery_status_manager_win_unittest.cc
blob3dd18751a99be36467c9765cf43aaff0fabdab67
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "device/battery/battery_status_manager_win.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace device {
11 namespace {
13 TEST(BatteryStatusManagerWinTest, ACLineStatusOffline) {
14 SYSTEM_POWER_STATUS win_status;
15 win_status.ACLineStatus = WIN_AC_LINE_STATUS_OFFLINE;
16 win_status.BatteryLifePercent = 100;
17 win_status.BatteryLifeTime = 200;
19 BatteryStatus status = ComputeWebBatteryStatus(win_status);
20 EXPECT_FALSE(status.charging);
21 EXPECT_EQ(std::numeric_limits<double>::infinity(), status.charging_time);
22 EXPECT_EQ(200, status.discharging_time);
23 EXPECT_EQ(1, status.level);
26 TEST(BatteryStatusManagerWinTest, ACLineStatusOfflineDischargingTimeUnknown) {
27 SYSTEM_POWER_STATUS win_status;
28 win_status.ACLineStatus = WIN_AC_LINE_STATUS_OFFLINE;
29 win_status.BatteryLifePercent = 100;
30 win_status.BatteryLifeTime = (DWORD)-1;
32 BatteryStatus status = ComputeWebBatteryStatus(win_status);
33 EXPECT_FALSE(status.charging);
34 EXPECT_EQ(std::numeric_limits<double>::infinity(), status.charging_time);
35 EXPECT_EQ(std::numeric_limits<double>::infinity(), status.discharging_time);
36 EXPECT_EQ(1, status.level);
39 TEST(BatteryStatusManagerWinTest, ACLineStatusOnline) {
40 SYSTEM_POWER_STATUS win_status;
41 win_status.ACLineStatus = WIN_AC_LINE_STATUS_ONLINE;
42 win_status.BatteryLifePercent = 50;
43 win_status.BatteryLifeTime = 200;
45 BatteryStatus status = ComputeWebBatteryStatus(win_status);
46 EXPECT_TRUE(status.charging);
47 EXPECT_EQ(std::numeric_limits<double>::infinity(), status.charging_time);
48 EXPECT_EQ(std::numeric_limits<double>::infinity(), status.discharging_time);
49 EXPECT_EQ(.5, status.level);
52 TEST(BatteryStatusManagerWinTest, ACLineStatusOnlineFullBattery) {
53 SYSTEM_POWER_STATUS win_status;
54 win_status.ACLineStatus = WIN_AC_LINE_STATUS_ONLINE;
55 win_status.BatteryLifePercent = 100;
56 win_status.BatteryLifeTime = 200;
58 BatteryStatus status = ComputeWebBatteryStatus(win_status);
59 EXPECT_TRUE(status.charging);
60 EXPECT_EQ(0, status.charging_time);
61 EXPECT_EQ(std::numeric_limits<double>::infinity(), status.discharging_time);
62 EXPECT_EQ(1, status.level);
65 TEST(BatteryStatusManagerWinTest, ACLineStatusUnknown) {
66 SYSTEM_POWER_STATUS win_status;
67 win_status.ACLineStatus = WIN_AC_LINE_STATUS_UNKNOWN;
68 win_status.BatteryLifePercent = 50;
69 win_status.BatteryLifeTime = 200;
71 BatteryStatus status = ComputeWebBatteryStatus(win_status);
72 EXPECT_TRUE(status.charging);
73 EXPECT_EQ(std::numeric_limits<double>::infinity(), status.charging_time);
74 EXPECT_EQ(std::numeric_limits<double>::infinity(), status.discharging_time);
75 EXPECT_EQ(.5, status.level);
78 } // namespace
80 } // namespace device