• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_HANDLER_MOCK_H
16 #define FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_HANDLER_MOCK_H
17 
18 #include <gmock/gmock.h>
19 #include "network/softbus/softbus_handler.h"
20 
21 namespace OHOS {
22 namespace Storage {
23 namespace DistributedFile {
24 class ISoftBusHandlerMock {
25 public:
26     ISoftBusHandlerMock() = default;
27     virtual ~ISoftBusHandlerMock() = default;
28 
29     virtual int32_t CreateSessionServer(const std::string &packageName, const std::string &sessionName,
30                                         DFS_CHANNEL_ROLE role, const std::string physicalPath) = 0;
31     virtual int32_t OpenSession(const std::string &mySessionName, const std::string &peerSessionName,
32                                 const std::string &peerDevId, int32_t &socketId) = 0;
33     virtual int32_t CopySendFile(int32_t socketId,
34                                  const std::string &sessionName,
35                                  const std::string &srcUri,
36                                  const std::string &dstUri) = 0;
37     virtual std::string GetSessionName(int32_t sessionId) = 0;
38     virtual bool IsSameAccount(const std::string &networkId) = 0;
39 
40 public:
41     static inline std::shared_ptr<ISoftBusHandlerMock> iSoftBusHandlerMock_ = nullptr;
42 };
43 
44 class SoftBusHandlerMock : public ISoftBusHandlerMock {
45 public:
46     MOCK_METHOD4(CreateSessionServer, int32_t(const std::string &packageName, const std::string &sessionName,
47                                               DFS_CHANNEL_ROLE role, const std::string physicalPath));
48     MOCK_METHOD4(OpenSession, int32_t(const std::string &mySessionName, const std::string &peerSessionName,
49                                       const std::string &peerDevId, int32_t &socketId));
50     MOCK_METHOD4(CopySendFile, int32_t(int32_t socketId,
51                                        const std::string &sessionName,
52                                        const std::string &srcUri,
53                                        const std::string &dstUri));
54     MOCK_METHOD1(GetSessionName, std::string(int32_t sessionId));
55     MOCK_METHOD1(IsSameAccount, bool(const std::string &networkId));
56 };
57 } // namespace DistributedFile
58 } // namespace Storage
59 } // namespace OHOS
60 #endif // FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_HANDLER_MOCK_H
61