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

Unified Diff: ash/system/chromeos/power/power_status_view_unittest.cc

Issue 1014753003: Move low battery notification to Message Center. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/chromeos/power/power_status_view.cc ('k') | ash/system/chromeos/power/tray_power.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/chromeos/power/power_status_view_unittest.cc
diff --git a/ash/system/chromeos/power/power_status_view_unittest.cc b/ash/system/chromeos/power/power_status_view_unittest.cc
index ebbb1a9c7df21339809edecc0bb8c98b20f59c42..dee352ae82f8067a1b7455134e79860fcd827408 100644
--- a/ash/system/chromeos/power/power_status_view_unittest.cc
+++ b/ash/system/chromeos/power/power_status_view_unittest.cc
@@ -24,7 +24,7 @@ class PowerStatusViewTest : public test::AshTestBase {
// Overridden from testing::Test:
void SetUp() override {
test::AshTestBase::SetUp();
- view_.reset(new PowerStatusView(GetViewType(), false));
+ view_.reset(new PowerStatusView(false));
}
void TearDown() override {
@@ -33,69 +33,30 @@ class PowerStatusViewTest : public test::AshTestBase {
}
protected:
- virtual PowerStatusView::ViewType GetViewType() = 0;
- PowerStatusView* view() { return view_.get(); }
-
void UpdatePowerStatus(const power_manager::PowerSupplyProperties& proto) {
PowerStatus::Get()->SetProtoForTesting(proto);
view_->OnPowerStatusChanged();
}
- private:
- scoped_ptr<PowerStatusView> view_;
-
- DISALLOW_COPY_AND_ASSIGN(PowerStatusViewTest);
-};
-
-class PowerStatusDefaultViewTest : public PowerStatusViewTest {
- public:
- PowerStatusDefaultViewTest() {}
- ~PowerStatusDefaultViewTest() override {}
-
- protected:
- PowerStatusView::ViewType GetViewType() override {
- return PowerStatusView::VIEW_DEFAULT;
- }
-
- bool IsPercentageVisible() {
- return view()->percentage_label_->visible();
+ bool IsPercentageVisible() const {
+ return view_->percentage_label_->visible();
}
- bool IsTimeStatusVisible() {
- return view()->time_status_label_->visible();
+ bool IsTimeStatusVisible() const {
+ return view_->time_status_label_->visible();
}
- base::string16 RemainingTimeInView() {
- return view()->time_status_label_->text();
+ base::string16 RemainingTimeInView() const {
+ return view_->time_status_label_->text();
}
private:
- DISALLOW_COPY_AND_ASSIGN(PowerStatusDefaultViewTest);
-};
-
-class PowerStatusNotificationViewTest : public PowerStatusViewTest {
- public:
- PowerStatusNotificationViewTest() {}
- ~PowerStatusNotificationViewTest() override {}
-
- protected:
- PowerStatusView::ViewType GetViewType() override {
- return PowerStatusView::VIEW_NOTIFICATION;
- }
-
- base::string16 StatusInView() {
- return view()->status_label_->text();
- }
-
- base::string16 RemainingTimeInView() {
- return view()->time_label_->text();
- }
+ scoped_ptr<PowerStatusView> view_;
- private:
- DISALLOW_COPY_AND_ASSIGN(PowerStatusNotificationViewTest);
+ DISALLOW_COPY_AND_ASSIGN(PowerStatusViewTest);
};
-TEST_F(PowerStatusDefaultViewTest, Basic) {
+TEST_F(PowerStatusViewTest, Basic) {
EXPECT_FALSE(IsPercentageVisible());
EXPECT_TRUE(IsTimeStatusVisible());
@@ -154,61 +115,4 @@ TEST_F(PowerStatusDefaultViewTest, Basic) {
EXPECT_FALSE(IsTimeStatusVisible());
}
-TEST_F(PowerStatusNotificationViewTest, Basic) {
- EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_FULL),
- StatusInView());
- EXPECT_TRUE(RemainingTimeInView().empty());
-
- // Disconnect the power.
- PowerSupplyProperties prop;
- prop.set_external_power(PowerSupplyProperties::DISCONNECTED);
- prop.set_battery_state(PowerSupplyProperties::DISCHARGING);
- prop.set_battery_percent(99.0);
- prop.set_battery_time_to_empty_sec(125);
- prop.set_is_calculating_battery_time(true);
- UpdatePowerStatus(prop);
-
- EXPECT_NE(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_FULL),
- StatusInView());
- EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING),
- RemainingTimeInView());
-
- prop.set_is_calculating_battery_time(false);
- UpdatePowerStatus(prop);
- // Low power warning has to be calculated by ui::TimeFormat, but ignore
- // seconds.
- EXPECT_EQ(ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_REMAINING,
- ui::TimeFormat::LENGTH_LONG,
- base::TimeDelta::FromMinutes(2)),
- RemainingTimeInView());
-
- prop.set_external_power(PowerSupplyProperties::AC);
- prop.set_battery_state(PowerSupplyProperties::CHARGING);
- prop.set_battery_time_to_full_sec(120);
- UpdatePowerStatus(prop);
- EXPECT_NE(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_FULL),
- StatusInView());
- // Charging time is somehow using another format?
- EXPECT_NE(ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_REMAINING,
- ui::TimeFormat::LENGTH_LONG,
- base::TimeDelta::FromMinutes(2)),
- RemainingTimeInView());
-
- // Unreliable connection.
- prop.set_external_power(PowerSupplyProperties::USB);
- UpdatePowerStatus(prop);
- EXPECT_EQ(
- l10n_util::GetStringUTF16(
- IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE),
- RemainingTimeInView());
-
- // Tricky -- connected to non-USB but still discharging. Not likely happening
- // on production though.
- prop.set_external_power(PowerSupplyProperties::AC);
- prop.set_battery_state(PowerSupplyProperties::DISCHARGING);
- prop.set_battery_time_to_full_sec(120);
- UpdatePowerStatus(prop);
- EXPECT_TRUE(RemainingTimeInView().empty());
-}
-
} // namespace ash
« no previous file with comments | « ash/system/chromeos/power/power_status_view.cc ('k') | ash/system/chromeos/power/tray_power.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698