• 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 
16 #ifndef LNN_SYNC_INFO_MOCK_H
17 #define LNN_SYNC_INFO_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include <mutex>
21 
22 #include "lnn_sync_info_manager.h"
23 
24 namespace OHOS {
25 class LnnSyncInfoInterface {
26 public:
LnnSyncInfoInterface()27     LnnSyncInfoInterface() {};
~LnnSyncInfoInterface()28     virtual ~LnnSyncInfoInterface() {};
29     virtual int32_t LnnSendSyncInfoMsg(LnnSyncInfoType type, const char *networkId, const uint8_t *msg, uint32_t len,
30         LnnSyncInfoMsgComplete complete) = 0;
31     virtual int32_t LnnRegSyncInfoHandler(LnnSyncInfoType type, LnnSyncInfoMsgHandler handler) = 0;
32     virtual int32_t LnnUnregSyncInfoHandler(LnnSyncInfoType type, LnnSyncInfoMsgHandler handler) = 0;
33     virtual int32_t LnnSendP2pSyncInfoMsg(const char *networkId, uint32_t netCapability) = 0;
34 
35     virtual void LnnSendAsyncInfoMsg(void *param) = 0;
36     virtual SendSyncInfoParam *CreateSyncInfoParam(LnnSyncInfoType type, const char *networkId, const uint8_t *msg,
37         uint32_t len, LnnSyncInfoMsgComplete complete) = 0;
38 };
39 
40 class LnnSyncInfoInterfaceMock : public LnnSyncInfoInterface {
41 public:
42     LnnSyncInfoInterfaceMock();
43     ~LnnSyncInfoInterfaceMock() override;
44     MOCK_METHOD5(
45         LnnSendSyncInfoMsg, int32_t(LnnSyncInfoType, const char *, const uint8_t *, uint32_t, LnnSyncInfoMsgComplete));
46     MOCK_METHOD2(LnnRegSyncInfoHandler, int32_t(LnnSyncInfoType, LnnSyncInfoMsgHandler));
47     MOCK_METHOD2(LnnUnregSyncInfoHandler, int32_t(LnnSyncInfoType, LnnSyncInfoMsgHandler));
48     MOCK_METHOD2(LnnSendP2pSyncInfoMsg, int32_t(const char *, uint32_t));
49 
50     MOCK_METHOD1(LnnSendAsyncInfoMsg, void (void *));
51     MOCK_METHOD5(CreateSyncInfoParam,
52         SendSyncInfoParam *(LnnSyncInfoType, const char *, const uint8_t *, uint32_t, LnnSyncInfoMsgComplete));
53 };
54 } // namespace OHOS
55 #endif // LNN_SYNC_INFO_MOCK_H
56