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

Side by Side Diff: dbus/bus_unittest.cc

Issue 14386016: dbus: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « dbus/bus.cc ('k') | dbus/end_to_end_async_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 dbus::ObjectPath("/org/chromium/DifferentTestObject"), 80 dbus::ObjectPath("/org/chromium/DifferentTestObject"),
81 dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS); 81 dbus::ObjectProxy::IGNORE_SERVICE_UNKNOWN_ERRORS);
82 ASSERT_TRUE(object_proxy3); 82 ASSERT_TRUE(object_proxy3);
83 EXPECT_NE(object_proxy1, object_proxy3); 83 EXPECT_NE(object_proxy1, object_proxy3);
84 84
85 bus->ShutdownAndBlock(); 85 bus->ShutdownAndBlock();
86 } 86 }
87 87
88 TEST(BusTest, RemoveObjectProxy) { 88 TEST(BusTest, RemoveObjectProxy) {
89 // Setup the current thread's MessageLoop. 89 // Setup the current thread's MessageLoop.
90 MessageLoop message_loop; 90 base::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 = base::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_task_runner = 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.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 dbus::ObjectPath("/org/chromium/DifferentTestObject")); 164 dbus::ObjectPath("/org/chromium/DifferentTestObject"));
165 ASSERT_TRUE(object_proxy3); 165 ASSERT_TRUE(object_proxy3);
166 EXPECT_NE(object_proxy1, object_proxy3); 166 EXPECT_NE(object_proxy1, object_proxy3);
167 167
168 bus->ShutdownAndBlock(); 168 bus->ShutdownAndBlock();
169 } 169 }
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 = base::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_task_runner = 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 =
(...skipping 29 matching lines...) Expand all
214 ASSERT_FALSE(bus->shutdown_completed()); 214 ASSERT_FALSE(bus->shutdown_completed());
215 215
216 // Shut down synchronously. 216 // Shut down synchronously.
217 bus->ShutdownAndBlock(); 217 bus->ShutdownAndBlock();
218 EXPECT_TRUE(bus->shutdown_completed()); 218 EXPECT_TRUE(bus->shutdown_completed());
219 } 219 }
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 = base::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_task_runner = 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.
(...skipping 54 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698