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 MOCK_SOFTBUS_ADAPTER_TEST_H
17 #define MOCK_SOFTBUS_ADAPTER_TEST_H
18 
19 #include <gmock/gmock.h>
20 
21 #include "broadcast.h"
22 
23 namespace OHOS {
24 namespace DistributedSchedule {
25 class MockInterface {
26 public:
MockInterface()27     MockInterface() {};
~MockInterface()28     virtual ~MockInterface() {};
29 
30     virtual int32_t SendEvent(const char* pkgName, BroadCastAddr target, EventData *event) = 0;
31     virtual int32_t StopEvent(const char* pkgName, BroadCastAddr target, EventType event) = 0;
32     virtual int32_t RegisterEventListener(const char* pkgName, EventListener *listener) = 0;
33     virtual int32_t UnregisterEventListener(const char* pkgName, EventListener *listener) = 0;
34 };
35 
36 class SoftbusMock : public MockInterface {
37 public:
38     SoftbusMock();
39     ~SoftbusMock() override;
40 
41     static SoftbusMock& GetMock();
42 
43     MOCK_METHOD(int32_t, SendEvent, (const char* pkgName, BroadCastAddr target, EventData *event), (override));
44     MOCK_METHOD(int32_t, StopEvent, (const char* pkgName, BroadCastAddr target, EventType event), (override));
45     MOCK_METHOD(int32_t, RegisterEventListener, (const char* pkgName, EventListener *listener), (override));
46     MOCK_METHOD(int32_t, UnregisterEventListener, (const char* pkgName, EventListener *listener), (override));
47 
48 private:
49     static SoftbusMock *gMock;
50 };
51 } // namespace DistributedSchedule
52 } // namespace OHOS
53 #endif // MOCK_SOFTBUS_ADAPTER_TEST_H
54