| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 writer.AppendString(kHello); | 307 writer.AppendString(kHello); |
| 308 | 308 |
| 309 // Call the method with an empty callback. | 309 // Call the method with an empty callback. |
| 310 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; | 310 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; |
| 311 object_proxy_->CallMethod(&method_call, | 311 object_proxy_->CallMethod(&method_call, |
| 312 timeout_ms, | 312 timeout_ms, |
| 313 dbus::ObjectProxy::EmptyResponseCallback()); | 313 dbus::ObjectProxy::EmptyResponseCallback()); |
| 314 // Post a delayed task to quit the message loop. | 314 // Post a delayed task to quit the message loop. |
| 315 message_loop_.PostDelayedTask(FROM_HERE, | 315 message_loop_.PostDelayedTask(FROM_HERE, |
| 316 MessageLoop::QuitClosure(), | 316 MessageLoop::QuitClosure(), |
| 317 TestTimeouts::tiny_timeout_ms()); | 317 TestTimeouts::tiny_timeout()); |
| 318 message_loop_.Run(); | 318 message_loop_.Run(); |
| 319 // We cannot tell if the empty callback is called, but at least we can | 319 // We cannot tell if the empty callback is called, but at least we can |
| 320 // check if the test does not crash. | 320 // check if the test does not crash. |
| 321 } | 321 } |
| 322 | 322 |
| 323 TEST_F(EndToEndAsyncTest, TestSignal) { | 323 TEST_F(EndToEndAsyncTest, TestSignal) { |
| 324 const char kMessage[] = "hello, world"; | 324 const char kMessage[] = "hello, world"; |
| 325 // Send the test signal from the exported object. | 325 // Send the test signal from the exported object. |
| 326 test_service_->SendTestSignal(kMessage); | 326 test_service_->SendTestSignal(kMessage); |
| 327 // Receive the signal with the object proxy. The signal is handled in | 327 // Receive the signal with the object proxy. The signal is handled in |
| 328 // EndToEndAsyncTest::OnTestSignal() in the main thread. | 328 // EndToEndAsyncTest::OnTestSignal() in the main thread. |
| 329 WaitForTestSignal(); | 329 WaitForTestSignal(); |
| 330 ASSERT_EQ(kMessage, test_signal_string_); | 330 ASSERT_EQ(kMessage, test_signal_string_); |
| 331 } | 331 } |
| 332 | 332 |
| 333 TEST_F(EndToEndAsyncTest, TestSignalFromRoot) { | 333 TEST_F(EndToEndAsyncTest, TestSignalFromRoot) { |
| 334 const char kMessage[] = "hello, world"; | 334 const char kMessage[] = "hello, world"; |
| 335 // Object proxies are tied to a particular object path, if a signal | 335 // Object proxies are tied to a particular object path, if a signal |
| 336 // arrives from a different object path like "/" the first object proxy | 336 // arrives from a different object path like "/" the first object proxy |
| 337 // |object_proxy_| should not handle it, and should leave it for the root | 337 // |object_proxy_| should not handle it, and should leave it for the root |
| 338 // object proxy |root_object_proxy_|. | 338 // object proxy |root_object_proxy_|. |
| 339 test_service_->SendTestSignalFromRoot(kMessage); | 339 test_service_->SendTestSignalFromRoot(kMessage); |
| 340 WaitForTestSignal(); | 340 WaitForTestSignal(); |
| 341 // Verify the signal was not received by the specific proxy. | 341 // Verify the signal was not received by the specific proxy. |
| 342 ASSERT_TRUE(test_signal_string_.empty()); | 342 ASSERT_TRUE(test_signal_string_.empty()); |
| 343 // Verify the string WAS received by the root proxy. | 343 // Verify the string WAS received by the root proxy. |
| 344 ASSERT_EQ(kMessage, root_test_signal_string_); | 344 ASSERT_EQ(kMessage, root_test_signal_string_); |
| 345 } | 345 } |
| OLD | NEW |