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 #include "mock_softbus_adapter.h"
16 
17 using namespace testing;
18 using namespace testing::ext;
19 
20 namespace OHOS {
21 namespace DistributedSchedule {
22 SoftbusMock *SoftbusMock::gMock;
23 
SoftbusMock()24 SoftbusMock::SoftbusMock()
25 {
26     gMock = this;
27 }
28 
~SoftbusMock()29 SoftbusMock::~SoftbusMock()
30 {
31     gMock = nullptr;
32 }
33 
GetMock()34 SoftbusMock& SoftbusMock::GetMock()
35 {
36     return *gMock;
37 }
38 
39 extern "C" {
SendEvent(const char * pkgName,BroadCastAddr target,EventData * event)40 int32_t SendEvent(const char* pkgName, BroadCastAddr target, EventData *event)
41 {
42     return SoftbusMock::GetMock().SendEvent(pkgName, target, event);
43 }
44 
StopEvent(const char * pkgName,BroadCastAddr target,EventType event)45 int32_t StopEvent(const char* pkgName, BroadCastAddr target, EventType event)
46 {
47     return SoftbusMock::GetMock().StopEvent(pkgName, target, event);
48 }
49 
RegisterEventListener(const char * pkgName,EventListener * listener)50 int32_t RegisterEventListener(const char* pkgName, EventListener *listener)
51 {
52     return SoftbusMock::GetMock().RegisterEventListener(pkgName, listener);
53 }
54 
UnregisterEventListener(const char * pkgName,EventListener * listener)55 int32_t UnregisterEventListener(const char* pkgName, EventListener *listener)
56 {
57     return SoftbusMock::GetMock().UnregisterEventListener(pkgName, listener);
58 }
59 }
60 } // namespace DistributedSchedule
61 } // namespace OHOS