| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/test/power_monitor_test_base.h" | 8 #include "base/test/power_monitor_test_base.h" |
| 9 #include "device/power_monitor/power_monitor_message_broadcaster.h" | 9 #include "device/power_monitor/power_monitor_message_broadcaster.h" |
| 10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 private: | 55 private: |
| 56 base::MessageLoop message_loop_; | 56 base::MessageLoop message_loop_; |
| 57 base::PowerMonitorTestSource* power_monitor_source_; | 57 base::PowerMonitorTestSource* power_monitor_source_; |
| 58 std::unique_ptr<base::PowerMonitor> power_monitor_; | 58 std::unique_ptr<base::PowerMonitor> power_monitor_; |
| 59 | 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(PowerMonitorMessageBroadcasterTest); | 60 DISALLOW_COPY_AND_ASSIGN(PowerMonitorMessageBroadcasterTest); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 TEST_F(PowerMonitorMessageBroadcasterTest, PowerMessageBroadcast) { | 63 TEST_F(PowerMonitorMessageBroadcasterTest, PowerMessageBroadcast) { |
| 64 device::mojom::PowerMonitorClientPtr proxy; | 64 device::mojom::PowerMonitorClientPtr proxy; |
| 65 FakePowerMonitorClient client(mojo::GetProxy(&proxy)); | 65 FakePowerMonitorClient client(mojo::MakeRequest(&proxy)); |
| 66 PowerMonitorMessageBroadcaster broadcaster; | 66 PowerMonitorMessageBroadcaster broadcaster; |
| 67 | 67 |
| 68 // Calling SetClient should invoke a power state change. | 68 // Calling SetClient should invoke a power state change. |
| 69 broadcaster.SetClient(std::move(proxy)); | 69 broadcaster.SetClient(std::move(proxy)); |
| 70 | 70 |
| 71 base::RunLoop().RunUntilIdle(); | 71 base::RunLoop().RunUntilIdle(); |
| 72 EXPECT_EQ(client.power_state_changes(), 1); | 72 EXPECT_EQ(client.power_state_changes(), 1); |
| 73 | 73 |
| 74 // Sending resume when not suspended should have no effect. | 74 // Sending resume when not suspended should have no effect. |
| 75 source()->GenerateResumeEvent(); | 75 source()->GenerateResumeEvent(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 102 // Pretend the device has gone off battery power | 102 // Pretend the device has gone off battery power |
| 103 source()->GeneratePowerStateEvent(false); | 103 source()->GeneratePowerStateEvent(false); |
| 104 EXPECT_EQ(client.power_state_changes(), 3); | 104 EXPECT_EQ(client.power_state_changes(), 3); |
| 105 | 105 |
| 106 // Repeated indications the device is off battery power should be suppressed. | 106 // Repeated indications the device is off battery power should be suppressed. |
| 107 source()->GeneratePowerStateEvent(false); | 107 source()->GeneratePowerStateEvent(false); |
| 108 EXPECT_EQ(client.power_state_changes(), 3); | 108 EXPECT_EQ(client.power_state_changes(), 3); |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace device | 111 } // namespace device |
| OLD | NEW |