1 /* 2 * Copyright (c) 2021-2022 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 #undef private 22 #undef protected 23 24 using namespace testing::ext; 25 namespace OHOS { 26 namespace Notification { 27 class ReminderRequestChild : public ReminderRequest { 28 public: ReminderRequestChild()29 ReminderRequestChild() : ReminderRequest() {}; 30 }; 31 32 class ReminderRequestTest : public testing::Test { 33 public: SetUpTestCase()34 static void SetUpTestCase() {} TearDownTestCase()35 static void TearDownTestCase() {} SetUp()36 void SetUp() {} TearDown()37 void TearDown() {} 38 39 static const uint8_t REMINDER_STATUS_SHOWING; 40 }; 41 42 const uint8_t ReminderRequestTest::REMINDER_STATUS_SHOWING = 4; 43 44 /** 45 * @tc.name: CanRemove_00100 46 * @tc.desc: When reminder init, CanRemove should return true. 47 * @tc.type: FUNC 48 * @tc.require: SR000GGTRD AR000GH8EF 49 */ 50 HWTEST_F(ReminderRequestTest, CanRemove_00100, Function | SmallTest | Level1) 51 { 52 auto rrc = std::make_shared<ReminderRequestChild>(); 53 EXPECT_TRUE(rrc->CanRemove()) << "When init, canRemove should be false"; 54 } 55 56 /** 57 * @tc.name: CanRemove_00200 58 * @tc.desc: When reminder is shown, CanRemove should return false. 59 * @tc.type: FUNC 60 * @tc.require: SR000GGTRD AR000GH8EF 61 */ 62 HWTEST_F(ReminderRequestTest, CanRemove_00200, Function | SmallTest | Level1) 63 { 64 auto rrc = std::make_shared<ReminderRequestChild>(); 65 rrc->OnShow(false, false, true); 66 EXPECT_FALSE(rrc->CanRemove()) << "When shown, canRemove should be false"; 67 } 68 69 /** 70 * @tc.name: CanRemove_00300 71 * @tc.desc: When reminder close, CanRemove should return true. 72 * @tc.type: FUNC 73 * @tc.require: SR000GGTRD AR000GH8EF 74 */ 75 HWTEST_F(ReminderRequestTest, CanRemove_00300, Function | SmallTest | Level1) 76 { 77 auto rrc = std::make_shared<ReminderRequestChild>(); 78 rrc->OnShow(false, false, true); 79 rrc->OnClose(false); 80 EXPECT_TRUE(rrc->CanRemove()) << "When reminder is expired and closed, can remove should be false"; 81 } 82 83 /** 84 * @tc.name: CanRemove_00400 85 * @tc.desc: When reminder is covered as same notification id, CanRemove should return true. 86 * @tc.type: FUNC 87 * @tc.require: SR000GGTRD AR000GH8EF AR000GH8E6 88 */ 89 HWTEST_F(ReminderRequestTest, CanRemove_00400, Function | SmallTest | Level1) 90 { 91 auto rrc = std::make_shared<ReminderRequestChild>(); 92 rrc->OnShow(false, false, true); 93 rrc->OnSameNotificationIdCovered(); 94 EXPECT_TRUE(rrc->CanRemove()) << "When reminder is expired and covered by \ 95 sameNotification id, can remove should be true"; 96 } 97 98 /** 99 * @tc.name: StateCheck_00100 100 * @tc.desc: When reminder init, state should be 0. 101 * @tc.type: FUNC 102 * @tc.require: SR000GGTRD AR000GH8EF 103 */ 104 HWTEST_F(ReminderRequestTest, StateCheck_00100, Function | SmallTest | Level1) 105 { 106 auto rrc = std::make_shared<ReminderRequestChild>(); 107 EXPECT_EQ(rrc->GetState(), 0) << "When init, state should be 0"; 108 } 109 110 /** 111 * @tc.name: StateCheck_00200 112 * @tc.desc: When reminder close with param true, state REMINDER_STATUS_SHOWING should be unset. 113 * @tc.type: FUNC 114 * @tc.require: SR000GGTRD AR000GH8EF 115 */ 116 HWTEST_F(ReminderRequestTest, StateCheck_00200, Function | SmallTest | Level1) 117 { 118 auto rrc = std::make_shared<ReminderRequestChild>(); 119 rrc->OnClose(true); 120 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) == 0); 121 } 122 123 /** 124 * @tc.name: StateCheck_00300 125 * @tc.desc: When reminder close with param false, state REMINDER_STATUS_SHOWING should be unset. 126 * @tc.type: FUNC 127 * @tc.require: SR000GGTRD AR000GH8EF 128 */ 129 HWTEST_F(ReminderRequestTest, StateCheck_00300, Function | SmallTest | Level1) 130 { 131 auto rrc = std::make_shared<ReminderRequestChild>(); 132 rrc->OnClose(false); 133 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) == 0); 134 } 135 136 /** 137 * @tc.name: StateCheck_00400 138 * @tc.desc: When reminder is covered as same notification id, state REMINDER_STATUS_SHOWING should be unset. 139 * @tc.type: FUNC 140 * @tc.require: SR000GGTRD AR000GH8EF AR000GH8E6 141 */ 142 HWTEST_F(ReminderRequestTest, StateCheck_00400, Function | SmallTest | Level1) 143 { 144 auto rrc = std::make_shared<ReminderRequestChild>(); 145 rrc->OnSameNotificationIdCovered(); 146 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) == 0); 147 } 148 149 /** 150 * @tc.name: StateCheck_00500 151 * @tc.desc: When reminder is shown with param true,true, state REMINDER_STATUS_SHOWING should be set. 152 * @tc.type: FUNC 153 * @tc.require: SR000GGTRD AR000GH8EF 154 */ 155 HWTEST_F(ReminderRequestTest, StateCheck_00500, Function | SmallTest | Level1) 156 { 157 auto rrc = std::make_shared<ReminderRequestChild>(); 158 rrc->OnShow(false, true, true); 159 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) != 0); 160 } 161 162 /** 163 * @tc.name: StateCheck_00600 164 * @tc.desc: When reminder is shown with param false,true, state REMINDER_STATUS_SHOWING should be set. 165 * @tc.type: FUNC 166 * @tc.require: SR000GGTRD AR000GH8EF 167 */ 168 HWTEST_F(ReminderRequestTest, StateCheck_00600, Function | SmallTest | Level1) 169 { 170 auto rrc = std::make_shared<ReminderRequestChild>(); 171 rrc->OnShow(false, false, true); 172 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) != 0); 173 } 174 175 /** 176 * @tc.name: StateCheck_00700 177 * @tc.desc: When reminder is shown with param true,false, state REMINDER_STATUS_SHOWING should not change. 178 * @tc.type: FUNC 179 * @tc.require: SR000GGTRD AR000GH8EF 180 */ 181 HWTEST_F(ReminderRequestTest, StateCheck_00700, Function | SmallTest | Level1) 182 { 183 auto rrc = std::make_shared<ReminderRequestChild>(); 184 uint8_t stateBefore = rrc->GetState(); 185 rrc->OnShow(false, true, false); 186 EXPECT_EQ(rrc->GetState(), stateBefore); 187 } 188 189 /** 190 * @tc.name: StateCheck_00800 191 * @tc.desc: When reminder is shown with param false,false, state REMINDER_STATUS_SHOWING should be unset. 192 * @tc.type: FUNC 193 * @tc.require: SR000GGTRD AR000GH8EF 194 */ 195 HWTEST_F(ReminderRequestTest, StateCheck_00800, Function | SmallTest | Level1) 196 { 197 auto rrc = std::make_shared<ReminderRequestChild>(); 198 uint8_t stateBefore = rrc->GetState(); 199 rrc->OnShow(false, false, false); 200 EXPECT_EQ(rrc->GetState(), stateBefore); 201 } 202 203 /** 204 * @tc.name: initReminderId_00100 205 * @tc.desc: When reminder create successfully, system should assign unique id to reminder. 206 * @tc.type: FUNC 207 * @tc.require: SR000GGTRD AR000GH8EF AR000GH8E6 208 */ 209 HWTEST_F(ReminderRequestTest, initReminderId_00100, Function | SmallTest | Level1) 210 { 211 auto rrc = std::make_shared<ReminderRequestChild>(); 212 rrc->InitReminderId(); 213 int32_t reminderIdBefore = rrc->GetReminderId(); 214 rrc->InitReminderId(); 215 int32_t reminderIdAfter = rrc->GetReminderId(); 216 EXPECT_EQ((reminderIdAfter - reminderIdBefore), 1); 217 } 218 219 /** 220 * @tc.name: setContent_00100 221 * @tc.desc: Test SetContent with normal parameters. 222 * @tc.type: FUNC 223 * @tc.require: SR000GGTRD AR000GH8EF 224 */ 225 HWTEST_F(ReminderRequestTest, setContent_00100, Function | SmallTest | Level1) 226 { 227 auto rrc = std::make_shared<ReminderRequestChild>(); 228 std::string content = "this is normal content"; 229 rrc->SetContent(content); 230 EXPECT_EQ(rrc->GetContent(), content); 231 } 232 233 /** 234 * @tc.name: setContent_00200 235 * @tc.desc: Test SetContent parameters with special characters. 236 * @tc.type: FUNC 237 * @tc.require: SR000GGTRD AR000GH8EF 238 */ 239 HWTEST_F(ReminderRequestTest, setContent_00200, Function | SmallTest | Level1) 240 { 241 auto rrc = std::make_shared<ReminderRequestChild>(); 242 std::string content = "this is content with special characters: ~!@#$%^&*()-+"; 243 rrc->SetContent(content); 244 EXPECT_EQ(rrc->GetContent(), content); 245 } 246 247 /** 248 * @tc.name: setExpiredContent_00100 249 * @tc.desc: Test SetExpiredContent with normal parameters. 250 * @tc.type: FUNC 251 * @tc.require: SR000GGTRD AR000GH8EF AR000GNF1U AR000GNF1U 252 */ 253 HWTEST_F(ReminderRequestTest, setExpiredContent_00100, Function | SmallTest | Level1) 254 { 255 auto rrc = std::make_shared<ReminderRequestChild>(); 256 std::string content = "this is normal content"; 257 rrc->SetExpiredContent(content); 258 EXPECT_EQ(rrc->GetExpiredContent(), content); 259 } 260 261 /** 262 * @tc.name: setExpiredContent_00200 263 * @tc.desc: Test SetExpiredContent with special characters. 264 * @tc.type: FUNC 265 * @tc.require: SR000GGTRD AR000GH8EF AR000GNF1U AR000GNF1U 266 */ 267 HWTEST_F(ReminderRequestTest, setExpiredContent_00200, Function | SmallTest | Level1) 268 { 269 auto rrc = std::make_shared<ReminderRequestChild>(); 270 std::string content = "this is content with special characters: ~!@#$%^&*()-+"; 271 rrc->SetExpiredContent(content); 272 EXPECT_EQ(rrc->GetExpiredContent(), content); 273 } 274 275 /** 276 * @tc.name: setTitle_00100 277 * @tc.desc: Test SetTitle with normal parameters. 278 * @tc.type: FUNC 279 * @tc.require: SR000GGTRD AR000GH8EF 280 */ 281 HWTEST_F(ReminderRequestTest, setTitle_00100, Function | SmallTest | Level1) 282 { 283 auto rrc = std::make_shared<ReminderRequestChild>(); 284 std::string content = "this is normal content"; 285 rrc->SetTitle(content); 286 EXPECT_EQ(rrc->GetTitle(), content); 287 } 288 289 /** 290 * @tc.name: setTitle_00200 291 * @tc.desc: Test SetTitle with special characters. 292 * @tc.type: FUNC 293 * @tc.require: SR000GGTRD AR000GH8EF 294 */ 295 HWTEST_F(ReminderRequestTest, setTitle_00200, Function | SmallTest | Level1) 296 { 297 auto rrc = std::make_shared<ReminderRequestChild>(); 298 std::string content = "this is content with special characters: ~!@#$%^&*()-+"; 299 rrc->SetTitle(content); 300 EXPECT_EQ(rrc->GetTitle(), content); 301 } 302 303 /** 304 * @tc.name: setNotificationId_00100 305 * @tc.desc: Test SetNotificationId parameters. 306 * @tc.type: FUNC 307 * @tc.require: SR000GGTRD AR000GH8EF 308 */ 309 HWTEST_F(ReminderRequestTest, setNotificationId_00100, Function | SmallTest | Level1) 310 { 311 auto rrc = std::make_shared<ReminderRequestChild>(); 312 int32_t notificationId = 0; 313 rrc->SetNotificationId(notificationId); 314 EXPECT_EQ(rrc->GetNotificationId(), notificationId); 315 } 316 317 /** 318 * @tc.name: setSnoozeTimes_00100 319 * @tc.desc: Test SetSnoozeTimes parameters. 320 * @tc.type: FUNC 321 * @tc.require: AR000GNF1T AR000GH8E7 322 */ 323 HWTEST_F(ReminderRequestTest, setSnoozeTimes_00100, Function | SmallTest | Level1) 324 { 325 auto rrc = std::make_shared<ReminderRequestChild>(); 326 rrc->SetSnoozeTimes(1); 327 EXPECT_EQ(rrc->GetSnoozeTimes(), 1) << "Get snoozeTimes not 1"; 328 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1) << "Get snoozeTimesDynamic not 1"; 329 } 330 331 /** 332 * @tc.name: setTimeInterval_00100 333 * @tc.desc: Test SetTimeInterval parameters. 334 * @tc.type: FUNC 335 * @tc.require: AR000GNF1T 336 */ 337 HWTEST_F(ReminderRequestTest, setTimeInterval_00100, Function | SmallTest | Level1) 338 { 339 uint32_t minTimeIntervalInSecond = 5 * 60; 340 auto rrc = std::make_shared<ReminderRequestChild>(); 341 rrc->SetTimeInterval(-1); 342 EXPECT_EQ(rrc->GetTimeInterval(), 0) << "timeInterval should be 0 when set with value less than 0"; 343 rrc->SetTimeInterval(0); 344 EXPECT_EQ(rrc->GetTimeInterval(), 0) << "timeInterval should be 0 when set with value 0"; 345 rrc->SetTimeInterval(1); 346 EXPECT_EQ(rrc->GetTimeInterval(), minTimeIntervalInSecond) 347 << "0 < timeInterval < minTimeInterval should be set to minTimeInterval"; 348 uint32_t timeInterval = minTimeIntervalInSecond; 349 rrc->SetTimeInterval(timeInterval); 350 EXPECT_EQ(rrc->GetTimeInterval(), timeInterval) << "timeInterval set error"; 351 timeInterval = minTimeIntervalInSecond + 1; 352 rrc->SetTimeInterval(timeInterval); 353 EXPECT_EQ(rrc->GetTimeInterval(), timeInterval) << "timeInterval set error."; 354 } 355 356 /** 357 * @tc.name: IsExpired_00100 358 * @tc.desc: Test IsExpired parameters. 359 * @tc.type: FUNC 360 * @tc.require: issueI5QVYA 361 */ 362 HWTEST_F(ReminderRequestTest, IsExpired_00100, Function | SmallTest | Level1) 363 { 364 auto rrc = std::make_shared<ReminderRequestChild>(); 365 EXPECT_EQ(rrc->IsExpired(), false); 366 } 367 368 /** 369 * @tc.name: IsShowing_00100 370 * @tc.desc: Test IsShowing parameters. 371 * @tc.type: FUNC 372 * @tc.require: issueI5QVYA 373 */ 374 HWTEST_F(ReminderRequestTest, IsShowing_00100, Function | SmallTest | Level1) 375 { 376 auto rrc = std::make_shared<ReminderRequestChild>(); 377 EXPECT_EQ(rrc->IsShowing(), false); 378 } 379 380 /** 381 * @tc.name: OnDateTimeChange_00100 382 * @tc.desc: Test OnDateTimeChange parameters. 383 * @tc.type: FUNC 384 * @tc.require: issueI5QVYA 385 */ 386 HWTEST_F(ReminderRequestTest, OnDateTimeChange_00100, Function | SmallTest | Level1) 387 { 388 auto rrc = std::make_shared<ReminderRequestChild>(); 389 EXPECT_EQ(rrc->OnDateTimeChange(), true); 390 } 391 392 /** 393 * @tc.name: OnSnooze_00100 394 * @tc.desc: Test OnSnooze parameters. 395 * @tc.type: FUNC 396 * @tc.require: issueI5QVYA 397 */ 398 HWTEST_F(ReminderRequestTest, OnSnooze_00100, Function | SmallTest | Level1) 399 { 400 auto rrc = std::make_shared<ReminderRequestChild>(); 401 EXPECT_EQ(rrc->OnSnooze(), true); 402 } 403 404 /** 405 * @tc.name: OnTerminate_00100 406 * @tc.desc: Test OnTerminate parameters. 407 * @tc.type: FUNC 408 * @tc.require: issueI5QVYA 409 */ 410 HWTEST_F(ReminderRequestTest, OnTerminate_00100, Function | SmallTest | Level1) 411 { 412 auto rrc = std::make_shared<ReminderRequestChild>(); 413 EXPECT_EQ(rrc->OnTerminate(), false); 414 } 415 416 /** 417 * @tc.name: ShouldShowImmediately_00100 418 * @tc.desc: Test ShouldShowImmediately parameters. 419 * @tc.type: FUNC 420 * @tc.require: issueI5QVYA 421 */ 422 HWTEST_F(ReminderRequestTest, ShouldShowImmediately_00100, Function | SmallTest | Level1) 423 { 424 auto rrc = std::make_shared<ReminderRequestChild>(); 425 EXPECT_EQ(rrc->ShouldShowImmediately(), true); 426 } 427 428 /** 429 * @tc.name: GetSlotType_00100 430 * @tc.desc: Test GetSlotType parameters. 431 * @tc.type: FUNC 432 * @tc.require: issueI5QVYA 433 */ 434 HWTEST_F(ReminderRequestTest, GetSlotType_00100, Function | SmallTest | Level1) 435 { 436 auto rrc = std::make_shared<ReminderRequestChild>(); 437 NotificationConstant::SlotType mySlotType = NotificationConstant::OTHER; 438 rrc->SetSlotType(mySlotType); 439 EXPECT_EQ(rrc->GetSlotType(), mySlotType); 440 } 441 442 /** 443 * @tc.name: GetTriggerTimeInMilli_00100 444 * @tc.desc: Test GetTriggerTimeInMilli parameters. 445 * @tc.type: FUNC 446 * @tc.require: issueI5QVYA 447 */ 448 HWTEST_F(ReminderRequestTest, GetTriggerTimeInMilli_00100, Function | SmallTest | Level1) 449 { 450 auto rrc = std::make_shared<ReminderRequestChild>(); 451 uint64_t triggerTimeInMilliTest = 1; 452 rrc->SetTriggerTimeInMilli(triggerTimeInMilliTest); 453 EXPECT_EQ(rrc->GetTriggerTimeInMilli(), triggerTimeInMilliTest); 454 } 455 456 /** 457 * @tc.name: GetUserId_00100 458 * @tc.desc: Test GetUserId parameters. 459 * @tc.type: FUNC 460 * @tc.require: issueI5QVYA 461 */ 462 HWTEST_F(ReminderRequestTest, GetUserId_00100, Function | SmallTest | Level1) 463 { 464 auto rrc = std::make_shared<ReminderRequestChild>(); 465 EXPECT_EQ(rrc->GetUserId(), -1); 466 } 467 468 /** 469 * @tc.name: GetUid_00100 470 * @tc.desc: Test GetUid parameters. 471 * @tc.type: FUNC 472 * @tc.require: issueI5QVYA 473 */ 474 HWTEST_F(ReminderRequestTest, GetUid_00100, Function | SmallTest | Level1) 475 { 476 auto rrc = std::make_shared<ReminderRequestChild>(); 477 EXPECT_EQ(rrc->GetUid(), -1); 478 } 479 480 /** 481 * @tc.name: GetReminderType_00100 482 * @tc.desc: Test GetReminderType parameters. 483 * @tc.type: FUNC 484 * @tc.require: issueI5QVYA 485 */ 486 HWTEST_F(ReminderRequestTest, GetReminderType_00100, Function | SmallTest | Level1) 487 { 488 auto rrc = std::make_shared<ReminderRequestChild>(); 489 EXPECT_EQ(rrc->GetReminderType(), ReminderRequest::ReminderType::INVALID); 490 } 491 492 /** 493 * @tc.name: GetRingDuration_00100 494 * @tc.desc: Test GetRingDuration parameters. 495 * @tc.type: FUNC 496 * @tc.require: issueI5QVYA 497 */ 498 HWTEST_F(ReminderRequestTest, GetRingDuration_00100, Function | SmallTest | Level1) 499 { 500 auto rrc = std::make_shared<ReminderRequestChild>(); 501 EXPECT_EQ(rrc->GetRingDuration(), 1); 502 } 503 504 /** 505 * @tc.name: SetNextTriggerTime_00100 506 * @tc.desc: Test SetNextTriggerTime parameters. 507 * @tc.type: FUNC 508 * @tc.require: issueI5QVYA 509 */ 510 HWTEST_F(ReminderRequestTest, SetNextTriggerTime_00100, Function | SmallTest | Level1) 511 { 512 auto rrc = std::make_shared<ReminderRequestChild>(); 513 EXPECT_EQ(rrc->SetNextTriggerTime(), false); 514 } 515 516 /** 517 * @tc.name: Marshalling_00100 518 * @tc.desc: Test Marshalling parameters. 519 * @tc.type: FUNC 520 * @tc.require: issueI5QVYA 521 */ 522 HWTEST_F(ReminderRequestTest, Marshalling_00100, Function | SmallTest | Level1) 523 { 524 auto rrc = std::make_shared<ReminderRequestChild>(); 525 Parcel p; 526 EXPECT_EQ(rrc->Marshalling(p), true); 527 } 528 529 /** 530 * @tc.name: CanShow_00001 531 * @tc.desc: Test CanShow parameters. 532 * @tc.type: FUNC 533 * @tc.require: issueI5UYHP 534 */ 535 HWTEST_F(ReminderRequestTest, CanShow_00001, Function | SmallTest | Level1) 536 { 537 auto rrc = std::make_shared<ReminderRequestChild>(); 538 EXPECT_EQ(rrc->CanShow(), true); 539 } 540 541 /** 542 * @tc.name: CanShow_00002 543 * @tc.desc: Test CanShow parameters. 544 * @tc.type: FUNC 545 * @tc.require: issueI5UYHP 546 */ 547 HWTEST_F(ReminderRequestTest, CanShow_00002, Function | SmallTest | Level1) 548 { 549 uint64_t reminderTimeInMilli = 5 * 60 * 1000; 550 auto rrc = std::make_shared<ReminderRequestChild>(); 551 rrc->SetReminderTimeInMilli(reminderTimeInMilli); 552 EXPECT_EQ(rrc->CanShow(), true); 553 } 554 555 /** 556 * @tc.name: Dump_00001 557 * @tc.desc: Test Dump parameters. 558 * @tc.type: FUNC 559 * @tc.require: issueI5UYHP 560 */ 561 HWTEST_F(ReminderRequestTest, Dump_00001, Function | SmallTest | Level1) 562 { 563 std::string ret = "Reminder[reminderId=-1, type=3, state='Inactive, nextTriggerTime=1970-01-01 "; 564 auto rrc = std::make_shared<ReminderRequestChild>(); 565 std::string res = rrc->Dump(); 566 EXPECT_EQ(res.substr(0, res.size()-9), ret); 567 } 568 569 /** 570 * @tc.name: SetExpired_00001 571 * @tc.desc: Test SetExpired parameters. 572 * @tc.type: FUNC 573 * @tc.require: issueI5UYHP 574 */ 575 HWTEST_F(ReminderRequestTest, SetExpired_00001, Function | SmallTest | Level1) 576 { 577 auto rrc = std::make_shared<ReminderRequestChild>(); 578 bool isExpired = rrc->IsExpired(); 579 rrc->SetExpired(isExpired); 580 EXPECT_EQ(isExpired, false); 581 } 582 583 /** 584 * @tc.name: HandleTimeZoneChange_00001 585 * @tc.desc: Test HandleTimeZoneChange parameters. 586 * @tc.type: FUNC 587 * @tc.require: issueI5UYHP 588 */ 589 HWTEST_F(ReminderRequestTest, HandleTimeZoneChange_00001, Function | SmallTest | Level1) 590 { 591 auto rrc = std::make_shared<ReminderRequestChild>(); 592 rrc->SetExpired(false); 593 uint64_t oldZoneTriggerTime = 1998; 594 uint64_t newZoneTriggerTime = 1999; 595 uint64_t optTriggerTime = 0; 596 EXPECT_EQ(rrc->HandleTimeZoneChange(oldZoneTriggerTime, newZoneTriggerTime, optTriggerTime), true); 597 } 598 599 /** 600 * @tc.name: HandleTimeZoneChange_00002 601 * @tc.desc: Test HandleTimeZoneChange parameters. 602 * @tc.type: FUNC 603 * @tc.require: issueI5UYHP 604 */ 605 HWTEST_F(ReminderRequestTest, HandleTimeZoneChange_00002, Function | SmallTest | Level1) 606 { 607 auto rrc = std::make_shared<ReminderRequestChild>(); 608 rrc->SetExpired(true); 609 uint64_t oldZoneTriggerTime = 1998; 610 uint64_t newZoneTriggerTime = 1998; 611 uint64_t optTriggerTime = 0; 612 EXPECT_EQ(rrc->HandleTimeZoneChange(oldZoneTriggerTime, newZoneTriggerTime, optTriggerTime), false); 613 } 614 615 /** 616 * @tc.name: HandleTimeZoneChange_00003 617 * @tc.desc: Test HandleTimeZoneChange parameters. 618 * @tc.type: FUNC 619 * @tc.require: issueI5UYHP 620 */ 621 HWTEST_F(ReminderRequestTest, HandleTimeZoneChange_00003, Function | SmallTest | Level1) 622 { 623 auto rrc = std::make_shared<ReminderRequestChild>(); 624 rrc->SetExpired(true); 625 uint64_t oldZoneTriggerTime = 1998; 626 uint64_t newZoneTriggerTime = 1999; 627 uint64_t optTriggerTime = 10; 628 EXPECT_EQ(rrc->HandleTimeZoneChange(oldZoneTriggerTime, newZoneTriggerTime, optTriggerTime), false); 629 } 630 631 /** 632 * @tc.name: HandleTimeZoneChange_00001 633 * @tc.desc: Test HandleSysTimeChange parameters. 634 * @tc.type: FUNC 635 * @tc.require: issueI5UYHP 636 */ 637 HWTEST_F(ReminderRequestTest, HandleSysTimeChange_00001, Function | SmallTest | Level1) 638 { 639 auto rrc = std::make_shared<ReminderRequestChild>(); 640 rrc->SetExpired(true); 641 uint64_t oriTriggerTime = 10; 642 uint64_t optTriggerTime = 10; 643 EXPECT_EQ(rrc->HandleSysTimeChange(oriTriggerTime, optTriggerTime), false); 644 } 645 646 /** 647 * @tc.name: OnSnooze_00001 648 * @tc.desc: Test OnSnooze parameters. 649 * @tc.type: FUNC 650 * @tc.require: issueI5UYHP 651 */ 652 HWTEST_F(ReminderRequestTest, OnSnooze_00001, Function | SmallTest | Level1) 653 { 654 auto rrc = std::make_shared<ReminderRequestChild>(); 655 rrc->OnShow(false, false, true); 656 EXPECT_EQ(rrc->OnSnooze(), true); 657 } 658 659 /** 660 * @tc.name: OnSnooze_00002 661 * @tc.desc: Test OnSnooze parameters. 662 * @tc.type: FUNC 663 * @tc.require: issueI5UYHP 664 */ 665 HWTEST_F(ReminderRequestTest, OnSnooze_00002, Function | SmallTest | Level1) 666 { 667 auto rrc = std::make_shared<ReminderRequestChild>(); 668 rrc->UpdateNextReminder(false); 669 EXPECT_EQ(rrc->OnSnooze(), true); 670 } 671 672 /** 673 * @tc.name: OnSnooze_00003 674 * @tc.desc: Test OnSnooze parameters. 675 * @tc.type: FUNC 676 * @tc.require: issueI5UYHP 677 */ 678 HWTEST_F(ReminderRequestTest, OnSnooze_00003, Function | SmallTest | Level1) 679 { 680 auto rrc = std::make_shared<ReminderRequestChild>(); 681 rrc->SetTimeInterval(100); 682 EXPECT_EQ(rrc->OnSnooze(), true); 683 } 684 685 /** 686 * @tc.name: OnTerminate_00001 687 * @tc.desc: Test OnTerminate parameters. 688 * @tc.type: FUNC 689 * @tc.require: issueI5UYHP 690 */ 691 HWTEST_F(ReminderRequestTest, OnTerminate_00001, Function | SmallTest | Level1) 692 { 693 auto rrc = std::make_shared<ReminderRequestChild>(); 694 rrc->OnShow(false, false, true); 695 EXPECT_EQ(rrc->OnTerminate(), false); 696 } 697 698 /** 699 * @tc.name: OnTimeZoneChange_00001 700 * @tc.desc: Test OnTerOnTimeZoneChangeminate parameters. 701 * @tc.type: FUNC 702 * @tc.require: issueI5UYHP 703 */ 704 HWTEST_F(ReminderRequestTest, OnTimeZoneChange_00001, Function | SmallTest | Level1) 705 { 706 auto rrc = std::make_shared<ReminderRequestChild>(); 707 EXPECT_EQ(rrc->OnTimeZoneChange(), false); 708 } 709 710 /** 711 * @tc.name: RecoverInt64FromDb_00001 712 * @tc.desc: Test RecoverInt64FromDb parameters. 713 * @tc.type: FUNC 714 * @tc.require: issueI5UYHP 715 */ 716 HWTEST_F(ReminderRequestTest, RecoverInt64FromDb_00001, Function | SmallTest | Level1) 717 { 718 std::shared_ptr<NativeRdb::AbsSharedResultSet> resultSet = nullptr; 719 std::string columnName = "columnName"; 720 ReminderRequest::DbRecoveryType columnType = ReminderRequest::DbRecoveryType::INT; 721 auto rrc = std::make_shared<ReminderRequestChild>(); 722 EXPECT_EQ(rrc->RecoverInt64FromDb(resultSet, columnName, columnType), 0); 723 } 724 725 /** 726 * @tc.name: StringSplit_00001 727 * @tc.desc: Test StringSplit parameters. 728 * @tc.type: FUNC 729 * @tc.require: issueI5UYHP 730 */ 731 HWTEST_F(ReminderRequestTest, StringSplit_00001, Function | SmallTest | Level1) 732 { 733 std::string source = ""; 734 std::string split = "split"; 735 auto rrc = std::make_shared<ReminderRequestChild>(); 736 std::vector<std::string> ret = rrc->StringSplit(source, split); 737 EXPECT_EQ(ret.size(), 0); 738 } 739 740 /** 741 * @tc.name: StringSplit_00002 742 * @tc.desc: Test StringSplit parameters. 743 * @tc.type: FUNC 744 * @tc.require: issueI5UYHP 745 */ 746 HWTEST_F(ReminderRequestTest, StringSplit_00002, Function | SmallTest | Level1) 747 { 748 std::string source = "source"; 749 std::string split = "split"; 750 auto rrc = std::make_shared<ReminderRequestChild>(); 751 std::vector<std::string> ret = rrc->StringSplit(source, split); 752 EXPECT_EQ(ret.size(), 1); 753 } 754 755 /** 756 * @tc.name: SetMaxScreenWantAgentInfo_00001 757 * @tc.desc: Test SetMaxScreenWantAgentInfo parameters. 758 * @tc.type: FUNC 759 * @tc.require: issueI5UYHP 760 */ 761 HWTEST_F(ReminderRequestTest, SetMaxScreenWantAgentInfo_00001, Function | SmallTest | Level1) 762 { 763 std::shared_ptr<ReminderRequest::MaxScreenAgentInfo> maxScreenWantAgentInfo = 764 std::make_shared<ReminderRequest::MaxScreenAgentInfo>(); 765 auto rrc = std::make_shared<ReminderRequestChild>(); 766 rrc->SetMaxScreenWantAgentInfo(maxScreenWantAgentInfo); 767 EXPECT_EQ(rrc->GetMaxScreenWantAgentInfo(), maxScreenWantAgentInfo); 768 } 769 770 /** 771 * @tc.name: SetSnoozeContent_00001 772 * @tc.desc: Test SetSnoozeContent parameters. 773 * @tc.type: FUNC 774 * @tc.require: issueI5UYHP 775 */ 776 HWTEST_F(ReminderRequestTest, SetSnoozeContent_00001, Function | SmallTest | Level1) 777 { 778 std::string snoozeContent = "snoozeContent"; 779 auto rrc = std::make_shared<ReminderRequestChild>(); 780 rrc->SetSnoozeContent(snoozeContent); 781 EXPECT_EQ(rrc->GetSnoozeContent(), snoozeContent); 782 } 783 784 /** 785 * @tc.name: SetWantAgentInfo_00001 786 * @tc.desc: Test SetWantAgentInfo parameters. 787 * @tc.type: FUNC 788 * @tc.require: issueI5UYHP 789 */ 790 HWTEST_F(ReminderRequestTest, SetWantAgentInfo_00001, Function | SmallTest | Level1) 791 { 792 std::shared_ptr<ReminderRequest::WantAgentInfo> wantAgentInfo = std::make_shared<ReminderRequest::WantAgentInfo>(); 793 auto rrc = std::make_shared<ReminderRequestChild>(); 794 rrc->SetWantAgentInfo(wantAgentInfo); 795 EXPECT_EQ(rrc->GetWantAgentInfo(), wantAgentInfo); 796 } 797 798 /** 799 * @tc.name: SetReminderTimeInMilli_00001 800 * @tc.desc: Test SetReminderTimeInMilli parameters. 801 * @tc.type: FUNC 802 * @tc.require: issueI5UYHP 803 */ 804 HWTEST_F(ReminderRequestTest, SetReminderTimeInMilli_00001, Function | SmallTest | Level1) 805 { 806 uint64_t reminderTimeInMilli = 10; 807 auto rrc = std::make_shared<ReminderRequestChild>(); 808 rrc->SetReminderTimeInMilli(reminderTimeInMilli); 809 EXPECT_EQ(rrc->GetReminderTimeInMilli(), reminderTimeInMilli); 810 } 811 812 /** 813 * @tc.name: SetRingDuration_00001 814 * @tc.desc: Test SetRingDuration parameters. 815 * @tc.type: FUNC 816 * @tc.require: issueI5VB6V 817 */ 818 HWTEST_F(ReminderRequestTest, SetRingDuration_00001, Function | SmallTest | Level1) 819 { 820 uint64_t ringDurationInSeconds = 0; 821 auto rrc = std::make_shared<ReminderRequestChild>(); 822 rrc->SetRingDuration(ringDurationInSeconds); 823 EXPECT_EQ(rrc->GetRingDuration(), 1); 824 } 825 826 /** 827 * @tc.name: SetRingDuration_00002 828 * @tc.desc: Test SetRingDuration parameters. 829 * @tc.type: FUNC 830 * @tc.require: issueI5VB6V 831 */ 832 HWTEST_F(ReminderRequestTest, SetRingDuration_00002, Function | SmallTest | Level1) 833 { 834 uint64_t ringDurationInSeconds = 10; 835 auto rrc = std::make_shared<ReminderRequestChild>(); 836 rrc->SetRingDuration(ringDurationInSeconds); 837 EXPECT_EQ(rrc->GetRingDuration(), ringDurationInSeconds); 838 } 839 840 /** 841 * @tc.name: Unmarshalling_00001 842 * @tc.desc: Test Unmarshalling parameters. 843 * @tc.type: FUNC 844 * @tc.require: issueI5VB6V 845 */ 846 HWTEST_F(ReminderRequestTest, Unmarshalling_00001, Function | SmallTest | Level1) 847 { 848 bool result = false; 849 Parcel parcel; 850 auto rrc = std::make_shared<ReminderRequestChild>(); 851 if (nullptr == rrc->Unmarshalling(parcel)) { 852 result = true; 853 } 854 EXPECT_EQ(true, result); 855 } 856 857 /** 858 * @tc.name: InitNotificationRequest_00001 859 * @tc.desc: Test InitNotificationRequest parameters. 860 * @tc.type: FUNC 861 * @tc.require: issueI5VB6V 862 */ 863 HWTEST_F(ReminderRequestTest, InitNotificationRequest_00001, Function | SmallTest | Level1) 864 { 865 auto rrc = std::make_shared<ReminderRequestChild>(); 866 EXPECT_EQ(rrc->InitNotificationRequest(), true); 867 } 868 869 /** 870 * @tc.name: InitNotificationRequest_00002 871 * @tc.desc: Test InitNotificationRequest parameters. 872 * @tc.type: FUNC 873 * @tc.require: issueI5VB6V 874 */ 875 HWTEST_F(ReminderRequestTest, InitNotificationRequest_00002, Function | SmallTest | Level1) 876 { 877 auto rrc = std::make_shared<ReminderRequestChild>(); 878 rrc->SetNotificationId(100); 879 EXPECT_EQ(rrc->InitNotificationRequest(), true); 880 } 881 882 /** 883 * @tc.name: IsAlerting_00001 884 * @tc.desc: Test IsAlerting parameters. 885 * @tc.type: FUNC 886 * @tc.require: issueI5VB6V 887 */ 888 HWTEST_F(ReminderRequestTest, IsAlerting_00001, Function | SmallTest | Level1) 889 { 890 auto rrc = std::make_shared<ReminderRequestChild>(); 891 EXPECT_EQ(rrc->IsAlerting(), false); 892 } 893 894 /** 895 * @tc.name: GetButtonInfo_00001 896 * @tc.desc: Test GetButtonInfo parameters. 897 * @tc.type: FUNC 898 * @tc.require: issueI5VB6V 899 */ 900 HWTEST_F(ReminderRequestTest, GetButtonInfo_00001, Function | SmallTest | Level1) 901 { 902 auto rrc = std::make_shared<ReminderRequestChild>(); 903 EXPECT_EQ(rrc->GetButtonInfo(), ""); 904 } 905 906 /** 907 * @tc.name: GetShowTime_00001 908 * @tc.desc: Test GetShowTime parameters. 909 * @tc.type: FUNC 910 * @tc.require: issueI5VB6V 911 */ 912 HWTEST_F(ReminderRequestTest, GetShowTime_00001, Function | SmallTest | Level1) 913 { 914 uint64_t showTime = 8 * 60 * 1000; 915 auto rrc = std::make_shared<ReminderRequestChild>(); 916 std::string ret = ":08"; 917 std::string res = rrc->GetShowTime(showTime); 918 EXPECT_EQ(res.substr(2, res.size()), ret); 919 } 920 921 /** 922 * @tc.name: GetShowTime_00002 923 * @tc.desc: Test GetShowTime parameters. 924 * @tc.type: FUNC 925 * @tc.require: issueI5VB6V 926 */ 927 HWTEST_F(ReminderRequestTest, GetShowTime_00002, Function | SmallTest | Level1) 928 { 929 uint64_t showTime = 8 * 60 * 1000; 930 ReminderRequest reminder = ReminderRequest(ReminderRequest::ReminderType::TIMER); 931 auto rrc = std::make_shared<ReminderRequestChild>(); 932 std::string ret = ":08"; 933 std::string res = rrc->GetShowTime(showTime); 934 EXPECT_EQ(res.substr(2, res.size()), ret); 935 } 936 937 /** 938 * @tc.name: CreateWantAgent_00001 939 * @tc.desc: Test CreateWantAgent parameters. 940 * @tc.type: FUNC 941 * @tc.require: issueI5VB6V 942 */ 943 HWTEST_F(ReminderRequestTest, CreateWantAgent_00001, Function | SmallTest | Level1) 944 { 945 AppExecFwk::ElementName element; 946 auto rrc = std::make_shared<ReminderRequestChild>(); 947 EXPECT_NE(rrc->CreateWantAgent(element), nullptr); 948 } 949 950 /** 951 * @tc.name: GetUid_00001 952 * @tc.desc: Test GetUid parameters. 953 * @tc.type: FUNC 954 * @tc.require: issueI5VB6V 955 */ 956 HWTEST_F(ReminderRequestTest, GetUid_00001, Function | SmallTest | Level1) 957 { 958 int32_t userId = 1; 959 std::string bundleName = "bundleName"; 960 auto rrc = std::make_shared<ReminderRequestChild>(); 961 EXPECT_EQ(rrc->GetUid(userId, bundleName), -1); 962 } 963 964 /** 965 * @tc.name: GetUserId_00001 966 * @tc.desc: Test GetUserId parameters. 967 * @tc.type: FUNC 968 * @tc.require: issueI5VB6V 969 */ 970 HWTEST_F(ReminderRequestTest, GetUserId_00001, Function | SmallTest | Level1) 971 { 972 int32_t uid = 1; 973 auto rrc = std::make_shared<ReminderRequestChild>(); 974 EXPECT_EQ(rrc->GetUserId(uid), 0); 975 } 976 } 977 } 978