blob: 533d55b11e8be163f68075283b581afea57f58a7 [file] [log] [blame]
[email protected]9cc40cb2013-03-25 18:20:081// 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
3// found in the LICENSE file.
4
5#include "dbus/object_manager.h"
6
avi22437c692015-12-22 18:12:457#include <stddef.h>
8#include <stdint.h>
9
[email protected]9cc40cb2013-03-25 18:20:0810#include <string>
11#include <vector>
12
[email protected]9cc40cb2013-03-25 18:20:0813#include "base/bind.h"
[email protected]2a9ec0e2013-07-17 23:00:3014#include "base/message_loop/message_loop.h"
earthdok9562caf2014-09-03 10:32:3615#include "base/run_loop.h"
fdoray6ef45cf2016-08-25 15:36:3716#include "base/single_thread_task_runner.h"
[email protected]9cc40cb2013-03-25 18:20:0817#include "base/threading/thread.h"
18#include "base/threading/thread_restrictions.h"
19#include "dbus/bus.h"
20#include "dbus/object_path.h"
21#include "dbus/object_proxy.h"
22#include "dbus/property.h"
23#include "dbus/test_service.h"
24#include "testing/gtest/include/gtest/gtest.h"
25
[email protected]2a57ca642013-06-13 06:37:1926namespace dbus {
27
[email protected]9cc40cb2013-03-25 18:20:0828// The object manager test exercises the asynchronous APIs in ObjectManager,
29// and by extension PropertySet and Property<>.
30class ObjectManagerTest
31 : public testing::Test,
[email protected]2a57ca642013-06-13 06:37:1932 public ObjectManager::Interface {
[email protected]9cc40cb2013-03-25 18:20:0833 public:
armansitoebff093d2014-09-05 17:49:3434 ObjectManagerTest() : timeout_expired_(false) {
[email protected]9cc40cb2013-03-25 18:20:0835 }
36
[email protected]2a57ca642013-06-13 06:37:1937 struct Properties : public PropertySet {
38 Property<std::string> name;
avi22437c692015-12-22 18:12:4539 Property<int16_t> version;
Ben Chanc7c9c762017-11-08 01:50:2140 Property<std::vector<std::string>> methods;
41 Property<std::vector<ObjectPath>> objects;
[email protected]9cc40cb2013-03-25 18:20:0842
[email protected]2a57ca642013-06-13 06:37:1943 Properties(ObjectProxy* object_proxy,
[email protected]9cc40cb2013-03-25 18:20:0844 const std::string& interface_name,
45 PropertyChangedCallback property_changed_callback)
[email protected]2a57ca642013-06-13 06:37:1946 : PropertySet(object_proxy, interface_name, property_changed_callback) {
[email protected]9cc40cb2013-03-25 18:20:0847 RegisterProperty("Name", &name);
48 RegisterProperty("Version", &version);
49 RegisterProperty("Methods", &methods);
50 RegisterProperty("Objects", &objects);
51 }
52 };
53
dcheng3bb7119c2014-12-29 18:30:1754 PropertySet* CreateProperties(ObjectProxy* object_proxy,
55 const ObjectPath& object_path,
56 const std::string& interface_name) override {
[email protected]9cc40cb2013-03-25 18:20:0857 Properties* properties = new Properties(
58 object_proxy, interface_name,
59 base::Bind(&ObjectManagerTest::OnPropertyChanged,
60 base::Unretained(this), object_path));
[email protected]2a57ca642013-06-13 06:37:1961 return static_cast<PropertySet*>(properties);
[email protected]9cc40cb2013-03-25 18:20:0862 }
63
dcheng3bb7119c2014-12-29 18:30:1764 void SetUp() override {
[email protected]9cc40cb2013-03-25 18:20:0865 // Make the main thread not to allow IO.
66 base::ThreadRestrictions::SetIOAllowed(false);
67
68 // Start the D-Bus thread.
69 dbus_thread_.reset(new base::Thread("D-Bus Thread"));
70 base::Thread::Options thread_options;
[email protected]ff33b18e2013-05-01 16:10:3071 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
[email protected]9cc40cb2013-03-25 18:20:0872 ASSERT_TRUE(dbus_thread_->StartWithOptions(thread_options));
73
74 // Start the test service, using the D-Bus thread.
[email protected]2a57ca642013-06-13 06:37:1975 TestService::Options options;
skyostil8a033aa2015-06-17 15:46:0476 options.dbus_task_runner = dbus_thread_->task_runner();
[email protected]2a57ca642013-06-13 06:37:1977 test_service_.reset(new TestService(options));
[email protected]9cc40cb2013-03-25 18:20:0878 ASSERT_TRUE(test_service_->StartService());
79 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted());
80 ASSERT_TRUE(test_service_->HasDBusThread());
81
82 // Create the client, using the D-Bus thread.
[email protected]2a57ca642013-06-13 06:37:1983 Bus::Options bus_options;
84 bus_options.bus_type = Bus::SESSION;
85 bus_options.connection_type = Bus::PRIVATE;
skyostil8a033aa2015-06-17 15:46:0486 bus_options.dbus_task_runner = dbus_thread_->task_runner();
[email protected]2a57ca642013-06-13 06:37:1987 bus_ = new Bus(bus_options);
[email protected]9cc40cb2013-03-25 18:20:0888 ASSERT_TRUE(bus_->HasDBusThread());
89
90 object_manager_ = bus_->GetObjectManager(
hashimoto067d84f522016-01-05 08:48:0391 test_service_->service_name(),
[email protected]2a57ca642013-06-13 06:37:1992 ObjectPath("/org/chromium/TestService"));
[email protected]9cc40cb2013-03-25 18:20:0893 object_manager_->RegisterInterface("org.chromium.TestInterface", this);
94
[email protected]9cc40cb2013-03-25 18:20:0895 WaitForObject();
96 }
97
dcheng3bb7119c2014-12-29 18:30:1798 void TearDown() override {
[email protected]9cc40cb2013-03-25 18:20:0899 bus_->ShutdownOnDBusThreadAndBlock();
100
101 // Shut down the service.
102 test_service_->ShutdownAndBlock();
103
104 // Reset to the default.
105 base::ThreadRestrictions::SetIOAllowed(true);
106
107 // Stopping a thread is considered an IO operation, so do this after
108 // allowing IO.
109 test_service_->Stop();
earthdok9562caf2014-09-03 10:32:36110
111 base::RunLoop().RunUntilIdle();
[email protected]9cc40cb2013-03-25 18:20:08112 }
113
[email protected]2a57ca642013-06-13 06:37:19114 void MethodCallback(Response* response) {
[email protected]9cc40cb2013-03-25 18:20:08115 method_callback_called_ = true;
earthdok9562caf2014-09-03 10:32:36116 run_loop_->Quit();
[email protected]9cc40cb2013-03-25 18:20:08117 }
118
armansitoebff093d2014-09-05 17:49:34119 // Called from the PropertiesChangedAsObjectsReceived test case. The test will
120 // not run the message loop if it receives the expected PropertiesChanged
121 // signal before the timeout. This method immediately fails the test.
122 void PropertiesChangedTestTimeout() {
123 timeout_expired_ = true;
124 run_loop_->Quit();
125
126 FAIL() << "Never received PropertiesChanged";
127 }
128
[email protected]2a57ca642013-06-13 06:37:19129 protected:
[email protected]9cc40cb2013-03-25 18:20:08130 // Called when an object is added.
dcheng3bb7119c2014-12-29 18:30:17131 void ObjectAdded(const ObjectPath& object_path,
132 const std::string& interface_name) override {
[email protected]9cc40cb2013-03-25 18:20:08133 added_objects_.push_back(std::make_pair(object_path, interface_name));
earthdok9562caf2014-09-03 10:32:36134 run_loop_->Quit();
[email protected]9cc40cb2013-03-25 18:20:08135 }
136
137 // Called when an object is removed.
dcheng3bb7119c2014-12-29 18:30:17138 void ObjectRemoved(const ObjectPath& object_path,
139 const std::string& interface_name) override {
[email protected]9cc40cb2013-03-25 18:20:08140 removed_objects_.push_back(std::make_pair(object_path, interface_name));
earthdok9562caf2014-09-03 10:32:36141 run_loop_->Quit();
[email protected]9cc40cb2013-03-25 18:20:08142 }
143
144 // Called when a property value is updated.
[email protected]2a57ca642013-06-13 06:37:19145 void OnPropertyChanged(const ObjectPath& object_path,
[email protected]9cc40cb2013-03-25 18:20:08146 const std::string& name) {
armansitoebff093d2014-09-05 17:49:34147 // Store the value of the "Name" property if that's the one that
148 // changed.
149 Properties* properties = static_cast<Properties*>(
150 object_manager_->GetProperties(
151 object_path,
152 "org.chromium.TestInterface"));
153 if (name == properties->name.name())
154 last_name_value_ = properties->name.value();
155
156 // Store the updated property.
[email protected]9cc40cb2013-03-25 18:20:08157 updated_properties_.push_back(name);
earthdok9562caf2014-09-03 10:32:36158 run_loop_->Quit();
[email protected]9cc40cb2013-03-25 18:20:08159 }
160
161 static const size_t kExpectedObjects = 1;
162 static const size_t kExpectedProperties = 4;
163
164 void WaitForObject() {
165 while (added_objects_.size() < kExpectedObjects ||
earthdok9562caf2014-09-03 10:32:36166 updated_properties_.size() < kExpectedProperties) {
167 run_loop_.reset(new base::RunLoop);
168 run_loop_->Run();
169 }
[email protected]9cc40cb2013-03-25 18:20:08170 for (size_t i = 0; i < kExpectedObjects; ++i)
171 added_objects_.erase(added_objects_.begin());
172 for (size_t i = 0; i < kExpectedProperties; ++i)
173 updated_properties_.erase(updated_properties_.begin());
174 }
175
176 void WaitForRemoveObject() {
earthdok9562caf2014-09-03 10:32:36177 while (removed_objects_.size() < kExpectedObjects) {
178 run_loop_.reset(new base::RunLoop);
179 run_loop_->Run();
180 }
[email protected]9cc40cb2013-03-25 18:20:08181 for (size_t i = 0; i < kExpectedObjects; ++i)
182 removed_objects_.erase(removed_objects_.begin());
183 }
184
185 void WaitForMethodCallback() {
earthdok9562caf2014-09-03 10:32:36186 run_loop_.reset(new base::RunLoop);
187 run_loop_->Run();
[email protected]9cc40cb2013-03-25 18:20:08188 method_callback_called_ = false;
189 }
190
[email protected]2a57ca642013-06-13 06:37:19191 void PerformAction(const std::string& action, const ObjectPath& object_path) {
192 ObjectProxy* object_proxy = bus_->GetObjectProxy(
hashimoto067d84f522016-01-05 08:48:03193 test_service_->service_name(),
[email protected]2a57ca642013-06-13 06:37:19194 ObjectPath("/org/chromium/TestObject"));
[email protected]9cc40cb2013-03-25 18:20:08195
[email protected]2a57ca642013-06-13 06:37:19196 MethodCall method_call("org.chromium.TestInterface", "PerformAction");
197 MessageWriter writer(&method_call);
[email protected]9cc40cb2013-03-25 18:20:08198 writer.AppendString(action);
199 writer.AppendObjectPath(object_path);
200
201 object_proxy->CallMethod(&method_call,
[email protected]2a57ca642013-06-13 06:37:19202 ObjectProxy::TIMEOUT_USE_DEFAULT,
[email protected]9cc40cb2013-03-25 18:20:08203 base::Bind(&ObjectManagerTest::MethodCallback,
204 base::Unretained(this)));
205 WaitForMethodCallback();
206 }
207
[email protected]ff33b18e2013-05-01 16:10:30208 base::MessageLoop message_loop_;
dcheng2a193282016-04-08 22:55:04209 std::unique_ptr<base::RunLoop> run_loop_;
210 std::unique_ptr<base::Thread> dbus_thread_;
[email protected]2a57ca642013-06-13 06:37:19211 scoped_refptr<Bus> bus_;
212 ObjectManager* object_manager_;
dcheng2a193282016-04-08 22:55:04213 std::unique_ptr<TestService> test_service_;
[email protected]9cc40cb2013-03-25 18:20:08214
armansitoebff093d2014-09-05 17:49:34215 std::string last_name_value_;
216 bool timeout_expired_;
217
Ben Chanc7c9c762017-11-08 01:50:21218 std::vector<std::pair<ObjectPath, std::string>> added_objects_;
219 std::vector<std::pair<ObjectPath, std::string>> removed_objects_;
[email protected]9cc40cb2013-03-25 18:20:08220 std::vector<std::string> updated_properties_;
221
222 bool method_callback_called_;
223};
224
225
226TEST_F(ObjectManagerTest, InitialObject) {
[email protected]2a57ca642013-06-13 06:37:19227 ObjectProxy* object_proxy = object_manager_->GetObjectProxy(
228 ObjectPath("/org/chromium/TestObject"));
[email protected]9cc40cb2013-03-25 18:20:08229 EXPECT_TRUE(object_proxy != NULL);
230
231 Properties* properties = static_cast<Properties*>(
[email protected]2a57ca642013-06-13 06:37:19232 object_manager_->GetProperties(ObjectPath("/org/chromium/TestObject"),
233 "org.chromium.TestInterface"));
[email protected]9cc40cb2013-03-25 18:20:08234 EXPECT_TRUE(properties != NULL);
235
236 EXPECT_EQ("TestService", properties->name.value());
237 EXPECT_EQ(10, properties->version.value());
238
239 std::vector<std::string> methods = properties->methods.value();
240 ASSERT_EQ(4U, methods.size());
241 EXPECT_EQ("Echo", methods[0]);
242 EXPECT_EQ("SlowEcho", methods[1]);
243 EXPECT_EQ("AsyncEcho", methods[2]);
244 EXPECT_EQ("BrokenMethod", methods[3]);
245
[email protected]2a57ca642013-06-13 06:37:19246 std::vector<ObjectPath> objects = properties->objects.value();
[email protected]9cc40cb2013-03-25 18:20:08247 ASSERT_EQ(1U, objects.size());
[email protected]2a57ca642013-06-13 06:37:19248 EXPECT_EQ(ObjectPath("/TestObjectPath"), objects[0]);
[email protected]9cc40cb2013-03-25 18:20:08249}
250
251TEST_F(ObjectManagerTest, UnknownObjectProxy) {
[email protected]2a57ca642013-06-13 06:37:19252 ObjectProxy* object_proxy = object_manager_->GetObjectProxy(
253 ObjectPath("/org/chromium/UnknownObject"));
[email protected]9cc40cb2013-03-25 18:20:08254 EXPECT_TRUE(object_proxy == NULL);
255}
256
257TEST_F(ObjectManagerTest, UnknownObjectProperties) {
258 Properties* properties = static_cast<Properties*>(
[email protected]2a57ca642013-06-13 06:37:19259 object_manager_->GetProperties(ObjectPath("/org/chromium/UnknownObject"),
260 "org.chromium.TestInterface"));
[email protected]9cc40cb2013-03-25 18:20:08261 EXPECT_TRUE(properties == NULL);
262}
263
264TEST_F(ObjectManagerTest, UnknownInterfaceProperties) {
265 Properties* properties = static_cast<Properties*>(
[email protected]2a57ca642013-06-13 06:37:19266 object_manager_->GetProperties(ObjectPath("/org/chromium/TestObject"),
267 "org.chromium.UnknownService"));
[email protected]9cc40cb2013-03-25 18:20:08268 EXPECT_TRUE(properties == NULL);
269}
270
271TEST_F(ObjectManagerTest, GetObjects) {
[email protected]2a57ca642013-06-13 06:37:19272 std::vector<ObjectPath> object_paths = object_manager_->GetObjects();
[email protected]9cc40cb2013-03-25 18:20:08273 ASSERT_EQ(1U, object_paths.size());
[email protected]2a57ca642013-06-13 06:37:19274 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[0]);
[email protected]9cc40cb2013-03-25 18:20:08275}
276
277TEST_F(ObjectManagerTest, GetObjectsWithInterface) {
[email protected]2a57ca642013-06-13 06:37:19278 std::vector<ObjectPath> object_paths =
[email protected]9cc40cb2013-03-25 18:20:08279 object_manager_->GetObjectsWithInterface("org.chromium.TestInterface");
280 ASSERT_EQ(1U, object_paths.size());
[email protected]2a57ca642013-06-13 06:37:19281 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[0]);
[email protected]9cc40cb2013-03-25 18:20:08282}
283
284TEST_F(ObjectManagerTest, GetObjectsWithUnknownInterface) {
[email protected]2a57ca642013-06-13 06:37:19285 std::vector<ObjectPath> object_paths =
[email protected]9cc40cb2013-03-25 18:20:08286 object_manager_->GetObjectsWithInterface("org.chromium.UnknownService");
287 EXPECT_EQ(0U, object_paths.size());
288}
289
290TEST_F(ObjectManagerTest, SameObject) {
[email protected]2a57ca642013-06-13 06:37:19291 ObjectManager* object_manager = bus_->GetObjectManager(
hashimoto067d84f522016-01-05 08:48:03292 test_service_->service_name(),
[email protected]2a57ca642013-06-13 06:37:19293 ObjectPath("/org/chromium/TestService"));
[email protected]9cc40cb2013-03-25 18:20:08294 EXPECT_EQ(object_manager_, object_manager);
295}
296
297TEST_F(ObjectManagerTest, DifferentObjectForService) {
[email protected]2a57ca642013-06-13 06:37:19298 ObjectManager* object_manager = bus_->GetObjectManager(
[email protected]9cc40cb2013-03-25 18:20:08299 "org.chromium.DifferentService",
[email protected]2a57ca642013-06-13 06:37:19300 ObjectPath("/org/chromium/TestService"));
[email protected]9cc40cb2013-03-25 18:20:08301 EXPECT_NE(object_manager_, object_manager);
302}
303
304TEST_F(ObjectManagerTest, DifferentObjectForPath) {
[email protected]2a57ca642013-06-13 06:37:19305 ObjectManager* object_manager = bus_->GetObjectManager(
hashimoto067d84f522016-01-05 08:48:03306 test_service_->service_name(),
[email protected]2a57ca642013-06-13 06:37:19307 ObjectPath("/org/chromium/DifferentService"));
[email protected]9cc40cb2013-03-25 18:20:08308 EXPECT_NE(object_manager_, object_manager);
309}
310
311TEST_F(ObjectManagerTest, SecondObject) {
[email protected]2a57ca642013-06-13 06:37:19312 PerformAction("AddObject", ObjectPath("/org/chromium/SecondObject"));
[email protected]9cc40cb2013-03-25 18:20:08313 WaitForObject();
314
[email protected]2a57ca642013-06-13 06:37:19315 ObjectProxy* object_proxy = object_manager_->GetObjectProxy(
316 ObjectPath("/org/chromium/SecondObject"));
[email protected]9cc40cb2013-03-25 18:20:08317 EXPECT_TRUE(object_proxy != NULL);
318
319 Properties* properties = static_cast<Properties*>(
[email protected]2a57ca642013-06-13 06:37:19320 object_manager_->GetProperties(ObjectPath("/org/chromium/SecondObject"),
321 "org.chromium.TestInterface"));
[email protected]9cc40cb2013-03-25 18:20:08322 EXPECT_TRUE(properties != NULL);
323
[email protected]2a57ca642013-06-13 06:37:19324 std::vector<ObjectPath> object_paths = object_manager_->GetObjects();
[email protected]9cc40cb2013-03-25 18:20:08325 ASSERT_EQ(2U, object_paths.size());
326
327 std::sort(object_paths.begin(), object_paths.end());
[email protected]2a57ca642013-06-13 06:37:19328 EXPECT_EQ(ObjectPath("/org/chromium/SecondObject"), object_paths[0]);
329 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[1]);
[email protected]9cc40cb2013-03-25 18:20:08330
331 object_paths =
332 object_manager_->GetObjectsWithInterface("org.chromium.TestInterface");
333 ASSERT_EQ(2U, object_paths.size());
334
335 std::sort(object_paths.begin(), object_paths.end());
[email protected]2a57ca642013-06-13 06:37:19336 EXPECT_EQ(ObjectPath("/org/chromium/SecondObject"), object_paths[0]);
337 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[1]);
[email protected]9cc40cb2013-03-25 18:20:08338}
339
340TEST_F(ObjectManagerTest, RemoveSecondObject) {
[email protected]2a57ca642013-06-13 06:37:19341 PerformAction("AddObject", ObjectPath("/org/chromium/SecondObject"));
[email protected]9cc40cb2013-03-25 18:20:08342 WaitForObject();
343
[email protected]2a57ca642013-06-13 06:37:19344 std::vector<ObjectPath> object_paths = object_manager_->GetObjects();
[email protected]9cc40cb2013-03-25 18:20:08345 ASSERT_EQ(2U, object_paths.size());
346
[email protected]2a57ca642013-06-13 06:37:19347 PerformAction("RemoveObject", ObjectPath("/org/chromium/SecondObject"));
[email protected]9cc40cb2013-03-25 18:20:08348 WaitForRemoveObject();
349
[email protected]2a57ca642013-06-13 06:37:19350 ObjectProxy* object_proxy = object_manager_->GetObjectProxy(
351 ObjectPath("/org/chromium/SecondObject"));
[email protected]9cc40cb2013-03-25 18:20:08352 EXPECT_TRUE(object_proxy == NULL);
353
354 Properties* properties = static_cast<Properties*>(
[email protected]2a57ca642013-06-13 06:37:19355 object_manager_->GetProperties(ObjectPath("/org/chromium/SecondObject"),
356 "org.chromium.TestInterface"));
[email protected]9cc40cb2013-03-25 18:20:08357 EXPECT_TRUE(properties == NULL);
358
359 object_paths = object_manager_->GetObjects();
360 ASSERT_EQ(1U, object_paths.size());
[email protected]2a57ca642013-06-13 06:37:19361 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[0]);
[email protected]9cc40cb2013-03-25 18:20:08362
363 object_paths =
364 object_manager_->GetObjectsWithInterface("org.chromium.TestInterface");
365 ASSERT_EQ(1U, object_paths.size());
[email protected]2a57ca642013-06-13 06:37:19366 EXPECT_EQ(ObjectPath("/org/chromium/TestObject"), object_paths[0]);
[email protected]9cc40cb2013-03-25 18:20:08367}
[email protected]2a57ca642013-06-13 06:37:19368
[email protected]043fb8c2014-03-07 02:24:33369TEST_F(ObjectManagerTest, OwnershipLost) {
370 PerformAction("ReleaseOwnership", ObjectPath("/org/chromium/TestService"));
371 WaitForRemoveObject();
372
373 std::vector<ObjectPath> object_paths = object_manager_->GetObjects();
374 ASSERT_EQ(0U, object_paths.size());
375}
376
377TEST_F(ObjectManagerTest, OwnershipLostAndRegained) {
378 PerformAction("Ownership", ObjectPath("/org/chromium/TestService"));
379 WaitForRemoveObject();
380 WaitForObject();
381
382 std::vector<ObjectPath> object_paths = object_manager_->GetObjects();
383 ASSERT_EQ(1U, object_paths.size());
384}
385
armansitoebff093d2014-09-05 17:49:34386TEST_F(ObjectManagerTest, PropertiesChangedAsObjectsReceived) {
387 // Remove the existing object manager.
388 object_manager_->UnregisterInterface("org.chromium.TestInterface");
389 run_loop_.reset(new base::RunLoop);
390 EXPECT_TRUE(bus_->RemoveObjectManager(
hashimoto067d84f522016-01-05 08:48:03391 test_service_->service_name(),
armansitoebff093d2014-09-05 17:49:34392 ObjectPath("/org/chromium/TestService"),
393 run_loop_->QuitClosure()));
394 run_loop_->Run();
395
396 PerformAction("SetSendImmediatePropertiesChanged",
397 ObjectPath("/org/chromium/TestService"));
398
399 object_manager_ = bus_->GetObjectManager(
hashimoto067d84f522016-01-05 08:48:03400 test_service_->service_name(),
armansitoebff093d2014-09-05 17:49:34401 ObjectPath("/org/chromium/TestService"));
402 object_manager_->RegisterInterface("org.chromium.TestInterface", this);
403
404 // The newly created object manager should call GetManagedObjects immediately
405 // after setting up the match rule for PropertiesChanged. We should process
406 // the PropertiesChanged event right after that. If we don't receive it within
407 // 2 seconds, then fail the test.
fdoray6ef45cf2016-08-25 15:36:37408 message_loop_.task_runner()->PostDelayedTask(
409 FROM_HERE, base::Bind(&ObjectManagerTest::PropertiesChangedTestTimeout,
410 base::Unretained(this)),
armansitoebff093d2014-09-05 17:49:34411 base::TimeDelta::FromSeconds(2));
412
413 while (last_name_value_ != "ChangedTestServiceName" && !timeout_expired_) {
414 run_loop_.reset(new base::RunLoop);
415 run_loop_->Run();
416 }
417}
418
[email protected]2a57ca642013-06-13 06:37:19419} // namespace dbus