| 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_FLIMFLAM_CLIENT_UNITTEST_BASE_H_ | 5 #ifndef CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ |
| 6 #define CHROMEOS_DBUS_FLIMFLAM_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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "chromeos/dbus/dbus_method_call_status.h" | 13 #include "chromeos/dbus/dbus_method_call_status.h" |
| 14 #include "chromeos/dbus/flimflam_client_helper.h" | 14 #include "chromeos/dbus/shill_client_helper.h" |
| 15 #include "dbus/mock_bus.h" | 15 #include "dbus/mock_bus.h" |
| 16 #include "dbus/mock_object_proxy.h" | 16 #include "dbus/mock_object_proxy.h" |
| 17 #include "dbus/object_proxy.h" | 17 #include "dbus/object_proxy.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 | 21 |
| 22 class Value; | 22 class Value; |
| 23 class DictionaryValue; | 23 class DictionaryValue; |
| 24 | 24 |
| 25 } // namespace base | 25 } // namespace base |
| 26 | 26 |
| 27 namespace dbus { | 27 namespace dbus { |
| 28 | 28 |
| 29 class MessageReader; | 29 class MessageReader; |
| 30 | 30 |
| 31 } // namespace dbus | 31 } // namespace dbus |
| 32 | 32 |
| 33 namespace chromeos { | 33 namespace chromeos { |
| 34 | 34 |
| 35 // A class to provide functionalities needed for testing Flimflam D-Bus clients. | 35 // A class to provide functionalities needed for testing Shill D-Bus clients. |
| 36 class FlimflamClientUnittestBase : public testing::Test { | 36 class ShillClientUnittestBase : public testing::Test { |
| 37 public: | 37 public: |
| 38 // A mock Closure. | 38 // A mock Closure. |
| 39 class MockClosure { | 39 class MockClosure { |
| 40 public: | 40 public: |
| 41 MockClosure(); | 41 MockClosure(); |
| 42 ~MockClosure(); | 42 ~MockClosure(); |
| 43 MOCK_METHOD0(Run, void()); | 43 MOCK_METHOD0(Run, void()); |
| 44 base::Closure GetCallback(); | 44 base::Closure GetCallback(); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // A mock ErrorCallback. | 47 // A mock ErrorCallback. |
| 48 class MockErrorCallback { | 48 class MockErrorCallback { |
| 49 public: | 49 public: |
| 50 MockErrorCallback(); | 50 MockErrorCallback(); |
| 51 ~MockErrorCallback(); | 51 ~MockErrorCallback(); |
| 52 MOCK_METHOD2(Run, void(const std::string& error_name, | 52 MOCK_METHOD2(Run, void(const std::string& error_name, |
| 53 const std::string& error_mesage)); | 53 const std::string& error_mesage)); |
| 54 FlimflamClientHelper::ErrorCallback GetCallback(); | 54 ShillClientHelper::ErrorCallback GetCallback(); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 explicit FlimflamClientUnittestBase(const std::string& interface_name, | 57 explicit ShillClientUnittestBase(const std::string& interface_name, |
| 58 const dbus::ObjectPath& object_path); | 58 const dbus::ObjectPath& object_path); |
| 59 virtual ~FlimflamClientUnittestBase(); | 59 virtual ~ShillClientUnittestBase(); |
| 60 | 60 |
| 61 virtual void SetUp() OVERRIDE; | 61 virtual void SetUp() OVERRIDE; |
| 62 virtual void TearDown() OVERRIDE; | 62 virtual void TearDown() OVERRIDE; |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 // A callback to intercept and check the method call arguments. | 65 // A callback to intercept and check the method call arguments. |
| 66 typedef base::Callback<void( | 66 typedef base::Callback<void( |
| 67 dbus::MessageReader* reader)> ArgumentCheckCallback; | 67 dbus::MessageReader* reader)> ArgumentCheckCallback; |
| 68 | 68 |
| 69 // Sets expectations for called method name and arguments, and sets response. | 69 // Sets expectations for called method name and arguments, and sets response. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // The name of the method which is expected to be called. | 155 // The name of the method which is expected to be called. |
| 156 std::string expected_method_name_; | 156 std::string expected_method_name_; |
| 157 // The response which the mock object proxy returns. | 157 // The response which the mock object proxy returns. |
| 158 dbus::Response* response_; | 158 dbus::Response* response_; |
| 159 // A callback to intercept and check the method call arguments. | 159 // A callback to intercept and check the method call arguments. |
| 160 ArgumentCheckCallback argument_checker_; | 160 ArgumentCheckCallback argument_checker_; |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 } // namespace chromeos | 163 } // namespace chromeos |
| 164 | 164 |
| 165 #endif // CHROMEOS_DBUS_FLIMFLAM_CLIENT_UNITTEST_BASE_H_ | 165 #endif // CHROMEOS_DBUS_SHILL_CLIENT_UNITTEST_BASE_H_ |
| OLD | NEW |