| 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 "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/cros_system_api/dbus/service_constants.h" | 11 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class TestObserver : public PowerStatus::Observer { | 16 class TestObserver : public PowerStatus::Observer { |
| 17 public: | 17 public: |
| 18 TestObserver() : power_changed_count_(0) {} | 18 TestObserver() : power_changed_count_(0) {} |
| 19 virtual ~TestObserver() {} | 19 virtual ~TestObserver() {} |
| 20 | 20 |
| 21 int power_changed_count() const { return power_changed_count_; } | 21 int power_changed_count() const { return power_changed_count_; } |
| 22 | 22 |
| 23 // PowerStatus::Observer overrides: | 23 // PowerStatus::Observer overrides: |
| 24 virtual void OnPowerStatusChanged() OVERRIDE { ++power_changed_count_; } | 24 virtual void OnPowerStatusChanged() override { ++power_changed_count_; } |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 int power_changed_count_; | 27 int power_changed_count_; |
| 28 | 28 |
| 29 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 29 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 class PowerStatusTest : public testing::Test { | 34 class PowerStatusTest : public testing::Test { |
| 35 public: | 35 public: |
| 36 PowerStatusTest() : power_status_(NULL) {} | 36 PowerStatusTest() : power_status_(NULL) {} |
| 37 virtual ~PowerStatusTest() {} | 37 virtual ~PowerStatusTest() {} |
| 38 | 38 |
| 39 virtual void SetUp() OVERRIDE { | 39 virtual void SetUp() override { |
| 40 chromeos::DBusThreadManager::Initialize(); | 40 chromeos::DBusThreadManager::Initialize(); |
| 41 PowerStatus::Initialize(); | 41 PowerStatus::Initialize(); |
| 42 power_status_ = PowerStatus::Get(); | 42 power_status_ = PowerStatus::Get(); |
| 43 test_observer_.reset(new TestObserver); | 43 test_observer_.reset(new TestObserver); |
| 44 power_status_->AddObserver(test_observer_.get()); | 44 power_status_->AddObserver(test_observer_.get()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 virtual void TearDown() OVERRIDE { | 47 virtual void TearDown() override { |
| 48 power_status_->RemoveObserver(test_observer_.get()); | 48 power_status_->RemoveObserver(test_observer_.get()); |
| 49 test_observer_.reset(); | 49 test_observer_.reset(); |
| 50 PowerStatus::Shutdown(); | 50 PowerStatus::Shutdown(); |
| 51 chromeos::DBusThreadManager::Shutdown(); | 51 chromeos::DBusThreadManager::Shutdown(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 protected: | 54 protected: |
| 55 base::MessageLoopForUI message_loop_; | 55 base::MessageLoopForUI message_loop_; |
| 56 PowerStatus* power_status_; // Not owned. | 56 PowerStatus* power_status_; // Not owned. |
| 57 scoped_ptr<TestObserver> test_observer_; | 57 scoped_ptr<TestObserver> test_observer_; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 EXPECT_EQ(1, hours); | 142 EXPECT_EQ(1, hours); |
| 143 EXPECT_EQ(0, minutes); | 143 EXPECT_EQ(0, minutes); |
| 144 | 144 |
| 145 PowerStatus::SplitTimeIntoHoursAndMinutes( | 145 PowerStatus::SplitTimeIntoHoursAndMinutes( |
| 146 base::TimeDelta::FromSecondsD(3600.1), &hours, &minutes); | 146 base::TimeDelta::FromSecondsD(3600.1), &hours, &minutes); |
| 147 EXPECT_EQ(1, hours); | 147 EXPECT_EQ(1, hours); |
| 148 EXPECT_EQ(0, minutes); | 148 EXPECT_EQ(0, minutes); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace ash | 151 } // namespace ash |
| OLD | NEW |