• 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)39 int32_t DiscPublishService(const char *packageName, const PublishInfo *info)
40 {
41     return GetDiscManagerInterface()->DiscPublishService(packageName, info);
42 }
DiscStartScan(DiscModule moduleId,const PublishInfo * info)43 int32_t DiscStartScan(DiscModule moduleId, const PublishInfo *info)
44 {
45     return GetDiscManagerInterface()->DiscStartScan(moduleId, info);
46 }
DiscUnPublishService(const char * packageName,int32_t publishId)47 int32_t DiscUnPublishService(const char *packageName, int32_t publishId)
48 {
49     return GetDiscManagerInterface()->DiscUnPublishService(packageName, publishId);
50 }
DiscUnpublish(DiscModule moduleId,int32_t publishId)51 int32_t DiscUnpublish(DiscModule moduleId, int32_t publishId)
52 {
53     return GetDiscManagerInterface()->DiscUnpublish(moduleId, publishId);
54 }
DiscStartDiscovery(const char * packageName,const SubscribeInfo * info,const IServerDiscInnerCallback * cb)55 int32_t DiscStartDiscovery(const char *packageName, const SubscribeInfo *info, const IServerDiscInnerCallback *cb)
56 {
57     return GetDiscManagerInterface()->DiscStartDiscovery(packageName, info, cb);
58 }
DiscSetDiscoverCallback(DiscModule moduleId,const DiscInnerCallback * callback)59 int32_t DiscSetDiscoverCallback(DiscModule moduleId, const DiscInnerCallback *callback)
60 {
61     return GetDiscManagerInterface()->DiscSetDiscoverCallback(moduleId, callback);
62 }
DiscStartAdvertise(DiscModule moduleId,const SubscribeInfo * info)63 int32_t DiscStartAdvertise(DiscModule moduleId, const SubscribeInfo *info)
64 {
65     return GetDiscManagerInterface()->DiscStartAdvertise(moduleId, info);
66 }
DiscStopDiscovery(const char * packageName,int32_t subscribeId)67 int32_t DiscStopDiscovery(const char *packageName, int32_t subscribeId)
68 {
69     return GetDiscManagerInterface()->DiscStopDiscovery(packageName, subscribeId);
70 }
DiscStopAdvertise(DiscModule moduleId,int32_t subscribeId)71 int32_t DiscStopAdvertise(DiscModule moduleId, int32_t subscribeId)
72 {
73     return GetDiscManagerInterface()->DiscStopAdvertise(moduleId, subscribeId);
74 }
75 }
76 } // namespace OHOS
77