Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: dbus/bus_unittest.cc

Issue 12255043: DBus: Use TaskRunners instead of MessageLoopProxies. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "dbus/bus.h" 5 #include "dbus/bus.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 MessageLoop message_loop; 90 MessageLoop message_loop;
91 91
92 // Start the D-Bus thread. 92 // Start the D-Bus thread.
93 base::Thread::Options thread_options; 93 base::Thread::Options thread_options;
94 thread_options.message_loop_type = MessageLoop::TYPE_IO; 94 thread_options.message_loop_type = MessageLoop::TYPE_IO;
95 base::Thread dbus_thread("D-Bus thread"); 95 base::Thread dbus_thread("D-Bus thread");
96 dbus_thread.StartWithOptions(thread_options); 96 dbus_thread.StartWithOptions(thread_options);
97 97
98 // Create the bus. 98 // Create the bus.
99 dbus::Bus::Options options; 99 dbus::Bus::Options options;
100 options.dbus_thread_message_loop_proxy = dbus_thread.message_loop_proxy(); 100 options.dbus_task_runner = dbus_thread.message_loop_proxy();
101 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); 101 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
102 ASSERT_FALSE(bus->shutdown_completed()); 102 ASSERT_FALSE(bus->shutdown_completed());
103 103
104 // Try to remove a non existant object proxy should return false. 104 // Try to remove a non existant object proxy should return false.
105 ASSERT_FALSE( 105 ASSERT_FALSE(
106 bus->RemoveObjectProxy("org.chromium.TestService", 106 bus->RemoveObjectProxy("org.chromium.TestService",
107 dbus::ObjectPath("/org/chromium/TestObject"), 107 dbus::ObjectPath("/org/chromium/TestObject"),
108 base::Bind(&base::DoNothing))); 108 base::Bind(&base::DoNothing)));
109 109
110 dbus::ObjectProxy* object_proxy1 = 110 dbus::ObjectProxy* object_proxy1 =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 TEST(BusTest, UnregisterExportedObject) { 171 TEST(BusTest, UnregisterExportedObject) {
172 // Start the D-Bus thread. 172 // Start the D-Bus thread.
173 base::Thread::Options thread_options; 173 base::Thread::Options thread_options;
174 thread_options.message_loop_type = MessageLoop::TYPE_IO; 174 thread_options.message_loop_type = MessageLoop::TYPE_IO;
175 base::Thread dbus_thread("D-Bus thread"); 175 base::Thread dbus_thread("D-Bus thread");
176 dbus_thread.StartWithOptions(thread_options); 176 dbus_thread.StartWithOptions(thread_options);
177 177
178 // Create the bus. 178 // Create the bus.
179 dbus::Bus::Options options; 179 dbus::Bus::Options options;
180 options.dbus_thread_message_loop_proxy = dbus_thread.message_loop_proxy(); 180 options.dbus_task_runner = dbus_thread.message_loop_proxy();
181 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); 181 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
182 ASSERT_FALSE(bus->shutdown_completed()); 182 ASSERT_FALSE(bus->shutdown_completed());
183 183
184 dbus::ExportedObject* object_proxy1 = 184 dbus::ExportedObject* object_proxy1 =
185 bus->GetExportedObject(dbus::ObjectPath("/org/chromium/TestObject")); 185 bus->GetExportedObject(dbus::ObjectPath("/org/chromium/TestObject"));
186 ASSERT_TRUE(object_proxy1); 186 ASSERT_TRUE(object_proxy1);
187 187
188 // Increment the reference count to the object proxy to avoid destroying it 188 // Increment the reference count to the object proxy to avoid destroying it
189 // calling UnregisterExportedObject. This ensures the dbus::ExportedObject is 189 // calling UnregisterExportedObject. This ensures the dbus::ExportedObject is
190 // not freed from memory. See http://crbug.com/137846 for details. 190 // not freed from memory. See http://crbug.com/137846 for details.
(...skipping 29 matching lines...) Expand all
220 220
221 TEST(BusTest, ShutdownAndBlockWithDBusThread) { 221 TEST(BusTest, ShutdownAndBlockWithDBusThread) {
222 // Start the D-Bus thread. 222 // Start the D-Bus thread.
223 base::Thread::Options thread_options; 223 base::Thread::Options thread_options;
224 thread_options.message_loop_type = MessageLoop::TYPE_IO; 224 thread_options.message_loop_type = MessageLoop::TYPE_IO;
225 base::Thread dbus_thread("D-Bus thread"); 225 base::Thread dbus_thread("D-Bus thread");
226 dbus_thread.StartWithOptions(thread_options); 226 dbus_thread.StartWithOptions(thread_options);
227 227
228 // Create the bus. 228 // Create the bus.
229 dbus::Bus::Options options; 229 dbus::Bus::Options options;
230 options.dbus_thread_message_loop_proxy = dbus_thread.message_loop_proxy(); 230 options.dbus_task_runner = dbus_thread.message_loop_proxy();
231 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options); 231 scoped_refptr<dbus::Bus> bus = new dbus::Bus(options);
232 ASSERT_FALSE(bus->shutdown_completed()); 232 ASSERT_FALSE(bus->shutdown_completed());
233 233
234 // Shut down synchronously. 234 // Shut down synchronously.
235 bus->ShutdownOnDBusThreadAndBlock(); 235 bus->ShutdownOnDBusThreadAndBlock();
236 EXPECT_TRUE(bus->shutdown_completed()); 236 EXPECT_TRUE(bus->shutdown_completed());
237 dbus_thread.Stop(); 237 dbus_thread.Stop();
238 } 238 }
239 239
240 TEST(BusTest, AddFilterFunction) { 240 TEST(BusTest, AddFilterFunction) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 error.get())); 289 error.get()));
290 ASSERT_FALSE(error.is_set()); 290 ASSERT_FALSE(error.is_set());
291 291
292 // A third attemp to remove the same rule should fail. 292 // A third attemp to remove the same rule should fail.
293 ASSERT_FALSE(bus->RemoveMatch( 293 ASSERT_FALSE(bus->RemoveMatch(
294 "type='signal',interface='org.chromium.TestService',path='/'", 294 "type='signal',interface='org.chromium.TestService',path='/'",
295 error.get())); 295 error.get()));
296 296
297 bus->ShutdownAndBlock(); 297 bus->ShutdownAndBlock();
298 } 298 }
OLDNEW
« no previous file with comments | « dbus/bus.cc ('k') | dbus/end_to_end_async_unittest.cc » ('j') | dbus/mock_bus.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698