• 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_SESSION_MOCK_H
16 #define FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_SESSION_MOCK_H
17 
18 #include <gmock/gmock.h>
19 #include "transport/softbus/softbus_session.h"
20 
21 namespace OHOS::FileManagement::CloudSync {
22 class ISoftbusSessionMock {
23 public:
24     enum DataType : int32_t {
25         TYPE_BYTES,
26         TYPE_FILE,
27     };
28     ISoftbusSessionMock() = default;
29     ISoftbusSessionMock(const std::string &peerDeviceId, const std::string &sessionName, DataType type);
30     virtual ~ISoftbusSessionMock() = default;
31 
32     virtual int32_t Start() = 0;
33 
34     virtual int32_t SendData(const void *data, uint32_t dataLen) = 0;
35     virtual int32_t SendFile(const std::vector<std::string> &sFileList,
36         const std::vector<std::string> &dFileList) = 0;
37     virtual int32_t WaitSessionOpened(int sessionId) = 0;
38 public:
39     static inline std::shared_ptr<ISoftbusSessionMock> iSoftbusSessionMock_ = nullptr;
40 };
41 
42 class SoftbusSessionMock : public ISoftbusSessionMock {
43 public:
44     MOCK_METHOD0(Start, int32_t());
45     MOCK_METHOD0(Stop, int32_t());
46     MOCK_METHOD2(SendData, int32_t(const void *data, uint32_t dataLen));
47     MOCK_METHOD2(SendFile, int32_t(const std::vector<std::string> &sFileList,
48         const std::vector<std::string> &dFileList));
49     MOCK_METHOD1(WaitSessionOpened, int32_t(int sessionId));
50 };
51 }
52 #endif // FILEMANAGEMENT_DFS_SERVICE_SOFTBUS_SESSION_MOCK_H
53