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

Side by Side Diff: dbus/object_manager_unittest.cc

Issue 16012018: Cleanup: Put DBus unit tests in the dbus namespace, so one does not need to write dbus:: everywhere… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 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/mock_unittest.cc ('k') | dbus/property_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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_manager.h" 5 #include "dbus/object_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/threading/thread_restrictions.h" 14 #include "base/threading/thread_restrictions.h"
15 #include "dbus/bus.h" 15 #include "dbus/bus.h"
16 #include "dbus/object_path.h" 16 #include "dbus/object_path.h"
17 #include "dbus/object_proxy.h" 17 #include "dbus/object_proxy.h"
18 #include "dbus/property.h" 18 #include "dbus/property.h"
19 #include "dbus/test_service.h" 19 #include "dbus/test_service.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 namespace dbus {
23
22 // The object manager test exercises the asynchronous APIs in ObjectManager, 24 // The object manager test exercises the asynchronous APIs in ObjectManager,
23 // and by extension PropertySet and Property<>. 25 // and by extension PropertySet and Property<>.
24 class ObjectManagerTest 26 class ObjectManagerTest
25 : public testing::Test, 27 : public testing::Test,
26 public dbus::ObjectManager::Interface { 28 public ObjectManager::Interface {
27 public: 29 public:
28 ObjectManagerTest() { 30 ObjectManagerTest() {
29 } 31 }
30 32
31 struct Properties : public dbus::PropertySet { 33 struct Properties : public PropertySet {
32 dbus::Property<std::string> name; 34 Property<std::string> name;
33 dbus::Property<int16> version; 35 Property<int16> version;
34 dbus::Property<std::vector<std::string> > methods; 36 Property<std::vector<std::string> > methods;
35 dbus::Property<std::vector<dbus::ObjectPath> > objects; 37 Property<std::vector<ObjectPath> > objects;
36 38
37 Properties(dbus::ObjectProxy* object_proxy, 39 Properties(ObjectProxy* object_proxy,
38 const std::string& interface_name, 40 const std::string& interface_name,
39 PropertyChangedCallback property_changed_callback) 41 PropertyChangedCallback property_changed_callback)
40 : dbus::PropertySet(object_proxy, interface_name, 42 : PropertySet(object_proxy, interface_name, property_changed_callback) {
41 property_changed_callback) {
42 RegisterProperty("Name", &name); 43 RegisterProperty("Name", &name);
43 RegisterProperty("Version", &version); 44 RegisterProperty("Version", &version);
44 RegisterProperty("Methods", &methods); 45 RegisterProperty("Methods", &methods);
45 RegisterProperty("Objects", &objects); 46 RegisterProperty("Objects", &objects);
46 } 47 }
47 }; 48 };
48 49
49 virtual dbus::PropertySet* CreateProperties( 50 virtual PropertySet* CreateProperties(
50 dbus::ObjectProxy* object_proxy, 51 ObjectProxy* object_proxy,
51 const dbus::ObjectPath& object_path, 52 const ObjectPath& object_path,
52 const std::string& interface_name) OVERRIDE { 53 const std::string& interface_name) OVERRIDE {
53 Properties* properties = new Properties( 54 Properties* properties = new Properties(
54 object_proxy, interface_name, 55 object_proxy, interface_name,
55 base::Bind(&ObjectManagerTest::OnPropertyChanged, 56 base::Bind(&ObjectManagerTest::OnPropertyChanged,
56 base::Unretained(this), object_path)); 57 base::Unretained(this), object_path));
57 return static_cast<dbus::PropertySet*>(properties); 58 return static_cast<PropertySet*>(properties);
58 } 59 }
59 60
60 virtual void SetUp() { 61 virtual void SetUp() {
61 // Make the main thread not to allow IO. 62 // Make the main thread not to allow IO.
62 base::ThreadRestrictions::SetIOAllowed(false); 63 base::ThreadRestrictions::SetIOAllowed(false);
63 64
64 // Start the D-Bus thread. 65 // Start the D-Bus thread.
65 dbus_thread_.reset(new base::Thread("D-Bus Thread")); 66 dbus_thread_.reset(new base::Thread("D-Bus Thread"));
66 base::Thread::Options thread_options; 67 base::Thread::Options thread_options;
67 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; 68 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
68 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options)); 69 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options));
69 70
70 // Start the test service, using the D-Bus thread. 71 // Start the test service, using the D-Bus thread.
71 dbus::TestService::Options options; 72 TestService::Options options;
72 options.dbus_task_runner = dbus_thread_->message_loop_proxy(); 73 options.dbus_task_runner = dbus_thread_->message_loop_proxy();
73 test_service_.reset(new dbus::TestService(options)); 74 test_service_.reset(new TestService(options));
74 ASSERT_TRUE(test_service_->StartService()); 75 ASSERT_TRUE(test_service_->StartService());
75 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); 76 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted());
76 ASSERT_TRUE(test_service_->HasDBusThread()); 77 ASSERT_TRUE(test_service_->HasDBusThread());
77 78
78 // Create the client, using the D-Bus thread. 79 // Create the client, using the D-Bus thread.
79 dbus::Bus::Options bus_options; 80 Bus::Options bus_options;
80 bus_options.bus_type = dbus::Bus::SESSION; 81 bus_options.bus_type = Bus::SESSION;
81 bus_options.connection_type = dbus::Bus::PRIVATE; 82 bus_options.connection_type = Bus::PRIVATE;
82 bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); 83 bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy();
83 bus_ = new dbus::Bus(bus_options); 84 bus_ = new Bus(bus_options);
84 ASSERT_TRUE(bus_->HasDBusThread()); 85 ASSERT_TRUE(bus_->HasDBusThread());
85 86
86 object_manager_ = bus_->GetObjectManager( 87 object_manager_ = bus_->GetObjectManager(
87 "org.chromium.TestService", 88 "org.chromium.TestService",
88 dbus::ObjectPath("/org/chromium/TestService")); 89 ObjectPath("/org/chromium/TestService"));
89 object_manager_->RegisterInterface("org.chromium.TestInterface", this); 90 object_manager_->RegisterInterface("org.chromium.TestInterface", this);
90 91
91 object_manager_->GetManagedObjects(); 92 object_manager_->GetManagedObjects();
92 WaitForObject(); 93 WaitForObject();
93 } 94 }
94 95
95 virtual void TearDown() { 96 virtual void TearDown() {
96 bus_->ShutdownOnDBusThreadAndBlock(); 97 bus_->ShutdownOnDBusThreadAndBlock();
97 98
98 // Shut down the service. 99 // Shut down the service.
99 test_service_->ShutdownAndBlock(); 100 test_service_->ShutdownAndBlock();
100 101
101 // Reset to the default. 102 // Reset to the default.
102 base::ThreadRestrictions::SetIOAllowed(true); 103 base::ThreadRestrictions::SetIOAllowed(true);
103 104
104 // Stopping a thread is considered an IO operation, so do this after 105 // Stopping a thread is considered an IO operation, so do this after
105 // allowing IO. 106 // allowing IO.
106 test_service_->Stop(); 107 test_service_->Stop();
107 } 108 }
108 109
109 void MethodCallback(dbus::Response* response) { 110 void MethodCallback(Response* response) {
110 method_callback_called_ = true; 111 method_callback_called_ = true;
111 message_loop_.Quit(); 112 message_loop_.Quit();
112 } 113 }
113 114
114 protected: 115 protected:
115 // Called when an object is added. 116 // Called when an object is added.
116 virtual void ObjectAdded(const dbus::ObjectPath& object_path, 117 virtual void ObjectAdded(const ObjectPath& object_path,
117 const std::string& interface_name) OVERRIDE { 118 const std::string& interface_name) OVERRIDE {
118 added_objects_.push_back(std::make_pair(object_path, interface_name)); 119 added_objects_.push_back(std::make_pair(object_path, interface_name));
119 message_loop_.Quit(); 120 message_loop_.Quit();
120 } 121 }
121 122
122 // Called when an object is removed. 123 // Called when an object is removed.
123 virtual void ObjectRemoved(const dbus::ObjectPath& object_path, 124 virtual void ObjectRemoved(const ObjectPath& object_path,
124 const std::string& interface_name) OVERRIDE { 125 const std::string& interface_name) OVERRIDE {
125 removed_objects_.push_back(std::make_pair(object_path, interface_name)); 126 removed_objects_.push_back(std::make_pair(object_path, interface_name));
126 message_loop_.Quit(); 127 message_loop_.Quit();
127 } 128 }
128 129
129 // Called when a property value is updated. 130 // Called when a property value is updated.
130 void OnPropertyChanged(const dbus::ObjectPath& object_path, 131 void OnPropertyChanged(const ObjectPath& object_path,
131 const std::string& name) { 132 const std::string& name) {
132 updated_properties_.push_back(name); 133 updated_properties_.push_back(name);
133 message_loop_.Quit(); 134 message_loop_.Quit();
134 } 135 }
135 136
136 static const size_t kExpectedObjects = 1; 137 static const size_t kExpectedObjects = 1;
137 static const size_t kExpectedProperties = 4; 138 static const size_t kExpectedProperties = 4;
138 139
139 void WaitForObject() { 140 void WaitForObject() {
140 while (added_objects_.size() < kExpectedObjects || 141 while (added_objects_.size() < kExpectedObjects ||
(...skipping 10 matching lines...) Expand all
151 message_loop_.Run(); 152 message_loop_.Run();
152 for (size_t i = 0; i < kExpectedObjects; ++i) 153 for (size_t i = 0; i < kExpectedObjects; ++i)
153 removed_objects_.erase(removed_objects_.begin()); 154 removed_objects_.erase(removed_objects_.begin());
154 } 155 }
155 156
156 void WaitForMethodCallback() { 157 void WaitForMethodCallback() {
157 message_loop_.Run(); 158 message_loop_.Run();
158 method_callback_called_ = false; 159 method_callback_called_ = false;
159 } 160 }
160 161
161 void PerformAction(const std::string& action, 162 void PerformAction(const std::string& action, const ObjectPath& object_path) {
162 const dbus::ObjectPath& object_path) { 163 ObjectProxy* object_proxy = bus_->GetObjectProxy(
163 dbus::ObjectProxy* object_proxy = bus_->GetObjectProxy(
164 "org.chromium.TestService", 164 "org.chromium.TestService",
165 dbus::ObjectPath("/org/chromium/TestObject")); 165 ObjectPath("/org/chromium/TestObject"));
166 166
167 dbus::MethodCall method_call("org.chromium.TestInterface", "PerformAction"); 167 MethodCall method_call("org.chromium.TestInterface", "PerformAction");
168 dbus::MessageWriter writer(&method_call); 168 MessageWriter writer(&method_call);
169 writer.AppendString(action); 169 writer.AppendString(action);
170 writer.AppendObjectPath(object_path); 170 writer.AppendObjectPath(object_path);
171 171
172 object_proxy->CallMethod(&method_call, 172 object_proxy->CallMethod(&method_call,
173 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 173 ObjectProxy::TIMEOUT_USE_DEFAULT,
174 base::Bind(&ObjectManagerTest::MethodCallback, 174 base::Bind(&ObjectManagerTest::MethodCallback,
175 base::Unretained(this))); 175 base::Unretained(this)));
176 WaitForMethodCallback(); 176 WaitForMethodCallback();
177 } 177 }
178 178
179 base::MessageLoop message_loop_; 179 base::MessageLoop message_loop_;
180 scoped_ptr<base::Thread> dbus_thread_; 180 scoped_ptr<base::Thread> dbus_thread_;
181 scoped_refptr<dbus::Bus> bus_; 181 scoped_refptr<Bus> bus_;
182 dbus::ObjectManager* object_manager_; 182 ObjectManager* object_manager_;
183 scoped_ptr<dbus::TestService> test_service_; 183 scoped_ptr<TestService> test_service_;
184 184
185 std::vector<std::pair<dbus::ObjectPath, std::string> > added_objects_; 185 std::vector<std::pair<ObjectPath, std::string> > added_objects_;
186 std::vector<std::pair<dbus::ObjectPath, std::string> > removed_objects_; 186 std::vector<std::pair<ObjectPath, std::string> > removed_objects_;
187 std::vector<std::string> updated_properties_; 187 std::vector<std::string> updated_properties_;
188 188
189 bool method_callback_called_; 189 bool method_callback_called_;
190 }; 190 };
191 191
192 192
193 TEST_F(ObjectManagerTest, InitialObject) { 193 TEST_F(ObjectManagerTest, InitialObject) {
194 dbus::ObjectProxy* object_proxy = object_manager_->GetObjectProxy( 194 ObjectProxy* object_proxy = object_manager_->GetObjectProxy(
195 dbus::ObjectPath("/org/chromium/TestObject")); 195 ObjectPath("/org/chromium/TestObject"));
196 EXPECT_TRUE(object_proxy != NULL); 196 EXPECT_TRUE(object_proxy != NULL);
197 197
198 Properties* properties = static_cast<Properties*>( 198 Properties* properties = static_cast<Properties*>(
199 object_manager_->GetProperties( 199 object_manager_->GetProperties(ObjectPath("/org/chromium/TestObject"),
200 dbus::ObjectPath("/org/chromium/TestObject"), 200 "org.chromium.TestInterface"));
201 "org.chromium.TestInterface"));
202 EXPECT_TRUE(properties != NULL); 201 EXPECT_TRUE(properties != NULL);
203 202
204 EXPECT_EQ("TestService", properties->name.value()); 203 EXPECT_EQ("TestService", properties->name.value());
205 EXPECT_EQ(10, properties->version.value()); 204 EXPECT_EQ(10, properties->version.value());
206 205
207 std::vector<std::string> methods = properties->methods.value(); 206 std::vector<std::string> methods = properties->methods.value();
208 ASSERT_EQ(4U, methods.size()); 207 ASSERT_EQ(4U, methods.size());
209 EXPECT_EQ("Echo", methods[0]); 208 EXPECT_EQ("Echo", methods[0]);
210 EXPECT_EQ("SlowEcho", methods[1]); 209 EXPECT_EQ("SlowEcho", methods[1]);
211 EXPECT_EQ("AsyncEcho", methods[2]); 210 EXPECT_EQ("AsyncEcho", methods[2]);
212 EXPECT_EQ("BrokenMethod", methods[3]); 211 EXPECT_EQ("BrokenMethod", methods[3]);
213 212
214 std::vector<dbus::ObjectPath> objects = properties->objects.value(); 213 std::vector<ObjectPath> objects = properties->objects.value();
215 ASSERT_EQ(1U, objects.size()); 214 ASSERT_EQ(1U, objects.size());
216 EXPECT_EQ(dbus::ObjectPath("/TestObjectPath"), objects[0]); 215 EXPECT_EQ(ObjectPath("/TestObjectPath"), objects[0]);
217 } 216 }
218 217
219 TEST_F(ObjectManagerTest, UnknownObjectProxy) { 218 TEST_F(ObjectManagerTest, UnknownObjectProxy) {
220 dbus::ObjectProxy* object_proxy = object_manager_->GetObjectProxy( 219 ObjectProxy* object_proxy = object_manager_->GetObjectProxy(
221 dbus::ObjectPath("/org/chromium/UnknownObject")); 220 ObjectPath("/org/chromium/UnknownObject"));
222 EXPECT_TRUE(object_proxy == NULL); 221 EXPECT_TRUE(object_proxy == NULL);
223 } 222 }
224 223
225 TEST_F(ObjectManagerTest, UnknownObjectProperties) { 224 TEST_F(ObjectManagerTest, UnknownObjectProperties) {
226 Properties* properties = static_cast<Properties*>( 225 Properties* properties = static_cast<Properties*>(
227 object_manager_->GetProperties( 226 object_manager_->GetProperties(ObjectPath("/org/chromium/UnknownObject"),
228 dbus::ObjectPath("/org/chromium/UnknownObject"), 227 "org.chromium.TestInterface"));
229 "org.chromium.TestInterface"));
230 EXPECT_TRUE(properties == NULL); 228 EXPECT_TRUE(properties == NULL);
231 } 229 }
232 230
233 TEST_F(ObjectManagerTest, UnknownInterfaceProperties) { 231 TEST_F(ObjectManagerTest, UnknownInterfaceProperties) {
234 Properties* properties = static_cast<Properties*>( 232 Properties* properties = static_cast<Properties*>(
235 object_manager_->GetProperties( 233 object_manager_->GetProperties(ObjectPath("/org/chromium/TestObject"),
236 dbus::ObjectPath("/org/chromium/TestObject"), 234 "org.chromium.UnknownService"));
237 "org.chromium.UnknownService"));
238 EXPECT_TRUE(properties == NULL); 235 EXPECT_TRUE(properties == NULL);
239 } 236 }
240 237
241 TEST_F(ObjectManagerTest, GetObjects) { 238 TEST_F(ObjectManagerTest, GetObjects) {
242 std::vector<dbus::ObjectPath> object_paths = object_manager_->GetObjects(); 239 std::vector<ObjectPath> object_paths = object_manager_->GetObjects();
243 ASSERT_EQ(1U, object_paths.size()); 240 ASSERT_EQ(1U, object_paths.size());
244 EXPECT_EQ(dbus::ObjectPath("/org/chromium/TestObject"), object_paths[0]); 241 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[0]);
245 } 242 }
246 243
247 TEST_F(ObjectManagerTest, GetObjectsWithInterface) { 244 TEST_F(ObjectManagerTest, GetObjectsWithInterface) {
248 std::vector<dbus::ObjectPath> object_paths = 245 std::vector<ObjectPath> object_paths =
249 object_manager_->GetObjectsWithInterface("org.chromium.TestInterface"); 246 object_manager_->GetObjectsWithInterface("org.chromium.TestInterface");
250 ASSERT_EQ(1U, object_paths.size()); 247 ASSERT_EQ(1U, object_paths.size());
251 EXPECT_EQ(dbus::ObjectPath("/org/chromium/TestObject"), object_paths[0]); 248 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[0]);
252 } 249 }
253 250
254 TEST_F(ObjectManagerTest, GetObjectsWithUnknownInterface) { 251 TEST_F(ObjectManagerTest, GetObjectsWithUnknownInterface) {
255 std::vector<dbus::ObjectPath> object_paths = 252 std::vector<ObjectPath> object_paths =
256 object_manager_->GetObjectsWithInterface("org.chromium.UnknownService"); 253 object_manager_->GetObjectsWithInterface("org.chromium.UnknownService");
257 EXPECT_EQ(0U, object_paths.size()); 254 EXPECT_EQ(0U, object_paths.size());
258 } 255 }
259 256
260 TEST_F(ObjectManagerTest, SameObject) { 257 TEST_F(ObjectManagerTest, SameObject) {
261 dbus::ObjectManager* object_manager = bus_->GetObjectManager( 258 ObjectManager* object_manager = bus_->GetObjectManager(
262 "org.chromium.TestService", 259 "org.chromium.TestService",
263 dbus::ObjectPath("/org/chromium/TestService")); 260 ObjectPath("/org/chromium/TestService"));
264 EXPECT_EQ(object_manager_, object_manager); 261 EXPECT_EQ(object_manager_, object_manager);
265 } 262 }
266 263
267 TEST_F(ObjectManagerTest, DifferentObjectForService) { 264 TEST_F(ObjectManagerTest, DifferentObjectForService) {
268 dbus::ObjectManager* object_manager = bus_->GetObjectManager( 265 ObjectManager* object_manager = bus_->GetObjectManager(
269 "org.chromium.DifferentService", 266 "org.chromium.DifferentService",
270 dbus::ObjectPath("/org/chromium/TestService")); 267 ObjectPath("/org/chromium/TestService"));
271 EXPECT_NE(object_manager_, object_manager); 268 EXPECT_NE(object_manager_, object_manager);
272 } 269 }
273 270
274 TEST_F(ObjectManagerTest, DifferentObjectForPath) { 271 TEST_F(ObjectManagerTest, DifferentObjectForPath) {
275 dbus::ObjectManager* object_manager = bus_->GetObjectManager( 272 ObjectManager* object_manager = bus_->GetObjectManager(
276 "org.chromium.TestService", 273 "org.chromium.TestService",
277 dbus::ObjectPath("/org/chromium/DifferentService")); 274 ObjectPath("/org/chromium/DifferentService"));
278 EXPECT_NE(object_manager_, object_manager); 275 EXPECT_NE(object_manager_, object_manager);
279 } 276 }
280 277
281 TEST_F(ObjectManagerTest, SecondObject) { 278 TEST_F(ObjectManagerTest, SecondObject) {
282 PerformAction("AddObject", dbus::ObjectPath("/org/chromium/SecondObject")); 279 PerformAction("AddObject", ObjectPath("/org/chromium/SecondObject"));
283 WaitForObject(); 280 WaitForObject();
284 281
285 dbus::ObjectProxy* object_proxy = object_manager_->GetObjectProxy( 282 ObjectProxy* object_proxy = object_manager_->GetObjectProxy(
286 dbus::ObjectPath("/org/chromium/SecondObject")); 283 ObjectPath("/org/chromium/SecondObject"));
287 EXPECT_TRUE(object_proxy != NULL); 284 EXPECT_TRUE(object_proxy != NULL);
288 285
289 Properties* properties = static_cast<Properties*>( 286 Properties* properties = static_cast<Properties*>(
290 object_manager_->GetProperties( 287 object_manager_->GetProperties(ObjectPath("/org/chromium/SecondObject"),
291 dbus::ObjectPath("/org/chromium/SecondObject"), 288 "org.chromium.TestInterface"));
292 "org.chromium.TestInterface"));
293 EXPECT_TRUE(properties != NULL); 289 EXPECT_TRUE(properties != NULL);
294 290
295 std::vector<dbus::ObjectPath> object_paths = object_manager_->GetObjects(); 291 std::vector<ObjectPath> object_paths = object_manager_->GetObjects();
296 ASSERT_EQ(2U, object_paths.size()); 292 ASSERT_EQ(2U, object_paths.size());
297 293
298 std::sort(object_paths.begin(), object_paths.end()); 294 std::sort(object_paths.begin(), object_paths.end());
299 EXPECT_EQ(dbus::ObjectPath("/org/chromium/SecondObject"), object_paths[0]); 295 EXPECT_EQ(ObjectPath("/org/chromium/SecondObject"), object_paths[0]);
300 EXPECT_EQ(dbus::ObjectPath("/org/chromium/TestObject"), object_paths[1]); 296 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[1]);
301 297
302 object_paths = 298 object_paths =
303 object_manager_->GetObjectsWithInterface("org.chromium.TestInterface"); 299 object_manager_->GetObjectsWithInterface("org.chromium.TestInterface");
304 ASSERT_EQ(2U, object_paths.size()); 300 ASSERT_EQ(2U, object_paths.size());
305 301
306 std::sort(object_paths.begin(), object_paths.end()); 302 std::sort(object_paths.begin(), object_paths.end());
307 EXPECT_EQ(dbus::ObjectPath("/org/chromium/SecondObject"), object_paths[0]); 303 EXPECT_EQ(ObjectPath("/org/chromium/SecondObject"), object_paths[0]);
308 EXPECT_EQ(dbus::ObjectPath("/org/chromium/TestObject"), object_paths[1]); 304 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[1]);
309 } 305 }
310 306
311 TEST_F(ObjectManagerTest, RemoveSecondObject) { 307 TEST_F(ObjectManagerTest, RemoveSecondObject) {
312 PerformAction("AddObject", dbus::ObjectPath("/org/chromium/SecondObject")); 308 PerformAction("AddObject", ObjectPath("/org/chromium/SecondObject"));
313 WaitForObject(); 309 WaitForObject();
314 310
315 std::vector<dbus::ObjectPath> object_paths = object_manager_->GetObjects(); 311 std::vector<ObjectPath> object_paths = object_manager_->GetObjects();
316 ASSERT_EQ(2U, object_paths.size()); 312 ASSERT_EQ(2U, object_paths.size());
317 313
318 PerformAction("RemoveObject", dbus::ObjectPath("/org/chromium/SecondObject")); 314 PerformAction("RemoveObject", ObjectPath("/org/chromium/SecondObject"));
319 WaitForRemoveObject(); 315 WaitForRemoveObject();
320 316
321 dbus::ObjectProxy* object_proxy = object_manager_->GetObjectProxy( 317 ObjectProxy* object_proxy = object_manager_->GetObjectProxy(
322 dbus::ObjectPath("/org/chromium/SecondObject")); 318 ObjectPath("/org/chromium/SecondObject"));
323 EXPECT_TRUE(object_proxy == NULL); 319 EXPECT_TRUE(object_proxy == NULL);
324 320
325 Properties* properties = static_cast<Properties*>( 321 Properties* properties = static_cast<Properties*>(
326 object_manager_->GetProperties( 322 object_manager_->GetProperties(ObjectPath("/org/chromium/SecondObject"),
327 dbus::ObjectPath("/org/chromium/SecondObject"), 323 "org.chromium.TestInterface"));
328 "org.chromium.TestInterface"));
329 EXPECT_TRUE(properties == NULL); 324 EXPECT_TRUE(properties == NULL);
330 325
331 object_paths = object_manager_->GetObjects(); 326 object_paths = object_manager_->GetObjects();
332 ASSERT_EQ(1U, object_paths.size()); 327 ASSERT_EQ(1U, object_paths.size());
333 EXPECT_EQ(dbus::ObjectPath("/org/chromium/TestObject"), object_paths[0]); 328 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[0]);
334 329
335 object_paths = 330 object_paths =
336 object_manager_->GetObjectsWithInterface("org.chromium.TestInterface"); 331 object_manager_->GetObjectsWithInterface("org.chromium.TestInterface");
337 ASSERT_EQ(1U, object_paths.size()); 332 ASSERT_EQ(1U, object_paths.size());
338 EXPECT_EQ(dbus::ObjectPath("/org/chromium/TestObject"), object_paths[0]); 333 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[0]);
339 } 334 }
335
336 } // namespace dbus
OLDNEW
« no previous file with comments | « dbus/mock_unittest.cc ('k') | dbus/property_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698