| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/dbus/services/service_provider_test_helper.h" | 5 #include "chromeos/dbus/services/service_provider_test_helper.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/run_loop.h" |
| 10 #include "dbus/message.h" | 11 #include "dbus/message.h" |
| 11 #include "dbus/mock_bus.h" | 12 #include "dbus/mock_bus.h" |
| 12 #include "third_party/cros_system_api/dbus/service_constants.h" | 13 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 13 | 14 |
| 14 using ::testing::_; | 15 using ::testing::_; |
| 15 using ::testing::AllOf; | 16 using ::testing::AllOf; |
| 16 using ::testing::Invoke; | 17 using ::testing::Invoke; |
| 17 using ::testing::ResultOf; | 18 using ::testing::ResultOf; |
| 18 using ::testing::Return; | 19 using ::testing::Return; |
| 19 using ::testing::Unused; | 20 using ::testing::Unused; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // dbus_message_new_method_return() won't emit a warning. | 127 // dbus_message_new_method_return() won't emit a warning. |
| 127 method_call->SetSerial(1); | 128 method_call->SetSerial(1); |
| 128 // Run the callback captured in MockExportMethod(). In addition to returning | 129 // Run the callback captured in MockExportMethod(). In addition to returning |
| 129 // a response that the caller will ignore, this will send a signal, which | 130 // a response that the caller will ignore, this will send a signal, which |
| 130 // will be received by |on_signal_callback_|. | 131 // will be received by |on_signal_callback_|. |
| 131 method_callback_.Run(method_call, | 132 method_callback_.Run(method_call, |
| 132 base::Bind(&ServiceProviderTestHelper::OnResponse, | 133 base::Bind(&ServiceProviderTestHelper::OnResponse, |
| 133 base::Unretained(this))); | 134 base::Unretained(this))); |
| 134 // Check for a response. | 135 // Check for a response. |
| 135 if (!response_received_) | 136 if (!response_received_) |
| 136 base::MessageLoop::current()->Run(); | 137 base::RunLoop().Run(); |
| 137 // Return response. | 138 // Return response. |
| 138 return response_.release(); | 139 return response_.release(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 void ServiceProviderTestHelper::MockConnectToSignal( | 142 void ServiceProviderTestHelper::MockConnectToSignal( |
| 142 const std::string& interface_name, | 143 const std::string& interface_name, |
| 143 const std::string& signal_name, | 144 const std::string& signal_name, |
| 144 dbus::ObjectProxy::SignalCallback signal_callback, | 145 dbus::ObjectProxy::SignalCallback signal_callback, |
| 145 dbus::ObjectProxy::OnConnectedCallback connected_callback) { | 146 dbus::ObjectProxy::OnConnectedCallback connected_callback) { |
| 146 // Tell the callback that the object proxy is connected to the signal. | 147 // Tell the callback that the object proxy is connected to the signal. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 157 | 158 |
| 158 void ServiceProviderTestHelper::OnResponse( | 159 void ServiceProviderTestHelper::OnResponse( |
| 159 std::unique_ptr<dbus::Response> response) { | 160 std::unique_ptr<dbus::Response> response) { |
| 160 response_ = std::move(response); | 161 response_ = std::move(response); |
| 161 response_received_ = true; | 162 response_received_ = true; |
| 162 if (base::MessageLoop::current()->is_running()) | 163 if (base::MessageLoop::current()->is_running()) |
| 163 base::MessageLoop::current()->QuitWhenIdle(); | 164 base::MessageLoop::current()->QuitWhenIdle(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 } // namespace chromeos | 167 } // namespace chromeos |
| OLD | NEW |