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

Side by Side Diff: dbus/bus_unittest.cc

Issue 2808983002: Migrate to base::FileDescriptionWatcher in dbus/bus.cc. (Closed)
Patch Set: CR-satorux1-48-update-comment 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
« no previous file with comments | « dbus/bus.cc ('k') | dbus/object_proxy_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/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 base::MessageLoopForIO message_loop;
322 // listeners to work. 323
323 base::MessageLoop message_loop(base::MessageLoop::TYPE_IO); 324 // This enables FileDescriptorWatcher, which is required by dbus::Watch.
325 base::FileDescriptorWatcher file_descriptor_watcher(&message_loop);
326
324 RunLoopWithExpectedCount run_loop_state; 327 RunLoopWithExpectedCount run_loop_state;
325 328
326 // Create the bus. 329 // Create the bus.
327 Bus::Options bus_options; 330 Bus::Options bus_options;
328 scoped_refptr<Bus> bus = new Bus(bus_options); 331 scoped_refptr<Bus> bus = new Bus(bus_options);
329 332
330 // Add a listener. 333 // Add a listener.
331 std::string service_owner1; 334 std::string service_owner1;
332 int num_of_owner_changes1 = 0; 335 int num_of_owner_changes1 = 0;
333 Bus::GetServiceOwnerCallback callback1 = 336 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. 412 // Connection name is not empty after connection is established.
410 EXPECT_TRUE(bus->is_connected()); 413 EXPECT_TRUE(bus->is_connected());
411 EXPECT_FALSE(bus->GetConnectionName().empty()); 414 EXPECT_FALSE(bus->GetConnectionName().empty());
412 415
413 // Shut down synchronously. 416 // Shut down synchronously.
414 bus->ShutdownAndBlock(); 417 bus->ShutdownAndBlock();
415 EXPECT_TRUE(bus->shutdown_completed()); 418 EXPECT_TRUE(bus->shutdown_completed());
416 } 419 }
417 420
418 } // namespace dbus 421 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/bus.cc ('k') | dbus/object_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698