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: SetNotificationAgent_00001
315  * @tc.desc: Test SetNotificationAgent parameters.
316  * @tc.type: FUNC
317  * @tc.require: issueI5WRQ2
318  */
319 HWTEST_F(NotificationHelperTest, SetNotificationAgent_00001, Function | SmallTest | Level1)
320 {
321     std::string agent = "Agent";
322     NotificationHelper notificationHelper;
323     ErrCode ret = notificationHelper.SetNotificationAgent(agent);
324     EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION);
325 }
326 
327 /**
328  * @tc.name: GetNotificationAgent_00001
329  * @tc.desc: Test GetNotificationAgent parameters.
330  * @tc.type: FUNC
331  * @tc.require: issueI5WRQ2
332  */
333 HWTEST_F(NotificationHelperTest, GetNotificationAgent_00001, Function | SmallTest | Level1)
334 {
335     std::string agent = "Agent";
336     NotificationHelper notificationHelper;
337     ErrCode ret = notificationHelper.GetNotificationAgent(agent);
338     EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION);
339 }
340 
341 /**
342  * @tc.name: CanPublishNotificationAsBundle_00001
343  * @tc.desc: Test CanPublishNotificationAsBundle parameters.
344  * @tc.type: FUNC
345  * @tc.require: issueI5WRQ2
346  */
347 HWTEST_F(NotificationHelperTest, CanPublishNotificationAsBundle_00001, Function | SmallTest | Level1)
348 {
349     std::string representativeBundle = "RepresentativeBundle";
350     bool canPublish = true;
351     NotificationHelper notificationHelper;
352     ErrCode ret = notificationHelper.CanPublishNotificationAsBundle(representativeBundle, canPublish);
353     EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION);
354 }
355 
356 /**
357  * @tc.name: PublishNotificationAsBundle_00001
358  * @tc.desc: Test PublishNotificationAsBundle parameters.
359  * @tc.type: FUNC
360  * @tc.require: issueI5WRQ2
361  */
362 HWTEST_F(NotificationHelperTest, PublishNotificationAsBundle_00001, Function | SmallTest | Level1)
363 {
364     std::string representativeBundle = "RepresentativeBundle";
365     NotificationRequest request;
366     NotificationHelper notificationHelper;
367     ErrCode ret = notificationHelper.PublishNotificationAsBundle(representativeBundle, request);
368     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
369 }
370 
371 /**
372  * @tc.name: SetNotificationBadgeNum_00001
373  * @tc.desc: Test SetNotificationBadgeNum parameters.
374  * @tc.type: FUNC
375  * @tc.require: issueI5WRQ2
376  */
377 HWTEST_F(NotificationHelperTest, SetNotificationBadgeNum_00001, Function | SmallTest | Level1)
378 {
379     NotificationHelper notificationHelper;
380     ErrCode ret = notificationHelper.SetNotificationBadgeNum();
381     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
382 }
383 
384 /**
385  * @tc.name: SetNotificationBadgeNum_00002
386  * @tc.desc: Test SetNotificationBadgeNum parameters.
387  * @tc.type: FUNC
388  * @tc.require: issueI5WRQ2
389  */
390 HWTEST_F(NotificationHelperTest, SetNotificationBadgeNum_00002, Function | SmallTest | Level1)
391 {
392     int32_t num = 10;
393     NotificationHelper notificationHelper;
394     ErrCode ret = notificationHelper.SetNotificationBadgeNum(num);
395     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
396 }
397 
398 /**
399  * @tc.name: IsAllowedNotify_00001
400  * @tc.desc: Test IsAllowedNotify parameters.
401  * @tc.type: FUNC
402  * @tc.require: issueI5WRQ2
403  */
404 HWTEST_F(NotificationHelperTest, IsAllowedNotify_00001, Function | SmallTest | Level1)
405 {
406     bool allowed = true;
407     NotificationHelper notificationHelper;
408     ErrCode ret = notificationHelper.IsAllowedNotify(allowed);
409     EXPECT_NE(ret, (int)ERR_ANS_NON_SYSTEM_APP);
410 }
411 
412 /**
413  * @tc.name: IsAllowedNotifySelf_00001
414  * @tc.desc: Test IsAllowedNotifySelf parameters.
415  * @tc.type: FUNC
416  * @tc.require: issueI5WRQ2
417  */
418 HWTEST_F(NotificationHelperTest, IsAllowedNotifySelf_00001, Function | SmallTest | Level1)
419 {
420     bool allowed = true;
421     NotificationHelper notificationHelper;
422     ErrCode ret = notificationHelper.IsAllowedNotifySelf(allowed);
423     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
424 }
425 
426 /**
427  * @tc.name: RequestEnableNotification_00001
428  * @tc.desc: Test RequestEnableNotification parameters.
429  * @tc.type: FUNC
430  * @tc.require: issueI5WRQ2
431  */
432 HWTEST_F(NotificationHelperTest, RequestEnableNotification_00001, Function | SmallTest | Level1)
433 {
434     std::string deviceId = "DeviceId";
435     NotificationHelper notificationHelper;
436     sptr<IRemoteObject> callerToken = nullptr;
437     sptr<AnsDialogHostClient> client = nullptr;
438     AnsDialogHostClient::CreateIfNullptr(client);
439     client = AnsDialogHostClient::GetInstance();
440     ErrCode ret = notificationHelper.RequestEnableNotification(deviceId, client, callerToken);
441     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
442 }
443 
444 /**
445  * @tc.name: HasNotificationPolicyAccessPermission_00001
446  * @tc.desc: Test HasNotificationPolicyAccessPermission parameters.
447  * @tc.type: FUNC
448  * @tc.require: issueI5WRQ2
449  */
450 HWTEST_F(NotificationHelperTest, HasNotificationPolicyAccessPermission_00001, Function | SmallTest | Level1)
451 {
452     bool hasPermission = true;
453     NotificationHelper notificationHelper;
454     ErrCode ret = notificationHelper.HasNotificationPolicyAccessPermission(hasPermission);
455     EXPECT_EQ(ret, (int)ERR_OK);
456 }
457 
458 /**
459  * @tc.name: GetBundleImportance_00001
460  * @tc.desc: Test GetBundleImportance parameters.
461  * @tc.type: FUNC
462  * @tc.require: issueI5WRQ2
463  */
464 HWTEST_F(NotificationHelperTest, GetBundleImportance_00001, Function | SmallTest | Level1)
465 {
466     NotificationSlot::NotificationLevel importance = NotificationSlot::NotificationLevel::LEVEL_NONE;
467     NotificationHelper notificationHelper;
468     ErrCode ret = notificationHelper.GetBundleImportance(importance);
469     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
470 }
471 
472 /**
473  * @tc.name: RemoveNotification_00001
474  * @tc.desc: Test RemoveNotification parameters.
475  * @tc.type: FUNC
476  * @tc.require: issueI5WRQ2
477  */
478 HWTEST_F(NotificationHelperTest, RemoveNotification_00001, Function | SmallTest | Level1)
479 {
480     std::string key = "Key";
481     int32_t removeReason = 2;
482     NotificationHelper notificationHelper;
483     ErrCode ret = notificationHelper.RemoveNotification(key, removeReason);
484     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
485 }
486 
487 /**
488  * @tc.name: RemoveNotification_00002
489  * @tc.desc: Test RemoveNotification parameters.
490  * @tc.type: FUNC
491  * @tc.require: issueI5WRQ2
492  */
493 HWTEST_F(NotificationHelperTest, RemoveNotification_00002, Function | SmallTest | Level1)
494 {
495     NotificationBundleOption bundleOption;
496     int32_t notificationId = 10;
497     std::string label = "Label";
498     int32_t removeReason = 2;
499     NotificationHelper notificationHelper;
500     ErrCode ret = notificationHelper.RemoveNotification(bundleOption, notificationId, label, removeReason);
501     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
502 }
503 
504 /**
505  * @tc.name: RemoveAllNotifications_00001
506  * @tc.desc: Test RemoveAllNotifications parameters.
507  * @tc.type: FUNC
508  * @tc.require: issueI5WRQ2
509  */
510 HWTEST_F(NotificationHelperTest, RemoveAllNotifications_00001, Function | SmallTest | Level1)
511 {
512     NotificationBundleOption bundleOption;
513     NotificationHelper notificationHelper;
514     ErrCode ret = notificationHelper.RemoveAllNotifications(bundleOption);
515     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
516 }
517 
518 /**
519  * @tc.name: RemoveNotificationsByBundle_00001
520  * @tc.desc: Test RemoveNotificationsByBundle parameters.
521  * @tc.type: FUNC
522  * @tc.require: issueI5WRQ2
523  */
524 HWTEST_F(NotificationHelperTest, RemoveNotificationsByBundle_00001, Function | SmallTest | Level1)
525 {
526     NotificationBundleOption bundleOption;
527     NotificationHelper notificationHelper;
528     ErrCode ret = notificationHelper.RemoveNotificationsByBundle(bundleOption);
529     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
530 }
531 
532 /**
533  * @tc.name: RemoveNotifications_00001
534  * @tc.desc: Test RemoveNotifications parameters.
535  * @tc.type: FUNC
536  * @tc.require: issueI5WRQ2
537  */
538 HWTEST_F(NotificationHelperTest, RemoveNotifications_00001, Function | SmallTest | Level1)
539 {
540     NotificationHelper notificationHelper;
541     ErrCode ret = notificationHelper.RemoveNotifications();
542     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
543 }
544 
545 /**
546  * @tc.name: GetNotificationSlotsForBundle_00001
547  * @tc.desc: Test GetNotificationSlotsForBundle parameters.
548  * @tc.type: FUNC
549  * @tc.require: issueI5WRQ2
550  */
551 HWTEST_F(NotificationHelperTest, GetNotificationSlotsForBundle_00001, Function | SmallTest | Level1)
552 {
553     NotificationBundleOption bundleOption;
554     std::vector<sptr<NotificationSlot>> slots;
555     NotificationHelper notificationHelper;
556     ErrCode ret = notificationHelper.GetNotificationSlotsForBundle(bundleOption, slots);
557     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
558 }
559 
560 /**
561  * @tc.name: UpdateNotificationSlots_00001
562  * @tc.desc: Test UpdateNotificationSlots parameters.
563  * @tc.type: FUNC
564  * @tc.require: issueI5WRQ2
565  */
566 HWTEST_F(NotificationHelperTest, UpdateNotificationSlots_00001, Function | SmallTest | Level1)
567 {
568     NotificationBundleOption bundleOption;
569     std::vector<sptr<NotificationSlot>> slots;
570     NotificationHelper notificationHelper;
571     ErrCode ret = notificationHelper.UpdateNotificationSlots(bundleOption, slots);
572     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
573 }
574 
575 /**
576  * @tc.name: GetAllActiveNotifications_00001
577  * @tc.desc: Test GetAllActiveNotifications parameters.
578  * @tc.type: FUNC
579  * @tc.require: issueI5WRQ2
580  */
581 HWTEST_F(NotificationHelperTest, GetAllActiveNotifications_00001, Function | SmallTest | Level1)
582 {
583     std::vector<sptr<Notification>> notification;
584     NotificationHelper notificationHelper;
585     ErrCode ret = notificationHelper.GetAllActiveNotifications(notification);
586     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
587 }
588 
589 /**
590  * @tc.name: GetAllActiveNotifications_00002
591  * @tc.desc: Test GetAllActiveNotifications parameters.
592  * @tc.type: FUNC
593  * @tc.require: issueI5WRQ2
594  */
595 HWTEST_F(NotificationHelperTest, GetAllActiveNotifications_00002, Function | SmallTest | Level1)
596 {
597     std::vector<std::string> key;
598     std::vector<sptr<Notification>> notification;
599     NotificationHelper notificationHelper;
600     ErrCode ret = notificationHelper.GetAllActiveNotifications(key, notification);
601     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
602 }
603 
604 /**
605  * @tc.name: IsAllowedNotify_00002
606  * @tc.desc: Test IsAllowedNotify parameters.
607  * @tc.type: FUNC
608  * @tc.require: issueI5WRQ2
609  */
610 HWTEST_F(NotificationHelperTest, IsAllowedNotify_00002, Function | SmallTest | Level1)
611 {
612     NotificationBundleOption bundleOption;
613     bool allowed = true;
614     NotificationHelper notificationHelper;
615     ErrCode ret = notificationHelper.IsAllowedNotify(bundleOption, allowed);
616     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
617 }
618 
619 /**
620  * @tc.name: SetNotificationsEnabledForAllBundles_00001
621  * @tc.desc: Test SetNotificationsEnabledForAllBundles parameters.
622  * @tc.type: FUNC
623  * @tc.require: issueI5WRQ2
624  */
625 HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00001, Function | SmallTest | Level1)
626 {
627     std::string deviceId = "DeviceId";
628     bool enabled = true;
629     NotificationHelper notificationHelper;
630     ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(deviceId, enabled);
631     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
632 }
633 
634 /**
635  * @tc.name: SetNotificationsEnabledForDefaultBundle_00001
636  * @tc.desc: Test SetNotificationsEnabledForDefaultBundle parameters.
637  * @tc.type: FUNC
638  * @tc.require: issueI5WRQ2
639  */
640 HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForDefaultBundle_00001, Function | SmallTest | Level1)
641 {
642     std::string deviceId = "DeviceId";
643     bool enabled = true;
644     NotificationHelper notificationHelper;
645     ErrCode ret = notificationHelper.SetNotificationsEnabledForDefaultBundle(deviceId, enabled);
646     EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION);
647 }
648 
649 /**
650  * @tc.name: SetShowBadgeEnabledForBundle_00001
651  * @tc.desc: Test SetShowBadgeEnabledForBundle parameters.
652  * @tc.type: FUNC
653  * @tc.require: issueI5WRQ2
654  */
655 HWTEST_F(NotificationHelperTest, SetShowBadgeEnabledForBundle_00001, Function | SmallTest | Level1)
656 {
657     NotificationBundleOption bundleOption;
658     bool enabled = true;
659     NotificationHelper notificationHelper;
660     ErrCode ret = notificationHelper.SetShowBadgeEnabledForBundle(bundleOption, enabled);
661     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
662 }
663 
664 /**
665  * @tc.name: GetShowBadgeEnabledForBundle_00001
666  * @tc.desc: Test GetShowBadgeEnabledForBundle parameters.
667  * @tc.type: FUNC
668  * @tc.require: issueI5WRQ2
669  */
670 HWTEST_F(NotificationHelperTest, GetShowBadgeEnabledForBundle_00001, Function | SmallTest | Level1)
671 {
672     NotificationBundleOption bundleOption;
673     bool enabled = true;
674     NotificationHelper notificationHelper;
675     ErrCode ret = notificationHelper.GetShowBadgeEnabledForBundle(bundleOption, enabled);
676     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
677 }
678 
679 /**
680  * @tc.name: GetShowBadgeEnabled_00001
681  * @tc.desc: Test GetShowBadgeEnabled parameters.
682  * @tc.type: FUNC
683  * @tc.require: issueI5WRQ2
684  */
685 HWTEST_F(NotificationHelperTest, GetShowBadgeEnabled_00001, Function | SmallTest | Level1)
686 {
687     bool enabled = true;
688     NotificationHelper notificationHelper;
689     ErrCode ret = notificationHelper.GetShowBadgeEnabled(enabled);
690     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
691 }
692 
693 /**
694  * @tc.name: CancelGroup_00001
695  * @tc.desc: Test CancelGroup parameters.
696  * @tc.type: FUNC
697  * @tc.require: issueI5WRQ2
698  */
699 HWTEST_F(NotificationHelperTest, CancelGroup_00001, Function | SmallTest | Level1)
700 {
701     std::string groupName = "GroupName";
702     NotificationHelper notificationHelper;
703     ErrCode ret = notificationHelper.CancelGroup(groupName);
704     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
705 }
706 
707 /**
708  * @tc.name: RemoveGroupByBundle_00001
709  * @tc.desc: Test RemoveGroupByBundle parameters.
710  * @tc.type: FUNC
711  * @tc.require: issueI5WRQ2
712  */
713 HWTEST_F(NotificationHelperTest, RemoveGroupByBundle_00001, Function | SmallTest | Level1)
714 {
715     NotificationBundleOption bundleOption;
716     std::string groupName = "GroupName";
717     NotificationHelper notificationHelper;
718     ErrCode ret = notificationHelper.RemoveGroupByBundle(bundleOption, groupName);
719     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
720 }
721 
722 /**
723  * @tc.name: SetDoNotDisturbDate_00001
724  * @tc.desc: Test SetDoNotDisturbDate parameters.
725  * @tc.type: FUNC
726  * @tc.require: issueI5WRQ2
727  */
728 HWTEST_F(NotificationHelperTest, SetDoNotDisturbDate_00001, Function | SmallTest | Level1)
729 {
730     NotificationDoNotDisturbDate doNotDisturbDate;
731     NotificationHelper notificationHelper;
732     ErrCode ret = notificationHelper.SetDoNotDisturbDate(doNotDisturbDate);
733     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
734 }
735 
736 /**
737  * @tc.name: GetDoNotDisturbDate_00001
738  * @tc.desc: Test GetDoNotDisturbDate parameters.
739  * @tc.type: FUNC
740  * @tc.require: issueI5WRQ2
741  */
742 HWTEST_F(NotificationHelperTest, GetDoNotDisturbDate_00001, Function | SmallTest | Level1)
743 {
744     NotificationDoNotDisturbDate doNotDisturbDate;
745     NotificationHelper notificationHelper;
746     ErrCode ret = notificationHelper.GetDoNotDisturbDate(doNotDisturbDate);
747     EXPECT_NE(ret, (int)ERR_ANS_NON_SYSTEM_APP);
748 }
749 
750 /**
751  * @tc.name: DoesSupportDoNotDisturbMode_00001
752  * @tc.desc: Test DoesSupportDoNotDisturbMode parameters.
753  * @tc.type: FUNC
754  * @tc.require: issueI5WRQ2
755  */
756 HWTEST_F(NotificationHelperTest, DoesSupportDoNotDisturbMode_00001, Function | SmallTest | Level1)
757 {
758     bool doesSupport = true;
759     NotificationHelper notificationHelper;
760     ErrCode ret = notificationHelper.DoesSupportDoNotDisturbMode(doesSupport);
761     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
762 }
763 
764 /**
765  * @tc.name: IsDistributedEnabled_00001
766  * @tc.desc: Test IsDistributedEnabled parameters.
767  * @tc.type: FUNC
768  * @tc.require: issueI5WRQ2
769  */
770 HWTEST_F(NotificationHelperTest, IsDistributedEnabled_00001, Function | SmallTest | Level1)
771 {
772     bool enabled = true;
773     NotificationHelper notificationHelper;
774     ErrCode ret = notificationHelper.IsDistributedEnabled(enabled);
775     EXPECT_EQ(ret, (int)ERR_OK);
776 }
777 
778 /**
779  * @tc.name: EnableDistributed_00001
780  * @tc.desc: Test EnableDistributed parameters.
781  * @tc.type: FUNC
782  * @tc.require: issueI5WRQ2
783  */
784 HWTEST_F(NotificationHelperTest, EnableDistributed_00001, Function | SmallTest | Level1)
785 {
786     bool enabled = true;
787     NotificationHelper notificationHelper;
788     notificationHelper.EnableDistributed(enabled);
789     EXPECT_EQ(enabled, true);
790 }
791 
792 /**
793  * @tc.name: EnableDistributedByBundle_00001
794  * @tc.desc: Test EnableDistributedByBundle parameters.
795  * @tc.type: FUNC
796  * @tc.require: issueI5WRQ2
797  */
798 HWTEST_F(NotificationHelperTest, EnableDistributedByBundle_00001, Function | SmallTest | Level1)
799 {
800     NotificationBundleOption bundleOption;
801     bool enabled = true;
802     NotificationHelper notificationHelper;
803     ErrCode ret = notificationHelper.EnableDistributedByBundle(bundleOption, enabled);
804     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
805 }
806 
807 /**
808  * @tc.name: EnableDistributedSelf_00001
809  * @tc.desc: Test EnableDistributedSelf parameters.
810  * @tc.type: FUNC
811  * @tc.require: issueI5WRQ2
812  */
813 HWTEST_F(NotificationHelperTest, EnableDistributedSelf_00001, Function | SmallTest | Level1)
814 {
815     bool enabled = true;
816     NotificationHelper notificationHelper;
817     ErrCode ret = notificationHelper.EnableDistributedSelf(enabled);
818     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
819 }
820 
821 /**
822  * @tc.name: IsDistributedEnableByBundle_00001
823  * @tc.desc: Test IsDistributedEnableByBundle parameters.
824  * @tc.type: FUNC
825  * @tc.require: issueI5WRQ2
826  */
827 HWTEST_F(NotificationHelperTest, IsDistributedEnableByBundle_00001, Function | SmallTest | Level1)
828 {
829     NotificationBundleOption bundleOption;
830     bool enabled = true;
831     NotificationHelper notificationHelper;
832     ErrCode ret = notificationHelper.IsDistributedEnableByBundle(bundleOption, enabled);
833     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
834 }
835 
836 /**
837  * @tc.name: GetDeviceRemindType_00001
838  * @tc.desc: Test GetDeviceRemindType parameters.
839  * @tc.type: FUNC
840  * @tc.require: issueI5WRQ2
841  */
842 HWTEST_F(NotificationHelperTest, GetDeviceRemindType_00001, Function | SmallTest | Level1)
843 {
844     NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND;
845     NotificationHelper notificationHelper;
846     ErrCode ret = notificationHelper.GetDeviceRemindType(remindType);
847     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
848 }
849 
850 /**
851  * @tc.name: PublishContinuousTaskNotification_00001
852  * @tc.desc: Test PublishContinuousTaskNotification parameters.
853  * @tc.type: FUNC
854  * @tc.require: issueI5WRQ2
855  */
856 HWTEST_F(NotificationHelperTest, PublishContinuousTaskNotification_00001, Function | SmallTest | Level1)
857 {
858     NotificationRequest request;
859     NotificationHelper notificationHelper;
860     ErrCode ret = notificationHelper.PublishContinuousTaskNotification(request);
861     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
862 }
863 
864 /**
865  * @tc.name: CancelContinuousTaskNotification_00001
866  * @tc.desc: Test CancelContinuousTaskNotification parameters.
867  * @tc.type: FUNC
868  * @tc.require: issueI5WRQ2
869  */
870 HWTEST_F(NotificationHelperTest, CancelContinuousTaskNotification_00001, Function | SmallTest | Level1)
871 {
872     std::string label = "label";
873     int32_t notificationId = 10;
874     NotificationHelper notificationHelper;
875     ErrCode ret = notificationHelper.CancelContinuousTaskNotification(label, notificationId);
876     EXPECT_EQ(ret, (int)ERR_OK);
877 }
878 
879 /**
880  * @tc.name: IsSupportTemplate_00001
881  * @tc.desc: Test IsSupportTemplate parameters.
882  * @tc.type: FUNC
883  * @tc.require: issueI5WRQ2
884  */
885 HWTEST_F(NotificationHelperTest, IsSupportTemplate_00001, Function | SmallTest | Level1)
886 {
887     std::string templateName = "TemplateName";
888     bool support = true;
889     NotificationHelper notificationHelper;
890     ErrCode ret = notificationHelper.IsSupportTemplate(templateName, support);
891     EXPECT_EQ(ret, (int)ERR_OK);
892 }
893 
894 /**
895  * @tc.name: SetNotificationsEnabledForAllBundles_00002
896  * @tc.desc: Test SetNotificationsEnabledForAllBundles parameters.
897  * @tc.type: FUNC
898  * @tc.require: issueI5WRQ2
899  */
900 HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00002, Function | SmallTest | Level1)
901 {
902     int32_t userId = 10;
903     bool enabled = true;
904     NotificationHelper notificationHelper;
905     ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(userId, enabled);
906     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
907 }
908 
909 /**
910  * @tc.name: IsSupportTemplate_00002
911  * @tc.desc: Test IsSupportTemplate parameters.
912  * @tc.type: FUNC
913  * @tc.require: issueI5WRQ2
914  */
915 HWTEST_F(NotificationHelperTest, IsSupportTemplate_00002, Function | SmallTest | Level1)
916 {
917     std::string templateName = "TemplateName";
918     bool support = true;
919     NotificationHelper notificationHelper;
920     ErrCode ret = notificationHelper.IsSupportTemplate(templateName, support);
921     EXPECT_EQ(ret, (int)ERR_OK);
922 }
923 
924 /**
925  * @tc.name: IsAllowedNotify_00004
926  * @tc.desc: Test IsAllowedNotify parameters.
927  * @tc.type: FUNC
928  * @tc.require: issueI5WRQ2
929  */
930 HWTEST_F(NotificationHelperTest, IsAllowedNotify_00004, Function | SmallTest | Level1)
931 {
932     int32_t userId = 10;
933     bool allowed = true;
934     NotificationHelper notificationHelper;
935     ErrCode ret = notificationHelper.IsAllowedNotify(userId, allowed);
936     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
937 }
938 
939 /**
940  * @tc.name: SetNotificationsEnabledForAllBundles_00003
941  * @tc.desc: Test SetNotificationsEnabledForAllBundles parameters.
942  * @tc.type: FUNC
943  * @tc.require: issueI5WRQ2
944  */
945 HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00003, Function | SmallTest | Level1)
946 {
947     int32_t userId = 10;
948     bool enabled = true;
949     NotificationHelper notificationHelper;
950     ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(userId, enabled);
951     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
952 }
953 
954 /**
955  * @tc.name: RemoveNotifications_00002
956  * @tc.desc: Test RemoveNotifications parameters.
957  * @tc.type: FUNC
958  * @tc.require: issueI5WRQ2
959  */
960 HWTEST_F(NotificationHelperTest, RemoveNotifications_00002, Function | SmallTest | Level1)
961 {
962     int32_t userId = 10;
963     NotificationHelper notificationHelper;
964     ErrCode ret = notificationHelper.RemoveNotifications(userId);
965     EXPECT_EQ(ret, (int)ERR_OK);
966 }
967 
968 /**
969  * @tc.name: SetDoNotDisturbDate_00002
970  * @tc.desc: Test SetDoNotDisturbDate parameters.
971  * @tc.type: FUNC
972  * @tc.require: issueI5WRQ2
973  */
974 HWTEST_F(NotificationHelperTest, SetDoNotDisturbDate_00002, Function | SmallTest | Level1)
975 {
976     int32_t userId = 10;
977     NotificationDoNotDisturbDate doNotDisturbDate;
978     NotificationHelper notificationHelper;
979     ErrCode ret = notificationHelper.SetDoNotDisturbDate(userId, doNotDisturbDate);
980     EXPECT_NE(ret, (int)ERR_ANS_INVALID_BUNDLE);
981 }
982 
983 /**
984  * @tc.name: GetDoNotDisturbDate_00002
985  * @tc.desc: Test GetDoNotDisturbDate parameters.
986  * @tc.type: FUNC
987  * @tc.require: issueI5WRQ2
988  */
989 HWTEST_F(NotificationHelperTest, GetDoNotDisturbDate_00002, Function | SmallTest | Level1)
990 {
991     int32_t userId = 10;
992     NotificationDoNotDisturbDate doNotDisturbDate;
993     NotificationHelper notificationHelper;
994     ErrCode ret = notificationHelper.GetDoNotDisturbDate(userId, doNotDisturbDate);
995     EXPECT_NE(ret, (int)ERR_ANS_NON_SYSTEM_APP);
996 }
997 
998 /**
999  * @tc.name: SetEnabledForBundleSlot_00001
1000  * @tc.desc: Test SetEnabledForBundleSlot parameters.
1001  * @tc.type: FUNC
1002  * @tc.require: issueI5WRQ2
1003  */
1004 HWTEST_F(NotificationHelperTest, SetEnabledForBundleSlot_00001, Function | SmallTest | Level1)
1005 {
1006     NotificationBundleOption bundleOption;
1007     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER;
1008     bool enabled = true;
1009     NotificationHelper notificationHelper;
1010     ErrCode ret = notificationHelper.SetEnabledForBundleSlot(bundleOption, slotType, enabled, false);
1011     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
1012 }
1013 
1014 /**
1015  * @tc.name: GetEnabledForBundleSlot_00001
1016  * @tc.desc: Test GetEnabledForBundleSlot parameters.
1017  * @tc.type: FUNC
1018  * @tc.require: issueI5WRQ2
1019  */
1020 HWTEST_F(NotificationHelperTest, GetEnabledForBundleSlot_00001, Function | SmallTest | Level1)
1021 {
1022     NotificationBundleOption bundleOption;
1023     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER;
1024     bool enabled = true;
1025     NotificationHelper notificationHelper;
1026     ErrCode ret = notificationHelper.GetEnabledForBundleSlot(bundleOption, slotType, enabled);
1027     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
1028 }
1029 
1030 /**
1031  * @tc.name: SetSyncNotificationEnabledWithoutApp_00001
1032  * @tc.desc: Test SetSyncNotificationEnabledWithoutApp parameters.
1033  * @tc.type: FUNC
1034  * @tc.require: issueI5WRQ2
1035  */
1036 HWTEST_F(NotificationHelperTest, SetSyncNotificationEnabledWithoutApp_00001, Function | SmallTest | Level1)
1037 {
1038     int32_t userId = 10;
1039     bool enabled = true;
1040     NotificationHelper notificationHelper;
1041     notificationHelper.SetSyncNotificationEnabledWithoutApp(userId, enabled);
1042     EXPECT_EQ(enabled, true);
1043 }
1044 
1045 /**
1046  * @tc.name: GetSyncNotificationEnabledWithoutApp_00001
1047  * @tc.desc: Test GetSyncNotificationEnabledWithoutApp parameters.
1048  * @tc.type: FUNC
1049  * @tc.require: issueI5WRQ2
1050  */
1051 HWTEST_F(NotificationHelperTest, GetSyncNotificationEnabledWithoutApp_00001, Function | SmallTest | Level1)
1052 {
1053     int32_t userId = 10;
1054     bool enabled = true;
1055     NotificationHelper notificationHelper;
1056     ErrCode ret = notificationHelper.GetSyncNotificationEnabledWithoutApp(userId, enabled);
1057     EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
1058 }
1059 
1060 /**
1061  * @tc.name: SetType_00001
1062  * @tc.desc: Test SetType_00001 parameters.
1063  * @tc.type: FUNC
1064  * @tc.require: issueI5WRQ2
1065  */
1066 HWTEST_F(NotificationHelperTest, SetType_00001, Function | SmallTest | Level1)
1067 {
1068     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SOCIAL_COMMUNICATION;
1069     auto slot1 = std::make_shared<NotificationSlot>(slotType);
1070     EXPECT_NE(slot1, nullptr);
1071 
1072     slotType = NotificationConstant::SlotType::SERVICE_REMINDER;
1073     auto slot2 = std::make_shared<NotificationSlot>(slotType);
1074     EXPECT_NE(slot2, nullptr);
1075 
1076     slotType = NotificationConstant::SlotType::CONTENT_INFORMATION;
1077     auto slot3 = std::make_shared<NotificationSlot>(slotType);
1078     EXPECT_NE(slot3, nullptr);
1079 
1080     slotType = NotificationConstant::SlotType::OTHER;
1081     auto slot4 = std::make_shared<NotificationSlot>(slotType);
1082     EXPECT_NE(slot4, nullptr);
1083 }
1084 
1085 /**
1086  * @tc.name: GetAllNotificationEnabledBundles_00001
1087  * @tc.desc: Test GetAllNotificationEnabledBundles parameters.
1088  * @tc.type: FUNC
1089  * @tc.require: issueI92VGR
1090  */
1091 HWTEST_F(NotificationHelperTest, GetAllNotificationEnabledBundles_00001, Function | SmallTest | Level1)
1092 {
1093     std::vector<NotificationBundleOption> bundleOption;
1094     NotificationHelper notificationHelper;
1095     ErrCode ret = notificationHelper.GetAllNotificationEnabledBundles(bundleOption);
1096     EXPECT_EQ(ret, (int)ERR_ANS_NON_SYSTEM_APP);
1097 }
1098 
1099 /**
1100  * @tc.name: GetActiveNotificationByFilter_00001
1101  * @tc.desc: Test GetActiveNotificationByFilter parameters.
1102  * @tc.type: FUNC
1103  * @tc.require: issueI5WRQ2
1104  */
1105 HWTEST_F(NotificationHelperTest, GetActiveNotificationByFilter_00001, Function | SmallTest | Level1)
1106 {
1107     LiveViewFilter filter;
1108     sptr<NotificationRequest> request;
1109     NotificationHelper notificationHelper;
1110     ErrCode ret = notificationHelper.GetActiveNotificationByFilter(filter, request);
1111     EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
1112 }
1113 
1114 /**
1115  * @tc.name: SetSmartReminderEnabled_0100
1116  * @tc.desc: test SetSmartReminderEnabled with parameters
1117  * @tc.type: FUNC
1118  */
1119 HWTEST_F(NotificationHelperTest, SetSmartReminderEnabled_0100, TestSize.Level1)
1120 {
1121     std::string deviceType = "testDeviceType";
1122     NotificationHelper notificationHelper;
1123     ErrCode ret = notificationHelper.SetSmartReminderEnabled(deviceType, true);
1124     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1125 }
1126 
1127 /**
1128  * @tc.name: SetSmartReminderEnabled_0200
1129  * @tc.desc: test SetSmartReminderEnabled with parameters, expect errorCode ERR_ANS_INVALID_PARAM.
1130  * @tc.type: FUNC
1131  */
1132 HWTEST_F(NotificationHelperTest, SetSmartReminderEnabled_0200, TestSize.Level1)
1133 {
1134     std::string deviceType = "";
1135     NotificationHelper notificationHelper;
1136     ErrCode ret = notificationHelper.SetSmartReminderEnabled(deviceType, true);
1137     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1138 }
1139 
1140 /**
1141  * @tc.name: IsSmartReminderEnabled_0100
1142  * @tc.desc: test IsSmartReminderEnabled with parameters
1143  * @tc.type: FUNC
1144  */
1145 HWTEST_F(NotificationHelperTest, IsSmartReminderEnabled_0100, TestSize.Level1)
1146 {
1147     std::string deviceType = "testDeviceType1111";
1148     NotificationHelper notificationHelper;
1149     bool enable = true;
1150     ErrCode ret = notificationHelper.IsSmartReminderEnabled(deviceType, enable);
1151     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1152 }
1153 
1154 /**
1155  * @tc.name: SetBadgeNumberByBundle_0100
1156  * @tc.desc: test SetBadgeNumberByBundle with invalid bundleOption, expect errorCode ERR_ANS_INVALID_PARAM.
1157  * @tc.type: FUNC
1158  */
1159 HWTEST_F(NotificationHelperTest, SetBadgeNumberByBundle_0100, TestSize.Level1)
1160 {
1161     NotificationBundleOption bundleOption;
1162     int32_t badgeNumber = 0;
1163     NotificationHelper notificationHelper;
1164     ErrCode ret = notificationHelper.SetBadgeNumberByBundle(bundleOption, badgeNumber);
1165     EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM);
1166 }
1167 
1168 /**
1169  * @tc.name: SetBadgeNumberByBundle_0200
1170  * @tc.desc: test SetBadgeNumberByBundle with invalid bundle name, expect errorCode ERR_ANS_INVALID_BUNDLE.
1171  * @tc.type: FUNC
1172  */
1173 HWTEST_F(NotificationHelperTest, SetBadgeNumberByBundle_0200, TestSize.Level1)
1174 {
1175     NotificationBundleOption bundleOption;
1176     std::string bundleName = "bundleName";
1177     bundleOption.SetBundleName(bundleName);
1178     int32_t badgeNumber = 0;
1179     NotificationHelper notificationHelper;
1180     ErrCode ret = notificationHelper.SetBadgeNumberByBundle(bundleOption, badgeNumber);
1181     EXPECT_EQ(ret, ERR_ANS_INVALID_BUNDLE);
1182 }
1183 
1184 /**
1185  * @tc.name: SetDistributedEnabledByBundle_0100
1186  * @tc.desc: test SetDistributedEnabledByBundle with parameters
1187  * @tc.type: FUNC
1188  */
1189 HWTEST_F(NotificationHelperTest, SetDistributedEnabledByBundle_0100, TestSize.Level1)
1190 {
1191     NotificationBundleOption bundleOption;
1192     std::string bundleName = "bundleName";
1193     bundleOption.SetBundleName(bundleName);
1194     bundleOption.SetUid(1);
1195     std::string deviceType = "testDeviceType";
1196     NotificationHelper notificationHelper;
1197     ErrCode ret = notificationHelper.SetDistributedEnabledByBundle(bundleOption, deviceType, true);
1198     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1199 }
1200 
1201 /**
1202  * @tc.name: SetDistributedEnabledByBundle_0200
1203  * @tc.desc: test SetDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM.
1204  * @tc.type: FUNC
1205  */
1206 HWTEST_F(NotificationHelperTest, SetDistributedEnabledByBundle_0200, TestSize.Level1)
1207 {
1208     NotificationBundleOption bundleOption;
1209     std::string deviceType = "testDeviceType";
1210     NotificationHelper notificationHelper;
1211     ErrCode ret = notificationHelper.SetDistributedEnabledByBundle(bundleOption, deviceType, true);
1212     EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM);
1213 }
1214 
1215 /**
1216  * @tc.name: IsDistributedEnabledByBundle_0100
1217  * @tc.desc: test IsDistributedEnabledByBundle with parameters
1218  * @tc.type: FUNC
1219  */
1220 HWTEST_F(NotificationHelperTest, IsDistributedEnabledByBundle_0100, TestSize.Level1)
1221 {
1222     NotificationBundleOption bundleOption;
1223     std::string bundleName = "bundleName";
1224     bundleOption.SetBundleName(bundleName);
1225     bundleOption.SetUid(1);
1226     std::string deviceType = "testDeviceType1111";
1227     NotificationHelper notificationHelper;
1228     bool enable = true;
1229     ErrCode ret = notificationHelper.IsDistributedEnabledByBundle(bundleOption, deviceType, enable);
1230     EXPECT_EQ(ret, ERR_ANS_PERMISSION_DENIED);
1231 }
1232 
1233 /**
1234  * @tc.name: IsDistributedEnabledByBundle_0200
1235  * @tc.desc: test IsDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM.
1236  * @tc.type: FUNC
1237  */
1238 HWTEST_F(NotificationHelperTest, IsDistributedEnabledByBundle_0200, TestSize.Level1)
1239 {
1240     NotificationBundleOption bundleOption;
1241     bundleOption.SetBundleName("");
1242     bundleOption.SetUid(1);
1243     std::string deviceType = "testDeviceType";
1244     NotificationHelper notificationHelper;
1245     bool enable = true;
1246     ErrCode ret = notificationHelper.IsDistributedEnabledByBundle(bundleOption, deviceType, enable);
1247     EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM);
1248 }
1249 
1250 /**
1251  * @tc.name: AddDoNotDisturbProfiles_0100
1252  * @tc.desc: test AddDoNotDisturbProfiles when profiles is empty.
1253  * @tc.type: FUNC
1254  */
1255 HWTEST_F(NotificationHelperTest, AddDoNotDisturbProfiles_0100, TestSize.Level1)
1256 {
1257     NotificationHelper notificationHelper;
1258     std::vector<sptr<NotificationDoNotDisturbProfile>> profiles;
1259     profiles.clear();
1260     ErrCode ret = notificationHelper.AddDoNotDisturbProfiles(profiles);
1261     EXPECT_EQ(ERR_ANS_INVALID_PARAM, ret);
1262 }
1263 
1264 /**
1265  * @tc.name: RemoveDoNotDisturbProfiles_0100
1266  * @tc.desc: test RemoveDoNotDisturbProfiles when profiles is empty.
1267  * @tc.type: FUNC
1268  */
1269 HWTEST_F(NotificationHelperTest, RemoveDoNotDisturbProfiles_0100, TestSize.Level1)
1270 {
1271     NotificationHelper notificationHelper;
1272     std::vector<sptr<NotificationDoNotDisturbProfile>> profiles;
1273     profiles.clear();
1274     ErrCode ret = notificationHelper.RemoveDoNotDisturbProfiles(profiles);
1275     EXPECT_EQ(ERR_ANS_INVALID_PARAM, ret);
1276 }
1277 
1278 /**
1279  * @tc.name: SetTargetDeviceStatus_0100
1280  * @tc.desc: test SetTargetDeviceStatus with parameters
1281  * @tc.type: FUNC
1282  */
1283 HWTEST_F(NotificationHelperTest, SetTargetDeviceStatus_0100, TestSize.Level1)
1284 {
1285     std::string deviceType = "testDeviceType";
1286     int32_t status = 1;
1287     NotificationHelper notificationHelper;
1288     ErrCode ret = notificationHelper.SetTargetDeviceStatus(deviceType, status);
1289     EXPECT_EQ(ret, ERR_OK);
1290 }
1291 
1292 /**
1293  * @tc.name: RegisterSwingCallback_0100
1294  * @tc.desc: test RegisterSwingCallback with parameters
1295  * @tc.type: FUNC
1296  */
1297 HWTEST_F(NotificationHelperTest, RegisterSwingCallback_0100, TestSize.Level1)
1298 {
1299 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
1300     std::function<void(bool, int)> swingCbFunc =
1301         std::bind(&NotificationHelperTest::UpdateStatuts, this, std::placeholders::_1, std::placeholders::_2);
1302     EXPECT_TRUE(swingCbFunc);
1303     NotificationHelper notificationHelper;
1304     ErrCode ret = notificationHelper.RegisterSwingCallback(swingCbFunc);
1305     EXPECT_EQ(ret, ERR_OK);
1306 #endif
1307 }
1308 
1309 /**
1310  * @tc.name: UpdateNotificationTimerByUid_00001
1311  * @tc.desc: Test UpdateNotificationTimerByUid.
1312  * @tc.type: FUNC
1313  */
1314 HWTEST_F(NotificationHelperTest, UpdateNotificationTimerByUid_00001, Function | SmallTest | Level1)
1315 {
1316     int32_t uid = 20099999;
1317     bool isPaused = true;
1318     NotificationHelper notificationHelper;
1319     ErrCode ret = notificationHelper.UpdateNotificationTimerByUid(uid, isPaused);
1320     EXPECT_EQ(ret, ERR_OK);
1321 }
1322 }
1323 }
1324