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