• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-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 MOCK_SOFTBUS_ADAPTER_TEST_H
17 #define MOCK_SOFTBUS_ADAPTER_TEST_H
18 
19 #include <gmock/gmock.h>
20 
21 #include "broadcast.h"
22 #include "session.h"
23 
24 namespace OHOS {
25 namespace DistributedSchedule {
26 class MockInterface {
27 public:
MockInterface()28     MockInterface() {};
~MockInterface()29     virtual ~MockInterface() {};
30 
31     virtual int32_t SendEvent(const char* pkgName, BroadCastAddr target, EventData *event) = 0;
32     virtual int32_t StopEvent(const char* pkgName, BroadCastAddr target, EventType event) = 0;
33     virtual int32_t RegisterEventListener(const char* pkgName, EventListener *listener) = 0;
34     virtual int32_t UnregisterEventListener(const char* pkgName, EventListener *listener) = 0;
35     virtual int GetSessionOption(int sessionId, SessionOption option, void* optionValue, uint32_t valueSize) = 0;
36 };
37 
38 class SoftbusMock : public MockInterface {
39 public:
40     SoftbusMock();
41     ~SoftbusMock() override;
42 
43     static SoftbusMock& GetMock();
44 
45     MOCK_METHOD(int32_t, SendEvent, (const char* pkgName, BroadCastAddr target, EventData *event), (override));
46     MOCK_METHOD(int32_t, StopEvent, (const char* pkgName, BroadCastAddr target, EventType event), (override));
47     MOCK_METHOD(int32_t, RegisterEventListener, (const char* pkgName, EventListener *listener), (override));
48     MOCK_METHOD(int32_t, UnregisterEventListener, (const char* pkgName, EventListener *listener), (override));
49     MOCK_METHOD(int, GetSessionOption, (int sessionId, SessionOption option, void* optionValue,
50         uint32_t valueSize), (override));
51 
52 private:
53     static SoftbusMock *gMock;
54 };
55 } // namespace DistributedSchedule
56 } // namespace OHOS
57 #endif // MOCK_SOFTBUS_ADAPTER_TEST_H
58