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 "chromeos/power/power_manager_handler.h" | 5 #include "chromeos/power/power_manager_handler.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 power_handler_->AddObserver(test_observer_.get()); | 66 power_handler_->AddObserver(test_observer_.get()); |
67 } | 67 } |
68 | 68 |
69 virtual void TearDown() OVERRIDE { | 69 virtual void TearDown() OVERRIDE { |
70 power_handler_.reset(); | 70 power_handler_.reset(); |
71 test_observer_.reset(); | 71 test_observer_.reset(); |
72 DBusThreadManager::Shutdown(); | 72 DBusThreadManager::Shutdown(); |
73 } | 73 } |
74 | 74 |
75 protected: | 75 protected: |
76 MessageLoopForUI message_loop_; | 76 base::MessageLoopForUI message_loop_; |
77 scoped_ptr<PowerManagerHandler> power_handler_; | 77 scoped_ptr<PowerManagerHandler> power_handler_; |
78 scoped_ptr<TestObserver> test_observer_; | 78 scoped_ptr<TestObserver> test_observer_; |
79 | 79 |
80 private: | 80 private: |
81 DISALLOW_COPY_AND_ASSIGN(PowerManagerHandlerTest); | 81 DISALLOW_COPY_AND_ASSIGN(PowerManagerHandlerTest); |
82 }; | 82 }; |
83 | 83 |
84 TEST_F(PowerManagerHandlerTest, PowerManagerInitializeAndUpdate) { | 84 TEST_F(PowerManagerHandlerTest, PowerManagerInitializeAndUpdate) { |
85 // Test that the initial power supply state should be acquired after | 85 // Test that the initial power supply state should be acquired after |
86 // PowerManagerHandler is instantiated. This depends on | 86 // PowerManagerHandler is instantiated. This depends on |
87 // PowerManagerClientStubImpl, which responds to power status update | 87 // PowerManagerClientStubImpl, which responds to power status update |
88 // requests, pretends there is a battery present, and generate some | 88 // requests, pretends there is a battery present, and generate some |
89 // valid power supply status data. | 89 // valid power supply status data. |
90 message_loop_.RunUntilIdle(); | 90 message_loop_.RunUntilIdle(); |
91 EXPECT_EQ(test_observer_->power_changed_count(), 0); | 91 EXPECT_EQ(test_observer_->power_changed_count(), 0); |
92 PowerSupplyStatus init_status = power_handler_->GetPowerSupplyStatus(); | 92 PowerSupplyStatus init_status = power_handler_->GetPowerSupplyStatus(); |
93 ValidatePowerSupplyStatus(init_status); | 93 ValidatePowerSupplyStatus(init_status); |
94 | 94 |
95 // Test RequestUpdate, test_obsever_ should be notified for power suuply | 95 // Test RequestUpdate, test_obsever_ should be notified for power suuply |
96 // status change. | 96 // status change. |
97 power_handler_->RequestStatusUpdate(); | 97 power_handler_->RequestStatusUpdate(); |
98 message_loop_.RunUntilIdle(); | 98 message_loop_.RunUntilIdle(); |
99 EXPECT_GE(test_observer_->power_changed_count(), 1); | 99 EXPECT_GE(test_observer_->power_changed_count(), 1); |
100 } | 100 } |
101 | 101 |
102 } // namespace chromeos | 102 } // namespace chromeos |
OLD | NEW |