| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This test is relatively complicated. Here's the summary of what it does: | 5 // This test is relatively complicated. Here's the summary of what it does: |
| 6 // | 6 // |
| 7 // - Set up mock D-Bus related objects to mock out D-Bus calls. | 7 // - Set up mock D-Bus related objects to mock out D-Bus calls. |
| 8 // - Set up a mock proxy resolver to mock out the proxy resolution. | 8 // - Set up a mock proxy resolver to mock out the proxy resolution. |
| 9 // - Create ProxyResolutionServiceProvider by injecting the mocks | 9 // - Create ProxyResolutionServiceProvider by injecting the mocks |
| 10 // - Start the service provider. | 10 // - Start the service provider. |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // Set the serial number to non-zero, so | 254 // Set the serial number to non-zero, so |
| 255 // dbus_message_new_method_return() won't emit a warning. | 255 // dbus_message_new_method_return() won't emit a warning. |
| 256 method_call->SetSerial(1); | 256 method_call->SetSerial(1); |
| 257 // Run the callback captured in MockExportMethod(). In addition to returning | 257 // Run the callback captured in MockExportMethod(). In addition to returning |
| 258 // a response that the caller will ignore, this will send a signal, which | 258 // a response that the caller will ignore, this will send a signal, which |
| 259 // will be received by |on_signal_callback_|. | 259 // will be received by |on_signal_callback_|. |
| 260 resolve_network_proxy_.Run( | 260 resolve_network_proxy_.Run( |
| 261 method_call, | 261 method_call, |
| 262 base::Bind(&ProxyResolutionServiceProviderTest::OnResponse, | 262 base::Bind(&ProxyResolutionServiceProviderTest::OnResponse, |
| 263 base::Unretained(this))); | 263 base::Unretained(this))); |
| 264 // Wait for a response. | 264 // Check for a response. |
| 265 while (!response_received_) { | 265 if (!response_received_) |
| 266 message_loop_.Run(); | 266 message_loop_.Run(); |
| 267 } | |
| 268 // Return response. | 267 // Return response. |
| 269 return response_.release(); | 268 return response_.release(); |
| 270 } | 269 } |
| 271 | 270 |
| 272 // Receives a response and makes it available to MockCallMethodAndBlock(). | 271 // Receives a response and makes it available to MockCallMethodAndBlock(). |
| 273 void OnResponse(dbus::Response* response) { | 272 void OnResponse(dbus::Response* response) { |
| 274 response_.reset(response); | 273 response_.reset(response); |
| 275 response_received_ = true; | 274 response_received_ = true; |
| 276 if (message_loop_.is_running()) { | 275 if (message_loop_.is_running()) |
| 277 message_loop_.Quit(); | 276 message_loop_.Quit(); |
| 278 } | |
| 279 } | 277 } |
| 280 | 278 |
| 281 // Behaves as |mock_object_proxy_|'s ConnectToSignal(). | 279 // Behaves as |mock_object_proxy_|'s ConnectToSignal(). |
| 282 void MockConnectToSignal( | 280 void MockConnectToSignal( |
| 283 const std::string& interface_name, | 281 const std::string& interface_name, |
| 284 const std::string& signal_name, | 282 const std::string& signal_name, |
| 285 dbus::ObjectProxy::SignalCallback signal_callback, | 283 dbus::ObjectProxy::SignalCallback signal_callback, |
| 286 dbus::ObjectProxy::OnConnectedCallback connected_callback) { | 284 dbus::ObjectProxy::OnConnectedCallback connected_callback) { |
| 287 // Tell the callback that the object proxy is connected to the signal. | 285 // Tell the callback that the object proxy is connected to the signal. |
| 288 connected_callback.Run(interface_name, signal_name, true); | 286 connected_callback.Run(interface_name, signal_name, true); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 ASSERT_TRUE(response.get()); | 321 ASSERT_TRUE(response.get()); |
| 324 dbus::MessageReader reader(response.get()); | 322 dbus::MessageReader reader(response.get()); |
| 325 ASSERT_FALSE(reader.HasMoreData()); | 323 ASSERT_FALSE(reader.HasMoreData()); |
| 326 | 324 |
| 327 // Confirm that the signal is received successfully. | 325 // Confirm that the signal is received successfully. |
| 328 // The contents of the signal are checked in OnSignalReceived(). | 326 // The contents of the signal are checked in OnSignalReceived(). |
| 329 ASSERT_TRUE(signal_received_successfully_); | 327 ASSERT_TRUE(signal_received_successfully_); |
| 330 } | 328 } |
| 331 | 329 |
| 332 } // namespace chromeos | 330 } // namespace chromeos |
| OLD | NEW |