Home | History | Annotate | Download | only in shill
      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_CONTROL_H_
     18 #define SHILL_MOCK_CONTROL_H_
     19 
     20 #include <string>
     21 
     22 #include <base/macros.h>
     23 #include <gmock/gmock.h>
     24 
     25 #include "shill/control_interface.h"
     26 
     27 namespace shill {
     28 // An implementation of the Shill RPC-channel-interface-factory interface that
     29 // returns mocks.
     30 class MockControl : public ControlInterface {
     31  public:
     32   MockControl();
     33   ~MockControl() override;
     34 
     35   void RegisterManagerObject(
     36       Manager* manager,
     37       const base::Closure& registration_done_callback) override {};
     38 
     39   // Each of these can be called once.  Ownership of the appropriate
     40   // interface pointer is given up upon call.
     41   DeviceAdaptorInterface* CreateDeviceAdaptor(Device* device) override;
     42   IPConfigAdaptorInterface* CreateIPConfigAdaptor(IPConfig* config) override;
     43   ManagerAdaptorInterface* CreateManagerAdaptor(Manager* manager) override;
     44   ProfileAdaptorInterface* CreateProfileAdaptor(Profile* profile) override;
     45   RPCTaskAdaptorInterface* CreateRPCTaskAdaptor(RPCTask* task) override;
     46   ServiceAdaptorInterface* CreateServiceAdaptor(Service* service) override;
     47 #ifndef DISABLE_VPN
     48   ThirdPartyVpnAdaptorInterface* CreateThirdPartyVpnAdaptor(
     49       ThirdPartyVpnDriver* driver) override;
     50 #endif
     51   const std::string& NullRPCIdentifier() override;
     52 
     53   MOCK_METHOD2(CreateRPCServiceWatcher,
     54                RPCServiceWatcherInterface*(
     55                    const std::string& connection_name,
     56                    const base::Closure& on_connection_vanished));
     57 
     58   MOCK_METHOD3(
     59       CreatePowerManagerProxy,
     60       PowerManagerProxyInterface*(
     61           PowerManagerProxyDelegate* delegate,
     62           const base::Closure& service_appeared_callback,
     63           const base::Closure& service_vanished_callback));
     64 #if !defined(DISABLE_WIFI) || !defined(DISABLE_WIRED_8021X)
     65   MOCK_METHOD2(CreateSupplicantProcessProxy,
     66                SupplicantProcessProxyInterface*(
     67                    const base::Closure& service_appeared_callback,
     68                    const base::Closure& service_vanished_callback));
     69   MOCK_METHOD2(CreateSupplicantInterfaceProxy,
     70                SupplicantInterfaceProxyInterface*(
     71                    SupplicantEventDelegateInterface* delegate,
     72                    const std::string& object_path));
     73   MOCK_METHOD1(CreateSupplicantNetworkProxy,
     74                SupplicantNetworkProxyInterface*(
     75                    const std::string& object_path));
     76 #endif  // DISABLE_WIFI || DISABLE_WIRED_8021X
     77 #if !defined(DISABLE_WIFI)
     78   MOCK_METHOD2(CreateSupplicantBSSProxy,
     79                SupplicantBSSProxyInterface*(WiFiEndpoint* wifi_endpoint,
     80                                             const std::string& object_path));
     81 #endif  // DISABLE_WIFI
     82   MOCK_METHOD1(CreateDHCPCDListener,
     83                DHCPCDListenerInterface*(DHCPProvider* provider));
     84   MOCK_METHOD1(CreateDHCPProxy,
     85                DHCPProxyInterface*(const std::string& service));
     86 
     87   MOCK_METHOD0(CreateUpstartProxy, UpstartProxyInterface*());
     88 
     89   MOCK_METHOD0(CreateFirewallProxy, FirewallProxyInterface*());
     90 
     91 #if !defined(DISABLE_CELLULAR)
     92   MOCK_METHOD2(CreateDBusPropertiesProxy,
     93                DBusPropertiesProxyInterface*(const std::string& path,
     94                                              const std::string& service));
     95 
     96   MOCK_METHOD4(CreateDBusObjectManagerProxy,
     97                DBusObjectManagerProxyInterface*(
     98                    const std::string& path,
     99                    const std::string& service,
    100                    const base::Closure& service_appeared_callback,
    101                    const base::Closure& service_vanished_callback));
    102   MOCK_METHOD5(CreateModemManagerProxy,
    103                ModemManagerProxyInterface*(
    104                    ModemManagerClassic* manager,
    105                    const std::string& path,
    106                    const std::string& service,
    107                    const base::Closure& service_appeared_callback,
    108                    const base::Closure& service_vanished_callback));
    109   MOCK_METHOD2(CreateModemProxy,
    110                ModemProxyInterface*(const std::string& path,
    111                                     const std::string& service));
    112   MOCK_METHOD2(CreateModemSimpleProxy,
    113                ModemSimpleProxyInterface*(const std::string& path,
    114                                           const std::string& service));
    115 
    116   MOCK_METHOD2(CreateModemCDMAProxy,
    117                ModemCDMAProxyInterface*(const std::string& path,
    118                                         const std::string& service));
    119   MOCK_METHOD2(CreateModemGSMCardProxy,
    120                ModemGSMCardProxyInterface*(const std::string& path,
    121                                            const std::string& service));
    122   MOCK_METHOD2(CreateModemGSMNetworkProxy,
    123                ModemGSMNetworkProxyInterface*(const std::string& path,
    124                                               const std::string& service));
    125   MOCK_METHOD2(CreateModemGobiProxy,
    126                ModemGobiProxyInterface*(const std::string& path,
    127                                         const std::string& service));
    128   MOCK_METHOD2(CreateMM1ModemModem3gppProxy,
    129                mm1::ModemModem3gppProxyInterface*(const std::string& path,
    130                                                   const std::string& service));
    131   MOCK_METHOD2(CreateMM1ModemModemCdmaProxy,
    132                mm1::ModemModemCdmaProxyInterface*(const std::string& path,
    133                                                   const std::string& service));
    134   MOCK_METHOD2(CreateMM1ModemProxy,
    135                mm1::ModemProxyInterface*(const std::string& path,
    136                                          const std::string& service));
    137   MOCK_METHOD2(CreateMM1ModemSimpleProxy,
    138                mm1::ModemSimpleProxyInterface*(const std::string& path,
    139                                                const std::string& service));
    140   MOCK_METHOD2(CreateSimProxy,
    141                mm1::SimProxyInterface*(const std::string& path,
    142                                        const std::string& service));
    143 #endif  // DISABLE_CELLULAR
    144 
    145 #if !defined(DISABLE_WIMAX)
    146   MOCK_METHOD1(CreateWiMaxDeviceProxy,
    147                WiMaxDeviceProxyInterface*(const std::string& path));
    148   MOCK_METHOD2(CreateWiMaxManagerProxy,
    149                WiMaxManagerProxyInterface*(
    150                    const base::Closure& service_appeared_callback,
    151                    const base::Closure& service_vanished_callback));
    152   MOCK_METHOD1(CreateWiMaxNetworkProxy,
    153                WiMaxNetworkProxyInterface*(const std::string& path));
    154 #endif  // DISABLE_WIMAX
    155 
    156  private:
    157   std::string null_identifier_;
    158 
    159   DISALLOW_COPY_AND_ASSIGN(MockControl);
    160 };
    161 
    162 }  // namespace shill
    163 
    164 #endif  // SHILL_MOCK_CONTROL_H_
    165