• 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_CTRL_LANE_DEPS_MOCK_H
17 #define LNN_CTRL_LANE_DEPS_MOCK_H
18 
19 #include <gmock/gmock.h>
20 
21 #include "lnn_lane_link.h"
22 
23 namespace OHOS {
24 class CtrlLaneDepsInterface {
25 public:
CtrlLaneDepsInterface()26     CtrlLaneDepsInterface() {};
~CtrlLaneDepsInterface()27     virtual ~CtrlLaneDepsInterface() {};
28 
29     virtual int32_t SelectAuthLane(const char *networkId, LanePreferredLinkList *recommendList,
30         LanePreferredLinkList *request) = 0;
31     virtual int32_t BuildLink(const LinkRequest *reqInfo, uint32_t reqId, const LaneLinkCb *callback) = 0;
32     virtual int32_t DestroyLink(const char *networkId, uint32_t laneReqId, LaneLinkType type) = 0;
33     virtual uint64_t GenerateLaneId(const char *localUdid, const char *remoteUdid, LaneLinkType linkType) = 0;
34     virtual int32_t AddLaneResourceToPool(const LaneLinkInfo *linkInfo, uint64_t laneId, bool isServerSide) = 0;
35     virtual int32_t DelLaneResourceByLaneId(uint64_t laneId, bool isServerSide) = 0;
36     virtual int32_t FindLaneResourceByLaneId(uint64_t laneId, LaneResource *resourceItem) = 0;
37     virtual int32_t FindLaneResourceByLinkType(const char *peerUdid, LaneLinkType type, LaneResource *resource) = 0;
38     virtual void FreeLaneReqId(uint32_t laneReqId) = 0;
39     virtual int32_t LaneInfoProcess(const LaneLinkInfo *linkInfo, LaneConnInfo *connInfo, LaneProfile *profile) = 0;
40 };
41 
42 class CtrlLaneDepsInterfaceMock : public CtrlLaneDepsInterface {
43 public:
44     CtrlLaneDepsInterfaceMock();
45     ~CtrlLaneDepsInterfaceMock() override;
46 
47     MOCK_METHOD3(SelectAuthLane, int32_t (const char *, LanePreferredLinkList *, LanePreferredLinkList *));
48     MOCK_METHOD3(BuildLink, int32_t (const LinkRequest *reqInfo, uint32_t reqId, const LaneLinkCb *callback));
49     MOCK_METHOD3(DestroyLink, int32_t (const char *networkId, uint32_t laneReqId, LaneLinkType type));
50     MOCK_METHOD3(GenerateLaneId, uint64_t (const char *localUdid, const char *remoteUdid, LaneLinkType linkType));
51     MOCK_METHOD3(AddLaneResourceToPool, int32_t (const LaneLinkInfo *linkInfo, uint64_t laneId, bool isServerSide));
52     MOCK_METHOD2(DelLaneResourceByLaneId, int32_t (uint64_t laneId, bool isServerSide));
53     MOCK_METHOD2(FindLaneResourceByLaneId, int32_t (uint64_t laneId, LaneResource *resourceItem));
54     MOCK_METHOD3(FindLaneResourceByLinkType, int32_t (const char *peerUdid, LaneLinkType type, LaneResource *resource));
55     MOCK_METHOD1(FreeLaneReqId, void (uint32_t laneReqId));
56     MOCK_METHOD3(LaneInfoProcess, int32_t (const LaneLinkInfo *linkInfo, LaneConnInfo *connInfo,
57         LaneProfile *profile));
58 
59     static int32_t BuildLinkSuccess(const LinkRequest *reqInfo, uint32_t reqId, const LaneLinkCb *callback);
60     static int32_t BuildLinkFail(const LinkRequest *reqInfo, uint32_t reqId, const LaneLinkCb *callback);
61 };
62 } // namespace OHOS
63 #endif // LNN_CTRL_LANE_DEPS_MOCK_H
64