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 19 matching lines...) Expand all Loading... |
30 base::ThreadRestrictions::SetIOAllowed(false); | 30 base::ThreadRestrictions::SetIOAllowed(false); |
31 | 31 |
32 // Start the D-Bus thread. | 32 // Start the D-Bus thread. |
33 dbus_thread_.reset(new base::Thread("D-Bus Thread")); | 33 dbus_thread_.reset(new base::Thread("D-Bus Thread")); |
34 base::Thread::Options thread_options; | 34 base::Thread::Options thread_options; |
35 thread_options.message_loop_type = MessageLoop::TYPE_IO; | 35 thread_options.message_loop_type = MessageLoop::TYPE_IO; |
36 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); | 36 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); |
37 | 37 |
38 // Start the test service, using the D-Bus thread. | 38 // Start the test service, using the D-Bus thread. |
39 dbus::TestService::Options options; | 39 dbus::TestService::Options options; |
40 options.dbus_thread = dbus_thread_.get(); | 40 options.dbus_thread_message_loop_proxy = dbus_thread_->message_loop_proxy(); |
41 test_service_.reset(new dbus::TestService(options)); | 41 test_service_.reset(new dbus::TestService(options)); |
42 ASSERT_TRUE(test_service_->StartService()); | 42 ASSERT_TRUE(test_service_->StartService()); |
43 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); | 43 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); |
44 ASSERT_TRUE(test_service_->HasDBusThread()); | 44 ASSERT_TRUE(test_service_->HasDBusThread()); |
45 | 45 |
46 // Create the client, using the D-Bus thread. | 46 // Create the client, using the D-Bus thread. |
47 dbus::Bus::Options bus_options; | 47 dbus::Bus::Options bus_options; |
48 bus_options.bus_type = dbus::Bus::SESSION; | 48 bus_options.bus_type = dbus::Bus::SESSION; |
49 bus_options.connection_type = dbus::Bus::PRIVATE; | 49 bus_options.connection_type = dbus::Bus::PRIVATE; |
50 bus_options.dbus_thread = dbus_thread_.get(); | 50 bus_options.dbus_thread_message_loop_proxy = |
| 51 dbus_thread_->message_loop_proxy(); |
51 bus_ = new dbus::Bus(bus_options); | 52 bus_ = new dbus::Bus(bus_options); |
52 object_proxy_ = bus_->GetObjectProxy("org.chromium.TestService", | 53 object_proxy_ = bus_->GetObjectProxy("org.chromium.TestService", |
53 "/org/chromium/TestObject"); | 54 "/org/chromium/TestObject"); |
54 ASSERT_TRUE(bus_->HasDBusThread()); | 55 ASSERT_TRUE(bus_->HasDBusThread()); |
55 | 56 |
56 // Connect to the "Test" signal from the remote object. | 57 // Connect to the "Test" signal from the remote object. |
57 object_proxy_->ConnectToSignal( | 58 object_proxy_->ConnectToSignal( |
58 "org.chromium.TestInterface", | 59 "org.chromium.TestInterface", |
59 "Test", | 60 "Test", |
60 base::Bind(&EndToEndAsyncTest::OnTestSignal, | 61 base::Bind(&EndToEndAsyncTest::OnTestSignal, |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 227 |
227 TEST_F(EndToEndAsyncTest, TestSignal) { | 228 TEST_F(EndToEndAsyncTest, TestSignal) { |
228 const char kMessage[] = "hello, world"; | 229 const char kMessage[] = "hello, world"; |
229 // Send the test signal from the exported object. | 230 // Send the test signal from the exported object. |
230 test_service_->SendTestSignal(kMessage); | 231 test_service_->SendTestSignal(kMessage); |
231 // Receive the signal with the object proxy. The signal is handled in | 232 // Receive the signal with the object proxy. The signal is handled in |
232 // EndToEndAsyncTest::OnTestSignal() in the main thread. | 233 // EndToEndAsyncTest::OnTestSignal() in the main thread. |
233 WaitForTestSignal(); | 234 WaitForTestSignal(); |
234 ASSERT_EQ(kMessage, test_signal_string_); | 235 ASSERT_EQ(kMessage, test_signal_string_); |
235 } | 236 } |
OLD | NEW |