1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef MESSAGE_PARCEL_MOCK_H 16 #define MESSAGE_PARCEL_MOCK_H 17 18 #include <memory> 19 #include <string> 20 #include <gmock/gmock.h> 21 22 #include "devicestatus_define.h" 23 #include "devicestatus_errors.h" 24 #include "utility.h" 25 #include "nocopyable.h" 26 27 #include "coordination_message.h" 28 #include "i_coordination_listener.h" 29 #include "i_event_listener.h" 30 #include "i_hotarea_listener.h" 31 #include "i_tunnel_client.h" 32 #include "net_packet.h" 33 #include "socket_client.h" 34 #include "stream_client.h" 35 36 namespace OHOS { 37 namespace Msdp { 38 namespace DeviceStatus { 39 40 class CooperateClientInterface { 41 public: 42 virtual ~CooperateClientInterface() = default; 43 public: 44 virtual int32_t Enable(Intention intention, ParamBase &data, ParamBase &reply) = 0; 45 virtual int32_t Disable(Intention intention, ParamBase &data, ParamBase &reply) = 0; 46 virtual int32_t Start(Intention intention, ParamBase &data, ParamBase &reply) = 0; 47 virtual int32_t Stop(Intention intention, ParamBase &data, ParamBase &reply) = 0; 48 virtual int32_t AddWatch(Intention intention, uint32_t id, ParamBase &data, ParamBase &reply) = 0; 49 virtual int32_t RemoveWatch(Intention intention, uint32_t id, ParamBase &data, ParamBase &reply) = 0; 50 virtual int32_t SetParam(Intention intention, uint32_t id, ParamBase &data, ParamBase &reply) = 0; 51 virtual int32_t GetParam(Intention intention, uint32_t id, ParamBase &data, ParamBase &reply) = 0; 52 virtual int32_t Control(Intention intention, uint32_t id, ParamBase &data, ParamBase &reply) = 0; 53 }; 54 55 class CooperateClientMock : public CooperateClientInterface { 56 public: GetMock()57 static CooperateClientMock& GetMock() 58 { 59 return *g_mock; 60 } 61 62 CooperateClientMock(); 63 ~CooperateClientMock(); 64 65 MOCK_METHOD(int32_t, Enable, (Intention intention, ParamBase &data, ParamBase &reply), (override)); 66 MOCK_METHOD(int32_t, Disable, (Intention intention, ParamBase &data, ParamBase &reply), (override)); 67 MOCK_METHOD(int32_t, Start, (Intention intention, ParamBase &data, ParamBase &reply), (override)); 68 MOCK_METHOD(int32_t, Stop, (Intention intention, ParamBase &data, ParamBase &reply), (override)); 69 MOCK_METHOD(int32_t, AddWatch, (Intention intention, uint32_t id, ParamBase &data, ParamBase &reply), (override)); 70 MOCK_METHOD(int32_t, RemoveWatch, 71 (Intention intention, uint32_t id, ParamBase &data, ParamBase &reply), (override)); 72 MOCK_METHOD(int32_t, SetParam, (Intention intention, uint32_t id, ParamBase &data, ParamBase &reply), (override)); 73 MOCK_METHOD(int32_t, GetParam, (Intention intention, uint32_t id, ParamBase &data, ParamBase &reply), (override)); 74 MOCK_METHOD(int32_t, Control, (Intention intention, uint32_t id, ParamBase &data, ParamBase &reply), (override)); 75 76 private: 77 static CooperateClientMock *g_mock; 78 }; 79 } // namespace DeviceStatus 80 } // namespace Msdp 81 } // namespace OHOS 82 #endif