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
16 #include "softbus_handler_mock.h"
17
18 namespace OHOS {
19 namespace Storage {
20 namespace DistributedFile {
21 SoftBusHandler::SoftBusHandler() = default;
22 SoftBusHandler::~SoftBusHandler() = default;
23
GetInstance()24 SoftBusHandler &SoftBusHandler::GetInstance()
25 {
26 static SoftBusHandler handle;
27 return handle;
28 }
29
OnSinkSessionOpened(int32_t sessionId,PeerSocketInfo info)30 void SoftBusHandler::OnSinkSessionOpened(int32_t sessionId, PeerSocketInfo info)
31 {
32 return;
33 }
34
IsSameAccount(const std::string & networkId)35 bool SoftBusHandler::IsSameAccount(const std::string &networkId)
36 {
37 return true;
38 }
39
GetSessionName(int32_t sessionId)40 std::string SoftBusHandler::GetSessionName(int32_t sessionId)
41 {
42 return "test";
43 }
44
CreateSessionServer(const std::string & packageName,const std::string & sessionName,DFS_CHANNEL_ROLE role,const std::string physicalPath)45 int32_t SoftBusHandler::CreateSessionServer(const std::string &packageName, const std::string &sessionName,
46 DFS_CHANNEL_ROLE role, const std::string physicalPath)
47 {
48 if (ISoftBusHandlerMock::iSoftBusHandlerMock_ == nullptr) {
49 return -1;
50 }
51 return ISoftBusHandlerMock::iSoftBusHandlerMock_->CreateSessionServer(packageName, sessionName, role, physicalPath);
52 }
53
OpenSession(const std::string & mySessionName,const std::string & peerSessionName,const std::string & peerDevId,int32_t & socketId)54 int32_t SoftBusHandler::OpenSession(const std::string &mySessionName, const std::string &peerSessionName,
55 const std::string &peerDevId, int32_t &socketId)
56 {
57 if (ISoftBusHandlerMock::iSoftBusHandlerMock_ == nullptr) {
58 return -1;
59 }
60 return ISoftBusHandlerMock::iSoftBusHandlerMock_->OpenSession(mySessionName,
61 peerSessionName, peerDevId, socketId);
62 }
63
CreatSocketId(const std::string & mySessionName,const std::string & peerSessionName,const std::string & peerDevId,int32_t & socketId)64 bool SoftBusHandler::CreatSocketId(const std::string &mySessionName, const std::string &peerSessionName,
65 const std::string &peerDevId, int32_t &socketId)
66 {
67 return true;
68 }
69
CopySendFile(int32_t socketId,const std::string & sessionName,const std::string & srcUri,const std::string & dstPath)70 int32_t SoftBusHandler::CopySendFile(int32_t socketId,
71 const std::string &sessionName,
72 const std::string &srcUri,
73 const std::string &dstPath)
74 {
75 if (ISoftBusHandlerMock::iSoftBusHandlerMock_ == nullptr) {
76 return -1;
77 }
78 return ISoftBusHandlerMock::iSoftBusHandlerMock_->CopySendFile(socketId, sessionName, srcUri, dstPath);
79 }
80
ChangeOwnerIfNeeded(int32_t sessionId,const std::string sessionName)81 void SoftBusHandler::ChangeOwnerIfNeeded(int32_t sessionId, const std::string sessionName)
82 {
83 return;
84 }
85
CloseSession(int32_t sessionId,const std::string sessionName)86 void SoftBusHandler::CloseSession(int32_t sessionId, const std::string sessionName)
87 {
88 return;
89 }
90
CloseSessionWithSessionName(const std::string sessionName)91 void SoftBusHandler::CloseSessionWithSessionName(const std::string sessionName)
92 {
93 return;
94 }
RemoveNetworkId(int32_t socketId)95 void SoftBusHandler::RemoveNetworkId(int32_t socketId)
96 {
97 return;
98 }
99
GetsocketIdFromPeerNetworkId(const std::string & peerNetworkId)100 std::vector<int32_t> SoftBusHandler::GetsocketIdFromPeerNetworkId(const std::string &peerNetworkId)
101 {
102 return {0};
103 }
104
IsService(std::string & sessionName)105 bool SoftBusHandler::IsService(std::string &sessionName)
106 {
107 return true;
108 }
109
CopyOnStop(const std::string & peerNetworkId)110 void SoftBusHandler::CopyOnStop(const std::string &peerNetworkId)
111 {
112 return;
113 }
114 } // namespace DistributedFile
115 } // namespace Storage
116 } // namespace OHOS