| 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 #ifndef CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ | 5 #ifndef CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ |
| 6 #define CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ | 6 #define CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 namespace chromeos { | 39 namespace chromeos { |
| 40 | 40 |
| 41 // A gmock matcher for base::Value types, so we can match them in expectations. | 41 // A gmock matcher for base::Value types, so we can match them in expectations. |
| 42 class ValueMatcher : public MatcherInterface<const base::Value&> { | 42 class ValueMatcher : public MatcherInterface<const base::Value&> { |
| 43 public: | 43 public: |
| 44 explicit ValueMatcher(const base::Value& value); | 44 explicit ValueMatcher(const base::Value& value); |
| 45 | 45 |
| 46 // MatcherInterface overrides. | 46 // MatcherInterface overrides. |
| 47 virtual bool MatchAndExplain(const base::Value& value, | 47 virtual bool MatchAndExplain(const base::Value& value, |
| 48 MatchResultListener* listener) const OVERRIDE; | 48 MatchResultListener* listener) const override; |
| 49 virtual void DescribeTo(::std::ostream* os) const OVERRIDE; | 49 virtual void DescribeTo(::std::ostream* os) const override; |
| 50 virtual void DescribeNegationTo(::std::ostream* os) const OVERRIDE; | 50 virtual void DescribeNegationTo(::std::ostream* os) const override; |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 scoped_ptr<base::Value> expected_value_; | 53 scoped_ptr<base::Value> expected_value_; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 inline Matcher<const base::Value&> ValueEq(const base::Value& expected_value) { | 56 inline Matcher<const base::Value&> ValueEq(const base::Value& expected_value) { |
| 57 return MakeMatcher(new ValueMatcher(expected_value)); | 57 return MakeMatcher(new ValueMatcher(expected_value)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // A class to provide functionalities needed for testing Shill D-Bus clients. | 60 // A class to provide functionalities needed for testing Shill D-Bus clients. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 MockPropertyChangeObserver(); | 94 MockPropertyChangeObserver(); |
| 95 ~MockPropertyChangeObserver(); | 95 ~MockPropertyChangeObserver(); |
| 96 MOCK_METHOD2(OnPropertyChanged, void(const std::string& name, | 96 MOCK_METHOD2(OnPropertyChanged, void(const std::string& name, |
| 97 const base::Value& value)); | 97 const base::Value& value)); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 explicit ShillClientUnittestBase(const std::string& interface_name, | 100 explicit ShillClientUnittestBase(const std::string& interface_name, |
| 101 const dbus::ObjectPath& object_path); | 101 const dbus::ObjectPath& object_path); |
| 102 virtual ~ShillClientUnittestBase(); | 102 virtual ~ShillClientUnittestBase(); |
| 103 | 103 |
| 104 virtual void SetUp() OVERRIDE; | 104 virtual void SetUp() override; |
| 105 virtual void TearDown() OVERRIDE; | 105 virtual void TearDown() override; |
| 106 | 106 |
| 107 protected: | 107 protected: |
| 108 // A callback to intercept and check the method call arguments. | 108 // A callback to intercept and check the method call arguments. |
| 109 typedef base::Callback<void( | 109 typedef base::Callback<void( |
| 110 dbus::MessageReader* reader)> ArgumentCheckCallback; | 110 dbus::MessageReader* reader)> ArgumentCheckCallback; |
| 111 | 111 |
| 112 // Sets expectations for called method name and arguments, and sets response. | 112 // Sets expectations for called method name and arguments, and sets response. |
| 113 void PrepareForMethodCall(const std::string& method_name, | 113 void PrepareForMethodCall(const std::string& method_name, |
| 114 const ArgumentCheckCallback& argument_checker, | 114 const ArgumentCheckCallback& argument_checker, |
| 115 dbus::Response* response); | 115 dbus::Response* response); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 std::string expected_method_name_; | 224 std::string expected_method_name_; |
| 225 // The response which the mock object proxy returns. | 225 // The response which the mock object proxy returns. |
| 226 dbus::Response* response_; | 226 dbus::Response* response_; |
| 227 // A callback to intercept and check the method call arguments. | 227 // A callback to intercept and check the method call arguments. |
| 228 ArgumentCheckCallback argument_checker_; | 228 ArgumentCheckCallback argument_checker_; |
| 229 }; | 229 }; |
| 230 | 230 |
| 231 } // namespace chromeos | 231 } // namespace chromeos |
| 232 | 232 |
| 233 #endif // CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ | 233 #endif // CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ |
| OLD | NEW |