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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // static | 219 // static |
220 void ShillClientUnittestBase::ExpectObjectPathResult( | 220 void ShillClientUnittestBase::ExpectObjectPathResult( |
221 const dbus::ObjectPath& expected_result, | 221 const dbus::ObjectPath& expected_result, |
222 DBusMethodCallStatus call_status, | 222 DBusMethodCallStatus call_status, |
223 const dbus::ObjectPath& result) { | 223 const dbus::ObjectPath& result) { |
224 EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); | 224 EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); |
225 EXPECT_EQ(expected_result, result); | 225 EXPECT_EQ(expected_result, result); |
226 } | 226 } |
227 | 227 |
228 // static | 228 // static |
229 void ShillClientUnittestBase::ExpectDictionaryValueResult( | 229 void ShillClientUnittestBase::ExpectObjectPathResultWithoutStatus( |
| 230 const dbus::ObjectPath& expected_result, |
| 231 const dbus::ObjectPath& result) { |
| 232 EXPECT_EQ(expected_result, result); |
| 233 } |
| 234 |
| 235 // static |
| 236 void ShillClientUnittestBase::ExpectDictionaryValueResultWithoutStatus( |
230 const base::DictionaryValue* expected_result, | 237 const base::DictionaryValue* expected_result, |
231 DBusMethodCallStatus call_status, | |
232 const base::DictionaryValue& result) { | 238 const base::DictionaryValue& result) { |
233 EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); | |
234 std::string expected_result_string; | 239 std::string expected_result_string; |
235 base::JSONWriter::Write(expected_result, &expected_result_string); | 240 base::JSONWriter::Write(expected_result, &expected_result_string); |
236 std::string result_string; | 241 std::string result_string; |
237 base::JSONWriter::Write(&result, &result_string); | 242 base::JSONWriter::Write(&result, &result_string); |
238 EXPECT_EQ(expected_result_string, result_string); | 243 EXPECT_EQ(expected_result_string, result_string); |
239 } | 244 } |
240 | 245 |
| 246 // static |
| 247 void ShillClientUnittestBase::ExpectDictionaryValueResult( |
| 248 const base::DictionaryValue* expected_result, |
| 249 DBusMethodCallStatus call_status, |
| 250 const base::DictionaryValue& result) { |
| 251 EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); |
| 252 ExpectDictionaryValueResultWithoutStatus(expected_result, result); |
| 253 } |
| 254 |
241 void ShillClientUnittestBase::OnConnectToSignal( | 255 void ShillClientUnittestBase::OnConnectToSignal( |
242 const std::string& interface_name, | 256 const std::string& interface_name, |
243 const std::string& signal_name, | 257 const std::string& signal_name, |
244 const dbus::ObjectProxy::SignalCallback& signal_callback, | 258 const dbus::ObjectProxy::SignalCallback& signal_callback, |
245 const dbus::ObjectProxy::OnConnectedCallback& on_connected_callback) { | 259 const dbus::ObjectProxy::OnConnectedCallback& on_connected_callback) { |
246 property_changed_handler_ = signal_callback; | 260 property_changed_handler_ = signal_callback; |
247 const bool success = true; | 261 const bool success = true; |
248 message_loop_.PostTask(FROM_HERE, | 262 message_loop_.PostTask(FROM_HERE, |
249 base::Bind(on_connected_callback, | 263 base::Bind(on_connected_callback, |
250 interface_name, | 264 interface_name, |
(...skipping 26 matching lines...) Expand all Loading... |
277 int timeout_ms) { | 291 int timeout_ms) { |
278 EXPECT_EQ(interface_name_, method_call->GetInterface()); | 292 EXPECT_EQ(interface_name_, method_call->GetInterface()); |
279 EXPECT_EQ(expected_method_name_, method_call->GetMember()); | 293 EXPECT_EQ(expected_method_name_, method_call->GetMember()); |
280 dbus::MessageReader reader(method_call); | 294 dbus::MessageReader reader(method_call); |
281 argument_checker_.Run(&reader); | 295 argument_checker_.Run(&reader); |
282 return dbus::Response::FromRawMessage( | 296 return dbus::Response::FromRawMessage( |
283 dbus_message_copy(response_->raw_message())); | 297 dbus_message_copy(response_->raw_message())); |
284 } | 298 } |
285 | 299 |
286 } // namespace chromeos | 300 } // namespace chromeos |
OLD | NEW |