• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_SLE_CAPABILITY_MOCK_H
17 #define LNN_SLE_CAPABILITY_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include <mutex>
21 
22 #include "bus_center_manager.h"
23 #include "g_enhance_adapter_func_pack.h"
24 #include "lnn_distributed_net_ledger.h"
25 #include "lnn_distributed_net_ledger_struct.h"
26 #include "lnn_local_net_ledger.h"
27 #include "lnn_sync_info_manager.h"
28 #include "softbus_json_utils.h"
29 
30 namespace OHOS {
31 class LnnSleCapabilityInterface {
32 public:
LnnSleCapabilityInterface()33     LnnSleCapabilityInterface() {};
~LnnSleCapabilityInterface()34     virtual ~LnnSleCapabilityInterface() {};
35 
36     virtual int32_t GetSleRangeCapacityPacked(void) = 0;
37     virtual int32_t LnnGetLocalNumInfo(InfoKey key, int32_t *info) = 0;
38     virtual int32_t LnnUpdateSleCapacityAndVersion(int32_t slecap) = 0;
39     virtual bool IsSleEnabledPacked(void) = 0;
40     virtual int32_t GetLocalSleAddrPacked(char *sleAddr, uint32_t sleAddrLen) = 0;
41     virtual int32_t LnnSetLocalStrInfo(InfoKey key, const char *info) = 0;
42     virtual bool AddNumberToJsonObject(cJSON *json, const char * const string, int32_t num) = 0;
43     virtual bool AddStringToJsonObject(cJSON *json, const char * const string, const char *value) = 0;
44     virtual cJSON *cJSON_CreateObject() = 0;
45     virtual int32_t LnnRegSyncInfoHandler(LnnSyncInfoType type, LnnSyncInfoMsgHandler handler) = 0;
46     virtual int32_t SoftBusAddSleStateListenerPacked(const SoftBusSleStateListener *listener, int32_t *listenerId) = 0;
47     virtual int32_t LnnSetDLSleRangeInfo(const char *id, IdCategory type, int32_t sleCap, const char *addr) = 0;
48 };
49 class LnnSleCapabilityInterfaceMock : public LnnSleCapabilityInterface {
50 public:
51     LnnSleCapabilityInterfaceMock();
52     ~LnnSleCapabilityInterfaceMock() override;
53     MOCK_METHOD0(GetSleRangeCapacityPacked, int32_t());
54     MOCK_METHOD2(LnnGetLocalNumInfo, int32_t(InfoKey key, int32_t *info));
55     MOCK_METHOD1(LnnUpdateSleCapacityAndVersion, int32_t(int32_t slecap));
56     MOCK_METHOD0(IsSleEnabledPacked, bool());
57     MOCK_METHOD2(GetLocalSleAddrPacked, int32_t(char *sleAddr, uint32_t sleAddrLen));
58     MOCK_METHOD2(LnnSetLocalStrInfo, int32_t(InfoKey key, const char *info));
59     MOCK_METHOD3(AddNumberToJsonObject, bool(cJSON *json, const char * const string, int32_t num));
60     MOCK_METHOD3(AddStringToJsonObject, bool(cJSON *json, const char * const string, const char *value));
61     MOCK_METHOD0(cJSON_CreateObject, cJSON *());
62     MOCK_METHOD2(LnnRegSyncInfoHandler, int32_t(LnnSyncInfoType type, LnnSyncInfoMsgHandler handler));
63     MOCK_METHOD2(
64         SoftBusAddSleStateListenerPacked, int32_t(const SoftBusSleStateListener *listener, int32_t *listenerId));
65     MOCK_METHOD4(LnnSetDLSleRangeInfo, int32_t(const char *id, IdCategory type, int32_t sleCap, const char *addr));
66 };
67 } // namespace OHOS
68 #endif // LNN_SLE_CAPABILITY_MOCK_H
69