• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 <cstdint>
17 #include <gtest/gtest.h>
18 
19 #include "notification_bundle_option.h"
20 #include "notification_do_not_disturb_date.h"
21 #include "enabled_notification_callback_data.h"
22 #include "notification_request.h"
23 #include "notification_slot.h"
24 #include "notification_sorting_map.h"
25 #include "notification_subscriber.h"
26 #include "ans_inner_errors.h"
27 #include "errors.h"
28 #include "notification_helper.h"
29 #include "nativetoken_kit.h"
30 #include "token_setproc.h"
31 
32 using namespace testing::ext;
33 namespace OHOS {
34 namespace Notification {
35 class NotificationHelperTest : public testing::Test {
36 public:
SetUpTestCase()37     static void SetUpTestCase()
38     {
39         const char **perms = new const char *[1];
40         perms[0] = "ohos.permission.NOTIFICATION_CONTROLLER";
41         NativeTokenInfoParams infoInstance = {
42             .dcapsNum = 0,
43             .permsNum = 1,
44             .aclsNum = 0,
45             .dcaps = nullptr,
46             .perms = perms,
47             .acls = nullptr,
48             .aplStr = "system_basic",
49         };
50 
51         uint64_t tokenId;
52         infoInstance.processName = "ans_reminder_unit_test";
53         tokenId = GetAccessTokenId(&infoInstance);
54         SetSelfTokenID(tokenId);
55         delete[] perms;
56     }
TearDownTestCase()57     static void TearDownTestCase() {}
SetUp()58     void SetUp() {}
TearDown()59     void TearDown() {}
60 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
UpdateStatuts(bool isEnable,int status)61     void UpdateStatuts(bool isEnable, int status)
62     {
63         ANS_LOGI("NotificationHelperTest UpdateStatuts");
64     }
65 #endif
66 };
67 
68 /**
69  * @tc.name: AddNotificationSlot_00001
70  * @tc.desc: Test AddNotificationSlot parameters.
71  * @tc.type: FUNC
72  * @tc.require: issueI5WRQ2
73  */
74 HWTEST_F(NotificationHelperTest, AddNotificationSlot_00001, Function | SmallTest | Level1)
75 {
76     NotificationSlot slot;
77     NotificationHelper notificationHelper;
78     ErrCode ret = notificationHelper.AddNotificationSlot(slot);
79     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
80 }
81 
82 /**
83  * @tc.name: AddSlotByType_00001
84  * @tc.desc: Test AddSlotByType parameters.
85  * @tc.type: FUNC
86  * @tc.require: issueI5WRQ2
87  */
88 HWTEST_F(NotificationHelperTest, AddSlotByType_00001, Function | SmallTest | Level1)
89 {
90     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER;
91     NotificationHelper notificationHelper;
92     ErrCode ret = notificationHelper.AddSlotByType(slotType);
93     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
94 }
95 
96 /**
97  * @tc.name: AddNotificationSlots_00001
98  * @tc.desc: Test AddNotificationSlots parameters.
99  * @tc.type: FUNC
100  * @tc.require: issueI5WRQ2
101  */
102 HWTEST_F(NotificationHelperTest, AddNotificationSlots_00001, Function | SmallTest | Level1)
103 {
104     std::vector<NotificationSlot> slots;
105     NotificationHelper notificationHelper;
106     ErrCode ret = notificationHelper.AddNotificationSlots(slots);
107     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
108 }
109 
110 /**
111  * @tc.name: RemoveNotificationSlot_00001
112  * @tc.desc: Test RemoveNotificationSlot parameters.
113  * @tc.type: FUNC
114  * @tc.require: issueI5WRQ2
115  */
116 HWTEST_F(NotificationHelperTest, RemoveNotificationSlot_00001, Function | SmallTest | Level1)
117 {
118     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER;
119     NotificationHelper notificationHelper;
120     ErrCode ret = notificationHelper.RemoveNotificationSlot(slotType);
121     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
122 }
123 
124 /**
125  * @tc.name: RemoveAllSlots_00001
126  * @tc.desc: Test RemoveAllSlots parameters.
127  * @tc.type: FUNC
128  * @tc.require: issueI5WRQ2
129  */
130 HWTEST_F(NotificationHelperTest, RemoveAllSlots_00001, Function | SmallTest | Level1)
131 {
132     NotificationHelper notificationHelper;
133     ErrCode ret = notificationHelper.RemoveAllSlots();
134     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
135 }
136 
137 /**
138  * @tc.name: GetNotificationSlot_00001
139  * @tc.desc: Test GetNotificationSlot parameters.
140  * @tc.type: FUNC
141  * @tc.require: issueI5WRQ2
142  */
143 HWTEST_F(NotificationHelperTest, GetNotificationSlot_00001, Function | SmallTest | Level1)
144 {
145     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER;
146     sptr<NotificationSlot> slot = nullptr;
147     NotificationHelper notificationHelper;
148     ErrCode ret = notificationHelper.GetNotificationSlot(slotType, slot);
149     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
150 }
151 
152 /**
153  * @tc.name: GetNotificationSlots_00001
154  * @tc.desc: Test GetNotificationSlots parameters.
155  * @tc.type: FUNC
156  * @tc.require: issueI5WRQ2
157  */
158 HWTEST_F(NotificationHelperTest, GetNotificationSlots_00001, Function | SmallTest | Level1)
159 {
160     std::vector<sptr<NotificationSlot>> slots;
161     NotificationHelper notificationHelper;
162     ErrCode ret = notificationHelper.GetNotificationSlots(slots);
163     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
164 }
165 
166 /**
167  * @tc.name: GetNotificationSlotNumAsBundle_00001
168  * @tc.desc: Test GetNotificationSlotNumAsBundle parameters.
169  * @tc.type: FUNC
170  * @tc.require: issueI5WRQ2
171  */
172 HWTEST_F(NotificationHelperTest, GetNotificationSlotNumAsBundle_00001, Function | SmallTest | Level1)
173 {
174     NotificationBundleOption bundleOption;
175     uint64_t num = 10;
176     NotificationHelper notificationHelper;
177     ErrCode ret = notificationHelper.GetNotificationSlotNumAsBundle(bundleOption, num);
178     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
179 }
180 
181 /**
182  * @tc.name: PublishNotification_00001
183  * @tc.desc: Test PublishNotification parameters.
184  * @tc.type: FUNC
185  * @tc.require: issueI5WRQ2
186  */
187 HWTEST_F(NotificationHelperTest, PublishNotification_00001, Function | SmallTest | Level1)
188 {
189     NotificationRequest request;
190     NotificationHelper notificationHelper;
191     ErrCode ret = notificationHelper.PublishNotification(request);
192     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
193 }
194 
195 /**
196  * @tc.name: PublishNotification_00003
197  * @tc.desc: Test PublishNotification parameters.
198  * @tc.type: FUNC
199  * @tc.require: issueI5WRQ2
200  */
201 HWTEST_F(NotificationHelperTest, PublishNotification_00003, Function | SmallTest | Level1)
202 {
203     std::string label = "Label";
204     NotificationRequest request;
205     NotificationHelper notificationHelper;
206     ErrCode ret = notificationHelper.PublishNotification(label, request);
207     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
208 }
209 
210 /**
211  * @tc.name: CancelNotification_00001
212  * @tc.desc: Test CancelNotification parameters.
213  * @tc.type: FUNC
214  * @tc.require: issueI5WRQ2
215  */
216 HWTEST_F(NotificationHelperTest, CancelNotification_00001, Function | SmallTest | Level1)
217 {
218     int32_t notificationId = 10;
219     NotificationHelper notificationHelper;
220     ErrCode ret = notificationHelper.CancelNotification(notificationId);
221     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
222 }
223 
224 /**
225  * @tc.name: CancelNotification_00002
226  * @tc.desc: Test CancelNotification parameters.
227  * @tc.type: FUNC
228  * @tc.require: issueI5WRQ2
229  */
230 HWTEST_F(NotificationHelperTest, CancelNotification_00002, Function | SmallTest | Level1)
231 {
232     std::string label = "Label";
233     int32_t notificationId = 10;
234     NotificationHelper notificationHelper;
235     ErrCode ret = notificationHelper.CancelNotification(label, notificationId);
236     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
237 }
238 
239 /**
240  * @tc.name: CancelAllNotifications_00001
241  * @tc.desc: Test CancelAllNotifications parameters.
242  * @tc.type: FUNC
243  * @tc.require: issueI5WRQ2
244  */
245 HWTEST_F(NotificationHelperTest, CancelAllNotifications_00001, Function | SmallTest | Level1)
246 {
247     NotificationHelper notificationHelper;
248     ErrCode ret = notificationHelper.CancelAllNotifications();
249     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
250 }
251 
252 /**
253  * @tc.name: CancelAsBundle_00001
254  * @tc.desc: Test CancelAsBundle parameters.
255  * @tc.type: FUNC
256  * @tc.require: issueI5WRQ2
257  */
258 HWTEST_F(NotificationHelperTest, CancelAsBundle_00001, Function | SmallTest | Level1)
259 {
260     int32_t notificationId = 10;
261     std::string representativeBundle = "RepresentativeBundle";
262     int32_t userId = 10;
263     NotificationHelper notificationHelper;
264     ErrCode ret = notificationHelper.CancelAsBundle(notificationId, representativeBundle, userId);
265     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
266 }
267 
268 /**
269  * @tc.name: CancelAsBundle_00002
270  * @tc.desc: Test CancelAsBundle parameters.
271  * @tc.type: FUNC
272  * @tc.require: issueI5WRQ2
273  */
274 HWTEST_F(NotificationHelperTest, CancelAsBundle_00002, Function | SmallTest | Level1)
275 {
276     NotificationBundleOption bundleOption;
277     int32_t notificationId = 10;
278     bundleOption.SetBundleName("bundlename");
279     bundleOption.SetUid(20);
280     NotificationHelper notificationHelper;
281     ErrCode ret = notificationHelper.CancelAsBundle(bundleOption, notificationId);
282     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
283 }
284 
285 /**
286  * @tc.name: GetActiveNotificationNums_00001
287  * @tc.desc: Test GetActiveNotificationNums parameters.
288  * @tc.type: FUNC
289  * @tc.require: issueI5WRQ2
290  */
291 HWTEST_F(NotificationHelperTest, GetActiveNotificationNums_00001, Function | SmallTest | Level1)
292 {
293     uint64_t num = 10;
294     NotificationHelper notificationHelper;
295     ErrCode ret = notificationHelper.GetActiveNotificationNums(num);
296     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
297 }
298 
299 /**
300  * @tc.name: GetActiveNotifications_00001
301  * @tc.desc: Test GetActiveNotifications parameters.
302  * @tc.type: FUNC
303  * @tc.require: issueI5WRQ2
304  */
305 HWTEST_F(NotificationHelperTest, GetActiveNotifications_00001, Function | SmallTest | Level1)
306 {
307     std::vector<sptr<NotificationRequest>> request;
308     NotificationHelper notificationHelper;
309     ErrCode ret = notificationHelper.GetActiveNotifications(request);
310     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
311 }
312 
313 /**
314  * @tc.name: CanPublishNotificationAsBundle_00001
315  * @tc.desc: Test CanPublishNotificationAsBundle parameters.
316  * @tc.type: FUNC
317  * @tc.require: issueI5WRQ2
318  */
319 HWTEST_F(NotificationHelperTest, CanPublishNotificationAsBundle_00001, Function | SmallTest | Level1)
320 {
321     std::string representativeBundle = "RepresentativeBundle";
322     bool canPublish = true;
323     NotificationHelper notificationHelper;
324     ErrCode ret = notificationHelper.CanPublishNotificationAsBundle(representativeBundle, canPublish);
325     EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION);
326 }
327 
328 /**
329  * @tc.name: PublishNotificationAsBundle_00001
330  * @tc.desc: Test PublishNotificationAsBundle parameters.
331  * @tc.type: FUNC
332  * @tc.require: issueI5WRQ2
333  */
334 HWTEST_F(NotificationHelperTest, PublishNotificationAsBundle_00001, Function | SmallTest | Level1)
335 {
336     std::string representativeBundle = "RepresentativeBundle";
337     NotificationRequest request;
338     NotificationHelper notificationHelper;
339     ErrCode ret = notificationHelper.PublishNotificationAsBundle(representativeBundle, request);
340     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
341 }
342 
343 /**
344  * @tc.name: SetNotificationBadgeNum_00001
345  * @tc.desc: Test SetNotificationBadgeNum parameters.
346  * @tc.type: FUNC
347  * @tc.require: issueI5WRQ2
348  */
349 HWTEST_F(NotificationHelperTest, SetNotificationBadgeNum_00001, Function | SmallTest | Level1)
350 {
351     NotificationHelper notificationHelper;
352     ErrCode ret = notificationHelper.SetNotificationBadgeNum();
353     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
354 }
355 
356 /**
357  * @tc.name: SetNotificationBadgeNum_00002
358  * @tc.desc: Test SetNotificationBadgeNum parameters.
359  * @tc.type: FUNC
360  * @tc.require: issueI5WRQ2
361  */
362 HWTEST_F(NotificationHelperTest, SetNotificationBadgeNum_00002, Function | SmallTest | Level1)
363 {
364     int32_t num = 10;
365     NotificationHelper notificationHelper;
366     ErrCode ret = notificationHelper.SetNotificationBadgeNum(num);
367     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
368 }
369 
370 /**
371  * @tc.name: IsAllowedNotify_00001
372  * @tc.desc: Test IsAllowedNotify parameters.
373  * @tc.type: FUNC
374  * @tc.require: issueI5WRQ2
375  */
376 HWTEST_F(NotificationHelperTest, IsAllowedNotify_00001, Function | SmallTest | Level1)
377 {
378     bool allowed = true;
379     NotificationHelper notificationHelper;
380     ErrCode ret = notificationHelper.IsAllowedNotify(allowed);
381     EXPECT_NE(ret, (int)ERR_ANS_NON_SYSTEM_APP);
382 }
383 
384 /**
385  * @tc.name: IsAllowedNotifySelf_00001
386  * @tc.desc: Test IsAllowedNotifySelf parameters.
387  * @tc.type: FUNC
388  * @tc.require: issueI5WRQ2
389  */
390 HWTEST_F(NotificationHelperTest, IsAllowedNotifySelf_00001, Function | SmallTest | Level1)
391 {
392     bool allowed = true;
393     NotificationHelper notificationHelper;
394     ErrCode ret = notificationHelper.IsAllowedNotifySelf(allowed);
395     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
396 }
397 
398 /**
399  * @tc.name: RequestEnableNotification_00001
400  * @tc.desc: Test RequestEnableNotification parameters.
401  * @tc.type: FUNC
402  * @tc.require: issueI5WRQ2
403  */
404 HWTEST_F(NotificationHelperTest, RequestEnableNotification_00001, Function | SmallTest | Level1)
405 {
406     std::string deviceId = "DeviceId";
407     NotificationHelper notificationHelper;
408     sptr<IRemoteObject> callerToken = nullptr;
409     sptr<AnsDialogHostClient> client = nullptr;
410     AnsDialogHostClient::CreateIfNullptr(client);
411     client = AnsDialogHostClient::GetInstance();
412     ErrCode ret = notificationHelper.RequestEnableNotification(deviceId, client, callerToken);
413     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
414 }
415 
416 /**
417  * @tc.name: HasNotificationPolicyAccessPermission_00001
418  * @tc.desc: Test HasNotificationPolicyAccessPermission parameters.
419  * @tc.type: FUNC
420  * @tc.require: issueI5WRQ2
421  */
422 HWTEST_F(NotificationHelperTest, HasNotificationPolicyAccessPermission_00001, Function | SmallTest | Level1)
423 {
424     bool hasPermission = true;
425     NotificationHelper notificationHelper;
426     ErrCode ret = notificationHelper.HasNotificationPolicyAccessPermission(hasPermission);
427     EXPECT_EQ(ret, (int)ERR_OK);
428 }
429 
430 /**
431  * @tc.name: GetBundleImportance_00001
432  * @tc.desc: Test GetBundleImportance parameters.
433  * @tc.type: FUNC
434  * @tc.require: issueI5WRQ2
435  */
436 HWTEST_F(NotificationHelperTest, GetBundleImportance_00001, Function | SmallTest | Level1)
437 {
438     NotificationSlot::NotificationLevel importance = NotificationSlot::NotificationLevel::LEVEL_NONE;
439     NotificationHelper notificationHelper;
440     ErrCode ret = notificationHelper.GetBundleImportance(importance);
441     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
442 }
443 
444 /**
445  * @tc.name: RemoveNotification_00001
446  * @tc.desc: Test RemoveNotification parameters.
447  * @tc.type: FUNC
448  * @tc.require: issueI5WRQ2
449  */
450 HWTEST_F(NotificationHelperTest, RemoveNotification_00001, Function | SmallTest | Level1)
451 {
452     std::string key = "Key";
453     int32_t removeReason = 2;
454     NotificationHelper notificationHelper;
455     ErrCode ret = notificationHelper.RemoveNotification(key, removeReason);
456     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
457 }
458 
459 /**
460  * @tc.name: RemoveNotification_00002
461  * @tc.desc: Test RemoveNotification parameters.
462  * @tc.type: FUNC
463  * @tc.require: issueI5WRQ2
464  */
465 HWTEST_F(NotificationHelperTest, RemoveNotification_00002, Function | SmallTest | Level1)
466 {
467     NotificationBundleOption bundleOption;
468     int32_t notificationId = 10;
469     std::string label = "Label";
470     int32_t removeReason = 2;
471     NotificationHelper notificationHelper;
472     ErrCode ret = notificationHelper.RemoveNotification(bundleOption, notificationId, label, removeReason);
473     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
474 }
475 
476 /**
477  * @tc.name: RemoveAllNotifications_00001
478  * @tc.desc: Test RemoveAllNotifications parameters.
479  * @tc.type: FUNC
480  * @tc.require: issueI5WRQ2
481  */
482 HWTEST_F(NotificationHelperTest, RemoveAllNotifications_00001, Function | SmallTest | Level1)
483 {
484     NotificationBundleOption bundleOption;
485     NotificationHelper notificationHelper;
486     ErrCode ret = notificationHelper.RemoveAllNotifications(bundleOption);
487     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
488 }
489 
490 /**
491  * @tc.name: RemoveNotificationsByBundle_00001
492  * @tc.desc: Test RemoveNotificationsByBundle parameters.
493  * @tc.type: FUNC
494  * @tc.require: issueI5WRQ2
495  */
496 HWTEST_F(NotificationHelperTest, RemoveNotificationsByBundle_00001, Function | SmallTest | Level1)
497 {
498     NotificationBundleOption bundleOption;
499     NotificationHelper notificationHelper;
500     ErrCode ret = notificationHelper.RemoveNotificationsByBundle(bundleOption);
501     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
502 }
503 
504 /**
505  * @tc.name: RemoveNotifications_00001
506  * @tc.desc: Test RemoveNotifications parameters.
507  * @tc.type: FUNC
508  * @tc.require: issueI5WRQ2
509  */
510 HWTEST_F(NotificationHelperTest, RemoveNotifications_00001, Function | SmallTest | Level1)
511 {
512     NotificationHelper notificationHelper;
513     ErrCode ret = notificationHelper.RemoveNotifications();
514     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
515 }
516 
517 /**
518  * @tc.name: GetNotificationSlotsForBundle_00001
519  * @tc.desc: Test GetNotificationSlotsForBundle parameters.
520  * @tc.type: FUNC
521  * @tc.require: issueI5WRQ2
522  */
523 HWTEST_F(NotificationHelperTest, GetNotificationSlotsForBundle_00001, Function | SmallTest | Level1)
524 {
525     NotificationBundleOption bundleOption;
526     std::vector<sptr<NotificationSlot>> slots;
527     NotificationHelper notificationHelper;
528     ErrCode ret = notificationHelper.GetNotificationSlotsForBundle(bundleOption, slots);
529     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
530 }
531 
532 /**
533  * @tc.name: UpdateNotificationSlots_00001
534  * @tc.desc: Test UpdateNotificationSlots parameters.
535  * @tc.type: FUNC
536  * @tc.require: issueI5WRQ2
537  */
538 HWTEST_F(NotificationHelperTest, UpdateNotificationSlots_00001, Function | SmallTest | Level1)
539 {
540     NotificationBundleOption bundleOption;
541     std::vector<sptr<NotificationSlot>> slots;
542     NotificationHelper notificationHelper;
543     ErrCode ret = notificationHelper.UpdateNotificationSlots(bundleOption, slots);
544     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
545 }
546 
547 /**
548  * @tc.name: GetAllActiveNotifications_00001
549  * @tc.desc: Test GetAllActiveNotifications parameters.
550  * @tc.type: FUNC
551  * @tc.require: issueI5WRQ2
552  */
553 HWTEST_F(NotificationHelperTest, GetAllActiveNotifications_00001, Function | SmallTest | Level1)
554 {
555     std::vector<sptr<Notification>> notification;
556     NotificationHelper notificationHelper;
557     ErrCode ret = notificationHelper.GetAllActiveNotifications(notification);
558     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
559 }
560 
561 /**
562  * @tc.name: GetAllActiveNotifications_00002
563  * @tc.desc: Test GetAllActiveNotifications parameters.
564  * @tc.type: FUNC
565  * @tc.require: issueI5WRQ2
566  */
567 HWTEST_F(NotificationHelperTest, GetAllActiveNotifications_00002, Function | SmallTest | Level1)
568 {
569     std::vector<std::string> key;
570     std::vector<sptr<Notification>> notification;
571     NotificationHelper notificationHelper;
572     ErrCode ret = notificationHelper.GetAllActiveNotifications(key, notification);
573     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
574 }
575 
576 /**
577  * @tc.name: IsAllowedNotify_00002
578  * @tc.desc: Test IsAllowedNotify parameters.
579  * @tc.type: FUNC
580  * @tc.require: issueI5WRQ2
581  */
582 HWTEST_F(NotificationHelperTest, IsAllowedNotify_00002, Function | SmallTest | Level1)
583 {
584     NotificationBundleOption bundleOption;
585     bool allowed = true;
586     NotificationHelper notificationHelper;
587     ErrCode ret = notificationHelper.IsAllowedNotify(bundleOption, allowed);
588     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
589 }
590 
591 /**
592  * @tc.name: SetNotificationsEnabledForAllBundles_00001
593  * @tc.desc: Test SetNotificationsEnabledForAllBundles parameters.
594  * @tc.type: FUNC
595  * @tc.require: issueI5WRQ2
596  */
597 HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00001, Function | SmallTest | Level1)
598 {
599     std::string deviceId = "DeviceId";
600     bool enabled = true;
601     NotificationHelper notificationHelper;
602     ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(deviceId, enabled);
603     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
604 }
605 
606 /**
607  * @tc.name: SetNotificationsEnabledForDefaultBundle_00001
608  * @tc.desc: Test SetNotificationsEnabledForDefaultBundle parameters.
609  * @tc.type: FUNC
610  * @tc.require: issueI5WRQ2
611  */
612 HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForDefaultBundle_00001, Function | SmallTest | Level1)
613 {
614     std::string deviceId = "DeviceId";
615     bool enabled = true;
616     NotificationHelper notificationHelper;
617     ErrCode ret = notificationHelper.SetNotificationsEnabledForDefaultBundle(deviceId, enabled);
618     EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION);
619 }
620 
621 /**
622  * @tc.name: SetShowBadgeEnabledForBundle_00001
623  * @tc.desc: Test SetShowBadgeEnabledForBundle parameters.
624  * @tc.type: FUNC
625  * @tc.require: issueI5WRQ2
626  */
627 HWTEST_F(NotificationHelperTest, SetShowBadgeEnabledForBundle_00001, Function | SmallTest | Level1)
628 {
629     NotificationBundleOption bundleOption;
630     bool enabled = true;
631     NotificationHelper notificationHelper;
632     ErrCode ret = notificationHelper.SetShowBadgeEnabledForBundle(bundleOption, enabled);
633     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
634 }
635 
636 /**
637  * @tc.name: GetShowBadgeEnabledForBundle_00001
638  * @tc.desc: Test GetShowBadgeEnabledForBundle parameters.
639  * @tc.type: FUNC
640  * @tc.require: issueI5WRQ2
641  */
642 HWTEST_F(NotificationHelperTest, GetShowBadgeEnabledForBundle_00001, Function | SmallTest | Level1)
643 {
644     NotificationBundleOption bundleOption;
645     bool enabled = true;
646     NotificationHelper notificationHelper;
647     ErrCode ret = notificationHelper.GetShowBadgeEnabledForBundle(bundleOption, enabled);
648     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
649 }
650 
651 /**
652  * @tc.name: GetShowBadgeEnabled_00001
653  * @tc.desc: Test GetShowBadgeEnabled parameters.
654  * @tc.type: FUNC
655  * @tc.require: issueI5WRQ2
656  */
657 HWTEST_F(NotificationHelperTest, GetShowBadgeEnabled_00001, Function | SmallTest | Level1)
658 {
659     bool enabled = true;
660     NotificationHelper notificationHelper;
661     ErrCode ret = notificationHelper.GetShowBadgeEnabled(enabled);
662     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
663 }
664 
665 /**
666  * @tc.name: CancelGroup_00001
667  * @tc.desc: Test CancelGroup parameters.
668  * @tc.type: FUNC
669  * @tc.require: issueI5WRQ2
670  */
671 HWTEST_F(NotificationHelperTest, CancelGroup_00001, Function | SmallTest | Level1)
672 {
673     std::string groupName = "GroupName";
674     NotificationHelper notificationHelper;
675     ErrCode ret = notificationHelper.CancelGroup(groupName);
676     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
677 }
678 
679 /**
680  * @tc.name: RemoveGroupByBundle_00001
681  * @tc.desc: Test RemoveGroupByBundle parameters.
682  * @tc.type: FUNC
683  * @tc.require: issueI5WRQ2
684  */
685 HWTEST_F(NotificationHelperTest, RemoveGroupByBundle_00001, Function | SmallTest | Level1)
686 {
687     NotificationBundleOption bundleOption;
688     std::string groupName = "GroupName";
689     NotificationHelper notificationHelper;
690     ErrCode ret = notificationHelper.RemoveGroupByBundle(bundleOption, groupName);
691     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
692 }
693 
694 /**
695  * @tc.name: SetDoNotDisturbDate_00001
696  * @tc.desc: Test SetDoNotDisturbDate parameters.
697  * @tc.type: FUNC
698  * @tc.require: issueI5WRQ2
699  */
700 HWTEST_F(NotificationHelperTest, SetDoNotDisturbDate_00001, Function | SmallTest | Level1)
701 {
702     NotificationDoNotDisturbDate doNotDisturbDate;
703     NotificationHelper notificationHelper;
704     ErrCode ret = notificationHelper.SetDoNotDisturbDate(doNotDisturbDate);
705     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
706 }
707 
708 /**
709  * @tc.name: GetDoNotDisturbDate_00001
710  * @tc.desc: Test GetDoNotDisturbDate parameters.
711  * @tc.type: FUNC
712  * @tc.require: issueI5WRQ2
713  */
714 HWTEST_F(NotificationHelperTest, GetDoNotDisturbDate_00001, Function | SmallTest | Level1)
715 {
716     NotificationDoNotDisturbDate doNotDisturbDate;
717     NotificationHelper notificationHelper;
718     ErrCode ret = notificationHelper.GetDoNotDisturbDate(doNotDisturbDate);
719     EXPECT_NE(ret, (int)ERR_ANS_NON_SYSTEM_APP);
720 }
721 
722 /**
723  * @tc.name: DoesSupportDoNotDisturbMode_00001
724  * @tc.desc: Test DoesSupportDoNotDisturbMode parameters.
725  * @tc.type: FUNC
726  * @tc.require: issueI5WRQ2
727  */
728 HWTEST_F(NotificationHelperTest, DoesSupportDoNotDisturbMode_00001, Function | SmallTest | Level1)
729 {
730     bool doesSupport = true;
731     NotificationHelper notificationHelper;
732     ErrCode ret = notificationHelper.DoesSupportDoNotDisturbMode(doesSupport);
733     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
734 }
735 
736 /**
737  * @tc.name: IsDistributedEnabled_00001
738  * @tc.desc: Test IsDistributedEnabled parameters.
739  * @tc.type: FUNC
740  * @tc.require: issueI5WRQ2
741  */
742 HWTEST_F(NotificationHelperTest, IsDistributedEnabled_00001, Function | SmallTest | Level1)
743 {
744     bool enabled = true;
745     NotificationHelper notificationHelper;
746     ErrCode ret = notificationHelper.IsDistributedEnabled(enabled);
747     EXPECT_EQ(ret, (int)ERR_OK);
748 }
749 
750 /**
751  * @tc.name: EnableDistributed_00001
752  * @tc.desc: Test EnableDistributed parameters.
753  * @tc.type: FUNC
754  * @tc.require: issueI5WRQ2
755  */
756 HWTEST_F(NotificationHelperTest, EnableDistributed_00001, Function | SmallTest | Level1)
757 {
758     bool enabled = true;
759     NotificationHelper notificationHelper;
760     notificationHelper.EnableDistributed(enabled);
761     EXPECT_EQ(enabled, true);
762 }
763 
764 /**
765  * @tc.name: EnableDistributedByBundle_00001
766  * @tc.desc: Test EnableDistributedByBundle parameters.
767  * @tc.type: FUNC
768  * @tc.require: issueI5WRQ2
769  */
770 HWTEST_F(NotificationHelperTest, EnableDistributedByBundle_00001, Function | SmallTest | Level1)
771 {
772     NotificationBundleOption bundleOption;
773     bool enabled = true;
774     NotificationHelper notificationHelper;
775     ErrCode ret = notificationHelper.EnableDistributedByBundle(bundleOption, enabled);
776     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
777 }
778 
779 /**
780  * @tc.name: EnableDistributedSelf_00001
781  * @tc.desc: Test EnableDistributedSelf parameters.
782  * @tc.type: FUNC
783  * @tc.require: issueI5WRQ2
784  */
785 HWTEST_F(NotificationHelperTest, EnableDistributedSelf_00001, Function | SmallTest | Level1)
786 {
787     bool enabled = true;
788     NotificationHelper notificationHelper;
789     ErrCode ret = notificationHelper.EnableDistributedSelf(enabled);
790     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
791 }
792 
793 /**
794  * @tc.name: IsDistributedEnableByBundle_00001
795  * @tc.desc: Test IsDistributedEnableByBundle parameters.
796  * @tc.type: FUNC
797  * @tc.require: issueI5WRQ2
798  */
799 HWTEST_F(NotificationHelperTest, IsDistributedEnableByBundle_00001, Function | SmallTest | Level1)
800 {
801     NotificationBundleOption bundleOption;
802     bool enabled = true;
803     NotificationHelper notificationHelper;
804     ErrCode ret = notificationHelper.IsDistributedEnableByBundle(bundleOption, enabled);
805     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
806 }
807 
808 /**
809  * @tc.name: GetDeviceRemindType_00001
810  * @tc.desc: Test GetDeviceRemindType parameters.
811  * @tc.type: FUNC
812  * @tc.require: issueI5WRQ2
813  */
814 HWTEST_F(NotificationHelperTest, GetDeviceRemindType_00001, Function | SmallTest | Level1)
815 {
816     NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND;
817     NotificationHelper notificationHelper;
818     ErrCode ret = notificationHelper.GetDeviceRemindType(remindType);
819     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
820 }
821 
822 /**
823  * @tc.name: PublishContinuousTaskNotification_00001
824  * @tc.desc: Test PublishContinuousTaskNotification parameters.
825  * @tc.type: FUNC
826  * @tc.require: issueI5WRQ2
827  */
828 HWTEST_F(NotificationHelperTest, PublishContinuousTaskNotification_00001, Function | SmallTest | Level1)
829 {
830     NotificationRequest request;
831     NotificationHelper notificationHelper;
832     ErrCode ret = notificationHelper.PublishContinuousTaskNotification(request);
833     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
834 }
835 
836 /**
837  * @tc.name: CancelContinuousTaskNotification_00001
838  * @tc.desc: Test CancelContinuousTaskNotification parameters.
839  * @tc.type: FUNC
840  * @tc.require: issueI5WRQ2
841  */
842 HWTEST_F(NotificationHelperTest, CancelContinuousTaskNotification_00001, Function | SmallTest | Level1)
843 {
844     std::string label = "label";
845     int32_t notificationId = 10;
846     NotificationHelper notificationHelper;
847     ErrCode ret = notificationHelper.CancelContinuousTaskNotification(label, notificationId);
848     EXPECT_EQ(ret, (int)ERR_OK);
849 }
850 
851 /**
852  * @tc.name: IsSupportTemplate_00001
853  * @tc.desc: Test IsSupportTemplate parameters.
854  * @tc.type: FUNC
855  * @tc.require: issueI5WRQ2
856  */
857 HWTEST_F(NotificationHelperTest, IsSupportTemplate_00001, Function | SmallTest | Level1)
858 {
859     std::string templateName = "TemplateName";
860     bool support = true;
861     NotificationHelper notificationHelper;
862     ErrCode ret = notificationHelper.IsSupportTemplate(templateName, support);
863     EXPECT_EQ(ret, (int)ERR_OK);
864 }
865 
866 /**
867  * @tc.name: SetNotificationsEnabledForAllBundles_00002
868  * @tc.desc: Test SetNotificationsEnabledForAllBundles parameters.
869  * @tc.type: FUNC
870  * @tc.require: issueI5WRQ2
871  */
872 HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00002, Function | SmallTest | Level1)
873 {
874     int32_t userId = 10;
875     bool enabled = true;
876     NotificationHelper notificationHelper;
877     ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(userId, enabled);
878     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
879 }
880 
881 /**
882  * @tc.name: IsSupportTemplate_00002
883  * @tc.desc: Test IsSupportTemplate parameters.
884  * @tc.type: FUNC
885  * @tc.require: issueI5WRQ2
886  */
887 HWTEST_F(NotificationHelperTest, IsSupportTemplate_00002, Function | SmallTest | Level1)
888 {
889     std::string templateName = "TemplateName";
890     bool support = true;
891     NotificationHelper notificationHelper;
892     ErrCode ret = notificationHelper.IsSupportTemplate(templateName, support);
893     EXPECT_EQ(ret, (int)ERR_OK);
894 }
895 
896 /**
897  * @tc.name: IsAllowedNotify_00004
898  * @tc.desc: Test IsAllowedNotify parameters.
899  * @tc.type: FUNC
900  * @tc.require: issueI5WRQ2
901  */
902 HWTEST_F(NotificationHelperTest, IsAllowedNotify_00004, Function | SmallTest | Level1)
903 {
904     int32_t userId = 10;
905     bool allowed = true;
906     NotificationHelper notificationHelper;
907     ErrCode ret = notificationHelper.IsAllowedNotify(userId, allowed);
908     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
909 }
910 
911 /**
912  * @tc.name: SetNotificationsEnabledForAllBundles_00003
913  * @tc.desc: Test SetNotificationsEnabledForAllBundles parameters.
914  * @tc.type: FUNC
915  * @tc.require: issueI5WRQ2
916  */
917 HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00003, Function | SmallTest | Level1)
918 {
919     int32_t userId = 10;
920     bool enabled = true;
921     NotificationHelper notificationHelper;
922     ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(userId, enabled);
923     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
924 }
925 
926 /**
927  * @tc.name: RemoveNotifications_00002
928  * @tc.desc: Test RemoveNotifications parameters.
929  * @tc.type: FUNC
930  * @tc.require: issueI5WRQ2
931  */
932 HWTEST_F(NotificationHelperTest, RemoveNotifications_00002, Function | SmallTest | Level1)
933 {
934     int32_t userId = 10;
935     NotificationHelper notificationHelper;
936     ErrCode ret = notificationHelper.RemoveNotifications(userId);
937     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
938 }
939 
940 /**
941  * @tc.name: SetDoNotDisturbDate_00002
942  * @tc.desc: Test SetDoNotDisturbDate parameters.
943  * @tc.type: FUNC
944  * @tc.require: issueI5WRQ2
945  */
946 HWTEST_F(NotificationHelperTest, SetDoNotDisturbDate_00002, Function | SmallTest | Level1)
947 {
948     int32_t userId = 10;
949     NotificationDoNotDisturbDate doNotDisturbDate;
950     NotificationHelper notificationHelper;
951     ErrCode ret = notificationHelper.SetDoNotDisturbDate(userId, doNotDisturbDate);
952     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
953 }
954 
955 /**
956  * @tc.name: GetDoNotDisturbDate_00002
957  * @tc.desc: Test GetDoNotDisturbDate parameters.
958  * @tc.type: FUNC
959  * @tc.require: issueI5WRQ2
960  */
961 HWTEST_F(NotificationHelperTest, GetDoNotDisturbDate_00002, Function | SmallTest | Level1)
962 {
963     int32_t userId = 10;
964     NotificationDoNotDisturbDate doNotDisturbDate;
965     NotificationHelper notificationHelper;
966     ErrCode ret = notificationHelper.GetDoNotDisturbDate(userId, doNotDisturbDate);
967     EXPECT_NE(ret, (int)ERR_ANS_NON_SYSTEM_APP);
968 }
969 
970 /**
971  * @tc.name: SetEnabledForBundleSlot_00001
972  * @tc.desc: Test SetEnabledForBundleSlot parameters.
973  * @tc.type: FUNC
974  * @tc.require: issueI5WRQ2
975  */
976 HWTEST_F(NotificationHelperTest, SetEnabledForBundleSlot_00001, Function | SmallTest | Level1)
977 {
978     NotificationBundleOption bundleOption;
979     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER;
980     bool enabled = true;
981     NotificationHelper notificationHelper;
982     ErrCode ret = notificationHelper.SetEnabledForBundleSlot(bundleOption, slotType, enabled, false);
983     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
984 }
985 
986 /**
987  * @tc.name: GetEnabledForBundleSlot_00001
988  * @tc.desc: Test GetEnabledForBundleSlot parameters.
989  * @tc.type: FUNC
990  * @tc.require: issueI5WRQ2
991  */
992 HWTEST_F(NotificationHelperTest, GetEnabledForBundleSlot_00001, Function | SmallTest | Level1)
993 {
994     NotificationBundleOption bundleOption;
995     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER;
996     bool enabled = true;
997     NotificationHelper notificationHelper;
998     ErrCode ret = notificationHelper.GetEnabledForBundleSlot(bundleOption, slotType, enabled);
999     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
1000 }
1001 
1002 /**
1003  * @tc.name: SetSyncNotificationEnabledWithoutApp_00001
1004  * @tc.desc: Test SetSyncNotificationEnabledWithoutApp parameters.
1005  * @tc.type: FUNC
1006  * @tc.require: issueI5WRQ2
1007  */
1008 HWTEST_F(NotificationHelperTest, SetSyncNotificationEnabledWithoutApp_00001, Function | SmallTest | Level1)
1009 {
1010     int32_t userId = 10;
1011     bool enabled = true;
1012     NotificationHelper notificationHelper;
1013     notificationHelper.SetSyncNotificationEnabledWithoutApp(userId, enabled);
1014     EXPECT_EQ(enabled, true);
1015 }
1016 
1017 /**
1018  * @tc.name: GetSyncNotificationEnabledWithoutApp_00001
1019  * @tc.desc: Test GetSyncNotificationEnabledWithoutApp parameters.
1020  * @tc.type: FUNC
1021  * @tc.require: issueI5WRQ2
1022  */
1023 HWTEST_F(NotificationHelperTest, GetSyncNotificationEnabledWithoutApp_00001, Function | SmallTest | Level1)
1024 {
1025     int32_t userId = 10;
1026     bool enabled = true;
1027     NotificationHelper notificationHelper;
1028     ErrCode ret = notificationHelper.GetSyncNotificationEnabledWithoutApp(userId, enabled);
1029     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
1030 }
1031 
1032 /**
1033  * @tc.name: SetType_00001
1034  * @tc.desc: Test SetType_00001 parameters.
1035  * @tc.type: FUNC
1036  * @tc.require: issueI5WRQ2
1037  */
1038 HWTEST_F(NotificationHelperTest, SetType_00001, Function | SmallTest | Level1)
1039 {
1040     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SOCIAL_COMMUNICATION;
1041     auto slot1 = std::make_shared<NotificationSlot>(slotType);
1042     EXPECT_NE(slot1, nullptr);
1043 
1044     slotType = NotificationConstant::SlotType::SERVICE_REMINDER;
1045     auto slot2 = std::make_shared<NotificationSlot>(slotType);
1046     EXPECT_NE(slot2, nullptr);
1047 
1048     slotType = NotificationConstant::SlotType::CONTENT_INFORMATION;
1049     auto slot3 = std::make_shared<NotificationSlot>(slotType);
1050     EXPECT_NE(slot3, nullptr);
1051 
1052     slotType = NotificationConstant::SlotType::OTHER;
1053     auto slot4 = std::make_shared<NotificationSlot>(slotType);
1054     EXPECT_NE(slot4, nullptr);
1055 }
1056 
1057 /**
1058  * @tc.name: GetAllNotificationEnabledBundles_00001
1059  * @tc.desc: Test GetAllNotificationEnabledBundles parameters.
1060  * @tc.type: FUNC
1061  * @tc.require: issueI92VGR
1062  */
1063 HWTEST_F(NotificationHelperTest, GetAllNotificationEnabledBundles_00001, Function | SmallTest | Level1)
1064 {
1065     std::vector<NotificationBundleOption> bundleOption;
1066     NotificationHelper notificationHelper;
1067     ErrCode ret = notificationHelper.GetAllNotificationEnabledBundles(bundleOption);
1068     EXPECT_EQ(ret, (int)ERR_ANS_NON_SYSTEM_APP);
1069 }
1070 
1071 /**
1072  * @tc.name: GetActiveNotificationByFilter_00001
1073  * @tc.desc: Test GetActiveNotificationByFilter parameters.
1074  * @tc.type: FUNC
1075  * @tc.require: issueI5WRQ2
1076  */
1077 HWTEST_F(NotificationHelperTest, GetActiveNotificationByFilter_00001, Function | SmallTest | Level1)
1078 {
1079     LiveViewFilter filter;
1080     sptr<NotificationRequest> request;
1081     NotificationHelper notificationHelper;
1082     ErrCode ret = notificationHelper.GetActiveNotificationByFilter(filter, request);
1083     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
1084 }
1085 
1086 /**
1087  * @tc.name: SetSmartReminderEnabled_0100
1088  * @tc.desc: test SetSmartReminderEnabled with parameters
1089  * @tc.type: FUNC
1090  */
1091 HWTEST_F(NotificationHelperTest, SetSmartReminderEnabled_0100, TestSize.Level1)
1092 {
1093     std::string deviceType = "testDeviceType";
1094     NotificationHelper notificationHelper;
1095     ErrCode ret = notificationHelper.SetSmartReminderEnabled(deviceType, true);
1096     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1097 }
1098 
1099 /**
1100  * @tc.name: SetSmartReminderEnabled_0200
1101  * @tc.desc: test SetSmartReminderEnabled with parameters, expect errorCode ERR_ANS_INVALID_PARAM.
1102  * @tc.type: FUNC
1103  */
1104 HWTEST_F(NotificationHelperTest, SetSmartReminderEnabled_0200, TestSize.Level1)
1105 {
1106     std::string deviceType = "";
1107     NotificationHelper notificationHelper;
1108     ErrCode ret = notificationHelper.SetSmartReminderEnabled(deviceType, true);
1109     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1110 }
1111 
1112 /**
1113  * @tc.name: IsSmartReminderEnabled_0100
1114  * @tc.desc: test IsSmartReminderEnabled with parameters
1115  * @tc.type: FUNC
1116  */
1117 HWTEST_F(NotificationHelperTest, IsSmartReminderEnabled_0100, TestSize.Level1)
1118 {
1119     std::string deviceType = "testDeviceType1111";
1120     NotificationHelper notificationHelper;
1121     bool enable = true;
1122     ErrCode ret = notificationHelper.IsSmartReminderEnabled(deviceType, enable);
1123     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1124 }
1125 
1126 /**
1127  * @tc.name: SetBadgeNumberByBundle_0100
1128  * @tc.desc: test SetBadgeNumberByBundle with invalid bundleOption, expect errorCode ERR_ANS_INVALID_PARAM.
1129  * @tc.type: FUNC
1130  */
1131 HWTEST_F(NotificationHelperTest, SetBadgeNumberByBundle_0100, TestSize.Level1)
1132 {
1133     NotificationBundleOption bundleOption;
1134     int32_t badgeNumber = 0;
1135     NotificationHelper notificationHelper;
1136     ErrCode ret = notificationHelper.SetBadgeNumberByBundle(bundleOption, badgeNumber);
1137     EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM);
1138 }
1139 
1140 /**
1141  * @tc.name: SetBadgeNumberByBundle_0200
1142  * @tc.desc: test SetBadgeNumberByBundle with invalid bundle name, expect errorCode ERR_ANS_INVALID_BUNDLE.
1143  * @tc.type: FUNC
1144  */
1145 HWTEST_F(NotificationHelperTest, SetBadgeNumberByBundle_0200, TestSize.Level1)
1146 {
1147     NotificationBundleOption bundleOption;
1148     std::string bundleName = "bundleName";
1149     bundleOption.SetBundleName(bundleName);
1150     int32_t badgeNumber = 0;
1151     NotificationHelper notificationHelper;
1152     ErrCode ret = notificationHelper.SetBadgeNumberByBundle(bundleOption, badgeNumber);
1153     EXPECT_EQ(ret, ERR_ANS_INVALID_BUNDLE);
1154 }
1155 
1156 /**
1157  * @tc.name: SetDistributedEnabledByBundle_0100
1158  * @tc.desc: test SetDistributedEnabledByBundle with parameters
1159  * @tc.type: FUNC
1160  */
1161 HWTEST_F(NotificationHelperTest, SetDistributedEnabledByBundle_0100, TestSize.Level1)
1162 {
1163     NotificationBundleOption bundleOption;
1164     std::string bundleName = "bundleName";
1165     bundleOption.SetBundleName(bundleName);
1166     bundleOption.SetUid(1);
1167     std::string deviceType = "testDeviceType";
1168     NotificationHelper notificationHelper;
1169     ErrCode ret = notificationHelper.SetDistributedEnabledByBundle(bundleOption, deviceType, true);
1170     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1171 }
1172 
1173 /**
1174  * @tc.name: SetDistributedEnabledByBundle_0200
1175  * @tc.desc: test SetDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM.
1176  * @tc.type: FUNC
1177  */
1178 HWTEST_F(NotificationHelperTest, SetDistributedEnabledByBundle_0200, TestSize.Level1)
1179 {
1180     NotificationBundleOption bundleOption;
1181     std::string deviceType = "testDeviceType";
1182     NotificationHelper notificationHelper;
1183     ErrCode ret = notificationHelper.SetDistributedEnabledByBundle(bundleOption, deviceType, true);
1184     EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM);
1185 }
1186 
1187 /**
1188  * @tc.name: IsDistributedEnabledByBundle_0100
1189  * @tc.desc: test IsDistributedEnabledByBundle with parameters
1190  * @tc.type: FUNC
1191  */
1192 HWTEST_F(NotificationHelperTest, IsDistributedEnabledByBundle_0100, TestSize.Level1)
1193 {
1194     NotificationBundleOption bundleOption;
1195     std::string bundleName = "bundleName";
1196     bundleOption.SetBundleName(bundleName);
1197     bundleOption.SetUid(1);
1198     std::string deviceType = "testDeviceType1111";
1199     NotificationHelper notificationHelper;
1200     bool enable = true;
1201     ErrCode ret = notificationHelper.IsDistributedEnabledByBundle(bundleOption, deviceType, enable);
1202     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1203 }
1204 
1205 /**
1206  * @tc.name: IsDistributedEnabledByBundle_0200
1207  * @tc.desc: test IsDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM.
1208  * @tc.type: FUNC
1209  */
1210 HWTEST_F(NotificationHelperTest, IsDistributedEnabledByBundle_0200, TestSize.Level1)
1211 {
1212     NotificationBundleOption bundleOption;
1213     bundleOption.SetBundleName("");
1214     bundleOption.SetUid(1);
1215     std::string deviceType = "testDeviceType";
1216     NotificationHelper notificationHelper;
1217     bool enable = true;
1218     ErrCode ret = notificationHelper.IsDistributedEnabledByBundle(bundleOption, deviceType, enable);
1219     EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM);
1220 }
1221 
1222 /**
1223  * @tc.name: AddDoNotDisturbProfiles_0100
1224  * @tc.desc: test AddDoNotDisturbProfiles when profiles is empty.
1225  * @tc.type: FUNC
1226  */
1227 HWTEST_F(NotificationHelperTest, AddDoNotDisturbProfiles_0100, TestSize.Level1)
1228 {
1229     NotificationHelper notificationHelper;
1230     std::vector<sptr<NotificationDoNotDisturbProfile>> profiles;
1231     profiles.clear();
1232     ErrCode ret = notificationHelper.AddDoNotDisturbProfiles(profiles);
1233     EXPECT_EQ(ERR_ANS_INVALID_PARAM, ret);
1234 }
1235 
1236 /**
1237  * @tc.name: RemoveDoNotDisturbProfiles_0100
1238  * @tc.desc: test RemoveDoNotDisturbProfiles when profiles is empty.
1239  * @tc.type: FUNC
1240  */
1241 HWTEST_F(NotificationHelperTest, RemoveDoNotDisturbProfiles_0100, TestSize.Level1)
1242 {
1243     NotificationHelper notificationHelper;
1244     std::vector<sptr<NotificationDoNotDisturbProfile>> profiles;
1245     profiles.clear();
1246     ErrCode ret = notificationHelper.RemoveDoNotDisturbProfiles(profiles);
1247     EXPECT_EQ(ERR_ANS_INVALID_PARAM, ret);
1248 }
1249 
1250 /**
1251  * @tc.name: SetTargetDeviceStatus_0100
1252  * @tc.desc: test SetTargetDeviceStatus with parameters
1253  * @tc.type: FUNC
1254  */
1255 HWTEST_F(NotificationHelperTest, SetTargetDeviceStatus_0100, TestSize.Level1)
1256 {
1257     std::string deviceType = "testDeviceType";
1258     int32_t status = 1;
1259     NotificationHelper notificationHelper;
1260     ErrCode ret = notificationHelper.SetTargetDeviceStatus(deviceType, status);
1261     EXPECT_EQ(ret, ERR_OK);
1262 }
1263 
1264 /**
1265  * @tc.name: RegisterSwingCallback_0100
1266  * @tc.desc: test RegisterSwingCallback with parameters
1267  * @tc.type: FUNC
1268  */
1269 HWTEST_F(NotificationHelperTest, RegisterSwingCallback_0100, TestSize.Level1)
1270 {
1271 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
1272     std::function<void(bool, int)> swingCbFunc =
1273         std::bind(&NotificationHelperTest::UpdateStatuts, this, std::placeholders::_1, std::placeholders::_2);
1274     EXPECT_TRUE(swingCbFunc);
1275     NotificationHelper notificationHelper;
1276     ErrCode ret = notificationHelper.RegisterSwingCallback(swingCbFunc);
1277     EXPECT_EQ(ret, ERR_OK);
1278 #endif
1279 }
1280 
1281 /**
1282  * @tc.name: IsNeedSilentInDoNotDisturbMode_00001
1283  * @tc.desc: Test IsNeedSilentInDoNotDisturbMode parameters.
1284  * @tc.type: FUNC
1285  * @tc.require: issueI5WRQ2
1286  */
1287 HWTEST_F(NotificationHelperTest, IsNeedSilentInDoNotDisturbMode_00001, Function | SmallTest | Level1)
1288 {
1289     std::string phoneNumber = "11111111111";
1290     int32_t callerType = 0;
1291     NotificationHelper notificationHelper;
1292     ErrCode ret = notificationHelper.IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType);
1293     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
1294 }
1295 
1296 /**
1297  * @tc.name: UpdateNotificationTimerByUid_00001
1298  * @tc.desc: Test UpdateNotificationTimerByUid.
1299  * @tc.type: FUNC
1300  */
1301 HWTEST_F(NotificationHelperTest, UpdateNotificationTimerByUid_00001, Function | SmallTest | Level1)
1302 {
1303     int32_t uid = 20099999;
1304     bool isPaused = true;
1305     NotificationHelper notificationHelper;
1306     ErrCode ret = notificationHelper.UpdateNotificationTimerByUid(uid, isPaused);
1307     EXPECT_EQ(ret, (int)ERR_OK);
1308 }
1309 
1310 /**
1311  * @tc.name: DisableNotificationFeature_00001
1312  * @tc.desc: Test DisableNotificationFeature.
1313  * @tc.type: FUNC
1314  */
1315 HWTEST_F(NotificationHelperTest, DisableNotificationFeature_00001, Function | SmallTest | Level1)
1316 {
1317     NotificationDisable notificationDisable;
1318     NotificationHelper notificationHelper;
1319     ErrCode ret = notificationHelper.DisableNotificationFeature(notificationDisable);
1320     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1321 }
1322 
1323 /**
1324  * @tc.name: SilentReminderEnabled_00001
1325  * @tc.desc: Test SetSilentReminderEnabled.
1326  * @tc.type: FUNC
1327  */
1328 HWTEST_F(NotificationHelperTest, SetSilentReminderEnabled_00001, Function | SmallTest | Level1)
1329 {
1330     NotificationHelper notificationHelper;
1331     NotificationBundleOption bo;
1332     bo.SetBundleName("bundleName");
1333     bo.SetUid(1);
1334     ErrCode ret = notificationHelper.SetSilentReminderEnabled(bo, true);
1335     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1336 }
1337 
1338 /**
1339  * @tc.name: SilentReminderEnabled_00002
1340  * @tc.desc: Test SetSilentReminderEnabled.
1341  * @tc.type: FUNC
1342  */
1343 HWTEST_F(NotificationHelperTest, SetSilentReminderEnabled_00002, Function | SmallTest | Level1)
1344 {
1345     NotificationHelper notificationHelper;
1346     NotificationBundleOption bo;
1347     bo.SetUid(1);
1348     ErrCode ret = notificationHelper.SetSilentReminderEnabled(bo, true);
1349     EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM);
1350 }
1351 
1352 /**
1353  * @tc.name: IsSilentReminderEnabled_00001
1354  * @tc.desc: Test SetSilentReminderEnabled.
1355  * @tc.type: FUNC
1356  */
1357 HWTEST_F(NotificationHelperTest, IsSilentReminderEnabled_00001, Function | SmallTest | Level1)
1358 {
1359     NotificationHelper notificationHelper;
1360     NotificationBundleOption bo;
1361     bo.SetUid(1);
1362     int32_t enableStatus = 0;
1363     ErrCode ret = notificationHelper.IsSilentReminderEnabled(bo, enableStatus);
1364     EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM);
1365 }
1366 
1367 /**
1368  * @tc.name: GetDistributedDevicelist_0100
1369  * @tc.desc: Test GetDistributedDevicelist.
1370  * @tc.type: FUNC
1371  */
1372 HWTEST_F(NotificationHelperTest, GetDistributedDevicelist_0100, Function | SmallTest | Level1)
1373 {
1374     std::vector<std::string> deviceTypes;
1375     NotificationHelper notificationHelper;
1376     ErrCode ret = notificationHelper.GetDistributedDevicelist(deviceTypes);
1377     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1378 }
1379 }
1380 }
1381