• 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_DATA_CLOUD_SYNC_DEPS_MOCK_H
17 #define LNN_DATA_CLOUD_SYNC_DEPS_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include <mutex>
21 
22 #include "lnn_device_info_recovery.h"
23 #include "lnn_cipherkey_manager.h"
24 #include "lnn_heartbeat_utils.h"
25 #include "lnn_distributed_net_ledger.h"
26 #include "softbus_utils.h"
27 #include "lnn_async_callback_utils.h"
28 
29 namespace OHOS {
30 class LnnDataCloudSyncInterface {
31 public:
LnnDataCloudSyncInterface()32     LnnDataCloudSyncInterface() {};
~LnnDataCloudSyncInterface()33     virtual ~LnnDataCloudSyncInterface() {};
34 
35     virtual int32_t LnnSaveRemoteDeviceInfo(const NodeInfo *deviceInfo);
36     virtual int32_t LnnRetrieveDeviceInfo(const char *udid, NodeInfo *deviceInfo);
37     virtual void LnnDeleteDeviceInfo(const char *udid);
38     virtual int32_t LnnGetLocalCacheNodeInfo(NodeInfo *info);
39     virtual int32_t LnnPackCloudSyncDeviceInfo(cJSON *json, const NodeInfo *cloudSyncInfo);
40     virtual int32_t LnnUnPackCloudSyncDeviceInfo(cJSON *json, NodeInfo *cloudSyncInfo);
41     virtual int32_t LnnUpdateNetworkId(const NodeInfo *newInfo) = 0;
42     virtual int32_t LnnGetLocalBroadcastCipherInfo(CloudSyncInfo *info);
43     virtual int32_t LnnSetRemoteBroadcastCipherInfo(const char *value, const char *udid);
44     virtual int32_t LnnGenerateHexStringHash(const unsigned char *str, char *hashStr, uint32_t len);
45     virtual int32_t ConvertHexStringToBytes(unsigned char *outBuf, uint32_t outBufLen,
46         const char *inBuf, uint32_t inLen);
47     virtual int32_t LnnAsyncCallbackDelayHelper(SoftBusLooper *looper, LnnAsyncCallbackFunc callback,
48         void *para, uint64_t delayMillis);
49 };
50 
51 class LnnDataCloudSyncInterfaceMock : public LnnDataCloudSyncInterface {
52 public:
53     LnnDataCloudSyncInterfaceMock();
54     ~LnnDataCloudSyncInterfaceMock() override;
55 
56     MOCK_METHOD1(LnnSaveRemoteDeviceInfo, int32_t (const NodeInfo *));
57     MOCK_METHOD2(LnnRetrieveDeviceInfo, int32_t (const char *, NodeInfo *));
58     MOCK_METHOD1(LnnDeleteDeviceInfo, void (const char *));
59     MOCK_METHOD1(LnnGetLocalCacheNodeInfo, int32_t (NodeInfo *));
60     MOCK_METHOD2(LnnPackCloudSyncDeviceInfo, int32_t (cJSON *, const NodeInfo *));
61     MOCK_METHOD2(LnnUnPackCloudSyncDeviceInfo, int32_t (cJSON *, NodeInfo *));
62     MOCK_METHOD1(LnnUpdateNetworkId, int32_t (const NodeInfo *));
63     MOCK_METHOD1(LnnGetLocalBroadcastCipherInfo, int32_t (CloudSyncInfo *));
64     MOCK_METHOD2(LnnSetRemoteBroadcastCipherInfo, int32_t (const char *, const char *));
65     MOCK_METHOD3(LnnGenerateHexStringHash, int32_t (const unsigned char *, char *, uint32_t));
66     MOCK_METHOD4(ConvertHexStringToBytes, int32_t (unsigned char *, uint32_t, const char *, uint32_t));
67     MOCK_METHOD4(LnnAsyncCallbackDelayHelper, int32_t (SoftBusLooper *, LnnAsyncCallbackFunc, void *, uint64_t));
68 };
69 } // namespace OHOS
70 #endif // LNN_AUTH_MOCK_H