• 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 #include "disc_manager_mock.h"
17 
18 using namespace testing;
19 using namespace testing::ext;
20 
21 namespace OHOS {
22 void *g_discManagerInterface;
DiscManagerInterfaceMock()23 DiscManagerInterfaceMock::DiscManagerInterfaceMock()
24 {
25     g_discManagerInterface = reinterpret_cast<void *>(this);
26 }
27 
~DiscManagerInterfaceMock()28 DiscManagerInterfaceMock::~DiscManagerInterfaceMock()
29 {
30     g_discManagerInterface = nullptr;
31 }
32 
GetDiscManagerInterface()33 static DiscManagerInterface *GetDiscManagerInterface()
34 {
35     return reinterpret_cast<DiscManagerInterfaceMock *>(g_discManagerInterface);
36 }
37 
38 extern "C" {
DiscPublishService(const char * packageName,const PublishInfo * info,int32_t callingPid)39 int32_t DiscPublishService(const char *packageName, const PublishInfo *info, int32_t callingPid)
40 {
41     return GetDiscManagerInterface()->DiscPublishService(packageName, info, callingPid);
42 }
DiscStartScan(DiscModule moduleId,const PublishInfo * info,int32_t callingPid)43 int32_t DiscStartScan(DiscModule moduleId, const PublishInfo *info, int32_t callingPid)
44 {
45     return GetDiscManagerInterface()->DiscStartScan(moduleId, info, callingPid);
46 }
DiscUnPublishService(const char * packageName,int32_t publishId,int32_t callingPid)47 int32_t DiscUnPublishService(const char *packageName, int32_t publishId, int32_t callingPid)
48 {
49     return GetDiscManagerInterface()->DiscUnPublishService(packageName, publishId, callingPid);
50 }
DiscUnpublish(DiscModule moduleId,int32_t publishId,int32_t callingPid)51 int32_t DiscUnpublish(DiscModule moduleId, int32_t publishId, int32_t callingPid)
52 {
53     return GetDiscManagerInterface()->DiscUnpublish(moduleId, publishId, callingPid);
54 }
DiscStartDiscovery(const char * packageName,const SubscribeInfo * info,const IServerDiscInnerCallback * cb,int32_t callingPid)55 int32_t DiscStartDiscovery(const char *packageName, const SubscribeInfo *info, const IServerDiscInnerCallback *cb,
56     int32_t callingPid)
57 {
58     return GetDiscManagerInterface()->DiscStartDiscovery(packageName, info, cb, callingPid);
59 }
DiscSetDiscoverCallback(DiscModule moduleId,const DiscInnerCallback * callback)60 int32_t DiscSetDiscoverCallback(DiscModule moduleId, const DiscInnerCallback *callback)
61 {
62     return GetDiscManagerInterface()->DiscSetDiscoverCallback(moduleId, callback);
63 }
DiscStartAdvertise(DiscModule moduleId,const SubscribeInfo * info,int32_t callingPid)64 int32_t DiscStartAdvertise(DiscModule moduleId, const SubscribeInfo *info, int32_t callingPid)
65 {
66     return GetDiscManagerInterface()->DiscStartAdvertise(moduleId, info, callingPid);
67 }
DiscStopDiscovery(const char * packageName,int32_t subscribeId,int32_t callingPid)68 int32_t DiscStopDiscovery(const char *packageName, int32_t subscribeId, int32_t callingPid)
69 {
70     return GetDiscManagerInterface()->DiscStopDiscovery(packageName, subscribeId, callingPid);
71 }
DiscStopAdvertise(DiscModule moduleId,int32_t subscribeId,int32_t callingPid)72 int32_t DiscStopAdvertise(DiscModule moduleId, int32_t subscribeId, int32_t callingPid)
73 {
74     return GetDiscManagerInterface()->DiscStopAdvertise(moduleId, subscribeId, callingPid);
75 }
76 }
77 } // namespace OHOS
78