| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_view.h" | 5 #include "ash/common/system/chromeos/power/power_status_view.h" |
| 6 | 6 |
| 7 #include "ash/common/system/chromeos/power/power_status.h" | 7 #include "ash/common/system/chromeos/power/power_status.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" | 9 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" |
| 10 #include "grit/ash_strings.h" | 10 #include "grit/ash_strings.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 EXPECT_TRUE(IsPercentageVisible()); | 76 EXPECT_TRUE(IsPercentageVisible()); |
| 77 EXPECT_TRUE(IsTimeStatusVisible()); | 77 EXPECT_TRUE(IsTimeStatusVisible()); |
| 78 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING), | 78 EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING), |
| 79 RemainingTimeInView()); | 79 RemainingTimeInView()); |
| 80 | 80 |
| 81 prop.set_is_calculating_battery_time(false); | 81 prop.set_is_calculating_battery_time(false); |
| 82 UpdatePowerStatus(prop); | 82 UpdatePowerStatus(prop); |
| 83 EXPECT_NE(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING), | 83 EXPECT_NE(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING), |
| 84 RemainingTimeInView()); | 84 RemainingTimeInView()); |
| 85 EXPECT_NE( | 85 EXPECT_NE(l10n_util::GetStringUTF16( |
| 86 l10n_util::GetStringUTF16( | 86 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE), |
| 87 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE), | 87 RemainingTimeInView()); |
| 88 RemainingTimeInView()); | |
| 89 | 88 |
| 90 prop.set_external_power(PowerSupplyProperties::AC); | 89 prop.set_external_power(PowerSupplyProperties::AC); |
| 91 prop.set_battery_state(PowerSupplyProperties::CHARGING); | 90 prop.set_battery_state(PowerSupplyProperties::CHARGING); |
| 92 prop.set_battery_time_to_full_sec(120); | 91 prop.set_battery_time_to_full_sec(120); |
| 93 UpdatePowerStatus(prop); | 92 UpdatePowerStatus(prop); |
| 94 EXPECT_TRUE(IsPercentageVisible()); | 93 EXPECT_TRUE(IsPercentageVisible()); |
| 95 EXPECT_TRUE(IsTimeStatusVisible()); | 94 EXPECT_TRUE(IsTimeStatusVisible()); |
| 96 EXPECT_NE(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING), | 95 EXPECT_NE(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING), |
| 97 RemainingTimeInView()); | 96 RemainingTimeInView()); |
| 98 EXPECT_NE( | 97 EXPECT_NE(l10n_util::GetStringUTF16( |
| 99 l10n_util::GetStringUTF16( | 98 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE), |
| 100 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE), | 99 RemainingTimeInView()); |
| 101 RemainingTimeInView()); | |
| 102 | 100 |
| 103 prop.set_external_power(PowerSupplyProperties::USB); | 101 prop.set_external_power(PowerSupplyProperties::USB); |
| 104 UpdatePowerStatus(prop); | 102 UpdatePowerStatus(prop); |
| 105 EXPECT_TRUE(IsPercentageVisible()); | 103 EXPECT_TRUE(IsPercentageVisible()); |
| 106 EXPECT_TRUE(IsTimeStatusVisible()); | 104 EXPECT_TRUE(IsTimeStatusVisible()); |
| 107 EXPECT_EQ( | 105 EXPECT_EQ(l10n_util::GetStringUTF16( |
| 108 l10n_util::GetStringUTF16( | 106 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE), |
| 109 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE), | 107 RemainingTimeInView()); |
| 110 RemainingTimeInView()); | |
| 111 | 108 |
| 112 // Tricky -- connected to non-USB but still discharging. Not likely happening | 109 // Tricky -- connected to non-USB but still discharging. Not likely happening |
| 113 // on production though. | 110 // on production though. |
| 114 prop.set_external_power(PowerSupplyProperties::AC); | 111 prop.set_external_power(PowerSupplyProperties::AC); |
| 115 prop.set_battery_state(PowerSupplyProperties::DISCHARGING); | 112 prop.set_battery_state(PowerSupplyProperties::DISCHARGING); |
| 116 prop.set_battery_time_to_full_sec(120); | 113 prop.set_battery_time_to_full_sec(120); |
| 117 UpdatePowerStatus(prop); | 114 UpdatePowerStatus(prop); |
| 118 EXPECT_TRUE(IsPercentageVisible()); | 115 EXPECT_TRUE(IsPercentageVisible()); |
| 119 EXPECT_FALSE(IsTimeStatusVisible()); | 116 EXPECT_FALSE(IsTimeStatusVisible()); |
| 120 } | 117 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 136 UpdatePowerStatus(prop); | 133 UpdatePowerStatus(prop); |
| 137 EXPECT_EQ(original_image.bitmap(), GetBatteryImage().bitmap()); | 134 EXPECT_EQ(original_image.bitmap(), GetBatteryImage().bitmap()); |
| 138 | 135 |
| 139 // Make a big change to the percentage and check that a new image is used. | 136 // Make a big change to the percentage and check that a new image is used. |
| 140 prop.set_battery_percent(100.0); | 137 prop.set_battery_percent(100.0); |
| 141 UpdatePowerStatus(prop); | 138 UpdatePowerStatus(prop); |
| 142 EXPECT_NE(original_image.bitmap(), GetBatteryImage().bitmap()); | 139 EXPECT_NE(original_image.bitmap(), GetBatteryImage().bitmap()); |
| 143 } | 140 } |
| 144 | 141 |
| 145 } // namespace ash | 142 } // namespace ash |
| OLD | NEW |