mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SHILL_MOCK_SERVICE_ |
| 6 | #define SHILL_MOCK_SERVICE_ |
| 7 | |
Hristo Stefanov | ed2c28c | 2011-11-29 15:37:30 -0800 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 10 | #include <base/memory/ref_counted.h> |
| 11 | #include <gmock/gmock.h> |
| 12 | |
Paul Stewart | be5f5b3 | 2011-12-07 17:11:11 -0800 | [diff] [blame] | 13 | #include "shill/connection.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 14 | #include "shill/refptr_types.h" |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 15 | #include "shill/service.h" |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 16 | #include "shill/technology.h" |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 17 | |
| 18 | namespace shill { |
| 19 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 20 | class MockService : public Service { |
| 21 | public: |
| 22 | // A constructor for the Service object |
| 23 | MockService(ControlInterface *control_interface, |
| 24 | EventDispatcher *dispatcher, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 25 | Metrics *metrics, |
mukesh agrawal | 51a7e93 | 2011-07-27 16:18:26 -0700 | [diff] [blame] | 26 | Manager *manager); |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 27 | virtual ~MockService(); |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 28 | |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 29 | MOCK_METHOD0(AutoConnect, void()); |
mukesh agrawal | dc7b844 | 2012-09-27 13:48:14 -0700 | [diff] [blame] | 30 | MOCK_METHOD2(Connect, void(Error *error, const char *reason)); |
mukesh agrawal | 0ed0f2e | 2011-12-05 20:36:17 +0000 | [diff] [blame] | 31 | MOCK_METHOD1(Disconnect, void(Error *error)); |
Christopher Wiley | abd3b50 | 2012-09-26 13:08:52 -0700 | [diff] [blame] | 32 | MOCK_METHOD2(DisconnectWithFailure, void(Service::ConnectFailure failure, |
| 33 | Error *error)); |
| 34 | MOCK_METHOD1(UserInitiatedDisconnect, void(Error *error)); |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 35 | MOCK_METHOD1(CalculateState, std::string(Error *error)); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 36 | MOCK_CONST_METHOD0(state, ConnectState()); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 37 | MOCK_METHOD1(SetState, void(ConnectState state)); |
| 38 | MOCK_CONST_METHOD0(IsConnected, bool()); |
| 39 | MOCK_CONST_METHOD0(IsConnecting, bool()); |
Paul Stewart | df3c0a8 | 2012-11-09 15:54:33 -0800 | [diff] [blame] | 40 | MOCK_CONST_METHOD1(IsDependentOn, bool(const ServiceRefPtr &b)); |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 41 | MOCK_CONST_METHOD0(IsFailed, bool()); |
Paul Stewart | bfb8255 | 2012-10-24 16:48:48 -0700 | [diff] [blame] | 42 | MOCK_CONST_METHOD0(IsVisible, bool()); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 43 | MOCK_METHOD1(SetFailure, void(ConnectFailure failure)); |
| 44 | MOCK_CONST_METHOD0(failure, ConnectFailure()); |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 45 | MOCK_METHOD1(GetDeviceRpcId, std::string(Error *error)); |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 46 | MOCK_CONST_METHOD0(GetRpcIdentifier, std::string()); |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 47 | MOCK_CONST_METHOD0(GetStorageIdentifier, std::string()); |
Paul Stewart | 967eaeb | 2013-04-25 19:53:07 -0700 | [diff] [blame] | 48 | MOCK_CONST_METHOD1(GetLoadableStorageIdentifier, |
| 49 | std::string(const StoreInterface &store_interface)); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 50 | MOCK_METHOD1(Load, bool(StoreInterface *store_interface)); |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 51 | MOCK_METHOD0(Unload, bool()); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 52 | MOCK_METHOD1(Save, bool(StoreInterface *store_interface)); |
Gary Morain | d93615e | 2012-04-27 11:50:03 -0700 | [diff] [blame] | 53 | MOCK_METHOD0(SaveToCurrentProfile, void()); |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 54 | MOCK_METHOD2(Configure, void(const KeyValueStore &args, Error *error)); |
Paul Stewart | 7a20aa4 | 2013-01-17 12:21:41 -0800 | [diff] [blame] | 55 | MOCK_CONST_METHOD1(DoPropertiesMatch, bool(const KeyValueStore &args)); |
Paul Stewart | 35eff13 | 2013-04-12 12:08:40 -0700 | [diff] [blame] | 56 | MOCK_CONST_METHOD0(Is8021xConnectable, bool()); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 57 | MOCK_CONST_METHOD0(IsPortalDetectionDisabled, bool()); |
| 58 | MOCK_CONST_METHOD0(IsPortalDetectionAuto, bool()); |
Paul Stewart | 10ccbb3 | 2012-04-26 15:59:30 -0700 | [diff] [blame] | 59 | MOCK_CONST_METHOD0(IsRemembered, bool()); |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 60 | MOCK_CONST_METHOD0(HasProxyConfig, bool()); |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 61 | MOCK_METHOD1(SetConnection, void(const ConnectionRefPtr &connection)); |
Paul Stewart | ce4ec19 | 2012-03-14 12:53:46 -0700 | [diff] [blame] | 62 | MOCK_CONST_METHOD0(connection, const ConnectionRefPtr &()); |
Thieu Le | 67370f6 | 2012-02-14 23:01:42 +0000 | [diff] [blame] | 63 | MOCK_CONST_METHOD0(explicitly_disconnected, bool()); |
Paul Stewart | 35eff13 | 2013-04-12 12:08:40 -0700 | [diff] [blame] | 64 | MOCK_CONST_METHOD0(eap, const EapCredentials *()); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 65 | MOCK_CONST_METHOD0(technology, Technology::Identifier()); |
mukesh agrawal | bebf1b8 | 2013-04-23 15:06:33 -0700 | [diff] [blame] | 66 | MOCK_METHOD1(OnPropertyChanged, void(const std::string &property)); |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 67 | // Set a string for this Service via |store|. Can be wired to Save() for |
| 68 | // test purposes. |
| 69 | bool FauxSave(StoreInterface *store); |
Paul Stewart | ce4ec19 | 2012-03-14 12:53:46 -0700 | [diff] [blame] | 70 | // Sets the connection reference returned by default when connection() |
| 71 | // is called. |
| 72 | void set_mock_connection(const ConnectionRefPtr &connection) { |
| 73 | mock_connection_ = connection; |
| 74 | } |
Darin Petkov | 457728b | 2013-01-09 09:49:08 +0100 | [diff] [blame] | 75 | const std::string &friendly_name() const { return Service::friendly_name(); } |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 76 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 77 | private: |
Paul Stewart | ce4ec19 | 2012-03-14 12:53:46 -0700 | [diff] [blame] | 78 | ConnectionRefPtr mock_connection_; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 79 | DISALLOW_COPY_AND_ASSIGN(MockService); |
| 80 | }; |
| 81 | |
| 82 | } // namespace shill |
| 83 | |
| 84 | #endif // SHILL_MOCK_SERVICE_ |