1 /*
2 * Copyright (c) 2021 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 <cstdio>
17 #include <ctime>
18 #include <gtest/gtest.h>
19 #include <sys/time.h>
20 #include <unistd.h>
21
22 #include "softbus_access_token_test.h"
23 #include "discovery_service.h"
24
25 using namespace testing::ext;
26
27 #define TEST_ERRO_MOUDULE ((MODULE_LNN) + 3)
28
29 namespace OHOS {
30 static int g_subscribeId = 0;
31 static int g_publishId = 0;
32 static const char *g_pkgName = "Softbus_Kits";
33 static const char *g_pkgName_1 = "Softbus_Kits_1";
34 static const char *g_erroPkgName = "Softbus_Erro_Kits";
35 static const char* g_erroPkgName1 = "ErroErroErroErroErroErroErroErroErroErroErroErroErroErroErroErroEErroE";
36
37 const int32_t ERRO_CAPDATA_LEN = 514;
38
39 class Disc_Test : public testing::Test {
40 public:
Disc_Test()41 Disc_Test()
42 {}
~Disc_Test()43 ~Disc_Test()
44 {}
45 static void SetUpTestCase(void);
46 static void TearDownTestCase(void);
SetUp()47 void SetUp() override
48 {}
TearDown()49 void TearDown() override
50 {}
51 };
52
SetUpTestCase(void)53 void Disc_Test::SetUpTestCase(void)
54 {
55 SetAceessTokenPermission("discTest");
56 }
57
TearDownTestCase(void)58 void Disc_Test::TearDownTestCase(void)
59 {}
60
GetSubscribeId(void)61 static int GetSubscribeId(void)
62 {
63 g_subscribeId++;
64 return g_subscribeId;
65 }
66
GetPublishId(void)67 static int GetPublishId(void)
68 {
69 g_publishId++;
70 return g_publishId;
71 }
72
73 static SubscribeInfo g_sInfo = {
74 .subscribeId = 1,
75 .mode = DISCOVER_MODE_ACTIVE,
76 .medium = COAP,
77 .freq = MID,
78 .isSameAccount = true,
79 .isWakeRemote = false,
80 .capability = "dvKit",
81 .capabilityData = (unsigned char *)"capdata3",
82 .dataLen = sizeof("capdata3")
83 };
84
85 static PublishInfo g_pInfo = {
86 .publishId = 1,
87 .mode = DISCOVER_MODE_ACTIVE,
88 .medium = COAP,
89 .freq = MID,
90 .capability = "dvKit",
91 .capabilityData = (unsigned char *)"capdata4",
92 .dataLen = sizeof("capdata4")
93 };
94
95 static PublishInfo g_pInfo1 = {
96 .publishId = 1,
97 .mode = DISCOVER_MODE_ACTIVE,
98 .medium = COAP,
99 .freq = MID,
100 .capability = "dvKit",
101 .capabilityData = NULL,
102 .dataLen = 0
103 };
104
105 static SubscribeInfo g_sInfo1 = {
106 .subscribeId = 1,
107 .mode = DISCOVER_MODE_ACTIVE,
108 .medium = COAP,
109 .freq = MID,
110 .isSameAccount = true,
111 .isWakeRemote = false,
112 .capability = "hicall",
113 .capabilityData = NULL,
114 .dataLen = 0
115 };
116
TestDeviceFound(const DeviceInfo * device)117 static void TestDeviceFound(const DeviceInfo *device)
118 {
119 printf("[client]TestDeviceFound\n");
120 }
121
TestDiscoverFailed(int subscribeId,DiscoveryFailReason failReason)122 static void TestDiscoverFailed(int subscribeId, DiscoveryFailReason failReason)
123 {
124 printf("[client]TestDiscoverFailed\n");
125 }
126
TestDiscoverySuccess(int subscribeId)127 static void TestDiscoverySuccess(int subscribeId)
128 {
129 printf("[client]TestDiscoverySuccess\n");
130 }
131
TestPublishSuccess(int publishId)132 static void TestPublishSuccess(int publishId)
133 {
134 printf("[client]TestPublishSuccess\n");
135 }
136
TestPublishFail(int publishId,PublishFailReason reason)137 static void TestPublishFail(int publishId, PublishFailReason reason)
138 {
139 printf("[client]TestPublishFail\n");
140 }
141
142 static IDiscoveryCallback g_subscribeCb = {
143 .OnDeviceFound = TestDeviceFound,
144 .OnDiscoverFailed = TestDiscoverFailed,
145 .OnDiscoverySuccess = TestDiscoverySuccess
146 };
147
148 static IPublishCallback g_publishCb = {
149 .OnPublishSuccess = TestPublishSuccess,
150 .OnPublishFail = TestPublishFail
151 };
152
153 /**
154 * @tc.name: PublishServiceTest001
155 * @tc.desc: Test for wrong parameters
156 * @tc.type: FUNC
157 * @tc.require:
158 */
159 HWTEST_F(Disc_Test, PublishServiceTest001, TestSize.Level0)
160 {
161 int ret;
162 PublishInfo testInfo = {
163 .publishId = GetPublishId(),
164 .mode = DISCOVER_MODE_ACTIVE,
165 .medium = COAP,
166 .freq = MID,
167 .capability = "dvKit",
168 .capabilityData = (unsigned char *)"capdata2",
169 .dataLen = sizeof("capdata2")
170 };
171
172 ret = PublishService(NULL, &testInfo, &g_publishCb);
173 EXPECT_TRUE(ret != 0);
174
175 ret = PublishService(g_pkgName, NULL, &g_publishCb);
176 EXPECT_TRUE(ret != 0);
177
178 ret = PublishService(g_pkgName, &testInfo, NULL);
179 EXPECT_TRUE(ret != 0);
180
181 testInfo.medium = (ExchangeMedium)(COAP + 1);
182 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
183 EXPECT_TRUE(ret != 0);
184 testInfo.medium = COAP;
185
186 testInfo.mode = (DiscoverMode)(DISCOVER_MODE_ACTIVE + 1);
187 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
188 EXPECT_TRUE(ret != 0);
189 testInfo.mode = DISCOVER_MODE_ACTIVE;
190
191 testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
192 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
193 EXPECT_TRUE(ret != 0);
194 testInfo.freq = LOW;
195
196 testInfo.capabilityData = NULL;
197 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
198 EXPECT_TRUE(ret != 0);
199 testInfo.capabilityData = (unsigned char *)"capdata1";
200
201 testInfo.dataLen = ERRO_CAPDATA_LEN;
202 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
203 EXPECT_TRUE(ret != 0);
204 testInfo.dataLen = sizeof("capdata1");
205 }
206
207 /**
208 * @tc.name: PublishServiceTest002
209 * @tc.desc: Test GetPublishId and PublishService to see if they are running properly.
210 * @tc.type: FUNC
211 * @tc.require:
212 */
213 HWTEST_F(Disc_Test, PublishServiceTest002, TestSize.Level0)
214 {
215 int ret;
216
217 g_pInfo.publishId = GetPublishId();
218 ret = PublishService(g_pkgName, &g_pInfo, &g_publishCb);
219 EXPECT_TRUE(ret == 0);
220 ret = UnPublishService(g_pkgName, g_pInfo.publishId);
221
222 g_pInfo1.publishId = GetPublishId();
223 ret = PublishService(g_pkgName, &g_pInfo1, &g_publishCb);
224 EXPECT_TRUE(ret == 0);
225 ret = UnPublishService(g_pkgName, g_pInfo1.publishId);
226
227 g_pInfo1.publishId = GetPublishId();
228 ret = PublishService(g_pkgName_1, &g_pInfo1, &g_publishCb);
229 EXPECT_TRUE(ret == 0);
230 ret = UnPublishService(g_pkgName, g_pInfo1.publishId);
231 }
232
233 /**
234 * @tc.name: PublishServiceTest003
235 * @tc.desc: Verify same parameter again
236 * @tc.type: FUNC
237 * @tc.require:
238 */
239 HWTEST_F(Disc_Test, PublishServiceTest003, TestSize.Level0)
240 {
241 int ret;
242
243 g_pInfo.publishId = GetPublishId();
244 ret = PublishService(g_pkgName, &g_pInfo, &g_publishCb);
245 EXPECT_TRUE(ret == 0);
246 ret = UnPublishService(g_pkgName, g_pInfo.publishId);
247 }
248
249 /**
250 * @tc.name: PublishServiceTest004
251 * @tc.desc: Test active publish, verify correct parameter with active mode and "COAP" medium.
252 * @tc.in: Test module, Test number, Test levels.
253 * @tc.out: Zero
254 * @tc.type: FUNC
255 * @tc.require: The PublishService and UnPublishService operates normally.
256 */
257 HWTEST_F(Disc_Test, PublishServiceTest004, TestSize.Level1)
258 {
259 int ret;
260 PublishInfo testInfo = {
261 .publishId = GetPublishId(),
262 .mode = DISCOVER_MODE_ACTIVE,
263 .medium = COAP,
264 .freq = LOW,
265 .capability = "dvKit",
266 .capabilityData = (unsigned char *)"capdata2",
267 .dataLen = sizeof("capdata2")
268 };
269
270 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
271 EXPECT_TRUE(ret == 0);
272 ret = UnPublishService(g_pkgName, testInfo.publishId);
273 EXPECT_TRUE(ret == 0);
274
275 testInfo.freq = MID;
276 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
277 EXPECT_TRUE(ret == 0);
278 ret = UnPublishService(g_pkgName, testInfo.publishId);
279 EXPECT_TRUE(ret == 0);
280
281 testInfo.freq = HIGH;
282 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
283 EXPECT_TRUE(ret == 0);
284 ret = UnPublishService(g_pkgName, testInfo.publishId);
285 EXPECT_TRUE(ret == 0);
286
287 testInfo.freq = SUPER_HIGH;
288 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
289 EXPECT_TRUE(ret == 0);
290 ret = UnPublishService(g_pkgName, testInfo.publishId);
291 EXPECT_TRUE(ret == 0);
292 }
293
294 /**
295 * @tc.name: PublishServiceTest005
296 * @tc.desc: Test passive publish, verify correct parameter with passive mode and "AUTO" medium.
297 * @tc.in: Test module, Test number, Test levels.
298 * @tc.out: Zero
299 * @tc.type: FUNC
300 * @tc.require: The PublishService and UnPublishService operates normally.
301 */
302 HWTEST_F(Disc_Test, PublishServiceTest005, TestSize.Level1)
303 {
304 int ret;
305 PublishInfo testInfo = {
306 .publishId = GetPublishId(),
307 .mode = DISCOVER_MODE_PASSIVE,
308 .medium = AUTO,
309 .freq = LOW,
310 .capability = "dvKit",
311 .capabilityData = (unsigned char *)"capdata2",
312 .dataLen = sizeof("capdata2")
313 };
314
315 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
316 EXPECT_TRUE(ret == 0);
317 ret = UnPublishService(g_pkgName, testInfo.publishId);
318 EXPECT_TRUE(ret == 0);
319
320 testInfo.freq = MID;
321 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
322 EXPECT_TRUE(ret == 0);
323 ret = UnPublishService(g_pkgName, testInfo.publishId);
324 EXPECT_TRUE(ret == 0);
325
326 testInfo.freq = HIGH;
327 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
328 EXPECT_TRUE(ret == 0);
329 ret = UnPublishService(g_pkgName, testInfo.publishId);
330 EXPECT_TRUE(ret == 0);
331
332 testInfo.freq = SUPER_HIGH;
333 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
334 EXPECT_TRUE(ret == 0);
335 ret = UnPublishService(g_pkgName, testInfo.publishId);
336 EXPECT_TRUE(ret == 0);
337 }
338
339 /**
340 * @tc.name: PublishServiceTest006
341 * @tc.desc: Test passive publish, verify correct parameter with passive mode and "COAP" medium.
342 * @tc.in: Test module, Test number, Test levels.
343 * @tc.out: Zero
344 * @tc.type: FUNC
345 * @tc.require: The PublishService and UnPublishService operates normally.
346 */
347 HWTEST_F(Disc_Test, PublishServiceTest006, TestSize.Level1)
348 {
349 int ret;
350 PublishInfo testInfo = {
351 .publishId = GetPublishId(),
352 .mode = DISCOVER_MODE_PASSIVE,
353 .medium = COAP,
354 .freq = LOW,
355 .capability = "dvKit",
356 .capabilityData = (unsigned char *)"capdata2",
357 .dataLen = sizeof("capdata2")
358 };
359
360 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
361 EXPECT_TRUE(ret == 0);
362 ret = UnPublishService(g_pkgName, testInfo.publishId);
363 EXPECT_TRUE(ret == 0);
364
365 testInfo.freq = MID;
366 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
367 EXPECT_TRUE(ret == 0);
368 ret = UnPublishService(g_pkgName, testInfo.publishId);
369 EXPECT_TRUE(ret == 0);
370
371 testInfo.freq = HIGH;
372 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
373 EXPECT_TRUE(ret == 0);
374 ret = UnPublishService(g_pkgName, testInfo.publishId);
375 EXPECT_TRUE(ret == 0);
376
377 testInfo.freq = SUPER_HIGH;
378 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
379 EXPECT_TRUE(ret == 0);
380 ret = UnPublishService(g_pkgName, testInfo.publishId);
381 EXPECT_TRUE(ret == 0);
382 }
383
384 /**
385 * @tc.name: PublishServiceTest007
386 * @tc.desc: Verify wrong parameter.
387 * @tc.in: Test module, Test number, Test levels.
388 * @tc.out: NonZero
389 * @tc.type: FUNC
390 * @tc.require:The PublishService operates normally.
391 */
392 HWTEST_F(Disc_Test, PublishServiceTest007, TestSize.Level1)
393 {
394 int ret;
395 g_pInfo.publishId = GetPublishId();
396 ret = PublishService(g_erroPkgName1, &g_pInfo, &g_publishCb);
397 EXPECT_TRUE(ret != 0);
398 }
399
400 /**
401 * @tc.name: PublishServiceTest008
402 * @tc.desc: Test active publish, verify wrong parameter with active mode and "COAP" medium.
403 * @tc.in: Test module, Test number, Test levels.
404 * @tc.out: NonZero
405 * @tc.type: FUNC
406 * @tc.require:The PublishService operates normally.
407 */
408 HWTEST_F(Disc_Test, PublishServiceTest008, TestSize.Level1)
409 {
410 int ret;
411 PublishInfo testInfo = {
412 .publishId = GetPublishId(),
413 .mode = DISCOVER_MODE_ACTIVE,
414 .medium = COAP,
415 .freq = MID,
416 .capability = "dvKit",
417 .capabilityData = (unsigned char*)"capdata2",
418 .dataLen = sizeof("capdata2")
419 };
420
421 testInfo.medium = (ExchangeMedium)(AUTO - 1);
422 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
423 EXPECT_TRUE(ret != 0);
424 testInfo.medium = COAP;
425
426 testInfo.freq = (ExchangeFreq)(LOW - 1);
427 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
428 EXPECT_TRUE(ret != 0);
429 testInfo.freq = LOW;
430 }
431 /**
432 * @tc.name: PublishServiceTest009
433 * @tc.desc: Test active publish, verify wrong parameter with active mode and "BLE" medium.
434 * @tc.in: Test module, Test number, Test levels.
435 * @tc.out: NonZero
436 * @tc.type: FUNC
437 * @tc.require:The PublishService operates normally.
438 */
439 HWTEST_F(Disc_Test, PublishServiceTest009, TestSize.Level1)
440 {
441 int ret;
442 PublishInfo testInfo = {
443 .publishId = GetPublishId(),
444 .mode = DISCOVER_MODE_ACTIVE,
445 .medium = BLE,
446 .freq = MID,
447 .capability = "dvKit",
448 .capabilityData = (unsigned char*)"capdata2",
449 .dataLen = sizeof("capdata2")
450 };
451
452 testInfo.medium = (ExchangeMedium)(AUTO - 1);
453 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
454 EXPECT_TRUE(ret != 0);
455 testInfo.medium = BLE;
456
457 testInfo.freq = (ExchangeFreq)(LOW - 1);
458 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
459 EXPECT_TRUE(ret != 0);
460 testInfo.freq = LOW;
461 }
462
463 /**
464 * @tc.name: PublishServiceTest010
465 * @tc.desc: Test active publish, verify wrong parameter with active mode and "AUTO" medium.
466 * @tc.in: Test module, Test number, Test levels.
467 * @tc.out: NonZero
468 * @tc.type: FUNC
469 * @tc.require:The PublishService operates normally.
470 */
471 HWTEST_F(Disc_Test, PublishServiceTest010, TestSize.Level1)
472 {
473 int ret;
474 PublishInfo testInfo = {
475 .publishId = GetPublishId(),
476 .mode = DISCOVER_MODE_ACTIVE,
477 .medium = AUTO,
478 .freq = MID,
479 .capability = "dvKit",
480 .capabilityData = (unsigned char*)"capdata2",
481 .dataLen = sizeof("capdata2")
482 };
483
484 testInfo.medium = (ExchangeMedium)(AUTO - 1);
485 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
486 EXPECT_TRUE(ret != 0);
487 testInfo.medium = AUTO;
488
489 testInfo.freq = (ExchangeFreq)(LOW - 1);
490 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
491 EXPECT_TRUE(ret != 0);
492 testInfo.freq = LOW;
493 }
494
495 /**
496 * @tc.name: PublishServiceTest011
497 * @tc.desc: Test passive publish, verify wrong parameter with active mode and "COAP" medium.
498 * @tc.in: Test module, Test number, Test levels.
499 * @tc.out: NonZero
500 * @tc.type: FUNC
501 * @tc.require:The PublishService operates normally.
502 */
503 HWTEST_F(Disc_Test, PublishServiceTest011, TestSize.Level1)
504 {
505 int ret;
506 PublishInfo testInfo = {
507 .publishId = GetPublishId(),
508 .mode = DISCOVER_MODE_PASSIVE,
509 .medium = COAP,
510 .freq = MID,
511 .capability = "dvKit",
512 .capabilityData = (unsigned char*)"capdata2",
513 .dataLen = sizeof("capdata2")
514 };
515
516 testInfo.medium = (ExchangeMedium)(AUTO - 1);
517 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
518 EXPECT_TRUE(ret != 0);
519 testInfo.medium = COAP;
520
521 testInfo.freq = (ExchangeFreq)(LOW - 1);
522 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
523 EXPECT_TRUE(ret != 0);
524 testInfo.freq = LOW;
525 }
526
527 /**
528 * @tc.name: PublishServiceTest012
529 * @tc.desc: Test passive publish, verify wrong parameter with active mode and "AUTO" medium.
530 * @tc.in: Test module, Test number, Test levels.
531 * @tc.out: NonZero
532 * @tc.type: FUNC
533 * @tc.require:The PublishService operates normally.
534 */
535 HWTEST_F(Disc_Test, PublishServiceTest012, TestSize.Level1)
536 {
537 int ret;
538 PublishInfo testInfo = {
539 .publishId = GetPublishId(),
540 .mode = DISCOVER_MODE_PASSIVE,
541 .medium = AUTO,
542 .freq = MID,
543 .capability = "dvKit",
544 .capabilityData = (unsigned char*)"capdata2",
545 .dataLen = sizeof("capdata2")
546 };
547
548 testInfo.medium = (ExchangeMedium)(AUTO - 1);
549 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
550 EXPECT_TRUE(ret != 0);
551 testInfo.medium = AUTO;
552
553 testInfo.freq = (ExchangeFreq)(LOW - 1);
554 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
555 EXPECT_TRUE(ret != 0);
556 testInfo.freq = LOW;
557 }
558
559 /**
560 * @tc.name: PublishServiceTest013
561 * @tc.desc: Test active publish, verify correct parameter with passive mode,"COAP" medium and diff capability.
562 * @tc.in: Test module, Test number, Test levels.
563 * @tc.out: Zero
564 * @tc.type: FUNC
565 * @tc.require: The PublishService and UnPublishService operates normally.
566 */
567 HWTEST_F(Disc_Test, PublishServiceTest013, TestSize.Level1)
568 {
569 int ret;
570 PublishInfo testInfo = {
571 .publishId = GetPublishId(),
572 .mode = DISCOVER_MODE_PASSIVE,
573 .medium = COAP,
574 .freq = LOW,
575 .capability = "dvKit",
576 .capabilityData = (unsigned char *)"capdata2",
577 .dataLen = sizeof("capdata2")
578 };
579
580 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
581 EXPECT_TRUE(ret == 0);
582 ret = UnPublishService(g_pkgName, testInfo.publishId);
583
584 testInfo.capability = "hicall";
585 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
586 EXPECT_TRUE(ret == 0);
587 ret = UnPublishService(g_pkgName, testInfo.publishId);
588
589 testInfo.capability = "profile";
590 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
591 EXPECT_TRUE(ret == 0);
592 ret = UnPublishService(g_pkgName, testInfo.publishId);
593
594 testInfo.capability = "homevisionPic";
595 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
596 EXPECT_TRUE(ret == 0);
597 ret = UnPublishService(g_pkgName, testInfo.publishId);
598
599 testInfo.capability = "castPlus";
600 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
601 EXPECT_TRUE(ret == 0);
602 ret = UnPublishService(g_pkgName, testInfo.publishId);
603
604 testInfo.capability = "aaCapability";
605 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
606 EXPECT_TRUE(ret == 0);
607 ret = UnPublishService(g_pkgName, testInfo.publishId);
608
609 testInfo.capability = "ddmpCapability";
610 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
611 EXPECT_TRUE(ret == 0);
612 ret = UnPublishService(g_pkgName, testInfo.publishId);
613
614 testInfo.capability = "osdCapability";
615 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
616 EXPECT_TRUE(ret == 0);
617 ret = UnPublishService(g_pkgName, testInfo.publishId);
618 }
619
620 /**
621 * @tc.name: PublishServiceTest014
622 * @tc.desc: Test active publish, verify correct parameter with active mode,"COAP" medium and diff capability.
623 * @tc.in: Test module, Test number, Test levels.
624 * @tc.out: Zero
625 * @tc.type: FUNC
626 * @tc.require: The PublishService and UnPublishService operates normally.
627 */
628 HWTEST_F(Disc_Test, PublishServiceTest014, TestSize.Level1)
629 {
630 int ret;
631 PublishInfo testInfo = {
632 .publishId = GetPublishId(),
633 .mode = DISCOVER_MODE_ACTIVE,
634 .medium = COAP,
635 .freq = LOW,
636 .capability = "dvKit",
637 .capabilityData = (unsigned char *)"capdata2",
638 .dataLen = sizeof("capdata2")
639 };
640
641 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
642 EXPECT_TRUE(ret == 0);
643 ret = UnPublishService(g_pkgName, testInfo.publishId);
644
645 testInfo.capability = "hicall";
646 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
647 EXPECT_TRUE(ret == 0);
648 ret = UnPublishService(g_pkgName, testInfo.publishId);
649
650 testInfo.capability = "profile";
651 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
652 EXPECT_TRUE(ret == 0);
653 ret = UnPublishService(g_pkgName, testInfo.publishId);
654
655 testInfo.capability = "homevisionPic";
656 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
657 EXPECT_TRUE(ret == 0);
658 ret = UnPublishService(g_pkgName, testInfo.publishId);
659
660 testInfo.capability = "castPlus";
661 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
662 EXPECT_TRUE(ret == 0);
663 ret = UnPublishService(g_pkgName, testInfo.publishId);
664
665 testInfo.capability = "aaCapability";
666 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
667 EXPECT_TRUE(ret == 0);
668 ret = UnPublishService(g_pkgName, testInfo.publishId);
669
670 testInfo.capability = "ddmpCapability";
671 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
672 EXPECT_TRUE(ret == 0);
673 ret = UnPublishService(g_pkgName, testInfo.publishId);
674
675 testInfo.capability = "osdCapability";
676 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
677 EXPECT_TRUE(ret == 0);
678 ret = UnPublishService(g_pkgName, testInfo.publishId);
679 }
680
681 /**
682 * @tc.name: PublishServiceTest015
683 * @tc.desc: Test active publish, verify correct parameter with passive mode,"AUTO" medium and diff capability.
684 * @tc.in: Test module, Test number, Test levels.
685 * @tc.out: Zero
686 * @tc.type: FUNC
687 * @tc.require: The PublishService and UnPublishService operates normally.
688 */
689 HWTEST_F(Disc_Test, PublishServiceTest015, TestSize.Level1)
690 {
691 int ret;
692 PublishInfo testInfo = {
693 .publishId = GetPublishId(),
694 .mode = DISCOVER_MODE_PASSIVE,
695 .medium = AUTO,
696 .freq = LOW,
697 .capability = "dvKit",
698 .capabilityData = (unsigned char *)"capdata2",
699 .dataLen = sizeof("capdata2")
700 };
701
702 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
703 EXPECT_TRUE(ret == 0);
704 ret = UnPublishService(g_pkgName, testInfo.publishId);
705
706 testInfo.capability = "hicall";
707 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
708 EXPECT_TRUE(ret == 0);
709 ret = UnPublishService(g_pkgName, testInfo.publishId);
710
711 testInfo.capability = "profile";
712 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
713 EXPECT_TRUE(ret == 0);
714 ret = UnPublishService(g_pkgName, testInfo.publishId);
715
716 testInfo.capability = "homevisionPic";
717 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
718 EXPECT_TRUE(ret == 0);
719 ret = UnPublishService(g_pkgName, testInfo.publishId);
720
721 testInfo.capability = "castPlus";
722 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
723 EXPECT_TRUE(ret == 0);
724 ret = UnPublishService(g_pkgName, testInfo.publishId);
725
726 testInfo.capability = "aaCapability";
727 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
728 EXPECT_TRUE(ret == 0);
729 ret = UnPublishService(g_pkgName, testInfo.publishId);
730
731 testInfo.capability = "ddmpCapability";
732 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
733 EXPECT_TRUE(ret == 0);
734 ret = UnPublishService(g_pkgName, testInfo.publishId);
735
736 testInfo.capability = "osdCapability";
737 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
738 EXPECT_TRUE(ret == 0);
739 ret = UnPublishService(g_pkgName, testInfo.publishId);
740 }
741
742 /**
743 * @tc.name: PublishServiceTest016
744 * @tc.desc: Test active publish, verify correct parameter with active mode,"AUTO" medium and diff capability.
745 * @tc.in: Test module, Test number, Test levels.
746 * @tc.out: Zero
747 * @tc.type: FUNC
748 * @tc.require: The PublishService and UnPublishService operates normally.
749 */
750 HWTEST_F(Disc_Test, PublishServiceTest016, TestSize.Level1)
751 {
752 int ret;
753 PublishInfo testInfo = {
754 .publishId = GetPublishId(),
755 .mode = DISCOVER_MODE_ACTIVE,
756 .medium = AUTO,
757 .freq = LOW,
758 .capability = "dvKit",
759 .capabilityData = (unsigned char *)"capdata2",
760 .dataLen = sizeof("capdata2")
761 };
762
763 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
764 EXPECT_TRUE(ret == 0);
765 ret = UnPublishService(g_pkgName, testInfo.publishId);
766
767 testInfo.capability = "hicall";
768 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
769 EXPECT_TRUE(ret == 0);
770 ret = UnPublishService(g_pkgName, testInfo.publishId);
771
772 testInfo.capability = "profile";
773 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
774 EXPECT_TRUE(ret == 0);
775 ret = UnPublishService(g_pkgName, testInfo.publishId);
776
777 testInfo.capability = "homevisionPic";
778 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
779 EXPECT_TRUE(ret == 0);
780 ret = UnPublishService(g_pkgName, testInfo.publishId);
781
782 testInfo.capability = "castPlus";
783 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
784 EXPECT_TRUE(ret == 0);
785 ret = UnPublishService(g_pkgName, testInfo.publishId);
786
787 testInfo.capability = "aaCapability";
788 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
789 EXPECT_TRUE(ret == 0);
790 ret = UnPublishService(g_pkgName, testInfo.publishId);
791
792 testInfo.capability = "ddmpCapability";
793 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
794 EXPECT_TRUE(ret == 0);
795 ret = UnPublishService(g_pkgName, testInfo.publishId);
796
797 testInfo.capability = "osdCapability";
798 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
799 EXPECT_TRUE(ret == 0);
800 ret = UnPublishService(g_pkgName, testInfo.publishId);
801 }
802
803 /**
804 * @tc.name: StartDiscoveryTest001
805 * @tc.desc: Verify statrtdiscovery wrong parameter.
806 * @tc.type: FUNC
807 * @tc.require:
808 */
809 HWTEST_F(Disc_Test, StartDiscoveryTest001, TestSize.Level0)
810 {
811 int ret;
812 SubscribeInfo testInfo = {
813 .subscribeId = GetSubscribeId(),
814 .mode = DISCOVER_MODE_ACTIVE,
815 .medium = COAP,
816 .freq = MID,
817 .isSameAccount = true,
818 .isWakeRemote = false,
819 .capability = "dvKit",
820 .capabilityData = (unsigned char *)"capdata3",
821 .dataLen = sizeof("capdata3")
822 };
823
824 ret = StartDiscovery(NULL, &testInfo, &g_subscribeCb);
825 EXPECT_TRUE(ret != 0);
826
827 ret = StartDiscovery(g_pkgName, NULL, &g_subscribeCb);
828 EXPECT_TRUE(ret != 0);
829
830 ret = StartDiscovery(g_pkgName, &testInfo, NULL);
831 EXPECT_TRUE(ret != 0);
832
833 testInfo.medium = (ExchangeMedium)(COAP + 1);
834 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
835 EXPECT_TRUE(ret != 0);
836 testInfo.medium = COAP;
837
838 testInfo.mode = (DiscoverMode)(DISCOVER_MODE_ACTIVE + 1);
839 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
840 EXPECT_TRUE(ret != 0);
841 testInfo.mode = DISCOVER_MODE_ACTIVE;
842
843 testInfo.freq = (ExchangeFreq)(SUPER_HIGH + 1);
844 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
845 EXPECT_TRUE(ret != 0);
846 testInfo.freq = LOW;
847
848 testInfo.capabilityData = NULL;
849 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
850 EXPECT_TRUE(ret != 0);
851 testInfo.capabilityData = (unsigned char *)"capdata1";
852
853 testInfo.dataLen = ERRO_CAPDATA_LEN;
854 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
855 EXPECT_TRUE(ret != 0);
856 testInfo.dataLen = sizeof("capdata1");
857 }
858
859 /**
860 * @tc.name: StartDiscoveryTest002
861 * @tc.desc: Verify the StartDiscovery error parameter
862 * @tc.type: FUNC
863 * @tc.require:
864 */
865 HWTEST_F(Disc_Test, StartDiscoveryTest002, TestSize.Level0)
866 {
867 int ret;
868 g_sInfo.subscribeId = GetSubscribeId();
869 ret = StartDiscovery(g_pkgName, &g_sInfo, &g_subscribeCb);
870 EXPECT_TRUE(ret == 0);
871 ret = StopDiscovery(g_pkgName, g_sInfo.subscribeId);
872
873 g_sInfo1.subscribeId = GetSubscribeId();
874 ret = StartDiscovery(g_pkgName, &g_sInfo1, &g_subscribeCb);
875 EXPECT_TRUE(ret == 0);
876 ret = StopDiscovery(g_pkgName, g_sInfo1.subscribeId);
877
878 g_sInfo1.subscribeId = GetSubscribeId();
879 ret = StartDiscovery(g_pkgName_1, &g_sInfo1, &g_subscribeCb);
880 EXPECT_TRUE(ret == 0);
881 ret = StopDiscovery(g_pkgName, g_sInfo1.subscribeId);
882 }
883
884 /**
885 * @tc.name: StartDiscoveryTest003
886 * @tc.desc: Verify startdiscovery same parameter again
887 * @tc.type: FUNC
888 * @tc.require:
889 */
890 HWTEST_F(Disc_Test, StartDiscoveryTest003, TestSize.Level0)
891 {
892 int ret;
893
894 g_sInfo.subscribeId = GetSubscribeId();
895 ret = StartDiscovery(g_pkgName, &g_sInfo, &g_subscribeCb);
896 EXPECT_TRUE(ret == 0);
897 ret = StopDiscovery(g_pkgName, g_sInfo.subscribeId);
898 }
899
900 /**
901 * @tc.name: StartDiscoveryTest004
902 * @tc.desc: Test active discover, verify correct parameter with active mode and "AUTO" medium.
903 * @tc.in: Test module, Test number, Test levels.
904 * @tc.out: Zero
905 * @tc.type: FUNC
906 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
907 */
908 HWTEST_F(Disc_Test, StartDiscoveryTest004, TestSize.Level1)
909 {
910 int ret;
911 SubscribeInfo testInfo = {
912 .subscribeId = GetSubscribeId(),
913 .mode = DISCOVER_MODE_ACTIVE,
914 .medium = AUTO,
915 .freq = LOW,
916 .isSameAccount = true,
917 .isWakeRemote = false,
918 .capability = "dvKit",
919 .capabilityData = (unsigned char *)"capdata3",
920 .dataLen = sizeof("capdata3")
921 };
922
923 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
924 EXPECT_TRUE(ret == 0);
925 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
926 EXPECT_TRUE(ret == 0);
927
928 testInfo.freq = MID;
929 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
930 EXPECT_TRUE(ret == 0);
931 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
932 EXPECT_TRUE(ret == 0);
933
934 testInfo.freq = HIGH;
935 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
936 EXPECT_TRUE(ret == 0);
937 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
938 EXPECT_TRUE(ret == 0);
939
940 testInfo.freq = SUPER_HIGH;
941 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
942 EXPECT_TRUE(ret == 0);
943 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
944 EXPECT_TRUE(ret == 0);
945 }
946
947 /**
948 * @tc.name: StartDiscoveryTest005
949 * @tc.desc: Test passive discover verify correct parameter with passive mode and "COAP" medium.
950 * @tc.in: Test module, Test number, Test levels.
951 * @tc.out: Zero
952 * @tc.type: FUNC
953 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
954 */
955 HWTEST_F(Disc_Test, StartDiscoveryTest005, TestSize.Level1)
956 {
957 int ret;
958 SubscribeInfo testInfo = {
959 .subscribeId = GetSubscribeId(),
960 .mode = DISCOVER_MODE_PASSIVE,
961 .medium = COAP,
962 .freq = LOW,
963 .isSameAccount = true,
964 .isWakeRemote = false,
965 .capability = "dvKit",
966 .capabilityData = (unsigned char *)"capdata3",
967 .dataLen = sizeof("capdata3")
968 };
969
970 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
971 EXPECT_TRUE(ret == 0);
972 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
973 EXPECT_TRUE(ret == 0);
974
975 testInfo.freq = MID;
976 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
977 EXPECT_TRUE(ret == 0);
978 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
979 EXPECT_TRUE(ret == 0);
980
981 testInfo.freq = HIGH;
982 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
983 EXPECT_TRUE(ret == 0);
984 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
985 EXPECT_TRUE(ret == 0);
986
987 testInfo.freq = SUPER_HIGH;
988 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
989 EXPECT_TRUE(ret == 0);
990 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
991 EXPECT_TRUE(ret == 0);
992 }
993
994 /**
995 * @tc.name: StartDiscoveryTest006
996 * @tc.desc: Test passive discover, verify correct parameter with passive mode and "AUTO" medium.
997 * @tc.in: Test module, Test number, Test levels.
998 * @tc.out: Zero
999 * @tc.type: FUNC
1000 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
1001 */
1002 HWTEST_F(Disc_Test, StartDiscoveryTest006, TestSize.Level1)
1003 {
1004 int ret;
1005 SubscribeInfo testInfo = {
1006 .subscribeId = GetSubscribeId(),
1007 .mode = DISCOVER_MODE_PASSIVE,
1008 .medium = AUTO,
1009 .freq = LOW,
1010 .isSameAccount = true,
1011 .isWakeRemote = false,
1012 .capability = "dvKit",
1013 .capabilityData = (unsigned char *)"capdata3",
1014 .dataLen = sizeof("capdata3")
1015 };
1016
1017 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1018 EXPECT_TRUE(ret == 0);
1019 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1020 EXPECT_TRUE(ret == 0);
1021
1022 testInfo.freq = MID;
1023 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1024 EXPECT_TRUE(ret == 0);
1025 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1026 EXPECT_TRUE(ret == 0);
1027
1028 testInfo.freq = HIGH;
1029 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1030 EXPECT_TRUE(ret == 0);
1031 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1032 EXPECT_TRUE(ret == 0);
1033
1034 testInfo.freq = SUPER_HIGH;
1035 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1036 EXPECT_TRUE(ret == 0);
1037 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1038 EXPECT_TRUE(ret == 0);
1039 }
1040
1041 /**
1042 * @tc.name: StartDiscoveryTest007
1043 * @tc.desc: Test passive discover verify correct parameter with passive mode and "COAP" medium.
1044 * @tc.in: Test module, Test number, Test levels.
1045 * @tc.out: Zero
1046 * @tc.type: FUNC
1047 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
1048 */
1049 HWTEST_F(Disc_Test, StartDiscoveryTest007, TestSize.Level1)
1050 {
1051 int ret;
1052 SubscribeInfo testInfo = {
1053 .subscribeId = GetSubscribeId(),
1054 .mode = DISCOVER_MODE_PASSIVE,
1055 .medium = COAP,
1056 .freq = LOW,
1057 .isSameAccount = true,
1058 .isWakeRemote = false,
1059 .capability = "dvKit",
1060 .capabilityData = (unsigned char *)"capdata3",
1061 .dataLen = sizeof("capdata3")
1062 };
1063
1064 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1065 EXPECT_TRUE(ret == 0);
1066 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1067 EXPECT_TRUE(ret == 0);
1068
1069 testInfo.freq = MID;
1070 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1071 EXPECT_TRUE(ret == 0);
1072 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1073 EXPECT_TRUE(ret == 0);
1074
1075 testInfo.freq = HIGH;
1076 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1077 EXPECT_TRUE(ret == 0);
1078 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1079 EXPECT_TRUE(ret == 0);
1080
1081 testInfo.freq = SUPER_HIGH;
1082 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1083 EXPECT_TRUE(ret == 0);
1084 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1085 EXPECT_TRUE(ret == 0);
1086 }
1087
1088 /**
1089 * @tc.name: StartDiscoveryTest008
1090 * @tc.desc: Test passive discover verify correct parameter with active mode and "COAP" medium.
1091 * @tc.in: Test module, Test number, Test levels.
1092 * @tc.out: Zero
1093 * @tc.type: FUNC
1094 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
1095 */
1096 HWTEST_F(Disc_Test, StartDiscoveryTest008, TestSize.Level1)
1097 {
1098 int ret;
1099 SubscribeInfo testInfo = {
1100 .subscribeId = GetSubscribeId(),
1101 .mode = DISCOVER_MODE_ACTIVE,
1102 .medium = COAP,
1103 .freq = LOW,
1104 .isSameAccount = true,
1105 .isWakeRemote = false,
1106 .capability = "dvKit",
1107 .capabilityData = (unsigned char *)"capdata3",
1108 .dataLen = sizeof("capdata3")
1109 };
1110
1111 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1112 EXPECT_TRUE(ret == 0);
1113 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1114 EXPECT_TRUE(ret == 0);
1115
1116 testInfo.freq = MID;
1117 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1118 EXPECT_TRUE(ret == 0);
1119 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1120 EXPECT_TRUE(ret == 0);
1121
1122 testInfo.freq = HIGH;
1123 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1124 EXPECT_TRUE(ret == 0);
1125 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1126 EXPECT_TRUE(ret == 0);
1127
1128 testInfo.freq = SUPER_HIGH;
1129 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1130 EXPECT_TRUE(ret == 0);
1131 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1132 EXPECT_TRUE(ret == 0);
1133 }
1134
1135 /**
1136 * @tc.name: StartDiscoveryTest009
1137 * @tc.desc: Test passive discover, verify correct parameter with passive mode and "AUTO" medium.
1138 * @tc.in: Test module, Test number, Test levels.
1139 * @tc.out: Zero
1140 * @tc.type: FUNC
1141 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
1142 */
1143 HWTEST_F(Disc_Test, StartDiscoveryTest009, TestSize.Level1)
1144 {
1145 int ret;
1146 SubscribeInfo testInfo = {
1147 .subscribeId = GetSubscribeId(),
1148 .mode = DISCOVER_MODE_PASSIVE,
1149 .medium = AUTO,
1150 .freq = LOW,
1151 .isSameAccount = true,
1152 .isWakeRemote = false,
1153 .capability = "dvKit",
1154 .capabilityData = (unsigned char *)"capdata3",
1155 .dataLen = sizeof("capdata3")
1156 };
1157
1158 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1159 EXPECT_TRUE(ret == 0);
1160 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1161 EXPECT_TRUE(ret == 0);
1162
1163 testInfo.freq = MID;
1164 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1165 EXPECT_TRUE(ret == 0);
1166 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1167 EXPECT_TRUE(ret == 0);
1168
1169 testInfo.freq = HIGH;
1170 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1171 EXPECT_TRUE(ret == 0);
1172 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1173 EXPECT_TRUE(ret == 0);
1174
1175 testInfo.freq = SUPER_HIGH;
1176 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1177 EXPECT_TRUE(ret == 0);
1178 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1179 EXPECT_TRUE(ret == 0);
1180 }
1181
1182 /**
1183 * @tc.name: StartDiscoveryTest010
1184 * @tc.desc: Test extern module passive discoveruse wrong Medium and Freq Under the COAP.
1185 * @tc.in: Test module, Test number, Test levels.
1186 * @tc.out: Zero
1187 * @tc.type: FUNC
1188 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
1189 */
1190 HWTEST_F(Disc_Test, StartDiscoveryTest010, TestSize.Level0)
1191 {
1192 int ret;
1193 SubscribeInfo testInfo = {
1194 .subscribeId = GetSubscribeId(),
1195 .mode = DISCOVER_MODE_PASSIVE,
1196 .medium = COAP,
1197 .freq = LOW,
1198 .isSameAccount = true,
1199 .isWakeRemote = false,
1200 .capability = "dvKit",
1201 .capabilityData = (unsigned char *)"capdata3",
1202 .dataLen = sizeof("capdata3")
1203 };
1204
1205 testInfo.medium = (ExchangeMedium)(AUTO - 1);
1206 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1207 EXPECT_TRUE(ret != 0);
1208 testInfo.medium = COAP;
1209
1210 testInfo.freq = (ExchangeFreq)(LOW - 1);
1211 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1212 EXPECT_TRUE(ret != 0);
1213 testInfo.freq = LOW;
1214 }
1215
1216 /**
1217 * @tc.name: StartDiscoveryTest011
1218 * @tc.desc: Test extern module passive discoveruse wrong Medium and Freq Under the AUTO.
1219 * @tc.in: Test module, Test number, Test levels.
1220 * @tc.out: Zero
1221 * @tc.type: FUNC
1222 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
1223 */
1224 HWTEST_F(Disc_Test, StartDiscoveryTest011, TestSize.Level0)
1225 {
1226 int ret;
1227 SubscribeInfo testInfo = {
1228 .subscribeId = GetSubscribeId(),
1229 .mode = DISCOVER_MODE_PASSIVE,
1230 .medium = AUTO,
1231 .freq = LOW,
1232 .isSameAccount = true,
1233 .isWakeRemote = false,
1234 .capability = "dvKit",
1235 .capabilityData = (unsigned char *)"capdata3",
1236 .dataLen = sizeof("capdata3")
1237 };
1238
1239 testInfo.medium = (ExchangeMedium)(AUTO - 1);
1240 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1241 EXPECT_TRUE(ret != 0);
1242 testInfo.medium = COAP;
1243
1244 testInfo.freq = (ExchangeFreq)(LOW - 1);
1245 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1246 EXPECT_TRUE(ret != 0);
1247 testInfo.freq = LOW;
1248 }
1249
1250 /**
1251 * @tc.name: StartDiscoveryTest012
1252 * @tc.desc: Test active publish, verify correct parameter with passive mode,"COAP" medium and diff capability.
1253 * @tc.in: Test module, Test number, Test levels.
1254 * @tc.out: Zero
1255 * @tc.type: FUNC
1256 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
1257 */
1258 HWTEST_F(Disc_Test, StartDiscoveryTest012, TestSize.Level1)
1259 {
1260 int ret;
1261 SubscribeInfo testInfo = {
1262 .subscribeId = GetSubscribeId(),
1263 .mode = DISCOVER_MODE_PASSIVE,
1264 .medium = COAP,
1265 .freq = LOW,
1266 .isSameAccount = true,
1267 .isWakeRemote = false,
1268 .capability = "dvKit",
1269 .capabilityData = (unsigned char *)"capdata3",
1270 .dataLen = sizeof("capdata3")
1271 };
1272
1273 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1274 EXPECT_TRUE(ret == 0);
1275 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1276
1277 testInfo.capability = "hicall";
1278 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1279 EXPECT_TRUE(ret == 0);
1280 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1281
1282 testInfo.capability = "profile";
1283 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1284 EXPECT_TRUE(ret == 0);
1285 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1286
1287 testInfo.capability = "homevisionPic";
1288 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1289 EXPECT_TRUE(ret == 0);
1290 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1291
1292 testInfo.capability = "castPlus";
1293 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1294 EXPECT_TRUE(ret == 0);
1295 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1296
1297 testInfo.capability = "aaCapability";
1298 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1299 EXPECT_TRUE(ret == 0);
1300 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1301
1302 testInfo.capability = "ddmpCapability";
1303 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1304 EXPECT_TRUE(ret == 0);
1305 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1306
1307 testInfo.capability = "osdCapability";
1308 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1309 EXPECT_TRUE(ret == 0);
1310 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1311 }
1312
1313 /**
1314 * @tc.name: StartDiscoveryTest013
1315 * @tc.desc: Test active publish, verify correct parameter with active mode,"COAP" medium and diff capability.
1316 * @tc.in: Test module, Test number, Test levels.
1317 * @tc.out: Zero
1318 * @tc.type: FUNC
1319 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
1320 */
1321 HWTEST_F(Disc_Test, StartDiscoveryTest013, TestSize.Level1)
1322 {
1323 int ret;
1324 SubscribeInfo testInfo = {
1325 .subscribeId = GetSubscribeId(),
1326 .mode = DISCOVER_MODE_ACTIVE,
1327 .medium = COAP,
1328 .freq = LOW,
1329 .isSameAccount = true,
1330 .isWakeRemote = false,
1331 .capability = "dvKit",
1332 .capabilityData = (unsigned char *)"capdata3",
1333 .dataLen = sizeof("capdata3")
1334 };
1335
1336 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1337 EXPECT_TRUE(ret == 0);
1338 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1339
1340 testInfo.capability = "hicall";
1341 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1342 EXPECT_TRUE(ret == 0);
1343 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1344
1345 testInfo.capability = "profile";
1346 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1347 EXPECT_TRUE(ret == 0);
1348 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1349
1350 testInfo.capability = "homevisionPic";
1351 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1352 EXPECT_TRUE(ret == 0);
1353 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1354
1355 testInfo.capability = "castPlus";
1356 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1357 EXPECT_TRUE(ret == 0);
1358 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1359
1360 testInfo.capability = "aaCapability";
1361 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1362 EXPECT_TRUE(ret == 0);
1363 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1364
1365 testInfo.capability = "ddmpCapability";
1366 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1367 EXPECT_TRUE(ret == 0);
1368 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1369
1370 testInfo.capability = "osdCapability";
1371 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1372 EXPECT_TRUE(ret == 0);
1373 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1374 }
1375
1376 /**
1377 * @tc.name: StartDiscoveryTest014
1378 * @tc.desc: Test active publish, verify correct parameter with passive mode,"AUTO" medium and diff capability.
1379 * @tc.in: Test module, Test number, Test levels.
1380 * @tc.out: Zero
1381 * @tc.type: FUNC
1382 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
1383 */
1384 HWTEST_F(Disc_Test, StartDiscoveryTest014, TestSize.Level1)
1385 {
1386 int ret;
1387 SubscribeInfo testInfo = {
1388 .subscribeId = GetSubscribeId(),
1389 .mode = DISCOVER_MODE_PASSIVE,
1390 .medium = AUTO,
1391 .freq = LOW,
1392 .isSameAccount = true,
1393 .isWakeRemote = false,
1394 .capability = "dvKit",
1395 .capabilityData = (unsigned char *)"capdata3",
1396 .dataLen = sizeof("capdata3")
1397 };
1398
1399 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1400 EXPECT_TRUE(ret == 0);
1401 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1402
1403 testInfo.capability = "hicall";
1404 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1405 EXPECT_TRUE(ret == 0);
1406 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1407
1408 testInfo.capability = "profile";
1409 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1410 EXPECT_TRUE(ret == 0);
1411 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1412
1413 testInfo.capability = "homevisionPic";
1414 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1415 EXPECT_TRUE(ret == 0);
1416 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1417
1418 testInfo.capability = "castPlus";
1419 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1420 EXPECT_TRUE(ret == 0);
1421 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1422
1423 testInfo.capability = "aaCapability";
1424 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1425 EXPECT_TRUE(ret == 0);
1426 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1427
1428 testInfo.capability = "ddmpCapability";
1429 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1430 EXPECT_TRUE(ret == 0);
1431 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1432
1433 testInfo.capability = "osdCapability";
1434 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1435 EXPECT_TRUE(ret == 0);
1436 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1437 }
1438
1439 /**
1440 * @tc.name: StartDiscoveryTest015
1441 * @tc.desc: Test active publish, verify correct parameter with active mode,"AUTO" medium and diff capability.
1442 * @tc.in: Test module, Test number, Test levels.
1443 * @tc.out: Zero
1444 * @tc.type: FUNC
1445 * @tc.require: The StartDiscovery and StopDiscovery operates normally.
1446 */
1447 HWTEST_F(Disc_Test, StartDiscoveryTest015, TestSize.Level1)
1448 {
1449 int ret;
1450 SubscribeInfo testInfo = {
1451 .subscribeId = GetSubscribeId(),
1452 .mode = DISCOVER_MODE_ACTIVE,
1453 .medium = AUTO,
1454 .freq = LOW,
1455 .isSameAccount = true,
1456 .isWakeRemote = false,
1457 .capability = "dvKit",
1458 .capabilityData = (unsigned char *)"capdata3",
1459 .dataLen = sizeof("capdata3")
1460 };
1461
1462 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1463 EXPECT_TRUE(ret == 0);
1464 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1465
1466 testInfo.capability = "hicall";
1467 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1468 EXPECT_TRUE(ret == 0);
1469 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1470
1471 testInfo.capability = "profile";
1472 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1473 EXPECT_TRUE(ret == 0);
1474 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1475
1476 testInfo.capability = "homevisionPic";
1477 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1478 EXPECT_TRUE(ret == 0);
1479 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1480
1481 testInfo.capability = "castPlus";
1482 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1483 EXPECT_TRUE(ret == 0);
1484 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1485
1486 testInfo.capability = "aaCapability";
1487 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1488 EXPECT_TRUE(ret == 0);
1489 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1490
1491 testInfo.capability = "ddmpCapability";
1492 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1493 EXPECT_TRUE(ret == 0);
1494 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1495
1496 testInfo.capability = "osdCapability";
1497 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
1498 EXPECT_TRUE(ret == 0);
1499 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
1500 }
1501
1502 /**
1503 * @tc.name: UnPublishServiceTest001
1504 * @tc.desc: Verify unpublishservice wrong parameter.
1505 * @tc.type: FUNC
1506 * @tc.require:
1507 */
1508 HWTEST_F(Disc_Test, UnPublishServiceTest001, TestSize.Level0)
1509 {
1510 int ret;
1511 int tmpId = GetPublishId();
1512
1513 g_pInfo.publishId = tmpId;
1514 PublishService(g_pkgName, &g_pInfo, &g_publishCb);
1515 ret = UnPublishService(NULL, tmpId);
1516 EXPECT_TRUE(ret != 0);
1517 ret = UnPublishService(g_erroPkgName, tmpId);
1518 EXPECT_TRUE(ret != 0);
1519 }
1520
1521 /**
1522 * @tc.name: UnPublishServiceTest002
1523 * @tc.desc: Verify publishservice and unpublishservice normal case.
1524 * @tc.type: FUNC
1525 * @tc.require:
1526 */
1527 HWTEST_F(Disc_Test, UnPublishServiceTest002, TestSize.Level0)
1528 {
1529 int ret;
1530 int tmpId1 = GetPublishId();
1531 int tmpId2 = GetPublishId();
1532
1533 g_pInfo.publishId = tmpId1;
1534 PublishService(g_pkgName, &g_pInfo, &g_publishCb);
1535 g_pInfo1.publishId = tmpId2;
1536 PublishService(g_pkgName, &g_pInfo1, &g_publishCb);
1537 ret = UnPublishService(g_pkgName, tmpId1);
1538 EXPECT_TRUE(ret == 0);
1539 ret = UnPublishService(g_pkgName, tmpId2);
1540 EXPECT_TRUE(ret == 0);
1541 }
1542
1543 /**
1544 * @tc.name: UnPublishServiceTest003
1545 * @tc.desc: Verify publishservice and unpublishservice same parameter again.
1546 * @tc.type: FUNC
1547 * @tc.require:
1548 */
1549 HWTEST_F(Disc_Test, UnPublishServiceTest003, TestSize.Level0)
1550 {
1551 int ret;
1552 int tmpId = GetPublishId();
1553
1554 g_pInfo.publishId = tmpId;
1555 PublishService(g_pkgName, &g_pInfo, &g_publishCb);
1556 ret = UnPublishService(g_pkgName, tmpId);
1557 EXPECT_TRUE(ret == 0);
1558 }
1559
1560 /**
1561 * @tc.name: UnPublishServiceTest004
1562 * @tc.desc: Extern module stop publish, use the normal parameter and different frequencies under active COAP.
1563 * @tc.in: Test module, Test number, Test levels.
1564 * @tc.out: Zero
1565 * @tc.type: FUNC
1566 * @tc.require: The UnPublishService operates normally.
1567 */
1568 HWTEST_F(Disc_Test, UnPublishServiceTest004, TestSize.Level0)
1569 {
1570 int ret;
1571 PublishInfo testInfo = {
1572 .publishId = GetPublishId(),
1573 .mode = DISCOVER_MODE_ACTIVE,
1574 .medium = COAP,
1575 .freq = LOW,
1576 .capability = "dvKit",
1577 .capabilityData = (unsigned char *)"capdata2",
1578 .dataLen = sizeof("capdata2")
1579 };
1580
1581 PublishService(g_pkgName, &testInfo, &g_publishCb);
1582 ret = UnPublishService(g_pkgName, testInfo.publishId);
1583 EXPECT_TRUE(ret == 0);
1584
1585 testInfo.freq = MID;
1586 PublishService(g_pkgName, &testInfo, &g_publishCb);
1587 ret = UnPublishService(g_pkgName, testInfo.publishId);
1588 EXPECT_TRUE(ret == 0);
1589
1590 testInfo.freq = HIGH;
1591 PublishService(g_pkgName, &testInfo, &g_publishCb);
1592 ret = UnPublishService(g_pkgName, testInfo.publishId);
1593 EXPECT_TRUE(ret == 0);
1594
1595 testInfo.freq = SUPER_HIGH;
1596 PublishService(g_pkgName, &testInfo, &g_publishCb);
1597 ret = UnPublishService(g_pkgName, testInfo.publishId);
1598 EXPECT_TRUE(ret == 0);
1599 }
1600
1601 /**
1602 * @tc.name: UnPublishServiceTest005
1603 * @tc.desc: Extern module stop publish, use the normal parameter and different frequencies under passive COAP.
1604 * @tc.in: Test module, Test number, Test levels.
1605 * @tc.out: Zero
1606 * @tc.type: FUNC
1607 * @tc.require: The UnPublishService operates normally.
1608 */
1609 HWTEST_F(Disc_Test, UnPublishServiceTest005, TestSize.Level0)
1610 {
1611 int ret;
1612 PublishInfo testInfo = {
1613 .publishId = GetPublishId(),
1614 .mode = DISCOVER_MODE_PASSIVE,
1615 .medium = COAP,
1616 .freq = LOW,
1617 .capability = "dvKit",
1618 .capabilityData = (unsigned char *)"capdata2",
1619 .dataLen = sizeof("capdata2")
1620 };
1621
1622 PublishService(g_pkgName, &testInfo, &g_publishCb);
1623 ret = UnPublishService(g_pkgName, testInfo.publishId);
1624 EXPECT_TRUE(ret == 0);
1625
1626 testInfo.freq = MID;
1627 PublishService(g_pkgName, &testInfo, &g_publishCb);
1628 ret = UnPublishService(g_pkgName, testInfo.publishId);
1629 EXPECT_TRUE(ret == 0);
1630
1631 testInfo.freq = HIGH;
1632 PublishService(g_pkgName, &testInfo, &g_publishCb);
1633 ret = UnPublishService(g_pkgName, testInfo.publishId);
1634 EXPECT_TRUE(ret == 0);
1635
1636 testInfo.freq = SUPER_HIGH;
1637 PublishService(g_pkgName, &testInfo, &g_publishCb);
1638 ret = UnPublishService(g_pkgName, testInfo.publishId);
1639 EXPECT_TRUE(ret == 0);
1640 }
1641
1642 /**
1643 * @tc.name: UnPublishServiceTest006
1644 * @tc.desc: Extern module stop publish, use the normal parameter and different frequencies under active AUTO.
1645 * @tc.in: Test module, Test number, Test levels.
1646 * @tc.out: Zero
1647 * @tc.type: FUNC
1648 * @tc.require: The UnPublishService operates normally.
1649 */
1650 HWTEST_F(Disc_Test, UnPublishServiceTest006, TestSize.Level0)
1651 {
1652 int ret;
1653 PublishInfo testInfo = {
1654 .publishId = GetPublishId(),
1655 .mode = DISCOVER_MODE_ACTIVE,
1656 .medium = AUTO,
1657 .freq = LOW,
1658 .capability = "dvKit",
1659 .capabilityData = (unsigned char *)"capdata2",
1660 .dataLen = sizeof("capdata2")
1661 };
1662
1663 PublishService(g_pkgName, &testInfo, &g_publishCb);
1664 ret = UnPublishService(g_pkgName, testInfo.publishId);
1665 EXPECT_TRUE(ret == 0);
1666
1667 testInfo.freq = MID;
1668 PublishService(g_pkgName, &testInfo, &g_publishCb);
1669 ret = UnPublishService(g_pkgName, testInfo.publishId);
1670 EXPECT_TRUE(ret == 0);
1671
1672 testInfo.freq = HIGH;
1673 PublishService(g_pkgName, &testInfo, &g_publishCb);
1674 ret = UnPublishService(g_pkgName, testInfo.publishId);
1675 EXPECT_TRUE(ret == 0);
1676
1677 testInfo.freq = SUPER_HIGH;
1678 PublishService(g_pkgName, &testInfo, &g_publishCb);
1679 ret = UnPublishService(g_pkgName, testInfo.publishId);
1680 EXPECT_TRUE(ret == 0);
1681 }
1682
1683 /**
1684 * @tc.name: UnPublishServiceTest007
1685 * @tc.desc: Extern module stop publish, use the normal parameter and different frequencies under passive AUTO.
1686 * @tc.in: Test module, Test number, Test levels.
1687 * @tc.out: Zero
1688 * @tc.type: FUNC
1689 * @tc.require: The UnPublishService operates normally.
1690 */
1691 HWTEST_F(Disc_Test, UnPublishServiceTest007, TestSize.Level0)
1692 {
1693 int ret;
1694 PublishInfo testInfo = {
1695 .publishId = GetPublishId(),
1696 .mode = DISCOVER_MODE_PASSIVE,
1697 .medium = AUTO,
1698 .freq = LOW,
1699 .capability = "dvKit",
1700 .capabilityData = (unsigned char *)"capdata2",
1701 .dataLen = sizeof("capdata2")
1702 };
1703
1704 PublishService(g_pkgName, &testInfo, &g_publishCb);
1705 ret = UnPublishService(g_pkgName, testInfo.publishId);
1706 EXPECT_TRUE(ret == 0);
1707
1708 testInfo.freq = MID;
1709 PublishService(g_pkgName, &testInfo, &g_publishCb);
1710 ret = UnPublishService(g_pkgName, testInfo.publishId);
1711 EXPECT_TRUE(ret == 0);
1712
1713 testInfo.freq = HIGH;
1714 PublishService(g_pkgName, &testInfo, &g_publishCb);
1715 ret = UnPublishService(g_pkgName, testInfo.publishId);
1716 EXPECT_TRUE(ret == 0);
1717
1718 testInfo.freq = SUPER_HIGH;
1719 PublishService(g_pkgName, &testInfo, &g_publishCb);
1720 ret = UnPublishService(g_pkgName, testInfo.publishId);
1721 EXPECT_TRUE(ret == 0);
1722 }
1723
1724 /**
1725 * @tc.name: UnPublishServiceTest008
1726 * @tc.desc: Test active publish, verify correct parameter with passive mode,"COAP" medium and diff capability.
1727 * @tc.in: Test module, Test number, Test levels.
1728 * @tc.out: Zero
1729 * @tc.type: FUNC
1730 * @tc.require: The UnPublishService operates normally.
1731 */
1732 HWTEST_F(Disc_Test, UnPublishServiceTest008, TestSize.Level1)
1733 {
1734 int ret;
1735 PublishInfo testInfo = {
1736 .publishId = GetPublishId(),
1737 .mode = DISCOVER_MODE_PASSIVE,
1738 .medium = COAP,
1739 .freq = LOW,
1740 .capability = "dvKit",
1741 .capabilityData = (unsigned char *)"capdata2",
1742 .dataLen = sizeof("capdata2")
1743 };
1744
1745 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1746 EXPECT_TRUE(ret == 0);
1747 ret = UnPublishService(g_pkgName, testInfo.publishId);
1748
1749 testInfo.capability = "hicall";
1750 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1751 EXPECT_TRUE(ret == 0);
1752 ret = UnPublishService(g_pkgName, testInfo.publishId);
1753
1754 testInfo.capability = "profile";
1755 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1756 EXPECT_TRUE(ret == 0);
1757 ret = UnPublishService(g_pkgName, testInfo.publishId);
1758
1759 testInfo.capability = "homevisionPic";
1760 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1761 EXPECT_TRUE(ret == 0);
1762 ret = UnPublishService(g_pkgName, testInfo.publishId);
1763
1764 testInfo.capability = "castPlus";
1765 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1766 EXPECT_TRUE(ret == 0);
1767 ret = UnPublishService(g_pkgName, testInfo.publishId);
1768
1769 testInfo.capability = "aaCapability";
1770 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1771 EXPECT_TRUE(ret == 0);
1772 ret = UnPublishService(g_pkgName, testInfo.publishId);
1773
1774 testInfo.capability = "ddmpCapability";
1775 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1776 EXPECT_TRUE(ret == 0);
1777 ret = UnPublishService(g_pkgName, testInfo.publishId);
1778
1779 testInfo.capability = "osdCapability";
1780 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1781 EXPECT_TRUE(ret == 0);
1782 ret = UnPublishService(g_pkgName, testInfo.publishId);
1783 }
1784
1785 /**
1786 * @tc.name: UnPublishServiceTest009
1787 * @tc.desc: Test active publish, verify correct parameter with active mode,"AUTO" medium and diff capability.
1788 * @tc.in: Test module, Test number, Test levels.
1789 * @tc.out: Zero
1790 * @tc.type: FUNC
1791 * @tc.require: The UnPublishService operates normally.
1792 */
1793 HWTEST_F(Disc_Test, UnPublishServiceTest009, TestSize.Level1)
1794 {
1795 int ret;
1796 PublishInfo testInfo = {
1797 .publishId = GetPublishId(),
1798 .mode = DISCOVER_MODE_ACTIVE,
1799 .medium = AUTO,
1800 .freq = LOW,
1801 .capability = "dvKit",
1802 .capabilityData = (unsigned char *)"capdata2",
1803 .dataLen = sizeof("capdata2")
1804 };
1805
1806 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1807 EXPECT_TRUE(ret == 0);
1808 ret = UnPublishService(g_pkgName, testInfo.publishId);
1809
1810 testInfo.capability = "hicall";
1811 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1812 EXPECT_TRUE(ret == 0);
1813 ret = UnPublishService(g_pkgName, testInfo.publishId);
1814
1815 testInfo.capability = "profile";
1816 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1817 EXPECT_TRUE(ret == 0);
1818 ret = UnPublishService(g_pkgName, testInfo.publishId);
1819
1820 testInfo.capability = "homevisionPic";
1821 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1822 EXPECT_TRUE(ret == 0);
1823 ret = UnPublishService(g_pkgName, testInfo.publishId);
1824
1825 testInfo.capability = "castPlus";
1826 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1827 EXPECT_TRUE(ret == 0);
1828 ret = UnPublishService(g_pkgName, testInfo.publishId);
1829
1830 testInfo.capability = "aaCapability";
1831 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1832 EXPECT_TRUE(ret == 0);
1833 ret = UnPublishService(g_pkgName, testInfo.publishId);
1834
1835 testInfo.capability = "ddmpCapability";
1836 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1837 EXPECT_TRUE(ret == 0);
1838 ret = UnPublishService(g_pkgName, testInfo.publishId);
1839
1840 testInfo.capability = "osdCapability";
1841 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1842 EXPECT_TRUE(ret == 0);
1843 ret = UnPublishService(g_pkgName, testInfo.publishId);
1844 }
1845
1846 /**
1847 * @tc.name: UnPublishServiceTest010
1848 * @tc.desc: Test active publish, verify correct parameter with passive mode,"AUTO" medium and diff capability.
1849 * @tc.in: Test module, Test number, Test levels.
1850 * @tc.out: Zero
1851 * @tc.type: FUNC
1852 * @tc.require: The UnPublishService operates normally.
1853 */
1854 HWTEST_F(Disc_Test, UnPublishServiceTest010, TestSize.Level1)
1855 {
1856 int ret;
1857 PublishInfo testInfo = {
1858 .publishId = GetPublishId(),
1859 .mode = DISCOVER_MODE_PASSIVE,
1860 .medium = AUTO,
1861 .freq = LOW,
1862 .capability = "dvKit",
1863 .capabilityData = (unsigned char *)"capdata2",
1864 .dataLen = sizeof("capdata2")
1865 };
1866
1867 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1868 EXPECT_TRUE(ret == 0);
1869 ret = UnPublishService(g_pkgName, testInfo.publishId);
1870
1871 testInfo.capability = "hicall";
1872 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1873 EXPECT_TRUE(ret == 0);
1874 ret = UnPublishService(g_pkgName, testInfo.publishId);
1875
1876 testInfo.capability = "profile";
1877 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1878 EXPECT_TRUE(ret == 0);
1879 ret = UnPublishService(g_pkgName, testInfo.publishId);
1880
1881 testInfo.capability = "homevisionPic";
1882 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1883 EXPECT_TRUE(ret == 0);
1884 ret = UnPublishService(g_pkgName, testInfo.publishId);
1885
1886 testInfo.capability = "castPlus";
1887 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1888 EXPECT_TRUE(ret == 0);
1889 ret = UnPublishService(g_pkgName, testInfo.publishId);
1890
1891 testInfo.capability = "aaCapability";
1892 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1893 EXPECT_TRUE(ret == 0);
1894 ret = UnPublishService(g_pkgName, testInfo.publishId);
1895
1896 testInfo.capability = "ddmpCapability";
1897 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1898 EXPECT_TRUE(ret == 0);
1899 ret = UnPublishService(g_pkgName, testInfo.publishId);
1900
1901 testInfo.capability = "osdCapability";
1902 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1903 EXPECT_TRUE(ret == 0);
1904 ret = UnPublishService(g_pkgName, testInfo.publishId);
1905 }
1906
1907 /**
1908 * @tc.name: UnPublishServiceTest011
1909 * @tc.desc: Test active publish, verify correct parameter with active mode,"AUTO" medium and diff capability.
1910 * @tc.in: Test module, Test number, Test levels.
1911 * @tc.out: Zero
1912 * @tc.type: FUNC
1913 * @tc.require: The UnPublishService operates normally.
1914 */
1915 HWTEST_F(Disc_Test, UnPublishServiceTest011, TestSize.Level1)
1916 {
1917 int ret;
1918 PublishInfo testInfo = {
1919 .publishId = GetPublishId(),
1920 .mode = DISCOVER_MODE_ACTIVE,
1921 .medium = AUTO,
1922 .freq = LOW,
1923 .capability = "dvKit",
1924 .capabilityData = (unsigned char *)"capdata2",
1925 .dataLen = sizeof("capdata2")
1926 };
1927
1928 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1929 EXPECT_TRUE(ret == 0);
1930 ret = UnPublishService(g_pkgName, testInfo.publishId);
1931
1932 testInfo.capability = "hicall";
1933 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1934 EXPECT_TRUE(ret == 0);
1935 ret = UnPublishService(g_pkgName, testInfo.publishId);
1936
1937 testInfo.capability = "profile";
1938 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1939 EXPECT_TRUE(ret == 0);
1940 ret = UnPublishService(g_pkgName, testInfo.publishId);
1941
1942 testInfo.capability = "homevisionPic";
1943 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1944 EXPECT_TRUE(ret == 0);
1945 ret = UnPublishService(g_pkgName, testInfo.publishId);
1946
1947 testInfo.capability = "castPlus";
1948 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1949 EXPECT_TRUE(ret == 0);
1950 ret = UnPublishService(g_pkgName, testInfo.publishId);
1951
1952 testInfo.capability = "aaCapability";
1953 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1954 EXPECT_TRUE(ret == 0);
1955 ret = UnPublishService(g_pkgName, testInfo.publishId);
1956
1957 testInfo.capability = "ddmpCapability";
1958 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1959 EXPECT_TRUE(ret == 0);
1960 ret = UnPublishService(g_pkgName, testInfo.publishId);
1961
1962 testInfo.capability = "osdCapability";
1963 ret = PublishService(g_pkgName, &testInfo, &g_publishCb);
1964 EXPECT_TRUE(ret == 0);
1965 ret = UnPublishService(g_pkgName, testInfo.publishId);
1966 }
1967
1968 /**
1969 * @tc.name: StopDiscoveryTest001
1970 * @tc.desc: Verify stopdiscovery wrong parameter.
1971 * @tc.type: FUNC
1972 * @tc.require:
1973 */
1974 HWTEST_F(Disc_Test, StopDiscoveryTest001, TestSize.Level0)
1975 {
1976 int ret;
1977 int tmpId = GetSubscribeId();
1978
1979 g_sInfo.subscribeId = tmpId;
1980 StartDiscovery(g_pkgName, &g_sInfo, &g_subscribeCb);
1981 ret = StopDiscovery(NULL, tmpId);
1982 EXPECT_TRUE(ret != 0);
1983 ret = StopDiscovery(g_erroPkgName, tmpId);
1984 EXPECT_TRUE(ret != 0);
1985 }
1986
1987 /**
1988 * @tc.name: StopDiscoveryTest002
1989 * @tc.desc: test under normal conditions.
1990 * @tc.type: FUNC
1991 * @tc.require:
1992 */
1993 HWTEST_F(Disc_Test, StopDiscoveryTest002, TestSize.Level0)
1994 {
1995 int ret;
1996 int tmpId1 = GetSubscribeId();
1997 int tmpId2 = GetSubscribeId();
1998
1999 g_sInfo.subscribeId = tmpId1;
2000 StartDiscovery(g_pkgName, &g_sInfo, &g_subscribeCb);
2001 g_sInfo1.subscribeId = tmpId2;
2002 StartDiscovery(g_pkgName, &g_sInfo1, &g_subscribeCb);
2003 ret = StopDiscovery(g_pkgName, tmpId1);
2004 EXPECT_TRUE(ret == 0);
2005 ret = StopDiscovery(g_pkgName, tmpId2);
2006 EXPECT_TRUE(ret == 0);
2007 }
2008
2009 /**
2010 * @tc.name: StopDiscoveryTest003
2011 * @tc.desc: Verify StartDiscovery and StopDiscovery same parameter again.
2012 * @tc.type: FUNC
2013 * @tc.require:
2014 */
2015 HWTEST_F(Disc_Test, StopDiscoveryTest003, TestSize.Level0)
2016 {
2017 int ret;
2018 int tmpId = GetSubscribeId();
2019
2020 g_sInfo.subscribeId = tmpId;
2021 StartDiscovery(g_pkgName, &g_sInfo, &g_subscribeCb);
2022 ret = StopDiscovery(g_pkgName, tmpId);
2023 EXPECT_TRUE(ret == 0);
2024 }
2025
2026 /**
2027 * @tc.name: StopDiscoveryTest004
2028 * @tc.desc:Test extern module stop active discover, use Diff Freq Under the COAP.
2029 * @tc.in: test module, test number, Test Levels.
2030 * @tc.out: Nonzero
2031 * @tc.type: FUNC
2032 * @tc.require: The StopDiscovery operates normally
2033 */
2034 HWTEST_F(Disc_Test, StopDiscoveryTest004, TestSize.Level0)
2035 {
2036 int ret;
2037 SubscribeInfo testInfo = {
2038 .subscribeId = GetSubscribeId(),
2039 .mode = DISCOVER_MODE_ACTIVE,
2040 .medium = COAP,
2041 .freq = LOW,
2042 .isSameAccount = true,
2043 .isWakeRemote = false,
2044 .capability = "dvKit",
2045 .capabilityData = (unsigned char *)"capdata3",
2046 .dataLen = sizeof("capdata3")
2047 };
2048 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2049 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2050 EXPECT_TRUE(ret == 0);
2051
2052 testInfo.freq = MID;
2053 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2054 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2055 EXPECT_TRUE(ret == 0);
2056
2057 testInfo.freq = HIGH;
2058 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2059 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2060 EXPECT_TRUE(ret == 0);
2061
2062 testInfo.freq = SUPER_HIGH;
2063 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2064 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2065 EXPECT_TRUE(ret == 0);
2066 }
2067
2068 /**
2069 * @tc.name: StopDiscoveryTest005
2070 * @tc.desc:Test extern module stop passive discover, use Diff Freq Under the COAP.
2071 * @tc.in: test module, test number, Test Levels.
2072 * @tc.out: Nonzero
2073 * @tc.type: FUNC
2074 * @tc.require: The StopDiscovery operates normally
2075 */
2076 HWTEST_F(Disc_Test, StopDiscoveryTest005, TestSize.Level0)
2077 {
2078 int ret;
2079 SubscribeInfo testInfo = {
2080 .subscribeId = GetSubscribeId(),
2081 .mode = DISCOVER_MODE_PASSIVE,
2082 .medium = COAP,
2083 .freq = LOW,
2084 .isSameAccount = true,
2085 .isWakeRemote = false,
2086 .capability = "dvKit",
2087 .capabilityData = (unsigned char *)"capdata3",
2088 .dataLen = sizeof("capdata3")
2089 };
2090 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2091 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2092 EXPECT_TRUE(ret == 0);
2093
2094 testInfo.freq = MID;
2095 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2096 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2097 EXPECT_TRUE(ret == 0);
2098
2099 testInfo.freq = HIGH;
2100 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2101 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2102 EXPECT_TRUE(ret == 0);
2103
2104 testInfo.freq = SUPER_HIGH;
2105 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2106 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2107 EXPECT_TRUE(ret == 0);
2108 }
2109
2110 /**
2111 * @tc.name: StopDiscoveryTest006
2112 * @tc.desc:Test extern module stop active discover, use Diff Freq Under the AUTO.
2113 * @tc.in: test module, test number, Test Levels.
2114 * @tc.out: Nonzero
2115 * @tc.type: FUNC
2116 * @tc.require: The StopDiscovery operates normally
2117 */
2118 HWTEST_F(Disc_Test, StopDiscoveryTest006, TestSize.Level0)
2119 {
2120 int ret;
2121 SubscribeInfo testInfo = {
2122 .subscribeId = GetSubscribeId(),
2123 .mode = DISCOVER_MODE_ACTIVE,
2124 .medium = AUTO,
2125 .freq = LOW,
2126 .isSameAccount = true,
2127 .isWakeRemote = false,
2128 .capability = "dvKit",
2129 .capabilityData = (unsigned char *)"capdata3",
2130 .dataLen = sizeof("capdata3")
2131 };
2132 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2133 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2134 EXPECT_TRUE(ret == 0);
2135
2136 testInfo.freq = MID;
2137 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2138 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2139 EXPECT_TRUE(ret == 0);
2140
2141 testInfo.freq = HIGH;
2142 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2143 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2144 EXPECT_TRUE(ret == 0);
2145
2146 testInfo.freq = SUPER_HIGH;
2147 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2148 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2149 EXPECT_TRUE(ret == 0);
2150 }
2151
2152 /**
2153 * @tc.name: StopDiscoveryTest007
2154 * @tc.desc:Test extern module stop passive discover, use Diff Freq Under the AUTO.
2155 * @tc.in: test module, test number, Test Levels.
2156 * @tc.out: Nonzero
2157 * @tc.type: FUNC
2158 * @tc.require: The StopDiscovery operates normally
2159 */
2160 HWTEST_F(Disc_Test, StopDiscoveryTest007, TestSize.Level0)
2161 {
2162 int ret;
2163 SubscribeInfo testInfo = {
2164 .subscribeId = GetSubscribeId(),
2165 .mode = DISCOVER_MODE_PASSIVE,
2166 .medium = AUTO,
2167 .freq = LOW,
2168 .isSameAccount = true,
2169 .isWakeRemote = false,
2170 .capability = "dvKit",
2171 .capabilityData = (unsigned char *)"capdata3",
2172 .dataLen = sizeof("capdata3")
2173 };
2174 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2175 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2176 EXPECT_TRUE(ret == 0);
2177
2178 testInfo.freq = MID;
2179 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2180 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2181 EXPECT_TRUE(ret == 0);
2182
2183 testInfo.freq = HIGH;
2184 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2185 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2186 EXPECT_TRUE(ret == 0);
2187
2188 testInfo.freq = SUPER_HIGH;
2189 StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2190 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2191 EXPECT_TRUE(ret == 0);
2192 }
2193
2194 /**
2195 * @tc.name: StopDiscoveryTest008
2196 * @tc.desc: Test active publish, verify correct parameter with passive mode,"COAP" medium and diff capability.
2197 * @tc.in: Test module, Test number, Test levels.
2198 * @tc.out: Zero
2199 * @tc.type: FUNC
2200 * @tc.require:The StopDiscovery operates normally
2201 */
2202 HWTEST_F(Disc_Test, StopDiscoveryTest008, TestSize.Level1)
2203 {
2204 int ret;
2205 SubscribeInfo testInfo = {
2206 .subscribeId = GetSubscribeId(),
2207 .mode = DISCOVER_MODE_PASSIVE,
2208 .medium = COAP,
2209 .freq = LOW,
2210 .isSameAccount = true,
2211 .isWakeRemote = false,
2212 .capability = "dvKit",
2213 .capabilityData = (unsigned char *)"capdata3",
2214 .dataLen = sizeof("capdata3")
2215 };
2216
2217 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2218 EXPECT_TRUE(ret == 0);
2219 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2220
2221 testInfo.capability = "hicall";
2222 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2223 EXPECT_TRUE(ret == 0);
2224 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2225
2226 testInfo.capability = "profile";
2227 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2228 EXPECT_TRUE(ret == 0);
2229 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2230
2231 testInfo.capability = "homevisionPic";
2232 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2233 EXPECT_TRUE(ret == 0);
2234 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2235
2236 testInfo.capability = "castPlus";
2237 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2238 EXPECT_TRUE(ret == 0);
2239 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2240
2241 testInfo.capability = "aaCapability";
2242 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2243 EXPECT_TRUE(ret == 0);
2244 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2245
2246 testInfo.capability = "ddmpCapability";
2247 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2248 EXPECT_TRUE(ret == 0);
2249 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2250
2251 testInfo.capability = "osdCapability";
2252 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2253 EXPECT_TRUE(ret == 0);
2254 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2255 }
2256
2257 /**
2258 * @tc.name:StopDiscoveryTest009
2259 * @tc.desc: Test active publish, verify correct parameter with active mode,"COAP" medium and diff capability.
2260 * @tc.in: Test module, Test number, Test levels.
2261 * @tc.out: Zero
2262 * @tc.type: FUNC
2263 * @tc.require:The StopDiscovery operates normally
2264 */
2265 HWTEST_F(Disc_Test, StopDiscoveryTest009, TestSize.Level1)
2266 {
2267 int ret;
2268 SubscribeInfo testInfo = {
2269 .subscribeId = GetSubscribeId(),
2270 .mode = DISCOVER_MODE_ACTIVE,
2271 .medium = COAP,
2272 .freq = LOW,
2273 .isSameAccount = true,
2274 .isWakeRemote = false,
2275 .capability = "dvKit",
2276 .capabilityData = (unsigned char *)"capdata3",
2277 .dataLen = sizeof("capdata3")
2278 };
2279
2280 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2281 EXPECT_TRUE(ret == 0);
2282 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2283
2284 testInfo.capability = "hicall";
2285 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2286 EXPECT_TRUE(ret == 0);
2287 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2288
2289 testInfo.capability = "profile";
2290 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2291 EXPECT_TRUE(ret == 0);
2292 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2293
2294 testInfo.capability = "homevisionPic";
2295 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2296 EXPECT_TRUE(ret == 0);
2297 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2298
2299 testInfo.capability = "castPlus";
2300 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2301 EXPECT_TRUE(ret == 0);
2302 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2303
2304 testInfo.capability = "aaCapability";
2305 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2306 EXPECT_TRUE(ret == 0);
2307 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2308
2309 testInfo.capability = "ddmpCapability";
2310 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2311 EXPECT_TRUE(ret == 0);
2312 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2313
2314 testInfo.capability = "osdCapability";
2315 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2316 EXPECT_TRUE(ret == 0);
2317 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2318 }
2319
2320 /**
2321 * @tc.name: StopDiscoveryTest011
2322 * @tc.desc: Test active publish, verify correct parameter with passive mode,"AUTO" medium and diff capability.
2323 * @tc.in: Test module, Test number, Test levels.
2324 * @tc.out: Zero
2325 * @tc.type: FUNC
2326 * @tc.require:The StopDiscovery operates normally
2327 */
2328 HWTEST_F(Disc_Test, StopDiscoveryTest011, TestSize.Level1)
2329 {
2330 int ret;
2331 SubscribeInfo testInfo = {
2332 .subscribeId = GetSubscribeId(),
2333 .mode = DISCOVER_MODE_PASSIVE,
2334 .medium = AUTO,
2335 .freq = LOW,
2336 .isSameAccount = true,
2337 .isWakeRemote = false,
2338 .capability = "dvKit",
2339 .capabilityData = (unsigned char *)"capdata3",
2340 .dataLen = sizeof("capdata3")
2341 };
2342
2343 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2344 EXPECT_TRUE(ret == 0);
2345 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2346
2347 testInfo.capability = "hicall";
2348 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2349 EXPECT_TRUE(ret == 0);
2350 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2351
2352 testInfo.capability = "profile";
2353 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2354 EXPECT_TRUE(ret == 0);
2355 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2356
2357 testInfo.capability = "homevisionPic";
2358 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2359 EXPECT_TRUE(ret == 0);
2360 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2361
2362 testInfo.capability = "castPlus";
2363 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2364 EXPECT_TRUE(ret == 0);
2365 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2366
2367 testInfo.capability = "aaCapability";
2368 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2369 EXPECT_TRUE(ret == 0);
2370 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2371
2372 testInfo.capability = "ddmpCapability";
2373 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2374 EXPECT_TRUE(ret == 0);
2375 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2376
2377 testInfo.capability = "osdCapability";
2378 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2379 EXPECT_TRUE(ret == 0);
2380 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2381 }
2382
2383 /**
2384 * @tc.name:StopDiscoveryTest012
2385 * @tc.desc: Test active publish, verify correct parameter with active mode,"AUTO" medium and diff capability.
2386 * @tc.in: Test module, Test number, Test levels.
2387 * @tc.out: Zero
2388 * @tc.type: FUNC
2389 * @tc.require:The StopDiscovery operates normally
2390 */
2391 HWTEST_F(Disc_Test, StopDiscoveryTest012, TestSize.Level1)
2392 {
2393 int ret;
2394 SubscribeInfo testInfo = {
2395 .subscribeId = GetSubscribeId(),
2396 .mode = DISCOVER_MODE_ACTIVE,
2397 .medium = AUTO,
2398 .freq = LOW,
2399 .isSameAccount = true,
2400 .isWakeRemote = false,
2401 .capability = "dvKit",
2402 .capabilityData = (unsigned char *)"capdata3",
2403 .dataLen = sizeof("capdata3")
2404 };
2405
2406 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2407 EXPECT_TRUE(ret == 0);
2408 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2409
2410 testInfo.capability = "hicall";
2411 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2412 EXPECT_TRUE(ret == 0);
2413 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2414
2415 testInfo.capability = "profile";
2416 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2417 EXPECT_TRUE(ret == 0);
2418 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2419
2420 testInfo.capability = "homevisionPic";
2421 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2422 EXPECT_TRUE(ret == 0);
2423 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2424
2425 testInfo.capability = "castPlus";
2426 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2427 EXPECT_TRUE(ret == 0);
2428 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2429
2430 testInfo.capability = "aaCapability";
2431 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2432 EXPECT_TRUE(ret == 0);
2433 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2434
2435 testInfo.capability = "ddmpCapability";
2436 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2437 EXPECT_TRUE(ret == 0);
2438 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2439
2440 testInfo.capability = "osdCapability";
2441 ret = StartDiscovery(g_pkgName, &testInfo, &g_subscribeCb);
2442 EXPECT_TRUE(ret == 0);
2443 ret = StopDiscovery(g_pkgName, testInfo.subscribeId);
2444 }
2445 } // namespace OHOS
2446