1// 2// Copyright (C) 2012 The Android Open Source Project 3// 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15// 16 17#ifndef SHILL_MOCK_MANAGER_H_ 18#define SHILL_MOCK_MANAGER_H_ 19 20#include <string> 21#include <vector> 22 23#include <base/macros.h> 24#include <gmock/gmock.h> 25 26#include "shill/manager.h" 27 28namespace shill { 29 30class MockManager : public Manager { 31 public: 32 MockManager(ControlInterface* control_interface, 33 EventDispatcher* dispatcher, 34 Metrics* metrics); 35 ~MockManager() override; 36 37 MOCK_METHOD0(device_info, DeviceInfo*()); 38 MOCK_METHOD0(modem_info, ModemInfo*()); 39#if !defined(DISABLE_WIRED_8021X) 40 MOCK_CONST_METHOD0(ethernet_eap_provider, EthernetEapProvider*()); 41#endif // DISABLE_WIRED_8021X 42 MOCK_METHOD0(wimax_provider, WiMaxProvider*()); 43 MOCK_METHOD0(mutable_store, PropertyStore*()); 44 MOCK_CONST_METHOD0(store, const PropertyStore&()); 45 MOCK_CONST_METHOD0(run_path, const base::FilePath&()); 46 MOCK_METHOD0(Start, void()); 47 MOCK_METHOD0(Stop, void()); 48 MOCK_METHOD3(SetProfileForService, void(const ServiceRefPtr& to_set, 49 const std::string& profile, 50 Error* error)); 51 MOCK_METHOD1(RegisterDevice, void(const DeviceRefPtr& to_manage)); 52 MOCK_METHOD1(DeregisterDevice, void(const DeviceRefPtr& to_forget)); 53 MOCK_METHOD1(HasService, bool(const ServiceRefPtr& to_manage)); 54 MOCK_METHOD1(RegisterService, void(const ServiceRefPtr& to_manage)); 55 MOCK_METHOD1(UpdateService, void(const ServiceRefPtr& to_update)); 56 MOCK_METHOD1(DeregisterService, void(const ServiceRefPtr& to_forget)); 57 MOCK_METHOD1(RegisterDefaultServiceCallback, 58 int(const ServiceCallback& callback)); 59 MOCK_METHOD1(DeregisterDefaultServiceCallback, void(int tag)); 60 MOCK_METHOD1(UpdateDevice, void(const DeviceRefPtr& to_update)); 61 MOCK_METHOD0(UpdateWiFiProvider, void()); 62 MOCK_METHOD1(OnDeviceGeolocationInfoUpdated, 63 void(const DeviceRefPtr& device)); 64 MOCK_METHOD1(RecheckPortalOnService, void(const ServiceRefPtr& service)); 65 MOCK_METHOD2(HandleProfileEntryDeletion, 66 bool(const ProfileRefPtr& profile, 67 const std::string& entry_name)); 68 MOCK_CONST_METHOD0(GetDefaultService, ServiceRefPtr()); 69 MOCK_METHOD3(GetServiceWithStorageIdentifier, 70 ServiceRefPtr(const ProfileRefPtr& profile, 71 const std::string& entry_name, 72 Error* error)); 73 MOCK_METHOD3(CreateTemporaryServiceFromProfile, 74 ServiceRefPtr(const ProfileRefPtr& profile, 75 const std::string& entry_name, 76 Error* error)); 77 MOCK_CONST_METHOD0(IsConnected, bool()); 78 MOCK_METHOD0(UpdateEnabledTechnologies, void()); 79 MOCK_METHOD1(IsPortalDetectionEnabled, bool(Technology::Identifier tech)); 80 MOCK_CONST_METHOD1(IsServiceEphemeral, 81 bool(const ServiceConstRefPtr& service)); 82 MOCK_CONST_METHOD2(IsProfileBefore, 83 bool(const ProfileRefPtr& a, 84 const ProfileRefPtr& b)); 85 MOCK_CONST_METHOD1(IsTechnologyConnected, 86 bool(Technology::Identifier tech)); 87 MOCK_CONST_METHOD1(IsTechnologyLinkMonitorEnabled, 88 bool(Technology::Identifier tech)); 89 MOCK_CONST_METHOD1(IsTechnologyAutoConnectDisabled, 90 bool(Technology::Identifier tech)); 91 MOCK_CONST_METHOD1(IsDefaultProfile, bool(const StoreInterface* storage)); 92 MOCK_METHOD3(RequestScan, void(Device::ScanType request_origin, 93 const std::string& technology, Error* error)); 94 MOCK_CONST_METHOD0(GetPortalCheckURL, const std::string&()); 95 MOCK_CONST_METHOD0(GetPortalCheckInterval, int()); 96 MOCK_METHOD0(IsSuspending, bool()); 97 MOCK_CONST_METHOD1(GetEnabledDeviceWithTechnology, 98 DeviceRefPtr(Technology::Identifier technology)); 99 MOCK_CONST_METHOD1(GetEnabledDeviceByLinkName, 100 DeviceRefPtr(const std::string& link_name)); 101 MOCK_CONST_METHOD0(GetMinimumMTU, int()); 102 MOCK_CONST_METHOD1(ShouldAcceptHostnameFrom, 103 bool(const std::string& device_name)); 104 MOCK_CONST_METHOD1(IsDHCPv6EnabledForDevice, 105 bool(const std::string& device_name)); 106 MOCK_METHOD1(SetBlacklistedDevices, 107 void(const std::vector<std::string>& blacklisted_devices)); 108 MOCK_METHOD1(SetDHCPv6EnabledDevices, 109 void(const std::vector<std::string>& device_list)); 110 MOCK_METHOD2(SetTechnologyOrder, 111 void(const std::string& order, Error* error)); 112 MOCK_METHOD1(SetIgnoreUnknownEthernet, void(bool ignore)); 113 MOCK_METHOD1(SetStartupPortalList, void(const std::string& portal_list)); 114 MOCK_METHOD0(SetPassiveMode, void()); 115 MOCK_METHOD1(SetPrependDNSServers, 116 void(const std::string& prepend_dns_servers)); 117 MOCK_METHOD1(SetMinimumMTU, void(const int mtu)); 118 MOCK_METHOD1(SetAcceptHostnameFrom, void(const std::string& hostname_from)); 119 MOCK_CONST_METHOD0(ignore_unknown_ethernet, bool()); 120 MOCK_CONST_METHOD1(FilterPrependDNSServersByFamily, 121 std::vector<std::string>(IPAddress::Family family)); 122 MOCK_METHOD0(OnInnerDevicesChanged, void()); 123 MOCK_METHOD3(ClaimDevice, 124 void(const std::string& claimer_name, 125 const std::string& interface_name, Error* error)); 126 MOCK_METHOD4(ReleaseDevice, void(const std::string& claimer_name, 127 const std::string& interface_name, 128 bool* claimer_removed, Error* error)); 129 MOCK_METHOD0(OnDeviceClaimerVanished, void()); 130#if !defined(DISABLE_WIFI) && defined(__BRILLO__) 131 MOCK_METHOD2(SetupApModeInterface, 132 bool(std::string* out_interface_name, Error* error)); 133 MOCK_METHOD2(SetupStationModeInterface, 134 bool(std::string* out_interface_name, Error* error)); 135 MOCK_METHOD0(OnApModeSetterVanished, void()); 136#endif // !DISABLE_WIFI && __BRILLO__ 137 138 // Getter and setter for a mocked device info instance. 139 DeviceInfo* mock_device_info() { return mock_device_info_; } 140 void set_mock_device_info(DeviceInfo* mock_device_info) { 141 mock_device_info_ = mock_device_info; 142 } 143 144 private: 145 DeviceInfo* mock_device_info_; 146 147 DISALLOW_COPY_AND_ASSIGN(MockManager); 148}; 149 150} // namespace shill 151 152#endif // SHILL_MOCK_MANAGER_H_ 153