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