| 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 #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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 // Call the method with timeout of 0ms. | 217 // Call the method with timeout of 0ms. |
| 218 const int timeout_ms = 0; | 218 const int timeout_ms = 0; |
| 219 CallMethod(&method_call, timeout_ms); | 219 CallMethod(&method_call, timeout_ms); |
| 220 WaitForResponses(1); | 220 WaitForResponses(1); |
| 221 | 221 |
| 222 // Should fail because of timeout. | 222 // Should fail because of timeout. |
| 223 ASSERT_EQ("", response_strings_[0]); | 223 ASSERT_EQ("", response_strings_[0]); |
| 224 } | 224 } |
| 225 | 225 |
| 226 // Tests calling a method that sends its reply asynchronously. | |
| 227 TEST_F(EndToEndAsyncTest, AsyncEcho) { | |
| 228 const char* kHello = "hello"; | |
| 229 | |
| 230 // Create the method call. | |
| 231 dbus::MethodCall method_call("org.chromium.TestInterface", "AsyncEcho"); | |
| 232 dbus::MessageWriter writer(&method_call); | |
| 233 writer.AppendString(kHello); | |
| 234 | |
| 235 // Call the method. | |
| 236 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; | |
| 237 CallMethod(&method_call, timeout_ms); | |
| 238 | |
| 239 // Check the response. | |
| 240 WaitForResponses(1); | |
| 241 EXPECT_EQ(kHello, response_strings_[0]); | |
| 242 } | |
| 243 | |
| 244 TEST_F(EndToEndAsyncTest, NonexistentMethod) { | 226 TEST_F(EndToEndAsyncTest, NonexistentMethod) { |
| 245 dbus::MethodCall method_call("org.chromium.TestInterface", "Nonexistent"); | 227 dbus::MethodCall method_call("org.chromium.TestInterface", "Nonexistent"); |
| 246 | 228 |
| 247 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; | 229 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; |
| 248 CallMethod(&method_call, timeout_ms); | 230 CallMethod(&method_call, timeout_ms); |
| 249 WaitForResponses(1); | 231 WaitForResponses(1); |
| 250 | 232 |
| 251 // Should fail because the method is nonexistent. | 233 // Should fail because the method is nonexistent. |
| 252 ASSERT_EQ("", response_strings_[0]); | 234 ASSERT_EQ("", response_strings_[0]); |
| 253 } | 235 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 TEST_F(EndToEndAsyncTest, TestSignalFromRoot) { | 280 TEST_F(EndToEndAsyncTest, TestSignalFromRoot) { |
| 299 const char kMessage[] = "hello, world"; | 281 const char kMessage[] = "hello, world"; |
| 300 // Send the test signal from the root object path, to see if we can | 282 // Send the test signal from the root object path, to see if we can |
| 301 // handle signals sent from "/", like dbus-send does. | 283 // handle signals sent from "/", like dbus-send does. |
| 302 test_service_->SendTestSignalFromRoot(kMessage); | 284 test_service_->SendTestSignalFromRoot(kMessage); |
| 303 // Receive the signal with the object proxy. The signal is handled in | 285 // Receive the signal with the object proxy. The signal is handled in |
| 304 // EndToEndAsyncTest::OnTestSignal() in the main thread. | 286 // EndToEndAsyncTest::OnTestSignal() in the main thread. |
| 305 WaitForTestSignal(); | 287 WaitForTestSignal(); |
| 306 ASSERT_EQ(kMessage, test_signal_string_); | 288 ASSERT_EQ(kMessage, test_signal_string_); |
| 307 } | 289 } |
| OLD | NEW |