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 28 matching lines...) Expand all Loading... |
39 base::ThreadRestrictions::SetIOAllowed(false); | 39 base::ThreadRestrictions::SetIOAllowed(false); |
40 | 40 |
41 // Start the D-Bus thread. | 41 // Start the D-Bus thread. |
42 dbus_thread_.reset(new base::Thread("D-Bus Thread")); | 42 dbus_thread_.reset(new base::Thread("D-Bus Thread")); |
43 base::Thread::Options thread_options; | 43 base::Thread::Options thread_options; |
44 thread_options.message_loop_type = MessageLoop::TYPE_IO; | 44 thread_options.message_loop_type = MessageLoop::TYPE_IO; |
45 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); | 45 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); |
46 | 46 |
47 // Start the test service, using the D-Bus thread. | 47 // Start the test service, using the D-Bus thread. |
48 dbus::TestService::Options options; | 48 dbus::TestService::Options options; |
49 options.dbus_thread_message_loop_proxy = dbus_thread_->message_loop_proxy(); | 49 options.dbus_task_runner = dbus_thread_->message_loop_proxy(); |
50 test_service_.reset(new dbus::TestService(options)); | 50 test_service_.reset(new dbus::TestService(options)); |
51 ASSERT_TRUE(test_service_->StartService()); | 51 ASSERT_TRUE(test_service_->StartService()); |
52 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); | 52 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); |
53 ASSERT_TRUE(test_service_->HasDBusThread()); | 53 ASSERT_TRUE(test_service_->HasDBusThread()); |
54 | 54 |
55 // Create the client, using the D-Bus thread. | 55 // Create the client, using the D-Bus thread. |
56 dbus::Bus::Options bus_options; | 56 dbus::Bus::Options bus_options; |
57 bus_options.bus_type = dbus::Bus::SESSION; | 57 bus_options.bus_type = dbus::Bus::SESSION; |
58 bus_options.connection_type = dbus::Bus::PRIVATE; | 58 bus_options.connection_type = dbus::Bus::PRIVATE; |
59 bus_options.dbus_thread_message_loop_proxy = | 59 bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); |
60 dbus_thread_->message_loop_proxy(); | |
61 bus_options.disconnected_callback = | 60 bus_options.disconnected_callback = |
62 base::Bind(&EndToEndAsyncTest::OnDisconnected, base::Unretained(this)); | 61 base::Bind(&EndToEndAsyncTest::OnDisconnected, base::Unretained(this)); |
63 bus_ = new dbus::Bus(bus_options); | 62 bus_ = new dbus::Bus(bus_options); |
64 object_proxy_ = bus_->GetObjectProxy( | 63 object_proxy_ = bus_->GetObjectProxy( |
65 "org.chromium.TestService", | 64 "org.chromium.TestService", |
66 dbus::ObjectPath("/org/chromium/TestObject")); | 65 dbus::ObjectPath("/org/chromium/TestObject")); |
67 ASSERT_TRUE(bus_->HasDBusThread()); | 66 ASSERT_TRUE(bus_->HasDBusThread()); |
68 | 67 |
69 // Connect to the "Test" signal of "org.chromium.TestInterface" from | 68 // Connect to the "Test" signal of "org.chromium.TestInterface" from |
70 // the remote object. | 69 // the remote object. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 void SetUpBrokenBus() { | 130 void SetUpBrokenBus() { |
132 // Shut down the existing bus. | 131 // Shut down the existing bus. |
133 bus_->ShutdownOnDBusThreadAndBlock(); | 132 bus_->ShutdownOnDBusThreadAndBlock(); |
134 | 133 |
135 // Create new bus with invalid address. | 134 // Create new bus with invalid address. |
136 const char kInvalidAddress[] = ""; | 135 const char kInvalidAddress[] = ""; |
137 dbus::Bus::Options bus_options; | 136 dbus::Bus::Options bus_options; |
138 bus_options.bus_type = dbus::Bus::CUSTOM_ADDRESS; | 137 bus_options.bus_type = dbus::Bus::CUSTOM_ADDRESS; |
139 bus_options.address = kInvalidAddress; | 138 bus_options.address = kInvalidAddress; |
140 bus_options.connection_type = dbus::Bus::PRIVATE; | 139 bus_options.connection_type = dbus::Bus::PRIVATE; |
141 bus_options.dbus_thread_message_loop_proxy = | 140 bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); |
142 dbus_thread_->message_loop_proxy(); | |
143 bus_ = new dbus::Bus(bus_options); | 141 bus_ = new dbus::Bus(bus_options); |
144 ASSERT_TRUE(bus_->HasDBusThread()); | 142 ASSERT_TRUE(bus_->HasDBusThread()); |
145 | 143 |
146 // Create new object proxy. | 144 // Create new object proxy. |
147 object_proxy_ = bus_->GetObjectProxy( | 145 object_proxy_ = bus_->GetObjectProxy( |
148 "org.chromium.TestService", | 146 "org.chromium.TestService", |
149 dbus::ObjectPath("/org/chromium/TestObject")); | 147 dbus::ObjectPath("/org/chromium/TestObject")); |
150 } | 148 } |
151 | 149 |
152 // Calls the method asynchronously. OnResponse() will be called once the | 150 // Calls the method asynchronously. OnResponse() will be called once the |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 const char kMessage[] = "hello, world"; | 635 const char kMessage[] = "hello, world"; |
638 // Send the test signal from the exported object. | 636 // Send the test signal from the exported object. |
639 test_service_->SendTestSignal(kMessage); | 637 test_service_->SendTestSignal(kMessage); |
640 // Receive the signal with the object proxy. | 638 // Receive the signal with the object proxy. |
641 WaitForTestSignal(); | 639 WaitForTestSignal(); |
642 // Verify the string WAS NOT received by the original handler. | 640 // Verify the string WAS NOT received by the original handler. |
643 ASSERT_TRUE(test_signal_string_.empty()); | 641 ASSERT_TRUE(test_signal_string_.empty()); |
644 // Verify the signal WAS received by the replacement handler. | 642 // Verify the signal WAS received by the replacement handler. |
645 ASSERT_EQ(kMessage, replacement_test_signal_string_); | 643 ASSERT_EQ(kMessage, replacement_test_signal_string_); |
646 } | 644 } |
OLD | NEW |