• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 AUTH_COMMON_MOCK_H
17 #define AUTH_COMMON_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include <mutex>
21 
22 #include "auth_common.h"
23 #include "device_auth.h"
24 #include "lnn_async_callback_utils.h"
25 #include "lnn_common_utils.h"
26 #include "lnn_feature_capability.h"
27 #include "lnn_node_info.h"
28 
29 namespace OHOS {
30 class AuthCommonInterface {
31 public:
AuthCommonInterface()32     AuthCommonInterface() {};
~AuthCommonInterface()33     virtual ~AuthCommonInterface() {};
34 
35     virtual int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback,
36         void *para, uint64_t delayMillis);
37     virtual int32_t LnnGetLocalNumU64Info(InfoKey key, uint64_t *info) = 0;
38     virtual int SoftBusGetBtState(void) = 0;
39     virtual void LnnHbOnTrustedRelationReduced(void) = 0;
40     virtual int32_t LnnInsertSpecificTrustedDevInfo(const char *udid) = 0;
41     virtual int32_t LnnGetNetworkIdByUuid(const char *uuid, char *buf, uint32_t len) = 0;
42     virtual int32_t LnnGetStaFrequency(const NodeInfo *info) = 0;
43     virtual int32_t LnnEncryptAesGcm(AesGcmInputParam *in, int32_t keyIndex, uint8_t **out, uint32_t *outLen) = 0;
44     virtual int32_t LnnDecryptAesGcm(AesGcmInputParam *in, uint8_t **out, uint32_t *outLen) = 0;
45     virtual int32_t LnnGetTrustedDevInfoFromDb(char **udidArray, uint32_t *num) = 0;
46 };
47 class AuthCommonInterfaceMock : public AuthCommonInterface {
48 public:
49     AuthCommonInterfaceMock();
50     ~AuthCommonInterfaceMock() override;
51     MOCK_METHOD4(LnnAsyncCallbackDelayHelper, int32_t (SoftBusLooper *, LnnAsyncCallbackFunc, void *, uint64_t));
52     MOCK_METHOD2(LnnGetLocalNumU64Info, int32_t (InfoKey, uint64_t *));
53     MOCK_METHOD0(SoftBusGetBtState, int (void));
54     MOCK_METHOD0(LnnHbOnTrustedRelationReduced, void ());
55     MOCK_METHOD1(LnnInsertSpecificTrustedDevInfo, int32_t (const char *));
56     MOCK_METHOD3(LnnGetNetworkIdByUuid, int32_t (const char *, char *, uint32_t));
57     MOCK_METHOD1(LnnGetStaFrequency, int32_t (const NodeInfo *));
58     MOCK_METHOD4(LnnEncryptAesGcm, int32_t (AesGcmInputParam *, int32_t, uint8_t **, uint32_t *));
59     MOCK_METHOD3(LnnDecryptAesGcm, int32_t (AesGcmInputParam *, uint8_t **, uint32_t *));
60     MOCK_METHOD2(LnnGetTrustedDevInfoFromDb, int32_t (char **, uint32_t *));
61 };
62 } // namespace OHOS
63 #endif // AUTH_COMMON_MOCK_H