1 /* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <gtest/gtest.h> 17 18 #define private public 19 #define protected public 20 #include "reminder_request.h" 21 #include "reminder_table.h" 22 #undef private 23 #undef protected 24 25 extern void MockNowInstantMilli(bool mockRet); 26 27 using namespace testing::ext; 28 namespace OHOS { 29 namespace Notification { 30 class ReminderRequestChild : public ReminderRequest { 31 public: ReminderRequestChild()32 ReminderRequestChild() : ReminderRequest() {}; 33 }; 34 35 class ReminderRequestTest : public testing::Test { 36 public: SetUpTestCase()37 static void SetUpTestCase() {} TearDownTestCase()38 static void TearDownTestCase() {} SetUp()39 void SetUp() {} TearDown()40 void TearDown() {} 41 42 static const uint8_t REMINDER_STATUS_SHOWING; 43 }; 44 45 const uint8_t ReminderRequestTest::REMINDER_STATUS_SHOWING = 4; 46 47 /** 48 * @tc.name: CanRemove_00100 49 * @tc.desc: When reminder init, CanRemove should return true. 50 * @tc.type: FUNC 51 * @tc.require: SR000GGTRD AR000GH8EF 52 */ 53 HWTEST_F(ReminderRequestTest, CanRemove_00100, Function | SmallTest | Level1) 54 { 55 auto rrc = std::make_shared<ReminderRequestChild>(); 56 EXPECT_TRUE(rrc->CanRemove()) << "When init, canRemove should be false"; 57 } 58 59 /** 60 * @tc.name: CanRemove_00200 61 * @tc.desc: When reminder is shown, CanRemove should return false. 62 * @tc.type: FUNC 63 * @tc.require: SR000GGTRD AR000GH8EF 64 */ 65 HWTEST_F(ReminderRequestTest, CanRemove_00200, Function | SmallTest | Level1) 66 { 67 auto rrc = std::make_shared<ReminderRequestChild>(); 68 rrc->OnShow(false, false, true); 69 EXPECT_FALSE(rrc->CanRemove()) << "When shown, canRemove should be false"; 70 } 71 72 /** 73 * @tc.name: CanRemove_00300 74 * @tc.desc: When reminder close, CanRemove should return true. 75 * @tc.type: FUNC 76 * @tc.require: SR000GGTRD AR000GH8EF 77 */ 78 HWTEST_F(ReminderRequestTest, CanRemove_00300, Function | SmallTest | Level1) 79 { 80 auto rrc = std::make_shared<ReminderRequestChild>(); 81 rrc->OnShow(false, false, true); 82 rrc->OnClose(false); 83 EXPECT_TRUE(rrc->CanRemove()) << "When reminder is expired and closed, can remove should be false"; 84 } 85 86 /** 87 * @tc.name: CanRemove_00400 88 * @tc.desc: When reminder is covered as same notification id, CanRemove should return true. 89 * @tc.type: FUNC 90 * @tc.require: SR000GGTRD AR000GH8EF AR000GH8E6 91 */ 92 HWTEST_F(ReminderRequestTest, CanRemove_00400, Function | SmallTest | Level1) 93 { 94 auto rrc = std::make_shared<ReminderRequestChild>(); 95 rrc->OnShow(false, false, true); 96 rrc->OnSameNotificationIdCovered(); 97 EXPECT_TRUE(rrc->CanRemove()) << "When reminder is expired and covered by \ 98 sameNotification id, can remove should be true"; 99 } 100 101 /** 102 * @tc.name: StateCheck_00100 103 * @tc.desc: When reminder init, state should be 0. 104 * @tc.type: FUNC 105 * @tc.require: SR000GGTRD AR000GH8EF 106 */ 107 HWTEST_F(ReminderRequestTest, StateCheck_00100, Function | SmallTest | Level1) 108 { 109 auto rrc = std::make_shared<ReminderRequestChild>(); 110 EXPECT_EQ(rrc->GetState(), 0) << "When init, state should be 0"; 111 } 112 113 /** 114 * @tc.name: StateCheck_00200 115 * @tc.desc: When reminder close with param true, state REMINDER_STATUS_SHOWING should be unset. 116 * @tc.type: FUNC 117 * @tc.require: SR000GGTRD AR000GH8EF 118 */ 119 HWTEST_F(ReminderRequestTest, StateCheck_00200, Function | SmallTest | Level1) 120 { 121 auto rrc = std::make_shared<ReminderRequestChild>(); 122 rrc->OnClose(true); 123 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) == 0); 124 } 125 126 /** 127 * @tc.name: StateCheck_00300 128 * @tc.desc: When reminder close with param false, state REMINDER_STATUS_SHOWING should be unset. 129 * @tc.type: FUNC 130 * @tc.require: SR000GGTRD AR000GH8EF 131 */ 132 HWTEST_F(ReminderRequestTest, StateCheck_00300, Function | SmallTest | Level1) 133 { 134 auto rrc = std::make_shared<ReminderRequestChild>(); 135 rrc->OnClose(false); 136 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) == 0); 137 } 138 139 /** 140 * @tc.name: StateCheck_00400 141 * @tc.desc: When reminder is covered as same notification id, state REMINDER_STATUS_SHOWING should be unset. 142 * @tc.type: FUNC 143 * @tc.require: SR000GGTRD AR000GH8EF AR000GH8E6 144 */ 145 HWTEST_F(ReminderRequestTest, StateCheck_00400, Function | SmallTest | Level1) 146 { 147 auto rrc = std::make_shared<ReminderRequestChild>(); 148 rrc->OnSameNotificationIdCovered(); 149 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) == 0); 150 } 151 152 /** 153 * @tc.name: StateCheck_00500 154 * @tc.desc: When reminder is shown with param true,true, state REMINDER_STATUS_SHOWING should be set. 155 * @tc.type: FUNC 156 * @tc.require: SR000GGTRD AR000GH8EF 157 */ 158 HWTEST_F(ReminderRequestTest, StateCheck_00500, Function | SmallTest | Level1) 159 { 160 auto rrc = std::make_shared<ReminderRequestChild>(); 161 rrc->OnShow(false, true, true); 162 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) != 0); 163 } 164 165 /** 166 * @tc.name: StateCheck_00600 167 * @tc.desc: When reminder is shown with param false,true, state REMINDER_STATUS_SHOWING should be set. 168 * @tc.type: FUNC 169 * @tc.require: SR000GGTRD AR000GH8EF 170 */ 171 HWTEST_F(ReminderRequestTest, StateCheck_00600, Function | SmallTest | Level1) 172 { 173 auto rrc = std::make_shared<ReminderRequestChild>(); 174 rrc->OnShow(false, false, true); 175 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) != 0); 176 } 177 178 /** 179 * @tc.name: StateCheck_00700 180 * @tc.desc: When reminder is shown with param true,false, state REMINDER_STATUS_SHOWING should not change. 181 * @tc.type: FUNC 182 * @tc.require: SR000GGTRD AR000GH8EF 183 */ 184 HWTEST_F(ReminderRequestTest, StateCheck_00700, Function | SmallTest | Level1) 185 { 186 auto rrc = std::make_shared<ReminderRequestChild>(); 187 uint8_t stateBefore = rrc->GetState(); 188 rrc->OnShow(false, true, false); 189 EXPECT_EQ(rrc->GetState(), stateBefore); 190 } 191 192 /** 193 * @tc.name: StateCheck_00800 194 * @tc.desc: When reminder is shown with param false,false, state REMINDER_STATUS_SHOWING should be unset. 195 * @tc.type: FUNC 196 * @tc.require: SR000GGTRD AR000GH8EF 197 */ 198 HWTEST_F(ReminderRequestTest, StateCheck_00800, Function | SmallTest | Level1) 199 { 200 auto rrc = std::make_shared<ReminderRequestChild>(); 201 uint8_t stateBefore = rrc->GetState(); 202 rrc->OnShow(false, false, false); 203 EXPECT_EQ(rrc->GetState(), stateBefore); 204 } 205 206 /** 207 * @tc.name: initReminderId_00100 208 * @tc.desc: When reminder create successfully, system should assign unique id to reminder. 209 * @tc.type: FUNC 210 * @tc.require: SR000GGTRD AR000GH8EF AR000GH8E6 211 */ 212 HWTEST_F(ReminderRequestTest, initReminderId_00100, Function | SmallTest | Level1) 213 { 214 auto rrc = std::make_shared<ReminderRequestChild>(); 215 rrc->InitReminderId(); 216 int32_t reminderIdBefore = rrc->GetReminderId(); 217 rrc->InitReminderId(); 218 int32_t reminderIdAfter = rrc->GetReminderId(); 219 EXPECT_EQ((reminderIdAfter - reminderIdBefore), 1); 220 } 221 222 /** 223 * @tc.name: setContent_00100 224 * @tc.desc: Test SetContent with normal parameters. 225 * @tc.type: FUNC 226 * @tc.require: SR000GGTRD AR000GH8EF 227 */ 228 HWTEST_F(ReminderRequestTest, setContent_00100, Function | SmallTest | Level1) 229 { 230 auto rrc = std::make_shared<ReminderRequestChild>(); 231 std::string content = "this is normal content"; 232 rrc->SetContent(content); 233 EXPECT_EQ(rrc->GetContent(), content); 234 } 235 236 /** 237 * @tc.name: setContent_00200 238 * @tc.desc: Test SetContent parameters with special characters. 239 * @tc.type: FUNC 240 * @tc.require: SR000GGTRD AR000GH8EF 241 */ 242 HWTEST_F(ReminderRequestTest, setContent_00200, Function | SmallTest | Level1) 243 { 244 auto rrc = std::make_shared<ReminderRequestChild>(); 245 std::string content = "this is content with special characters: ~!@#$%^&*()-+"; 246 rrc->SetContent(content); 247 EXPECT_EQ(rrc->GetContent(), content); 248 } 249 250 /** 251 * @tc.name: setExpiredContent_00100 252 * @tc.desc: Test SetExpiredContent with normal parameters. 253 * @tc.type: FUNC 254 * @tc.require: SR000GGTRD AR000GH8EF AR000GNF1U AR000GNF1U 255 */ 256 HWTEST_F(ReminderRequestTest, setExpiredContent_00100, Function | SmallTest | Level1) 257 { 258 auto rrc = std::make_shared<ReminderRequestChild>(); 259 std::string content = "this is normal content"; 260 rrc->SetExpiredContent(content); 261 EXPECT_EQ(rrc->GetExpiredContent(), content); 262 } 263 264 /** 265 * @tc.name: setExpiredContent_00200 266 * @tc.desc: Test SetExpiredContent with special characters. 267 * @tc.type: FUNC 268 * @tc.require: SR000GGTRD AR000GH8EF AR000GNF1U AR000GNF1U 269 */ 270 HWTEST_F(ReminderRequestTest, setExpiredContent_00200, Function | SmallTest | Level1) 271 { 272 auto rrc = std::make_shared<ReminderRequestChild>(); 273 std::string content = "this is content with special characters: ~!@#$%^&*()-+"; 274 rrc->SetExpiredContent(content); 275 EXPECT_EQ(rrc->GetExpiredContent(), content); 276 } 277 278 /** 279 * @tc.name: setTitle_00100 280 * @tc.desc: Test SetTitle with normal parameters. 281 * @tc.type: FUNC 282 * @tc.require: SR000GGTRD AR000GH8EF 283 */ 284 HWTEST_F(ReminderRequestTest, setTitle_00100, Function | SmallTest | Level1) 285 { 286 auto rrc = std::make_shared<ReminderRequestChild>(); 287 std::string content = "this is normal content"; 288 rrc->SetTitle(content); 289 EXPECT_EQ(rrc->GetTitle(), content); 290 } 291 292 /** 293 * @tc.name: setTitle_00200 294 * @tc.desc: Test SetTitle with special characters. 295 * @tc.type: FUNC 296 * @tc.require: SR000GGTRD AR000GH8EF 297 */ 298 HWTEST_F(ReminderRequestTest, setTitle_00200, Function | SmallTest | Level1) 299 { 300 auto rrc = std::make_shared<ReminderRequestChild>(); 301 std::string content = "this is content with special characters: ~!@#$%^&*()-+"; 302 rrc->SetTitle(content); 303 EXPECT_EQ(rrc->GetTitle(), content); 304 } 305 306 /** 307 * @tc.name: setNotificationId_00100 308 * @tc.desc: Test SetNotificationId parameters. 309 * @tc.type: FUNC 310 * @tc.require: SR000GGTRD AR000GH8EF 311 */ 312 HWTEST_F(ReminderRequestTest, setNotificationId_00100, Function | SmallTest | Level1) 313 { 314 auto rrc = std::make_shared<ReminderRequestChild>(); 315 int32_t notificationId = 0; 316 rrc->SetNotificationId(notificationId); 317 EXPECT_EQ(rrc->GetNotificationId(), notificationId); 318 } 319 320 /** 321 * @tc.name: setSnoozeTimes_00100 322 * @tc.desc: Test SetSnoozeTimes parameters. 323 * @tc.type: FUNC 324 * @tc.require: AR000GNF1T AR000GH8E7 325 */ 326 HWTEST_F(ReminderRequestTest, setSnoozeTimes_00100, Function | SmallTest | Level1) 327 { 328 auto rrc = std::make_shared<ReminderRequestChild>(); 329 rrc->SetSnoozeTimes(1); 330 EXPECT_EQ(rrc->GetSnoozeTimes(), 1) << "Get snoozeTimes not 1"; 331 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1) << "Get snoozeTimesDynamic not 1"; 332 } 333 334 /** 335 * @tc.name: setTimeInterval_00100 336 * @tc.desc: Test SetTimeInterval parameters. 337 * @tc.type: FUNC 338 * @tc.require: AR000GNF1T 339 */ 340 HWTEST_F(ReminderRequestTest, setTimeInterval_00100, Function | SmallTest | Level1) 341 { 342 uint32_t minTimeIntervalInSecond = 5 * 60; 343 auto rrc = std::make_shared<ReminderRequestChild>(); 344 rrc->SetTimeInterval(-1); 345 EXPECT_EQ(rrc->GetTimeInterval(), 0) << "timeInterval should be 0 when set with value less than 0"; 346 rrc->SetTimeInterval(0); 347 EXPECT_EQ(rrc->GetTimeInterval(), 0) << "timeInterval should be 0 when set with value 0"; 348 rrc->SetTimeInterval(1); 349 EXPECT_EQ(rrc->GetTimeInterval(), minTimeIntervalInSecond) 350 << "0 < timeInterval < minTimeInterval should be set to minTimeInterval"; 351 uint32_t timeInterval = minTimeIntervalInSecond; 352 rrc->SetTimeInterval(timeInterval); 353 EXPECT_EQ(rrc->GetTimeInterval(), timeInterval) << "timeInterval set error"; 354 timeInterval = minTimeIntervalInSecond + 1; 355 rrc->SetTimeInterval(timeInterval); 356 EXPECT_EQ(rrc->GetTimeInterval(), timeInterval) << "timeInterval set error."; 357 } 358 359 /** 360 * @tc.name: IsExpired_00100 361 * @tc.desc: Test IsExpired parameters. 362 * @tc.type: FUNC 363 * @tc.require: issueI5QVYA 364 */ 365 HWTEST_F(ReminderRequestTest, IsExpired_00100, Function | SmallTest | Level1) 366 { 367 auto rrc = std::make_shared<ReminderRequestChild>(); 368 EXPECT_EQ(rrc->IsExpired(), false); 369 } 370 371 /** 372 * @tc.name: IsShowing_00100 373 * @tc.desc: Test IsShowing parameters. 374 * @tc.type: FUNC 375 * @tc.require: issueI5QVYA 376 */ 377 HWTEST_F(ReminderRequestTest, IsShowing_00100, Function | SmallTest | Level1) 378 { 379 auto rrc = std::make_shared<ReminderRequestChild>(); 380 EXPECT_EQ(rrc->IsShowing(), false); 381 } 382 383 /** 384 * @tc.name: IsShowing_00200 385 * @tc.desc: Test IsShowing parameters. 386 * @tc.type: FUNC 387 * @tc.require: issueI5QVYA 388 */ 389 HWTEST_F(ReminderRequestTest, IsShowing_00200, Function | SmallTest | Level1) 390 { 391 auto rrc = std::make_shared<ReminderRequestChild>(); 392 bool deSet = true; 393 uint8_t newState = 4; 394 std::string function = "this is function"; 395 rrc->SetState(deSet, newState, function); 396 uint8_t result1 = rrc->GetState(); 397 EXPECT_EQ(result1, 4); 398 bool result = rrc->IsShowing(); 399 EXPECT_EQ(result, true); 400 } 401 402 /** 403 * @tc.name: OnDateTimeChange_00100 404 * @tc.desc: Test OnDateTimeChange parameters. 405 * @tc.type: FUNC 406 * @tc.require: issueI5QVYA 407 */ 408 HWTEST_F(ReminderRequestTest, OnDateTimeChange_00100, Function | SmallTest | Level1) 409 { 410 auto rrc = std::make_shared<ReminderRequestChild>(); 411 rrc->SetExpired(true); 412 EXPECT_EQ(rrc->OnDateTimeChange(), false); 413 } 414 415 /** 416 * @tc.name: OnSnooze_00100 417 * @tc.desc: Test OnSnooze parameters. 418 * @tc.type: FUNC 419 * @tc.require: issueI5QVYA 420 */ 421 HWTEST_F(ReminderRequestTest, OnSnooze_00100, Function | SmallTest | Level1) 422 { 423 MockNowInstantMilli(true); 424 auto rrc = std::make_shared<ReminderRequestChild>(); 425 EXPECT_EQ(rrc->OnSnooze(), true); 426 } 427 428 /** 429 * @tc.name: OnTerminate_00100 430 * @tc.desc: Test OnTerminate parameters. 431 * @tc.type: FUNC 432 * @tc.require: issueI5QVYA 433 */ 434 HWTEST_F(ReminderRequestTest, OnTerminate_00100, Function | SmallTest | Level1) 435 { 436 auto rrc = std::make_shared<ReminderRequestChild>(); 437 EXPECT_EQ(rrc->OnTerminate(), false); 438 } 439 440 /** 441 * @tc.name: ShouldShowImmediately_00100 442 * @tc.desc: Test ShouldShowImmediately parameters. 443 * @tc.type: FUNC 444 * @tc.require: issueI5QVYA 445 */ 446 HWTEST_F(ReminderRequestTest, ShouldShowImmediately_00100, Function | SmallTest | Level1) 447 { 448 MockNowInstantMilli(true); 449 auto rrc = std::make_shared<ReminderRequestChild>(); 450 EXPECT_EQ(rrc->ShouldShowImmediately(), true); 451 } 452 453 /** 454 * @tc.name: GetSlotType_00100 455 * @tc.desc: Test GetSlotType parameters. 456 * @tc.type: FUNC 457 * @tc.require: issueI5QVYA 458 */ 459 HWTEST_F(ReminderRequestTest, GetSlotType_00100, Function | SmallTest | Level1) 460 { 461 auto rrc = std::make_shared<ReminderRequestChild>(); 462 NotificationConstant::SlotType mySlotType = NotificationConstant::OTHER; 463 rrc->SetSlotType(mySlotType); 464 EXPECT_EQ(rrc->GetSlotType(), mySlotType); 465 } 466 467 /** 468 * @tc.name: GetTriggerTimeInMilli_00100 469 * @tc.desc: Test GetTriggerTimeInMilli parameters. 470 * @tc.type: FUNC 471 * @tc.require: issueI5QVYA 472 */ 473 HWTEST_F(ReminderRequestTest, GetTriggerTimeInMilli_00100, Function | SmallTest | Level1) 474 { 475 auto rrc = std::make_shared<ReminderRequestChild>(); 476 uint64_t triggerTimeInMilliTest = 1; 477 rrc->SetTriggerTimeInMilli(triggerTimeInMilliTest); 478 EXPECT_EQ(rrc->GetTriggerTimeInMilli(), triggerTimeInMilliTest); 479 } 480 481 /** 482 * @tc.name: GetUserId_00100 483 * @tc.desc: Test GetUserId parameters. 484 * @tc.type: FUNC 485 * @tc.require: issueI5QVYA 486 */ 487 HWTEST_F(ReminderRequestTest, GetUserId_00100, Function | SmallTest | Level1) 488 { 489 auto rrc = std::make_shared<ReminderRequestChild>(); 490 EXPECT_EQ(rrc->GetUserId(), -1); 491 } 492 493 /** 494 * @tc.name: GetUid_00100 495 * @tc.desc: Test GetUid parameters. 496 * @tc.type: FUNC 497 * @tc.require: issueI5QVYA 498 */ 499 HWTEST_F(ReminderRequestTest, GetUid_00100, Function | SmallTest | Level1) 500 { 501 auto rrc = std::make_shared<ReminderRequestChild>(); 502 EXPECT_EQ(rrc->GetUid(), -1); 503 } 504 505 /** 506 * @tc.name: GetReminderType_00100 507 * @tc.desc: Test GetReminderType parameters. 508 * @tc.type: FUNC 509 * @tc.require: issueI5QVYA 510 */ 511 HWTEST_F(ReminderRequestTest, GetReminderType_00100, Function | SmallTest | Level1) 512 { 513 auto rrc = std::make_shared<ReminderRequestChild>(); 514 EXPECT_EQ(rrc->GetReminderType(), ReminderRequest::ReminderType::INVALID); 515 } 516 517 /** 518 * @tc.name: GetRingDuration_00100 519 * @tc.desc: Test GetRingDuration parameters. 520 * @tc.type: FUNC 521 * @tc.require: issueI5QVYA 522 */ 523 HWTEST_F(ReminderRequestTest, GetRingDuration_00100, Function | SmallTest | Level1) 524 { 525 auto rrc = std::make_shared<ReminderRequestChild>(); 526 EXPECT_EQ(rrc->GetRingDuration(), 1); 527 } 528 529 /** 530 * @tc.name: SetNextTriggerTime_00100 531 * @tc.desc: Test SetNextTriggerTime parameters. 532 * @tc.type: FUNC 533 * @tc.require: issueI5QVYA 534 */ 535 HWTEST_F(ReminderRequestTest, SetNextTriggerTime_00100, Function | SmallTest | Level1) 536 { 537 auto rrc = std::make_shared<ReminderRequestChild>(); 538 EXPECT_EQ(rrc->SetNextTriggerTime(), false); 539 } 540 541 /** 542 * @tc.name: Marshalling_00100 543 * @tc.desc: Test Marshalling parameters. 544 * @tc.type: FUNC 545 * @tc.require: issueI5QVYA 546 */ 547 HWTEST_F(ReminderRequestTest, Marshalling_00100, Function | SmallTest | Level1) 548 { 549 auto rrc = std::make_shared<ReminderRequestChild>(); 550 Parcel p; 551 EXPECT_EQ(rrc->Marshalling(p), true); 552 } 553 554 /** 555 * @tc.name: CanShow_00001 556 * @tc.desc: Test CanShow parameters. 557 * @tc.type: FUNC 558 * @tc.require: issueI5UYHP 559 */ 560 HWTEST_F(ReminderRequestTest, CanShow_00001, Function | SmallTest | Level1) 561 { 562 MockNowInstantMilli(true); 563 auto rrc = std::make_shared<ReminderRequestChild>(); 564 EXPECT_EQ(rrc->CanShow(), true); 565 } 566 567 /** 568 * @tc.name: Dump_00001 569 * @tc.desc: Test Dump parameters. 570 * @tc.type: FUNC 571 * @tc.require: issueI5UYHP 572 */ 573 HWTEST_F(ReminderRequestTest, Dump_00001, Function | SmallTest | Level1) 574 { 575 std::string ret = "Reminder[reminderId=-1, type=3, state='Inactive', nextTriggerTime="; 576 auto rrc = std::make_shared<ReminderRequestChild>(); 577 std::string res = rrc->Dump(); 578 EXPECT_EQ(res.substr(0, res.size()-20), ret); 579 } 580 581 /** 582 * @tc.name: SetExpired_00001 583 * @tc.desc: Test SetExpired parameters. 584 * @tc.type: FUNC 585 * @tc.require: issueI5UYHP 586 */ 587 HWTEST_F(ReminderRequestTest, SetExpired_00001, Function | SmallTest | Level1) 588 { 589 auto rrc = std::make_shared<ReminderRequestChild>(); 590 bool isExpired = rrc->IsExpired(); 591 rrc->SetExpired(isExpired); 592 EXPECT_EQ(isExpired, false); 593 } 594 595 /** 596 * @tc.name: HandleTimeZoneChange_00001 597 * @tc.desc: Test HandleTimeZoneChange parameters. 598 * @tc.type: FUNC 599 * @tc.require: issueI5UYHP 600 */ 601 HWTEST_F(ReminderRequestTest, HandleTimeZoneChange_00001, Function | SmallTest | Level1) 602 { 603 auto rrc = std::make_shared<ReminderRequestChild>(); 604 rrc->SetExpired(false); 605 uint64_t oldZoneTriggerTime = 1998; 606 uint64_t newZoneTriggerTime = 1999; 607 uint64_t optTriggerTime = 0; 608 EXPECT_EQ(rrc->HandleTimeZoneChange(oldZoneTriggerTime, newZoneTriggerTime, optTriggerTime), true); 609 } 610 611 /** 612 * @tc.name: HandleTimeZoneChange_00002 613 * @tc.desc: Test HandleTimeZoneChange parameters. 614 * @tc.type: FUNC 615 * @tc.require: issueI5UYHP 616 */ 617 HWTEST_F(ReminderRequestTest, HandleTimeZoneChange_00002, Function | SmallTest | Level1) 618 { 619 auto rrc = std::make_shared<ReminderRequestChild>(); 620 rrc->SetExpired(true); 621 uint64_t oldZoneTriggerTime = 1998; 622 uint64_t newZoneTriggerTime = 1998; 623 uint64_t optTriggerTime = 0; 624 EXPECT_EQ(rrc->HandleTimeZoneChange(oldZoneTriggerTime, newZoneTriggerTime, optTriggerTime), false); 625 } 626 627 /** 628 * @tc.name: HandleTimeZoneChange_00003 629 * @tc.desc: Test HandleTimeZoneChange parameters. 630 * @tc.type: FUNC 631 * @tc.require: issueI5UYHP 632 */ 633 HWTEST_F(ReminderRequestTest, HandleTimeZoneChange_00003, Function | SmallTest | Level1) 634 { 635 auto rrc = std::make_shared<ReminderRequestChild>(); 636 rrc->SetExpired(true); 637 uint64_t oldZoneTriggerTime = 1998; 638 uint64_t newZoneTriggerTime = 1999; 639 uint64_t optTriggerTime = 10; 640 EXPECT_EQ(rrc->HandleTimeZoneChange(oldZoneTriggerTime, newZoneTriggerTime, optTriggerTime), false); 641 } 642 643 /** 644 * @tc.name: HandleTimeZoneChange_00001 645 * @tc.desc: Test HandleSysTimeChange parameters. 646 * @tc.type: FUNC 647 * @tc.require: issueI5UYHP 648 */ 649 HWTEST_F(ReminderRequestTest, HandleSysTimeChange_00001, Function | SmallTest | Level1) 650 { 651 auto rrc = std::make_shared<ReminderRequestChild>(); 652 rrc->SetExpired(true); 653 uint64_t oriTriggerTime = 10; 654 uint64_t optTriggerTime = 10; 655 EXPECT_EQ(rrc->HandleSysTimeChange(oriTriggerTime, optTriggerTime), false); 656 } 657 658 /** 659 * @tc.name: HandleTimeZoneChange_00002 660 * @tc.desc: Test HandleSysTimeChange parameters. 661 * @tc.type: FUNC 662 * @tc.require: issueI5UYHP 663 */ 664 HWTEST_F(ReminderRequestTest, HandleSysTimeChange_00002, Function | SmallTest | Level1) 665 { 666 auto rrc = std::make_shared<ReminderRequestChild>(); 667 rrc->SetExpired(false); 668 uint64_t oriTriggerTime = 10; 669 uint64_t optTriggerTime = 20; 670 MockNowInstantMilli(false); 671 EXPECT_EQ(rrc->HandleSysTimeChange(oriTriggerTime, optTriggerTime), false); 672 } 673 674 /** 675 * @tc.name: OnSnooze_00001 676 * @tc.desc: Test OnSnooze parameters. 677 * @tc.type: FUNC 678 * @tc.require: issueI5UYHP 679 */ 680 HWTEST_F(ReminderRequestTest, OnSnooze_00001, Function | SmallTest | Level1) 681 { 682 MockNowInstantMilli(true); 683 auto rrc = std::make_shared<ReminderRequestChild>(); 684 rrc->OnShow(false, false, true); 685 EXPECT_EQ(rrc->OnSnooze(), true); 686 } 687 688 /** 689 * @tc.name: OnSnooze_00002 690 * @tc.desc: Test OnSnooze parameters. 691 * @tc.type: FUNC 692 * @tc.require: issueI5UYHP 693 */ 694 HWTEST_F(ReminderRequestTest, OnSnooze_00002, Function | SmallTest | Level1) 695 { 696 MockNowInstantMilli(true); 697 auto rrc = std::make_shared<ReminderRequestChild>(); 698 rrc->UpdateNextReminder(false); 699 EXPECT_EQ(rrc->OnSnooze(), true); 700 } 701 702 /** 703 * @tc.name: OnSnooze_00003 704 * @tc.desc: Test OnSnooze parameters. 705 * @tc.type: FUNC 706 * @tc.require: issueI5UYHP 707 */ 708 HWTEST_F(ReminderRequestTest, OnSnooze_00003, Function | SmallTest | Level1) 709 { 710 MockNowInstantMilli(true); 711 auto rrc = std::make_shared<ReminderRequestChild>(); 712 rrc->SetTimeInterval(100); 713 EXPECT_EQ(rrc->OnSnooze(), true); 714 } 715 716 /** 717 * @tc.name: OnSnooze_00004 718 * @tc.desc: Test OnSnooze parameters. 719 * @tc.type: FUNC 720 * @tc.require: issueI5UYHP 721 */ 722 HWTEST_F(ReminderRequestTest, OnSnooze_00004, Function | SmallTest | Level1) 723 { 724 auto rrc = std::make_shared<ReminderRequestChild>(); 725 bool deSet = true; 726 uint8_t newState = 8; 727 std::string function = "this is function"; 728 rrc->SetState(deSet, newState, function); 729 uint8_t result1 = rrc->GetState(); 730 EXPECT_EQ(result1, 8); 731 EXPECT_EQ(rrc->OnSnooze(), false); 732 } 733 734 /** 735 * @tc.name: OnSnooze_00005 736 * @tc.desc: Test OnSnooze parameters. 737 * @tc.type: FUNC 738 * @tc.require: issueI5UYHP 739 */ 740 HWTEST_F(ReminderRequestTest, OnSnooze_00005, Function | SmallTest | Level1) 741 { 742 MockNowInstantMilli(true); 743 auto rrc = std::make_shared<ReminderRequestChild>(); 744 bool deSet = true; 745 uint8_t newState = 1; 746 std::string function = "this is function"; 747 rrc->SetState(deSet, newState, function); 748 uint8_t result1 = rrc->GetState(); 749 EXPECT_EQ(result1, 1); 750 EXPECT_EQ(rrc->OnSnooze(), true); 751 } 752 753 /** 754 * @tc.name: OnTerminate_00001 755 * @tc.desc: Test OnTerminate parameters. 756 * @tc.type: FUNC 757 * @tc.require: issueI5UYHP 758 */ 759 HWTEST_F(ReminderRequestTest, OnTerminate_00001, Function | SmallTest | Level1) 760 { 761 auto rrc = std::make_shared<ReminderRequestChild>(); 762 rrc->OnShow(false, false, true); 763 EXPECT_EQ(rrc->OnTerminate(), false); 764 } 765 766 /** 767 * @tc.name: OnTimeZoneChange_00001 768 * @tc.desc: Test OnTerOnTimeZoneChangeminate parameters. 769 * @tc.type: FUNC 770 * @tc.require: issueI5UYHP 771 */ 772 HWTEST_F(ReminderRequestTest, OnTimeZoneChange_00001, Function | SmallTest | Level1) 773 { 774 auto rrc = std::make_shared<ReminderRequestChild>(); 775 uint64_t ret = rrc->GetTriggerTimeInMilli(); 776 struct tm oriTime; 777 time_t newZoneTriggerTime = mktime(&oriTime); 778 uint64_t ret2 = rrc->GetDurationSinceEpochInMilli(newZoneTriggerTime); 779 if (ret == ret2) { 780 EXPECT_EQ(rrc->OnTimeZoneChange(), false); 781 } else { 782 EXPECT_EQ(rrc->OnTimeZoneChange(), true); 783 } 784 } 785 786 /** 787 * @tc.name: RecoverInt64FromDb_00001 788 * @tc.desc: Test RecoverInt64FromDb parameters. 789 * @tc.type: FUNC 790 * @tc.require: issueI5UYHP 791 */ 792 HWTEST_F(ReminderRequestTest, RecoverInt64FromDb_00001, Function | SmallTest | Level1) 793 { 794 std::shared_ptr<NativeRdb::ResultSet> resultSet = nullptr; 795 std::string columnName = "columnName"; 796 ReminderRequest::DbRecoveryType columnType = ReminderRequest::DbRecoveryType::INT; 797 auto rrc = std::make_shared<ReminderRequestChild>(); 798 EXPECT_EQ(rrc->RecoverInt64FromDb(resultSet, columnName, columnType), 0); 799 } 800 801 /** 802 * @tc.name: StringSplit_00001 803 * @tc.desc: Test StringSplit parameters. 804 * @tc.type: FUNC 805 * @tc.require: issueI5UYHP 806 */ 807 HWTEST_F(ReminderRequestTest, StringSplit_00001, Function | SmallTest | Level1) 808 { 809 std::string source = ""; 810 std::string split = "split"; 811 auto rrc = std::make_shared<ReminderRequestChild>(); 812 std::vector<std::string> ret = rrc->StringSplit(source, split); 813 EXPECT_EQ(ret.size(), 0); 814 } 815 816 /** 817 * @tc.name: StringSplit_00002 818 * @tc.desc: Test StringSplit parameters. 819 * @tc.type: FUNC 820 * @tc.require: issueI5UYHP 821 */ 822 HWTEST_F(ReminderRequestTest, StringSplit_00002, Function | SmallTest | Level1) 823 { 824 std::string source = "source"; 825 std::string split = "split"; 826 auto rrc = std::make_shared<ReminderRequestChild>(); 827 std::vector<std::string> ret = rrc->StringSplit(source, split); 828 EXPECT_EQ(ret.size(), 1); 829 } 830 831 /** 832 * @tc.name: SetMaxScreenWantAgentInfo_00001 833 * @tc.desc: Test SetMaxScreenWantAgentInfo parameters. 834 * @tc.type: FUNC 835 * @tc.require: issueI5UYHP 836 */ 837 HWTEST_F(ReminderRequestTest, SetMaxScreenWantAgentInfo_00001, Function | SmallTest | Level1) 838 { 839 std::shared_ptr<ReminderRequest::MaxScreenAgentInfo> maxScreenWantAgentInfo = 840 std::make_shared<ReminderRequest::MaxScreenAgentInfo>(); 841 auto rrc = std::make_shared<ReminderRequestChild>(); 842 rrc->SetMaxScreenWantAgentInfo(maxScreenWantAgentInfo); 843 EXPECT_EQ(rrc->GetMaxScreenWantAgentInfo(), maxScreenWantAgentInfo); 844 } 845 846 /** 847 * @tc.name: SetSnoozeContent_00001 848 * @tc.desc: Test SetSnoozeContent parameters. 849 * @tc.type: FUNC 850 * @tc.require: issueI5UYHP 851 */ 852 HWTEST_F(ReminderRequestTest, SetSnoozeContent_00001, Function | SmallTest | Level1) 853 { 854 std::string snoozeContent = "snoozeContent"; 855 auto rrc = std::make_shared<ReminderRequestChild>(); 856 rrc->SetSnoozeContent(snoozeContent); 857 EXPECT_EQ(rrc->GetSnoozeContent(), snoozeContent); 858 } 859 860 /** 861 * @tc.name: SetWantAgentInfo_00001 862 * @tc.desc: Test SetWantAgentInfo parameters. 863 * @tc.type: FUNC 864 * @tc.require: issueI5UYHP 865 */ 866 HWTEST_F(ReminderRequestTest, SetWantAgentInfo_00001, Function | SmallTest | Level1) 867 { 868 std::shared_ptr<ReminderRequest::WantAgentInfo> wantAgentInfo = std::make_shared<ReminderRequest::WantAgentInfo>(); 869 auto rrc = std::make_shared<ReminderRequestChild>(); 870 rrc->SetWantAgentInfo(wantAgentInfo); 871 EXPECT_EQ(rrc->GetWantAgentInfo(), wantAgentInfo); 872 } 873 874 /** 875 * @tc.name: SetReminderTimeInMilli_00001 876 * @tc.desc: Test SetReminderTimeInMilli parameters. 877 * @tc.type: FUNC 878 * @tc.require: issueI5UYHP 879 */ 880 HWTEST_F(ReminderRequestTest, SetReminderTimeInMilli_00001, Function | SmallTest | Level1) 881 { 882 uint64_t reminderTimeInMilli = 10; 883 auto rrc = std::make_shared<ReminderRequestChild>(); 884 rrc->SetReminderTimeInMilli(reminderTimeInMilli); 885 EXPECT_EQ(rrc->GetReminderTimeInMilli(), reminderTimeInMilli); 886 } 887 888 /** 889 * @tc.name: SetRingDuration_00001 890 * @tc.desc: Test SetRingDuration parameters. 891 * @tc.type: FUNC 892 * @tc.require: issueI5VB6V 893 */ 894 HWTEST_F(ReminderRequestTest, SetRingDuration_00001, Function | SmallTest | Level1) 895 { 896 uint64_t ringDurationInSeconds = 0; 897 auto rrc = std::make_shared<ReminderRequestChild>(); 898 rrc->SetRingDuration(ringDurationInSeconds); 899 EXPECT_EQ(rrc->GetRingDuration(), 1); 900 } 901 902 /** 903 * @tc.name: SetRingDuration_00002 904 * @tc.desc: Test SetRingDuration parameters. 905 * @tc.type: FUNC 906 * @tc.require: issueI5VB6V 907 */ 908 HWTEST_F(ReminderRequestTest, SetRingDuration_00002, Function | SmallTest | Level1) 909 { 910 uint64_t ringDurationInSeconds = 10; 911 auto rrc = std::make_shared<ReminderRequestChild>(); 912 rrc->SetRingDuration(ringDurationInSeconds); 913 EXPECT_EQ(rrc->GetRingDuration(), ringDurationInSeconds); 914 } 915 916 /** 917 * @tc.name: Unmarshalling_00001 918 * @tc.desc: Test Unmarshalling parameters. 919 * @tc.type: FUNC 920 * @tc.require: issueI5VB6V 921 */ 922 HWTEST_F(ReminderRequestTest, Unmarshalling_00001, Function | SmallTest | Level1) 923 { 924 bool result = false; 925 Parcel parcel; 926 auto rrc = std::make_shared<ReminderRequestChild>(); 927 if (nullptr == rrc->Unmarshalling(parcel)) { 928 result = true; 929 } 930 EXPECT_EQ(true, result); 931 } 932 933 /** 934 * @tc.name: InitNotificationRequest_00001 935 * @tc.desc: Test InitNotificationRequest parameters. 936 * @tc.type: FUNC 937 * @tc.require: issueI5VB6V 938 */ 939 HWTEST_F(ReminderRequestTest, InitNotificationRequest_00001, Function | SmallTest | Level1) 940 { 941 auto rrc = std::make_shared<ReminderRequestChild>(); 942 EXPECT_EQ(rrc->InitNotificationRequest(), true); 943 } 944 945 /** 946 * @tc.name: InitNotificationRequest_00002 947 * @tc.desc: Test InitNotificationRequest parameters. 948 * @tc.type: FUNC 949 * @tc.require: issueI5VB6V 950 */ 951 HWTEST_F(ReminderRequestTest, InitNotificationRequest_00002, Function | SmallTest | Level1) 952 { 953 auto rrc = std::make_shared<ReminderRequestChild>(); 954 rrc->SetNotificationId(100); 955 EXPECT_EQ(rrc->InitNotificationRequest(), true); 956 } 957 958 /** 959 * @tc.name: IsAlerting_00001 960 * @tc.desc: Test IsAlerting parameters. 961 * @tc.type: FUNC 962 * @tc.require: issueI5VB6V 963 */ 964 HWTEST_F(ReminderRequestTest, IsAlerting_00001, Function | SmallTest | Level1) 965 { 966 auto rrc = std::make_shared<ReminderRequestChild>(); 967 EXPECT_EQ(rrc->IsAlerting(), false); 968 } 969 970 /** 971 * @tc.name: GetButtonInfo_00001 972 * @tc.desc: Test GetButtonInfo parameters. 973 * @tc.type: FUNC 974 * @tc.require: issueI5VB6V 975 */ 976 HWTEST_F(ReminderRequestTest, GetButtonInfo_00001, Function | SmallTest | Level1) 977 { 978 auto rrc = std::make_shared<ReminderRequestChild>(); 979 EXPECT_EQ(rrc->GetButtonInfo(), ""); 980 } 981 982 /** 983 * @tc.name: GetShowTime_00001 984 * @tc.desc: Test GetShowTime parameters. 985 * @tc.type: FUNC 986 * @tc.require: issueI5VB6V 987 */ 988 HWTEST_F(ReminderRequestTest, GetShowTime_00001, Function | SmallTest | Level1) 989 { 990 uint64_t showTime = 8 * 60 * 1000; 991 auto rrc = std::make_shared<ReminderRequestChild>(); 992 std::string ret = "8"; 993 std::string res = rrc->GetShowTime(showTime); 994 EXPECT_EQ(res.substr(4, res.size()), ret); 995 } 996 997 /** 998 * @tc.name: GetShowTime_00002 999 * @tc.desc: Test GetShowTime parameters. 1000 * @tc.type: FUNC 1001 * @tc.require: issueI5VB6V 1002 */ 1003 HWTEST_F(ReminderRequestTest, GetShowTime_00002, Function | SmallTest | Level1) 1004 { 1005 uint64_t showTime = 8 * 60 * 1000; 1006 ReminderRequest reminder = ReminderRequest(ReminderRequest::ReminderType::TIMER); 1007 auto rrc = std::make_shared<ReminderRequestChild>(); 1008 std::string ret = "8"; 1009 std::string res = rrc->GetShowTime(showTime); 1010 EXPECT_EQ(res.substr(4, res.size()), ret); 1011 } 1012 1013 /** 1014 * @tc.name: GetUid_00001 1015 * @tc.desc: Test GetUid parameters. 1016 * @tc.type: FUNC 1017 * @tc.require: issueI5VB6V 1018 */ 1019 HWTEST_F(ReminderRequestTest, GetUid_00001, Function | SmallTest | Level1) 1020 { 1021 int32_t userId = 1; 1022 std::string bundleName = "bundleName"; 1023 auto rrc = std::make_shared<ReminderRequestChild>(); 1024 EXPECT_EQ(rrc->GetUid(userId, bundleName), -1); 1025 } 1026 1027 /** 1028 * @tc.name: GetUserId_00001 1029 * @tc.desc: Test GetUserId parameters. 1030 * @tc.type: FUNC 1031 * @tc.require: issueI5VB6V 1032 */ 1033 HWTEST_F(ReminderRequestTest, GetUserId_00001, Function | SmallTest | Level1) 1034 { 1035 int32_t uid = 1; 1036 auto rrc = std::make_shared<ReminderRequestChild>(); 1037 EXPECT_EQ(rrc->GetUserId(uid), 0); 1038 } 1039 1040 /** 1041 * @tc.name: SetActionButton_00001 1042 * @tc.desc: Test SetActionButton parameters. 1043 * @tc.type: FUNC 1044 * @tc.require: issueI65R21 1045 */ 1046 HWTEST_F(ReminderRequestTest, SetActionButton_00001, Function | SmallTest | Level1) 1047 { 1048 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1049 ASSERT_NE(nullptr, reminderRequestChild); 1050 std::string title = "this is title"; 1051 std::string resource = "invalid"; 1052 Notification::ReminderRequest::ActionButtonType type = 1053 Notification::ReminderRequest::ActionButtonType::INVALID; 1054 reminderRequestChild->SetActionButton(title, type, resource); 1055 } 1056 1057 /** 1058 * @tc.name: SetActionButton_00002 1059 * @tc.desc: Test SetActionButton parameters. 1060 * @tc.type: FUNC 1061 * @tc.require: issueI65R21 1062 */ 1063 HWTEST_F(ReminderRequestTest, SetActionButton_00002, Function | SmallTest | Level1) 1064 { 1065 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1066 ASSERT_NE(nullptr, reminderRequestChild); 1067 std::string title = "this is title"; 1068 std::string resource = "close"; 1069 Notification::ReminderRequest::ActionButtonType type2 = 1070 Notification::ReminderRequest::ActionButtonType::CLOSE; 1071 reminderRequestChild->SetActionButton(title, type2, resource); 1072 } 1073 1074 /** 1075 * @tc.name: SetActionButton_00003 1076 * @tc.desc: Test SetActionButton parameters. 1077 * @tc.type: FUNC 1078 * @tc.require: issueI65R21 1079 */ 1080 HWTEST_F(ReminderRequestTest, SetActionButton_00003, Function | SmallTest | Level1) 1081 { 1082 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1083 ASSERT_NE(nullptr, reminderRequestChild); 1084 std::string title = "this is title"; 1085 std::string resource = "snooze"; 1086 Notification::ReminderRequest::ActionButtonType type3 = 1087 Notification::ReminderRequest::ActionButtonType::SNOOZE; 1088 reminderRequestChild->SetActionButton(title, type3, resource); 1089 } 1090 1091 /** 1092 * @tc.name: SetActionButton_00004 1093 * @tc.desc: Test SetActionButton parameters. 1094 * @tc.type: FUNC 1095 * @tc.require: issueI89IQR 1096 */ 1097 HWTEST_F(ReminderRequestTest, SetActionButton_00004, Function | SmallTest | Level1) 1098 { 1099 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1100 ASSERT_NE(nullptr, reminderRequestChild); 1101 std::string title = "this is title"; 1102 std::string resource = "CLOSE"; 1103 Notification::ReminderRequest::ActionButtonType type2 = 1104 Notification::ReminderRequest::ActionButtonType::CLOSE; 1105 std::shared_ptr<ReminderRequest::ButtonWantAgent> buttonWantAgent = 1106 std::make_shared<ReminderRequest::ButtonWantAgent>(); 1107 std::shared_ptr<ReminderRequest::ButtonDataShareUpdate> buttonDataShareUpdate = 1108 std::make_shared<ReminderRequest::ButtonDataShareUpdate>(); 1109 reminderRequestChild->SetActionButton(title, type2, resource, buttonWantAgent, buttonDataShareUpdate); 1110 } 1111 1112 /** 1113 * @tc.name: SetActionButton_00005 1114 * @tc.desc: Test SetActionButton parameters. 1115 * @tc.type: FUNC 1116 * @tc.require: issueI89IQR 1117 */ 1118 HWTEST_F(ReminderRequestTest, SetActionButton_00005, Function | SmallTest | Level1) 1119 { 1120 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1121 ASSERT_NE(nullptr, reminderRequestChild); 1122 std::string title = "this is title"; 1123 std::string resource = "SNOOZE"; 1124 Notification::ReminderRequest::ActionButtonType type3 = 1125 Notification::ReminderRequest::ActionButtonType::SNOOZE; 1126 std::shared_ptr<ReminderRequest::ButtonWantAgent> buttonWantAgent = 1127 std::make_shared<ReminderRequest::ButtonWantAgent>(); 1128 std::shared_ptr<ReminderRequest::ButtonDataShareUpdate> buttonDataShareUpdate = 1129 std::make_shared<ReminderRequest::ButtonDataShareUpdate>(); 1130 reminderRequestChild->SetActionButton(title, type3, resource, buttonWantAgent, buttonDataShareUpdate); 1131 } 1132 1133 /** 1134 * @tc.name: AddActionButtons_00001 1135 * @tc.desc: Test AddActionButtons parameters. 1136 * @tc.type: FUNC 1137 * @tc.require: issueI65R21 1138 */ 1139 HWTEST_F(ReminderRequestTest, AddActionButtons_00001, Function | SmallTest | Level1) 1140 { 1141 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1142 ASSERT_NE(nullptr, reminderRequestChild); 1143 reminderRequestChild->AddActionButtons(true); 1144 reminderRequestChild->AddActionButtons(false); 1145 } 1146 1147 /** 1148 * @tc.name: InitUserId_00001 1149 * @tc.desc: Test InitUserId parameters. 1150 * @tc.type: FUNC 1151 * @tc.require: issueI65R21 1152 */ 1153 HWTEST_F(ReminderRequestTest, InitUserId_00001, Function | SmallTest | Level1) 1154 { 1155 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1156 ASSERT_NE(nullptr, reminderRequestChild); 1157 bool deSet = true; 1158 uint8_t newState = 2; 1159 std::string function = "this is function"; 1160 int32_t userId = 1; 1161 int32_t uid = 2; 1162 reminderRequestChild->InitUserId(userId); 1163 reminderRequestChild->InitUid(uid); 1164 reminderRequestChild->SetState(deSet, newState, function); 1165 uint8_t result1 = reminderRequestChild->GetState(); 1166 EXPECT_EQ(result1, 2); 1167 bool result = reminderRequestChild->IsShowing(); 1168 EXPECT_EQ(result, false); 1169 reminderRequestChild->OnShow(true, true, true); 1170 reminderRequestChild->OnShowFail(); 1171 } 1172 1173 /** 1174 * @tc.name: OnStart_00001 1175 * @tc.desc: Test OnStart parameters. 1176 * @tc.type: FUNC 1177 * @tc.require: issueI65R21 1178 */ 1179 HWTEST_F(ReminderRequestTest, OnStart_00001, Function | SmallTest | Level1) 1180 { 1181 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1182 ASSERT_NE(nullptr, reminderRequestChild); 1183 reminderRequestChild->OnStart(); 1184 reminderRequestChild->OnStop(); 1185 bool deSet = true; 1186 uint8_t newState = 2; 1187 std::string function = "this is function"; 1188 int32_t userId = 1; 1189 int32_t uid = 2; 1190 reminderRequestChild->InitUserId(userId); 1191 reminderRequestChild->InitUid(uid); 1192 reminderRequestChild->SetState(deSet, newState, function); 1193 reminderRequestChild->OnStart(); 1194 reminderRequestChild->OnStop(); 1195 } 1196 1197 /** 1198 * @tc.name: RecoverInt64FromDb_00002 1199 * @tc.desc: Test RecoverInt64FromDb parameters. 1200 * @tc.type: FUNC 1201 * @tc.require: issueI65R21 1202 */ 1203 HWTEST_F(ReminderRequestTest, RecoverInt64FromDb_00002, Function | SmallTest | Level1) 1204 { 1205 auto rrc = std::make_shared<ReminderRequestChild>(); 1206 std::shared_ptr<NativeRdb::ResultSet> resultSet = 1207 std::make_shared<NativeRdb::AbsSharedResultSet>(); 1208 std::string columnName = "this is columnName"; 1209 ReminderRequest::DbRecoveryType columnType = ReminderRequest::DbRecoveryType::INT; 1210 int64_t result = rrc->RecoverInt64FromDb(resultSet, columnName, columnType); 1211 EXPECT_EQ(result, 0); 1212 1213 ReminderRequest::DbRecoveryType columnType2 = ReminderRequest::DbRecoveryType::LONG; 1214 int64_t result2 = rrc->RecoverInt64FromDb(resultSet, columnName, columnType2); 1215 EXPECT_EQ(result2, 0); 1216 rrc->RecoverFromDb(resultSet); 1217 rrc->RecoverActionButton(resultSet); 1218 rrc->RecoverActionButton(nullptr); 1219 } 1220 1221 /** 1222 * @tc.name: RecoverInt64FromDb_00003 1223 * @tc.desc: Test RecoverInt64FromDb parameters. 1224 * @tc.type: FUNC 1225 * @tc.require: issueI65R21 1226 */ 1227 HWTEST_F(ReminderRequestTest, RecoverInt64FromDb_00003, Function | SmallTest | Level1) 1228 { 1229 auto rrc = std::make_shared<ReminderRequestChild>(); 1230 std::shared_ptr<NativeRdb::ResultSet> resultSet = 1231 std::make_shared<NativeRdb::AbsSharedResultSet>(); 1232 std::string columnName = "this is columnName"; 1233 1234 ReminderRequest::DbRecoveryType columnType = ReminderRequest::DbRecoveryType(3); 1235 int64_t result2 = rrc->RecoverInt64FromDb(resultSet, columnName, columnType); 1236 EXPECT_EQ(result2, 0); 1237 } 1238 1239 /** 1240 * @tc.name: RecoverWantAgent_00002 1241 * @tc.desc: Test RecoverWantAgent parameters. 1242 * @tc.type: FUNC 1243 * @tc.require: issueI65R21 1244 */ 1245 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00002, Function | SmallTest | Level1) 1246 { 1247 auto rrc = std::make_shared<ReminderRequestChild>(); 1248 std::string source = "source"; 1249 std::string split = "split"; 1250 std::vector<std::string> ret = rrc->StringSplit(source, split); 1251 EXPECT_EQ(ret.size(), 1); 1252 1253 std::string wantAgentInfo = "this is wantAgentInfo"; 1254 uint8_t type = 0; 1255 rrc->RecoverWantAgent(wantAgentInfo, type); 1256 } 1257 1258 /** 1259 * @tc.name: GetActionButtons_00002 1260 * @tc.desc: Test GetActionButtons parameters. 1261 * @tc.type: FUNC 1262 * @tc.require: issueI65R21 1263 */ 1264 HWTEST_F(ReminderRequestTest, GetActionButtons_00002, Function | SmallTest | Level1) 1265 { 1266 auto rrc = std::make_shared<ReminderRequestChild>(); 1267 std::map<ReminderRequest::ActionButtonType, ReminderRequest::ActionButtonInfo> ret = 1268 rrc->GetActionButtons(); 1269 EXPECT_EQ(ret.size(), 0); 1270 } 1271 1272 /** 1273 * @tc.name: UpdateNotificationContent_00002 1274 * @tc.desc: Test UpdateNotificationContent parameters. 1275 * @tc.type: FUNC 1276 * @tc.require: issueI65R21 1277 */ 1278 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00002, Function | SmallTest | Level1) 1279 { 1280 auto rrc = std::make_shared<ReminderRequestChild>(); 1281 rrc->SetNotificationId(100); 1282 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1283 1284 rrc->UpdateNotificationContent(true); 1285 rrc->UpdateNotificationContent(false); 1286 1287 Notification::ReminderRequest::TimeTransferType type = Notification::ReminderRequest::TimeTransferType::WEEK; 1288 int32_t actualTime = 1; 1289 int32_t result = rrc->GetCTime(type, actualTime); 1290 EXPECT_EQ(result, 1); 1291 } 1292 1293 /** 1294 * @tc.name: CreateWantAgent_00001 1295 * @tc.desc: Test CreateWantAgent parameters. 1296 * @tc.type: FUNC 1297 * @tc.require: issueI5VB6V 1298 */ 1299 HWTEST_F(ReminderRequestTest, CreateWantAgent_00001, Function | SmallTest | Level1) 1300 { 1301 AppExecFwk::ElementName element("", "com.example.myapplication", "EntryAbility"); 1302 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1303 ASSERT_NE(nullptr, reminderRequestChild); 1304 std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> WantAgent = 1305 reminderRequestChild->CreateWantAgent(element, false); 1306 EXPECT_EQ(WantAgent, nullptr); 1307 } 1308 1309 /** 1310 * @tc.name: CreateWantAgent_00002 1311 * @tc.desc: Test CreateWantAgent parameters. 1312 * @tc.type: FUNC 1313 * @tc.require: issueI86QW2 1314 */ 1315 HWTEST_F(ReminderRequestTest, CreateWantAgent_00002, Function | SmallTest | Level1) 1316 { 1317 AppExecFwk::ElementName element("", "com.example.myapplication", "EntryAbility"); 1318 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1319 ASSERT_NE(nullptr, reminderRequestChild); 1320 std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> WantAgent = 1321 reminderRequestChild->CreateWantAgent(element, true); 1322 EXPECT_EQ(WantAgent, nullptr); 1323 } 1324 1325 /** 1326 * @tc.name: AddColumn_00002 1327 * @tc.desc: Test AddColumn parameters. 1328 * @tc.type: FUNC 1329 * @tc.require: issueI65R21 1330 */ 1331 HWTEST_F(ReminderRequestTest, AddColumn_00002, Function | SmallTest | Level1) 1332 { 1333 std::string name = "this is name"; 1334 std::string type = "this is type"; 1335 ReminderTable::AddColumn(name, type, true); 1336 ReminderTable::AddColumn(name, type, false); 1337 EXPECT_EQ(ReminderTable::columns.size(), 2); 1338 } 1339 1340 /** 1341 * @tc.name: OnClose_00100 1342 * @tc.desc: Test OnClose parameters. 1343 * @tc.type: FUNC 1344 * @tc.require: issueI5QVYA 1345 */ 1346 HWTEST_F(ReminderRequestTest, OnClose_00100, Function | SmallTest | Level1) 1347 { 1348 auto rrc = std::make_shared<ReminderRequestChild>(); 1349 bool deSet = true; 1350 uint8_t newState = 4; 1351 std::string function = "this is function"; 1352 rrc->SetState(deSet, newState, function); 1353 uint8_t result1 = rrc->GetState(); 1354 EXPECT_EQ(result1, 4); 1355 rrc->OnClose(true); 1356 } 1357 1358 /** 1359 * @tc.name: OnClose_00200 1360 * @tc.desc: Test OnClose parameters. 1361 * @tc.type: FUNC 1362 * @tc.require: issueI5QVYA 1363 */ 1364 HWTEST_F(ReminderRequestTest, OnClose_00200, Function | SmallTest | Level1) 1365 { 1366 auto rrc = std::make_shared<ReminderRequestChild>(); 1367 bool deSet = true; 1368 uint8_t newState = 2; 1369 std::string function = "this is function"; 1370 rrc->SetState(deSet, newState, function); 1371 uint8_t result1 = rrc->GetState(); 1372 EXPECT_EQ(result1, 2); 1373 rrc->OnClose(true); 1374 } 1375 1376 /** 1377 * @tc.name: OnShow_00100 1378 * @tc.desc: Test OnShow parameters. 1379 * @tc.type: FUNC 1380 * @tc.require: issueI5QVYA 1381 */ 1382 HWTEST_F(ReminderRequestTest, OnShow_00100, Function | SmallTest | Level1) 1383 { 1384 auto rrc = std::make_shared<ReminderRequestChild>(); 1385 bool deSet = true; 1386 uint8_t newState = 9; 1387 std::string function = "this is function"; 1388 rrc->SetState(deSet, newState, function); 1389 uint8_t result1 = rrc->GetState(); 1390 EXPECT_EQ(result1, 9); 1391 rrc->OnShow(true, true, true); 1392 } 1393 1394 /** 1395 * @tc.name: OnStart_00002 1396 * @tc.desc: Test OnStart parameters. 1397 * @tc.type: FUNC 1398 * @tc.require: issueI65R21 1399 */ 1400 HWTEST_F(ReminderRequestTest, OnStart_00002, Function | SmallTest | Level1) 1401 { 1402 auto rrc = std::make_shared<ReminderRequestChild>(); 1403 bool deSet = true; 1404 uint8_t newState = 1; 1405 std::string function = "this is function"; 1406 rrc->SetState(deSet, newState, function); 1407 uint8_t result1 = rrc->GetState(); 1408 EXPECT_EQ(result1, 1); 1409 rrc->OnStart(); 1410 } 1411 1412 /** 1413 * @tc.name: OnStart_00003 1414 * @tc.desc: Test OnStart parameters. 1415 * @tc.type: FUNC 1416 * @tc.require: issueI65R21 1417 */ 1418 HWTEST_F(ReminderRequestTest, OnStart_00003, Function | SmallTest | Level1) 1419 { 1420 auto rrc = std::make_shared<ReminderRequestChild>(); 1421 bool deSet = true; 1422 uint8_t newState = 2; 1423 std::string function = "this is function"; 1424 rrc->SetState(deSet, newState, function); 1425 uint8_t result1 = rrc->GetState(); 1426 EXPECT_EQ(result1, 2); 1427 rrc->SetExpired(true); 1428 rrc->OnStart(); 1429 } 1430 1431 /** 1432 * @tc.name: StringSplit_00003 1433 * @tc.desc: Test StringSplit parameters. 1434 * @tc.type: FUNC 1435 * @tc.require: issueI65R21 1436 */ 1437 HWTEST_F(ReminderRequestTest, StringSplit_00003, Function | SmallTest | Level1) 1438 { 1439 auto rrc = std::make_shared<ReminderRequestChild>(); 1440 std::string source1 = "source1"; 1441 std::string split = "c"; 1442 std::vector<std::string> ret1 = rrc->StringSplit(source1, split); 1443 EXPECT_EQ(ret1.size(), 2); 1444 } 1445 1446 /** 1447 * @tc.name: RecoverWantAgent_00003 1448 * @tc.desc: Test RecoverWantAgent parameters. 1449 * @tc.type: FUNC 1450 * @tc.require: issueI65R21 1451 */ 1452 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00003, Function | SmallTest | Level1) 1453 { 1454 auto rrc = std::make_shared<ReminderRequestChild>(); 1455 std::string wantAgentInfo = "sour<SEP#/>123"; 1456 uint8_t type = 0; 1457 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1458 EXPECT_EQ(ret1.size(), 2); 1459 rrc->RecoverWantAgent(wantAgentInfo, type); 1460 } 1461 1462 /** 1463 * @tc.name: RecoverWantAgent_00004 1464 * @tc.desc: Test RecoverWantAgent parameters. 1465 * @tc.type: FUNC 1466 * @tc.require: issueI65R21 1467 */ 1468 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00004, Function | SmallTest | Level1) 1469 { 1470 auto rrc = std::make_shared<ReminderRequestChild>(); 1471 std::string wantAgentInfo = "sour<SEP#/>123"; 1472 uint8_t type = 1; 1473 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1474 EXPECT_EQ(ret1.size(), 2); 1475 rrc->RecoverWantAgent(wantAgentInfo, type); 1476 } 1477 1478 /** 1479 * @tc.name: RecoverWantAgent_00005 1480 * @tc.desc: Test RecoverWantAgent parameters. 1481 * @tc.type: FUNC 1482 * @tc.require: issueI65R21 1483 */ 1484 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00005, Function | SmallTest | Level1) 1485 { 1486 auto rrc = std::make_shared<ReminderRequestChild>(); 1487 std::string wantAgentInfo = "sour<SEP#/>123"; 1488 uint8_t type = 2; 1489 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1490 EXPECT_EQ(ret1.size(), 2); 1491 rrc->RecoverWantAgent(wantAgentInfo, type); 1492 } 1493 1494 /** 1495 * @tc.name: RecoverWantAgent_00006 1496 * @tc.desc: Test RecoverWantAgent parameters. 1497 * @tc.type: FUNC 1498 * @tc.require: issueI86QW2 1499 */ 1500 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00006, Function | SmallTest | Level1) 1501 { 1502 auto rrc = std::make_shared<ReminderRequestChild>(); 1503 std::string wantAgentInfo = "sour<SEP#/>123<SEP#/>uri"; 1504 uint8_t type = 0; 1505 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1506 EXPECT_EQ(ret1.size(), 3); 1507 rrc->RecoverWantAgent(wantAgentInfo, type); 1508 } 1509 1510 /** 1511 * @tc.name: UpdateActionButtons_00001 1512 * @tc.desc: Test UpdateActionButtons parameters. 1513 * @tc.type: FUNC 1514 * @tc.require: issueI5VB6V 1515 */ 1516 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00001, Function | SmallTest | Level1) 1517 { 1518 auto rrc = std::make_shared<ReminderRequestChild>(); 1519 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1520 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1521 bool setSnooze = true; 1522 rrc->SetSnoozeTimes(1); 1523 EXPECT_EQ(rrc->GetSnoozeTimes(), 1); 1524 rrc->SetSnoozeTimesDynamic(1); 1525 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1526 rrc->UpdateActionButtons(setSnooze); 1527 } 1528 1529 /** 1530 * @tc.name: UpdateActionButtons_00002 1531 * @tc.desc: Test UpdateActionButtons parameters. 1532 * @tc.type: FUNC 1533 * @tc.require: issueI5VB6V 1534 */ 1535 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00002, Function | SmallTest | Level1) 1536 { 1537 auto rrc = std::make_shared<ReminderRequestChild>(); 1538 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1539 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1540 bool setSnooze = true; 1541 rrc->SetSnoozeTimes(0); 1542 EXPECT_EQ(rrc->GetSnoozeTimes(), 0); 1543 rrc->SetSnoozeTimesDynamic(1); 1544 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1545 rrc->UpdateActionButtons(setSnooze); 1546 } 1547 1548 /** 1549 * @tc.name: UpdateActionButtons_00003 1550 * @tc.desc: Test UpdateActionButtons parameters. 1551 * @tc.type: FUNC 1552 * @tc.require: issueI5VB6V 1553 */ 1554 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00003, Function | SmallTest | Level1) 1555 { 1556 auto rrc = std::make_shared<ReminderRequestChild>(); 1557 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1558 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1559 bool setSnooze = false; 1560 rrc->SetSnoozeTimes(1); 1561 EXPECT_EQ(rrc->GetSnoozeTimes(), 1); 1562 rrc->SetSnoozeTimesDynamic(1); 1563 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1564 rrc->UpdateActionButtons(setSnooze); 1565 } 1566 1567 /** 1568 * @tc.name: UpdateActionButtons_00004 1569 * @tc.desc: Test UpdateActionButtons parameters. 1570 * @tc.type: FUNC 1571 * @tc.require: issueI5VB6V 1572 */ 1573 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00004, Function | SmallTest | Level1) 1574 { 1575 auto rrc = std::make_shared<ReminderRequestChild>(); 1576 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1577 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1578 bool setSnooze = true; 1579 rrc->SetSnoozeTimes(1); 1580 EXPECT_EQ(rrc->GetSnoozeTimes(), 1); 1581 rrc->SetSnoozeTimesDynamic(0); 1582 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 0); 1583 rrc->UpdateActionButtons(setSnooze); 1584 } 1585 1586 /** 1587 * @tc.name: UpdateNotificationContent_00300 1588 * @tc.desc: Test UpdateNotificationContent parameters. 1589 * @tc.type: FUNC 1590 * @tc.require: AR000GNF1T 1591 */ 1592 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00300, Function | SmallTest | Level1) 1593 { 1594 auto rrc = std::make_shared<ReminderRequestChild>(); 1595 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1596 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1597 uint32_t minTimeIntervalInSecond = 5 * 60; 1598 rrc->SetTimeInterval(1); 1599 EXPECT_EQ(rrc->GetTimeInterval(), minTimeIntervalInSecond); 1600 1601 bool setSnooze = true; 1602 rrc->UpdateNotificationContent(setSnooze); 1603 } 1604 1605 1606 /** 1607 * @tc.name: UpdateNotificationContent_00400 1608 * @tc.desc: Test UpdateNotificationContent parameters. 1609 * @tc.type: FUNC 1610 * @tc.require: AR000GNF1T 1611 */ 1612 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00400, Function | SmallTest | Level1) 1613 { 1614 auto rrc = std::make_shared<ReminderRequestChild>(); 1615 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1616 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1617 1618 bool deSet = true; 1619 uint8_t newState = 2; 1620 std::string function = "this is function"; 1621 rrc->SetState(deSet, newState, function); 1622 uint8_t result1 = rrc->GetState(); 1623 EXPECT_EQ(result1, 2); 1624 EXPECT_EQ(rrc->IsAlerting(), true); 1625 bool setSnooze = false; 1626 rrc->UpdateNotificationContent(setSnooze); 1627 } 1628 1629 /** 1630 * @tc.name: UpdateNotificationContent_00600 1631 * @tc.desc: Test UpdateNotificationContent extend content when snooze. 1632 * @tc.type: FUNC 1633 * @tc.require: issueI87A02 1634 */ 1635 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00600, Function | SmallTest | Level1) 1636 { 1637 // given 1638 auto rrc = std::make_shared<ReminderRequestChild>(); 1639 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1640 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1641 rrc->snoozeContent_ = "snooze"; 1642 rrc->content_ = "content"; 1643 rrc->expiredContent_ = "expiredContent"; 1644 rrc->timeIntervalInMilli_ = 1; 1645 1646 // when 1647 bool setSnooze = true; 1648 rrc->UpdateNotificationContent(setSnooze); 1649 1650 // then 1651 EXPECT_EQ(rrc->displayContent_, "snooze"); 1652 } 1653 1654 /** 1655 * @tc.name: UpdateNotificationContent_00800 1656 * @tc.desc: Test UpdateNotificationContent extend content when expiredContent. 1657 * @tc.type: FUNC 1658 * @tc.require: issueI87A02 1659 */ 1660 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00800, Function | SmallTest | Level1) 1661 { 1662 // given 1663 auto rrc = std::make_shared<ReminderRequestChild>(); 1664 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1665 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1666 rrc->snoozeContent_ = "snooze"; 1667 rrc->content_ = "content"; 1668 rrc->expiredContent_ = "expiredContent"; 1669 rrc->timeIntervalInMilli_ = 0; 1670 1671 // when 1672 bool setSnooze = true; 1673 rrc->UpdateNotificationContent(setSnooze); 1674 1675 // then 1676 EXPECT_EQ(rrc->displayContent_, "expiredContent"); 1677 } 1678 1679 /** 1680 * @tc.name: UpdateNotificationContent_00500 1681 * @tc.desc: Test UpdateNotificationContent parameters. 1682 * @tc.type: FUNC 1683 * @tc.require: AR000GNF1T 1684 */ 1685 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00500, Function | SmallTest | Level1) 1686 { 1687 auto rrc = std::make_shared<ReminderRequestChild>(); 1688 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1689 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1690 1691 bool deSet = false; 1692 uint8_t newState = 0; 1693 std::string function = "this is function"; 1694 rrc->SetState(deSet, newState, function); 1695 uint8_t result1 = rrc->GetState(); 1696 EXPECT_EQ(result1, 0); 1697 EXPECT_EQ(rrc->IsAlerting(), false); 1698 1699 rrc->SetSnoozeTimes(0); 1700 EXPECT_EQ(rrc->GetSnoozeTimes(), 0); 1701 rrc->SetSnoozeTimesDynamic(1); 1702 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1703 1704 bool setSnooze = false; 1705 rrc->UpdateNotificationContent(setSnooze); 1706 } 1707 1708 /** 1709 * @tc.name: GetCTime_00001 1710 * @tc.desc: Test GetCTime parameters. 1711 * @tc.type: FUNC 1712 * @tc.require: issueI65R21 1713 */ 1714 HWTEST_F(ReminderRequestTest, GetCTime_00001, Function | SmallTest | Level1) 1715 { 1716 auto rrc = std::make_shared<ReminderRequestChild>(); 1717 Notification::ReminderRequest::TimeTransferType type = Notification::ReminderRequest::TimeTransferType(3); 1718 int32_t actualTime = 1; 1719 int32_t result = rrc->GetCTime(type, actualTime); 1720 int32_t ret = -1; 1721 EXPECT_EQ(result, ret); 1722 } 1723 1724 /** 1725 * @tc.name: GetActualTime_00001 1726 * @tc.desc: Test GetActualTime parameters. 1727 * @tc.type: FUNC 1728 * @tc.require: issueI65R21 1729 */ 1730 HWTEST_F(ReminderRequestTest, GetActualTime_00001, Function | SmallTest | Level1) 1731 { 1732 auto rrc = std::make_shared<ReminderRequestChild>(); 1733 Notification::ReminderRequest::TimeTransferType type = Notification::ReminderRequest::TimeTransferType(3); 1734 int32_t actualTime = 1; 1735 int32_t result = rrc->GetActualTime(type, actualTime); 1736 int32_t ret = -1; 1737 EXPECT_EQ(result, ret); 1738 } 1739 1740 /** 1741 * @tc.name: SetSystemApp_00001 1742 * @tc.desc: Test SetSystemApp parameters. 1743 * @tc.type: FUNC 1744 * @tc.require: issueI6NQPJ 1745 */ 1746 HWTEST_F(ReminderRequestTest, SetSystemApp_00001, Function | SmallTest | Level1) 1747 { 1748 auto rrc = std::make_shared<ReminderRequestChild>(); 1749 rrc->SetSystemApp(true); 1750 bool result = rrc->IsSystemApp(); 1751 bool ret = true; 1752 EXPECT_EQ(result, ret); 1753 } 1754 1755 /** 1756 * @tc.name: SetTapDismissed_00001 1757 * @tc.desc: Test SetTapDismissed parameters. 1758 * @tc.type: FUNC 1759 * @tc.require: issueI6NQPJ 1760 */ 1761 HWTEST_F(ReminderRequestTest, SetTapDismissed_00001, Function | SmallTest | Level1) 1762 { 1763 auto rrc = std::make_shared<ReminderRequestChild>(); 1764 rrc->SetTapDismissed(true); 1765 bool result = rrc->IsTapDismissed(); 1766 bool ret = true; 1767 EXPECT_EQ(result, ret); 1768 } 1769 1770 /** 1771 * @tc.name: SetAutoDeletedTime_00001 1772 * @tc.desc: Test SetAutoDeletedTime parameters. 1773 * @tc.type: FUNC 1774 * @tc.require: issueI6NQPJ 1775 */ 1776 HWTEST_F(ReminderRequestTest, SetAutoDeletedTime_00001, Function | SmallTest | Level1) 1777 { 1778 auto rrc = std::make_shared<ReminderRequestChild>(); 1779 rrc->SetAutoDeletedTime(1); 1780 int32_t result = rrc->GetAutoDeletedTime(); 1781 int32_t ret = 1; 1782 EXPECT_EQ(result, ret); 1783 } 1784 1785 /** 1786 * @tc.name: SetCustomButtonUri_00001 1787 * @tc.desc: Test SetCustomButtonUri parameters. 1788 * @tc.type: FUNC 1789 * @tc.require: issueI6NQPJ 1790 */ 1791 HWTEST_F(ReminderRequestTest, SetCustomButtonUri_00001, Function | SmallTest | Level1) 1792 { 1793 auto rrc = std::make_shared<ReminderRequestChild>(); 1794 rrc->SetCustomButtonUri("test"); 1795 std::string result = rrc->GetCustomButtonUri(); 1796 std::string ret = "test"; 1797 EXPECT_EQ(result, ret); 1798 } 1799 1800 /** 1801 * @tc.name: SetGroupId_00001 1802 * @tc.desc: Test SetGroupId parameters. 1803 * @tc.type: FUNC 1804 * @tc.require: issueI8CDH3 1805 */ 1806 HWTEST_F(ReminderRequestTest, SetGroupId_00001, Function | SmallTest | Level1) 1807 { 1808 auto rrc = std::make_shared<ReminderRequestChild>(); 1809 std::string groupId = "123"; 1810 rrc->SetGroupId(groupId); 1811 EXPECT_EQ(rrc->GetGroupId(), groupId); 1812 } 1813 1814 /** 1815 * @tc.name: InitBundleName_00001 1816 * @tc.desc: Test InitBundleName with normal parameters. 1817 * @tc.type: FUNC 1818 * @tc.require: issueI89858 1819 */ 1820 HWTEST_F(ReminderRequestTest, InitBundleName_00001, Function | SmallTest | Level1) 1821 { 1822 auto rrc = std::make_shared<ReminderRequestChild>(); 1823 std::string bundleName = "com.example.myapplication"; 1824 rrc->InitBundleName(bundleName); 1825 EXPECT_EQ(rrc->GetBundleName(), bundleName); 1826 } 1827 1828 /** 1829 * @tc.name: InitBundleName_00002 1830 * @tc.desc: Test InitBundleName with special parameters. 1831 * @tc.type: FUNC 1832 * @tc.require: issueI89858 1833 */ 1834 HWTEST_F(ReminderRequestTest, InitBundleName_00002, Function | SmallTest | Level1) 1835 { 1836 auto rrc = std::make_shared<ReminderRequestChild>(); 1837 std::string bundleName = "com.example.myapplication.~!@#$%^&*()"; 1838 rrc->InitBundleName(bundleName); 1839 EXPECT_EQ(rrc->GetBundleName(), bundleName); 1840 } 1841 1842 /** 1843 * @tc.name: UpdateNotificationCommon_00100 1844 * @tc.desc: Test UpdateNotificationCommon when snooze is true. 1845 * @tc.type: FUNC 1846 * @tc.require: issueII8F9EZ 1847 */ 1848 HWTEST_F(ReminderRequestTest, UpdateNotificationCommon_00100, Function | SmallTest | Level1) 1849 { 1850 // given 1851 auto rrc = std::make_shared<ReminderRequestChild>(); 1852 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1853 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1854 rrc->snoozeSlotType_ = NotificationConstant::SlotType::OTHER; 1855 bool isSnooze = true; 1856 1857 // when 1858 rrc->UpdateNotificationCommon(isSnooze); 1859 1860 // then 1861 EXPECT_EQ(ret->GetSlotType(), NotificationConstant::SlotType::CONTENT_INFORMATION); 1862 } 1863 1864 /** 1865 * @tc.name: UpdateNotificationCommon_00200 1866 * @tc.desc: Test UpdateNotificationCommon when snooze is true. 1867 * @tc.type: FUNC 1868 * @tc.require: issueII8F9EZ 1869 */ 1870 HWTEST_F(ReminderRequestTest, UpdateNotificationCommon_00200, Function | SmallTest | Level1) 1871 { 1872 // given 1873 auto rrc = std::make_shared<ReminderRequestChild>(); 1874 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1875 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1876 rrc->snoozeSlotType_ = NotificationConstant::SlotType::SERVICE_REMINDER; 1877 bool isSnooze = true; 1878 1879 // when 1880 rrc->UpdateNotificationCommon(isSnooze); 1881 1882 // then 1883 EXPECT_EQ(ret->GetSlotType(), NotificationConstant::SlotType::SERVICE_REMINDER); 1884 } 1885 1886 /** 1887 * @tc.name: UpdateNotificationCommon_00300 1888 * @tc.desc: Test UpdateNotificationCommon when snooze is false. 1889 * @tc.type: FUNC 1890 * @tc.require: issueII8F9EZ 1891 */ 1892 HWTEST_F(ReminderRequestTest, UpdateNotificationCommon_00300, Function | SmallTest | Level1) 1893 { 1894 // given 1895 auto rrc = std::make_shared<ReminderRequestChild>(); 1896 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1897 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1898 rrc->snoozeSlotType_ = NotificationConstant::SlotType::SERVICE_REMINDER; 1899 rrc->slotType_ = NotificationConstant::SlotType::SOCIAL_COMMUNICATION; 1900 bool isSnooze = false; 1901 1902 // when 1903 rrc->UpdateNotificationCommon(isSnooze); 1904 1905 // then 1906 EXPECT_EQ(ret->GetSlotType(), NotificationConstant::SlotType::SOCIAL_COMMUNICATION); 1907 } 1908 1909 /** 1910 * @tc.name: InitCreatorBundleName_00001 1911 * @tc.desc: Test InitCreatorBundleName with normal parameters. 1912 * @tc.type: FUNC 1913 * @tc.require: issue#I8R55M 1914 */ 1915 HWTEST_F(ReminderRequestTest, InitCreatorBundleName_00001, Function | SmallTest | Level1) 1916 { 1917 auto rrc = std::make_shared<ReminderRequestChild>(); 1918 std::string bundleName = "com.example.myapplication"; 1919 rrc->InitCreatorBundleName(bundleName); 1920 EXPECT_EQ(rrc->GetCreatorBundleName(), bundleName); 1921 } 1922 1923 /** 1924 * @tc.name: InitCreatorBundleName_00002 1925 * @tc.desc: Test InitCreatorBundleName with special parameters. 1926 * @tc.type: FUNC 1927 * @tc.require: issue#I8R55M 1928 */ 1929 HWTEST_F(ReminderRequestTest, InitCreatorBundleName_00002, Function | SmallTest | Level1) 1930 { 1931 auto rrc = std::make_shared<ReminderRequestChild>(); 1932 std::string bundleName = "com.example.myapplication.~!@#$%^&*()"; 1933 rrc->InitCreatorBundleName(bundleName); 1934 EXPECT_EQ(rrc->GetCreatorBundleName(), bundleName); 1935 } 1936 } 1937 } 1938