blob: 304ed05727fdad0e8139ca5f30d47231c63de45c [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());
mukesh agrawaldc7b8442012-09-27 13:48:14 -070030 MOCK_METHOD2(Connect, void(Error *error, const char *reason));
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000031 MOCK_METHOD1(Disconnect, void(Error *error));
Christopher Wileyabd3b502012-09-26 13:08:52 -070032 MOCK_METHOD2(DisconnectWithFailure, void(Service::ConnectFailure failure,
33 Error *error));
34 MOCK_METHOD1(UserInitiatedDisconnect, void(Error *error));
Gaurav Shah1b7a6162011-11-09 11:41:01 -080035 MOCK_METHOD1(CalculateState, std::string(Error *error));
Paul Stewart03dba0b2011-08-22 16:32:45 -070036 MOCK_CONST_METHOD0(state, ConnectState());
Gaurav Shah435de2c2011-11-17 19:01:07 -080037 MOCK_METHOD1(SetState, void(ConnectState state));
38 MOCK_CONST_METHOD0(IsConnected, bool());
39 MOCK_CONST_METHOD0(IsConnecting, bool());
Paul Stewartdf3c0a82012-11-09 15:54:33 -080040 MOCK_CONST_METHOD1(IsDependentOn, bool(const ServiceRefPtr &b));
mukesh agrawal8a3188d2011-12-01 20:56:44 +000041 MOCK_CONST_METHOD0(IsFailed, bool());
Paul Stewartbfb82552012-10-24 16:48:48 -070042 MOCK_CONST_METHOD0(IsVisible, bool());
Paul Stewart03dba0b2011-08-22 16:32:45 -070043 MOCK_METHOD1(SetFailure, void(ConnectFailure failure));
44 MOCK_CONST_METHOD0(failure, ConnectFailure());
Gaurav Shah1b7a6162011-11-09 11:41:01 -080045 MOCK_METHOD1(GetDeviceRpcId, std::string(Error *error));
Chris Masone6791a432011-07-12 13:23:19 -070046 MOCK_CONST_METHOD0(GetRpcIdentifier, std::string());
Chris Masone6515aab2011-10-12 16:19:09 -070047 MOCK_CONST_METHOD0(GetStorageIdentifier, std::string());
Paul Stewart967eaeb2013-04-25 19:53:07 -070048 MOCK_CONST_METHOD1(GetLoadableStorageIdentifier,
49 std::string(const StoreInterface &store_interface));
Paul Stewart22aa71b2011-09-16 12:15:11 -070050 MOCK_METHOD1(Load, bool(StoreInterface *store_interface));
Paul Stewart65512e12012-03-26 18:01:08 -070051 MOCK_METHOD0(Unload, bool());
Paul Stewart22aa71b2011-09-16 12:15:11 -070052 MOCK_METHOD1(Save, bool(StoreInterface *store_interface));
Gary Moraind93615e2012-04-27 11:50:03 -070053 MOCK_METHOD0(SaveToCurrentProfile, void());
Paul Stewartcb59fed2012-03-21 21:14:46 -070054 MOCK_METHOD2(Configure, void(const KeyValueStore &args, Error *error));
Paul Stewart7a20aa42013-01-17 12:21:41 -080055 MOCK_CONST_METHOD1(DoPropertiesMatch, bool(const KeyValueStore &args));
Paul Stewart35eff132013-04-12 12:08:40 -070056 MOCK_CONST_METHOD0(Is8021xConnectable, bool());
Paul Stewartd215af62012-04-24 23:25:50 -070057 MOCK_CONST_METHOD0(IsPortalDetectionDisabled, bool());
58 MOCK_CONST_METHOD0(IsPortalDetectionAuto, bool());
Paul Stewart10ccbb32012-04-26 15:59:30 -070059 MOCK_CONST_METHOD0(IsRemembered, bool());
Paul Stewart20088d82012-02-16 06:58:55 -080060 MOCK_CONST_METHOD0(HasProxyConfig, bool());
Darin Petkov5eb05422012-05-11 15:45:25 +020061 MOCK_METHOD1(SetConnection, void(const ConnectionRefPtr &connection));
Paul Stewartce4ec192012-03-14 12:53:46 -070062 MOCK_CONST_METHOD0(connection, const ConnectionRefPtr &());
Thieu Le67370f62012-02-14 23:01:42 +000063 MOCK_CONST_METHOD0(explicitly_disconnected, bool());
Paul Stewart35eff132013-04-12 12:08:40 -070064 MOCK_CONST_METHOD0(eap, const EapCredentials *());
Gaurav Shah435de2c2011-11-17 19:01:07 -080065 MOCK_CONST_METHOD0(technology, Technology::Identifier());
mukesh agrawalbebf1b82013-04-23 15:06:33 -070066 MOCK_METHOD1(OnPropertyChanged, void(const std::string &property));
Chris Masone6515aab2011-10-12 16:19:09 -070067 // Set a string for this Service via |store|. Can be wired to Save() for
68 // test purposes.
69 bool FauxSave(StoreInterface *store);
Paul Stewartce4ec192012-03-14 12:53:46 -070070 // 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 Petkov457728b2013-01-09 09:49:08 +010075 const std::string &friendly_name() const { return Service::friendly_name(); }
Chris Masone6515aab2011-10-12 16:19:09 -070076
Chris Masone9be4a9d2011-05-16 15:44:09 -070077 private:
Paul Stewartce4ec192012-03-14 12:53:46 -070078 ConnectionRefPtr mock_connection_;
Chris Masone9be4a9d2011-05-16 15:44:09 -070079 DISALLOW_COPY_AND_ASSIGN(MockService);
80};
81
82} // namespace shill
83
84#endif // SHILL_MOCK_SERVICE_