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()); |
Darin Petkov | 4d6d941 | 2011-08-24 13:19:54 -0700 | [diff] [blame] | 30 | MOCK_METHOD1(Connect, void(Error *error)); |
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()); |
mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 40 | MOCK_CONST_METHOD0(IsFailed, bool()); |
Paul Stewart | bfb8255 | 2012-10-24 16:48:48 -0700 | [diff] [blame] | 41 | MOCK_CONST_METHOD0(IsVisible, bool()); |
Paul Stewart | 03dba0b | 2011-08-22 16:32:45 -0700 | [diff] [blame] | 42 | MOCK_METHOD1(SetFailure, void(ConnectFailure failure)); |
| 43 | MOCK_CONST_METHOD0(failure, ConnectFailure()); |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 44 | MOCK_METHOD1(GetDeviceRpcId, std::string(Error *error)); |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 45 | MOCK_CONST_METHOD0(GetRpcIdentifier, std::string()); |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 46 | MOCK_CONST_METHOD0(GetStorageIdentifier, std::string()); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 47 | MOCK_METHOD1(Load, bool(StoreInterface *store_interface)); |
Paul Stewart | 65512e1 | 2012-03-26 18:01:08 -0700 | [diff] [blame] | 48 | MOCK_METHOD0(Unload, bool()); |
Paul Stewart | 22aa71b | 2011-09-16 12:15:11 -0700 | [diff] [blame] | 49 | MOCK_METHOD1(Save, bool(StoreInterface *store_interface)); |
Gary Morain | d93615e | 2012-04-27 11:50:03 -0700 | [diff] [blame] | 50 | MOCK_METHOD0(SaveToCurrentProfile, void()); |
Paul Stewart | cb59fed | 2012-03-21 21:14:46 -0700 | [diff] [blame] | 51 | MOCK_METHOD2(Configure, void(const KeyValueStore &args, Error *error)); |
Paul Stewart | d215af6 | 2012-04-24 23:25:50 -0700 | [diff] [blame] | 52 | MOCK_CONST_METHOD0(IsPortalDetectionDisabled, bool()); |
| 53 | MOCK_CONST_METHOD0(IsPortalDetectionAuto, bool()); |
Paul Stewart | 10ccbb3 | 2012-04-26 15:59:30 -0700 | [diff] [blame] | 54 | MOCK_CONST_METHOD0(IsRemembered, bool()); |
Paul Stewart | 20088d8 | 2012-02-16 06:58:55 -0800 | [diff] [blame] | 55 | MOCK_CONST_METHOD0(HasProxyConfig, bool()); |
Darin Petkov | 5eb0542 | 2012-05-11 15:45:25 +0200 | [diff] [blame] | 56 | MOCK_METHOD1(SetConnection, void(const ConnectionRefPtr &connection)); |
Paul Stewart | ce4ec19 | 2012-03-14 12:53:46 -0700 | [diff] [blame] | 57 | MOCK_CONST_METHOD0(connection, const ConnectionRefPtr &()); |
Thieu Le | 67370f6 | 2012-02-14 23:01:42 +0000 | [diff] [blame] | 58 | MOCK_CONST_METHOD0(explicitly_disconnected, bool()); |
Gaurav Shah | 435de2c | 2011-11-17 19:01:07 -0800 | [diff] [blame] | 59 | MOCK_CONST_METHOD0(technology, Technology::Identifier()); |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 60 | // Set a string for this Service via |store|. Can be wired to Save() for |
| 61 | // test purposes. |
| 62 | bool FauxSave(StoreInterface *store); |
Paul Stewart | ce4ec19 | 2012-03-14 12:53:46 -0700 | [diff] [blame] | 63 | // Sets the connection reference returned by default when connection() |
| 64 | // is called. |
| 65 | void set_mock_connection(const ConnectionRefPtr &connection) { |
| 66 | mock_connection_ = connection; |
| 67 | } |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 68 | |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 69 | private: |
Paul Stewart | ce4ec19 | 2012-03-14 12:53:46 -0700 | [diff] [blame] | 70 | ConnectionRefPtr mock_connection_; |
Chris Masone | 9be4a9d | 2011-05-16 15:44:09 -0700 | [diff] [blame] | 71 | DISALLOW_COPY_AND_ASSIGN(MockService); |
| 72 | }; |
| 73 | |
| 74 | } // namespace shill |
| 75 | |
| 76 | #endif // SHILL_MOCK_SERVICE_ |