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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 // Call the method with timeout of 0ms. | 198 // Call the method with timeout of 0ms. |
199 const int timeout_ms = 0; | 199 const int timeout_ms = 0; |
200 CallMethod(&method_call, timeout_ms); | 200 CallMethod(&method_call, timeout_ms); |
201 WaitForResponses(1); | 201 WaitForResponses(1); |
202 | 202 |
203 // Should fail because of timeout. | 203 // Should fail because of timeout. |
204 ASSERT_EQ("", response_strings_[0]); | 204 ASSERT_EQ("", response_strings_[0]); |
205 } | 205 } |
206 | 206 |
| 207 // Tests calling a method that sends its reply asynchronously. |
| 208 TEST_F(EndToEndAsyncTest, AsyncEcho) { |
| 209 const char* kHello = "hello"; |
| 210 |
| 211 // Create the method call. |
| 212 dbus::MethodCall method_call("org.chromium.TestInterface", "AsyncEcho"); |
| 213 dbus::MessageWriter writer(&method_call); |
| 214 writer.AppendString(kHello); |
| 215 |
| 216 // Call the method. |
| 217 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; |
| 218 CallMethod(&method_call, timeout_ms); |
| 219 |
| 220 // Check the response. |
| 221 WaitForResponses(1); |
| 222 EXPECT_EQ(kHello, response_strings_[0]); |
| 223 } |
| 224 |
207 TEST_F(EndToEndAsyncTest, NonexistentMethod) { | 225 TEST_F(EndToEndAsyncTest, NonexistentMethod) { |
208 dbus::MethodCall method_call("org.chromium.TestInterface", "Nonexistent"); | 226 dbus::MethodCall method_call("org.chromium.TestInterface", "Nonexistent"); |
209 | 227 |
210 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; | 228 const int timeout_ms = dbus::ObjectProxy::TIMEOUT_USE_DEFAULT; |
211 CallMethod(&method_call, timeout_ms); | 229 CallMethod(&method_call, timeout_ms); |
212 WaitForResponses(1); | 230 WaitForResponses(1); |
213 | 231 |
214 // Should fail because the method is nonexistent. | 232 // Should fail because the method is nonexistent. |
215 ASSERT_EQ("", response_strings_[0]); | 233 ASSERT_EQ("", response_strings_[0]); |
216 } | 234 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 TEST_F(EndToEndAsyncTest, TestSignalFromRoot) { | 279 TEST_F(EndToEndAsyncTest, TestSignalFromRoot) { |
262 const char kMessage[] = "hello, world"; | 280 const char kMessage[] = "hello, world"; |
263 // Send the test signal from the root object path, to see if we can | 281 // Send the test signal from the root object path, to see if we can |
264 // handle signals sent from "/", like dbus-send does. | 282 // handle signals sent from "/", like dbus-send does. |
265 test_service_->SendTestSignalFromRoot(kMessage); | 283 test_service_->SendTestSignalFromRoot(kMessage); |
266 // Receive the signal with the object proxy. The signal is handled in | 284 // Receive the signal with the object proxy. The signal is handled in |
267 // EndToEndAsyncTest::OnTestSignal() in the main thread. | 285 // EndToEndAsyncTest::OnTestSignal() in the main thread. |
268 WaitForTestSignal(); | 286 WaitForTestSignal(); |
269 ASSERT_EQ(kMessage, test_signal_string_); | 287 ASSERT_EQ(kMessage, test_signal_string_); |
270 } | 288 } |
OLD | NEW |