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