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 extern void MockNowInstantMilli(bool mockRet); 25 26 using namespace testing::ext; 27 namespace OHOS { 28 namespace Notification { 29 class ReminderRequestChild : public ReminderRequest { 30 public: ReminderRequestChild()31 ReminderRequestChild() : ReminderRequest() {}; 32 }; 33 34 class ReminderRequestTest : public testing::Test { 35 public: SetUpTestCase()36 static void SetUpTestCase() {} TearDownTestCase()37 static void TearDownTestCase() {} SetUp()38 void SetUp() {} TearDown()39 void TearDown() {} 40 41 static const uint8_t REMINDER_STATUS_SHOWING; 42 }; 43 44 const uint8_t ReminderRequestTest::REMINDER_STATUS_SHOWING = 4; 45 46 /** 47 * @tc.name: CanRemove_00100 48 * @tc.desc: When reminder init, CanRemove should return true. 49 * @tc.type: FUNC 50 * @tc.require: SR000GGTRD AR000GH8EF 51 */ 52 HWTEST_F(ReminderRequestTest, CanRemove_00100, Function | SmallTest | Level1) 53 { 54 auto rrc = std::make_shared<ReminderRequestChild>(); 55 EXPECT_TRUE(rrc->CanRemove()) << "When init, canRemove should be false"; 56 } 57 58 /** 59 * @tc.name: CanRemove_00200 60 * @tc.desc: When reminder is shown, CanRemove should return false. 61 * @tc.type: FUNC 62 * @tc.require: SR000GGTRD AR000GH8EF 63 */ 64 HWTEST_F(ReminderRequestTest, CanRemove_00200, Function | SmallTest | Level1) 65 { 66 auto rrc = std::make_shared<ReminderRequestChild>(); 67 rrc->OnShow(false, false, true); 68 EXPECT_FALSE(rrc->CanRemove()) << "When shown, canRemove should be false"; 69 } 70 71 /** 72 * @tc.name: CanRemove_00300 73 * @tc.desc: When reminder close, CanRemove should return true. 74 * @tc.type: FUNC 75 * @tc.require: SR000GGTRD AR000GH8EF 76 */ 77 HWTEST_F(ReminderRequestTest, CanRemove_00300, Function | SmallTest | Level1) 78 { 79 auto rrc = std::make_shared<ReminderRequestChild>(); 80 rrc->OnShow(false, false, true); 81 rrc->OnClose(false); 82 EXPECT_TRUE(rrc->CanRemove()) << "When reminder is expired and closed, can remove should be false"; 83 } 84 85 /** 86 * @tc.name: CanRemove_00400 87 * @tc.desc: When reminder is covered as same notification id, CanRemove should return true. 88 * @tc.type: FUNC 89 * @tc.require: SR000GGTRD AR000GH8EF AR000GH8E6 90 */ 91 HWTEST_F(ReminderRequestTest, CanRemove_00400, Function | SmallTest | Level1) 92 { 93 auto rrc = std::make_shared<ReminderRequestChild>(); 94 rrc->OnShow(false, false, true); 95 rrc->OnSameNotificationIdCovered(); 96 EXPECT_TRUE(rrc->CanRemove()) << "When reminder is expired and covered by \ 97 sameNotification id, can remove should be true"; 98 } 99 100 /** 101 * @tc.name: StateCheck_00100 102 * @tc.desc: When reminder init, state should be 0. 103 * @tc.type: FUNC 104 * @tc.require: SR000GGTRD AR000GH8EF 105 */ 106 HWTEST_F(ReminderRequestTest, StateCheck_00100, Function | SmallTest | Level1) 107 { 108 auto rrc = std::make_shared<ReminderRequestChild>(); 109 EXPECT_EQ(rrc->GetState(), 0) << "When init, state should be 0"; 110 } 111 112 /** 113 * @tc.name: StateCheck_00200 114 * @tc.desc: When reminder close with param true, state REMINDER_STATUS_SHOWING should be unset. 115 * @tc.type: FUNC 116 * @tc.require: SR000GGTRD AR000GH8EF 117 */ 118 HWTEST_F(ReminderRequestTest, StateCheck_00200, Function | SmallTest | Level1) 119 { 120 auto rrc = std::make_shared<ReminderRequestChild>(); 121 rrc->OnClose(true); 122 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) == 0); 123 } 124 125 /** 126 * @tc.name: StateCheck_00300 127 * @tc.desc: When reminder close with param false, state REMINDER_STATUS_SHOWING should be unset. 128 * @tc.type: FUNC 129 * @tc.require: SR000GGTRD AR000GH8EF 130 */ 131 HWTEST_F(ReminderRequestTest, StateCheck_00300, Function | SmallTest | Level1) 132 { 133 auto rrc = std::make_shared<ReminderRequestChild>(); 134 rrc->OnClose(false); 135 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) == 0); 136 } 137 138 /** 139 * @tc.name: StateCheck_00400 140 * @tc.desc: When reminder is covered as same notification id, state REMINDER_STATUS_SHOWING should be unset. 141 * @tc.type: FUNC 142 * @tc.require: SR000GGTRD AR000GH8EF AR000GH8E6 143 */ 144 HWTEST_F(ReminderRequestTest, StateCheck_00400, Function | SmallTest | Level1) 145 { 146 auto rrc = std::make_shared<ReminderRequestChild>(); 147 rrc->OnSameNotificationIdCovered(); 148 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) == 0); 149 } 150 151 /** 152 * @tc.name: StateCheck_00500 153 * @tc.desc: When reminder is shown with param true,true, state REMINDER_STATUS_SHOWING should be set. 154 * @tc.type: FUNC 155 * @tc.require: SR000GGTRD AR000GH8EF 156 */ 157 HWTEST_F(ReminderRequestTest, StateCheck_00500, Function | SmallTest | Level1) 158 { 159 auto rrc = std::make_shared<ReminderRequestChild>(); 160 rrc->OnShow(false, true, true); 161 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) != 0); 162 } 163 164 /** 165 * @tc.name: StateCheck_00600 166 * @tc.desc: When reminder is shown with param false,true, state REMINDER_STATUS_SHOWING should be set. 167 * @tc.type: FUNC 168 * @tc.require: SR000GGTRD AR000GH8EF 169 */ 170 HWTEST_F(ReminderRequestTest, StateCheck_00600, Function | SmallTest | Level1) 171 { 172 auto rrc = std::make_shared<ReminderRequestChild>(); 173 rrc->OnShow(false, false, true); 174 EXPECT_TRUE((rrc->GetState() & ReminderRequestTest::REMINDER_STATUS_SHOWING) != 0); 175 } 176 177 /** 178 * @tc.name: StateCheck_00700 179 * @tc.desc: When reminder is shown with param true,false, state REMINDER_STATUS_SHOWING should not change. 180 * @tc.type: FUNC 181 * @tc.require: SR000GGTRD AR000GH8EF 182 */ 183 HWTEST_F(ReminderRequestTest, StateCheck_00700, Function | SmallTest | Level1) 184 { 185 auto rrc = std::make_shared<ReminderRequestChild>(); 186 uint8_t stateBefore = rrc->GetState(); 187 rrc->OnShow(false, true, false); 188 EXPECT_EQ(rrc->GetState(), stateBefore); 189 } 190 191 /** 192 * @tc.name: StateCheck_00800 193 * @tc.desc: When reminder is shown with param false,false, state REMINDER_STATUS_SHOWING should be unset. 194 * @tc.type: FUNC 195 * @tc.require: SR000GGTRD AR000GH8EF 196 */ 197 HWTEST_F(ReminderRequestTest, StateCheck_00800, Function | SmallTest | Level1) 198 { 199 auto rrc = std::make_shared<ReminderRequestChild>(); 200 uint8_t stateBefore = rrc->GetState(); 201 rrc->OnShow(false, false, false); 202 EXPECT_EQ(rrc->GetState(), stateBefore); 203 } 204 205 /** 206 * @tc.name: initReminderId_00100 207 * @tc.desc: When reminder create successfully, system should assign unique id to reminder. 208 * @tc.type: FUNC 209 * @tc.require: SR000GGTRD AR000GH8EF AR000GH8E6 210 */ 211 HWTEST_F(ReminderRequestTest, initReminderId_00100, Function | SmallTest | Level1) 212 { 213 auto rrc = std::make_shared<ReminderRequestChild>(); 214 rrc->InitReminderId(); 215 int32_t reminderIdBefore = rrc->GetReminderId(); 216 rrc->InitReminderId(); 217 int32_t reminderIdAfter = rrc->GetReminderId(); 218 EXPECT_EQ((reminderIdAfter - reminderIdBefore), 1); 219 } 220 221 /** 222 * @tc.name: setContent_00100 223 * @tc.desc: Test SetContent with normal parameters. 224 * @tc.type: FUNC 225 * @tc.require: SR000GGTRD AR000GH8EF 226 */ 227 HWTEST_F(ReminderRequestTest, setContent_00100, Function | SmallTest | Level1) 228 { 229 auto rrc = std::make_shared<ReminderRequestChild>(); 230 std::string content = "this is normal content"; 231 rrc->SetContent(content); 232 EXPECT_EQ(rrc->GetContent(), content); 233 } 234 235 /** 236 * @tc.name: setContent_00200 237 * @tc.desc: Test SetContent parameters with special characters. 238 * @tc.type: FUNC 239 * @tc.require: SR000GGTRD AR000GH8EF 240 */ 241 HWTEST_F(ReminderRequestTest, setContent_00200, Function | SmallTest | Level1) 242 { 243 auto rrc = std::make_shared<ReminderRequestChild>(); 244 std::string content = "this is content with special characters: ~!@#$%^&*()-+"; 245 rrc->SetContent(content); 246 EXPECT_EQ(rrc->GetContent(), content); 247 } 248 249 /** 250 * @tc.name: setExpiredContent_00100 251 * @tc.desc: Test SetExpiredContent with normal parameters. 252 * @tc.type: FUNC 253 * @tc.require: SR000GGTRD AR000GH8EF AR000GNF1U AR000GNF1U 254 */ 255 HWTEST_F(ReminderRequestTest, setExpiredContent_00100, Function | SmallTest | Level1) 256 { 257 auto rrc = std::make_shared<ReminderRequestChild>(); 258 std::string content = "this is normal content"; 259 rrc->SetExpiredContent(content); 260 EXPECT_EQ(rrc->GetExpiredContent(), content); 261 } 262 263 /** 264 * @tc.name: setExpiredContent_00200 265 * @tc.desc: Test SetExpiredContent with special characters. 266 * @tc.type: FUNC 267 * @tc.require: SR000GGTRD AR000GH8EF AR000GNF1U AR000GNF1U 268 */ 269 HWTEST_F(ReminderRequestTest, setExpiredContent_00200, Function | SmallTest | Level1) 270 { 271 auto rrc = std::make_shared<ReminderRequestChild>(); 272 std::string content = "this is content with special characters: ~!@#$%^&*()-+"; 273 rrc->SetExpiredContent(content); 274 EXPECT_EQ(rrc->GetExpiredContent(), content); 275 } 276 277 /** 278 * @tc.name: setTitle_00100 279 * @tc.desc: Test SetTitle with normal parameters. 280 * @tc.type: FUNC 281 * @tc.require: SR000GGTRD AR000GH8EF 282 */ 283 HWTEST_F(ReminderRequestTest, setTitle_00100, Function | SmallTest | Level1) 284 { 285 auto rrc = std::make_shared<ReminderRequestChild>(); 286 std::string content = "this is normal content"; 287 rrc->SetTitle(content); 288 EXPECT_EQ(rrc->GetTitle(), content); 289 } 290 291 /** 292 * @tc.name: setTitle_00200 293 * @tc.desc: Test SetTitle with special characters. 294 * @tc.type: FUNC 295 * @tc.require: SR000GGTRD AR000GH8EF 296 */ 297 HWTEST_F(ReminderRequestTest, setTitle_00200, Function | SmallTest | Level1) 298 { 299 auto rrc = std::make_shared<ReminderRequestChild>(); 300 std::string content = "this is content with special characters: ~!@#$%^&*()-+"; 301 rrc->SetTitle(content); 302 EXPECT_EQ(rrc->GetTitle(), content); 303 } 304 305 /** 306 * @tc.name: setNotificationId_00100 307 * @tc.desc: Test SetNotificationId parameters. 308 * @tc.type: FUNC 309 * @tc.require: SR000GGTRD AR000GH8EF 310 */ 311 HWTEST_F(ReminderRequestTest, setNotificationId_00100, Function | SmallTest | Level1) 312 { 313 auto rrc = std::make_shared<ReminderRequestChild>(); 314 int32_t notificationId = 0; 315 rrc->SetNotificationId(notificationId); 316 EXPECT_EQ(rrc->GetNotificationId(), notificationId); 317 } 318 319 /** 320 * @tc.name: setSnoozeTimes_00100 321 * @tc.desc: Test SetSnoozeTimes parameters. 322 * @tc.type: FUNC 323 * @tc.require: AR000GNF1T AR000GH8E7 324 */ 325 HWTEST_F(ReminderRequestTest, setSnoozeTimes_00100, Function | SmallTest | Level1) 326 { 327 auto rrc = std::make_shared<ReminderRequestChild>(); 328 rrc->SetSnoozeTimes(1); 329 EXPECT_EQ(rrc->GetSnoozeTimes(), 1) << "Get snoozeTimes not 1"; 330 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1) << "Get snoozeTimesDynamic not 1"; 331 } 332 333 /** 334 * @tc.name: setTimeInterval_00100 335 * @tc.desc: Test SetTimeInterval parameters. 336 * @tc.type: FUNC 337 * @tc.require: AR000GNF1T 338 */ 339 HWTEST_F(ReminderRequestTest, setTimeInterval_00100, Function | SmallTest | Level1) 340 { 341 uint32_t minTimeIntervalInSecond = 5 * 60; 342 auto rrc = std::make_shared<ReminderRequestChild>(); 343 rrc->SetTimeInterval(-1); 344 EXPECT_EQ(rrc->GetTimeInterval(), 0) << "timeInterval should be 0 when set with value less than 0"; 345 rrc->SetTimeInterval(0); 346 EXPECT_EQ(rrc->GetTimeInterval(), 0) << "timeInterval should be 0 when set with value 0"; 347 rrc->SetTimeInterval(1); 348 EXPECT_EQ(rrc->GetTimeInterval(), minTimeIntervalInSecond) 349 << "0 < timeInterval < minTimeInterval should be set to minTimeInterval"; 350 uint32_t timeInterval = minTimeIntervalInSecond; 351 rrc->SetTimeInterval(timeInterval); 352 EXPECT_EQ(rrc->GetTimeInterval(), timeInterval) << "timeInterval set error"; 353 timeInterval = minTimeIntervalInSecond + 1; 354 rrc->SetTimeInterval(timeInterval); 355 EXPECT_EQ(rrc->GetTimeInterval(), timeInterval) << "timeInterval set error."; 356 } 357 358 /** 359 * @tc.name: IsExpired_00100 360 * @tc.desc: Test IsExpired parameters. 361 * @tc.type: FUNC 362 * @tc.require: issueI5QVYA 363 */ 364 HWTEST_F(ReminderRequestTest, IsExpired_00100, Function | SmallTest | Level1) 365 { 366 auto rrc = std::make_shared<ReminderRequestChild>(); 367 EXPECT_EQ(rrc->IsExpired(), false); 368 } 369 370 /** 371 * @tc.name: IsShowing_00100 372 * @tc.desc: Test IsShowing parameters. 373 * @tc.type: FUNC 374 * @tc.require: issueI5QVYA 375 */ 376 HWTEST_F(ReminderRequestTest, IsShowing_00100, Function | SmallTest | Level1) 377 { 378 auto rrc = std::make_shared<ReminderRequestChild>(); 379 EXPECT_EQ(rrc->IsShowing(), false); 380 } 381 382 /** 383 * @tc.name: IsShowing_00200 384 * @tc.desc: Test IsShowing parameters. 385 * @tc.type: FUNC 386 * @tc.require: issueI5QVYA 387 */ 388 HWTEST_F(ReminderRequestTest, IsShowing_00200, Function | SmallTest | Level1) 389 { 390 auto rrc = std::make_shared<ReminderRequestChild>(); 391 bool deSet = true; 392 uint8_t newState = 4; 393 std::string function = "this is function"; 394 rrc->SetState(deSet, newState, function); 395 uint8_t result1 = rrc->GetState(); 396 EXPECT_EQ(result1, 4); 397 bool result = rrc->IsShowing(); 398 EXPECT_EQ(result, true); 399 } 400 401 /** 402 * @tc.name: OnDateTimeChange_00100 403 * @tc.desc: Test OnDateTimeChange parameters. 404 * @tc.type: FUNC 405 * @tc.require: issueI5QVYA 406 */ 407 HWTEST_F(ReminderRequestTest, OnDateTimeChange_00100, Function | SmallTest | Level1) 408 { 409 MockNowInstantMilli(true); 410 auto rrc = std::make_shared<ReminderRequestChild>(); 411 rrc->isExpired_ = 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=1970-01-01 "; 576 auto rrc = std::make_shared<ReminderRequestChild>(); 577 std::string res = rrc->Dump(); 578 EXPECT_EQ(res.substr(0, res.size()-9), 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 EXPECT_EQ(rrc->OnTimeZoneChange(), false); 776 } 777 778 /** 779 * @tc.name: RecoverInt64FromDb_00001 780 * @tc.desc: Test RecoverInt64FromDb parameters. 781 * @tc.type: FUNC 782 * @tc.require: issueI5UYHP 783 */ 784 HWTEST_F(ReminderRequestTest, RecoverInt64FromDb_00001, Function | SmallTest | Level1) 785 { 786 std::shared_ptr<NativeRdb::ResultSet> resultSet = nullptr; 787 std::string columnName = "columnName"; 788 ReminderRequest::DbRecoveryType columnType = ReminderRequest::DbRecoveryType::INT; 789 auto rrc = std::make_shared<ReminderRequestChild>(); 790 EXPECT_EQ(rrc->RecoverInt64FromDb(resultSet, columnName, columnType), 0); 791 } 792 793 /** 794 * @tc.name: StringSplit_00001 795 * @tc.desc: Test StringSplit parameters. 796 * @tc.type: FUNC 797 * @tc.require: issueI5UYHP 798 */ 799 HWTEST_F(ReminderRequestTest, StringSplit_00001, Function | SmallTest | Level1) 800 { 801 std::string source = ""; 802 std::string split = "split"; 803 auto rrc = std::make_shared<ReminderRequestChild>(); 804 std::vector<std::string> ret = rrc->StringSplit(source, split); 805 EXPECT_EQ(ret.size(), 0); 806 } 807 808 /** 809 * @tc.name: StringSplit_00002 810 * @tc.desc: Test StringSplit parameters. 811 * @tc.type: FUNC 812 * @tc.require: issueI5UYHP 813 */ 814 HWTEST_F(ReminderRequestTest, StringSplit_00002, Function | SmallTest | Level1) 815 { 816 std::string source = "source"; 817 std::string split = "split"; 818 auto rrc = std::make_shared<ReminderRequestChild>(); 819 std::vector<std::string> ret = rrc->StringSplit(source, split); 820 EXPECT_EQ(ret.size(), 1); 821 } 822 823 /** 824 * @tc.name: SetMaxScreenWantAgentInfo_00001 825 * @tc.desc: Test SetMaxScreenWantAgentInfo parameters. 826 * @tc.type: FUNC 827 * @tc.require: issueI5UYHP 828 */ 829 HWTEST_F(ReminderRequestTest, SetMaxScreenWantAgentInfo_00001, Function | SmallTest | Level1) 830 { 831 std::shared_ptr<ReminderRequest::MaxScreenAgentInfo> maxScreenWantAgentInfo = 832 std::make_shared<ReminderRequest::MaxScreenAgentInfo>(); 833 auto rrc = std::make_shared<ReminderRequestChild>(); 834 rrc->SetMaxScreenWantAgentInfo(maxScreenWantAgentInfo); 835 EXPECT_EQ(rrc->GetMaxScreenWantAgentInfo(), maxScreenWantAgentInfo); 836 } 837 838 /** 839 * @tc.name: SetSnoozeContent_00001 840 * @tc.desc: Test SetSnoozeContent parameters. 841 * @tc.type: FUNC 842 * @tc.require: issueI5UYHP 843 */ 844 HWTEST_F(ReminderRequestTest, SetSnoozeContent_00001, Function | SmallTest | Level1) 845 { 846 std::string snoozeContent = "snoozeContent"; 847 auto rrc = std::make_shared<ReminderRequestChild>(); 848 rrc->SetSnoozeContent(snoozeContent); 849 EXPECT_EQ(rrc->GetSnoozeContent(), snoozeContent); 850 } 851 852 /** 853 * @tc.name: SetWantAgentInfo_00001 854 * @tc.desc: Test SetWantAgentInfo parameters. 855 * @tc.type: FUNC 856 * @tc.require: issueI5UYHP 857 */ 858 HWTEST_F(ReminderRequestTest, SetWantAgentInfo_00001, Function | SmallTest | Level1) 859 { 860 std::shared_ptr<ReminderRequest::WantAgentInfo> wantAgentInfo = std::make_shared<ReminderRequest::WantAgentInfo>(); 861 auto rrc = std::make_shared<ReminderRequestChild>(); 862 rrc->SetWantAgentInfo(wantAgentInfo); 863 EXPECT_EQ(rrc->GetWantAgentInfo(), wantAgentInfo); 864 } 865 866 /** 867 * @tc.name: SetReminderTimeInMilli_00001 868 * @tc.desc: Test SetReminderTimeInMilli parameters. 869 * @tc.type: FUNC 870 * @tc.require: issueI5UYHP 871 */ 872 HWTEST_F(ReminderRequestTest, SetReminderTimeInMilli_00001, Function | SmallTest | Level1) 873 { 874 uint64_t reminderTimeInMilli = 10; 875 auto rrc = std::make_shared<ReminderRequestChild>(); 876 rrc->SetReminderTimeInMilli(reminderTimeInMilli); 877 EXPECT_EQ(rrc->GetReminderTimeInMilli(), reminderTimeInMilli); 878 } 879 880 /** 881 * @tc.name: SetRingDuration_00001 882 * @tc.desc: Test SetRingDuration parameters. 883 * @tc.type: FUNC 884 * @tc.require: issueI5VB6V 885 */ 886 HWTEST_F(ReminderRequestTest, SetRingDuration_00001, Function | SmallTest | Level1) 887 { 888 uint64_t ringDurationInSeconds = 0; 889 auto rrc = std::make_shared<ReminderRequestChild>(); 890 rrc->SetRingDuration(ringDurationInSeconds); 891 EXPECT_EQ(rrc->GetRingDuration(), 1); 892 } 893 894 /** 895 * @tc.name: SetRingDuration_00002 896 * @tc.desc: Test SetRingDuration parameters. 897 * @tc.type: FUNC 898 * @tc.require: issueI5VB6V 899 */ 900 HWTEST_F(ReminderRequestTest, SetRingDuration_00002, Function | SmallTest | Level1) 901 { 902 uint64_t ringDurationInSeconds = 10; 903 auto rrc = std::make_shared<ReminderRequestChild>(); 904 rrc->SetRingDuration(ringDurationInSeconds); 905 EXPECT_EQ(rrc->GetRingDuration(), ringDurationInSeconds); 906 } 907 908 /** 909 * @tc.name: Unmarshalling_00001 910 * @tc.desc: Test Unmarshalling parameters. 911 * @tc.type: FUNC 912 * @tc.require: issueI5VB6V 913 */ 914 HWTEST_F(ReminderRequestTest, Unmarshalling_00001, Function | SmallTest | Level1) 915 { 916 bool result = false; 917 Parcel parcel; 918 auto rrc = std::make_shared<ReminderRequestChild>(); 919 if (nullptr == rrc->Unmarshalling(parcel)) { 920 result = true; 921 } 922 EXPECT_EQ(true, result); 923 } 924 925 /** 926 * @tc.name: InitNotificationRequest_00001 927 * @tc.desc: Test InitNotificationRequest parameters. 928 * @tc.type: FUNC 929 * @tc.require: issueI5VB6V 930 */ 931 HWTEST_F(ReminderRequestTest, InitNotificationRequest_00001, Function | SmallTest | Level1) 932 { 933 auto rrc = std::make_shared<ReminderRequestChild>(); 934 EXPECT_EQ(rrc->InitNotificationRequest(), true); 935 } 936 937 /** 938 * @tc.name: InitNotificationRequest_00002 939 * @tc.desc: Test InitNotificationRequest parameters. 940 * @tc.type: FUNC 941 * @tc.require: issueI5VB6V 942 */ 943 HWTEST_F(ReminderRequestTest, InitNotificationRequest_00002, Function | SmallTest | Level1) 944 { 945 auto rrc = std::make_shared<ReminderRequestChild>(); 946 rrc->SetNotificationId(100); 947 EXPECT_EQ(rrc->InitNotificationRequest(), true); 948 } 949 950 /** 951 * @tc.name: IsAlerting_00001 952 * @tc.desc: Test IsAlerting parameters. 953 * @tc.type: FUNC 954 * @tc.require: issueI5VB6V 955 */ 956 HWTEST_F(ReminderRequestTest, IsAlerting_00001, Function | SmallTest | Level1) 957 { 958 auto rrc = std::make_shared<ReminderRequestChild>(); 959 EXPECT_EQ(rrc->IsAlerting(), false); 960 } 961 962 /** 963 * @tc.name: GetButtonInfo_00001 964 * @tc.desc: Test GetButtonInfo parameters. 965 * @tc.type: FUNC 966 * @tc.require: issueI5VB6V 967 */ 968 HWTEST_F(ReminderRequestTest, GetButtonInfo_00001, Function | SmallTest | Level1) 969 { 970 auto rrc = std::make_shared<ReminderRequestChild>(); 971 EXPECT_EQ(rrc->GetButtonInfo(), ""); 972 } 973 974 /** 975 * @tc.name: GetShowTime_00001 976 * @tc.desc: Test GetShowTime parameters. 977 * @tc.type: FUNC 978 * @tc.require: issueI5VB6V 979 */ 980 HWTEST_F(ReminderRequestTest, GetShowTime_00001, Function | SmallTest | Level1) 981 { 982 uint64_t showTime = 8 * 60 * 1000; 983 auto rrc = std::make_shared<ReminderRequestChild>(); 984 std::string ret = ":08"; 985 std::string res = rrc->GetShowTime(showTime); 986 EXPECT_EQ(res.substr(2, res.size()), ret); 987 } 988 989 /** 990 * @tc.name: GetShowTime_00002 991 * @tc.desc: Test GetShowTime parameters. 992 * @tc.type: FUNC 993 * @tc.require: issueI5VB6V 994 */ 995 HWTEST_F(ReminderRequestTest, GetShowTime_00002, Function | SmallTest | Level1) 996 { 997 uint64_t showTime = 8 * 60 * 1000; 998 ReminderRequest reminder = ReminderRequest(ReminderRequest::ReminderType::TIMER); 999 auto rrc = std::make_shared<ReminderRequestChild>(); 1000 std::string ret = ":08"; 1001 std::string res = rrc->GetShowTime(showTime); 1002 EXPECT_EQ(res.substr(2, res.size()), ret); 1003 } 1004 1005 /** 1006 * @tc.name: GetUid_00001 1007 * @tc.desc: Test GetUid parameters. 1008 * @tc.type: FUNC 1009 * @tc.require: issueI5VB6V 1010 */ 1011 HWTEST_F(ReminderRequestTest, GetUid_00001, Function | SmallTest | Level1) 1012 { 1013 int32_t userId = 1; 1014 std::string bundleName = "bundleName"; 1015 auto rrc = std::make_shared<ReminderRequestChild>(); 1016 EXPECT_EQ(rrc->GetUid(userId, bundleName), -1); 1017 } 1018 1019 /** 1020 * @tc.name: GetUserId_00001 1021 * @tc.desc: Test GetUserId parameters. 1022 * @tc.type: FUNC 1023 * @tc.require: issueI5VB6V 1024 */ 1025 HWTEST_F(ReminderRequestTest, GetUserId_00001, Function | SmallTest | Level1) 1026 { 1027 int32_t uid = 1; 1028 auto rrc = std::make_shared<ReminderRequestChild>(); 1029 EXPECT_EQ(rrc->GetUserId(uid), 0); 1030 } 1031 1032 /** 1033 * @tc.name: SetActionButton_00001 1034 * @tc.desc: Test SetActionButton parameters. 1035 * @tc.type: FUNC 1036 * @tc.require: issueI65R21 1037 */ 1038 HWTEST_F(ReminderRequestTest, SetActionButton_00001, Function | SmallTest | Level1) 1039 { 1040 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1041 ASSERT_NE(nullptr, reminderRequestChild); 1042 std::string title = "this is title"; 1043 Notification::ReminderRequest::ActionButtonType type = 1044 Notification::ReminderRequest::ActionButtonType::INVALID; 1045 reminderRequestChild->SetActionButton(title, type); 1046 } 1047 1048 /** 1049 * @tc.name: SetActionButton_00002 1050 * @tc.desc: Test SetActionButton parameters. 1051 * @tc.type: FUNC 1052 * @tc.require: issueI65R21 1053 */ 1054 HWTEST_F(ReminderRequestTest, SetActionButton_00002, Function | SmallTest | Level1) 1055 { 1056 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1057 ASSERT_NE(nullptr, reminderRequestChild); 1058 std::string title = "this is title"; 1059 Notification::ReminderRequest::ActionButtonType type2 = 1060 Notification::ReminderRequest::ActionButtonType::CLOSE; 1061 reminderRequestChild->SetActionButton(title, type2); 1062 } 1063 1064 /** 1065 * @tc.name: SetActionButton_00003 1066 * @tc.desc: Test SetActionButton parameters. 1067 * @tc.type: FUNC 1068 * @tc.require: issueI65R21 1069 */ 1070 HWTEST_F(ReminderRequestTest, SetActionButton_00003, Function | SmallTest | Level1) 1071 { 1072 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1073 ASSERT_NE(nullptr, reminderRequestChild); 1074 std::string title = "this is title"; 1075 Notification::ReminderRequest::ActionButtonType type3 = 1076 Notification::ReminderRequest::ActionButtonType::SNOOZE; 1077 reminderRequestChild->SetActionButton(title, type3); 1078 } 1079 1080 /** 1081 * @tc.name: AddActionButtons_00001 1082 * @tc.desc: Test AddActionButtons parameters. 1083 * @tc.type: FUNC 1084 * @tc.require: issueI65R21 1085 */ 1086 HWTEST_F(ReminderRequestTest, AddActionButtons_00001, Function | SmallTest | Level1) 1087 { 1088 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1089 ASSERT_NE(nullptr, reminderRequestChild); 1090 reminderRequestChild->AddActionButtons(true); 1091 reminderRequestChild->AddActionButtons(false); 1092 } 1093 1094 /** 1095 * @tc.name: InitUserId_00001 1096 * @tc.desc: Test InitUserId parameters. 1097 * @tc.type: FUNC 1098 * @tc.require: issueI65R21 1099 */ 1100 HWTEST_F(ReminderRequestTest, InitUserId_00001, Function | SmallTest | Level1) 1101 { 1102 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1103 ASSERT_NE(nullptr, reminderRequestChild); 1104 bool deSet = true; 1105 uint8_t newState = 2; 1106 std::string function = "this is function"; 1107 int32_t userId = 1; 1108 int32_t uid = 2; 1109 reminderRequestChild->InitUserId(userId); 1110 reminderRequestChild->InitUid(uid); 1111 reminderRequestChild->SetState(deSet, newState, function); 1112 uint8_t result1 = reminderRequestChild->GetState(); 1113 EXPECT_EQ(result1, 2); 1114 bool result = reminderRequestChild->IsShowing(); 1115 EXPECT_EQ(result, false); 1116 reminderRequestChild->OnShow(true, true, true); 1117 reminderRequestChild->OnShowFail(); 1118 } 1119 1120 /** 1121 * @tc.name: OnStart_00001 1122 * @tc.desc: Test OnStart parameters. 1123 * @tc.type: FUNC 1124 * @tc.require: issueI65R21 1125 */ 1126 HWTEST_F(ReminderRequestTest, OnStart_00001, Function | SmallTest | Level1) 1127 { 1128 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1129 ASSERT_NE(nullptr, reminderRequestChild); 1130 reminderRequestChild->OnStart(); 1131 reminderRequestChild->OnStop(); 1132 bool deSet = true; 1133 uint8_t newState = 2; 1134 std::string function = "this is function"; 1135 int32_t userId = 1; 1136 int32_t uid = 2; 1137 reminderRequestChild->InitUserId(userId); 1138 reminderRequestChild->InitUid(uid); 1139 reminderRequestChild->SetState(deSet, newState, function); 1140 reminderRequestChild->OnStart(); 1141 reminderRequestChild->OnStop(); 1142 } 1143 1144 /** 1145 * @tc.name: RecoverInt64FromDb_00002 1146 * @tc.desc: Test RecoverInt64FromDb parameters. 1147 * @tc.type: FUNC 1148 * @tc.require: issueI65R21 1149 */ 1150 HWTEST_F(ReminderRequestTest, RecoverInt64FromDb_00002, Function | SmallTest | Level1) 1151 { 1152 auto rrc = std::make_shared<ReminderRequestChild>(); 1153 std::shared_ptr<NativeRdb::ResultSet> resultSet = 1154 std::make_shared<NativeRdb::AbsSharedResultSet>(); 1155 std::string columnName = "this is columnName"; 1156 ReminderRequest::DbRecoveryType columnType = ReminderRequest::DbRecoveryType::INT; 1157 int64_t result = rrc->RecoverInt64FromDb(resultSet, columnName, columnType); 1158 EXPECT_EQ(result, 0); 1159 1160 ReminderRequest::DbRecoveryType columnType2 = ReminderRequest::DbRecoveryType::LONG; 1161 int64_t result2 = rrc->RecoverInt64FromDb(resultSet, columnName, columnType2); 1162 EXPECT_EQ(result2, 0); 1163 rrc->RecoverFromDb(resultSet); 1164 rrc->RecoverActionButton(resultSet); 1165 rrc->RecoverActionButton(nullptr); 1166 } 1167 1168 /** 1169 * @tc.name: RecoverInt64FromDb_00003 1170 * @tc.desc: Test RecoverInt64FromDb parameters. 1171 * @tc.type: FUNC 1172 * @tc.require: issueI65R21 1173 */ 1174 HWTEST_F(ReminderRequestTest, RecoverInt64FromDb_00003, Function | SmallTest | Level1) 1175 { 1176 auto rrc = std::make_shared<ReminderRequestChild>(); 1177 std::shared_ptr<NativeRdb::ResultSet> resultSet = 1178 std::make_shared<NativeRdb::AbsSharedResultSet>(); 1179 std::string columnName = "this is columnName"; 1180 1181 ReminderRequest::DbRecoveryType columnType = ReminderRequest::DbRecoveryType(3); 1182 int64_t result2 = rrc->RecoverInt64FromDb(resultSet, columnName, columnType); 1183 EXPECT_EQ(result2, 0); 1184 } 1185 1186 /** 1187 * @tc.name: RecoverWantAgent_00002 1188 * @tc.desc: Test RecoverWantAgent parameters. 1189 * @tc.type: FUNC 1190 * @tc.require: issueI65R21 1191 */ 1192 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00002, Function | SmallTest | Level1) 1193 { 1194 auto rrc = std::make_shared<ReminderRequestChild>(); 1195 std::string source = "source"; 1196 std::string split = "split"; 1197 std::vector<std::string> ret = rrc->StringSplit(source, split); 1198 EXPECT_EQ(ret.size(), 1); 1199 1200 std::string wantAgentInfo = "this is wantAgentInfo"; 1201 uint8_t type = 0; 1202 rrc->RecoverWantAgent(wantAgentInfo, type); 1203 } 1204 1205 /** 1206 * @tc.name: GetActionButtons_00002 1207 * @tc.desc: Test GetActionButtons parameters. 1208 * @tc.type: FUNC 1209 * @tc.require: issueI65R21 1210 */ 1211 HWTEST_F(ReminderRequestTest, GetActionButtons_00002, Function | SmallTest | Level1) 1212 { 1213 auto rrc = std::make_shared<ReminderRequestChild>(); 1214 std::map<ReminderRequest::ActionButtonType, ReminderRequest::ActionButtonInfo> ret = 1215 rrc->GetActionButtons(); 1216 EXPECT_EQ(ret.size(), 0); 1217 } 1218 1219 /** 1220 * @tc.name: UpdateNotificationContent_00002 1221 * @tc.desc: Test UpdateNotificationContent parameters. 1222 * @tc.type: FUNC 1223 * @tc.require: issueI65R21 1224 */ 1225 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00002, Function | SmallTest | Level1) 1226 { 1227 auto rrc = std::make_shared<ReminderRequestChild>(); 1228 rrc->SetNotificationId(100); 1229 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1230 1231 rrc->UpdateNotificationContent(true); 1232 rrc->UpdateNotificationContent(false); 1233 1234 Notification::ReminderRequest::TimeTransferType type = Notification::ReminderRequest::TimeTransferType::WEEK; 1235 int32_t actualTime = 1; 1236 int32_t result = rrc->GetCTime(type, actualTime); 1237 EXPECT_EQ(result, 1); 1238 } 1239 1240 /** 1241 * @tc.name: CreateWantAgent_00001 1242 * @tc.desc: Test CreateWantAgent parameters. 1243 * @tc.type: FUNC 1244 * @tc.require: issueI5VB6V 1245 */ 1246 HWTEST_F(ReminderRequestTest, CreateWantAgent_00001, Function | SmallTest | Level1) 1247 { 1248 AppExecFwk::ElementName element; 1249 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1250 ASSERT_NE(nullptr, reminderRequestChild); 1251 std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> WantAgent = 1252 reminderRequestChild->CreateWantAgent(element); 1253 } 1254 1255 /** 1256 * @tc.name: AddColumn_00002 1257 * @tc.desc: Test AddColumn parameters. 1258 * @tc.type: FUNC 1259 * @tc.require: issueI65R21 1260 */ 1261 HWTEST_F(ReminderRequestTest, AddColumn_00002, Function | SmallTest | Level1) 1262 { 1263 auto rrc = std::make_shared<ReminderRequestChild>(); 1264 rrc->InitDbColumns(); 1265 std::string name = "this is name"; 1266 std::string type = "this is type"; 1267 rrc->AddColumn(name, type, true); 1268 rrc->AddColumn(name, type, false); 1269 int32_t result = rrc->GetReminderId(); 1270 EXPECT_EQ(result, -1); 1271 } 1272 1273 /** 1274 * @tc.name: OnClose_00100 1275 * @tc.desc: Test OnClose parameters. 1276 * @tc.type: FUNC 1277 * @tc.require: issueI5QVYA 1278 */ 1279 HWTEST_F(ReminderRequestTest, OnClose_00100, Function | SmallTest | Level1) 1280 { 1281 auto rrc = std::make_shared<ReminderRequestChild>(); 1282 bool deSet = true; 1283 uint8_t newState = 4; 1284 std::string function = "this is function"; 1285 rrc->SetState(deSet, newState, function); 1286 uint8_t result1 = rrc->GetState(); 1287 EXPECT_EQ(result1, 4); 1288 rrc->OnClose(true); 1289 } 1290 1291 /** 1292 * @tc.name: OnClose_00200 1293 * @tc.desc: Test OnClose parameters. 1294 * @tc.type: FUNC 1295 * @tc.require: issueI5QVYA 1296 */ 1297 HWTEST_F(ReminderRequestTest, OnClose_00200, Function | SmallTest | Level1) 1298 { 1299 auto rrc = std::make_shared<ReminderRequestChild>(); 1300 bool deSet = true; 1301 uint8_t newState = 2; 1302 std::string function = "this is function"; 1303 rrc->SetState(deSet, newState, function); 1304 uint8_t result1 = rrc->GetState(); 1305 EXPECT_EQ(result1, 2); 1306 rrc->OnClose(true); 1307 } 1308 1309 /** 1310 * @tc.name: OnShow_00100 1311 * @tc.desc: Test OnShow parameters. 1312 * @tc.type: FUNC 1313 * @tc.require: issueI5QVYA 1314 */ 1315 HWTEST_F(ReminderRequestTest, OnShow_00100, Function | SmallTest | Level1) 1316 { 1317 auto rrc = std::make_shared<ReminderRequestChild>(); 1318 bool deSet = true; 1319 uint8_t newState = 9; 1320 std::string function = "this is function"; 1321 rrc->SetState(deSet, newState, function); 1322 uint8_t result1 = rrc->GetState(); 1323 EXPECT_EQ(result1, 9); 1324 rrc->OnShow(true, true, true); 1325 } 1326 1327 /** 1328 * @tc.name: OnStart_00002 1329 * @tc.desc: Test OnStart parameters. 1330 * @tc.type: FUNC 1331 * @tc.require: issueI65R21 1332 */ 1333 HWTEST_F(ReminderRequestTest, OnStart_00002, Function | SmallTest | Level1) 1334 { 1335 auto rrc = std::make_shared<ReminderRequestChild>(); 1336 bool deSet = true; 1337 uint8_t newState = 1; 1338 std::string function = "this is function"; 1339 rrc->SetState(deSet, newState, function); 1340 uint8_t result1 = rrc->GetState(); 1341 EXPECT_EQ(result1, 1); 1342 rrc->OnStart(); 1343 } 1344 1345 /** 1346 * @tc.name: OnStart_00003 1347 * @tc.desc: Test OnStart parameters. 1348 * @tc.type: FUNC 1349 * @tc.require: issueI65R21 1350 */ 1351 HWTEST_F(ReminderRequestTest, OnStart_00003, Function | SmallTest | Level1) 1352 { 1353 auto rrc = std::make_shared<ReminderRequestChild>(); 1354 bool deSet = true; 1355 uint8_t newState = 2; 1356 std::string function = "this is function"; 1357 rrc->SetState(deSet, newState, function); 1358 uint8_t result1 = rrc->GetState(); 1359 EXPECT_EQ(result1, 2); 1360 rrc->SetExpired(true); 1361 rrc->OnStart(); 1362 } 1363 1364 /** 1365 * @tc.name: StringSplit_00003 1366 * @tc.desc: Test StringSplit parameters. 1367 * @tc.type: FUNC 1368 * @tc.require: issueI65R21 1369 */ 1370 HWTEST_F(ReminderRequestTest, StringSplit_00003, Function | SmallTest | Level1) 1371 { 1372 auto rrc = std::make_shared<ReminderRequestChild>(); 1373 std::string source1 = "source1"; 1374 std::string split = "c"; 1375 std::vector<std::string> ret1 = rrc->StringSplit(source1, split); 1376 EXPECT_EQ(ret1.size(), 2); 1377 } 1378 1379 /** 1380 * @tc.name: RecoverWantAgent_00003 1381 * @tc.desc: Test RecoverWantAgent parameters. 1382 * @tc.type: FUNC 1383 * @tc.require: issueI65R21 1384 */ 1385 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00003, Function | SmallTest | Level1) 1386 { 1387 auto rrc = std::make_shared<ReminderRequestChild>(); 1388 std::string wantAgentInfo = "sour<SEP#/>123"; 1389 uint8_t type = 0; 1390 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1391 EXPECT_EQ(ret1.size(), 2); 1392 rrc->RecoverWantAgent(wantAgentInfo, type); 1393 } 1394 1395 /** 1396 * @tc.name: RecoverWantAgent_00004 1397 * @tc.desc: Test RecoverWantAgent parameters. 1398 * @tc.type: FUNC 1399 * @tc.require: issueI65R21 1400 */ 1401 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00004, Function | SmallTest | Level1) 1402 { 1403 auto rrc = std::make_shared<ReminderRequestChild>(); 1404 std::string wantAgentInfo = "sour<SEP#/>123"; 1405 uint8_t type = 1; 1406 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1407 EXPECT_EQ(ret1.size(), 2); 1408 rrc->RecoverWantAgent(wantAgentInfo, type); 1409 } 1410 1411 /** 1412 * @tc.name: RecoverWantAgent_00005 1413 * @tc.desc: Test RecoverWantAgent parameters. 1414 * @tc.type: FUNC 1415 * @tc.require: issueI65R21 1416 */ 1417 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00005, Function | SmallTest | Level1) 1418 { 1419 auto rrc = std::make_shared<ReminderRequestChild>(); 1420 std::string wantAgentInfo = "sour<SEP#/>123"; 1421 uint8_t type = 2; 1422 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1423 EXPECT_EQ(ret1.size(), 2); 1424 rrc->RecoverWantAgent(wantAgentInfo, type); 1425 } 1426 1427 /** 1428 * @tc.name: UpdateActionButtons_00001 1429 * @tc.desc: Test UpdateActionButtons parameters. 1430 * @tc.type: FUNC 1431 * @tc.require: issueI5VB6V 1432 */ 1433 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00001, Function | SmallTest | Level1) 1434 { 1435 auto rrc = std::make_shared<ReminderRequestChild>(); 1436 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1437 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1438 bool setSnooze = true; 1439 rrc->SetSnoozeTimes(1); 1440 EXPECT_EQ(rrc->GetSnoozeTimes(), 1); 1441 rrc->SetSnoozeTimesDynamic(1); 1442 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1443 rrc->UpdateActionButtons(setSnooze); 1444 } 1445 1446 /** 1447 * @tc.name: UpdateActionButtons_00002 1448 * @tc.desc: Test UpdateActionButtons parameters. 1449 * @tc.type: FUNC 1450 * @tc.require: issueI5VB6V 1451 */ 1452 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00002, Function | SmallTest | Level1) 1453 { 1454 auto rrc = std::make_shared<ReminderRequestChild>(); 1455 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1456 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1457 bool setSnooze = true; 1458 rrc->SetSnoozeTimes(0); 1459 EXPECT_EQ(rrc->GetSnoozeTimes(), 0); 1460 rrc->SetSnoozeTimesDynamic(1); 1461 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1462 rrc->UpdateActionButtons(setSnooze); 1463 } 1464 1465 /** 1466 * @tc.name: UpdateActionButtons_00003 1467 * @tc.desc: Test UpdateActionButtons parameters. 1468 * @tc.type: FUNC 1469 * @tc.require: issueI5VB6V 1470 */ 1471 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00003, Function | SmallTest | Level1) 1472 { 1473 auto rrc = std::make_shared<ReminderRequestChild>(); 1474 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1475 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1476 bool setSnooze = false; 1477 rrc->SetSnoozeTimes(1); 1478 EXPECT_EQ(rrc->GetSnoozeTimes(), 1); 1479 rrc->SetSnoozeTimesDynamic(1); 1480 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1481 rrc->UpdateActionButtons(setSnooze); 1482 } 1483 1484 /** 1485 * @tc.name: UpdateActionButtons_00004 1486 * @tc.desc: Test UpdateActionButtons parameters. 1487 * @tc.type: FUNC 1488 * @tc.require: issueI5VB6V 1489 */ 1490 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00004, Function | SmallTest | Level1) 1491 { 1492 auto rrc = std::make_shared<ReminderRequestChild>(); 1493 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1494 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1495 bool setSnooze = true; 1496 rrc->SetSnoozeTimes(1); 1497 EXPECT_EQ(rrc->GetSnoozeTimes(), 1); 1498 rrc->SetSnoozeTimesDynamic(0); 1499 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 0); 1500 rrc->UpdateActionButtons(setSnooze); 1501 } 1502 1503 /** 1504 * @tc.name: UpdateNotificationContent_00300 1505 * @tc.desc: Test UpdateNotificationContent parameters. 1506 * @tc.type: FUNC 1507 * @tc.require: AR000GNF1T 1508 */ 1509 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00300, Function | SmallTest | Level1) 1510 { 1511 auto rrc = std::make_shared<ReminderRequestChild>(); 1512 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1513 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1514 uint32_t minTimeIntervalInSecond = 5 * 60; 1515 rrc->SetTimeInterval(1); 1516 EXPECT_EQ(rrc->GetTimeInterval(), minTimeIntervalInSecond); 1517 1518 bool setSnooze = true; 1519 rrc->UpdateNotificationContent(setSnooze); 1520 } 1521 1522 1523 /** 1524 * @tc.name: UpdateNotificationContent_00400 1525 * @tc.desc: Test UpdateNotificationContent parameters. 1526 * @tc.type: FUNC 1527 * @tc.require: AR000GNF1T 1528 */ 1529 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00400, Function | SmallTest | Level1) 1530 { 1531 auto rrc = std::make_shared<ReminderRequestChild>(); 1532 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1533 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1534 1535 bool deSet = true; 1536 uint8_t newState = 2; 1537 std::string function = "this is function"; 1538 rrc->SetState(deSet, newState, function); 1539 uint8_t result1 = rrc->GetState(); 1540 EXPECT_EQ(result1, 2); 1541 EXPECT_EQ(rrc->IsAlerting(), true); 1542 bool setSnooze = false; 1543 rrc->UpdateNotificationContent(setSnooze); 1544 } 1545 1546 /** 1547 * @tc.name: UpdateNotificationContent_00500 1548 * @tc.desc: Test UpdateNotificationContent parameters. 1549 * @tc.type: FUNC 1550 * @tc.require: AR000GNF1T 1551 */ 1552 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00500, Function | SmallTest | Level1) 1553 { 1554 auto rrc = std::make_shared<ReminderRequestChild>(); 1555 EXPECT_EQ(rrc->InitNotificationRequest(), true); 1556 sptr<NotificationRequest> ret = rrc->GetNotificationRequest(); 1557 1558 bool deSet = false; 1559 uint8_t newState = 0; 1560 std::string function = "this is function"; 1561 rrc->SetState(deSet, newState, function); 1562 uint8_t result1 = rrc->GetState(); 1563 EXPECT_EQ(result1, 0); 1564 EXPECT_EQ(rrc->IsAlerting(), false); 1565 1566 rrc->SetSnoozeTimes(0); 1567 EXPECT_EQ(rrc->GetSnoozeTimes(), 0); 1568 rrc->SetSnoozeTimesDynamic(1); 1569 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1570 1571 bool setSnooze = false; 1572 rrc->UpdateNotificationContent(setSnooze); 1573 } 1574 1575 /** 1576 * @tc.name: GetCTime_00001 1577 * @tc.desc: Test GetCTime parameters. 1578 * @tc.type: FUNC 1579 * @tc.require: issueI65R21 1580 */ 1581 HWTEST_F(ReminderRequestTest, GetCTime_00001, Function | SmallTest | Level1) 1582 { 1583 auto rrc = std::make_shared<ReminderRequestChild>(); 1584 Notification::ReminderRequest::TimeTransferType type = Notification::ReminderRequest::TimeTransferType(3); 1585 int32_t actualTime = 1; 1586 int32_t result = rrc->GetCTime(type, actualTime); 1587 int32_t ret = -1; 1588 EXPECT_EQ(result, ret); 1589 } 1590 1591 /** 1592 * @tc.name: GetActualTime_00001 1593 * @tc.desc: Test GetActualTime parameters. 1594 * @tc.type: FUNC 1595 * @tc.require: issueI65R21 1596 */ 1597 HWTEST_F(ReminderRequestTest, GetActualTime_00001, Function | SmallTest | Level1) 1598 { 1599 auto rrc = std::make_shared<ReminderRequestChild>(); 1600 Notification::ReminderRequest::TimeTransferType type = Notification::ReminderRequest::TimeTransferType(3); 1601 int32_t actualTime = 1; 1602 int32_t result = rrc->GetActualTime(type, actualTime); 1603 int32_t ret = -1; 1604 EXPECT_EQ(result, ret); 1605 } 1606 1607 /** 1608 * @tc.name: SetSystemApp_00001 1609 * @tc.desc: Test SetSystemApp parameters. 1610 * @tc.type: FUNC 1611 * @tc.require: issueI6NQPJ 1612 */ 1613 HWTEST_F(ReminderRequestTest, SetSystemApp_00001, Function | SmallTest | Level1) 1614 { 1615 auto rrc = std::make_shared<ReminderRequestChild>(); 1616 rrc->SetSystemApp(true); 1617 bool result = rrc->IsSystemApp(); 1618 bool ret = true; 1619 EXPECT_EQ(result, ret); 1620 } 1621 1622 /** 1623 * @tc.name: SetTapDismissed_00001 1624 * @tc.desc: Test SetTapDismissed parameters. 1625 * @tc.type: FUNC 1626 * @tc.require: issueI6NQPJ 1627 */ 1628 HWTEST_F(ReminderRequestTest, SetTapDismissed_00001, Function | SmallTest | Level1) 1629 { 1630 auto rrc = std::make_shared<ReminderRequestChild>(); 1631 rrc->SetTapDismissed(true); 1632 bool result = rrc->IsTapDismissed(); 1633 bool ret = true; 1634 EXPECT_EQ(result, ret); 1635 } 1636 1637 /** 1638 * @tc.name: SetAutoDeletedTime_00001 1639 * @tc.desc: Test SetAutoDeletedTime parameters. 1640 * @tc.type: FUNC 1641 * @tc.require: issueI6NQPJ 1642 */ 1643 HWTEST_F(ReminderRequestTest, SetAutoDeletedTime_00001, Function | SmallTest | Level1) 1644 { 1645 auto rrc = std::make_shared<ReminderRequestChild>(); 1646 rrc->SetAutoDeletedTime(1); 1647 int32_t result = rrc->GetAutoDeletedTime(); 1648 int32_t ret = 1; 1649 EXPECT_EQ(result, ret); 1650 } 1651 1652 /** 1653 * @tc.name: SetCustomButtonUri_00001 1654 * @tc.desc: Test SetCustomButtonUri parameters. 1655 * @tc.type: FUNC 1656 * @tc.require: issueI6NQPJ 1657 */ 1658 HWTEST_F(ReminderRequestTest, SetCustomButtonUri_00001, Function | SmallTest | Level1) 1659 { 1660 auto rrc = std::make_shared<ReminderRequestChild>(); 1661 rrc->SetCustomButtonUri("test"); 1662 std::string result = rrc->GetCustomButtonUri(); 1663 std::string ret = "test"; 1664 EXPECT_EQ(result, ret); 1665 } 1666 } 1667 } 1668