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 "chromeos/dbus/shill_client_unittest_base.h" | 5 #include "chromeos/dbus/shill_client_unittest_base.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // static | 189 // static |
190 void ShillClientUnittestBase::ExpectObjectPathResult( | 190 void ShillClientUnittestBase::ExpectObjectPathResult( |
191 const dbus::ObjectPath& expected_result, | 191 const dbus::ObjectPath& expected_result, |
192 DBusMethodCallStatus call_status, | 192 DBusMethodCallStatus call_status, |
193 const dbus::ObjectPath& result) { | 193 const dbus::ObjectPath& result) { |
194 EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); | 194 EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); |
195 EXPECT_EQ(expected_result, result); | 195 EXPECT_EQ(expected_result, result); |
196 } | 196 } |
197 | 197 |
198 // static | 198 // static |
199 void ShillClientUnittestBase::ExpectDictionaryValueResult( | 199 void ShillClientUnittestBase::ExpectObjectPathResultWithoutStatus( |
| 200 const dbus::ObjectPath& expected_result, |
| 201 const dbus::ObjectPath& result) { |
| 202 EXPECT_EQ(expected_result, result); |
| 203 } |
| 204 |
| 205 // static |
| 206 void ShillClientUnittestBase::ExpectDictionaryValueResultWithoutStatus( |
200 const base::DictionaryValue* expected_result, | 207 const base::DictionaryValue* expected_result, |
201 DBusMethodCallStatus call_status, | |
202 const base::DictionaryValue& result) { | 208 const base::DictionaryValue& result) { |
203 EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); | |
204 std::string expected_result_string; | 209 std::string expected_result_string; |
205 base::JSONWriter::Write(expected_result, &expected_result_string); | 210 base::JSONWriter::Write(expected_result, &expected_result_string); |
206 std::string result_string; | 211 std::string result_string; |
207 base::JSONWriter::Write(&result, &result_string); | 212 base::JSONWriter::Write(&result, &result_string); |
208 EXPECT_EQ(expected_result_string, result_string); | 213 EXPECT_EQ(expected_result_string, result_string); |
209 } | 214 } |
210 | 215 |
| 216 // static |
| 217 void ShillClientUnittestBase::ExpectDictionaryValueResult( |
| 218 const base::DictionaryValue* expected_result, |
| 219 DBusMethodCallStatus call_status, |
| 220 const base::DictionaryValue& result) { |
| 221 EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); |
| 222 ExpectDictionaryValueResultWithoutStatus(expected_result, result); |
| 223 } |
| 224 |
211 void ShillClientUnittestBase::OnConnectToSignal( | 225 void ShillClientUnittestBase::OnConnectToSignal( |
212 const std::string& interface_name, | 226 const std::string& interface_name, |
213 const std::string& signal_name, | 227 const std::string& signal_name, |
214 const dbus::ObjectProxy::SignalCallback& signal_callback, | 228 const dbus::ObjectProxy::SignalCallback& signal_callback, |
215 const dbus::ObjectProxy::OnConnectedCallback& on_connected_callback) { | 229 const dbus::ObjectProxy::OnConnectedCallback& on_connected_callback) { |
216 property_changed_handler_ = signal_callback; | 230 property_changed_handler_ = signal_callback; |
217 const bool success = true; | 231 const bool success = true; |
218 message_loop_.PostTask(FROM_HERE, | 232 message_loop_.PostTask(FROM_HERE, |
219 base::Bind(on_connected_callback, | 233 base::Bind(on_connected_callback, |
220 interface_name, | 234 interface_name, |
(...skipping 26 matching lines...) Expand all Loading... |
247 int timeout_ms) { | 261 int timeout_ms) { |
248 EXPECT_EQ(interface_name_, method_call->GetInterface()); | 262 EXPECT_EQ(interface_name_, method_call->GetInterface()); |
249 EXPECT_EQ(expected_method_name_, method_call->GetMember()); | 263 EXPECT_EQ(expected_method_name_, method_call->GetMember()); |
250 dbus::MessageReader reader(method_call); | 264 dbus::MessageReader reader(method_call); |
251 argument_checker_.Run(&reader); | 265 argument_checker_.Run(&reader); |
252 return dbus::Response::FromRawMessage( | 266 return dbus::Response::FromRawMessage( |
253 dbus_message_copy(response_->raw_message())); | 267 dbus_message_copy(response_->raw_message())); |
254 } | 268 } |
255 | 269 |
256 } // namespace chromeos | 270 } // namespace chromeos |
OLD | NEW |