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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 bus_options.connection_type = dbus::Bus::PRIVATE; | 69 bus_options.connection_type = dbus::Bus::PRIVATE; |
70 bus_options.dbus_thread_message_loop_proxy = | 70 bus_options.dbus_thread_message_loop_proxy = |
71 dbus_thread_->message_loop_proxy(); | 71 dbus_thread_->message_loop_proxy(); |
72 bus_ = new dbus::Bus(bus_options); | 72 bus_ = new dbus::Bus(bus_options); |
73 object_proxy_ = bus_->GetObjectProxy( | 73 object_proxy_ = bus_->GetObjectProxy( |
74 "org.chromium.TestService", | 74 "org.chromium.TestService", |
75 dbus::ObjectPath("/org/chromium/TestObject")); | 75 dbus::ObjectPath("/org/chromium/TestObject")); |
76 ASSERT_TRUE(bus_->HasDBusThread()); | 76 ASSERT_TRUE(bus_->HasDBusThread()); |
77 | 77 |
78 // Create the properties structure | 78 // Create the properties structure |
79 properties_ = new Properties(object_proxy_, | 79 properties_.reset(new Properties( |
80 base::Bind(&PropertyTest::OnPropertyChanged, | 80 object_proxy_, |
81 base::Unretained(this))); | 81 base::Bind(&PropertyTest::OnPropertyChanged, |
| 82 base::Unretained(this)))); |
82 properties_->ConnectSignals(); | 83 properties_->ConnectSignals(); |
83 properties_->GetAll(); | 84 properties_->GetAll(); |
84 } | 85 } |
85 | 86 |
86 virtual void TearDown() { | 87 virtual void TearDown() { |
87 bus_->ShutdownOnDBusThreadAndBlock(); | 88 bus_->ShutdownOnDBusThreadAndBlock(); |
88 | 89 |
89 // Shut down the service. | 90 // Shut down the service. |
90 test_service_->ShutdownAndBlock(); | 91 test_service_->ShutdownAndBlock(); |
91 | 92 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 void WaitForCallback(const std::string& id) { | 135 void WaitForCallback(const std::string& id) { |
135 while (last_callback_ != id) { | 136 while (last_callback_ != id) { |
136 message_loop_.Run(); | 137 message_loop_.Run(); |
137 } | 138 } |
138 } | 139 } |
139 | 140 |
140 MessageLoop message_loop_; | 141 MessageLoop message_loop_; |
141 scoped_ptr<base::Thread> dbus_thread_; | 142 scoped_ptr<base::Thread> dbus_thread_; |
142 scoped_refptr<dbus::Bus> bus_; | 143 scoped_refptr<dbus::Bus> bus_; |
143 dbus::ObjectProxy* object_proxy_; | 144 dbus::ObjectProxy* object_proxy_; |
144 Properties* properties_; | 145 scoped_ptr<Properties> properties_; |
145 scoped_ptr<dbus::TestService> test_service_; | 146 scoped_ptr<dbus::TestService> test_service_; |
146 // Properties updated. | 147 // Properties updated. |
147 std::vector<std::string> updated_properties_; | 148 std::vector<std::string> updated_properties_; |
148 // Last callback received. | 149 // Last callback received. |
149 std::string last_callback_; | 150 std::string last_callback_; |
150 }; | 151 }; |
151 | 152 |
152 TEST_F(PropertyTest, InitialValues) { | 153 TEST_F(PropertyTest, InitialValues) { |
153 WaitForGetAll(); | 154 WaitForGetAll(); |
154 | 155 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 base::Bind(&PropertyTest::PropertyCallback, | 240 base::Bind(&PropertyTest::PropertyCallback, |
240 base::Unretained(this), | 241 base::Unretained(this), |
241 "Set")); | 242 "Set")); |
242 WaitForCallback("Set"); | 243 WaitForCallback("Set"); |
243 | 244 |
244 // TestService sends a property update. | 245 // TestService sends a property update. |
245 WaitForUpdates(1); | 246 WaitForUpdates(1); |
246 | 247 |
247 EXPECT_EQ("NewService", properties_->name.value()); | 248 EXPECT_EQ("NewService", properties_->name.value()); |
248 } | 249 } |
OLD | NEW |