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 CLIENT_BUS_CENTER_MANAGER_MOCK_H
17 #define CLIENT_BUS_CENTER_MANAGER_MOCK_H
18 
19 #include <gmock/gmock.h>
20 #include <securec.h>
21 
22 #include "bus_center_server_proxy.h"
23 #include "softbus_bus_center.h"
24 #include "softbus_config_type.h"
25 #include "softbus_feature_config.h"
26 
27 namespace OHOS {
28 class ClientBusCenterManagerInterface {
29 public:
ClientBusCenterManagerInterface()30     ClientBusCenterManagerInterface() {};
~ClientBusCenterManagerInterface()31     virtual ~ClientBusCenterManagerInterface() {};
32 
33     virtual int32_t BusCenterServerProxyInit(void);
34     virtual void BusCenterServerProxyDeInit(void);
35     virtual int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len);
36     virtual int32_t ServerIpcGetAllOnlineNodeInfo(const char *pkgName,
37         void **info, uint32_t infoTypeLen, int32_t *infoNum);
38     virtual int32_t ServerIpcGetLocalDeviceInfo(const char *pkgName, void *info, uint32_t infoTypeLen);
39     virtual int32_t ServerIpcGetNodeKeyInfo(const char *pkgName,
40         const char *networkId, int key, unsigned char *buf, uint32_t len);
41     virtual int32_t ServerIpcSetNodeDataChangeFlag(const char *pkgName,
42         const char *networkId, uint16_t dataChangeFlag);
43     virtual int32_t ServerIpcJoinLNN(const char *pkgName, void *addr, unsigned int addrTypeLen);
44     virtual int32_t ServerIpcLeaveLNN(const char *pkgName, const char *networkId);
45     virtual int32_t ServerIpcStartTimeSync(const char *pkgName,
46         const char *targetNetworkId, int32_t accuracy, int32_t period);
47     virtual int32_t ServerIpcStopTimeSync(const char *pkgName, const char *targetNetworkId);
48     virtual int32_t ServerIpcPublishLNN(const char *pkgName, const PublishInfo *info);
49     virtual int32_t ServerIpcStopPublishLNN(const char *pkgName, int32_t publishId);
50     virtual int32_t ServerIpcRefreshLNN(const char *pkgName, const SubscribeInfo *info);
51     virtual int32_t ServerIpcStopRefreshLNN(const char *pkgName, int32_t refreshId);
52 };
53 class ClientBusCenterManagerInterfaceMock : public ClientBusCenterManagerInterface {
54 public:
55     ClientBusCenterManagerInterfaceMock();
56     ~ClientBusCenterManagerInterfaceMock() override;
57 
58     MOCK_METHOD0(BusCenterServerProxyInit, int32_t ());
59     MOCK_METHOD0(BusCenterServerProxyDeInit, void ());
60     MOCK_METHOD3(SoftbusGetConfig, int (ConfigType, unsigned char *, uint32_t));
61     MOCK_METHOD4(ServerIpcGetAllOnlineNodeInfo, int32_t (const char *, void **, uint32_t, int32_t *));
62     MOCK_METHOD3(ServerIpcGetLocalDeviceInfo, int32_t (const char *, void *, uint32_t));
63     MOCK_METHOD5(ServerIpcGetNodeKeyInfo, int32_t (const char *, const char *, int, unsigned char *, uint32_t));
64     MOCK_METHOD3(ServerIpcSetNodeDataChangeFlag, int32_t (const char *, const char *, uint16_t));
65     MOCK_METHOD3(ServerIpcJoinLNN, int32_t (const char *, void *, unsigned int));
66     MOCK_METHOD2(ServerIpcLeaveLNN, int32_t (const char *, const char *));
67     MOCK_METHOD4(ServerIpcStartTimeSync, int32_t (const char *, const char *, int32_t, int32_t));
68     MOCK_METHOD2(ServerIpcStopTimeSync, int32_t (const char *, const char *));
69     MOCK_METHOD2(ServerIpcPublishLNN, int32_t (const char *, const PublishInfo *));
70     MOCK_METHOD2(ServerIpcStopPublishLNN, int32_t (const char *, int32_t));
71     MOCK_METHOD2(ServerIpcRefreshLNN, int32_t (const char *, const SubscribeInfo *));
72     MOCK_METHOD2(ServerIpcStopRefreshLNN, int32_t (const char *, int32_t));
73 };
74 } // namespace OHOS
75 #endif // CLIENT_BUS_CENTER_MANAGER_MOCK_H
76