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

Side by Side Diff: dbus/object_proxy_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_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/object_proxy.h"
5 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/files/file_descriptor_watcher_posix.h"
6 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
7 #include "base/run_loop.h" 9 #include "base/run_loop.h"
8 #include "dbus/bus.h" 10 #include "dbus/bus.h"
9 #include "dbus/object_proxy.h"
10 #include "dbus/test_service.h" 11 #include "dbus/test_service.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace dbus { 14 namespace dbus {
14 namespace { 15 namespace {
15 16
16 class ObjectProxyTest : public testing::Test { 17 class ObjectProxyTest : public testing::Test {
17 protected: 18 protected:
19 ObjectProxyTest() : file_descriptor_watcher_(&message_loop_) {}
20
18 void SetUp() override { 21 void SetUp() override {
19 Bus::Options bus_options; 22 Bus::Options bus_options;
20 bus_options.bus_type = Bus::SESSION; 23 bus_options.bus_type = Bus::SESSION;
21 bus_options.connection_type = Bus::PRIVATE; 24 bus_options.connection_type = Bus::PRIVATE;
22 bus_ = new Bus(bus_options); 25 bus_ = new Bus(bus_options);
23 } 26 }
24 27
25 void TearDown() override { bus_->ShutdownAndBlock(); } 28 void TearDown() override { bus_->ShutdownAndBlock(); }
26 29
27 base::MessageLoopForIO message_loop_; 30 base::MessageLoopForIO message_loop_;
31
32 // This enables FileDescriptorWatcher, which is required by dbus::Watch.
33 base::FileDescriptorWatcher file_descriptor_watcher_;
34
28 scoped_refptr<Bus> bus_; 35 scoped_refptr<Bus> bus_;
29 }; 36 };
30 37
31 // Used as a WaitForServiceToBeAvailableCallback. 38 // Used as a WaitForServiceToBeAvailableCallback.
32 void OnServiceIsAvailable(bool* dest_service_is_available, 39 void OnServiceIsAvailable(bool* dest_service_is_available,
33 int* num_calls, 40 int* num_calls,
34 bool src_service_is_available) { 41 bool src_service_is_available) {
35 *dest_service_is_available = src_service_is_available; 42 *dest_service_is_available = src_service_is_available;
36 (*num_calls)++; 43 (*num_calls)++;
37 } 44 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 num_calls_2 = 0; 137 num_calls_2 = 0;
131 base::RunLoop().RunUntilIdle(); 138 base::RunLoop().RunUntilIdle();
132 EXPECT_EQ(1, num_calls_1); 139 EXPECT_EQ(1, num_calls_1);
133 EXPECT_EQ(1, num_calls_2); 140 EXPECT_EQ(1, num_calls_2);
134 EXPECT_TRUE(service_is_available_1); 141 EXPECT_TRUE(service_is_available_1);
135 EXPECT_TRUE(service_is_available_2); 142 EXPECT_TRUE(service_is_available_2);
136 } 143 }
137 144
138 } // namespace 145 } // namespace
139 } // namespace dbus 146 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/bus_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698