• 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 DISTRIBUTE_NET_LEDGER_MOCK_H
17 #define DISTRIBUTE_NET_LEDGER_MOCK_H
18 
19 #include "lnn_distributed_net_ledger.h"
20 #include "bus_center_manager.h"
21 #include <gmock/gmock.h>
22 #include <mutex>
23 
24 namespace OHOS {
25 class DistributeLedgerInterface {
26 public:
DistributeLedgerInterface()27     DistributeLedgerInterface() {};
~DistributeLedgerInterface()28     virtual ~DistributeLedgerInterface() {};
29 
30     virtual int32_t LnnGetDLHeartbeatTimestamp(const char *networkId, uint64_t *timestamp) = 0;
31     virtual int32_t LnnSetDLHeartbeatTimestamp(const char *networkId, const uint64_t timestamp) = 0;
32     virtual int32_t LnnGetRemoteStrInfo(const char *netWorkId, InfoKey key, char *info, uint32_t len) = 0;
33     virtual bool LnnGetOnlineStateById(const char *id, IdCategory type) = 0;
34     virtual int32_t LnnGetRemoteNumU64Info(const char *networkId, InfoKey key, uint64_t *info) = 0;
35     virtual const char *LnnConvertDLidToUdid(const char *id, IdCategory type) = 0;
36     virtual int32_t ConvertBtMacToBinary(const char *, uint32_t, uint8_t *, uint32_t) = 0;
37 };
38 class DistributeLedgerInterfaceMock : public DistributeLedgerInterface {
39 public:
40     DistributeLedgerInterfaceMock();
41     ~DistributeLedgerInterfaceMock() override;
42 
43     MOCK_METHOD2(LnnGetDLHeartbeatTimestamp, int32_t(const char *, uint64_t *));
44     MOCK_METHOD2(LnnSetDLHeartbeatTimestamp, int32_t(const char *, const uint64_t));
45     MOCK_METHOD4(LnnGetRemoteStrInfo, int32_t(const char *, InfoKey, char *, uint32_t));
46     MOCK_METHOD2(LnnGetOnlineStateById, bool(const char *, IdCategory));
47     MOCK_METHOD2(LnnConvertDLidToUdid, const char *(const char *, IdCategory));
48     MOCK_METHOD3(LnnGetRemoteNumU64Info, int32_t(const char *networkId, InfoKey key, uint64_t *info));
49     MOCK_METHOD4(ConvertBtMacToBinary, int32_t(const char *, uint32_t, uint8_t *, uint32_t));
50 };
51 } // namespace OHOS
52 #endif // AUTH_CONNECTION_MOCK_H