• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_HICHAIN_MOCK_H
17 #define LNN_HICHAIN_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include <map>
21 #include <mutex>
22 
23 #include "device_auth.h"
24 #include "device_auth_defines.h"
25 #include "lnn_connection_fsm.h"
26 #include "softbus_adapter_thread.h"
27 #include "softbus_error_code.h"
28 
29 #define TEST_LEN 1
30 #define TEST_SEQ 2
31 
32 namespace OHOS {
33 class LnnHichainInterface {
34 public:
LnnHichainInterface()35     LnnHichainInterface() {};
~LnnHichainInterface()36     virtual ~LnnHichainInterface() {};
37 
38     virtual int32_t InitDeviceAuthService() = 0;
39     virtual void DestroyDeviceAuthService() = 0;
40     virtual GroupAuthManager *GetGaInstance() = 0;
41     virtual DeviceGroupManager *GetGmInstance() = 0;
42     virtual void GetLnnTriggerInfo(LnnTriggerInfo *triggerInfo) = 0;
43 };
44 
45 class LnnHichainInterfaceMock : public LnnHichainInterface {
46 public:
47     LnnHichainInterfaceMock();
48     ~LnnHichainInterfaceMock() override;
49     MOCK_METHOD0(InitDeviceAuthService, int32_t());
50     MOCK_METHOD0(DestroyDeviceAuthService, void());
51     MOCK_METHOD0(GetGaInstance, GroupAuthManager *());
52     MOCK_METHOD0(GetGmInstance, DeviceGroupManager *());
53     MOCK_METHOD1(GetLnnTriggerInfo, void(LnnTriggerInfo *));
54 
55     static int32_t InvokeAuthDevice(
56         int32_t osAccountId, int64_t authReqId, const char *authParams, const DeviceAuthCallback *gaCallback);
57     static int32_t InvokeDataChangeListener(const char *appId, const DataChangeListener *listener);
58     static int32_t InvokeGetJoinedGroups1(
59         int32_t osAccountId, const char *appId, int32_t groupType, char **returnGroupVec, uint32_t *groupNum);
60     static int32_t InvokeGetJoinedGroups2(
61         int32_t osAccountId, const char *appId, int32_t groupType, char **returnGroupVec, uint32_t *groupNum);
62     static int32_t InvokeGetJoinedGroups3(
63         int32_t osAccountId, const char *appId, int32_t groupType, char **returnGroupVec, uint32_t *groupNum);
64     static int32_t ActionofunRegDataChangeListener(const char *appId);
65     static int32_t ActionOfProcessData(
66         int64_t authSeq, const uint8_t *data, uint32_t len, const DeviceAuthCallback *gaCallback);
67     static int32_t AuthDeviceConnSend(
68         int32_t osAccountId, int64_t authReqId, const char *authParams, const DeviceAuthCallback *gaCallback);
69     static inline std::map<const char *, const DataChangeListener *> g_datachangelistener;
70     static inline DeviceAuthCallback g_devAuthCb;
71     static inline SoftBusCond cond;
72     static inline SoftBusMutex mutex;
73     static int32_t getRelatedGroups(
74         int32_t accountId, const char *auth_appId, const char *groupId, char **returnDevInfoVec, uint32_t *deviceNum);
75     static int32_t getRelatedGroups1(
76         int32_t accountId, const char *auth_appId, const char *groupId, char **returnDevInfoVec, uint32_t *deviceNum);
77     static int32_t getTrustedDevices(
78         int32_t osAccountId, const char *appId, const char *groupId, char **returnDevInfoVec, uint32_t *deviceNum);
79     static int32_t getTrustedDevices1(
80         int32_t osAccountId, const char *appId, const char *groupId, char **returnDevInfoVec, uint32_t *deviceNum);
81     static void destroyInfo(char **returnDevInfoVec);
82 };
83 
84 } // namespace OHOS
85 #endif // AUTH_HICHAIN_MOCK_H