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

Side by Side Diff: dbus/bus_unittest.cc

Issue 2808983002: Migrate to base::FileDescriptionWatcher in dbus/bus.cc. (Closed)
Patch Set: self-review Created 3 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
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/files/file_descriptor_watcher_posix.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 12 #include "base/run_loop.h"
12 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
13 #include "dbus/exported_object.h" 14 #include "dbus/exported_object.h"
14 #include "dbus/object_path.h" 15 #include "dbus/object_path.h"
15 #include "dbus/object_proxy.h" 16 #include "dbus/object_proxy.h"
16 #include "dbus/scoped_dbus_error.h" 17 #include "dbus/scoped_dbus_error.h"
17 #include "dbus/test_service.h" 18 #include "dbus/test_service.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 312
312 // A third attemp to remove the same rule should fail. 313 // A third attemp to remove the same rule should fail.
313 ASSERT_FALSE(bus->RemoveMatch( 314 ASSERT_FALSE(bus->RemoveMatch(
314 "type='signal',interface='org.chromium.TestService',path='/'", 315 "type='signal',interface='org.chromium.TestService',path='/'",
315 error.get())); 316 error.get()));
316 317
317 bus->ShutdownAndBlock(); 318 bus->ShutdownAndBlock();
318 } 319 }
319 320
320 TEST(BusTest, ListenForServiceOwnerChange) { 321 TEST(BusTest, ListenForServiceOwnerChange) {
321 // Setup the current thread's MessageLoop. Must be of TYPE_IO for the 322 // Setup a MessageLoopForIO and enable FileDescriptorWatcher for listeners.
322 // listeners to work. 323 base::MessageLoopForIO message_loop;
323 base::MessageLoop message_loop(base::MessageLoop::TYPE_IO); 324 base::FileDescriptorWatcher file_descriptor_watcher(&message_loop);
325
324 RunLoopWithExpectedCount run_loop_state; 326 RunLoopWithExpectedCount run_loop_state;
325 327
326 // Create the bus. 328 // Create the bus.
327 Bus::Options bus_options; 329 Bus::Options bus_options;
328 scoped_refptr<Bus> bus = new Bus(bus_options); 330 scoped_refptr<Bus> bus = new Bus(bus_options);
329 331
330 // Add a listener. 332 // Add a listener.
331 std::string service_owner1; 333 std::string service_owner1;
332 int num_of_owner_changes1 = 0; 334 int num_of_owner_changes1 = 0;
333 Bus::GetServiceOwnerCallback callback1 = 335 Bus::GetServiceOwnerCallback callback1 =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 // Connection name is not empty after connection is established. 411 // Connection name is not empty after connection is established.
410 EXPECT_TRUE(bus->is_connected()); 412 EXPECT_TRUE(bus->is_connected());
411 EXPECT_FALSE(bus->GetConnectionName().empty()); 413 EXPECT_FALSE(bus->GetConnectionName().empty());
412 414
413 // Shut down synchronously. 415 // Shut down synchronously.
414 bus->ShutdownAndBlock(); 416 bus->ShutdownAndBlock();
415 EXPECT_TRUE(bus->shutdown_completed()); 417 EXPECT_TRUE(bus->shutdown_completed());
416 } 418 }
417 419
418 } // namespace dbus 420 } // namespace dbus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698