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 "chromeos/network/shill_property_util.h" | 10 #include "chromeos/network/shill_property_util.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 ValueMatcher::ValueMatcher(const base::Value& value) | 47 ValueMatcher::ValueMatcher(const base::Value& value) |
48 : expected_value_(value.DeepCopy()) {} | 48 : expected_value_(value.DeepCopy()) {} |
49 | 49 |
50 bool ValueMatcher::MatchAndExplain(const base::Value& value, | 50 bool ValueMatcher::MatchAndExplain(const base::Value& value, |
51 MatchResultListener* listener) const { | 51 MatchResultListener* listener) const { |
52 return expected_value_->Equals(&value); | 52 return expected_value_->Equals(&value); |
53 } | 53 } |
54 | 54 |
55 void ValueMatcher::DescribeTo(::std::ostream* os) const { | 55 void ValueMatcher::DescribeTo(::std::ostream* os) const { |
56 std::string expected_value_str; | 56 std::string expected_value_str; |
57 base::JSONWriter::WriteWithOptions(expected_value_.get(), | 57 base::JSONWriter::WriteWithOptions(*expected_value_, |
58 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 58 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
59 &expected_value_str); | 59 &expected_value_str); |
60 *os << "value equals " << expected_value_str; | 60 *os << "value equals " << expected_value_str; |
61 } | 61 } |
62 | 62 |
63 void ValueMatcher::DescribeNegationTo(::std::ostream* os) const { | 63 void ValueMatcher::DescribeNegationTo(::std::ostream* os) const { |
64 std::string expected_value_str; | 64 std::string expected_value_str; |
65 base::JSONWriter::WriteWithOptions(expected_value_.get(), | 65 base::JSONWriter::WriteWithOptions(*expected_value_, |
66 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 66 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
67 &expected_value_str); | 67 &expected_value_str); |
68 *os << "value does not equal " << expected_value_str; | 68 *os << "value does not equal " << expected_value_str; |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 ShillClientUnittestBase::MockClosure::MockClosure() {} | 72 ShillClientUnittestBase::MockClosure::MockClosure() {} |
73 | 73 |
74 ShillClientUnittestBase::MockClosure::~MockClosure() {} | 74 ShillClientUnittestBase::MockClosure::~MockClosure() {} |
75 | 75 |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 const std::string& expected_result, | 386 const std::string& expected_result, |
387 const std::string& result) { | 387 const std::string& result) { |
388 EXPECT_EQ(expected_result, result); | 388 EXPECT_EQ(expected_result, result); |
389 } | 389 } |
390 | 390 |
391 // static | 391 // static |
392 void ShillClientUnittestBase::ExpectDictionaryValueResultWithoutStatus( | 392 void ShillClientUnittestBase::ExpectDictionaryValueResultWithoutStatus( |
393 const base::DictionaryValue* expected_result, | 393 const base::DictionaryValue* expected_result, |
394 const base::DictionaryValue& result) { | 394 const base::DictionaryValue& result) { |
395 std::string expected_result_string; | 395 std::string expected_result_string; |
396 base::JSONWriter::Write(expected_result, &expected_result_string); | 396 base::JSONWriter::Write(*expected_result, &expected_result_string); |
397 std::string result_string; | 397 std::string result_string; |
398 base::JSONWriter::Write(&result, &result_string); | 398 base::JSONWriter::Write(result, &result_string); |
399 EXPECT_EQ(expected_result_string, result_string); | 399 EXPECT_EQ(expected_result_string, result_string); |
400 } | 400 } |
401 | 401 |
402 // static | 402 // static |
403 void ShillClientUnittestBase::ExpectDictionaryValueResult( | 403 void ShillClientUnittestBase::ExpectDictionaryValueResult( |
404 const base::DictionaryValue* expected_result, | 404 const base::DictionaryValue* expected_result, |
405 DBusMethodCallStatus call_status, | 405 DBusMethodCallStatus call_status, |
406 const base::DictionaryValue& result) { | 406 const base::DictionaryValue& result) { |
407 EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); | 407 EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); |
408 ExpectDictionaryValueResultWithoutStatus(expected_result, result); | 408 ExpectDictionaryValueResultWithoutStatus(expected_result, result); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 464 |
465 void ShillClientUnittestBase::OnCallMethodWithErrorCallback( | 465 void ShillClientUnittestBase::OnCallMethodWithErrorCallback( |
466 dbus::MethodCall* method_call, | 466 dbus::MethodCall* method_call, |
467 int timeout_ms, | 467 int timeout_ms, |
468 const dbus::ObjectProxy::ResponseCallback& response_callback, | 468 const dbus::ObjectProxy::ResponseCallback& response_callback, |
469 const dbus::ObjectProxy::ErrorCallback& error_callback) { | 469 const dbus::ObjectProxy::ErrorCallback& error_callback) { |
470 OnCallMethod(method_call, timeout_ms, response_callback); | 470 OnCallMethod(method_call, timeout_ms, response_callback); |
471 } | 471 } |
472 | 472 |
473 } // namespace chromeos | 473 } // namespace chromeos |
OLD | NEW |