OLD | NEW |
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/system/chromeos/power/power_status.h" | 5 #include "ash/system/chromeos/power/power_status.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include <memory> |
| 8 |
8 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "third_party/cros_system_api/dbus/service_constants.h" | 12 #include "third_party/cros_system_api/dbus/service_constants.h" |
12 | 13 |
13 namespace ash { | 14 namespace ash { |
14 namespace { | 15 namespace { |
15 | 16 |
16 class TestObserver : public PowerStatus::Observer { | 17 class TestObserver : public PowerStatus::Observer { |
17 public: | 18 public: |
(...skipping 29 matching lines...) Expand all Loading... |
47 void TearDown() override { | 48 void TearDown() override { |
48 power_status_->RemoveObserver(test_observer_.get()); | 49 power_status_->RemoveObserver(test_observer_.get()); |
49 test_observer_.reset(); | 50 test_observer_.reset(); |
50 PowerStatus::Shutdown(); | 51 PowerStatus::Shutdown(); |
51 chromeos::DBusThreadManager::Shutdown(); | 52 chromeos::DBusThreadManager::Shutdown(); |
52 } | 53 } |
53 | 54 |
54 protected: | 55 protected: |
55 base::MessageLoopForUI message_loop_; | 56 base::MessageLoopForUI message_loop_; |
56 PowerStatus* power_status_; // Not owned. | 57 PowerStatus* power_status_; // Not owned. |
57 scoped_ptr<TestObserver> test_observer_; | 58 std::unique_ptr<TestObserver> test_observer_; |
58 | 59 |
59 private: | 60 private: |
60 DISALLOW_COPY_AND_ASSIGN(PowerStatusTest); | 61 DISALLOW_COPY_AND_ASSIGN(PowerStatusTest); |
61 }; | 62 }; |
62 | 63 |
63 TEST_F(PowerStatusTest, InitializeAndUpdate) { | 64 TEST_F(PowerStatusTest, InitializeAndUpdate) { |
64 // Test that the initial power supply state should be acquired after | 65 // Test that the initial power supply state should be acquired after |
65 // PowerStatus is instantiated. This depends on | 66 // PowerStatus is instantiated. This depends on |
66 // PowerManagerClientStubImpl, which responds to power status update | 67 // PowerManagerClientStubImpl, which responds to power status update |
67 // requests, pretends there is a battery present, and generates some valid | 68 // requests, pretends there is a battery present, and generates some valid |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 EXPECT_EQ(1, hours); | 143 EXPECT_EQ(1, hours); |
143 EXPECT_EQ(0, minutes); | 144 EXPECT_EQ(0, minutes); |
144 | 145 |
145 PowerStatus::SplitTimeIntoHoursAndMinutes( | 146 PowerStatus::SplitTimeIntoHoursAndMinutes( |
146 base::TimeDelta::FromSecondsD(3600.1), &hours, &minutes); | 147 base::TimeDelta::FromSecondsD(3600.1), &hours, &minutes); |
147 EXPECT_EQ(1, hours); | 148 EXPECT_EQ(1, hours); |
148 EXPECT_EQ(0, minutes); | 149 EXPECT_EQ(0, minutes); |
149 } | 150 } |
150 | 151 |
151 } // namespace ash | 152 } // namespace ash |
OLD | NEW |