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 #include "reminder_request.h" 19 #include "reminder_table_old.h" 20 #include "reminder_table.h" 21 #include "string_wrapper.h" 22 #include "reminder_request_factory.h" 23 #include "reminder_request_adaptation.h" 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 = ReminderRequest::MIN_TIME_INTERVAL_IN_MILLI / ReminderRequest::MILLI_SECONDS; 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), false); 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 EXPECT_EQ(rrc->HandleSysTimeChange(oriTriggerTime, optTriggerTime), true); 671 } 672 673 /** 674 * @tc.name: OnSnooze_00001 675 * @tc.desc: Test OnSnooze parameters. 676 * @tc.type: FUNC 677 * @tc.require: issueI5UYHP 678 */ 679 HWTEST_F(ReminderRequestTest, OnSnooze_00001, Function | SmallTest | Level1) 680 { 681 MockNowInstantMilli(true); 682 auto rrc = std::make_shared<ReminderRequestChild>(); 683 rrc->OnShow(false, false, true); 684 EXPECT_EQ(rrc->OnSnooze(), true); 685 } 686 687 /** 688 * @tc.name: OnSnooze_00002 689 * @tc.desc: Test OnSnooze parameters. 690 * @tc.type: FUNC 691 * @tc.require: issueI5UYHP 692 */ 693 HWTEST_F(ReminderRequestTest, OnSnooze_00002, Function | SmallTest | Level1) 694 { 695 MockNowInstantMilli(true); 696 auto rrc = std::make_shared<ReminderRequestChild>(); 697 rrc->UpdateNextReminder(false); 698 EXPECT_EQ(rrc->OnSnooze(), true); 699 } 700 701 /** 702 * @tc.name: OnSnooze_00003 703 * @tc.desc: Test OnSnooze parameters. 704 * @tc.type: FUNC 705 * @tc.require: issueI5UYHP 706 */ 707 HWTEST_F(ReminderRequestTest, OnSnooze_00003, Function | SmallTest | Level1) 708 { 709 MockNowInstantMilli(true); 710 auto rrc = std::make_shared<ReminderRequestChild>(); 711 rrc->SetTimeInterval(100); 712 EXPECT_EQ(rrc->OnSnooze(), true); 713 } 714 715 /** 716 * @tc.name: OnSnooze_00004 717 * @tc.desc: Test OnSnooze parameters. 718 * @tc.type: FUNC 719 * @tc.require: issueI5UYHP 720 */ 721 HWTEST_F(ReminderRequestTest, OnSnooze_00004, Function | SmallTest | Level1) 722 { 723 auto rrc = std::make_shared<ReminderRequestChild>(); 724 bool deSet = true; 725 uint8_t newState = 8; 726 std::string function = "this is function"; 727 rrc->SetState(deSet, newState, function); 728 uint8_t result1 = rrc->GetState(); 729 EXPECT_EQ(result1, 8); 730 EXPECT_EQ(rrc->OnSnooze(), false); 731 } 732 733 /** 734 * @tc.name: OnSnooze_00005 735 * @tc.desc: Test OnSnooze parameters. 736 * @tc.type: FUNC 737 * @tc.require: issueI5UYHP 738 */ 739 HWTEST_F(ReminderRequestTest, OnSnooze_00005, Function | SmallTest | Level1) 740 { 741 MockNowInstantMilli(true); 742 auto rrc = std::make_shared<ReminderRequestChild>(); 743 bool deSet = true; 744 uint8_t newState = 1; 745 std::string function = "this is function"; 746 rrc->SetState(deSet, newState, function); 747 uint8_t result1 = rrc->GetState(); 748 EXPECT_EQ(result1, 1); 749 EXPECT_EQ(rrc->OnSnooze(), true); 750 } 751 752 /** 753 * @tc.name: OnTerminate_00001 754 * @tc.desc: Test OnTerminate parameters. 755 * @tc.type: FUNC 756 * @tc.require: issueI5UYHP 757 */ 758 HWTEST_F(ReminderRequestTest, OnTerminate_00001, Function | SmallTest | Level1) 759 { 760 auto rrc = std::make_shared<ReminderRequestChild>(); 761 rrc->OnShow(false, false, true); 762 EXPECT_EQ(rrc->OnTerminate(), false); 763 } 764 765 /** 766 * @tc.name: OnTimeZoneChange_00001 767 * @tc.desc: Test OnTerOnTimeZoneChangeminate parameters. 768 * @tc.type: FUNC 769 * @tc.require: issueI5UYHP 770 */ 771 HWTEST_F(ReminderRequestTest, OnTimeZoneChange_00001, Function | SmallTest | Level1) 772 { 773 auto rrc = std::make_shared<ReminderRequestChild>(); 774 uint64_t ret = rrc->GetTriggerTimeInMilli(); 775 struct tm oriTime; 776 time_t newZoneTriggerTime = mktime(&oriTime); 777 uint64_t ret2 = rrc->GetDurationSinceEpochInMilli(newZoneTriggerTime); 778 if (ret == ret2) { 779 EXPECT_EQ(rrc->OnTimeZoneChange(), false); 780 } else { 781 EXPECT_EQ(rrc->OnTimeZoneChange(), true); 782 } 783 } 784 785 /** 786 * @tc.name: StringSplit_00001 787 * @tc.desc: Test StringSplit parameters. 788 * @tc.type: FUNC 789 * @tc.require: issueI5UYHP 790 */ 791 HWTEST_F(ReminderRequestTest, StringSplit_00001, Function | SmallTest | Level1) 792 { 793 std::string source = ""; 794 std::string split = "split"; 795 auto rrc = std::make_shared<ReminderRequestChild>(); 796 std::vector<std::string> ret = rrc->StringSplit(source, split); 797 EXPECT_EQ(ret.size(), 0); 798 } 799 800 /** 801 * @tc.name: StringSplit_00002 802 * @tc.desc: Test StringSplit parameters. 803 * @tc.type: FUNC 804 * @tc.require: issueI5UYHP 805 */ 806 HWTEST_F(ReminderRequestTest, StringSplit_00002, Function | SmallTest | Level1) 807 { 808 std::string source = "source"; 809 std::string split = "split"; 810 auto rrc = std::make_shared<ReminderRequestChild>(); 811 std::vector<std::string> ret = rrc->StringSplit(source, split); 812 EXPECT_EQ(ret.size(), 1); 813 } 814 815 /** 816 * @tc.name: SetMaxScreenWantAgentInfo_001 817 * @tc.desc: Test SetMaxScreenWantAgentInfo parameters. 818 * @tc.type: FUNC 819 * @tc.require: issueI5UYHP 820 */ 821 HWTEST_F(ReminderRequestTest, SetMaxScreenWantAgentInfo_001, Function | SmallTest | Level1) 822 { 823 auto agentInfo = std::make_shared<ReminderRequest::MaxScreenAgentInfo>(); 824 auto rrc = std::make_shared<ReminderRequestChild>(); 825 rrc->SetMaxScreenWantAgentInfo(agentInfo); 826 EXPECT_EQ(rrc->GetMaxScreenWantAgentInfo(), agentInfo); 827 } 828 829 /** 830 * @tc.name: SetMaxScreenWantAgentInfo_002 831 * @tc.desc: Test SetMaxScreenWantAgentInfo parameters. 832 * @tc.type: FUNC 833 * @tc.require: issueI5UYHP 834 */ 835 HWTEST_F(ReminderRequestTest, SetMaxScreenWantAgentInfo_002, Function | SmallTest | Level1) 836 { 837 auto rrc = std::make_shared<ReminderRequestChild>(); 838 rrc->SetMaxScreenWantAgentInfo(nullptr); 839 EXPECT_EQ(rrc->GetMaxScreenWantAgentInfo(), nullptr); 840 } 841 842 /** 843 * @tc.name: SetSnoozeContent_00001 844 * @tc.desc: Test SetSnoozeContent parameters. 845 * @tc.type: FUNC 846 * @tc.require: issueI5UYHP 847 */ 848 HWTEST_F(ReminderRequestTest, SetSnoozeContent_00001, Function | SmallTest | Level1) 849 { 850 std::string snoozeContent = "snoozeContent"; 851 auto rrc = std::make_shared<ReminderRequestChild>(); 852 rrc->SetSnoozeContent(snoozeContent); 853 EXPECT_EQ(rrc->GetSnoozeContent(), snoozeContent); 854 } 855 856 /** 857 * @tc.name: SetWantAgentInfo_001 858 * @tc.desc: Test SetWantAgentInfo parameters. 859 * @tc.type: FUNC 860 * @tc.require: issueI5UYHP 861 */ 862 HWTEST_F(ReminderRequestTest, SetWantAgentInfo_001, Function | SmallTest | Level1) 863 { 864 auto rrc = std::make_shared<ReminderRequestChild>(); 865 EXPECT_NE(rrc->GetWantAgentInfo(), nullptr); 866 auto wantAgentInfo = std::make_shared<ReminderRequest::WantAgentInfo>(); 867 rrc->SetWantAgentInfo(wantAgentInfo); 868 EXPECT_EQ(rrc->GetWantAgentInfo(), wantAgentInfo); 869 rrc->SetWantAgentInfo(nullptr); 870 EXPECT_EQ(rrc->GetWantAgentInfo(), wantAgentInfo); 871 } 872 873 /** 874 * @tc.name: SetReminderTimeInMilli_00001 875 * @tc.desc: Test SetReminderTimeInMilli parameters. 876 * @tc.type: FUNC 877 * @tc.require: issueI5UYHP 878 */ 879 HWTEST_F(ReminderRequestTest, SetReminderTimeInMilli_00001, Function | SmallTest | Level1) 880 { 881 uint64_t reminderTimeInMilli = 10; 882 auto rrc = std::make_shared<ReminderRequestChild>(); 883 rrc->SetReminderTimeInMilli(reminderTimeInMilli); 884 EXPECT_EQ(rrc->GetReminderTimeInMilli(), reminderTimeInMilli); 885 } 886 887 /** 888 * @tc.name: SetRingDuration_00001 889 * @tc.desc: Test SetRingDuration parameters. 890 * @tc.type: FUNC 891 * @tc.require: issueI5VB6V 892 */ 893 HWTEST_F(ReminderRequestTest, SetRingDuration_00001, Function | SmallTest | Level1) 894 { 895 uint64_t ringDurationInSeconds = 0; 896 auto rrc = std::make_shared<ReminderRequestChild>(); 897 rrc->SetRingDuration(ringDurationInSeconds); 898 EXPECT_EQ(rrc->GetRingDuration(), 0); 899 } 900 901 /** 902 * @tc.name: SetRingDuration_00002 903 * @tc.desc: Test SetRingDuration parameters. 904 * @tc.type: FUNC 905 * @tc.require: issueI5VB6V 906 */ 907 HWTEST_F(ReminderRequestTest, SetRingDuration_00002, Function | SmallTest | Level1) 908 { 909 uint64_t ringDurationInSeconds = 10; 910 auto rrc = std::make_shared<ReminderRequestChild>(); 911 rrc->SetRingDuration(ringDurationInSeconds); 912 EXPECT_EQ(rrc->GetRingDuration(), ringDurationInSeconds); 913 } 914 915 /** 916 * @tc.name: SetRingDuration_00003 917 * @tc.desc: Test SetRingDuration parameters. 918 * @tc.type: FUNC 919 * @tc.require: issueI5VB6V 920 */ 921 HWTEST_F(ReminderRequestTest, SetRingDuration_00003, Function | SmallTest | Level1) 922 { 923 uint64_t ringDurationInSeconds = 45 * 60; 924 auto rrc = std::make_shared<ReminderRequestChild>(); 925 rrc->SetRingDuration(ringDurationInSeconds); 926 EXPECT_EQ(rrc->GetRingDuration(), ReminderRequest::MAX_RING_DURATION / ReminderRequest::MILLI_SECONDS); 927 } 928 929 /** 930 * @tc.name: SetRingDuration_00004 931 * @tc.desc: Test SetRingDuration parameters. 932 * @tc.type: FUNC 933 * @tc.require: issueI5VB6V 934 */ 935 HWTEST_F(ReminderRequestTest, SetRingDuration_00004, Function | SmallTest | Level1) 936 { 937 uint64_t ringDurationInSeconds = UINT64_MAX - 1; 938 auto rrc = std::make_shared<ReminderRequestChild>(); 939 rrc->SetRingDuration(ringDurationInSeconds); 940 EXPECT_EQ(rrc->GetRingDuration(), 0); 941 } 942 943 /** 944 * @tc.name: Unmarshalling_00001 945 * @tc.desc: Test Unmarshalling parameters. 946 * @tc.type: FUNC 947 * @tc.require: issueI5VB6V 948 */ 949 HWTEST_F(ReminderRequestTest, Unmarshalling_00001, Function | SmallTest | Level1) 950 { 951 bool result = false; 952 Parcel parcel; 953 auto rrc = std::make_shared<ReminderRequestChild>(); 954 if (nullptr == rrc->Unmarshalling(parcel)) { 955 result = true; 956 } 957 EXPECT_EQ(true, result); 958 } 959 960 /** 961 * @tc.name: IsAlerting_00001 962 * @tc.desc: Test IsAlerting parameters. 963 * @tc.type: FUNC 964 * @tc.require: issueI5VB6V 965 */ 966 HWTEST_F(ReminderRequestTest, IsAlerting_00001, Function | SmallTest | Level1) 967 { 968 auto rrc = std::make_shared<ReminderRequestChild>(); 969 EXPECT_EQ(rrc->IsAlerting(), false); 970 } 971 972 /** 973 * @tc.name: GetButtonInfo_00001 974 * @tc.desc: Test GetButtonInfo parameters. 975 * @tc.type: FUNC 976 * @tc.require: issueI5VB6V 977 */ 978 HWTEST_F(ReminderRequestTest, GetButtonInfo_00001, Function | SmallTest | Level1) 979 { 980 auto rrc = std::make_shared<ReminderRequestChild>(); 981 EXPECT_EQ(rrc->SerializeButtonInfo(), ""); 982 } 983 984 /** 985 * @tc.name: GetShowTime_00001 986 * @tc.desc: Test GetShowTime parameters. 987 * @tc.type: FUNC 988 * @tc.require: issueI5VB6V 989 */ 990 HWTEST_F(ReminderRequestTest, GetShowTime_00001, Function | SmallTest | Level1) 991 { 992 uint64_t showTime = 8 * 60 * 1000; 993 auto rrc = std::make_shared<ReminderRequestChild>(); 994 std::string ret = "8"; 995 std::string res = rrc->GetShowTime(showTime); 996 EXPECT_EQ(res.substr(4, res.size()), ret); 997 } 998 999 /** 1000 * @tc.name: GetShowTime_00002 1001 * @tc.desc: Test GetShowTime parameters. 1002 * @tc.type: FUNC 1003 * @tc.require: issueI5VB6V 1004 */ 1005 HWTEST_F(ReminderRequestTest, GetShowTime_00002, Function | SmallTest | Level1) 1006 { 1007 uint64_t showTime = 8 * 60 * 1000; 1008 ReminderRequest reminder = ReminderRequest(ReminderRequest::ReminderType::TIMER); 1009 auto rrc = std::make_shared<ReminderRequestChild>(); 1010 std::string ret = "8"; 1011 std::string res = rrc->GetShowTime(showTime); 1012 EXPECT_EQ(res.substr(4, res.size()), ret); 1013 } 1014 1015 /** 1016 * @tc.name: SetActionButton_00001 1017 * @tc.desc: Test SetActionButton parameters. 1018 * @tc.type: FUNC 1019 * @tc.require: issueI65R21 1020 */ 1021 HWTEST_F(ReminderRequestTest, SetActionButton_00001, Function | SmallTest | Level1) 1022 { 1023 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1024 ASSERT_NE(nullptr, reminderRequestChild); 1025 std::string title = "this is title"; 1026 std::string resource = "invalid"; 1027 Notification::ReminderRequest::ActionButtonType type = 1028 Notification::ReminderRequest::ActionButtonType::INVALID; 1029 reminderRequestChild->SetActionButton(title, type, resource); 1030 } 1031 1032 /** 1033 * @tc.name: SetActionButton_00002 1034 * @tc.desc: Test SetActionButton parameters. 1035 * @tc.type: FUNC 1036 * @tc.require: issueI65R21 1037 */ 1038 HWTEST_F(ReminderRequestTest, SetActionButton_00002, 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 std::string resource = "close"; 1044 Notification::ReminderRequest::ActionButtonType type2 = 1045 Notification::ReminderRequest::ActionButtonType::CLOSE; 1046 reminderRequestChild->SetActionButton(title, type2, resource); 1047 } 1048 1049 /** 1050 * @tc.name: SetActionButton_00003 1051 * @tc.desc: Test SetActionButton parameters. 1052 * @tc.type: FUNC 1053 * @tc.require: issueI65R21 1054 */ 1055 HWTEST_F(ReminderRequestTest, SetActionButton_00003, Function | SmallTest | Level1) 1056 { 1057 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1058 ASSERT_NE(nullptr, reminderRequestChild); 1059 std::string title = "this is title"; 1060 std::string resource = "snooze"; 1061 Notification::ReminderRequest::ActionButtonType type3 = 1062 Notification::ReminderRequest::ActionButtonType::SNOOZE; 1063 reminderRequestChild->SetActionButton(title, type3, resource); 1064 } 1065 1066 /** 1067 * @tc.name: SetActionButton_00004 1068 * @tc.desc: Test SetActionButton parameters. 1069 * @tc.type: FUNC 1070 * @tc.require: issueI89IQR 1071 */ 1072 HWTEST_F(ReminderRequestTest, SetActionButton_00004, Function | SmallTest | Level1) 1073 { 1074 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1075 ASSERT_NE(nullptr, reminderRequestChild); 1076 std::string title = "this is title"; 1077 std::string resource = "CLOSE"; 1078 Notification::ReminderRequest::ActionButtonType type2 = 1079 Notification::ReminderRequest::ActionButtonType::CLOSE; 1080 std::shared_ptr<ReminderRequest::ButtonWantAgent> buttonWantAgent = 1081 std::make_shared<ReminderRequest::ButtonWantAgent>(); 1082 std::shared_ptr<ReminderRequest::ButtonDataShareUpdate> buttonDataShareUpdate = 1083 std::make_shared<ReminderRequest::ButtonDataShareUpdate>(); 1084 reminderRequestChild->SetActionButton(title, type2, resource, buttonWantAgent, buttonDataShareUpdate); 1085 } 1086 1087 /** 1088 * @tc.name: SetActionButton_00005 1089 * @tc.desc: Test SetActionButton parameters. 1090 * @tc.type: FUNC 1091 * @tc.require: issueI89IQR 1092 */ 1093 HWTEST_F(ReminderRequestTest, SetActionButton_00005, Function | SmallTest | Level1) 1094 { 1095 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1096 ASSERT_NE(nullptr, reminderRequestChild); 1097 std::string title = "this is title"; 1098 std::string resource = "SNOOZE"; 1099 Notification::ReminderRequest::ActionButtonType type3 = 1100 Notification::ReminderRequest::ActionButtonType::SNOOZE; 1101 std::shared_ptr<ReminderRequest::ButtonWantAgent> buttonWantAgent = 1102 std::make_shared<ReminderRequest::ButtonWantAgent>(); 1103 std::shared_ptr<ReminderRequest::ButtonDataShareUpdate> buttonDataShareUpdate = 1104 std::make_shared<ReminderRequest::ButtonDataShareUpdate>(); 1105 reminderRequestChild->SetActionButton(title, type3, resource, buttonWantAgent, buttonDataShareUpdate); 1106 } 1107 1108 /** 1109 * @tc.name: AddActionButtons_00001 1110 * @tc.desc: Test AddActionButtons parameters. 1111 * @tc.type: FUNC 1112 * @tc.require: issueI65R21 1113 */ 1114 HWTEST_F(ReminderRequestTest, AddActionButtons_00001, Function | SmallTest | Level1) 1115 { 1116 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1117 NotificationRequest notificationRequest(reminderRequestChild->GetNotificationId()); 1118 ASSERT_NE(nullptr, reminderRequestChild); 1119 reminderRequestChild->AddActionButtons(notificationRequest, true); 1120 reminderRequestChild->AddActionButtons(notificationRequest, false); 1121 } 1122 1123 /** 1124 * @tc.name: InitUserId_00001 1125 * @tc.desc: Test InitUserId parameters. 1126 * @tc.type: FUNC 1127 * @tc.require: issueI65R21 1128 */ 1129 HWTEST_F(ReminderRequestTest, InitUserId_00001, Function | SmallTest | Level1) 1130 { 1131 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1132 ASSERT_NE(nullptr, reminderRequestChild); 1133 bool deSet = true; 1134 uint8_t newState = 2; 1135 std::string function = "this is function"; 1136 int32_t userId = 1; 1137 int32_t uid = 2; 1138 reminderRequestChild->InitUserId(userId); 1139 reminderRequestChild->InitUid(uid); 1140 reminderRequestChild->SetState(deSet, newState, function); 1141 uint8_t result1 = reminderRequestChild->GetState(); 1142 EXPECT_EQ(result1, 2); 1143 bool result = reminderRequestChild->IsShowing(); 1144 EXPECT_EQ(result, false); 1145 reminderRequestChild->OnShow(true, true, true); 1146 reminderRequestChild->OnShowFail(); 1147 } 1148 1149 /** 1150 * @tc.name: OnStart_00001 1151 * @tc.desc: Test OnStart parameters. 1152 * @tc.type: FUNC 1153 * @tc.require: issueI65R21 1154 */ 1155 HWTEST_F(ReminderRequestTest, OnStart_00001, Function | SmallTest | Level1) 1156 { 1157 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1158 ASSERT_NE(nullptr, reminderRequestChild); 1159 reminderRequestChild->OnStart(); 1160 reminderRequestChild->OnStop(); 1161 bool deSet = true; 1162 uint8_t newState = 2; 1163 std::string function = "this is function"; 1164 int32_t userId = 1; 1165 int32_t uid = 2; 1166 reminderRequestChild->InitUserId(userId); 1167 reminderRequestChild->InitUid(uid); 1168 reminderRequestChild->SetState(deSet, newState, function); 1169 reminderRequestChild->OnStart(); 1170 reminderRequestChild->OnStop(); 1171 } 1172 1173 /** 1174 * @tc.name: RecoverWantAgent_00002 1175 * @tc.desc: Test RecoverWantAgent parameters. 1176 * @tc.type: FUNC 1177 * @tc.require: issueI65R21 1178 */ 1179 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00002, Function | SmallTest | Level1) 1180 { 1181 auto rrc = std::make_shared<ReminderRequestChild>(); 1182 std::string source = "source"; 1183 std::string split = "split"; 1184 std::vector<std::string> ret = rrc->StringSplit(source, split); 1185 EXPECT_EQ(ret.size(), 1); 1186 } 1187 1188 /** 1189 * @tc.name: GetActionButtons_00002 1190 * @tc.desc: Test GetActionButtons parameters. 1191 * @tc.type: FUNC 1192 * @tc.require: issueI65R21 1193 */ 1194 HWTEST_F(ReminderRequestTest, GetActionButtons_00002, Function | SmallTest | Level1) 1195 { 1196 auto rrc = std::make_shared<ReminderRequestChild>(); 1197 std::map<ReminderRequest::ActionButtonType, ReminderRequest::ActionButtonInfo> ret = 1198 rrc->GetActionButtons(); 1199 EXPECT_EQ(ret.size(), 0); 1200 } 1201 1202 /** 1203 * @tc.name: UpdateNotificationContent_00002 1204 * @tc.desc: Test UpdateNotificationContent parameters. 1205 * @tc.type: FUNC 1206 * @tc.require: issueI65R21 1207 */ 1208 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00002, Function | SmallTest | Level1) 1209 { 1210 auto rrc = std::make_shared<ReminderRequestChild>(); 1211 rrc->SetNotificationId(100); 1212 NotificationRequest notification(rrc->GetNotificationId()); 1213 1214 rrc->UpdateNotificationContent(notification, true); 1215 rrc->UpdateNotificationContent(notification, false); 1216 1217 Notification::ReminderRequest::TimeTransferType type = Notification::ReminderRequest::TimeTransferType::WEEK; 1218 int32_t actualTime = 1; 1219 int32_t result = rrc->GetCTime(type, actualTime); 1220 EXPECT_EQ(result, 1); 1221 } 1222 1223 /** 1224 * @tc.name: CreateWantAgent_00001 1225 * @tc.desc: Test CreateWantAgent parameters. 1226 * @tc.type: FUNC 1227 * @tc.require: issueI5VB6V 1228 */ 1229 HWTEST_F(ReminderRequestTest, CreateWantAgent_00001, Function | SmallTest | Level1) 1230 { 1231 AppExecFwk::ElementName element("", "com.example.myapplication", "EntryAbility"); 1232 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1233 ASSERT_NE(nullptr, reminderRequestChild); 1234 std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> WantAgent = 1235 reminderRequestChild->CreateMaxWantAgent(element); 1236 EXPECT_EQ(WantAgent, nullptr); 1237 } 1238 1239 /** 1240 * @tc.name: CreateWantAgent_00002 1241 * @tc.desc: Test CreateWantAgent parameters. 1242 * @tc.type: FUNC 1243 * @tc.require: issueI86QW2 1244 */ 1245 HWTEST_F(ReminderRequestTest, CreateWantAgent_00002, Function | SmallTest | Level1) 1246 { 1247 AppExecFwk::ElementName element("", "com.example.myapplication", "EntryAbility"); 1248 std::shared_ptr<ReminderRequestChild> reminderRequestChild = std::make_shared<ReminderRequestChild>(); 1249 ASSERT_NE(nullptr, reminderRequestChild); 1250 std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> WantAgent = 1251 reminderRequestChild->CreateWantAgent(element); 1252 EXPECT_EQ(WantAgent, nullptr); 1253 } 1254 1255 /** 1256 * @tc.name: OnClose_00100 1257 * @tc.desc: Test OnClose parameters. 1258 * @tc.type: FUNC 1259 * @tc.require: issueI5QVYA 1260 */ 1261 HWTEST_F(ReminderRequestTest, OnClose_00100, Function | SmallTest | Level1) 1262 { 1263 auto rrc = std::make_shared<ReminderRequestChild>(); 1264 bool deSet = true; 1265 uint8_t newState = 4; 1266 std::string function = "this is function"; 1267 rrc->SetState(deSet, newState, function); 1268 uint8_t result1 = rrc->GetState(); 1269 EXPECT_EQ(result1, 4); 1270 rrc->OnClose(true); 1271 } 1272 1273 /** 1274 * @tc.name: OnClose_00200 1275 * @tc.desc: Test OnClose parameters. 1276 * @tc.type: FUNC 1277 * @tc.require: issueI5QVYA 1278 */ 1279 HWTEST_F(ReminderRequestTest, OnClose_00200, Function | SmallTest | Level1) 1280 { 1281 auto rrc = std::make_shared<ReminderRequestChild>(); 1282 bool deSet = true; 1283 uint8_t newState = 2; 1284 std::string function = "this is function"; 1285 rrc->SetState(deSet, newState, function); 1286 uint8_t result1 = rrc->GetState(); 1287 EXPECT_EQ(result1, 2); 1288 rrc->OnClose(true); 1289 } 1290 1291 /** 1292 * @tc.name: OnShow_00100 1293 * @tc.desc: Test OnShow parameters. 1294 * @tc.type: FUNC 1295 * @tc.require: issueI5QVYA 1296 */ 1297 HWTEST_F(ReminderRequestTest, OnShow_00100, Function | SmallTest | Level1) 1298 { 1299 auto rrc = std::make_shared<ReminderRequestChild>(); 1300 bool deSet = true; 1301 uint8_t newState = 9; 1302 std::string function = "this is function"; 1303 rrc->SetState(deSet, newState, function); 1304 uint8_t result1 = rrc->GetState(); 1305 EXPECT_EQ(result1, 9); 1306 rrc->OnShow(true, true, true); 1307 } 1308 1309 /** 1310 * @tc.name: OnStart_00002 1311 * @tc.desc: Test OnStart parameters. 1312 * @tc.type: FUNC 1313 * @tc.require: issueI65R21 1314 */ 1315 HWTEST_F(ReminderRequestTest, OnStart_00002, Function | SmallTest | Level1) 1316 { 1317 auto rrc = std::make_shared<ReminderRequestChild>(); 1318 bool deSet = true; 1319 uint8_t newState = 1; 1320 std::string function = "this is function"; 1321 rrc->SetState(deSet, newState, function); 1322 uint8_t result1 = rrc->GetState(); 1323 EXPECT_EQ(result1, 1); 1324 rrc->OnStart(); 1325 } 1326 1327 /** 1328 * @tc.name: OnStart_00003 1329 * @tc.desc: Test OnStart parameters. 1330 * @tc.type: FUNC 1331 * @tc.require: issueI65R21 1332 */ 1333 HWTEST_F(ReminderRequestTest, OnStart_00003, Function | SmallTest | Level1) 1334 { 1335 auto rrc = std::make_shared<ReminderRequestChild>(); 1336 bool deSet = true; 1337 uint8_t newState = 2; 1338 std::string function = "this is function"; 1339 rrc->SetState(deSet, newState, function); 1340 uint8_t result1 = rrc->GetState(); 1341 EXPECT_EQ(result1, 2); 1342 rrc->SetExpired(true); 1343 rrc->OnStart(); 1344 } 1345 1346 /** 1347 * @tc.name: StringSplit_00003 1348 * @tc.desc: Test StringSplit parameters. 1349 * @tc.type: FUNC 1350 * @tc.require: issueI65R21 1351 */ 1352 HWTEST_F(ReminderRequestTest, StringSplit_00003, Function | SmallTest | Level1) 1353 { 1354 auto rrc = std::make_shared<ReminderRequestChild>(); 1355 std::string source1 = "source1"; 1356 std::string split = "c"; 1357 std::vector<std::string> ret1 = rrc->StringSplit(source1, split); 1358 EXPECT_EQ(ret1.size(), 2); 1359 } 1360 1361 /** 1362 * @tc.name: RecoverWantAgent_00003 1363 * @tc.desc: Test RecoverWantAgent parameters. 1364 * @tc.type: FUNC 1365 * @tc.require: issueI65R21 1366 */ 1367 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00003, Function | SmallTest | Level1) 1368 { 1369 auto rrc = std::make_shared<ReminderRequestChild>(); 1370 std::string wantAgentInfo = "sour<SEP#/>123"; 1371 uint8_t type = 0; 1372 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1373 EXPECT_EQ(ret1.size(), 2); 1374 rrc->DeserializeWantAgent(wantAgentInfo, type); 1375 } 1376 1377 /** 1378 * @tc.name: RecoverWantAgent_00004 1379 * @tc.desc: Test RecoverWantAgent parameters. 1380 * @tc.type: FUNC 1381 * @tc.require: issueI65R21 1382 */ 1383 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00004, Function | SmallTest | Level1) 1384 { 1385 auto rrc = std::make_shared<ReminderRequestChild>(); 1386 std::string wantAgentInfo = "sour<SEP#/>123"; 1387 uint8_t type = 1; 1388 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1389 EXPECT_EQ(ret1.size(), 2); 1390 rrc->DeserializeWantAgent(wantAgentInfo, type); 1391 } 1392 1393 /** 1394 * @tc.name: RecoverWantAgent_00005 1395 * @tc.desc: Test RecoverWantAgent parameters. 1396 * @tc.type: FUNC 1397 * @tc.require: issueI65R21 1398 */ 1399 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00005, Function | SmallTest | Level1) 1400 { 1401 auto rrc = std::make_shared<ReminderRequestChild>(); 1402 std::string wantAgentInfo = "sour<SEP#/>123"; 1403 uint8_t type = 2; 1404 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1405 EXPECT_EQ(ret1.size(), 2); 1406 rrc->DeserializeWantAgent(wantAgentInfo, type); 1407 } 1408 1409 /** 1410 * @tc.name: RecoverWantAgent_00006 1411 * @tc.desc: Test RecoverWantAgent parameters. 1412 * @tc.type: FUNC 1413 * @tc.require: issueI86QW2 1414 */ 1415 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00006, Function | SmallTest | Level1) 1416 { 1417 auto rrc = std::make_shared<ReminderRequestChild>(); 1418 std::string wantAgentInfo = "sour<SEP#/>123<SEP#/>uri"; 1419 uint8_t type = 0; 1420 std::vector<std::string> ret1 = rrc->StringSplit(wantAgentInfo, "<SEP#/>"); 1421 EXPECT_EQ(ret1.size(), 3); 1422 rrc->DeserializeWantAgent(wantAgentInfo, type); 1423 } 1424 1425 /** 1426 * @tc.name: UpdateActionButtons_00001 1427 * @tc.desc: Test UpdateActionButtons parameters. 1428 * @tc.type: FUNC 1429 * @tc.require: issueI5VB6V 1430 */ 1431 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00001, Function | SmallTest | Level1) 1432 { 1433 auto rrc = std::make_shared<ReminderRequestChild>(); 1434 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1435 bool setSnooze = true; 1436 rrc->SetSnoozeTimes(1); 1437 EXPECT_EQ(rrc->GetSnoozeTimes(), 1); 1438 rrc->SetSnoozeTimesDynamic(1); 1439 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1440 rrc->UpdateActionButtons(notificationRequest, setSnooze); 1441 } 1442 1443 /** 1444 * @tc.name: UpdateActionButtons_00002 1445 * @tc.desc: Test UpdateActionButtons parameters. 1446 * @tc.type: FUNC 1447 * @tc.require: issueI5VB6V 1448 */ 1449 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00002, Function | SmallTest | Level1) 1450 { 1451 auto rrc = std::make_shared<ReminderRequestChild>(); 1452 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1453 bool setSnooze = true; 1454 rrc->SetSnoozeTimes(0); 1455 EXPECT_EQ(rrc->GetSnoozeTimes(), 0); 1456 rrc->SetSnoozeTimesDynamic(1); 1457 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1458 rrc->UpdateActionButtons(notificationRequest, setSnooze); 1459 } 1460 1461 /** 1462 * @tc.name: UpdateActionButtons_00003 1463 * @tc.desc: Test UpdateActionButtons parameters. 1464 * @tc.type: FUNC 1465 * @tc.require: issueI5VB6V 1466 */ 1467 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00003, Function | SmallTest | Level1) 1468 { 1469 auto rrc = std::make_shared<ReminderRequestChild>(); 1470 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1471 bool setSnooze = false; 1472 rrc->SetSnoozeTimes(1); 1473 EXPECT_EQ(rrc->GetSnoozeTimes(), 1); 1474 rrc->SetSnoozeTimesDynamic(1); 1475 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1476 rrc->UpdateActionButtons(notificationRequest, setSnooze); 1477 } 1478 1479 /** 1480 * @tc.name: UpdateActionButtons_00004 1481 * @tc.desc: Test UpdateActionButtons parameters. 1482 * @tc.type: FUNC 1483 * @tc.require: issueI5VB6V 1484 */ 1485 HWTEST_F(ReminderRequestTest, UpdateActionButtons_00004, Function | SmallTest | Level1) 1486 { 1487 auto rrc = std::make_shared<ReminderRequestChild>(); 1488 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1489 bool setSnooze = true; 1490 rrc->SetSnoozeTimes(1); 1491 EXPECT_EQ(rrc->GetSnoozeTimes(), 1); 1492 rrc->SetSnoozeTimesDynamic(0); 1493 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 0); 1494 rrc->UpdateActionButtons(notificationRequest, setSnooze); 1495 } 1496 1497 /** 1498 * @tc.name: UpdateNotificationContent_00300 1499 * @tc.desc: Test UpdateNotificationContent parameters. 1500 * @tc.type: FUNC 1501 * @tc.require: AR000GNF1T 1502 */ 1503 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00300, Function | SmallTest | Level1) 1504 { 1505 auto rrc = std::make_shared<ReminderRequestChild>(); 1506 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1507 uint32_t minTimeIntervalInSecond = ReminderRequest::MIN_TIME_INTERVAL_IN_MILLI / ReminderRequest::MILLI_SECONDS; 1508 rrc->SetTimeInterval(1); 1509 EXPECT_EQ(rrc->GetTimeInterval(), minTimeIntervalInSecond); 1510 1511 bool setSnooze = true; 1512 rrc->UpdateNotificationContent(notificationRequest, setSnooze); 1513 } 1514 1515 1516 /** 1517 * @tc.name: UpdateNotificationContent_00400 1518 * @tc.desc: Test UpdateNotificationContent parameters. 1519 * @tc.type: FUNC 1520 * @tc.require: AR000GNF1T 1521 */ 1522 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00400, Function | SmallTest | Level1) 1523 { 1524 auto rrc = std::make_shared<ReminderRequestChild>(); 1525 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1526 1527 bool deSet = true; 1528 uint8_t newState = 2; 1529 std::string function = "this is function"; 1530 rrc->SetState(deSet, newState, function); 1531 uint8_t result1 = rrc->GetState(); 1532 EXPECT_EQ(result1, 2); 1533 EXPECT_EQ(rrc->IsAlerting(), true); 1534 bool setSnooze = false; 1535 rrc->UpdateNotificationContent(notificationRequest, setSnooze); 1536 } 1537 1538 /** 1539 * @tc.name: UpdateNotificationContent_00600 1540 * @tc.desc: Test UpdateNotificationContent extend content when snooze. 1541 * @tc.type: FUNC 1542 * @tc.require: issueI87A02 1543 */ 1544 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00600, Function | SmallTest | Level1) 1545 { 1546 // given 1547 auto rrc = std::make_shared<ReminderRequestChild>(); 1548 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1549 rrc->snoozeContent_ = "snooze"; 1550 rrc->content_ = "content"; 1551 rrc->expiredContent_ = "expiredContent"; 1552 rrc->timeIntervalInMilli_ = 1; 1553 1554 // when 1555 bool setSnooze = true; 1556 rrc->UpdateNotificationContent(notificationRequest, setSnooze); 1557 1558 // then 1559 EXPECT_EQ(rrc->displayContent_, "snooze"); 1560 } 1561 1562 /** 1563 * @tc.name: UpdateNotificationContent_00800 1564 * @tc.desc: Test UpdateNotificationContent extend content when expiredContent. 1565 * @tc.type: FUNC 1566 * @tc.require: issueI87A02 1567 */ 1568 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00800, Function | SmallTest | Level1) 1569 { 1570 // given 1571 auto rrc = std::make_shared<ReminderRequestChild>(); 1572 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1573 rrc->snoozeContent_ = "snooze"; 1574 rrc->content_ = "content"; 1575 rrc->expiredContent_ = "expiredContent"; 1576 rrc->timeIntervalInMilli_ = 0; 1577 1578 // when 1579 bool setSnooze = true; 1580 rrc->UpdateNotificationContent(notificationRequest, setSnooze); 1581 1582 // then 1583 EXPECT_EQ(rrc->displayContent_, "expiredContent"); 1584 } 1585 1586 /** 1587 * @tc.name: UpdateNotificationContent_00500 1588 * @tc.desc: Test UpdateNotificationContent parameters. 1589 * @tc.type: FUNC 1590 * @tc.require: AR000GNF1T 1591 */ 1592 HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00500, Function | SmallTest | Level1) 1593 { 1594 auto rrc = std::make_shared<ReminderRequestChild>(); 1595 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1596 1597 bool deSet = false; 1598 uint8_t newState = 0; 1599 std::string function = "this is function"; 1600 rrc->SetState(deSet, newState, function); 1601 uint8_t result1 = rrc->GetState(); 1602 EXPECT_EQ(result1, 0); 1603 EXPECT_EQ(rrc->IsAlerting(), false); 1604 1605 rrc->SetSnoozeTimes(0); 1606 EXPECT_EQ(rrc->GetSnoozeTimes(), 0); 1607 rrc->SetSnoozeTimesDynamic(1); 1608 EXPECT_EQ(rrc->GetSnoozeTimesDynamic(), 1); 1609 1610 bool setSnooze = false; 1611 rrc->UpdateNotificationContent(notificationRequest, setSnooze); 1612 } 1613 1614 /** 1615 * @tc.name: GetCTime_00001 1616 * @tc.desc: Test GetCTime parameters. 1617 * @tc.type: FUNC 1618 * @tc.require: issueI65R21 1619 */ 1620 HWTEST_F(ReminderRequestTest, GetCTime_00001, Function | SmallTest | Level1) 1621 { 1622 auto rrc = std::make_shared<ReminderRequestChild>(); 1623 Notification::ReminderRequest::TimeTransferType type = Notification::ReminderRequest::TimeTransferType(3); 1624 int32_t actualTime = 1; 1625 int32_t result = rrc->GetCTime(type, actualTime); 1626 int32_t ret = -1; 1627 EXPECT_EQ(result, ret); 1628 } 1629 1630 /** 1631 * @tc.name: GetActualTime_00001 1632 * @tc.desc: Test GetActualTime parameters. 1633 * @tc.type: FUNC 1634 * @tc.require: issueI65R21 1635 */ 1636 HWTEST_F(ReminderRequestTest, GetActualTime_00001, Function | SmallTest | Level1) 1637 { 1638 auto rrc = std::make_shared<ReminderRequestChild>(); 1639 Notification::ReminderRequest::TimeTransferType type = Notification::ReminderRequest::TimeTransferType(3); 1640 int32_t actualTime = 1; 1641 int32_t result = rrc->GetActualTime(type, actualTime); 1642 int32_t ret = -1; 1643 EXPECT_EQ(result, ret); 1644 } 1645 1646 /** 1647 * @tc.name: SetSystemApp_00001 1648 * @tc.desc: Test SetSystemApp parameters. 1649 * @tc.type: FUNC 1650 * @tc.require: issueI6NQPJ 1651 */ 1652 HWTEST_F(ReminderRequestTest, SetSystemApp_00001, Function | SmallTest | Level1) 1653 { 1654 auto rrc = std::make_shared<ReminderRequestChild>(); 1655 rrc->SetSystemApp(true); 1656 bool result = rrc->IsSystemApp(); 1657 bool ret = true; 1658 EXPECT_EQ(result, ret); 1659 } 1660 1661 /** 1662 * @tc.name: SetTapDismissed_00001 1663 * @tc.desc: Test SetTapDismissed parameters. 1664 * @tc.type: FUNC 1665 * @tc.require: issueI6NQPJ 1666 */ 1667 HWTEST_F(ReminderRequestTest, SetTapDismissed_00001, Function | SmallTest | Level1) 1668 { 1669 auto rrc = std::make_shared<ReminderRequestChild>(); 1670 rrc->SetTapDismissed(true); 1671 bool result = rrc->IsTapDismissed(); 1672 bool ret = true; 1673 EXPECT_EQ(result, ret); 1674 } 1675 1676 /** 1677 * @tc.name: SetAutoDeletedTime_00001 1678 * @tc.desc: Test SetAutoDeletedTime parameters. 1679 * @tc.type: FUNC 1680 * @tc.require: issueI6NQPJ 1681 */ 1682 HWTEST_F(ReminderRequestTest, SetAutoDeletedTime_00001, Function | SmallTest | Level1) 1683 { 1684 auto rrc = std::make_shared<ReminderRequestChild>(); 1685 rrc->SetAutoDeletedTime(1); 1686 int32_t result = rrc->GetAutoDeletedTime(); 1687 int32_t ret = 1; 1688 EXPECT_EQ(result, ret); 1689 } 1690 1691 /** 1692 * @tc.name: SetCustomButtonUri_00001 1693 * @tc.desc: Test SetCustomButtonUri parameters. 1694 * @tc.type: FUNC 1695 * @tc.require: issueI6NQPJ 1696 */ 1697 HWTEST_F(ReminderRequestTest, SetCustomButtonUri_00001, Function | SmallTest | Level1) 1698 { 1699 auto rrc = std::make_shared<ReminderRequestChild>(); 1700 rrc->SetCustomButtonUri("test"); 1701 std::string result = rrc->GetCustomButtonUri(); 1702 std::string ret = "test"; 1703 EXPECT_EQ(result, ret); 1704 } 1705 1706 /** 1707 * @tc.name: SetGroupId_00001 1708 * @tc.desc: Test SetGroupId parameters. 1709 * @tc.type: FUNC 1710 * @tc.require: issueI8CDH3 1711 */ 1712 HWTEST_F(ReminderRequestTest, SetGroupId_00001, Function | SmallTest | Level1) 1713 { 1714 auto rrc = std::make_shared<ReminderRequestChild>(); 1715 std::string groupId = "123"; 1716 rrc->SetGroupId(groupId); 1717 EXPECT_EQ(rrc->GetGroupId(), groupId); 1718 } 1719 1720 /** 1721 * @tc.name: InitBundleName_00001 1722 * @tc.desc: Test InitBundleName with normal parameters. 1723 * @tc.type: FUNC 1724 * @tc.require: issueI89858 1725 */ 1726 HWTEST_F(ReminderRequestTest, InitBundleName_00001, Function | SmallTest | Level1) 1727 { 1728 auto rrc = std::make_shared<ReminderRequestChild>(); 1729 std::string bundleName = "com.example.myapplication"; 1730 rrc->InitBundleName(bundleName); 1731 EXPECT_EQ(rrc->GetBundleName(), bundleName); 1732 } 1733 1734 /** 1735 * @tc.name: InitBundleName_00002 1736 * @tc.desc: Test InitBundleName with special parameters. 1737 * @tc.type: FUNC 1738 * @tc.require: issueI89858 1739 */ 1740 HWTEST_F(ReminderRequestTest, InitBundleName_00002, Function | SmallTest | Level1) 1741 { 1742 auto rrc = std::make_shared<ReminderRequestChild>(); 1743 std::string bundleName = "com.example.myapplication.~!@#$%^&*()"; 1744 rrc->InitBundleName(bundleName); 1745 EXPECT_EQ(rrc->GetBundleName(), bundleName); 1746 } 1747 1748 /** 1749 * @tc.name: UpdateNotificationCommon_00100 1750 * @tc.desc: Test UpdateNotificationCommon when snooze is true. 1751 * @tc.type: FUNC 1752 * @tc.require: issueII8F9EZ 1753 */ 1754 HWTEST_F(ReminderRequestTest, UpdateNotificationCommon_00100, Function | SmallTest | Level1) 1755 { 1756 // given 1757 auto rrc = std::make_shared<ReminderRequestChild>(); 1758 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1759 rrc->snoozeSlotType_ = NotificationConstant::SlotType::OTHER; 1760 bool isSnooze = true; 1761 1762 // when 1763 rrc->UpdateNotificationCommon(notificationRequest, isSnooze); 1764 1765 // then 1766 EXPECT_EQ(notificationRequest.GetSlotType(), NotificationConstant::SlotType::CONTENT_INFORMATION); 1767 } 1768 1769 /** 1770 * @tc.name: UpdateNotificationCommon_00200 1771 * @tc.desc: Test UpdateNotificationCommon when snooze is true. 1772 * @tc.type: FUNC 1773 * @tc.require: issueII8F9EZ 1774 */ 1775 HWTEST_F(ReminderRequestTest, UpdateNotificationCommon_00200, Function | SmallTest | Level1) 1776 { 1777 // given 1778 auto rrc = std::make_shared<ReminderRequestChild>(); 1779 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1780 rrc->snoozeSlotType_ = NotificationConstant::SlotType::SERVICE_REMINDER; 1781 bool isSnooze = true; 1782 1783 // when 1784 rrc->UpdateNotificationCommon(notificationRequest, isSnooze); 1785 1786 // then 1787 EXPECT_EQ(notificationRequest.GetSlotType(), NotificationConstant::SlotType::SERVICE_REMINDER); 1788 } 1789 1790 /** 1791 * @tc.name: UpdateNotificationCommon_00300 1792 * @tc.desc: Test UpdateNotificationCommon when snooze is false. 1793 * @tc.type: FUNC 1794 * @tc.require: issueII8F9EZ 1795 */ 1796 HWTEST_F(ReminderRequestTest, UpdateNotificationCommon_00300, Function | SmallTest | Level1) 1797 { 1798 // given 1799 auto rrc = std::make_shared<ReminderRequestChild>(); 1800 1801 NotificationRequest notificationRequest(rrc->GetNotificationId()); 1802 rrc->snoozeSlotType_ = NotificationConstant::SlotType::SERVICE_REMINDER; 1803 rrc->slotType_ = NotificationConstant::SlotType::SOCIAL_COMMUNICATION; 1804 bool isSnooze = false; 1805 1806 // when 1807 rrc->UpdateNotificationCommon(notificationRequest, isSnooze); 1808 1809 // then 1810 EXPECT_EQ(notificationRequest.GetSlotType(), NotificationConstant::SlotType::SOCIAL_COMMUNICATION); 1811 } 1812 1813 /** 1814 * @tc.name: InitCreatorBundleName_00001 1815 * @tc.desc: Test InitCreatorBundleName with normal parameters. 1816 * @tc.type: FUNC 1817 * @tc.require: issue#I8R55M 1818 */ 1819 HWTEST_F(ReminderRequestTest, InitCreatorBundleName_00001, Function | SmallTest | Level1) 1820 { 1821 auto rrc = std::make_shared<ReminderRequestChild>(); 1822 std::string bundleName = "com.example.myapplication"; 1823 rrc->InitCreatorBundleName(bundleName); 1824 EXPECT_EQ(rrc->GetCreatorBundleName(), bundleName); 1825 } 1826 1827 /** 1828 * @tc.name: InitCreatorBundleName_00002 1829 * @tc.desc: Test InitCreatorBundleName with special parameters. 1830 * @tc.type: FUNC 1831 * @tc.require: issue#I8R55M 1832 */ 1833 HWTEST_F(ReminderRequestTest, InitCreatorBundleName_00002, Function | SmallTest | Level1) 1834 { 1835 auto rrc = std::make_shared<ReminderRequestChild>(); 1836 std::string bundleName = "com.example.myapplication.~!@#$%^&*()"; 1837 rrc->InitCreatorBundleName(bundleName); 1838 EXPECT_EQ(rrc->GetCreatorBundleName(), bundleName); 1839 } 1840 1841 /** 1842 * @tc.name: RecoverWantAgentByJson_00001 1843 * @tc.desc: Test invalid parameters. 1844 * @tc.type: FUNC 1845 * @tc.require: issue#I94VJT 1846 */ 1847 HWTEST_F(ReminderRequestTest, RecoverWantAgentByJson_00001, Function | SmallTest | Level1) 1848 { 1849 auto rrc = std::make_shared<ReminderRequestChild>(); 1850 std::string jsonValue = ""; 1851 rrc->RecoverWantAgentByJson(jsonValue, 0); 1852 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, ""); 1853 1854 jsonValue = "{}"; 1855 rrc->RecoverWantAgentByJson(jsonValue, 0); 1856 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, ""); 1857 1858 jsonValue = R"({"pkgName":1})"; 1859 rrc->RecoverWantAgentByJson(jsonValue, 0); 1860 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, ""); 1861 1862 jsonValue = R"({"pkgName":"com.example.myapplication"})"; 1863 rrc->RecoverWantAgentByJson(jsonValue, 0); 1864 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, ""); 1865 1866 jsonValue = R"({"pkgName":"com.example.myapplication","abilityName":1})"; 1867 rrc->RecoverWantAgentByJson(jsonValue, 0); 1868 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, ""); 1869 1870 jsonValue = R"({"pkgName":"com.example.myapplication","abilityName":"MainAbility"})"; 1871 rrc->RecoverWantAgentByJson(jsonValue, 0); 1872 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, "MainAbility"); 1873 1874 jsonValue = R"({"pkgName":"com.example.myapplication","abilityName":"MainAbility","uri":1})"; 1875 rrc->RecoverWantAgentByJson(jsonValue, 0); 1876 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, "MainAbility"); 1877 1878 jsonValue = R"({"pkgName":"com.example.myapplication","abilityName":"MainAbility","uri":""})"; 1879 rrc->RecoverWantAgentByJson(jsonValue, 0); 1880 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, "MainAbility"); 1881 1882 jsonValue = R"({"pkgName":"com.example.myapplication","abilityName":"MainAbility","uri":"","parameters":1})"; 1883 rrc->RecoverWantAgentByJson(jsonValue, 0); 1884 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, "MainAbility"); 1885 1886 jsonValue = R"({"pkgName":"com.example.myapplication","abilityName":"MainAbility","uri":"","parameters":""})"; 1887 rrc->RecoverWantAgentByJson(jsonValue, 0); 1888 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, "MainAbility"); 1889 1890 jsonValue = R"({"pkgName":"com.example.myapplication","abilityName":"MainAbility","uri":"","parameters":""})"; 1891 rrc->RecoverWantAgentByJson(jsonValue, 1); 1892 EXPECT_EQ(rrc->GetMaxScreenWantAgentInfo()->abilityName, "MainAbility"); 1893 1894 jsonValue = R"({"pkgName":"com.example.myapplication","abilityName":"MainAbility","uri":"","parameters":""})"; 1895 rrc->RecoverWantAgentByJson(jsonValue, 2); 1896 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, "MainAbility"); 1897 1898 jsonValue = "awefasdfawefasdfaswe"; 1899 rrc->RecoverWantAgentByJson(jsonValue, 0); 1900 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, "MainAbility"); 1901 } 1902 1903 /** 1904 * @tc.name: RecoverWantAgent_00007 1905 * @tc.desc: Test RecoverWantAgent parameters. 1906 * @tc.type: FUNC 1907 * @tc.require: issue#I94VJT 1908 */ 1909 HWTEST_F(ReminderRequestTest, RecoverWantAgent_00007, Function | SmallTest | Level1) 1910 { 1911 auto rrc = std::make_shared<ReminderRequestChild>(); 1912 std::string jsonValue = ""; 1913 rrc->DeserializeWantAgent(jsonValue, 0); 1914 EXPECT_EQ(rrc->GetWantAgentInfo()->abilityName, ""); 1915 1916 jsonValue = R"({"pkgName":"com.example.myapplication","abilityName":"MainAbility","uri":"","parameters":""})"; 1917 rrc->DeserializeWantAgent(jsonValue, 1); 1918 EXPECT_EQ(rrc->GetMaxScreenWantAgentInfo()->abilityName, "MainAbility"); 1919 1920 jsonValue = R"(})"; 1921 rrc->DeserializeWantAgent(jsonValue, 1); 1922 EXPECT_EQ(rrc->GetMaxScreenWantAgentInfo()->abilityName, "MainAbility"); 1923 1924 jsonValue = R"({})"; 1925 rrc->DeserializeWantAgent(jsonValue, 1); 1926 EXPECT_EQ(rrc->GetMaxScreenWantAgentInfo()->abilityName, ""); 1927 1928 jsonValue = "fawexcdvasdfwessdf"; 1929 rrc->DeserializeWantAgent(jsonValue, 1); 1930 EXPECT_EQ(rrc->GetMaxScreenWantAgentInfo()->abilityName, ""); 1931 } 1932 1933 /** 1934 * @tc.name: MarshallingWantParameters_00001 1935 * @tc.desc: Test MarshallingWantParameters parameters. 1936 * @tc.type: FUNC 1937 * @tc.require: issue#I94VJT 1938 */ 1939 HWTEST_F(ReminderRequestTest, MarshallingWantParameters_00001, Function | SmallTest | Level1) 1940 { 1941 auto rrc = std::make_shared<ReminderRequestChild>(); 1942 AAFwk::WantParams params1; 1943 Parcel p1; 1944 bool ret = rrc->MarshallingWantParameters(p1, params1); 1945 EXPECT_EQ(ret, true); 1946 1947 std::string key = "key"; 1948 std::string value = "value"; 1949 params1.SetParam(key, AAFwk::String::Box(value)); 1950 Parcel p2; 1951 ret = rrc->MarshallingWantParameters(p2, params1); 1952 EXPECT_EQ(ret, true); 1953 1954 AAFwk::WantParams params2; 1955 ret = rrc->ReadWantParametersFromParcel(p1, params2); 1956 EXPECT_EQ(ret, true); 1957 1958 ret = rrc->ReadWantParametersFromParcel(p2, params2); 1959 EXPECT_EQ(ret, true); 1960 EXPECT_EQ(params2.GetStringParam(key), value); 1961 } 1962 1963 /** 1964 * @tc.name: WantAgentStr_00001 1965 * @tc.desc: Test want agent str parameters. 1966 * @tc.type: FUNC 1967 * @tc.require: issue#I94VJT 1968 */ 1969 HWTEST_F(ReminderRequestTest, WantAgentStr_00001, Function | SmallTest | Level1) 1970 { 1971 sptr<ReminderRequestChild> rrc = new ReminderRequestChild; 1972 rrc->wantAgentStr_ = "test"; 1973 rrc->maxWantAgentStr_ = "test_max"; 1974 EXPECT_EQ(rrc->GetWantAgentStr(), "test"); 1975 EXPECT_EQ(rrc->GetMaxWantAgentStr(), "test_max"); 1976 } 1977 1978 /** 1979 * @tc.name: RecoverActionButtonJsonMode_00001 1980 * @tc.desc: Test action button json string. 1981 * @tc.type: FUNC 1982 * @tc.require: issue#I94VJT 1983 */ 1984 HWTEST_F(ReminderRequestTest, RecoverActionButtonJsonMode_00001, Function | SmallTest | Level1) 1985 { 1986 auto rrc = std::make_shared<ReminderRequestChild>(); 1987 std::string jsonValue = ""; 1988 rrc->RecoverActionButtonJsonMode(jsonValue); 1989 EXPECT_EQ(rrc->actionButtonMap_.size(), 0); 1990 1991 // test type 1992 jsonValue = R"({})"; 1993 rrc->RecoverActionButtonJsonMode(jsonValue); 1994 EXPECT_EQ(rrc->actionButtonMap_.size(), 0); 1995 1996 jsonValue = R"({"type":1})"; 1997 rrc->RecoverActionButtonJsonMode(jsonValue); 1998 EXPECT_EQ(rrc->actionButtonMap_.size(), 0); 1999 2000 jsonValue = R"({"type":"a"})"; 2001 rrc->RecoverActionButtonJsonMode(jsonValue); 2002 EXPECT_EQ(rrc->actionButtonMap_.size(), 0); 2003 2004 jsonValue = R"({"type":"asdfwe"})"; 2005 rrc->RecoverActionButtonJsonMode(jsonValue); 2006 EXPECT_EQ(rrc->actionButtonMap_.size(), 0); 2007 2008 // test title 2009 jsonValue = R"({"type":"1"})"; 2010 rrc->RecoverActionButtonJsonMode(jsonValue); 2011 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].title, ""); 2012 2013 rrc->actionButtonMap_.clear(); 2014 jsonValue = R"({"type":"1","title":1})"; 2015 rrc->RecoverActionButtonJsonMode(jsonValue); 2016 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].title, ""); 2017 2018 rrc->actionButtonMap_.clear(); 2019 jsonValue = R"({"type":"1","title":"test"})"; 2020 rrc->RecoverActionButtonJsonMode(jsonValue); 2021 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].title, "test"); 2022 2023 // test resource 2024 rrc->actionButtonMap_.clear(); 2025 jsonValue = R"({"type":"1","title":"test"})"; 2026 rrc->RecoverActionButtonJsonMode(jsonValue); 2027 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].resource, ""); 2028 2029 rrc->actionButtonMap_.clear(); 2030 jsonValue = R"({"type":"1","title":"test","resource":1})"; 2031 rrc->RecoverActionButtonJsonMode(jsonValue); 2032 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].resource, ""); 2033 2034 rrc->actionButtonMap_.clear(); 2035 jsonValue = R"({"type":"1","title":"test","resource":"resource"})"; 2036 rrc->RecoverActionButtonJsonMode(jsonValue); 2037 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].resource, "resource"); 2038 } 2039 2040 /** 2041 * @tc.name: RecoverActionButtonJsonMode_00002 2042 * @tc.desc: Test action button json string wantAgent. 2043 * @tc.type: FUNC 2044 * @tc.require: issue#I94VJT 2045 */ 2046 HWTEST_F(ReminderRequestTest, RecoverActionButtonJsonMode_00002, Function | SmallTest | Level1) 2047 { 2048 auto rrc = std::make_shared<ReminderRequestChild>(); 2049 // test wantAgent.pkgName 2050 std::string jsonValue = R"({"type":"1","title":"test","resource":"resource"})"; 2051 rrc->RecoverActionButtonJsonMode(jsonValue); 2052 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].wantAgent->pkgName, ""); 2053 2054 rrc->actionButtonMap_.clear(); 2055 jsonValue = R"({"type":"1","title":"test","resource":"resource","wantAgent":{"pkgName":1}})"; 2056 rrc->RecoverActionButtonJsonMode(jsonValue); 2057 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].wantAgent->pkgName, ""); 2058 2059 rrc->actionButtonMap_.clear(); 2060 jsonValue = R"({"type":"1","title":"test","resource":"resource","wantAgent":{"pkgName":"pkgName"}})"; 2061 rrc->RecoverActionButtonJsonMode(jsonValue); 2062 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].wantAgent->pkgName, "pkgName"); 2063 2064 // test wantAgent.abilityName 2065 rrc->actionButtonMap_.clear(); 2066 jsonValue = R"({"type":"1","title":"test","resource":"resource","wantAgent":{"pkgName":"pkgName"}})"; 2067 rrc->RecoverActionButtonJsonMode(jsonValue); 2068 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].wantAgent->abilityName, ""); 2069 2070 rrc->actionButtonMap_.clear(); 2071 jsonValue = R"({"type":"1","title":"test","resource":"res","wantAgent":{"pkgName":"pkgName","abilityName":1}})"; 2072 rrc->RecoverActionButtonJsonMode(jsonValue); 2073 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].wantAgent->abilityName, ""); 2074 2075 rrc->actionButtonMap_.clear(); 2076 jsonValue = R"({"type":"1","title":"test","resource":"resource","wantAgent":{"abilityName":"abilityName"}})"; 2077 rrc->RecoverActionButtonJsonMode(jsonValue); 2078 EXPECT_EQ(rrc->actionButtonMap_[ReminderRequest::ActionButtonType::SNOOZE].wantAgent->abilityName, "abilityName"); 2079 } 2080 2081 /** 2082 * @tc.name: RecoverActionButtonJsonMode_00003 2083 * @tc.desc: Test action button json string dataShareUpdate. 2084 * @tc.type: FUNC 2085 * @tc.require: issue#I94VJT 2086 */ 2087 HWTEST_F(ReminderRequestTest, RecoverActionButtonJsonMode_00003, Function | SmallTest | Level1) 2088 { 2089 auto rrc = std::make_shared<ReminderRequestChild>(); 2090 constexpr auto type = ReminderRequest::ActionButtonType::SNOOZE; 2091 // test dataShareUpdate.uri 2092 std::string jsonValue = R"({"type":"1","title":"test","resource":"resource"})"; 2093 rrc->RecoverActionButtonJsonMode(jsonValue); 2094 EXPECT_EQ(rrc->actionButtonMap_[type].dataShareUpdate->uri, ""); 2095 2096 rrc->actionButtonMap_.clear(); 2097 jsonValue = R"({"type":"1","title":"test","resource":"resource","dataShareUpdate":{"uri":1}})"; 2098 rrc->RecoverActionButtonJsonMode(jsonValue); 2099 EXPECT_EQ(rrc->actionButtonMap_[type].dataShareUpdate->uri, ""); 2100 2101 rrc->actionButtonMap_.clear(); 2102 jsonValue = R"({"type":"1","title":"test","resource":"resource","dataShareUpdate":{"uri":"uri"}})"; 2103 rrc->RecoverActionButtonJsonMode(jsonValue); 2104 EXPECT_EQ(rrc->actionButtonMap_[type].dataShareUpdate->uri, "uri"); 2105 2106 // test dataShareUpdate.equalTo 2107 rrc->actionButtonMap_.clear(); 2108 jsonValue = R"({"type":"1","title":"test","resource":"resource","dataShareUpdate":{"uri":"uri"}})"; 2109 rrc->RecoverActionButtonJsonMode(jsonValue); 2110 EXPECT_EQ(rrc->actionButtonMap_[type].dataShareUpdate->equalTo, ""); 2111 2112 rrc->actionButtonMap_.clear(); 2113 jsonValue = R"({"type":"1","title":"test","resource":"resource","dataShareUpdate":{"equalTo":1}})"; 2114 rrc->RecoverActionButtonJsonMode(jsonValue); 2115 EXPECT_EQ(rrc->actionButtonMap_[type].dataShareUpdate->equalTo, ""); 2116 2117 rrc->actionButtonMap_.clear(); 2118 jsonValue = R"({"type":"1","title":"test","resource":"resource","dataShareUpdate":{"equalTo":"equalTo"}})"; 2119 rrc->RecoverActionButtonJsonMode(jsonValue); 2120 EXPECT_EQ(rrc->actionButtonMap_[type].dataShareUpdate->equalTo, "equalTo"); 2121 2122 // test dataShareUpdate.valuesBucket 2123 rrc->actionButtonMap_.clear(); 2124 jsonValue = R"({"type":"1","title":"test","resource":"resource","dataShareUpdate":{"uri":"uri"}})"; 2125 rrc->RecoverActionButtonJsonMode(jsonValue); 2126 EXPECT_EQ(rrc->actionButtonMap_[type].dataShareUpdate->valuesBucket, ""); 2127 2128 rrc->actionButtonMap_.clear(); 2129 jsonValue = R"({"type":"1","title":"test","resource":"resource","dataShareUpdate":{"valuesBucket":1}})"; 2130 rrc->RecoverActionButtonJsonMode(jsonValue); 2131 EXPECT_EQ(rrc->actionButtonMap_[type].dataShareUpdate->valuesBucket, ""); 2132 2133 rrc->actionButtonMap_.clear(); 2134 jsonValue = R"({"type":"1","title":"test","resource":"res","dataShareUpdate":{"valuesBucket":"valuesBucket"}})"; 2135 rrc->RecoverActionButtonJsonMode(jsonValue); 2136 EXPECT_EQ(rrc->actionButtonMap_[type].dataShareUpdate->valuesBucket, "valuesBucket"); 2137 } 2138 2139 /** 2140 * @tc.name: InitCreatorUid_00001 2141 * @tc.desc: Test InitCreatorUid. 2142 * @tc.type: FUNC 2143 * @tc.require: issue#I94VJT 2144 */ 2145 HWTEST_F(ReminderRequestTest, InitCreatorUid_00001, Function | SmallTest | Level1) 2146 { 2147 auto rrc = std::make_shared<ReminderRequestChild>(); 2148 rrc->InitCreatorUid(100); 2149 EXPECT_EQ(rrc->GetCreatorUid(), 100); 2150 2151 rrc->InitCreatorUid(-1); 2152 EXPECT_EQ(rrc->GetCreatorUid(), -1); 2153 } 2154 2155 /** 2156 * @tc.name: SetSnoozeSlotType_001 2157 * @tc.desc: Test SetGroupId parameters. 2158 * @tc.type: FUNC 2159 * @tc.require: issueI8CDH3 2160 */ 2161 HWTEST_F(ReminderRequestTest, SetSnoozeSlotType_001, Function | SmallTest | Level1) 2162 { 2163 auto rrc = std::make_shared<ReminderRequestChild>(); 2164 rrc->SetSnoozeSlotType(NotificationConstant::SlotType::CONTENT_INFORMATION); 2165 EXPECT_EQ(rrc->GetSnoozeSlotType(), NotificationConstant::SlotType::CONTENT_INFORMATION); 2166 rrc->SetSnoozeSlotType(NotificationConstant::SlotType::CUSTOM); 2167 EXPECT_EQ(rrc->GetSnoozeSlotType(), NotificationConstant::SlotType::CUSTOM); 2168 } 2169 2170 /** 2171 * @tc.name: SetReminderId_001 2172 * @tc.desc: Test SetReminderId parameters. 2173 * @tc.type: FUNC 2174 * @tc.require: issueI8CDH3 2175 */ 2176 HWTEST_F(ReminderRequestTest, SetReminderId_001, Function | SmallTest | Level1) 2177 { 2178 auto rrc = std::make_shared<ReminderRequestChild>(); 2179 EXPECT_EQ(rrc->GetReminderId(), -1); 2180 rrc->SetReminderId(100); 2181 EXPECT_EQ(rrc->GetReminderId(), 100); 2182 } 2183 2184 /** 2185 * @tc.name: SetReminderType_001 2186 * @tc.desc: Test SetReminderType parameters. 2187 * @tc.type: FUNC 2188 * @tc.require: issueI8CDH3 2189 */ 2190 HWTEST_F(ReminderRequestTest, SetReminderType_001, Function | SmallTest | Level1) 2191 { 2192 auto rrc = std::make_shared<ReminderRequestChild>(); 2193 EXPECT_EQ(rrc->GetReminderType(), ReminderRequest::ReminderType::INVALID); 2194 rrc->SetReminderType(ReminderRequest::ReminderType::ALARM); 2195 EXPECT_EQ(rrc->GetReminderType(), ReminderRequest::ReminderType::ALARM); 2196 } 2197 2198 /** 2199 * @tc.name: SetRepeatDaysOfWeek_001 2200 * @tc.desc: Test SetRepeatDaysOfWeek parameters. 2201 * @tc.type: FUNC 2202 * @tc.require: issueI8CDH3 2203 */ 2204 HWTEST_F(ReminderRequestTest, SetRepeatDaysOfWeek_001, Function | SmallTest | Level1) 2205 { 2206 auto rrc = std::make_shared<ReminderRequestChild>(); 2207 EXPECT_EQ(rrc->GetRepeatDaysOfWeek(), 0); 2208 rrc->SetRepeatDaysOfWeek(66); 2209 EXPECT_EQ(rrc->GetRepeatDaysOfWeek(), 66); 2210 } 2211 2212 /** 2213 * @tc.name: SetCustomRingUri_001 2214 * @tc.desc: Test SetCustomRingUri parameters. 2215 * @tc.type: FUNC 2216 * @tc.require: issueI8CDH3 2217 */ 2218 HWTEST_F(ReminderRequestTest, SetCustomRingUri_001, Function | SmallTest | Level1) 2219 { 2220 auto rrc = std::make_shared<ReminderRequestChild>(); 2221 EXPECT_EQ(rrc->GetCustomRingUri(), ""); 2222 rrc->SetCustomRingUri("test123sevxgasdr5"); 2223 EXPECT_EQ(rrc->GetCustomRingUri(), "test123sevxgasdr5"); 2224 rrc->SetCustomRingUri("@#$^%&*)(&&*^(@!#%$#$))"); 2225 EXPECT_EQ(rrc->GetCustomRingUri(), "@#$^%&*)(&&*^(@!#%$#$))"); 2226 } 2227 2228 /** 2229 * @tc.name: SetWantAgentStr_001 2230 * @tc.desc: Test SetWantAgentStr parameters. 2231 * @tc.type: FUNC 2232 * @tc.require: issueI8CDH3 2233 */ 2234 HWTEST_F(ReminderRequestTest, SetWantAgentStr_001, Function | SmallTest | Level1) 2235 { 2236 auto rrc = std::make_shared<ReminderRequestChild>(); 2237 EXPECT_EQ(rrc->GetWantAgentStr(), ""); 2238 rrc->SetWantAgentStr("test123sevxgasdr5"); 2239 EXPECT_EQ(rrc->GetWantAgentStr(), "test123sevxgasdr5"); 2240 rrc->SetWantAgentStr("@#$^%&*)(&&*^(@!#%$#$))"); 2241 EXPECT_EQ(rrc->GetWantAgentStr(), "@#$^%&*)(&&*^(@!#%$#$))"); 2242 } 2243 2244 /** 2245 * @tc.name: SetMaxWantAgentStr_001 2246 * @tc.desc: Test SetMaxWantAgentStr parameters. 2247 * @tc.type: FUNC 2248 * @tc.require: issueI8CDH3 2249 */ 2250 HWTEST_F(ReminderRequestTest, SetMaxWantAgentStr_001, Function | SmallTest | Level1) 2251 { 2252 auto rrc = std::make_shared<ReminderRequestChild>(); 2253 EXPECT_EQ(rrc->GetMaxWantAgentStr(), ""); 2254 rrc->SetMaxWantAgentStr("test123sevxgasdr5"); 2255 EXPECT_EQ(rrc->GetMaxWantAgentStr(), "test123sevxgasdr5"); 2256 rrc->SetMaxWantAgentStr("@#$^%&*)(&&*^(@!#%$#$))"); 2257 EXPECT_EQ(rrc->GetMaxWantAgentStr(), "@#$^%&*)(&&*^(@!#%$#$))"); 2258 } 2259 2260 /** 2261 * @tc.name: DeserializeButtonInfoFromJson_001 2262 * @tc.desc: Test DeserializeButtonInfoFromJson parameters. 2263 * @tc.type: FUNC 2264 * @tc.require: issueI8CDH3 2265 */ 2266 HWTEST_F(ReminderRequestTest, DeserializeButtonInfoFromJson_001, Function | SmallTest | Level1) 2267 { 2268 ReminderRequest request(1); 2269 request.DeserializeButtonInfoFromJson(""); 2270 EXPECT_EQ(request.GetActionButtons().size(), 0); 2271 request.DeserializeButtonInfoFromJson("{11"); 2272 EXPECT_EQ(request.GetActionButtons().size(), 0); 2273 request.DeserializeButtonInfoFromJson("{}"); 2274 EXPECT_EQ(request.GetActionButtons().size(), 0); 2275 request.DeserializeButtonInfoFromJson("[]"); 2276 EXPECT_EQ(request.GetActionButtons().size(), 0); 2277 request.DeserializeButtonInfoFromJson( 2278 R"([{"titleResource":"join","title":"test","type":0,"wantAgent":{"pkgName":"","abilityName":"","uri":""}}])"); 2279 EXPECT_EQ(request.GetActionButtons().size(), 1); 2280 request.DeserializeButtonInfoFromJson( 2281 R"([{"titleResource":"join","title":"test","type":2,"wantAgent":{"pkgName":"","abilityName":"","uri":""}}])"); 2282 EXPECT_EQ(request.GetActionButtons().size(), 2); 2283 } 2284 2285 /** 2286 * @tc.name: ReminderRequestTest_001 2287 * @tc.desc: Test CanShow parameters. 2288 * @tc.type: FUNC 2289 * @tc.require: issueI8CDH3 2290 */ 2291 HWTEST_F(ReminderRequestTest, ReminderRequestTest_001, Function | SmallTest | Level1) 2292 { 2293 ReminderRequestChild child; 2294 uint64_t now = child.GetNowInstantMilli(); 2295 child.reminderTimeInMilli_ = now; 2296 EXPECT_EQ(child.CanShow(), false); 2297 2298 ReminderRequest::GLOBAL_ID = -1; 2299 child.InitReminderId(); 2300 EXPECT_EQ(child.reminderId_, 1); 2301 } 2302 2303 /** 2304 * @tc.name: ReminderRequestTest_002 2305 * @tc.desc: Test DeserializeButtonInfoFromJson parameters. 2306 * @tc.type: FUNC 2307 * @tc.require: issueI8CDH3 2308 */ 2309 HWTEST_F(ReminderRequestTest, ReminderRequestTest_002, Function | SmallTest | Level1) 2310 { 2311 ReminderRequestChild child; 2312 child.DeserializeButtonInfoFromJson(""); 2313 child.DeserializeButtonInfoFromJson("{"); 2314 child.DeserializeButtonInfoFromJson("1"); 2315 child.DeserializeButtonInfoFromJson("[]"); 2316 std::string jsonValue = R"([{"type":1, "title":"111", "titleResource":""}])"; 2317 child.DeserializeButtonInfoFromJson(jsonValue); 2318 2319 jsonValue = R"([{"type":1, "title":"111", "titleResource":"", "wantAgent":""}])"; 2320 child.DeserializeButtonInfoFromJson(jsonValue); 2321 2322 jsonValue = R"([{"type":1, "title":"111", "titleResource":"", "wantAgent":{"pkgName": ""}}])"; 2323 child.DeserializeButtonInfoFromJson(jsonValue); 2324 2325 jsonValue = R"([{"type":1, "title":"111", "titleResource":"", "dataShareUpdate":""}])"; 2326 child.DeserializeButtonInfoFromJson(jsonValue); 2327 2328 jsonValue = R"([{"type":1, "title":"111", "titleResource":"", "dataShareUpdate":{"uri":""}}])"; 2329 child.DeserializeButtonInfoFromJson(jsonValue); 2330 2331 jsonValue = R"([{"type":3, "title":"111", "titleResource":"", "dataShareUpdate":{"uri":""}}])"; 2332 child.DeserializeButtonInfoFromJson(jsonValue); 2333 EXPECT_GE(child.actionButtonMap_.size(), 0); 2334 } 2335 2336 /** 2337 * @tc.name: ReminderRequestTest_003 2338 * @tc.desc: Test StringToInt parameters. 2339 * @tc.type: FUNC 2340 * @tc.require: issueI8CDH3 2341 */ 2342 HWTEST_F(ReminderRequestTest, ReminderRequestTest_003, Function | SmallTest | Level1) 2343 { 2344 ReminderRequestChild child; 2345 int32_t ret = child.StringToInt(""); 2346 EXPECT_EQ(ret, 0); 2347 ret = child.StringToInt("1a"); 2348 EXPECT_EQ(ret, 0); 2349 ret = child.StringToInt("-99999999999999999999"); 2350 EXPECT_EQ(ret, 0); 2351 ret = child.StringToInt("2147483648"); 2352 EXPECT_EQ(ret, 0); 2353 ret = child.StringToInt("-2147483649"); 2354 EXPECT_EQ(ret, 0); 2355 ret = child.StringToInt("100"); 2356 EXPECT_EQ(ret, 100); 2357 } 2358 2359 /** 2360 * @tc.name: ReminderRequestTest_004 2361 * @tc.desc: Test StringToInt parameters. 2362 * @tc.type: FUNC 2363 * @tc.require: issueI8CDH3 2364 */ 2365 HWTEST_F(ReminderRequestTest, ReminderRequestTest_004, Function | SmallTest | Level1) 2366 { 2367 ReminderRequestChild child; 2368 NotificationRequest request; 2369 child.wantAgentInfo_->parameters.SetParam("NotificationRequest_extraInfo", nullptr); 2370 child.UpdateNotificationWantAgent(request); 2371 2372 child.OnLanguageChange(nullptr); 2373 EXPECT_NE(request.GetAdditionalData(), nullptr); 2374 } 2375 2376 /** 2377 * @tc.name: ReminderRequestTest_005 2378 * @tc.desc: Test StringToInt parameters. 2379 * @tc.type: FUNC 2380 * @tc.require: issueI8CDH3 2381 */ 2382 HWTEST_F(ReminderRequestTest, ReminderRequestTest_005, Function | SmallTest | Level1) 2383 { 2384 auto alarm = ReminderRequestFactory::CreateReminderRequest(ReminderRequest::ReminderType::ALARM); 2385 EXPECT_NE(alarm, nullptr); 2386 delete alarm; 2387 auto timer = ReminderRequestFactory::CreateReminderRequest(ReminderRequest::ReminderType::TIMER); 2388 EXPECT_NE(timer, nullptr); 2389 delete timer; 2390 auto calendar = ReminderRequestFactory::CreateReminderRequest(ReminderRequest::ReminderType::CALENDAR); 2391 EXPECT_NE(calendar, nullptr); 2392 delete calendar; 2393 auto invalid = ReminderRequestFactory::CreateReminderRequest(ReminderRequest::ReminderType::INVALID); 2394 EXPECT_EQ(invalid, nullptr); 2395 delete invalid; 2396 } 2397 2398 /** 2399 * @tc.name: ReminderRequestTest_006 2400 * @tc.desc: Test StringToInt parameters. 2401 * @tc.type: FUNC 2402 * @tc.require: issueI8CDH3 2403 */ 2404 HWTEST_F(ReminderRequestTest, ReminderRequestTest_006, Function | SmallTest | Level1) 2405 { 2406 ReminderRequestChild child; 2407 child.SetRingChannel(ReminderRequest::RingChannel::ALARM); 2408 EXPECT_EQ(child.GetRingChannel(), ReminderRequest::RingChannel::ALARM); 2409 child.SetRingChannel(ReminderRequest::RingChannel::MEDIA); 2410 EXPECT_EQ(child.GetRingChannel(), ReminderRequest::RingChannel::MEDIA); 2411 } 2412 2413 /** 2414 * @tc.name: ReminderRequestTest_007 2415 * @tc.desc: Test RingLoop parameters. 2416 * @tc.type: FUNC 2417 * @tc.require: issueI8CDH3 2418 */ 2419 HWTEST_F(ReminderRequestTest, ReminderRequestTest_007, Function | SmallTest | Level1) 2420 { 2421 ReminderRequestChild child; 2422 child.SetRingLoop(true); 2423 EXPECT_EQ(child.IsRingLoop(), true); 2424 child.SetRingLoop(false); 2425 EXPECT_EQ(child.IsRingLoop(), false); 2426 } 2427 2428 /** 2429 * @tc.name: ReminderRequestTest_008 2430 * @tc.desc: Test MarshallingActionButton parameters. 2431 * @tc.type: FUNC 2432 * @tc.require: issueI8CDH3 2433 */ 2434 HWTEST_F(ReminderRequestTest, ReminderRequestTest_008, Function | SmallTest | Level1) 2435 { 2436 ReminderRequestChild child; 2437 child.SetActionButton("test1", ReminderRequest::ActionButtonType::CLOSE, "test1", 2438 nullptr, nullptr); 2439 Parcel p; 2440 child.MarshallingActionButton(p); 2441 EXPECT_EQ(child.actionButtonMap_.size(), 1); 2442 2443 child.actionButtonMap_.clear(); 2444 auto wantAgent = std::make_shared<ReminderRequest::ButtonWantAgent>(); 2445 child.SetActionButton("test2", ReminderRequest::ActionButtonType::SNOOZE, "test2", 2446 wantAgent, nullptr); 2447 child.MarshallingActionButton(p); 2448 EXPECT_EQ(child.actionButtonMap_.size(), 1); 2449 2450 child.actionButtonMap_.clear(); 2451 auto update = std::make_shared<ReminderRequest::ButtonDataShareUpdate>(); 2452 child.SetActionButton("test3", ReminderRequest::ActionButtonType::CUSTOM, "test3", 2453 wantAgent, update); 2454 child.MarshallingActionButton(p); 2455 EXPECT_EQ(child.actionButtonMap_.size(), 1); 2456 } 2457 } 2458 } 2459