1 /* 2 * Copyright (c) 2025 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_CHANNEL_MANAGER_MOCK_H 16 #define FILEMANAGEMENT_DFS_SERVICE_CHANNEL_MANAGER_MOCK_H 17 18 #include "channel_manager.h" 19 #include <gmock/gmock.h> 20 21 namespace OHOS { 22 namespace Storage { 23 namespace DistributedFile { 24 class IChannelManagerMock { 25 public: 26 IChannelManagerMock() = default; 27 virtual ~IChannelManagerMock() = default; 28 29 virtual int32_t CreateClientChannel(const std::string &networkId) = 0; 30 virtual int32_t DestroyClientChannel(const std::string &networkId) = 0; 31 virtual bool HasExistChannel(const std::string &networkId) = 0; 32 33 virtual int32_t SendRequest(const std::string &networkId, 34 ControlCmd &request, 35 ControlCmd &response, 36 bool needResponse = false) = 0; 37 virtual int32_t SendBytes(const std::string &networkId, const std::string &data) = 0; 38 39 public: 40 static inline std::shared_ptr<IChannelManagerMock> iChannelManagerMock = nullptr; 41 }; 42 43 class ChannelManagerMock : public IChannelManagerMock { 44 public: 45 MOCK_METHOD1(CreateClientChannel, int32_t(const std::string &networkId)); 46 MOCK_METHOD1(DestroyClientChannel, int32_t(const std::string &networkId)); 47 MOCK_METHOD1(HasExistChannel, bool(const std::string &networkId)); 48 MOCK_METHOD4(SendRequest, 49 int32_t(const std::string &networkId, ControlCmd &request, ControlCmd &response, bool needResponse)); 50 MOCK_METHOD2(SendBytes, int32_t(const std::string &networkId, const std::string &data)); 51 }; 52 } // namespace DistributedFile 53 } // namespace Storage 54 } // namespace OHOS 55 #endif // FILEMANAGEMENT_DFS_SERVICE_CHANNEL_MANAGER_MOCK_H