1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "notification_bundle_option.h"
17 #include <chrono>
18 #include <functional>
19 #include <memory>
20 #include <new>
21 #include <thread>
22 
23 #include "gtest/gtest.h"
24 
25 #define private public
26 #include "advanced_notification_service.h"
27 #include "ans_inner_errors.h"
28 #include "ans_log_wrapper.h"
29 #include "accesstoken_kit.h"
30 #include "notification_preferences.h"
31 #include "notification_constant.h"
32 #include "notification_config_parse.h"
33 
34 using namespace testing::ext;
35 using namespace OHOS::Security::AccessToken;
36 
37 namespace OHOS {
38 namespace Notification {
39 extern void MockIsVerfyPermisson(bool isVerify);
40 extern void MockGetTokenTypeFlag(ATokenTypeEnum mockRet);
41 extern void MockIsSystemApp(bool isSystemApp);
42 
43 class AnsSlotServiceTest : public testing::Test {
44 public:
45     static void SetUpTestCase();
46     static void TearDownTestCase();
47     void SetUp();
48     void TearDown();
49 
50 private:
51     void TestAddSlot(NotificationConstant::SlotType type);
52 
53 private:
54     static sptr<AdvancedNotificationService> advancedNotificationService_;
55 };
56 
57 sptr<AdvancedNotificationService> AnsSlotServiceTest::advancedNotificationService_ = nullptr;
58 
SetUpTestCase()59 void AnsSlotServiceTest::SetUpTestCase() {}
60 
TearDownTestCase()61 void AnsSlotServiceTest::TearDownTestCase() {}
62 
SetUp()63 void AnsSlotServiceTest::SetUp()
64 {
65     GTEST_LOG_(INFO) << "SetUp start";
66 
67     advancedNotificationService_ = new (std::nothrow) AdvancedNotificationService();
68     NotificationPreferences::GetInstance()->ClearNotificationInRestoreFactorySettings();
69     advancedNotificationService_->CancelAll(0);
70     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE);
71     MockIsSystemApp(true);
72     GTEST_LOG_(INFO) << "SetUp end";
73 }
74 
TearDown()75 void AnsSlotServiceTest::TearDown()
76 {
77     delete advancedNotificationService_;
78     advancedNotificationService_ = nullptr;
79     GTEST_LOG_(INFO) << "TearDown";
80 }
81 
TestAddSlot(NotificationConstant::SlotType type)82 void AnsSlotServiceTest::TestAddSlot(NotificationConstant::SlotType type)
83 {
84     MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP);
85     MockIsSystemApp(true);
86     MockIsVerfyPermisson(true);
87     std::vector<sptr<NotificationSlot>> slots;
88     sptr<NotificationSlot> slot = new NotificationSlot(type);
89     slot->SetEnable(true);
90     slots.push_back(slot);
91     ASSERT_EQ(advancedNotificationService_->AddSlots(slots), (int)ERR_OK);
92 }
93 
94 /**
95  * @tc.name: AddSlots_00001
96  * @tc.desc: Test AddSlots
97  * @tc.type: FUNC
98  * @tc.require: issue
99  */
100 HWTEST_F(AnsSlotServiceTest, AddSlots_00001, Function | SmallTest | Level1)
101 {
102     MockIsSystemApp(true);
103     MockIsVerfyPermisson(true);
104     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOMER_SERVICE;
105     std::vector<sptr<NotificationSlot>> slots;
106     sptr<NotificationSlot> slot = new NotificationSlot(slotType);
107     slots.push_back(slot);
108     advancedNotificationService_->notificationSvrQueue_ = nullptr;
109     ASSERT_EQ(advancedNotificationService_->AddSlots(slots), (int)ERR_ANS_INVALID_PARAM);
110 }
111 
112 /**
113  * @tc.name: GetSlots_00001
114  * @tc.desc: Test GetSlots
115  * @tc.type: FUNC
116  * @tc.require: issue
117  */
118 HWTEST_F(AnsSlotServiceTest, GetSlots_00001, Function | SmallTest | Level1)
119 {
120     std::vector<sptr<NotificationSlot>> slots;
121     advancedNotificationService_->notificationSvrQueue_ = nullptr;
122     ASSERT_EQ(advancedNotificationService_->GetSlots(slots), (int)ERR_ANS_INVALID_PARAM);
123 }
124 
125 /**
126  * @tc.name: GetSlotsByBundle_00001
127  * @tc.desc: Test GetSlotsByBundle
128  * @tc.type: FUNC
129  * @tc.require: issue
130  */
131 HWTEST_F(AnsSlotServiceTest, GetSlotsByBundle_00001, Function | SmallTest | Level1)
132 {
133     MockIsSystemApp(true);
134     MockIsVerfyPermisson(true);
135     std::vector<sptr<NotificationSlot>> slots;
136     sptr<NotificationBundleOption> bundle = nullptr;
137     ASSERT_EQ(advancedNotificationService_->GetSlotsByBundle(bundle, slots), (int)ERR_ANS_INVALID_BUNDLE);
138 }
139 
140 /**
141  * @tc.name: GetSlotsByBundle_00002
142  * @tc.desc: Test GetSlotsByBundle
143  * @tc.type: FUNC
144  * @tc.require: issue
145  */
146 HWTEST_F(AnsSlotServiceTest, GetSlotsByBundle_00002, Function | SmallTest | Level1)
147 {
148     MockIsSystemApp(true);
149     MockIsVerfyPermisson(true);
150     std::vector<sptr<NotificationSlot>> slots;
151     sptr<NotificationBundleOption> bundle = new NotificationBundleOption("test", 1);
152     advancedNotificationService_->notificationSvrQueue_ = nullptr;
153     ASSERT_EQ(advancedNotificationService_->GetSlotsByBundle(bundle, slots), (int)ERR_ANS_INVALID_PARAM);
154 }
155 
156 /**
157  * @tc.name: UpdateSlots_00001
158  * @tc.desc: Test UpdateSlots
159  * @tc.type: FUNC
160  * @tc.require: issue
161  */
162 HWTEST_F(AnsSlotServiceTest, UpdateSlots_00001, Function | SmallTest | Level1)
163 {
164     MockIsSystemApp(true);
165     MockIsVerfyPermisson(true);
166     std::vector<sptr<NotificationSlot>> slots;
167     sptr<NotificationBundleOption> bundle = nullptr;
168     ASSERT_EQ(advancedNotificationService_->UpdateSlots(bundle, slots), (int)ERR_ANS_INVALID_BUNDLE);
169 
170     bundle = new NotificationBundleOption("test", 1);
171     advancedNotificationService_->notificationSvrQueue_ = nullptr;
172     ASSERT_EQ(advancedNotificationService_->UpdateSlots(bundle, slots), (int)ERR_ANS_INVALID_PARAM);
173 }
174 
175 /**
176  * @tc.name: UpdateSlots_00002
177  * @tc.desc: Test UpdateSlots
178  * @tc.type: FUNC
179  * @tc.require: issue
180  */
181 HWTEST_F(AnsSlotServiceTest, UpdateSlots_00002, Function | SmallTest | Level1)
182 {
183     MockIsSystemApp(true);
184     MockIsVerfyPermisson(true);
185     std::vector<sptr<NotificationSlot>> slots;
186     sptr<NotificationSlot> slot = new NotificationSlot(NotificationConstant::SlotType::LIVE_VIEW);
187     slot->SetEnable(true);
188     slots.push_back(slot);
189 
190     sptr<NotificationBundleOption> bundle = new NotificationBundleOption("test", 1);
191     auto ret = advancedNotificationService_->UpdateSlots(bundle, slots);
192     ASSERT_EQ(ret, (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_TYPE_NOT_EXIST);
193 }
194 
195 /**
196  * @tc.name: RemoveAllSlots_00001
197  * @tc.desc: Test RemoveAllSlots
198  * @tc.type: FUNC
199  * @tc.require: issue
200  */
201 HWTEST_F(AnsSlotServiceTest, RemoveAllSlots_00001, Function | SmallTest | Level1)
202 {
203     advancedNotificationService_->notificationSvrQueue_ = nullptr;
204     auto ret = advancedNotificationService_->RemoveAllSlots();
205     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
206 }
207 
208 /**
209  * @tc.name: RemoveAllSlots_00002
210  * @tc.desc: Test RemoveAllSlots
211  * @tc.type: FUNC
212  * @tc.require: issue
213  */
214 HWTEST_F(AnsSlotServiceTest, RemoveAllSlots_00002, Function | SmallTest | Level1)
215 {
216     TestAddSlot(NotificationConstant::SlotType::LIVE_VIEW);
217     auto ret = advancedNotificationService_->RemoveAllSlots();
218     ASSERT_EQ(ret, (int)ERR_OK);
219 }
220 
221 /**
222  * @tc.name: GetEnabledForBundleSlotSelf_00001
223  * @tc.desc: Test GetEnabledForBundleSlotSelf
224  * @tc.type: FUNC
225  * @tc.require: issue
226  */
227 HWTEST_F(AnsSlotServiceTest, GetEnabledForBundleSlotSelf_00001, Function | SmallTest | Level1)
228 {
229     auto slotType = NotificationConstant::SlotType::CONTENT_INFORMATION;
230     TestAddSlot(slotType);
231 
232     bool enable = false;
233     advancedNotificationService_->GetEnabledForBundleSlotSelf(slotType, enable);
234     ASSERT_EQ(enable, true);
235 }
236 
237 /**
238  * @tc.name: GetSlotFlagsAsBundle_00001
239  * @tc.desc: Test GetSlotFlagsAsBundle
240  * @tc.type: FUNC
241  * @tc.require: issue
242  */
243 HWTEST_F(AnsSlotServiceTest, GetSlotFlagsAsBundle_00001, Function | SmallTest | Level1)
244 {
245     sptr<NotificationBundleOption> bundle = new NotificationBundleOption("test", 1);
246     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP);
247     MockIsSystemApp(false);
248     auto ret = advancedNotificationService_->SetSlotFlagsAsBundle(bundle, 1);
249     ASSERT_EQ(ret, (int)ERR_ANS_NON_SYSTEM_APP);
250 
251     uint32_t flag = 0;
252     ret = advancedNotificationService_->GetSlotFlagsAsBundle(bundle, flag);
253     ASSERT_EQ(ret, (int)ERR_ANS_NON_SYSTEM_APP);
254 }
255 
256 /**
257  * @tc.name: GetSlotFlagsAsBundle_00002
258  * @tc.desc: Test GetSlotFlagsAsBundle
259  * @tc.type: FUNC
260  * @tc.require: issue
261  */
262 HWTEST_F(AnsSlotServiceTest, GetSlotFlagsAsBundle_00002, Function | SmallTest | Level1)
263 {
264     sptr<NotificationBundleOption> bundle = new NotificationBundleOption("test", 1);
265     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP);
266     MockIsSystemApp(true);
267     MockIsVerfyPermisson(false);
268     auto ret = advancedNotificationService_->SetSlotFlagsAsBundle(bundle, 1);
269     ASSERT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
270 
271     uint32_t flag = 0;
272     ret = advancedNotificationService_->GetSlotFlagsAsBundle(bundle, flag);
273     ASSERT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
274 }
275 
276 /**
277  * @tc.name: GetSlotFlagsAsBundle_00003
278  * @tc.desc: Test GetSlotFlagsAsBundle
279  * @tc.type: FUNC
280  * @tc.require: issue
281  */
282 HWTEST_F(AnsSlotServiceTest, GetSlotFlagsAsBundle_00003, Function | SmallTest | Level1)
283 {
284     sptr<NotificationBundleOption> bundle = nullptr;
285     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP);
286     MockIsSystemApp(true);
287     MockIsVerfyPermisson(true);
288     auto ret = advancedNotificationService_->SetSlotFlagsAsBundle(bundle, 1);
289     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE);
290 
291     uint32_t flag = 0;
292     ret = advancedNotificationService_->GetSlotFlagsAsBundle(bundle, flag);
293     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE);
294 }
295 
296 /**
297  * @tc.name: GetSlotFlagsAsBundle_00004
298  * @tc.desc: Test GetSlotFlagsAsBundle
299  * @tc.type: FUNC
300  * @tc.require: issue
301  */
302 HWTEST_F(AnsSlotServiceTest, GetSlotFlagsAsBundle_00004, Function | SmallTest | Level1)
303 {
304     sptr<NotificationBundleOption> bundle = new NotificationBundleOption("test", 1);
305     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP);
306     MockIsSystemApp(true);
307     MockIsVerfyPermisson(true);
308     advancedNotificationService_->notificationSvrQueue_ = nullptr;
309     auto ret = advancedNotificationService_->SetSlotFlagsAsBundle(bundle, 1);
310     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
311 
312     uint32_t flag = 0;
313     ret = advancedNotificationService_->GetSlotFlagsAsBundle(bundle, flag);
314     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
315 }
316 
317 /**
318  * @tc.name: GetSlotFlagsAsBundle_00005
319  * @tc.desc: Test GetSlotFlagsAsBundle
320  * @tc.type: FUNC
321  * @tc.require: issue
322  */
323 HWTEST_F(AnsSlotServiceTest, GetSlotFlagsAsBundle_00005, Function | SmallTest | Level1)
324 {
325     sptr<NotificationBundleOption> bundle = new NotificationBundleOption("test", 1);
326     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP);
327     MockIsSystemApp(true);
328     MockIsVerfyPermisson(true);
329     auto ret = advancedNotificationService_->SetSlotFlagsAsBundle(bundle, 1);
330     ASSERT_EQ(ret, (int)ERR_OK);
331 
332     uint32_t flag = 0;
333     ret = advancedNotificationService_->GetSlotFlagsAsBundle(bundle, flag);
334     ASSERT_EQ(ret, (int)ERR_OK);
335     ASSERT_EQ(flag, 1);
336 }
337 
338 /**
339  * @tc.name: SetRequestBySlotType_00001
340  * @tc.desc: Test SetRequestBySlotType
341  * @tc.type: FUNC
342  * @tc.require: issue
343  */
344 HWTEST_F(AnsSlotServiceTest, SetRequestBySlotType_00001, Function | SmallTest | Level1)
345 {
346     sptr<NotificationRequest> request = new NotificationRequest();
347     request->SetSlotType(NotificationConstant::SlotType::CUSTOMER_SERVICE);
348     sptr<NotificationBundleOption> bundle = new (std::nothrow) NotificationBundleOption();
349     advancedNotificationService_->SetRequestBySlotType(request, bundle);
350     EXPECT_NE(request->GetFlags(), nullptr);
351 }
352 
353 /**
354  * @tc.name: GetSlotByType_00001
355  * @tc.desc: Test GetSlotByType
356  * @tc.type: FUNC
357  * @tc.require: issue
358  */
359 HWTEST_F(AnsSlotServiceTest, GetSlotByType_00001, Function | SmallTest | Level1)
360 {
361     sptr<NotificationSlot> slot;
362     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOMER_SERVICE;
363     advancedNotificationService_->notificationSvrQueue_ = nullptr;
364     auto ret = advancedNotificationService_->AddSlotByType(slotType);
365     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
366 
367     ret = advancedNotificationService_->GetSlotByType(slotType, slot);
368     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
369 }
370 
371 /**
372  * @tc.name: RemoveSlotByType_00001
373  * @tc.desc: Test RemoveSlotByType
374  * @tc.type: FUNC
375  * @tc.require: issue
376  */
377 HWTEST_F(AnsSlotServiceTest, RemoveSlotByType_00001, Function | SmallTest | Level1)
378 {
379     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOMER_SERVICE;
380     advancedNotificationService_->notificationSvrQueue_ = nullptr;
381     auto ret = advancedNotificationService_->RemoveSlotByType(slotType);
382     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
383 }
384 
385 /**
386  * @tc.name: RemoveSlotByType_00002
387  * @tc.desc: Test RemoveSlotByType
388  * @tc.type: FUNC
389  * @tc.require: issue
390  */
391 HWTEST_F(AnsSlotServiceTest, RemoveSlotByType_00002, Function | SmallTest | Level1)
392 {
393     MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP);
394     MockIsSystemApp(true);
395     MockIsVerfyPermisson(true);
396     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::LIVE_VIEW;
397     std::vector<sptr<NotificationSlot>> slots;
398     sptr<NotificationSlot> slot = new NotificationSlot(slotType);
399     slot->SetForceControl(true);
400     slots.push_back(slot);
401     ASSERT_EQ(advancedNotificationService_->AddSlots(slots), (int)ERR_OK);
402 
403     MockIsSystemApp(false);
404     auto ret = advancedNotificationService_->RemoveSlotByType(slotType);
405     ASSERT_EQ(ret, (int)ERR_ANS_NON_SYSTEM_APP);
406 }
407 
408 /**
409  * @tc.name: GetSlotNumAsBundle_00001
410  * @tc.desc: Test GetSlotNumAsBundle
411  * @tc.type: FUNC
412  * @tc.require: issue
413  */
414 HWTEST_F(AnsSlotServiceTest, GetSlotNumAsBundle_00001, Function | SmallTest | Level1)
415 {
416     sptr<NotificationBundleOption> bundle = new NotificationBundleOption("test", 1);
417     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP);
418     MockIsSystemApp(true);
419     MockIsVerfyPermisson(true);
420     advancedNotificationService_->notificationSvrQueue_ = nullptr;
421     uint64_t num = 0;
422     auto ret = advancedNotificationService_->GetSlotNumAsBundle(bundle, num);
423     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
424 }
425 
426 /**
427  * @tc.name: GetSlotByBundle_00001
428  * @tc.desc: Test GetSlotByBundle
429  * @tc.type: FUNC
430  * @tc.require: issue
431  */
432 HWTEST_F(AnsSlotServiceTest, GetSlotByBundle_00001, Function | SmallTest | Level1)
433 {
434     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOMER_SERVICE;
435     sptr<NotificationBundleOption> bundle = nullptr;
436     sptr<NotificationSlot> slot = nullptr;
437     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP);
438     MockIsSystemApp(false);
439     auto ret = advancedNotificationService_->GetSlotByBundle(bundle, slotType, slot);
440     ASSERT_EQ(ret, (int)ERR_ANS_NON_SYSTEM_APP);
441 }
442 
443 /**
444  * @tc.name: GetSlotByBundle_00002
445  * @tc.desc: Test GetSlotByBundle
446  * @tc.type: FUNC
447  * @tc.require: issue
448  */
449 HWTEST_F(AnsSlotServiceTest, GetSlotByBundle_00002, Function | SmallTest | Level1)
450 {
451     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOMER_SERVICE;
452     sptr<NotificationBundleOption> bundle = nullptr;
453     sptr<NotificationSlot> slot = nullptr;
454     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP);
455     MockIsSystemApp(true);
456     MockIsVerfyPermisson(false);
457 
458     auto ret = advancedNotificationService_->GetSlotByBundle(bundle, slotType, slot);
459     ASSERT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED);
460 
461     MockIsVerfyPermisson(true);
462     ret = advancedNotificationService_->GetSlotByBundle(bundle, slotType, slot);
463     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE);
464 
465     bundle = new NotificationBundleOption("test", 1);
466     ret = advancedNotificationService_->GetSlotByBundle(bundle, slotType, slot);
467     ASSERT_EQ(ret, (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_TYPE_NOT_EXIST);
468 }
469 
470 /**
471  * @tc.name: UpdateSlotReminderModeBySlotFlags_00001
472  * @tc.desc: Test UpdateSlotReminderModeBySlotFlags
473  * @tc.type: FUNC
474  * @tc.require: issue
475  */
476 HWTEST_F(AnsSlotServiceTest, UpdateSlotReminderModeBySlotFlags_00001, Function | SmallTest | Level1)
477 {
478     uint32_t slotFlags = 0b111011;
479     sptr<NotificationBundleOption> bundle = nullptr;
480     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP);
481     MockIsSystemApp(false);
482     auto ret = advancedNotificationService_->UpdateSlotReminderModeBySlotFlags(bundle, slotFlags);
483     ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM);
484 }
485 
486 /**
487  * @tc.name: UpdateSlotReminderModeBySlotFlags_00002
488  * @tc.desc: Test UpdateSlotReminderModeBySlotFlags
489  * @tc.type: FUNC
490  * @tc.require: issue
491  */
492 HWTEST_F(AnsSlotServiceTest, UpdateSlotReminderModeBySlotFlags_00002, Function | SmallTest | Level1)
493 {
494     uint32_t slotFlags = 0b000011;
495     sptr<NotificationBundleOption> bundle = new NotificationBundleOption("test", 1);
496     MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP);
497     MockIsSystemApp(true);
498     MockIsVerfyPermisson(true);
499 
500     sptr<NotificationSlot> slot = new (std::nothrow) NotificationSlot(NotificationConstant::SlotType::CUSTOMER_SERVICE);
501     advancedNotificationService_->GenerateSlotReminderMode(slot, bundle);
502     std::vector<sptr<NotificationSlot>> slots;
503     slots.push_back(slot);
504     NotificationPreferences::GetInstance()->AddNotificationSlots(bundle, slots);
505 
506     auto ret = advancedNotificationService_->UpdateSlotReminderModeBySlotFlags(bundle, slotFlags);
507     ASSERT_EQ(ret, (int)ERR_OK);
508 }
509 
510 /**
511  * @tc.name: GenerateSlotReminderMode_00001
512  * @tc.desc: Test GenerateSlotReminderMode
513  * @tc.type: FUNC
514  * @tc.require: issue
515  */
516 HWTEST_F(AnsSlotServiceTest, GenerateSlotReminderMode_00001, Function | SmallTest | Level1)
517 {
518     sptr<NotificationBundleOption> bundle = new (std::nothrow) NotificationBundleOption();
519     sptr<NotificationSlot> slot = new (std::nothrow) NotificationSlot(NotificationConstant::SlotType::SERVICE_REMINDER);
520     advancedNotificationService_->GenerateSlotReminderMode(slot, bundle);
521     ASSERT_EQ(slot->GetReminderMode(), (int)0b111011);
522 }
523 
524 /**
525  * @tc.name: GenerateSlotReminderMode_00002
526  * @tc.desc: Test GenerateSlotReminderMode
527  * @tc.type: FUNC
528  * @tc.require: issue
529  */
530 HWTEST_F(AnsSlotServiceTest, GenerateSlotReminderMode_00002, Function | SmallTest | Level1)
531 {
532     sptr<NotificationBundleOption> bundle = new (std::nothrow) NotificationBundleOption();
533     sptr<NotificationSlot> slot = new (std::nothrow) NotificationSlot(NotificationConstant::SlotType::SERVICE_REMINDER);
534     advancedNotificationService_->GenerateSlotReminderMode(slot, bundle, true);
535     ASSERT_EQ(slot->GetReminderMode(), (int)0b111011);
536 }
537 
538 /**
539  * @tc.name: GetConfigSlotReminderModeByType_00001
540  * @tc.desc: Test GenerateSlotReminderMode
541  * @tc.type: FUNC
542  * @tc.require: issue
543  */
544 HWTEST_F(AnsSlotServiceTest, GetConfigSlotReminderModeByType_00001, Function | SmallTest | Level1)
545 {
546     NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER;
547     auto reminderMode =
548         DelayedSingleton<NotificationConfigParse>::GetInstance()->GetConfigSlotReminderModeByType(slotType);
549     ASSERT_EQ(reminderMode, (int)0b111111);
550 }
551 }  // namespace Notification
552 }  // namespace OHOS
553