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

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

Issue 2795823002: Remove pre-MD code from PowerStatusView. (Closed)
Patch Set: . Created 3 years, 8 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 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/strings/grit/ash_strings.h" 8 #include "ash/strings/grit/ash_strings.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" 10 #include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
11 #include "ui/base/l10n/l10n_util.h" 11 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/base/l10n/time_format.h" 12 #include "ui/base/l10n/time_format.h"
13 #include "ui/gfx/image/image_skia.h"
14 #include "ui/views/controls/image_view.h"
15 #include "ui/views/controls/label.h" 13 #include "ui/views/controls/label.h"
16 14
17 using power_manager::PowerSupplyProperties; 15 using power_manager::PowerSupplyProperties;
18 16
19 namespace ash { 17 namespace ash {
20 18
21 class PowerStatusViewTest : public test::AshTestBase { 19 class PowerStatusViewTest : public test::AshTestBase {
22 public: 20 public:
23 PowerStatusViewTest() {} 21 PowerStatusViewTest() {}
24 ~PowerStatusViewTest() override {} 22 ~PowerStatusViewTest() override {}
25 23
26 // Overridden from testing::Test: 24 // Overridden from testing::Test:
27 void SetUp() override { 25 void SetUp() override {
28 test::AshTestBase::SetUp(); 26 test::AshTestBase::SetUp();
29 view_.reset(new PowerStatusView(false)); 27 view_.reset(new PowerStatusView());
30 } 28 }
31 29
32 void TearDown() override { 30 void TearDown() override {
33 view_.reset(); 31 view_.reset();
34 test::AshTestBase::TearDown(); 32 test::AshTestBase::TearDown();
35 } 33 }
36 34
37 protected: 35 protected:
38 void UpdatePowerStatus(const power_manager::PowerSupplyProperties& proto) { 36 void UpdatePowerStatus(const power_manager::PowerSupplyProperties& proto) {
39 PowerStatus::Get()->SetProtoForTesting(proto); 37 PowerStatus::Get()->SetProtoForTesting(proto);
40 view_->OnPowerStatusChanged(); 38 view_->OnPowerStatusChanged();
41 } 39 }
42 40
43 bool IsPercentageVisible() const { 41 bool IsPercentageVisible() const {
44 return view_->percentage_label_->visible(); 42 return view_->percentage_label_->visible();
45 } 43 }
46 44
47 bool IsTimeStatusVisible() const { 45 bool IsTimeStatusVisible() const {
48 return view_->time_status_label_->visible(); 46 return view_->time_status_label_->visible();
49 } 47 }
50 48
51 base::string16 RemainingTimeInView() const { 49 base::string16 RemainingTimeInView() const {
52 return view_->time_status_label_->text(); 50 return view_->time_status_label_->text();
53 } 51 }
54 52
55 gfx::ImageSkia GetBatteryImage() const { return view_->icon_->GetImage(); }
56
57 private: 53 private:
58 std::unique_ptr<PowerStatusView> view_; 54 std::unique_ptr<PowerStatusView> view_;
59 55
60 DISALLOW_COPY_AND_ASSIGN(PowerStatusViewTest); 56 DISALLOW_COPY_AND_ASSIGN(PowerStatusViewTest);
61 }; 57 };
62 58
63 TEST_F(PowerStatusViewTest, Basic) { 59 TEST_F(PowerStatusViewTest, Basic) {
64 EXPECT_FALSE(IsPercentageVisible()); 60 EXPECT_FALSE(IsPercentageVisible());
65 EXPECT_TRUE(IsTimeStatusVisible()); 61 EXPECT_TRUE(IsTimeStatusVisible());
66 62
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // on production though. 106 // on production though.
111 prop.set_external_power(PowerSupplyProperties::AC); 107 prop.set_external_power(PowerSupplyProperties::AC);
112 prop.set_battery_state(PowerSupplyProperties::DISCHARGING); 108 prop.set_battery_state(PowerSupplyProperties::DISCHARGING);
113 prop.set_battery_time_to_full_sec(120); 109 prop.set_battery_time_to_full_sec(120);
114 UpdatePowerStatus(prop); 110 UpdatePowerStatus(prop);
115 EXPECT_TRUE(IsPercentageVisible()); 111 EXPECT_TRUE(IsPercentageVisible());
116 EXPECT_FALSE(IsTimeStatusVisible()); 112 EXPECT_FALSE(IsTimeStatusVisible());
117 } 113 }
118 114
119 } // namespace ash 115 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698