1 /*
2 * Copyright (c) 2023-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 <gtest/gtest.h>
17 #include <sys/stat.h>
18 #include <sys/types.h>
19 #include <string>
20 #include <vector>
21 #include <iostream>
22
23 #define private public
24 #define protected public
25 #include "distributed_device_profile_constants.h"
26 #include "distributed_device_profile_log.h"
27 #include "distributed_device_profile_errors.h"
28 #include "subscribe_profile_manager.h"
29 #include "distributed_device_profile_client.h"
30 #undef private
31 #undef protected
32
33 namespace OHOS {
34 namespace DistributedDeviceProfile {
35 using namespace testing::ext;
36 // using namespace OHOS::DistributedDeviceProfile;
37 using namespace std;
38 namespace {
39 const std::string TAG = "SubscribeProfileManagerTest";
40 }
41 class SubscribeProfileManagerTest : public testing::Test {
42 public:
43 static void SetUpTestCase();
44 static void TearDownTestCase();
45 void SetUp();
46 void TearDown();
47 };
48
SetUpTestCase()49 void SubscribeProfileManagerTest::SetUpTestCase()
50 {
51 int32_t errCode = SubscribeProfileManager::GetInstance().Init();
52 EXPECT_EQ(errCode, DP_SUCCESS);
53 }
54
TearDownTestCase()55 void SubscribeProfileManagerTest::TearDownTestCase()
56 {
57 int32_t errCode = SubscribeProfileManager::GetInstance().UnInit();
58 EXPECT_EQ(errCode, DP_SUCCESS);
59 }
60
SetUp()61 void SubscribeProfileManagerTest::SetUp()
62 {
63 }
64
TearDown()65 void SubscribeProfileManagerTest::TearDown()
66 {
67 }
68
69 class SubscribeDPChangeListener : public ProfileChangeListenerStub {
70 public:
SubscribeDPChangeListener()71 SubscribeDPChangeListener()
72 {
73 }
~SubscribeDPChangeListener()74 ~SubscribeDPChangeListener()
75 {
76 }
OnTrustDeviceProfileAdd(const TrustDeviceProfile & profile)77 int32_t OnTrustDeviceProfileAdd(const TrustDeviceProfile &profile)
78 {
79 return 0;
80 }
OnTrustDeviceProfileDelete(const TrustDeviceProfile & profile)81 int32_t OnTrustDeviceProfileDelete(const TrustDeviceProfile &profile)
82 {
83 return 0;
84 }
OnTrustDeviceProfileUpdate(const TrustDeviceProfile & oldProfile,const TrustDeviceProfile & newProfile)85 int32_t OnTrustDeviceProfileUpdate(const TrustDeviceProfile &oldProfile, const TrustDeviceProfile &newProfile)
86 {
87 return 0;
88 }
OnDeviceProfileAdd(const DeviceProfile & profile)89 int32_t OnDeviceProfileAdd(const DeviceProfile &profile)
90 {
91 return 0;
92 }
OnDeviceProfileDelete(const DeviceProfile & profile)93 int32_t OnDeviceProfileDelete(const DeviceProfile &profile)
94 {
95 return 0;
96 }
OnDeviceProfileUpdate(const DeviceProfile & oldProfile,const DeviceProfile & newProfile)97 int32_t OnDeviceProfileUpdate(const DeviceProfile &oldProfile, const DeviceProfile &newProfile)
98 {
99 return 0;
100 }
OnServiceProfileAdd(const ServiceProfile & profile)101 int32_t OnServiceProfileAdd(const ServiceProfile &profile)
102 {
103 return 0;
104 }
OnServiceProfileDelete(const ServiceProfile & profile)105 int32_t OnServiceProfileDelete(const ServiceProfile &profile)
106 {
107 return 0;
108 }
OnServiceProfileUpdate(const ServiceProfile & oldProfile,const ServiceProfile & newProfile)109 int32_t OnServiceProfileUpdate(const ServiceProfile &oldProfile, const ServiceProfile &newProfile)
110 {
111 return 0;
112 }
OnCharacteristicProfileAdd(const CharacteristicProfile & profile)113 int32_t OnCharacteristicProfileAdd(const CharacteristicProfile &profile)
114 {
115 return 0;
116 }
OnCharacteristicProfileDelete(const CharacteristicProfile & profile)117 int32_t OnCharacteristicProfileDelete(const CharacteristicProfile &profile)
118 {
119 return 0;
120 }
OnCharacteristicProfileUpdate(const CharacteristicProfile & oldProfile,const CharacteristicProfile & newProfile)121 int32_t OnCharacteristicProfileUpdate(const CharacteristicProfile &oldProfile,
122 const CharacteristicProfile &newProfile)
123 {
124 return 0;
125 }
126 };
127
128 /*
129 * @tc.name: SubscribeDeviceProfile_001
130 * @tc.desc: Normal testCase of SubscribeDeviceProfile for CRUD
131 * @tc.type: FUNC
132 * @tc.require: I4NY1T
133 */
134 HWTEST_F(SubscribeProfileManagerTest, SubscribeDeviceProfile_001, TestSize.Level1)
135 {
136 string subscribeKey = "subscribeKey";
137 int32_t saId = 4801;
138 unordered_set<ProfileChangeType> subscribeTypes = {
139 ProfileChangeType::SERVICE_PROFILE_ADD,
140 ProfileChangeType::SERVICE_PROFILE_UPDATE,
141 ProfileChangeType::SERVICE_PROFILE_DELETE,
142 ProfileChangeType::TRUST_DEVICE_PROFILE_ADD,
143 ProfileChangeType::TRUST_DEVICE_PROFILE_UPDATE,
144 ProfileChangeType::TRUST_DEVICE_PROFILE_DELETE,
145 ProfileChangeType::CHAR_PROFILE_ADD,
146 ProfileChangeType::CHAR_PROFILE_UPDATE,
147 ProfileChangeType::CHAR_PROFILE_DELETE,
148 ProfileChangeType::DEVICE_PROFILE_ADD,
149 ProfileChangeType::DEVICE_PROFILE_UPDATE,
150 ProfileChangeType::DEVICE_PROFILE_DELETE,
151 };
152 OHOS::sptr<IProfileChangeListener> subscribeDPChangeListener =
153 OHOS::sptr<ProfileChangeListenerStub>(new SubscribeDPChangeListener);
154 SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, subscribeDPChangeListener);
155
156 int32_t errCode = SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(subscribeInfo);
157 EXPECT_EQ(errCode, DP_SUCCESS);
158 }
159
160 /*
161 * @tc.name: NotifyProfileChange_001
162 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
163 * @tc.type: FUNC
164 * @tc.require: I4NY1T
165 */
166 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_001, TestSize.Level1)
167 {
168 std::string dbKey = "";
169 std::string dbValue = "";
170 int32_t errCode = SubscribeProfileManager::GetInstance().
171 NotifyProfileChange(ProfileType::PROFILE_TYPE_MAX, ChangeType::CHANGE_TYPE_MAX, dbKey, dbValue);
172 EXPECT_NE(errCode, DP_SUCCESS);
173 }
174
175 /*
176 * @tc.name: NotifyProfileChange_002
177 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
178 * @tc.type: FUNC
179 * @tc.require: I4NY1T
180 */
181 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_002, TestSize.Level1)
182 {
183 std::string dbKey = "";
184 std::string dbValue = "";
185 int32_t errCode = SubscribeProfileManager::GetInstance().
186 NotifyProfileChange(ProfileType::TRUST_DEVICE_PROFILE, ChangeType::ADD, dbKey, dbValue);
187 EXPECT_NE(errCode, DP_SUCCESS);
188 }
189
190 /*
191 * @tc.name: NotifyDeviceProfileAdd_001
192 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
193 * @tc.type: FUNC
194 * @tc.require: I4NY1T
195 */
196 HWTEST_F(SubscribeProfileManagerTest, NotifyTrustDeviceProfileAdd_001, TestSize.Level1)
197 {
198 TrustDeviceProfile profile;
199 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyTrustDeviceProfileAdd(profile);
200 EXPECT_EQ(errCode, DP_SUCCESS);
201 }
202
203 /*
204 * @tc.name: NotifyTrustDeviceProfileDelete_001
205 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
206 * @tc.type: FUNC
207 * @tc.require: I4NY1T
208 */
209 HWTEST_F(SubscribeProfileManagerTest, NotifyTrustDeviceProfileDelete_001, TestSize.Level1)
210 {
211 TrustDeviceProfile profile;
212 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyTrustDeviceProfileDelete(profile);
213 EXPECT_EQ(errCode, DP_SUCCESS);
214 }
215
216 /*
217 * @tc.name: NotifyTrustDeviceProfileUpdate_001
218 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
219 * @tc.type: FUNC
220 * @tc.require: I4NY1T
221 */
222 HWTEST_F(SubscribeProfileManagerTest, NotifyTrustDeviceProfileUpdate_001, TestSize.Level1)
223 {
224 TrustDeviceProfile oldProfile;
225 TrustDeviceProfile newProfile;
226 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyTrustDeviceProfileUpdate(oldProfile, newProfile);
227 EXPECT_EQ(errCode, DP_SUCCESS);
228 }
229
230 /*
231 * @tc.name: NotifyDeviceProfileAdd_001
232 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
233 * @tc.type: FUNC
234 * @tc.require: I4NY1T
235 */
236 HWTEST_F(SubscribeProfileManagerTest, NotifyDeviceProfileAdd_001, TestSize.Level1)
237 {
238 std::string dbKey = "";
239 std::string dbValue = "";
240 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyDeviceProfileAdd(dbKey, dbValue);
241 EXPECT_EQ(errCode, DP_SUCCESS);
242 }
243
244 /*
245 * @tc.name: NotifyDeviceProfileUpdate_001
246 * @tc.desc: Normal testCase of NotifyDeviceProfileUpdate for CRUD
247 * @tc.type: FUNC
248 * @tc.require: I4NY1T
249 */
250 HWTEST_F(SubscribeProfileManagerTest, NotifyDeviceProfileUpdate_001, TestSize.Level1)
251 {
252 std::string dbKey = "";
253 std::string dbValue = "";
254 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyDeviceProfileUpdate(dbKey, dbValue);
255 EXPECT_EQ(errCode, DP_SUCCESS);
256 }
257
258 /*
259 * @tc.name: NotifyDeviceProfileDelete_001
260 * @tc.desc: Normal testCase of NotifyDeviceProfileDelete for CRUD
261 * @tc.type: FUNC
262 * @tc.require: I4NY1T
263 */
264 HWTEST_F(SubscribeProfileManagerTest, NotifyDeviceProfileDelete_001, TestSize.Level1)
265 {
266 std::string dbKey = "";
267 std::string dbValue = "";
268 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyDeviceProfileDelete(dbKey, dbValue);
269 EXPECT_EQ(errCode, DP_SUCCESS);
270 }
271
272 /*
273 * @tc.name: NotifyServiceProfileAdd_001
274 * @tc.desc: Normal testCase of NotifyServiceProfileAdd for CRUD
275 * @tc.type: FUNC
276 * @tc.require: I4NY1T
277 */
278 HWTEST_F(SubscribeProfileManagerTest, NotifyServiceProfileAdd_001, TestSize.Level1)
279 {
280 std::string dbKey = "";
281 std::string dbValue = "";
282 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyServiceProfileAdd(dbKey, dbValue);
283 EXPECT_EQ(errCode, DP_SUCCESS);
284 }
285
286 /*
287 * @tc.name: NotifyServiceProfileUpdate_001
288 * @tc.desc: Normal testCase of NotifyServiceProfileUpdate for CRUD
289 * @tc.type: FUNC
290 * @tc.require: I4NY1T
291 */
292 HWTEST_F(SubscribeProfileManagerTest, NotifyServiceProfileUpdate_001, TestSize.Level1)
293 {
294 std::string dbKey = "";
295 std::string dbValue = "";
296 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyServiceProfileUpdate(dbKey, dbValue);
297 EXPECT_EQ(errCode, DP_SUCCESS);
298 }
299
300 /*
301 * @tc.name: NotifyServiceProfileDelete_001
302 * @tc.desc: Normal testCase of NotifyServiceProfileUpdate for CRUD
303 * @tc.type: FUNC
304 * @tc.require: I4NY1T
305 */
306 HWTEST_F(SubscribeProfileManagerTest, NotifyServiceProfileDelete_001, TestSize.Level1)
307 {
308 std::string dbKey = "";
309 std::string dbValue = "";
310 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyServiceProfileDelete(dbKey, dbValue);
311 EXPECT_EQ(errCode, DP_SUCCESS);
312 }
313
314 /*
315 * @tc.name: NotifyCharProfileAdd_001
316 * @tc.desc: Normal testCase of NotifyCharProfileAdd for CRUD
317 * @tc.type: FUNC
318 * @tc.require: I4NY1T
319 */
320 HWTEST_F(SubscribeProfileManagerTest, NotifyCharProfileAdd_001, TestSize.Level1)
321 {
322 std::string dbKey = "";
323 std::string dbValue = "";
324 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyCharProfileAdd(dbKey, dbValue);
325 EXPECT_EQ(errCode, DP_SUCCESS);
326 }
327
328 /*
329 * @tc.name: NotifyCharProfileUpdate_001
330 * @tc.desc: Normal testCase of NotifyCharProfileAdd for CRUD
331 * @tc.type: FUNC
332 * @tc.require: I4NY1T
333 */
334 HWTEST_F(SubscribeProfileManagerTest, NotifyCharProfileUpdate_001, TestSize.Level1)
335 {
336 std::string dbKey = "";
337 std::string dbValue = "";
338 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyCharProfileUpdate(dbKey, dbValue);
339 EXPECT_EQ(errCode, DP_SUCCESS);
340 }
341
342 /*
343 * @tc.name: NotifyCharProfileDelete_001
344 * @tc.desc: Normal testCase of NotifyCharProfileDelete for CRUD
345 * @tc.type: FUNC
346 * @tc.require: I4NY1T
347 */
348 HWTEST_F(SubscribeProfileManagerTest, NotifyCharProfileDelete_001, TestSize.Level1)
349 {
350 std::string dbKey = "";
351 std::string dbValue = "";
352 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyCharProfileDelete(dbKey, dbValue);
353 EXPECT_EQ(errCode, DP_SUCCESS);
354 }
355
356 /**
357 * @tc.name: UnSubscribeDeviceProfile001
358 * @tc.desc: UnSubscribeDeviceProfile success
359 * @tc.type: FUNC
360 * @tc.require:
361 * @tc.require: I4NY1T
362 */
363 HWTEST_F(SubscribeProfileManagerTest, UnSubscribeDeviceProfile001, TestSize.Level1)
364 {
365 string subscribeKey = "subscribeKey";
366 int32_t saId = 4801;
367 unordered_set<ProfileChangeType> subscribeTypes = {
368 ProfileChangeType::SERVICE_PROFILE_ADD,
369 ProfileChangeType::SERVICE_PROFILE_UPDATE,
370 ProfileChangeType::SERVICE_PROFILE_DELETE,
371 ProfileChangeType::TRUST_DEVICE_PROFILE_ADD,
372 ProfileChangeType::TRUST_DEVICE_PROFILE_UPDATE,
373 ProfileChangeType::TRUST_DEVICE_PROFILE_DELETE,
374 ProfileChangeType::CHAR_PROFILE_ADD,
375 ProfileChangeType::CHAR_PROFILE_UPDATE,
376 ProfileChangeType::CHAR_PROFILE_DELETE,
377 ProfileChangeType::DEVICE_PROFILE_ADD,
378 ProfileChangeType::DEVICE_PROFILE_UPDATE,
379 ProfileChangeType::DEVICE_PROFILE_DELETE,
380 };
381 OHOS::sptr<IProfileChangeListener> subscribeDPChangeListener =
382 OHOS::sptr<ProfileChangeListenerStub>(new SubscribeDPChangeListener);
383 SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, subscribeDPChangeListener);
384
385 int32_t errCode = SubscribeProfileManager::GetInstance().UnSubscribeDeviceProfile(subscribeInfo);
386 EXPECT_EQ(errCode, DP_SUCCESS);
387 }
388
389 /*
390 * @tc.name: SubscribeDeviceProfile_002
391 * @tc.desc: Normal testCase of SubscribeDeviceProfile for CRUD
392 * @tc.type: FUNC
393 * @tc.require: I4NY1T
394 */
395 HWTEST_F(SubscribeProfileManagerTest, SubscribeDeviceProfile_002, TestSize.Level1)
396 {
397 string subscribeKey = "subscribeKey";
398 int32_t saId = 4801;
399 unordered_set<ProfileChangeType> subscribeTypes = {};
400 SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, nullptr);
401
402 int32_t errCode = SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(subscribeInfo);
403 EXPECT_EQ(errCode, DP_SUCCESS);
404 }
405
406 /*
407 * @tc.name: NotifyTrustDeviceProfileAdd_002
408 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
409 * @tc.type: FUNC
410 * @tc.require: I4NY1T
411 */
412 HWTEST_F(SubscribeProfileManagerTest, NotifyTrustDeviceProfileAdd_002, TestSize.Level1)
413 {
414 TrustDeviceProfile profile;
415 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyTrustDeviceProfileAdd(profile);
416 EXPECT_EQ(errCode, DP_SUCCESS);
417 }
418
419 /*
420 * @tc.name: NotifyTrustDeviceProfileDelete_002
421 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
422 * @tc.type: FUNC
423 * @tc.require: I4NY1T
424 */
425 HWTEST_F(SubscribeProfileManagerTest, NotifyTrustDeviceProfileDelete_002, TestSize.Level1)
426 {
427 TrustDeviceProfile profile;
428 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyTrustDeviceProfileDelete(profile);
429 EXPECT_EQ(errCode, DP_SUCCESS);
430 }
431
432 /*
433 * @tc.name: NotifyTrustDeviceProfileUpdate_002
434 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
435 * @tc.type: FUNC
436 * @tc.require: I4NY1T
437 */
438 HWTEST_F(SubscribeProfileManagerTest, NotifyTrustDeviceProfileUpdate_002, TestSize.Level1)
439 {
440 TrustDeviceProfile oldProfile;
441 TrustDeviceProfile newProfile;
442 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyTrustDeviceProfileUpdate(oldProfile, newProfile);
443 EXPECT_EQ(errCode, DP_SUCCESS);
444 }
445
446 /*
447 * @tc.name: NotifyDeviceProfileAdd_002
448 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
449 * @tc.type: FUNC
450 * @tc.require: I4NY1T
451 */
452 HWTEST_F(SubscribeProfileManagerTest, NotifyDeviceProfileAdd_002, TestSize.Level1)
453 {
454 std::string dbKey = "";
455 std::string dbValue = "";
456 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyDeviceProfileAdd(dbKey, dbValue);
457 EXPECT_EQ(errCode, DP_SUCCESS);
458 }
459
460 /*
461 * @tc.name: NotifyDeviceProfileUpdate_002
462 * @tc.desc: Normal testCase of NotifyDeviceProfileUpdate for CRUD
463 * @tc.type: FUNC
464 * @tc.require: I4NY1T
465 */
466 HWTEST_F(SubscribeProfileManagerTest, NotifyDeviceProfileUpdate_002, TestSize.Level1)
467 {
468 std::string dbKey = "";
469 std::string dbValue = "";
470 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyDeviceProfileUpdate(dbKey, dbValue);
471 EXPECT_EQ(errCode, DP_SUCCESS);
472 }
473
474 /*
475 * @tc.name: NotifyDeviceProfileDelete_002
476 * @tc.desc: Normal testCase of NotifyDeviceProfileDelete for CRUD
477 * @tc.type: FUNC
478 * @tc.require: I4NY1T
479 */
480 HWTEST_F(SubscribeProfileManagerTest, NotifyDeviceProfileDelete_002, TestSize.Level1)
481 {
482 std::string dbKey = "";
483 std::string dbValue = "";
484 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyDeviceProfileDelete(dbKey, dbValue);
485 EXPECT_EQ(errCode, DP_SUCCESS);
486 }
487
488 /*
489 * @tc.name: NotifyServiceProfileAdd_002
490 * @tc.desc: Normal testCase of NotifyServiceProfileAdd for CRUD
491 * @tc.type: FUNC
492 * @tc.require: I4NY1T
493 */
494 HWTEST_F(SubscribeProfileManagerTest, NotifyServiceProfileAdd_002, TestSize.Level1)
495 {
496 std::string dbKey = "";
497 std::string dbValue = "";
498 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyServiceProfileAdd(dbKey, dbValue);
499 EXPECT_EQ(errCode, DP_SUCCESS);
500 }
501
502 /*
503 * @tc.name: NotifyServiceProfileUpdate_002
504 * @tc.desc: Normal testCase of NotifyServiceProfileUpdate for CRUD
505 * @tc.type: FUNC
506 * @tc.require: I4NY1T
507 */
508 HWTEST_F(SubscribeProfileManagerTest, NotifyServiceProfileUpdate_002, TestSize.Level1)
509 {
510 std::string dbKey = "";
511 std::string dbValue = "";
512 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyServiceProfileUpdate(dbKey, dbValue);
513 EXPECT_EQ(errCode, DP_SUCCESS);
514 }
515
516 /*
517 * @tc.name: NotifyServiceProfileDelete_002
518 * @tc.desc: Normal testCase of NotifyServiceProfileUpdate for CRUD
519 * @tc.type: FUNC
520 * @tc.require: I4NY1T
521 */
522 HWTEST_F(SubscribeProfileManagerTest, NotifyServiceProfileDelete_002, TestSize.Level1)
523 {
524 std::string dbKey = "";
525 std::string dbValue = "";
526 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyServiceProfileDelete(dbKey, dbValue);
527 EXPECT_EQ(errCode, DP_SUCCESS);
528 }
529
530 /*
531 * @tc.name: NotifyCharProfileAdd_002
532 * @tc.desc: Normal testCase of NotifyCharProfileAdd for CRUD
533 * @tc.type: FUNC
534 * @tc.require: I4NY1T
535 */
536 HWTEST_F(SubscribeProfileManagerTest, NotifyCharProfileAdd_002, TestSize.Level1)
537 {
538 std::string dbKey = "";
539 std::string dbValue = "";
540 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyCharProfileAdd(dbKey, dbValue);
541 EXPECT_EQ(errCode, DP_SUCCESS);
542 }
543
544 /*
545 * @tc.name: NotifyCharProfileUpdate_002
546 * @tc.desc: Normal testCase of NotifyCharProfileAdd for CRUD
547 * @tc.type: FUNC
548 * @tc.require: I4NY1T
549 */
550 HWTEST_F(SubscribeProfileManagerTest, NotifyCharProfileUpdate_002, TestSize.Level1)
551 {
552 std::string dbKey = "";
553 std::string dbValue = "";
554 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyCharProfileUpdate(dbKey, dbValue);
555 EXPECT_EQ(errCode, DP_SUCCESS);
556 }
557
558 /*
559 * @tc.name: NotifyCharProfileDelete_002
560 * @tc.desc: Normal testCase of NotifyCharProfileDelete for CRUD
561 * @tc.type: FUNC
562 * @tc.require: I4NY1T
563 */
564 HWTEST_F(SubscribeProfileManagerTest, NotifyCharProfileDelete_002, TestSize.Level1)
565 {
566 std::string dbKey = "";
567 std::string dbValue = "";
568 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyCharProfileDelete(dbKey, dbValue);
569 EXPECT_EQ(errCode, DP_SUCCESS);
570 }
571
572 /**
573 * @tc.name: UnSubscribeDeviceProfile002
574 * @tc.desc: UnSubscribeDeviceProfile success
575 * @tc.type: FUNC
576 * @tc.require:
577 * @tc.require: I4NY1T
578 */
579 HWTEST_F(SubscribeProfileManagerTest, UnSubscribeDeviceProfile002, TestSize.Level1)
580 {
581 string subscribeKey = "subscribeKey";
582 int32_t saId = 4801;
583 unordered_set<ProfileChangeType> subscribeTypes = {};
584 SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, nullptr);
585
586 int32_t errCode = SubscribeProfileManager::GetInstance().UnSubscribeDeviceProfile(subscribeInfo);
587 EXPECT_EQ(errCode, DP_SUCCESS);
588 }
589
590
591 /*
592 * @tc.name: SubscribeDeviceProfile_003
593 * @tc.desc: Normal testCase of SubscribeDeviceProfile for CRUD
594 * @tc.type: FUNC
595 * @tc.require: I4NY1T
596 */
597 HWTEST_F(SubscribeProfileManagerTest, SubscribeDeviceProfile_003, TestSize.Level1)
598 {
599 string subscribeKey = "subscribeKey";
600 int32_t saId = 4801;
601 unordered_set<ProfileChangeType> subscribeTypes = {};
602 OHOS::sptr<IProfileChangeListener> subscribeDPChangeListener =
603 OHOS::sptr<ProfileChangeListenerStub>(new SubscribeDPChangeListener);
604 SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, subscribeDPChangeListener);
605
606 int32_t errCode = SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(subscribeInfo);
607 EXPECT_EQ(errCode, DP_SUCCESS);
608 }
609
610 /*
611 * @tc.name: NotifyDeviceProfileAdd_003
612 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
613 * @tc.type: FUNC
614 * @tc.require: I4NY1T
615 */
616 HWTEST_F(SubscribeProfileManagerTest, NotifyTrustDeviceProfileAdd_003, TestSize.Level1)
617 {
618 TrustDeviceProfile profile;
619 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyTrustDeviceProfileAdd(profile);
620 EXPECT_EQ(errCode, DP_SUCCESS);
621 }
622
623 /*
624 * @tc.name: NotifyTrustDeviceProfileDelete_001
625 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
626 * @tc.type: FUNC
627 * @tc.require: I4NY1T
628 */
629 HWTEST_F(SubscribeProfileManagerTest, NotifyTrustDeviceProfileDelete_003, TestSize.Level1)
630 {
631 TrustDeviceProfile profile;
632 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyTrustDeviceProfileDelete(profile);
633 EXPECT_EQ(errCode, DP_SUCCESS);
634 }
635
636 /*
637 * @tc.name: NotifyTrustDeviceProfileUpdate_001
638 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
639 * @tc.type: FUNC
640 * @tc.require: I4NY1T
641 */
642 HWTEST_F(SubscribeProfileManagerTest, NotifyTrustDeviceProfileUpdate_003, TestSize.Level1)
643 {
644 TrustDeviceProfile oldProfile;
645 TrustDeviceProfile newProfile;
646 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyTrustDeviceProfileUpdate(oldProfile, newProfile);
647 EXPECT_EQ(errCode, DP_SUCCESS);
648 }
649
650 /*
651 * @tc.name: NotifyDeviceProfileAdd_003
652 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
653 * @tc.type: FUNC
654 * @tc.require: I4NY1T
655 */
656 HWTEST_F(SubscribeProfileManagerTest, NotifyDeviceProfileAdd_003, TestSize.Level1)
657 {
658 std::string dbKey = "";
659 std::string dbValue = "";
660 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyDeviceProfileAdd(dbKey, dbValue);
661 EXPECT_EQ(errCode, DP_SUCCESS);
662 }
663
664 /*
665 * @tc.name: NotifyDeviceProfileUpdate_003
666 * @tc.desc: Normal testCase of NotifyDeviceProfileUpdate for CRUD
667 * @tc.type: FUNC
668 * @tc.require: I4NY1T
669 */
670 HWTEST_F(SubscribeProfileManagerTest, NotifyDeviceProfileUpdate_003, TestSize.Level1)
671 {
672 std::string dbKey = "";
673 std::string dbValue = "";
674 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyDeviceProfileUpdate(dbKey, dbValue);
675 EXPECT_EQ(errCode, DP_SUCCESS);
676 }
677
678 /*
679 * @tc.name: NotifyDeviceProfileDelete_003
680 * @tc.desc: Normal testCase of NotifyDeviceProfileDelete for CRUD
681 * @tc.type: FUNC
682 * @tc.require: I4NY1T
683 */
684 HWTEST_F(SubscribeProfileManagerTest, NotifyDeviceProfileDelete_003, TestSize.Level1)
685 {
686 std::string dbKey = "";
687 std::string dbValue = "";
688 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyDeviceProfileDelete(dbKey, dbValue);
689 EXPECT_EQ(errCode, DP_SUCCESS);
690 }
691
692 /*
693 * @tc.name: NotifyServiceProfileAdd_003
694 * @tc.desc: Normal testCase of NotifyServiceProfileAdd for CRUD
695 * @tc.type: FUNC
696 * @tc.require: I4NY1T
697 */
698 HWTEST_F(SubscribeProfileManagerTest, NotifyServiceProfileAdd_003, TestSize.Level1)
699 {
700 std::string dbKey = "";
701 std::string dbValue = "";
702 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyServiceProfileAdd(dbKey, dbValue);
703 EXPECT_EQ(errCode, DP_SUCCESS);
704 }
705
706 /*
707 * @tc.name: NotifyServiceProfileUpdate_003
708 * @tc.desc: Normal testCase of NotifyServiceProfileUpdate for CRUD
709 * @tc.type: FUNC
710 * @tc.require: I4NY1T
711 */
712 HWTEST_F(SubscribeProfileManagerTest, NotifyServiceProfileUpdate_003, TestSize.Level1)
713 {
714 std::string dbKey = "";
715 std::string dbValue = "";
716 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyServiceProfileUpdate(dbKey, dbValue);
717 EXPECT_EQ(errCode, DP_SUCCESS);
718 }
719
720 /*
721 * @tc.name: NotifyServiceProfileDelete_003
722 * @tc.desc: Normal testCase of NotifyServiceProfileUpdate for CRUD
723 * @tc.type: FUNC
724 * @tc.require: I4NY1T
725 */
726 HWTEST_F(SubscribeProfileManagerTest, NotifyServiceProfileDelete_003, TestSize.Level1)
727 {
728 std::string dbKey = "";
729 std::string dbValue = "";
730 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyServiceProfileDelete(dbKey, dbValue);
731 EXPECT_EQ(errCode, DP_SUCCESS);
732 }
733
734 /*
735 * @tc.name: NotifyCharProfileAdd_003
736 * @tc.desc: Normal testCase of NotifyCharProfileAdd for CRUD
737 * @tc.type: FUNC
738 * @tc.require: I4NY1T
739 */
740 HWTEST_F(SubscribeProfileManagerTest, NotifyCharProfileAdd_003, TestSize.Level1)
741 {
742 std::string dbKey = "";
743 std::string dbValue = "";
744 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyCharProfileAdd(dbKey, dbValue);
745 EXPECT_EQ(errCode, DP_SUCCESS);
746 }
747
748 /*
749 * @tc.name: NotifyCharProfileUpdate_003
750 * @tc.desc: Normal testCase of NotifyCharProfileAdd for CRUD
751 * @tc.type: FUNC
752 * @tc.require: I4NY1T
753 */
754 HWTEST_F(SubscribeProfileManagerTest, NotifyCharProfileUpdate_003, TestSize.Level1)
755 {
756 std::string dbKey = "";
757 std::string dbValue = "";
758 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyCharProfileUpdate(dbKey, dbValue);
759 EXPECT_EQ(errCode, DP_SUCCESS);
760 }
761
762 /*
763 * @tc.name: NotifyCharProfileDelete_003
764 * @tc.desc: Normal testCase of NotifyCharProfileDelete for CRUD
765 * @tc.type: FUNC
766 * @tc.require: I4NY1T
767 */
768 HWTEST_F(SubscribeProfileManagerTest, NotifyCharProfileDelete_003, TestSize.Level1)
769 {
770 std::string dbKey = "";
771 std::string dbValue = "";
772 int32_t errCode = SubscribeProfileManager::GetInstance().NotifyCharProfileDelete(dbKey, dbValue);
773 EXPECT_EQ(errCode, DP_SUCCESS);
774 }
775
776 /*
777 * @tc.name: NotifyProfileChange_003
778 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
779 * @tc.type: FUNC
780 * @tc.require: I4NY1T
781 */
782 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_003, TestSize.Level1)
783 {
784 std::string dbKey = "";
785 std::string dbValue = "";
786 int32_t errCode = SubscribeProfileManager::GetInstance().
787 NotifyProfileChange(ProfileType::DEVICE_PROFILE, ChangeType::ADD, dbKey, dbValue);
788 EXPECT_EQ(errCode, DP_SUCCESS);
789 }
790
791 /*
792 * @tc.name: NotifyProfileChange_004
793 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
794 * @tc.type: FUNC
795 * @tc.require: I4NY1T
796 */
797 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_004, TestSize.Level1)
798 {
799 std::string dbKey = "";
800 std::string dbValue = "";
801 int32_t errCode = SubscribeProfileManager::GetInstance().
802 NotifyProfileChange(ProfileType::DEVICE_PROFILE, ChangeType::UPDATE, dbKey, dbValue);
803 EXPECT_EQ(errCode, DP_SUCCESS);
804 }
805
806 /*
807 * @tc.name: NotifyProfileChange_005
808 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
809 * @tc.type: FUNC
810 * @tc.require: I4NY1T
811 */
812 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_005, TestSize.Level1)
813 {
814 std::string dbKey = "";
815 std::string dbValue = "";
816 int32_t errCode = SubscribeProfileManager::GetInstance().
817 NotifyProfileChange(ProfileType::DEVICE_PROFILE, ChangeType::DELETE, dbKey, dbValue);
818 EXPECT_EQ(errCode, DP_SUCCESS);
819 }
820
821 /*
822 * @tc.name: NotifyProfileChange_006
823 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
824 * @tc.type: FUNC
825 * @tc.require: I4NY1T
826 */
827 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_006, TestSize.Level1)
828 {
829 std::string dbKey = "";
830 std::string dbValue = "";
831 int32_t errCode = SubscribeProfileManager::GetInstance().
832 NotifyProfileChange(ProfileType::SERVICE_PROFILE, ChangeType::ADD, dbKey, dbValue);
833 EXPECT_EQ(errCode, DP_SUCCESS);
834 }
835
836 /*
837 * @tc.name: NotifyProfileChange_007
838 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
839 * @tc.type: FUNC
840 * @tc.require: I4NY1T
841 */
842 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_007, TestSize.Level1)
843 {
844 std::string dbKey = "";
845 std::string dbValue = "";
846 int32_t errCode = SubscribeProfileManager::GetInstance().
847 NotifyProfileChange(ProfileType::SERVICE_PROFILE, ChangeType::UPDATE, dbKey, dbValue);
848 EXPECT_EQ(errCode, DP_SUCCESS);
849 }
850
851 /*
852 * @tc.name: NotifyProfileChange_008
853 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
854 * @tc.type: FUNC
855 * @tc.require: I4NY1T
856 */
857 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_008, TestSize.Level1)
858 {
859 std::string dbKey = "";
860 std::string dbValue = "";
861 int32_t errCode = SubscribeProfileManager::GetInstance().
862 NotifyProfileChange(ProfileType::SERVICE_PROFILE, ChangeType::DELETE, dbKey, dbValue);
863 EXPECT_EQ(errCode, DP_SUCCESS);
864 }
865
866 /*
867 * @tc.name: NotifyProfileChange_009
868 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
869 * @tc.type: FUNC
870 * @tc.require: I4NY1T
871 */
872 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_009, TestSize.Level1)
873 {
874 std::string dbKey = "";
875 std::string dbValue = "";
876 int32_t errCode = SubscribeProfileManager::GetInstance().
877 NotifyProfileChange(ProfileType::CHAR_PROFILE, ChangeType::ADD, dbKey, dbValue);
878 EXPECT_EQ(errCode, DP_SUCCESS);
879 }
880
881 /*
882 * @tc.name: NotifyProfileChange_010
883 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
884 * @tc.type: FUNC
885 * @tc.require: I4NY1T
886 */
887 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_010, TestSize.Level1)
888 {
889 std::string dbKey = "";
890 std::string dbValue = "";
891 int32_t errCode = SubscribeProfileManager::GetInstance().
892 NotifyProfileChange(ProfileType::CHAR_PROFILE, ChangeType::UPDATE, dbKey, dbValue);
893 EXPECT_EQ(errCode, DP_SUCCESS);
894 }
895
896 /*
897 * @tc.name: NotifyProfileChange_011
898 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
899 * @tc.type: FUNC
900 * @tc.require: I4NY1T
901 */
902 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_011, TestSize.Level1)
903 {
904 std::string dbKey = "";
905 std::string dbValue = "";
906 int32_t errCode = SubscribeProfileManager::GetInstance().
907 NotifyProfileChange(ProfileType::CHAR_PROFILE, ChangeType::DELETE, dbKey, dbValue);
908 EXPECT_EQ(errCode, DP_SUCCESS);
909 }
910
911 /*
912 * @tc.name: NotifyProfileChange_012
913 * @tc.desc: Normal testCase of NotifyDeviceProfileAdd for CRUD
914 * @tc.type: FUNC
915 * @tc.require: I4NY1T
916 */
917 HWTEST_F(SubscribeProfileManagerTest, NotifyProfileChange_012, TestSize.Level1)
918 {
919 std::string dbKey = "";
920 std::string dbValue = "";
921 int32_t errCode = SubscribeProfileManager::GetInstance().
922 NotifyProfileChange(ProfileType::CHAR_PROFILE, ChangeType::CHANGE_TYPE_MIN, dbKey, dbValue);
923 EXPECT_EQ(errCode, DP_INVALID_PARAMS);
924 }
925 }
926 }