blob: edb86a3678e57dc8329ae6beb46443d19cbbf001 [file] [log] [blame]
mukesh agrawal8a3188d2011-12-01 20:56:44 +00001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Chris Masone9be4a9d2011-05-16 15:44:09 -07002// 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 Stefanoved2c28c2011-11-29 15:37:30 -08008#include <string>
9
Chris Masone9be4a9d2011-05-16 15:44:09 -070010#include <base/memory/ref_counted.h>
11#include <gmock/gmock.h>
12
Paul Stewartbe5f5b32011-12-07 17:11:11 -080013#include "shill/connection.h"
Chris Masone7aa5f902011-07-11 11:13:35 -070014#include "shill/refptr_types.h"
Chris Masone9be4a9d2011-05-16 15:44:09 -070015#include "shill/service.h"
Gaurav Shah435de2c2011-11-17 19:01:07 -080016#include "shill/technology.h"
Chris Masone9be4a9d2011-05-16 15:44:09 -070017
18namespace shill {
19
Chris Masone9be4a9d2011-05-16 15:44:09 -070020class MockService : public Service {
21 public:
22 // A constructor for the Service object
23 MockService(ControlInterface *control_interface,
24 EventDispatcher *dispatcher,
Thieu Le3426c8f2012-01-11 17:35:11 -080025 Metrics *metrics,
mukesh agrawal51a7e932011-07-27 16:18:26 -070026 Manager *manager);
Chris Masonea82b7112011-05-25 15:16:29 -070027 virtual ~MockService();
Chris Masone9be4a9d2011-05-16 15:44:09 -070028
mukesh agrawal8a3188d2011-12-01 20:56:44 +000029 MOCK_METHOD0(AutoConnect, void());
Darin Petkov4d6d9412011-08-24 13:19:54 -070030 MOCK_METHOD1(Connect, void(Error *error));
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000031 MOCK_METHOD1(Disconnect, void(Error *error));
Gaurav Shah1b7a6162011-11-09 11:41:01 -080032 MOCK_METHOD1(CalculateState, std::string(Error *error));
Paul Stewart22aa71b2011-09-16 12:15:11 -070033 MOCK_CONST_METHOD1(TechnologyIs,
34 bool(const Technology::Identifier technology));
Paul Stewart03dba0b2011-08-22 16:32:45 -070035 MOCK_CONST_METHOD0(state, ConnectState());
Gaurav Shah435de2c2011-11-17 19:01:07 -080036 MOCK_METHOD1(SetState, void(ConnectState state));
37 MOCK_CONST_METHOD0(IsConnected, bool());
38 MOCK_CONST_METHOD0(IsConnecting, bool());
mukesh agrawal8a3188d2011-12-01 20:56:44 +000039 MOCK_CONST_METHOD0(IsFailed, bool());
Paul Stewart03dba0b2011-08-22 16:32:45 -070040 MOCK_METHOD1(SetFailure, void(ConnectFailure failure));
41 MOCK_CONST_METHOD0(failure, ConnectFailure());
Gaurav Shah1b7a6162011-11-09 11:41:01 -080042 MOCK_METHOD1(GetDeviceRpcId, std::string(Error *error));
Chris Masone6791a432011-07-12 13:23:19 -070043 MOCK_CONST_METHOD0(GetRpcIdentifier, std::string());
Chris Masone6515aab2011-10-12 16:19:09 -070044 MOCK_CONST_METHOD0(GetStorageIdentifier, std::string());
Paul Stewart22aa71b2011-09-16 12:15:11 -070045 MOCK_METHOD1(Load, bool(StoreInterface *store_interface));
Paul Stewart65512e12012-03-26 18:01:08 -070046 MOCK_METHOD0(Unload, bool());
Paul Stewart22aa71b2011-09-16 12:15:11 -070047 MOCK_METHOD1(Save, bool(StoreInterface *store_interface));
Gary Moraind93615e2012-04-27 11:50:03 -070048 MOCK_METHOD0(SaveToCurrentProfile, void());
Paul Stewartcb59fed2012-03-21 21:14:46 -070049 MOCK_METHOD2(Configure, void(const KeyValueStore &args, Error *error));
Paul Stewartd215af62012-04-24 23:25:50 -070050 MOCK_CONST_METHOD0(IsPortalDetectionDisabled, bool());
51 MOCK_CONST_METHOD0(IsPortalDetectionAuto, bool());
Paul Stewart10ccbb32012-04-26 15:59:30 -070052 MOCK_CONST_METHOD0(IsRemembered, bool());
Paul Stewart20088d82012-02-16 06:58:55 -080053 MOCK_CONST_METHOD0(HasProxyConfig, bool());
Darin Petkov5eb05422012-05-11 15:45:25 +020054 MOCK_METHOD1(SetConnection, void(const ConnectionRefPtr &connection));
Paul Stewartce4ec192012-03-14 12:53:46 -070055 MOCK_CONST_METHOD0(connection, const ConnectionRefPtr &());
Thieu Le67370f62012-02-14 23:01:42 +000056 MOCK_CONST_METHOD0(explicitly_disconnected, bool());
Gaurav Shah435de2c2011-11-17 19:01:07 -080057 MOCK_CONST_METHOD0(technology, Technology::Identifier());
Chris Masone6515aab2011-10-12 16:19:09 -070058 // Set a string for this Service via |store|. Can be wired to Save() for
59 // test purposes.
60 bool FauxSave(StoreInterface *store);
Paul Stewartce4ec192012-03-14 12:53:46 -070061 // Sets the connection reference returned by default when connection()
62 // is called.
63 void set_mock_connection(const ConnectionRefPtr &connection) {
64 mock_connection_ = connection;
65 }
Chris Masone6515aab2011-10-12 16:19:09 -070066
Chris Masone9be4a9d2011-05-16 15:44:09 -070067 private:
Paul Stewartce4ec192012-03-14 12:53:46 -070068 ConnectionRefPtr mock_connection_;
Chris Masone9be4a9d2011-05-16 15:44:09 -070069 DISALLOW_COPY_AND_ASSIGN(MockService);
70};
71
72} // namespace shill
73
74#endif // SHILL_MOCK_SERVICE_