1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <gtest/gtest.h> 17 18 #define private public 19 #define protected public 20 #include "notification.h" 21 #undef private 22 #undef protected 23 24 #include "notification_request.h" 25 #include "parcel.h" 26 27 using namespace testing::ext; 28 namespace OHOS { 29 namespace Notification { 30 class NotificationTest : public testing::Test { 31 public: SetUpTestCase()32 static void SetUpTestCase() {} TearDownTestCase()33 static void TearDownTestCase() {} SetUp()34 void SetUp() {} TearDown()35 void TearDown() {} 36 }; 37 38 /** 39 * @tc.name: GetBundleName_00001 40 * @tc.desc: Test when request_ is nullptr get parameters. 41 * @tc.type: FUNC 42 * @tc.require: issueI5WBBH 43 */ 44 HWTEST_F(NotificationTest, GetBundleName_00001, Function | SmallTest | Level1) 45 { 46 sptr<NotificationRequest> request = nullptr; 47 auto rrc = std::make_shared<Notification>(request); 48 std::string ret = ""; 49 EXPECT_EQ(rrc->GetBundleName(), ret); 50 EXPECT_EQ(rrc->GetCreateBundle(), ret); 51 EXPECT_EQ(rrc->GetLabel(), ret); 52 EXPECT_EQ(rrc->GetId(), -1); 53 EXPECT_EQ(rrc->GetUid(), 0); 54 EXPECT_EQ(rrc->GetPid(), 0); 55 EXPECT_EQ(rrc->IsUnremovable(), false); 56 EXPECT_EQ(rrc->IsGroup(), false); 57 EXPECT_EQ(rrc->IsFloatingIcon(), false); 58 EXPECT_EQ(rrc->GetUserId(), 0); 59 } 60 61 /** 62 * @tc.name: GetLedLightColor_00001 63 * @tc.desc: Test GetLedLightColor parameters. 64 * @tc.type: FUNC 65 * @tc.require: issueI5WBBH 66 */ 67 HWTEST_F(NotificationTest, GetLedLightColor_00001, Function | SmallTest | Level1) 68 { 69 int32_t color = 10; 70 std::string deviceId = "DeviceId"; 71 sptr<NotificationRequest> request = nullptr; 72 auto rrc = std::make_shared<Notification>(deviceId, request); 73 rrc->SetLedLightColor(color); 74 EXPECT_EQ(rrc->GetLedLightColor(), color); 75 } 76 77 /** 78 * @tc.name: GetLockscreenVisibleness_00001 79 * @tc.desc: Test GetLockscreenVisibleness parameters. 80 * @tc.type: FUNC 81 * @tc.require: issueI5WBBH 82 */ 83 HWTEST_F(NotificationTest, GetLockscreenVisibleness_00001, Function | SmallTest | Level1) 84 { 85 NotificationConstant::VisiblenessType visbleness = NotificationConstant::VisiblenessType::PUBLIC; 86 sptr<NotificationRequest> request = nullptr; 87 auto rrc = std::make_shared<Notification>(request); 88 rrc->SetLockScreenVisbleness(visbleness); 89 EXPECT_EQ(rrc->GetLockscreenVisibleness(), visbleness); 90 } 91 92 /** 93 * @tc.name: GetGroup_00001 94 * @tc.desc: Test GetGroup parameters. 95 * @tc.type: FUNC 96 * @tc.require: issue 97 */ 98 HWTEST_F(NotificationTest, GetGroup_00001, Function | SmallTest | Level1) 99 { 100 sptr<NotificationRequest> request = nullptr; 101 auto rrc = std::make_shared<Notification>(request); 102 std::string ret = ""; 103 EXPECT_EQ(rrc->GetGroup(), ret); 104 } 105 106 /** 107 * @tc.name: GetGroup_00002 108 * @tc.desc: Test when request_ is not nullptr get parameters. 109 * @tc.type: FUNC 110 * @tc.require: issue 111 */ 112 HWTEST_F(NotificationTest, GetGroup_00002, Function | SmallTest | Level1) 113 { 114 sptr<NotificationRequest> request = new NotificationRequest(1); 115 auto rrc = std::make_shared<Notification>(request); 116 std::string ret = ""; 117 EXPECT_EQ(rrc->GetGroup(), ret); 118 EXPECT_EQ(rrc->GetPid(), 0); 119 EXPECT_EQ(rrc->IsUnremovable(), false); 120 EXPECT_EQ(rrc->IsGroup(), false); 121 EXPECT_EQ(rrc->IsFloatingIcon(), false); 122 } 123 124 /** 125 * @tc.name: GetNotificationRequestPoint_00001 126 * @tc.desc: Test GetNotificationRequestPoint parameters. 127 * @tc.type: FUNC 128 * @tc.require: issue 129 */ 130 HWTEST_F(NotificationTest, GetNotificationRequestPoint_00001, Function | SmallTest | Level1) 131 { 132 int32_t notificationId = 10; 133 sptr<NotificationRequest> request = new(std::nothrow) NotificationRequest(notificationId); 134 auto rrc = std::make_shared<Notification>(request); 135 EXPECT_EQ(rrc->GetNotificationRequestPoint()->GetNotificationId(), notificationId); 136 } 137 138 /** 139 * @tc.name: GetPostTime_00001 140 * @tc.desc: Test GetPostTime parameters. 141 * @tc.type: FUNC 142 * @tc.require: issue 143 */ 144 HWTEST_F(NotificationTest, GetPostTime_00001, Function | SmallTest | Level1) 145 { 146 int64_t time = 10; 147 sptr<NotificationRequest> request = nullptr; 148 auto rrc = std::make_shared<Notification>(request); 149 rrc->SetPostTime(time); 150 EXPECT_EQ(rrc->GetPostTime(), time); 151 } 152 153 /** 154 * @tc.name: GetSound_00001 155 * @tc.desc: Test GetSound parameters. 156 * @tc.type: FUNC 157 * @tc.require: issue 158 */ 159 HWTEST_F(NotificationTest, GetSound_00001, Function | SmallTest | Level1) 160 { 161 Uri sound = Uri("sound"); 162 bool enable = true; 163 sptr<NotificationRequest> request = nullptr; 164 auto rrc = std::make_shared<Notification>(request); 165 rrc->SetSound(sound); 166 rrc->SetEnableSound(enable); 167 EXPECT_EQ(rrc->GetSound(), sound); 168 } 169 170 /** 171 * @tc.name: GetVibrationStyle_00001 172 * @tc.desc: Test GetVibrationStyle parameters. 173 * @tc.type: FUNC 174 * @tc.require: issue 175 */ 176 HWTEST_F(NotificationTest, GetVibrationStyle_00001, Function | SmallTest | Level1) 177 { 178 std::vector<int64_t> style; 179 sptr<NotificationRequest> request = nullptr; 180 auto rrc = std::make_shared<Notification>(request); 181 rrc->SetVibrationStyle(style); 182 EXPECT_EQ(rrc->GetVibrationStyle(), style); 183 } 184 185 /** 186 * @tc.name: GetRemindType_00001 187 * @tc.desc: Test GetRemindType parameters. 188 * @tc.type: FUNC 189 * @tc.require: issue 190 */ 191 HWTEST_F(NotificationTest, GetRemindType_00001, Function | SmallTest | Level1) 192 { 193 NotificationConstant::RemindType reminType = NotificationConstant::RemindType::NONE; 194 sptr<NotificationRequest> request = nullptr; 195 auto rrc = std::make_shared<Notification>(request); 196 rrc->SetRemindType(reminType); 197 EXPECT_EQ(rrc->GetRemindType(), reminType); 198 } 199 200 /** 201 * @tc.name: GenerateNotificationKey_00001 202 * @tc.desc: Test GenerateNotificationKey parameters. 203 * @tc.type: FUNC 204 * @tc.require: issue 205 */ 206 HWTEST_F(NotificationTest, GenerateNotificationKey_00001, Function | SmallTest | Level1) 207 { 208 int32_t userId = 10; 209 int32_t uid = 20; 210 std::string label = "Lable"; 211 int32_t id = 30; 212 sptr<NotificationRequest> request = sptr<NotificationRequest>::MakeSptr(); 213 request->SetCreatorUid(uid); 214 request->SetCreatorUserId(userId); 215 request->SetLabel(label); 216 request->SetNotificationId(id); 217 request->SetCreatorBundleName("come.test"); 218 auto rrc = std::make_shared<Notification>(request); 219 std::string result = "__10_20_come.test_Lable_30"; 220 EXPECT_EQ(rrc->GetKey(), result); 221 } 222 223 /** 224 * @tc.name: GenerateNotificationKey_00002 225 * @tc.desc: Test GenerateNotificationKey parameters. 226 * @tc.type: FUNC 227 * @tc.require: issue 228 */ 229 HWTEST_F(NotificationTest, GenerateNotificationKey_00002, Function | SmallTest | Level1) 230 { 231 std::string deviceId = "DeviceId"; 232 int32_t userId = 10; 233 int32_t uid = 20; 234 std::string label = "Lable"; 235 int32_t id = 30; 236 sptr<NotificationRequest> request = sptr<NotificationRequest>::MakeSptr(); 237 request->SetIsAgentNotification(true); 238 request->SetOwnerUid(uid); 239 request->SetOwnerUserId(userId); 240 request->SetLabel(label); 241 request->SetNotificationId(id); 242 request->SetCreatorBundleName("come.push"); 243 request->SetOwnerBundleName("come.test"); 244 auto rrc = std::make_shared<Notification>(deviceId, request); 245 std::string result = "_DeviceId_10_20_come.test_Lable_30"; 246 EXPECT_EQ(rrc->GetKey(), result); 247 } 248 249 /** 250 * @tc.name: IsRemoveAllowed_00001 251 * @tc.desc: Test IsRemoveAllowed parameters. 252 * @tc.type: FUNC 253 * @tc.require: issue 254 */ 255 HWTEST_F(NotificationTest, IsRemoveAllowed_00001, Function | SmallTest | Level1) 256 { 257 bool removeAllowed = true; 258 sptr<NotificationRequest> request = nullptr; 259 auto rrc = std::make_shared<Notification>(request); 260 rrc->SetRemoveAllowed(removeAllowed); 261 EXPECT_EQ(rrc->IsRemoveAllowed(), removeAllowed); 262 } 263 264 /** 265 * @tc.name: GetSourceType_00001 266 * @tc.desc: Test GetSourceType parameters. 267 * @tc.type: FUNC 268 * @tc.require: issue 269 */ 270 HWTEST_F(NotificationTest, GetSourceType_00001, Function | SmallTest | Level1) 271 { 272 NotificationConstant::SourceType sourceType = NotificationConstant::SourceType::TYPE_NORMAL; 273 sptr<NotificationRequest> request = nullptr; 274 auto rrc = std::make_shared<Notification>(request); 275 rrc->SetSourceType(sourceType); 276 EXPECT_EQ(rrc->GetSourceType(), sourceType); 277 } 278 279 /** 280 * @tc.name: GetDeviceId_00001 281 * @tc.desc: Test GetDeviceId parameters. 282 * @tc.type: FUNC 283 * @tc.require: issue 284 */ 285 HWTEST_F(NotificationTest, GetDeviceId_00001, Function | SmallTest | Level1) 286 { 287 std::string deviceId = "DeviceId"; 288 sptr<NotificationRequest> request = new NotificationRequest(); 289 auto rrc = std::make_shared<Notification>(deviceId, request); 290 EXPECT_EQ(rrc->GetDeviceId(), deviceId); 291 } 292 293 /** 294 * @tc.name: Dump_00001 295 * @tc.desc: Test Dump parameters. 296 * @tc.type: FUNC 297 * @tc.require: issue 298 */ 299 HWTEST_F(NotificationTest, Dump_00001, Function | SmallTest | Level1) 300 { 301 std::string deviceId = "DeviceId"; 302 sptr<NotificationRequest> request = new NotificationRequest(); 303 auto rrc = std::make_shared<Notification>(deviceId, request); 304 std::string ret = "Notification{ key = _DeviceId_-1_0___0, ledLightColor = 0, " 305 "lockscreenVisbleness = 0, remindType = -1, isRemoveAllowed = true, sourceType = 0, " 306 "deviceId = DeviceId, request = NotificationRequest{ notificationId = 0, slotType = 3, " 307 "createTime = 0, deliveryTime = 0, autoDeletedTime = -1, settingsText = , " 308 "creatorBundleName = , creatorPid = 0, creatorUid = 0, ownerBundleName = , " 309 "ownerUid = 0, groupName = , statusBarText = , label = , shortcutId = , " 310 "sortingKey = , groupAlertType = 0, color = 0, badgeNumber = 0, visiblenessType = 0, " 311 "progressValue = 0, progressMax = 0, badgeStyle = 0, classification = , " 312 "notificationContentType = 0, notificationControlFlags = 0, showDeliveryTime = false, " 313 "tapDismissed = true, colorEnabled = false, alertOneTime = false, showStopwatch = false, " 314 "isCountdown = false, inProgress = false, groupOverview = false, isRemoveAllowed = true, " 315 "progressIndeterminate = false, unremovable = false, floatingIcon = false, onlyLocal = false, " 316 "permitted = true, isAgent = false, updateOnly = false, isForceDistributed = false, " 317 "isNotDistributed = false, isDoNotDisturbByPassed = false, " 318 "removalWantAgent = null, maxScreenWantAgent = null, " 319 "additionalParams = null, extendInfo = null, littleIcon = null, bigIcon = null, overlayIcon = null, " 320 "notificationContent = null, notificationTemplate = null, actionButtons = empty, " 321 "messageUsers = empty, userInputHistory = empty, distributedOptions = " 322 "NotificationDistributedOptions{ isDistributed = true, devicesSupportDisplay = [], " 323 "devicesSupportOperate = [] }, notificationFlags = null, notificationFlagsOfDevices = null, " 324 "notificationBundleOption = null, agentBundle = null, creatorUserId = -1, ownerUserId = -1, " 325 "receiverUserId = -1, updateDeadLine = 0, finishDeadLine = 0, sound = , distributed = 0: " 326 "flag: 0, unifiedGroupInfo_ = null }, postTime = 0, " 327 "sound = nullptr, vibrationStyle = [], updateTimer = 0, finishTimer = 0, archiveTimer = 0 }"; 328 EXPECT_EQ(rrc->Dump(), ret); 329 } 330 331 /** 332 * @tc.name: MarshallingBool_00001 333 * @tc.desc: Test MarshallingBool parameters. 334 * @tc.type: FUNC 335 * @tc.require: issue 336 */ 337 HWTEST_F(NotificationTest, MarshallingBool_00001, Function | SmallTest | Level1) 338 { 339 Parcel parcel; 340 std::string deviceId = "DeviceId"; 341 sptr<NotificationRequest> request = new NotificationRequest(); 342 auto rrc = std::make_shared<Notification>(deviceId, request); 343 EXPECT_EQ(rrc->MarshallingBool(parcel), true); 344 } 345 346 /** 347 * @tc.name: Marshalling_00001 348 * @tc.desc: Test Marshalling parameters. 349 * @tc.type: FUNC 350 * @tc.require: issueI5WBBHI 351 */ 352 HWTEST_F(NotificationTest, Marshalling_00001, Function | SmallTest | Level1) 353 { 354 Parcel parcel; 355 std::string deviceId = "DeviceId"; 356 sptr<NotificationRequest> request = new NotificationRequest(); 357 auto rrc = std::make_shared<Notification>(deviceId, request); 358 EXPECT_EQ(rrc->Marshalling(parcel), true); 359 } 360 361 /** 362 * @tc.name: Unmarshalling_00001 363 * @tc.desc: Test Unmarshalling parameters. 364 * @tc.type: FUNC 365 * @tc.require: issueI5WBBH 366 */ 367 HWTEST_F(NotificationTest, Unmarshalling_001, Function | SmallTest | Level1) 368 { 369 bool unmarshalling = true; 370 Parcel parcel; 371 std::string deviceId = "DeviceId"; 372 sptr<NotificationRequest> request = new NotificationRequest(); 373 std::shared_ptr<Notification> result = 374 std::make_shared<Notification>(deviceId, request); 375 result->Marshalling(parcel); 376 377 if (nullptr != result) { 378 if (nullptr == result->Unmarshalling(parcel)) { 379 unmarshalling = false; 380 } 381 } 382 EXPECT_EQ(unmarshalling, false); 383 } 384 385 /** 386 * @tc.name: ReadFromParcel_00001 387 * @tc.desc: Test ReadFromParcel parameters. 388 * @tc.type: FUNC 389 * @tc.require: issueI5WBBH 390 */ 391 HWTEST_F(NotificationTest, ReadFromParcel_00001, Function | SmallTest | Level1) 392 { 393 Parcel parcel; 394 std::string deviceId = "DeviceId"; 395 sptr<NotificationRequest> request = new NotificationRequest(); 396 auto rrc = std::make_shared<Notification>(deviceId, request); 397 rrc->Marshalling(parcel); 398 EXPECT_EQ(rrc->ReadFromParcel(parcel), false); 399 } 400 401 /** 402 * @tc.name: GetSound_00002 403 * @tc.desc: Test GetSound parameters. 404 * @tc.type: FUNC 405 * @tc.require: issue 406 */ 407 HWTEST_F(NotificationTest, GetSound_00002, Function | SmallTest | Level1) 408 { 409 Uri sound = Uri("sound"); 410 bool enable = false; 411 sptr<NotificationRequest> request = nullptr; 412 auto rrc = std::make_shared<Notification>(request); 413 rrc->SetSound(sound); 414 rrc->SetEnableSound(enable); 415 EXPECT_EQ(rrc->GetSound(), Uri("")); 416 } 417 418 /** 419 * @tc.name: GetSound_00003 420 * @tc.desc: Test GetSound parameters. 421 * @tc.type: FUNC 422 * @tc.require: issue 423 */ 424 HWTEST_F(NotificationTest, GetSound_00003, Function | SmallTest | Level1) 425 { 426 Uri sound = Uri(""); 427 bool enable = true; 428 sptr<NotificationRequest> request = nullptr; 429 auto rrc = std::make_shared<Notification>(request); 430 rrc->SetSound(sound); 431 rrc->SetEnableSound(enable); 432 EXPECT_EQ(rrc->GetSound(), Uri("")); 433 } 434 435 /** 436 * @tc.name: EnableLight_00001 437 * @tc.desc: Test EnableLight parameters. 438 * @tc.type: FUNC 439 * @tc.require: issue 440 */ 441 HWTEST_F(NotificationTest, EnableLight_00001, Function | SmallTest | Level1) 442 { 443 bool enable = true; 444 sptr<NotificationRequest> request = nullptr; 445 auto rrc = std::make_shared<Notification>(request); 446 rrc->SetEnableLight(enable); 447 EXPECT_EQ(rrc->EnableLight(), enable); 448 } 449 450 /** 451 * @tc.name: EnableSound_00001 452 * @tc.desc: Test EnableSound parameters. 453 * @tc.type: FUNC 454 * @tc.require: issue 455 */ 456 HWTEST_F(NotificationTest, EnableSound_00001, Function | SmallTest | Level1) 457 { 458 bool enable = true; 459 sptr<NotificationRequest> request = nullptr; 460 auto rrc = std::make_shared<Notification>(request); 461 rrc->SetEnableSound(enable); 462 EXPECT_EQ(rrc->EnableSound(), enable); 463 Parcel parcel; 464 rrc->ReadFromParcelString(parcel); 465 } 466 467 /** 468 * @tc.name: EnableVibrate_00001 469 * @tc.desc: Test EnableVibrate parameters. 470 * @tc.type: FUNC 471 * @tc.require: issue 472 */ 473 HWTEST_F(NotificationTest, EnableVibrate_00001, Function | SmallTest | Level1) 474 { 475 bool enable = true; 476 sptr<NotificationRequest> request = nullptr; 477 auto rrc = std::make_shared<Notification>(request); 478 rrc->SetEnableVibration(enable); 479 EXPECT_EQ(rrc->EnableVibrate(), enable); 480 } 481 482 /** 483 * @tc.name: GetBundleName_00002 484 * @tc.desc: Test when request_ is nullptr get parameters. 485 * @tc.type: FUNC 486 * @tc.require: issueI5WBBH 487 */ 488 HWTEST_F(NotificationTest, GetBundleName_00002, Function | SmallTest | Level1) 489 { 490 sptr<NotificationRequest> request = new NotificationRequest(1); 491 auto rrc = std::make_shared<Notification>(request); 492 std::string ret = ""; 493 EXPECT_EQ(rrc->GetBundleName(), ret); 494 EXPECT_EQ(rrc->GetCreateBundle(), ret); 495 } 496 497 /** 498 * @tc.name: GetSound_00004 499 * @tc.desc: Test GetSound parameters. 500 * @tc.type: FUNC 501 * @tc.require: issue 502 */ 503 HWTEST_F(NotificationTest, GetSound_00004, Function | SmallTest | Level1) 504 { 505 Uri sound = Uri("sound"); 506 bool enable = false; 507 sptr<NotificationRequest> request = new NotificationRequest(1); 508 auto rrc = std::make_shared<Notification>(request); 509 rrc->SetSound(sound); 510 rrc->SetEnableSound(enable); 511 EXPECT_EQ(rrc->GetSound(), Uri("")); 512 } 513 514 /** 515 * @tc.name: GetSound_00005 516 * @tc.desc: Test GetSound parameters. 517 * @tc.type: FUNC 518 * @tc.require: issue 519 */ 520 HWTEST_F(NotificationTest, GetSound_00005, Function | SmallTest | Level1) 521 { 522 Uri sound = Uri("sound"); 523 bool enable = true; 524 sptr<NotificationRequest> request = new NotificationRequest(1); 525 auto rrc = std::make_shared<Notification>(request); 526 rrc->SetSound(sound); 527 rrc->SetEnableSound(enable); 528 EXPECT_EQ(rrc->GetSound(), Uri("sound")); 529 } 530 531 /** 532 * @tc.name: Marshalling_00002 533 * @tc.desc: Test Marshalling parameters. 534 * @tc.type: FUNC 535 * @tc.require: issueI5WBBHI 536 */ 537 HWTEST_F(NotificationTest, Marshalling_00002, Function | SmallTest | Level1) 538 { 539 Parcel parcel; 540 std::string deviceId = "DeviceId"; 541 sptr<NotificationRequest> request = new NotificationRequest(); 542 auto rrc = std::make_shared<Notification>(deviceId, request); 543 544 bool enable = true; 545 auto sound = std::make_shared<Uri>("sound"); 546 rrc->SetSound(*sound); 547 rrc->SetEnableSound(enable); 548 549 EXPECT_EQ(rrc->Marshalling(parcel), true); 550 } 551 552 /** 553 * @tc.name: Marshalling_00003 554 * @tc.desc: Test Marshalling parameters. 555 * @tc.type: FUNC 556 * @tc.require: issueI5WBBHI 557 */ 558 HWTEST_F(NotificationTest, Marshalling_00003, Function | SmallTest | Level1) 559 { 560 Parcel parcel; 561 std::string deviceId = "DeviceId"; 562 sptr<NotificationRequest> request = new NotificationRequest(); 563 auto rrc = std::make_shared<Notification>(deviceId, request); 564 565 bool enable = false; 566 auto sound = std::make_shared<Uri>("sound"); 567 rrc->SetSound(*sound); 568 rrc->SetEnableSound(enable); 569 570 EXPECT_EQ(rrc->Marshalling(parcel), true); 571 } 572 573 /** 574 * @tc.name: GetUpdateTimer_00001 575 * @tc.desc: Test get update timer. 576 * @tc.type: FUNC 577 * @tc.require: issue 578 */ 579 HWTEST_F(NotificationTest, GetUpdateTimer_00001, Function | SmallTest | Level1) 580 { 581 sptr<NotificationRequest> request = new NotificationRequest(1); 582 auto rrc = std::make_shared<Notification>(request); 583 rrc->SetUpdateTimer(1); 584 EXPECT_EQ(rrc->GetUpdateTimer(), 1); 585 } 586 587 /** 588 * @tc.name: GetFinishTimer_00001 589 * @tc.desc: Test get finish timer. 590 * @tc.type: FUNC 591 * @tc.require: issue 592 */ 593 HWTEST_F(NotificationTest, GetFinishTimer_00001, Function | SmallTest | Level1) 594 { 595 sptr<NotificationRequest> request = new NotificationRequest(1); 596 auto rrc = std::make_shared<Notification>(request); 597 rrc->SetFinishTimer(1); 598 EXPECT_EQ(rrc->GetFinishTimer(), 1); 599 } 600 601 /** 602 * @tc.name: GetInstanceKey_00001 603 * @tc.desc: Test get finish timer. 604 * @tc.type: FUNC 605 * @tc.require: issue 606 */ 607 HWTEST_F(NotificationTest, GetInstanceKeyr_00001, Function | SmallTest | Level1) 608 { 609 sptr<Notification> notification(new Notification(nullptr)); 610 611 ASSERT_EQ(notification->GetInstanceKey(), ""); 612 } 613 614 /** 615 * @tc.name: Dump_00002 616 * @tc.desc: Test Dump_00002 617 * @tc.type: FUNC 618 * @tc.require: issue 619 */ 620 HWTEST_F(NotificationTest, Dump_00002, Function | SmallTest | Level1) 621 { 622 sptr<Notification> notification(new Notification(nullptr)); 623 std::vector<int64_t> style; 624 style.push_back(999); 625 notification->SetVibrationStyle(style); 626 627 auto dump = notification->Dump(); 628 auto it = dump.find("999"); 629 ASSERT_NE(it, std::string::npos); 630 } 631 } // namespace Notification 632 } // namespace OHOS 633