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_ADAPTORS_H_
     18 #define SHILL_MOCK_ADAPTORS_H_
     19 
     20 #include <string>
     21 #include <vector>
     22 
     23 #include <gmock/gmock.h>
     24 
     25 #include "shill/adaptor_interfaces.h"
     26 #include "shill/error.h"
     27 
     28 namespace shill {
     29 
     30 // These are the functions that a Device adaptor must support
     31 class DeviceMockAdaptor : public DeviceAdaptorInterface {
     32  public:
     33   static const char kRpcId[];
     34   static const char kRpcConnId[];
     35 
     36   DeviceMockAdaptor();
     37   ~DeviceMockAdaptor() override;
     38   const std::string& GetRpcIdentifier() override;
     39 
     40   MOCK_METHOD2(EmitBoolChanged, void(const std::string& name, bool value));
     41   MOCK_METHOD2(EmitUintChanged, void(const std::string& name, uint32_t value));
     42   MOCK_METHOD2(EmitUint16Changed,
     43                void(const std::string& name, uint16_t value));
     44   MOCK_METHOD2(EmitIntChanged, void(const std::string& name, int value));
     45   MOCK_METHOD2(EmitStringChanged, void(const std::string& name,
     46                                        const std::string& value));
     47   MOCK_METHOD2(EmitStringmapChanged, void(const std::string& name,
     48                                           const Stringmap& value));
     49   MOCK_METHOD2(EmitStringmapsChanged, void(const std::string& name,
     50                                            const Stringmaps& value));
     51   MOCK_METHOD2(EmitStringsChanged, void(const std::string& name,
     52                                         const Strings& value));
     53   MOCK_METHOD2(EmitKeyValueStoreChanged, void(const std::string& name,
     54                                               const KeyValueStore& value));
     55   MOCK_METHOD2(EmitRpcIdentifierChanged,
     56                void(const std::string& name,
     57                     const std::string& value));
     58   MOCK_METHOD2(EmitRpcIdentifierArrayChanged,
     59                void(const std::string& name,
     60                     const std::vector<std::string>& value));
     61 
     62  private:
     63   const std::string rpc_id_;
     64   const std::string rpc_conn_id_;
     65 };
     66 
     67 // These are the functions that a IPConfig adaptor must support
     68 class IPConfigMockAdaptor : public IPConfigAdaptorInterface {
     69  public:
     70   static const char kRpcId[];
     71 
     72   IPConfigMockAdaptor();
     73   ~IPConfigMockAdaptor() override;
     74   const std::string& GetRpcIdentifier() override;
     75 
     76   MOCK_METHOD2(EmitBoolChanged, void(const std::string&, bool));
     77   MOCK_METHOD2(EmitUintChanged, void(const std::string&, uint32_t));
     78   MOCK_METHOD2(EmitIntChanged, void(const std::string&, int));
     79   MOCK_METHOD2(EmitStringChanged, void(const std::string&, const std::string&));
     80   MOCK_METHOD2(EmitStringsChanged,
     81                void(const std::string&, const std::vector<std::string>&));
     82 
     83  private:
     84   const std::string rpc_id_;
     85 };
     86 
     87 // These are the functions that a Manager adaptor must support
     88 class ManagerMockAdaptor : public ManagerAdaptorInterface {
     89  public:
     90   static const char kRpcId[];
     91 
     92   ManagerMockAdaptor();
     93   ~ManagerMockAdaptor() override;
     94   const std::string& GetRpcIdentifier() override;
     95 
     96   MOCK_METHOD1(RegisterAsync,
     97                void(const base::Callback<void(bool)>& completion_callback));
     98   MOCK_METHOD2(EmitBoolChanged, void(const std::string&, bool));
     99   MOCK_METHOD2(EmitUintChanged, void(const std::string&, uint32_t));
    100   MOCK_METHOD2(EmitIntChanged, void(const std::string&, int));
    101   MOCK_METHOD2(EmitStringChanged, void(const std::string&, const std::string&));
    102   MOCK_METHOD2(EmitStringsChanged,
    103                void(const std::string&, const std::vector<std::string>&));
    104   MOCK_METHOD2(EmitRpcIdentifierChanged,
    105                void(const std::string&, const std::string&));
    106   MOCK_METHOD2(EmitRpcIdentifierArrayChanged,
    107                void(const std::string&, const std::vector<std::string>&));
    108 
    109  private:
    110   const std::string rpc_id_;
    111 };
    112 
    113 // These are the functions that a Profile adaptor must support
    114 class ProfileMockAdaptor : public ProfileAdaptorInterface {
    115  public:
    116   static const char kRpcId[];
    117 
    118   ProfileMockAdaptor();
    119   ~ProfileMockAdaptor() override;
    120   const std::string& GetRpcIdentifier() override;
    121 
    122   MOCK_METHOD2(EmitBoolChanged, void(const std::string&, bool));
    123   MOCK_METHOD2(EmitUintChanged, void(const std::string&, uint32_t));
    124   MOCK_METHOD2(EmitIntChanged, void(const std::string&, int));
    125   MOCK_METHOD2(EmitStringChanged, void(const std::string&, const std::string&));
    126 
    127  private:
    128   const std::string rpc_id_;
    129 };
    130 
    131 // These are the functions that a Task adaptor must support
    132 class RPCTaskMockAdaptor : public RPCTaskAdaptorInterface {
    133  public:
    134   static const char kRpcId[];
    135   static const char kRpcInterfaceId[];
    136   static const char kRpcConnId[];
    137 
    138   RPCTaskMockAdaptor();
    139   ~RPCTaskMockAdaptor() override;
    140 
    141   const std::string& GetRpcIdentifier() override;
    142   const std::string& GetRpcConnectionIdentifier() override;
    143 
    144  private:
    145   const std::string rpc_id_;
    146   const std::string rpc_interface_id_;
    147   const std::string rpc_conn_id_;
    148 };
    149 
    150 // These are the functions that a Service adaptor must support
    151 class ServiceMockAdaptor : public ServiceAdaptorInterface {
    152  public:
    153   static const char kRpcId[];
    154 
    155   ServiceMockAdaptor();
    156   ~ServiceMockAdaptor() override;
    157   const std::string& GetRpcIdentifier() override;
    158 
    159   MOCK_METHOD2(EmitBoolChanged, void(const std::string& name, bool value));
    160   MOCK_METHOD2(EmitUint8Changed, void(const std::string& name, uint8_t value));
    161   MOCK_METHOD2(EmitUint16Changed,
    162                void(const std::string& name, uint16_t value));
    163   MOCK_METHOD2(EmitUint16sChanged, void(const std::string& name,
    164                                         const Uint16s& value));
    165   MOCK_METHOD2(EmitUintChanged, void(const std::string& name, uint32_t value));
    166   MOCK_METHOD2(EmitIntChanged, void(const std::string& name, int value));
    167   MOCK_METHOD2(EmitRpcIdentifierChanged,
    168                void(const std::string& name, const std::string& value));
    169   MOCK_METHOD2(EmitStringChanged,
    170                void(const std::string& name, const std::string& value));
    171   MOCK_METHOD2(EmitStringmapChanged,
    172                void(const std::string& name, const Stringmap& value));
    173 
    174  private:
    175   const std::string rpc_id_;
    176 };
    177 
    178 #ifndef DISABLE_VPN
    179 class ThirdPartyVpnMockAdaptor : public ThirdPartyVpnAdaptorInterface {
    180  public:
    181   ThirdPartyVpnMockAdaptor();
    182   ~ThirdPartyVpnMockAdaptor() override;
    183 
    184   MOCK_METHOD1(EmitPacketReceived, void(const std::vector<uint8_t>& packet));
    185 
    186   MOCK_METHOD1(EmitPlatformMessage, void(uint32_t message));
    187 };
    188 #endif
    189 
    190 }  // namespace shill
    191 
    192 #endif  // SHILL_MOCK_ADAPTORS_H_
    193