1 /* 2 * Copyright (c) 2023 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 16 #ifndef MOCK_I_DAEMON_H 17 #define MOCK_I_DAEMON_H 18 19 #include <gmock/gmock.h> 20 #include <gtest/gtest.h> 21 22 #include "dfs_error.h" 23 #include "ipc/i_daemon.h" 24 #include "iremote_broker.h" 25 #include "iremote_stub.h" 26 27 namespace OHOS::Storage::DistributedFile { 28 class DaemonServiceMock : public IRemoteStub<IDaemon> { 29 public: 30 int code_; DaemonServiceMock()31 DaemonServiceMock() : code_(0) {} ~DaemonServiceMock()32 virtual ~DaemonServiceMock() {} 33 34 MOCK_METHOD4(SendRequest, int(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)); 35 InvokeSendRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)36 int32_t InvokeSendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) 37 { 38 code_ = code; 39 reply.WriteInt32(FileManagement::E_OK); 40 return FileManagement::E_OK; 41 } 42 OpenP2PConnection(const DistributedHardware::DmDeviceInfo & deviceInfo)43 int32_t OpenP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) 44 { 45 return FileManagement::E_OK; 46 } 47 CloseP2PConnection(const DistributedHardware::DmDeviceInfo & deviceInfo)48 int32_t CloseP2PConnection(const DistributedHardware::DmDeviceInfo &deviceInfo) 49 { 50 return FileManagement::E_OK; 51 } 52 PrepareSession(const std::string & srcUri,const std::string & dstUri,const std::string & srcDeviceId,const sptr<IRemoteObject> & listener)53 int32_t PrepareSession(const std::string &srcUri, 54 const std::string &dstUri, 55 const std::string &srcDeviceId, 56 const sptr<IRemoteObject> &listener) 57 { 58 return FileManagement::E_OK; 59 } 60 RequestSendFile(const std::string & srcUri,const std::string & dstPath,const std::string & remoteDeviceId,const std::string & sessionName)61 int32_t RequestSendFile(const std::string &srcUri, 62 const std::string &dstPath, 63 const std::string &remoteDeviceId, 64 const std::string &sessionName) 65 { 66 return FileManagement::E_OK; 67 } 68 }; 69 70 } // namespace OHOS::Storage::DistributedFile 71 72 #endif // MOCK_I_DAEMON_H