OLD | NEW |
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/property.h" | 5 #include "dbus/property.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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 struct Properties : public dbus::PropertySet { | 29 struct Properties : public dbus::PropertySet { |
30 dbus::Property<std::string> name; | 30 dbus::Property<std::string> name; |
31 dbus::Property<int16> version; | 31 dbus::Property<int16> version; |
32 dbus::Property<std::vector<std::string> > methods; | 32 dbus::Property<std::vector<std::string> > methods; |
33 dbus::Property<std::vector<dbus::ObjectPath> > objects; | 33 dbus::Property<std::vector<dbus::ObjectPath> > objects; |
34 | 34 |
35 Properties(dbus::ObjectProxy* object_proxy, | 35 Properties(dbus::ObjectProxy* object_proxy, |
36 PropertyChangedCallback property_changed_callback) | 36 PropertyChangedCallback property_changed_callback) |
37 : dbus::PropertySet(object_proxy, | 37 : dbus::PropertySet(object_proxy, |
38 "org.chromium.TestService", | 38 "org.chromium.TestInterface", |
39 property_changed_callback) { | 39 property_changed_callback) { |
40 RegisterProperty("Name", &name); | 40 RegisterProperty("Name", &name); |
41 RegisterProperty("Version", &version); | 41 RegisterProperty("Version", &version); |
42 RegisterProperty("Methods", &methods); | 42 RegisterProperty("Methods", &methods); |
43 RegisterProperty("Objects", &objects); | 43 RegisterProperty("Objects", &objects); |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 virtual void SetUp() { | 47 virtual void SetUp() { |
48 // Make the main thread not to allow IO. | 48 // Make the main thread not to allow IO. |
(...skipping 13 matching lines...) Expand all Loading... |
62 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); | 62 ASSERT_TRUE(test_service_->WaitUntilServiceIsStarted()); |
63 ASSERT_TRUE(test_service_->HasDBusThread()); | 63 ASSERT_TRUE(test_service_->HasDBusThread()); |
64 | 64 |
65 // Create the client, using the D-Bus thread. | 65 // Create the client, using the D-Bus thread. |
66 dbus::Bus::Options bus_options; | 66 dbus::Bus::Options bus_options; |
67 bus_options.bus_type = dbus::Bus::SESSION; | 67 bus_options.bus_type = dbus::Bus::SESSION; |
68 bus_options.connection_type = dbus::Bus::PRIVATE; | 68 bus_options.connection_type = dbus::Bus::PRIVATE; |
69 bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); | 69 bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); |
70 bus_ = new dbus::Bus(bus_options); | 70 bus_ = new dbus::Bus(bus_options); |
71 object_proxy_ = bus_->GetObjectProxy( | 71 object_proxy_ = bus_->GetObjectProxy( |
72 "org.chromium.TestService", | 72 "org.chromium.TestInterface", |
73 dbus::ObjectPath("/org/chromium/TestObject")); | 73 dbus::ObjectPath("/org/chromium/TestObject")); |
74 ASSERT_TRUE(bus_->HasDBusThread()); | 74 ASSERT_TRUE(bus_->HasDBusThread()); |
75 | 75 |
76 // Create the properties structure | 76 // Create the properties structure |
77 properties_.reset(new Properties( | 77 properties_.reset(new Properties( |
78 object_proxy_, | 78 object_proxy_, |
79 base::Bind(&PropertyTest::OnPropertyChanged, | 79 base::Bind(&PropertyTest::OnPropertyChanged, |
80 base::Unretained(this)))); | 80 base::Unretained(this)))); |
81 properties_->ConnectSignals(); | 81 properties_->ConnectSignals(); |
82 properties_->GetAll(); | 82 properties_->GetAll(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 base::Bind(&PropertyTest::PropertyCallback, | 238 base::Bind(&PropertyTest::PropertyCallback, |
239 base::Unretained(this), | 239 base::Unretained(this), |
240 "Set")); | 240 "Set")); |
241 WaitForCallback("Set"); | 241 WaitForCallback("Set"); |
242 | 242 |
243 // TestService sends a property update. | 243 // TestService sends a property update. |
244 WaitForUpdates(1); | 244 WaitForUpdates(1); |
245 | 245 |
246 EXPECT_EQ("NewService", properties_->name.value()); | 246 EXPECT_EQ("NewService", properties_->name.value()); |
247 } | 247 } |
OLD | NEW |