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 #include <gmock/gmock.h>
17 #include <gtest/gtest.h>
18 #include <string>
19 #include <vector>
20 
21 #include "bus_center_manager.h"
22 #include "lnn_bus_center_ipc.h"
23 #include "softbus_common.h"
24 #include "softbus_def.h"
25 #include "softbus_error_code.h"
26 
27 using namespace testing::ext;
28 using testing::_;
29 using testing::AtLeast;
30 using testing::Eq;
31 using testing::Field;
32 using testing::Ge;
33 using testing::NiceMock;
34 using testing::NotNull;
35 using testing::Return;
36 
37 namespace {
38 constexpr int32_t CAPABILITY_CASTPLUS = 1 << 3;
39 constexpr int32_t CAPABILITY_OSD = 1 << 7;
40 constexpr int32_t g_callingPid1 = 1;
41 constexpr int32_t g_callingPid2 = 2;
42 const std::string g_pkgName1 = "pkgName1";
43 const std::string g_pkgName2 = "pkgName2";
44 const std::vector<char> g_invalidPkgName(PKG_NAME_SIZE_MAX + 1, 'X');
45 const SubscribeInfo g_subscribeInfoCast = {
46     .subscribeId = 1,
47     .capability = "castPlus",
48 };
49 const SubscribeInfo g_subscribeInfoOsd = {
50     .subscribeId = 2,
51     .capability = "osdCapability",
52 };
53 const DeviceInfo g_deviceInfoCast = {
54     .capabilityBitmapNum = 1,
55     .capabilityBitmap = {CAPABILITY_CASTPLUS},
56 };
57 const DeviceInfo g_deviceInfoOsd = {
58     .capabilityBitmapNum = 1,
59     .capabilityBitmap = {CAPABILITY_OSD},
60 };
61 const InnerDeviceInfoAddtions g_additions = {};
62 
63 class BusCenterInterface {
64 public:
65     virtual int32_t ClientOnRefreshDeviceFound(const char *pkgName, int32_t pid, const void *device,
66         uint32_t deviceLen) = 0;
67     virtual int32_t LnnStartDiscDevice(const char *pkgName, const SubscribeInfo *info, const InnerCallback *cb,
68         bool isInnerRequest) = 0;
69     virtual int32_t LnnStopDiscDevice(const char *pkgName, int32_t subscribeId, bool isInnerRequest) = 0;
70     virtual void LnnRefreshDeviceOnlineStateAndDevIdInfo(const char *pkgName, DeviceInfo *device,
71         const InnerDeviceInfoAddtions *additions) = 0;
72 };
73 
74 class BusCenterMock : public BusCenterInterface {
75 public:
BusCenterMock()76     BusCenterMock()
77     {
78         mock_ = this;
79         ON_CALL(*this, ClientOnRefreshDeviceFound).WillByDefault(Return(SOFTBUS_OK));
80         ON_CALL(*this, LnnStartDiscDevice).WillByDefault(ActionLnnStartDiscDevice);
81         ON_CALL(*this, LnnStopDiscDevice).WillByDefault(Return(SOFTBUS_OK));
82         innerCallback_.serverCb.OnServerDeviceFound = nullptr;
83     }
~BusCenterMock()84     ~BusCenterMock()
85     {
86         mock_ = nullptr;
87         innerCallback_.serverCb.OnServerDeviceFound = nullptr;
88     }
89 
90     MOCK_METHOD(int32_t, ClientOnRefreshDeviceFound, (const char *pkgName, int32_t pid, const void *device,
91         uint32_t deviceLen), (override));
92     MOCK_METHOD(int32_t, LnnStartDiscDevice, (const char *pkgName, const SubscribeInfo *info, const InnerCallback *cb,
93         bool isInnerRequest), (override));
94     MOCK_METHOD(int32_t, LnnStopDiscDevice, (const char *pkgName, int32_t subscribeId,
95         bool isInnerRequest), (override));
96     MOCK_METHOD(void, LnnRefreshDeviceOnlineStateAndDevIdInfo, (const char *pkgName, DeviceInfo *device,
97         const InnerDeviceInfoAddtions *additions), (override));
98 
GetMock()99     static BusCenterMock *GetMock()
100     {
101         return mock_;
102     }
ActionLnnStartDiscDevice(const char * pkgName,const SubscribeInfo * info,const InnerCallback * cb,bool isInnerRequest)103     static int32_t ActionLnnStartDiscDevice(const char *pkgName, const SubscribeInfo *info, const InnerCallback *cb,
104         bool isInnerRequest)
105     {
106         if (cb == nullptr || cb->serverCb.OnServerDeviceFound == nullptr) {
107             return SOFTBUS_INVALID_PARAM;
108         }
109         innerCallback_.serverCb.OnServerDeviceFound = cb->serverCb.OnServerDeviceFound;
110         return SOFTBUS_OK;
111     }
CallbackOnServerDeviceFound(const char * pkgName,const DeviceInfo * device,const InnerDeviceInfoAddtions * additions)112     static int32_t CallbackOnServerDeviceFound(const char *pkgName, const DeviceInfo *device,
113         const InnerDeviceInfoAddtions *additions)
114     {
115         if (innerCallback_.serverCb.OnServerDeviceFound == nullptr) {
116             return SOFTBUS_NO_INIT;
117         }
118         return innerCallback_.serverCb.OnServerDeviceFound(pkgName, device, additions);
119     }
120 
121 private:
122     static inline BusCenterMock *mock_ = nullptr;
123     static inline InnerCallback innerCallback_ = {};
124 };
125 
126 extern "C" {
ClientOnRefreshDeviceFound(const char * pkgName,int32_t pid,const void * device,uint32_t deviceLen)127 int32_t ClientOnRefreshDeviceFound(const char *pkgName, int32_t pid, const void *device, uint32_t deviceLen)
128 {
129     return BusCenterMock::GetMock()->ClientOnRefreshDeviceFound(pkgName, pid, device, deviceLen);
130 }
131 
LnnStartDiscDevice(const char * pkgName,const SubscribeInfo * info,const InnerCallback * cb,bool isInnerRequest)132 int32_t LnnStartDiscDevice(const char *pkgName, const SubscribeInfo *info, const InnerCallback *cb,
133     bool isInnerRequest)
134 {
135     return BusCenterMock::GetMock()->LnnStartDiscDevice(pkgName, info, cb, isInnerRequest);
136 }
137 
LnnStopDiscDevice(const char * pkgName,int32_t subscribeId,bool isInnerRequest)138 int32_t LnnStopDiscDevice(const char *pkgName, int32_t subscribeId, bool isInnerRequest)
139 {
140     return BusCenterMock::GetMock()->LnnStopDiscDevice(pkgName, subscribeId, isInnerRequest);
141 }
142 
LnnRefreshDeviceOnlineStateAndDevIdInfo(const char * pkgName,DeviceInfo * device,const InnerDeviceInfoAddtions * additions)143 void LnnRefreshDeviceOnlineStateAndDevIdInfo(const char *pkgName, DeviceInfo *device,
144     const InnerDeviceInfoAddtions *additions)
145 {
146     return BusCenterMock::GetMock()->LnnRefreshDeviceOnlineStateAndDevIdInfo(pkgName, device, additions);
147 }
148 } // extern "C"
149 } // anonymize namespace
150 
151 namespace OHOS {
152 class DiscClientOnDeviceFoundTest : public testing::Test {
153 public:
SetUpTestCase()154     static void SetUpTestCase() {}
TearDownTestCase()155     static void TearDownTestCase() {}
SetUp()156     void SetUp() override {}
TearDown()157     void TearDown() override {}
158 };
159 
160 MATCHER_P(EqStr, expect, "string not equal")
161 {
162     return expect == std::string(arg);
163 }
164 
165 /*
166  * @tc.name: LnnIpcRefreshLNNFailed001
167  * @tc.desc: should not call LnnStartDiscDevice when call LnnIpcRefreshLNN with invalid params
168  * @tc.type: FUNC
169  * @tc.require:
170  */
171 HWTEST_F(DiscClientOnDeviceFoundTest, LnnIpcRefreshLNNFailed001, TestSize.Level1)
172 {
173     NiceMock<BusCenterMock> mock;
174     EXPECT_CALL(mock, LnnStartDiscDevice).Times(0);
175 
176     int32_t ret = LnnIpcRefreshLNN(nullptr, g_callingPid1, &g_subscribeInfoCast);
177     EXPECT_NE(ret, SOFTBUS_OK);
178 
179     ret = LnnIpcRefreshLNN(&g_invalidPkgName[0], g_callingPid1, &g_subscribeInfoCast);
180     EXPECT_NE(ret, SOFTBUS_OK);
181 
182     ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid1, nullptr);
183     EXPECT_NE(ret, SOFTBUS_OK);
184 }
185 
186 /*
187  * @tc.name: LnnIpcRefreshLNNSuccess001
188  * @tc.desc: should call LnnStartDiscDevice when call LnnIpcRefreshLNN with valid params
189  * @tc.type: FUNC
190  * @tc.require:
191  */
192 HWTEST_F(DiscClientOnDeviceFoundTest, LnnIpcRefreshLNNSuccess001, TestSize.Level1)
193 {
194     NiceMock<BusCenterMock> mock;
195     int32_t ret = SOFTBUS_OK;
196     {
197         EXPECT_CALL(mock, LnnStartDiscDevice(EqStr(g_pkgName1),
198             Field(&SubscribeInfo::subscribeId, Eq(g_subscribeInfoCast.subscribeId)), NotNull(), _)).Times(1);
199         ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid1, &g_subscribeInfoCast);
200         EXPECT_EQ(ret, SOFTBUS_OK);
201     }
202     {
203         EXPECT_CALL(mock, LnnStartDiscDevice(EqStr(g_pkgName2),
204             Field(&SubscribeInfo::subscribeId, Eq(g_subscribeInfoOsd.subscribeId)), NotNull(), _)).Times(1);
205         ret = LnnIpcRefreshLNN(g_pkgName2.c_str(), g_callingPid2, &g_subscribeInfoOsd);
206         EXPECT_EQ(ret, SOFTBUS_OK);
207     }
208 }
209 
210 /*
211  * @tc.name: LnnIpcStopRefreshLNNFailed001
212  * @tc.desc: should not call LnnStopDiscDevice when call LnnIpcStopRefreshLNN with invalid params
213  * @tc.type: FUNC
214  * @tc.require:
215  */
216 HWTEST_F(DiscClientOnDeviceFoundTest, LnnIpcStopRefreshLNNFailed001, TestSize.Level1)
217 {
218     NiceMock<BusCenterMock> mock;
219     EXPECT_CALL(mock, LnnStopDiscDevice).Times(0);
220 
221     int32_t ret = LnnIpcStopRefreshLNN(nullptr, g_callingPid1, g_subscribeInfoCast.subscribeId);
222     EXPECT_NE(ret, SOFTBUS_OK);
223 
224     ret = LnnIpcStopRefreshLNN(&g_invalidPkgName[0], g_callingPid1, g_subscribeInfoCast.subscribeId);
225     EXPECT_NE(ret, SOFTBUS_OK);
226 }
227 
228 /*
229  * @tc.name: LnnIpcStopRefreshLNNSuccess001
230  * @tc.desc: should call LnnStopDiscDevice when call LnnIpcStopRefreshLNN with valid params
231  * @tc.type: FUNC
232  * @tc.require:
233  */
234 HWTEST_F(DiscClientOnDeviceFoundTest, LnnIpcStopRefreshLNNSuccess001, TestSize.Level1)
235 {
236     NiceMock<BusCenterMock> mock;
237     int32_t ret = SOFTBUS_OK;
238     {
239         EXPECT_CALL(mock, LnnStopDiscDevice(EqStr(g_pkgName1), g_subscribeInfoCast.subscribeId, _)).Times(1);
240         ret = LnnIpcStopRefreshLNN(g_pkgName1.c_str(), g_callingPid1, g_subscribeInfoCast.subscribeId);
241         EXPECT_EQ(ret, SOFTBUS_OK);
242     }
243     {
244         EXPECT_CALL(mock, LnnStopDiscDevice(EqStr(g_pkgName2), g_subscribeInfoOsd.subscribeId, _)).Times(1);
245         ret = LnnIpcStopRefreshLNN(g_pkgName2.c_str(), g_callingPid2, g_subscribeInfoOsd.subscribeId);
246         EXPECT_EQ(ret, SOFTBUS_OK);
247     }
248 }
249 
250 /*
251  * @tc.name: OnServerDeviceFoundFailed001
252  * @tc.desc: should not report device when call OnServerDeviceFound with invalid params or uninterested params
253  * @tc.type: FUNC
254  * @tc.require:
255  */
256 HWTEST_F(DiscClientOnDeviceFoundTest, OnServerDeviceFoundFailed001, TestSize.Level1)
257 {
258     NiceMock<BusCenterMock> mock;
259     EXPECT_CALL(mock, ClientOnRefreshDeviceFound).Times(0);
260 
261     int32_t ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoCast, &g_additions);
262     EXPECT_NE(ret, SOFTBUS_OK);
263 
264     ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid1, &g_subscribeInfoCast);
265     EXPECT_EQ(ret, SOFTBUS_OK);
266 
267     ret = mock.CallbackOnServerDeviceFound(nullptr, &g_deviceInfoCast, &g_additions);
268     EXPECT_NE(ret, SOFTBUS_OK);
269 
270     ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), nullptr, &g_additions);
271     EXPECT_NE(ret, SOFTBUS_OK);
272 
273     ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoCast, nullptr);
274     EXPECT_NE(ret, SOFTBUS_OK);
275 
276     ret = mock.CallbackOnServerDeviceFound(g_pkgName2.c_str(), &g_deviceInfoCast, &g_additions);
277     EXPECT_EQ(ret, SOFTBUS_OK);
278 
279     ret = LnnIpcStopRefreshLNN(g_pkgName1.c_str(), g_callingPid1, g_subscribeInfoCast.subscribeId);
280     EXPECT_EQ(ret, SOFTBUS_OK);
281 
282     ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoCast, &g_additions);
283     EXPECT_EQ(ret, SOFTBUS_OK);
284 }
285 
286 /*
287  * @tc.name: OnServerDeviceFoundSuccess001
288  * @tc.desc: should report cast when refresh cast and cast device found
289  * @tc.type: FUNC
290  * @tc.require:
291  */
292 HWTEST_F(DiscClientOnDeviceFoundTest, OnServerDeviceFoundSuccess001, TestSize.Level1)
293 {
294     NiceMock<BusCenterMock> mock;
295 
296     int32_t ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid1, &g_subscribeInfoCast);
297     EXPECT_EQ(ret, SOFTBUS_OK);
298     {
299         EXPECT_CALL(mock, ClientOnRefreshDeviceFound(EqStr(g_pkgName1), g_callingPid1, NotNull(), Ge(1))).Times(1);
300         ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoCast, &g_additions);
301         EXPECT_EQ(ret, SOFTBUS_OK);
302     }
303     ret = LnnIpcStopRefreshLNN(g_pkgName1.c_str(), g_callingPid1, g_subscribeInfoCast.subscribeId);
304     EXPECT_EQ(ret, SOFTBUS_OK);
305 }
306 
307 /*
308  * @tc.name: OnServerDeviceFoundWhenRefreshRepeatRequest001
309  * @tc.desc: should report device once when refresh cast twice with same params and one cast device found
310  *           should not report cast when refresh cast twice with same params and stop refresh cast once
311  * @tc.type: FUNC
312  * @tc.require:
313  */
314 HWTEST_F(DiscClientOnDeviceFoundTest, OnServerDeviceFoundWhenRefreshRepeatRequest001, TestSize.Level1)
315 {
316     NiceMock<BusCenterMock> mock;
317 
318     int32_t ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid1, &g_subscribeInfoCast);
319     EXPECT_EQ(ret, SOFTBUS_OK);
320     ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid1, &g_subscribeInfoCast);
321     EXPECT_EQ(ret, SOFTBUS_OK);
322     {
323         EXPECT_CALL(mock, ClientOnRefreshDeviceFound(EqStr(g_pkgName1), g_callingPid1, NotNull(), Ge(1))).Times(1);
324         ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoCast, &g_additions);
325         EXPECT_EQ(ret, SOFTBUS_OK);
326     }
327     ret = LnnIpcStopRefreshLNN(g_pkgName1.c_str(), g_callingPid1, g_subscribeInfoCast.subscribeId);
328     EXPECT_EQ(ret, SOFTBUS_OK);
329     {
330         EXPECT_CALL(mock, ClientOnRefreshDeviceFound).Times(0);
331         ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoCast, &g_additions);
332         EXPECT_EQ(ret, SOFTBUS_OK);
333     }
334 }
335 
336 /*
337  * @tc.name: OnServerDeviceFoundWhenRefreshWithSamePkgPid001
338  * @tc.desc: should report osd when refresh osd & cast with same pkgName, pid and stop refresh cast
339  * @tc.type: FUNC
340  * @tc.require:
341  */
342 HWTEST_F(DiscClientOnDeviceFoundTest, OnServerDeviceFoundWhenRefreshWithSamePkgPid001, TestSize.Level1)
343 {
344     NiceMock<BusCenterMock> mock;
345 
346     int32_t ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid1, &g_subscribeInfoCast);
347     EXPECT_EQ(ret, SOFTBUS_OK);
348     ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid1, &g_subscribeInfoOsd);
349     EXPECT_EQ(ret, SOFTBUS_OK);
350     {
351         EXPECT_CALL(mock, ClientOnRefreshDeviceFound(EqStr(g_pkgName1), g_callingPid1, NotNull(), Ge(1)))
352             .Times(AtLeast(1));
353         ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoCast, &g_additions);
354         EXPECT_EQ(ret, SOFTBUS_OK);
355     }
356     {
357         EXPECT_CALL(mock, ClientOnRefreshDeviceFound(EqStr(g_pkgName1), g_callingPid1, NotNull(), Ge(1)))
358             .Times(AtLeast(1));
359         ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoOsd, &g_additions);
360         EXPECT_EQ(ret, SOFTBUS_OK);
361     }
362     ret = LnnIpcStopRefreshLNN(g_pkgName1.c_str(), g_callingPid1, g_subscribeInfoCast.subscribeId);
363     EXPECT_EQ(ret, SOFTBUS_OK);
364     {
365         EXPECT_CALL(mock, ClientOnRefreshDeviceFound(EqStr(g_pkgName1), g_callingPid1, NotNull(), Ge(1))).Times(1);
366         ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoOsd, &g_additions);
367         EXPECT_EQ(ret, SOFTBUS_OK);
368     }
369     ret = LnnIpcStopRefreshLNN(g_pkgName1.c_str(), g_callingPid1, g_subscribeInfoOsd.subscribeId);
370     EXPECT_EQ(ret, SOFTBUS_OK);
371     {
372         EXPECT_CALL(mock, ClientOnRefreshDeviceFound).Times(0);
373         ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoOsd, &g_additions);
374         EXPECT_EQ(ret, SOFTBUS_OK);
375     }
376 }
377 
378 /*
379  * @tc.name: OnServerDeviceFoundWhenRefreshWithDiffPid001
380  * @tc.desc: should report osd when refresh osd & cast with different pid and stop refresh cast
381  * @tc.type: FUNC
382  * @tc.require:
383  */
384 HWTEST_F(DiscClientOnDeviceFoundTest, OnServerDeviceFoundWhenRefreshWithDiffPid001, TestSize.Level1)
385 {
386     NiceMock<BusCenterMock> mock;
387 
388     int32_t ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid1, &g_subscribeInfoCast);
389     EXPECT_EQ(ret, SOFTBUS_OK);
390     ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid2, &g_subscribeInfoOsd);
391     EXPECT_EQ(ret, SOFTBUS_OK);
392     ret = LnnIpcStopRefreshLNN(g_pkgName1.c_str(), g_callingPid1, g_subscribeInfoCast.subscribeId);
393     EXPECT_EQ(ret, SOFTBUS_OK);
394     {
395         EXPECT_CALL(mock, ClientOnRefreshDeviceFound(EqStr(g_pkgName1), g_callingPid2, NotNull(), Ge(1))).Times(1);
396         ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoOsd, &g_additions);
397         EXPECT_EQ(ret, SOFTBUS_OK);
398     }
399     ret = LnnIpcStopRefreshLNN(g_pkgName1.c_str(), g_callingPid2, g_subscribeInfoOsd.subscribeId);
400     EXPECT_EQ(ret, SOFTBUS_OK);
401     {
402         EXPECT_CALL(mock, ClientOnRefreshDeviceFound).Times(0);
403         ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoOsd, &g_additions);
404         EXPECT_EQ(ret, SOFTBUS_OK);
405     }
406 }
407 
408 /*
409  * @tc.name: OnServerDeviceFoundWhenRefreshWithDiffPkg001
410  * @tc.desc: should report osd and not report cast when refresh osd & cast with different pkgName and stop refresh cast
411  * @tc.type: FUNC
412  * @tc.require:
413  */
414 HWTEST_F(DiscClientOnDeviceFoundTest, OnServerDeviceFoundWhenRefreshWithDiffPkg001, TestSize.Level1)
415 {
416     NiceMock<BusCenterMock> mock;
417 
418     int32_t ret = LnnIpcRefreshLNN(g_pkgName1.c_str(), g_callingPid1, &g_subscribeInfoCast);
419     EXPECT_EQ(ret, SOFTBUS_OK);
420     ret = LnnIpcRefreshLNN(g_pkgName2.c_str(), g_callingPid1, &g_subscribeInfoOsd);
421     EXPECT_EQ(ret, SOFTBUS_OK);
422     ret = LnnIpcStopRefreshLNN(g_pkgName1.c_str(), g_callingPid1, g_subscribeInfoCast.subscribeId);
423     EXPECT_EQ(ret, SOFTBUS_OK);
424     {
425         EXPECT_CALL(mock, ClientOnRefreshDeviceFound).Times(0);
426         ret = mock.CallbackOnServerDeviceFound(g_pkgName1.c_str(), &g_deviceInfoCast, &g_additions);
427         EXPECT_EQ(ret, SOFTBUS_OK);
428     }
429     {
430         EXPECT_CALL(mock, ClientOnRefreshDeviceFound(EqStr(g_pkgName2), g_callingPid1, NotNull(), Ge(1))).Times(1);
431         ret = mock.CallbackOnServerDeviceFound(g_pkgName2.c_str(), &g_deviceInfoOsd, &g_additions);
432         EXPECT_EQ(ret, SOFTBUS_OK);
433     }
434     ret = LnnIpcStopRefreshLNN(g_pkgName2.c_str(), g_callingPid1, g_subscribeInfoOsd.subscribeId);
435     EXPECT_EQ(ret, SOFTBUS_OK);
436     {
437         EXPECT_CALL(mock, ClientOnRefreshDeviceFound).Times(0);
438         ret = mock.CallbackOnServerDeviceFound(g_pkgName2.c_str(), &g_deviceInfoOsd, &g_additions);
439         EXPECT_EQ(ret, SOFTBUS_OK);
440     }
441 }
442 } // namespace OHOS
443