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 FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_ADAPTER_MOCK_H 16 #define FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_ADAPTER_MOCK_H 17 18 #include <gmock/gmock.h> 19 #include "transport/softbus/softbus_adapter.h" 20 21 namespace OHOS::FileManagement::CloudSync { 22 class ISoftbusAdapterMock { 23 public: 24 ISoftbusAdapterMock() = default; 25 virtual ~ISoftbusAdapterMock() = default; 26 27 virtual int32_t CreateSessionServer(const char *packageName, const char *sessionName) = 0; 28 virtual int32_t OpenSession(char *sessionName, char *peerDeviceId, char *groupId, TransDataType dataType) = 0; 29 virtual int OpenSessionByP2P(char *sessionName, char *peerDeviceId, char *groupId, bool isFileType) = 0; 30 31 virtual int SendBytes(int sessionId, const void *data, unsigned int dataLen) = 0; 32 virtual int SendFile(int sessionId, const std::vector<std::string> &sFileList, 33 const std::vector<std::string> &dFileList) = 0; 34 public: 35 static inline std::shared_ptr<ISoftbusAdapterMock> iSoftbusAdapterMock_ = nullptr; 36 }; 37 38 class SoftbusAdapterMock : public ISoftbusAdapterMock { 39 public: 40 MOCK_METHOD2(CreateSessionServer, int32_t(const char *packageName, const char *sessionName)); 41 MOCK_METHOD4(OpenSession, int32_t(char *sessionName, char *peerDeviceId, char *groupId, TransDataType dataType)); 42 MOCK_METHOD4(OpenSessionByP2P, int(char *sessionName, char *peerDeviceId, char *groupId, bool isFileType)); 43 MOCK_METHOD3(SendBytes, int(int sessionId, const void *data, unsigned int dataLen)); 44 MOCK_METHOD3(SendFile, int(int sessionId, const std::vector<std::string> &sFileList, 45 const std::vector<std::string> &dFileList)); 46 }; 47 } 48 #endif // FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_ADAPTER_MOCK_H 49