1 /* 2 * Copyright (c) 2022-2024 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 "errors.h" 17 #include "ipc_types.h" 18 #include "iremote_object.h" 19 #include "notification_button_option.h" 20 #include "notification_check_request.h" 21 #include "notification_subscribe_info.h" 22 #include <gtest/gtest.h> 23 24 #define private public 25 #define protected public 26 #include "ans_manager_stub.h" 27 #include "ans_subscriber_stub.h" 28 #include "ans_dialog_host_client.h" 29 #include "notification_subscriber.h" 30 #undef private 31 #undef protected 32 33 #include "ans_inner_errors.h" 34 35 using namespace testing::ext; 36 namespace OHOS { 37 namespace Notification { 38 class AnsManagerStubTest : public testing::Test { 39 public: SetUpTestCase()40 static void SetUpTestCase() {} TearDownTestCase()41 static void TearDownTestCase() {} SetUp()42 void SetUp() 43 { 44 ansManagerStub_ = new AnsManagerStub(); 45 } TearDown()46 void TearDown() {} 47 sptr<AnsManagerStub> ansManagerStub_; 48 }; 49 50 /** 51 * @tc.name: OnRemoteRequest01 52 * @tc.desc: Test if get the wrong descriptor. 53 * @tc.type: FUNC 54 * @tc.require: issueI5XQ4E 55 */ 56 HWTEST_F(AnsManagerStubTest, OnRemoteRequest0001, Function | SmallTest | Level1) 57 { 58 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_NOTIFICATION); 59 MessageParcel data; 60 MessageParcel reply; 61 MessageOption option = {MessageOption::TF_SYNC}; 62 63 data.WriteInterfaceToken(u"error.GetDescriptor"); 64 65 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 66 EXPECT_EQ(ret, (int)OBJECT_NULL); 67 } 68 69 /** 70 * @tc.name: OnRemoteRequest02 71 * @tc.desc: Test if get the wrong code. 72 * @tc.type: FUNC 73 * @tc.require: issueI5XQ4E 74 */ 75 HWTEST_F(AnsManagerStubTest, OnRemoteRequest0002, Function | SmallTest | Level1) 76 { 77 uint32_t code = 267; 78 MessageParcel data; 79 MessageParcel reply; 80 MessageOption option = {MessageOption::TF_SYNC}; 81 82 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 83 84 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 85 EXPECT_EQ(ret, (int)IPC_STUB_UNKNOW_TRANS_ERR); 86 } 87 88 /** 89 * @tc.name: HandlePublish01 90 * @tc.desc: Test HandlePublish succeeds. 91 * @tc.type: FUNC 92 * @tc.require: issueI5XQ4E 93 */ 94 HWTEST_F(AnsManagerStubTest, HandlePublish01, Function | SmallTest | Level1) 95 { 96 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_NOTIFICATION); 97 MessageParcel data; 98 MessageParcel reply; 99 MessageOption option = {MessageOption::TF_SYNC}; 100 101 std::string label = "this is a notification label"; 102 sptr<NotificationRequest> notification = new NotificationRequest(); 103 notification->SetSlotType(NotificationConstant::SlotType::CONTENT_INFORMATION); 104 std::shared_ptr<NotificationLongTextContent> longTextContent = 105 std::make_shared<NotificationLongTextContent>("longtext"); 106 std::shared_ptr<NotificationContent> content2 = std::make_shared<NotificationContent>(longTextContent); 107 notification->SetContent(content2); 108 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 109 data.WriteString(label); 110 data.WriteParcelable(notification); 111 112 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 113 EXPECT_EQ(ret, (int)NO_ERROR); 114 } 115 116 /** 117 * @tc.name: HandlePublish02 118 * @tc.desc: Test if the label is null. 119 * @tc.type: FUNC 120 * @tc.require: issueI5XQ4E 121 */ 122 HWTEST_F(AnsManagerStubTest, HandlePublish02, Function | SmallTest | Level1) 123 { 124 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_NOTIFICATION); 125 MessageParcel data; 126 MessageParcel reply; 127 MessageOption option = {MessageOption::TF_SYNC}; 128 129 sptr<NotificationRequest> notification = new NotificationRequest(); 130 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 131 data.WriteParcelable(notification); 132 133 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 134 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 135 } 136 137 /** 138 * @tc.name: HandlePublish03 139 * @tc.desc: Test if the notification is null. 140 * @tc.type: FUNC 141 * @tc.require: issueI5XQ4E 142 */ 143 HWTEST_F(AnsManagerStubTest, HandlePublish03, Function | SmallTest | Level1) 144 { 145 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_NOTIFICATION); 146 MessageParcel data; 147 MessageParcel reply; 148 MessageOption option = {MessageOption::TF_SYNC}; 149 150 std::string label = "this is a notification label"; 151 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 152 data.WriteString(label); 153 154 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 155 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 156 } 157 158 /** 159 * @tc.name: HandleCancel01 160 * @tc.desc: Test HandleCancel succeeds 161 * @tc.type: FUNC 162 * @tc.require: issueI5XQ4E 163 */ 164 HWTEST_F(AnsManagerStubTest, HandleCancel01, Function | SmallTest | Level1) 165 { 166 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_NOTIFICATION); 167 MessageParcel data; 168 MessageParcel reply; 169 MessageOption option = {MessageOption::TF_SYNC}; 170 171 int32_t notificationId = 3; 172 std::string instanceKey = ""; 173 std::string label = "this is a notification label"; 174 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 175 data.WriteInt32(notificationId); 176 data.WriteString(label); 177 data.WriteString(instanceKey); 178 179 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 180 EXPECT_EQ(ret, (int)NO_ERROR); 181 } 182 183 /** 184 * @tc.name: HandleCancel02 185 * @tc.desc: Test if the notificationId in data is null. 186 * @tc.type: FUNC 187 * @tc.require: issueI5XQ4E 188 */ 189 HWTEST_F(AnsManagerStubTest, HandleCancel02, Function | SmallTest | Level1) 190 { 191 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_NOTIFICATION); 192 MessageParcel data; 193 MessageParcel reply; 194 MessageOption option = {MessageOption::TF_SYNC}; 195 196 std::string label = "this is a notification label"; 197 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 198 data.WriteString(label); 199 200 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 201 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 202 } 203 204 /** 205 * @tc.name: HandleCancel03 206 * @tc.desc: Test if the label in data is null. 207 * @tc.type: FUNC 208 * @tc.require: issueI5XQ4E 209 */ 210 HWTEST_F(AnsManagerStubTest, HandleCancel03, Function | SmallTest | Level1) 211 { 212 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_NOTIFICATION); 213 MessageParcel data; 214 MessageParcel reply; 215 MessageOption option = {MessageOption::TF_SYNC}; 216 217 int32_t notificationId = 3; 218 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 219 data.WriteInt32(notificationId); 220 221 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 222 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 223 } 224 225 /** 226 * @tc.name: HandleCancelAll01 227 * @tc.desc: Test HandleCancelAll succeeds. 228 * @tc.type: FUNC 229 * @tc.require: issueI5XQ4E 230 */ 231 HWTEST_F(AnsManagerStubTest, HandleCancelAll01, Function | SmallTest | Level1) 232 { 233 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_ALL_NOTIFICATIONS); 234 MessageParcel data; 235 MessageParcel reply; 236 MessageOption option = {MessageOption::TF_SYNC}; 237 238 std::string instanceKey = ""; 239 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 240 data.WriteString(instanceKey); 241 242 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 243 EXPECT_EQ(ret, (int)NO_ERROR); 244 } 245 246 /** 247 * @tc.name: HandleCancelAsBundle01 248 * @tc.desc: Test HandlePublish succeeds. 249 * @tc.type: FUNC 250 * @tc.require: issueI5XQ4E 251 */ 252 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle01, Function | SmallTest | Level1) 253 { 254 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE); 255 MessageParcel data; 256 MessageParcel reply; 257 MessageOption option = {MessageOption::TF_SYNC}; 258 259 int32_t notificationId = 3; 260 std::string representativeBundle = "this is a representativeBundle"; 261 int32_t userId = 4; 262 263 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 264 data.WriteInt32(notificationId); 265 data.WriteString(representativeBundle); 266 data.WriteInt32(userId); 267 268 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 269 EXPECT_EQ(ret, (int)NO_ERROR); 270 } 271 272 /** 273 * @tc.name: HandleCancelAsBundle02 274 * @tc.desc: Test if the notificationId in data is null.. 275 * @tc.type: FUNC 276 * @tc.require: issueI5XQ4E 277 */ 278 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle02, Function | SmallTest | Level1) 279 { 280 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE); 281 MessageParcel data; 282 MessageParcel reply; 283 MessageOption option = {MessageOption::TF_SYNC}; 284 285 std::string representativeBundle = "this is a representativeBundle"; 286 int32_t userId = 4; 287 288 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 289 data.WriteString(representativeBundle); 290 data.WriteInt32(userId); 291 292 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 293 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 294 } 295 296 /** 297 * @tc.name: HandleCancelAsBundle03 298 * @tc.desc: Test if the representativeBundle in data is null. 299 * @tc.type: FUNC 300 * @tc.require: issueI5XQ4E 301 */ 302 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle03, Function | SmallTest | Level1) 303 { 304 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE); 305 MessageParcel data; 306 MessageParcel reply; 307 MessageOption option = {MessageOption::TF_SYNC}; 308 309 int32_t notificationId = 3; 310 int32_t userId = 4; 311 312 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 313 data.WriteInt32(notificationId); 314 data.WriteInt32(userId); 315 316 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 317 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 318 } 319 320 /** 321 * @tc.name: HandleCancelAsBundle04 322 * @tc.desc: Test if the userId in data is null. 323 * @tc.type: FUNC 324 * @tc.require: issueI5XQ4E 325 */ 326 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle04, Function | SmallTest | Level1) 327 { 328 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE); 329 MessageParcel data; 330 MessageParcel reply; 331 MessageOption option = {MessageOption::TF_SYNC}; 332 333 int32_t notificationId = 3; 334 std::string representativeBundle = "this is a representativeBundle"; 335 336 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 337 data.WriteInt32(notificationId); 338 data.WriteString(representativeBundle); 339 340 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 341 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 342 } 343 344 /** 345 * @tc.name: HandleCancelAsBundle05 346 * @tc.desc: Test HandlePublish succeeds. 347 * @tc.type: FUNC 348 * @tc.require: issueI5XQ4E 349 */ 350 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle05, Function | SmallTest | Level1) 351 { 352 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE_OPTION); 353 MessageParcel data; 354 MessageParcel reply; 355 MessageOption option = {MessageOption::TF_SYNC}; 356 357 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 358 int32_t notificationId = 3; 359 360 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 361 data.WriteStrongParcelable(bundleOption); 362 data.WriteInt32(notificationId); 363 364 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 365 EXPECT_EQ(ret, (int)NO_ERROR); 366 } 367 368 /** 369 * @tc.name: HandleCancelAsBundle06 370 * @tc.desc: Test if the bundleOption in data is null. 371 * @tc.type: FUNC 372 * @tc.require: issueI5XQ4E 373 */ 374 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle06, Function | SmallTest | Level1) 375 { 376 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE_OPTION); 377 MessageParcel data; 378 MessageParcel reply; 379 MessageOption option = {MessageOption::TF_SYNC}; 380 381 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 382 int32_t notificationId = 3; 383 384 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 385 data.WriteInt32(notificationId); 386 387 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 388 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 389 } 390 391 /** 392 * @tc.name: HandleCancelAsBundle07 393 * @tc.desc: Test if the notificationId in data is null. 394 * @tc.type: FUNC 395 * @tc.require: issueI5XQ4E 396 */ 397 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle07, Function | SmallTest | Level1) 398 { 399 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE_OPTION); 400 MessageParcel data; 401 MessageParcel reply; 402 MessageOption option = {MessageOption::TF_SYNC}; 403 404 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 405 406 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 407 data.WriteStrongParcelable(bundleOption); 408 409 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 410 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 411 } 412 413 /** 414 * @tc.name: HandleCancelAsBundle08 415 * @tc.desc: Test HandlePublish succeeds. 416 * @tc.type: FUNC 417 * @tc.require: issueI5XQ4E 418 */ 419 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle08, Function | SmallTest | Level1) 420 { 421 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE_AND_USER); 422 MessageParcel data; 423 MessageParcel reply; 424 MessageOption option = {MessageOption::TF_SYNC}; 425 426 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 427 int32_t notificationId = 3; 428 int32_t userId = 4; 429 430 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 431 data.WriteStrongParcelable(bundleOption); 432 data.WriteInt32(notificationId); 433 data.WriteInt32(userId); 434 435 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 436 EXPECT_EQ(ret, (int)NO_ERROR); 437 } 438 439 /** 440 * @tc.name: HandleCancelAsBundleWithAgent01 441 * @tc.desc: Test HandleCancelAsBundleWithAgent. 442 * @tc.type: FUNC 443 * @tc.require: issueI5XQ4E 444 */ 445 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundleWithAgent01, Function | SmallTest | Level1) 446 { 447 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE_WITH_AGENT); 448 MessageParcel data; 449 MessageParcel reply; 450 MessageOption option = {MessageOption::TF_SYNC}; 451 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 452 int32_t id = 1; 453 454 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 455 data.WriteStrongParcelable(bundleOption); 456 data.WriteInt32(id); 457 458 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 459 EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); 460 } 461 462 /** 463 * @tc.name: HandleCancelAsBundleWithAgent02 464 * @tc.desc: Test HandleCancelAsBundleWithAgent. 465 * @tc.type: FUNC 466 * @tc.require: issueI5XQ4E 467 */ 468 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundleWithAgent02, Function | SmallTest | Level1) 469 { 470 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE_WITH_AGENT); 471 MessageParcel data; 472 MessageParcel reply; 473 MessageOption option = {MessageOption::TF_SYNC}; 474 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 475 476 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 477 data.WriteStrongParcelable(bundleOption); 478 479 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 480 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 481 } 482 483 /** 484 * @tc.name: HandleCancelAsBundleWithAgent03 485 * @tc.desc: Test HandleCancelAsBundleWithAgent. 486 * @tc.type: FUNC 487 * @tc.require: issueI5XQ4E 488 */ 489 HWTEST_F(AnsManagerStubTest, HandleCancelAsBundleWithAgent03, Function | SmallTest | Level1) 490 { 491 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_AS_BUNDLE_WITH_AGENT); 492 MessageParcel data; 493 MessageParcel reply; 494 MessageOption option = {MessageOption::TF_SYNC}; 495 496 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 497 498 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 499 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 500 } 501 502 /** 503 * @tc.name: HandleSetTargetDeviceStatus01 504 * @tc.desc: Test HandleSetTargetDeviceStatus. 505 * @tc.type: FUNC 506 * @tc.require: issueI5XQ4E 507 */ 508 HWTEST_F(AnsManagerStubTest, HandleSetTargetDeviceStatus01, Function | SmallTest | Level1) 509 { 510 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS); 511 MessageParcel data; 512 MessageParcel reply; 513 MessageOption option = {MessageOption::TF_SYNC}; 514 int32_t status = 1; 515 516 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 517 data.WriteString("device"); 518 data.WriteInt32(status); 519 520 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 521 EXPECT_EQ(ret, (int)ERR_OK); 522 } 523 524 /** 525 * @tc.name: HandleSetTargetDeviceStatus02 526 * @tc.desc: Test HandleSetTargetDeviceStatus. 527 * @tc.type: FUNC 528 * @tc.require: issueI5XQ4E 529 */ 530 HWTEST_F(AnsManagerStubTest, HandleSetTargetDeviceStatus02, Function | SmallTest | Level1) 531 { 532 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS); 533 MessageParcel data; 534 MessageParcel reply; 535 MessageOption option = {MessageOption::TF_SYNC}; 536 537 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 538 data.WriteString("device"); 539 540 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 541 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 542 } 543 544 /** 545 * @tc.name: HandleSetTargetDeviceStatus03 546 * @tc.desc: Test HandleSetTargetDeviceStatus. 547 * @tc.type: FUNC 548 * @tc.require: issueI5XQ4E 549 */ 550 HWTEST_F(AnsManagerStubTest, HandleSetTargetDeviceStatus03, Function | SmallTest | Level1) 551 { 552 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS); 553 MessageParcel data; 554 MessageParcel reply; 555 MessageOption option = {MessageOption::TF_SYNC}; 556 557 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 558 559 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 560 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 561 } 562 563 /** 564 * @tc.name: HandleAddSlotByType01 565 * @tc.desc: Test HandleAddSlotByType succeeds. 566 * @tc.type: FUNC 567 * @tc.require: issueI5XQ4E 568 */ 569 HWTEST_F(AnsManagerStubTest, HandleAddSlotByType01, Function | SmallTest | Level1) 570 { 571 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::ADD_SLOT_BY_TYPE); 572 MessageParcel data; 573 MessageParcel reply; 574 MessageOption option = {MessageOption::TF_SYNC}; 575 576 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 577 578 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 579 EXPECT_EQ(ret, (int)NO_ERROR); 580 } 581 582 /** 583 * @tc.name: HandleRemoveSlotByType01 584 * @tc.desc: Test HandleRemoveSlotByType succeeds. 585 * @tc.type: FUNC 586 * @tc.require: issueI5XQ4E 587 */ 588 HWTEST_F(AnsManagerStubTest, HandleRemoveSlotByType01, Function | SmallTest | Level1) 589 { 590 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_SLOT_BY_TYPE); 591 MessageParcel data; 592 MessageParcel reply; 593 MessageOption option = {MessageOption::TF_SYNC}; 594 595 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 596 597 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 598 EXPECT_EQ(ret, (int)NO_ERROR); 599 } 600 601 /** 602 * @tc.name: HandleRemoveAllSlots01 603 * @tc.desc: Test HandleRemoveAllSlots succeeds. 604 * @tc.type: FUNC 605 * @tc.require: issueI5XQ4E 606 */ 607 HWTEST_F(AnsManagerStubTest, HandleRemoveAllSlots01, Function | SmallTest | Level1) 608 { 609 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_ALL_SLOTS); 610 MessageParcel data; 611 MessageParcel reply; 612 MessageOption option = {MessageOption::TF_SYNC}; 613 614 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 615 616 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 617 EXPECT_EQ(ret, (int)NO_ERROR); 618 } 619 620 /** 621 * @tc.name: HandleGetSlotByType01 622 * @tc.desc: Test HandleGetSlotByType succeeds. 623 * @tc.type: FUNC 624 * @tc.require: issueI5XQ4E 625 */ 626 HWTEST_F(AnsManagerStubTest, HandleGetSlotByType01, Function | SmallTest | Level1) 627 { 628 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOT_BY_TYPE); 629 MessageParcel data; 630 MessageParcel reply; 631 MessageOption option = {MessageOption::TF_SYNC}; 632 633 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 634 635 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 636 EXPECT_EQ(ret, (int)NO_ERROR); 637 } 638 639 /** 640 * @tc.name: HandleGetSlotNumAsBundle01 641 * @tc.desc: Test HandleGetSlotNumAsBundle succeeds. 642 * @tc.type: FUNC 643 * @tc.require: issueI5XQ4E 644 */ 645 HWTEST_F(AnsManagerStubTest, HandleGetSlotNumAsBundle01, Function | SmallTest | Level1) 646 { 647 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOT_NUM_AS_BUNDLE); 648 MessageParcel data; 649 MessageParcel reply; 650 MessageOption option = {MessageOption::TF_SYNC}; 651 652 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 653 654 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 655 data.WriteStrongParcelable(bundleOption); 656 657 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 658 EXPECT_EQ(ret, (int)NO_ERROR); 659 } 660 661 /** 662 * @tc.name: HandleGetSlotNumAsBundle02 663 * @tc.desc: Test if the bundleOption in data is null. 664 * @tc.type: FUNC 665 * @tc.require: issueI5XQ4E 666 */ 667 HWTEST_F(AnsManagerStubTest, HandleGetSlotNumAsBundle02, Function | SmallTest | Level1) 668 { 669 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOT_NUM_AS_BUNDLE); 670 MessageParcel data; 671 MessageParcel reply; 672 MessageOption option = {MessageOption::TF_SYNC}; 673 674 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 675 676 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 677 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 678 } 679 680 /** 681 * @tc.name: HandleGetActiveNotifications01 682 * @tc.desc: Test HandleGetActiveNotifications succeeds. 683 * @tc.type: FUNC 684 * @tc.require: issueI5XQ4E 685 */ 686 HWTEST_F(AnsManagerStubTest, HandleGetActiveNotifications01, Function | SmallTest | Level1) 687 { 688 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATIONS); 689 MessageParcel data; 690 MessageParcel reply; 691 MessageOption option = {MessageOption::TF_SYNC}; 692 693 std::string instanceKey = ""; 694 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 695 data.WriteString(instanceKey); 696 697 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 698 EXPECT_EQ(ret, (int)NO_ERROR); 699 } 700 701 /** 702 * @tc.name: HandleGetActiveNotificationNums01 703 * @tc.desc: Test HandleGetActiveNotificationNums succeeds. 704 * @tc.type: FUNC 705 * @tc.require: issueI5XQ4E 706 */ 707 HWTEST_F(AnsManagerStubTest, HandleGetActiveNotificationNums01, Function | SmallTest | Level1) 708 { 709 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_NUMS); 710 MessageParcel data; 711 MessageParcel reply; 712 MessageOption option = {MessageOption::TF_SYNC}; 713 714 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 715 716 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 717 EXPECT_EQ(ret, (int)NO_ERROR); 718 } 719 720 /** 721 * @tc.name: HandleGetAllActiveNotifications01 722 * @tc.desc: Test HandleGetAllActiveNotifications succeeds. 723 * @tc.type: FUNC 724 * @tc.require: issueI5XQ4E 725 */ 726 HWTEST_F(AnsManagerStubTest, HandleGetAllActiveNotifications01, Function | SmallTest | Level1) 727 { 728 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ALL_ACTIVE_NOTIFICATIONS); 729 MessageParcel data; 730 MessageParcel reply; 731 MessageOption option = {MessageOption::TF_SYNC}; 732 733 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 734 735 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 736 EXPECT_EQ(ret, (int)NO_ERROR); 737 } 738 739 /** 740 * @tc.name: HandleGetActiveNotificationByFilter01 741 * @tc.desc: Test HandleGetActiveNotificationByFilter succeeds. 742 * @tc.type: FUNC 743 * @tc.require: issueI5XQ4E 744 */ 745 HWTEST_F(AnsManagerStubTest, HandleGetActiveNotificationByFilter01, Function | SmallTest | Level1) 746 { 747 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_BY_FILTER); 748 MessageParcel data; 749 MessageParcel reply; 750 MessageOption option = {MessageOption::TF_SYNC}; 751 752 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 753 754 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 755 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 756 } 757 758 /** 759 * @tc.name: HandleGetActiveNotificationByFilter02 760 * @tc.desc: Test HandleGetActiveNotificationByFilter succeeds. 761 * @tc.type: FUNC 762 * @tc.require: issueI5XQ4E 763 */ 764 HWTEST_F(AnsManagerStubTest, HandleGetActiveNotificationByFilter02, Function | SmallTest | Level1) 765 { 766 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_BY_FILTER); 767 MessageParcel data; 768 MessageParcel reply; 769 MessageOption option = {MessageOption::TF_SYNC}; 770 771 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 772 int32_t notificationId = 1; 773 std::string label = "this is a label"; 774 775 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 776 data.WriteStrongParcelable(bundleOption); 777 data.WriteInt32(notificationId); 778 data.WriteString(label); 779 780 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 781 EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); 782 } 783 784 /** 785 * @tc.name: HandleGetActiveNotificationByFilter03 786 * @tc.desc: Test HandleGetActiveNotificationByFilter succeeds. 787 * @tc.type: FUNC 788 * @tc.require: issueI5XQ4E 789 */ 790 HWTEST_F(AnsManagerStubTest, HandleGetActiveNotificationByFilter03, Function | SmallTest | Level1) 791 { 792 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_BY_FILTER); 793 MessageParcel data; 794 MessageParcel reply; 795 MessageOption option = {MessageOption::TF_SYNC}; 796 797 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 798 int32_t notificationId = 1; 799 std::string label = "this is a label"; 800 801 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 802 data.WriteStrongParcelable(bundleOption); 803 data.WriteInt32(notificationId); 804 805 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 806 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 807 } 808 809 /** 810 * @tc.name: HandleTriggerLocalLiveView01 811 * @tc.desc: Test HandleTriggerLocalLiveView succeeds. 812 * @tc.type: FUNC 813 * @tc.require: issueI5XQ4E 814 */ 815 HWTEST_F(AnsManagerStubTest, HandleTriggerLocalLiveView01, Function | SmallTest | Level1) 816 { 817 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_NOTIFICATION); 818 MessageParcel data; 819 MessageParcel reply; 820 MessageOption option = {MessageOption::TF_SYNC}; 821 822 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 823 824 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 825 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 826 } 827 828 /** 829 * @tc.name: HandleTriggerLocalLiveView02 830 * @tc.desc: Test HandleTriggerLocalLiveView succeeds. 831 * @tc.type: FUNC 832 * @tc.require: issueI5XQ4E 833 */ 834 HWTEST_F(AnsManagerStubTest, HandleTriggerLocalLiveView02, Function | SmallTest | Level1) 835 { 836 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_NOTIFICATION); 837 MessageParcel data; 838 MessageParcel reply; 839 MessageOption option = {MessageOption::TF_SYNC}; 840 841 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 842 int32_t notificationId = 1; 843 sptr<NotificationButtonOption> buttonOption = new NotificationButtonOption(); 844 845 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 846 data.WriteStrongParcelable(bundleOption); 847 data.WriteInt32(notificationId); 848 data.WriteStrongParcelable(buttonOption); 849 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 850 EXPECT_EQ(ret, (int)ERR_OK); 851 } 852 853 /** 854 * @tc.name: HandleTriggerLocalLiveView03 855 * @tc.desc: Test HandleTriggerLocalLiveView succeeds. 856 * @tc.type: FUNC 857 * @tc.require: issueI5XQ4E 858 */ 859 HWTEST_F(AnsManagerStubTest, HandleTriggerLocalLiveView03, Function | SmallTest | Level1) 860 { 861 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_NOTIFICATION); 862 MessageParcel data; 863 MessageParcel reply; 864 MessageOption option = {MessageOption::TF_SYNC}; 865 866 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 867 int32_t notificationId = 1; 868 869 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 870 data.WriteStrongParcelable(bundleOption); 871 data.WriteInt32(notificationId); 872 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 873 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 874 } 875 876 /** 877 * @tc.name: HandleTriggerLocalLiveView04 878 * @tc.desc: Test HandleTriggerLocalLiveView succeeds. 879 * @tc.type: FUNC 880 * @tc.require: issueI5XQ4E 881 */ 882 HWTEST_F(AnsManagerStubTest, HandleTriggerLocalLiveView04, Function | SmallTest | Level1) 883 { 884 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_NOTIFICATION); 885 MessageParcel data; 886 MessageParcel reply; 887 MessageOption option = {MessageOption::TF_SYNC}; 888 889 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 890 891 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 892 data.WriteStrongParcelable(bundleOption); 893 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 894 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 895 } 896 897 /** 898 * @tc.name: HandleCanPublishAsBundle01 899 * @tc.desc: Test HandleCanPublishAsBundle succeeds. 900 * @tc.type: FUNC 901 * @tc.require: issueI5XQ4E 902 */ 903 HWTEST_F(AnsManagerStubTest, HandleCanPublishAsBundle01, Function | SmallTest | Level1) 904 { 905 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CAN_PUBLISH_AS_BUNDLE); 906 MessageParcel data; 907 MessageParcel reply; 908 MessageOption option = {MessageOption::TF_SYNC}; 909 910 std::string representativeBundle = "this is a representativeBundle"; 911 912 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 913 data.WriteString(representativeBundle); 914 915 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 916 EXPECT_EQ(ret, (int)NO_ERROR); 917 } 918 919 /** 920 * @tc.name: HandleCanPublishAsBundle02 921 * @tc.desc: Test if the representativeBundle in data is null. 922 * @tc.type: FUNC 923 * @tc.require: issueI5XQ4E 924 */ 925 HWTEST_F(AnsManagerStubTest, HandleCanPublishAsBundle02, Function | SmallTest | Level1) 926 { 927 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CAN_PUBLISH_AS_BUNDLE); 928 MessageParcel data; 929 MessageParcel reply; 930 MessageOption option = {MessageOption::TF_SYNC}; 931 932 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 933 934 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 935 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 936 } 937 938 /** 939 * @tc.name: HandlePublishAsBundle01 940 * @tc.desc: Test HandlePublishAsBundle succeeds. 941 * @tc.type: FUNC 942 * @tc.require: issueI5XQ4E 943 */ 944 HWTEST_F(AnsManagerStubTest, HandlePublishAsBundle01, Function | SmallTest | Level1) 945 { 946 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_AS_BUNDLE); 947 MessageParcel data; 948 MessageParcel reply; 949 MessageOption option = {MessageOption::TF_SYNC}; 950 951 sptr<NotificationRequest> notification = new NotificationRequest(); 952 notification->SetSlotType(NotificationConstant::SlotType::CONTENT_INFORMATION); 953 std::shared_ptr<NotificationLongTextContent> longTextContent = 954 std::make_shared<NotificationLongTextContent>("longtext"); 955 std::shared_ptr<NotificationContent> content2 = std::make_shared<NotificationContent>(longTextContent); 956 notification->SetContent(content2); 957 std::string representativeBundle = "this is a representativeBundle"; 958 959 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 960 data.WriteParcelable(notification); 961 data.WriteString(representativeBundle); 962 963 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 964 EXPECT_EQ(ret, (int)NO_ERROR); 965 } 966 967 /** 968 * @tc.name: HandlePublishAsBundle02 969 * @tc.desc: Test if the notification in data is null. 970 * @tc.type: FUNC 971 * @tc.require: issueI5XQ4E 972 */ 973 HWTEST_F(AnsManagerStubTest, HandlePublishAsBundle02, Function | SmallTest | Level1) 974 { 975 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_AS_BUNDLE); 976 MessageParcel data; 977 MessageParcel reply; 978 MessageOption option = {MessageOption::TF_SYNC}; 979 980 std::string representativeBundle = "this is a representativeBundle"; 981 982 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 983 data.WriteString(representativeBundle); 984 985 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 986 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 987 } 988 989 /** 990 * @tc.name: HandlePublishAsBundle03 991 * @tc.desc: Test if the representativeBundle in data is null. 992 * @tc.type: FUNC 993 * @tc.require: issueI5XQ4E 994 */ 995 HWTEST_F(AnsManagerStubTest, HandlePublishAsBundle03, Function | SmallTest | Level1) 996 { 997 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_AS_BUNDLE); 998 MessageParcel data; 999 MessageParcel reply; 1000 MessageOption option = {MessageOption::TF_SYNC}; 1001 1002 sptr<NotificationRequest> notification = new NotificationRequest(); 1003 1004 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1005 data.WriteParcelable(notification); 1006 1007 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1008 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1009 } 1010 1011 /** 1012 * @tc.name: HandleSetNotificationBadgeNum01 1013 * @tc.desc: Test HandleSetNotificationBadgeNum succeeds. 1014 * @tc.type: FUNC 1015 * @tc.require: issueI5XQ4E 1016 */ 1017 HWTEST_F(AnsManagerStubTest, HandleSetNotificationBadgeNum01, Function | SmallTest | Level1) 1018 { 1019 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_BADGE_NUM); 1020 MessageParcel data; 1021 MessageParcel reply; 1022 MessageOption option = {MessageOption::TF_SYNC}; 1023 1024 int32_t num = 4; 1025 1026 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1027 data.WriteInt32(num); 1028 1029 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1030 EXPECT_EQ(ret, (int)NO_ERROR); 1031 } 1032 1033 /** 1034 * @tc.name: HandleSetNotificationBadgeNum02 1035 * @tc.desc: Test if the num in data is null. 1036 * @tc.type: FUNC 1037 * @tc.require: issueI5XQ4E 1038 */ 1039 HWTEST_F(AnsManagerStubTest, HandleSetNotificationBadgeNum02, Function | SmallTest | Level1) 1040 { 1041 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_BADGE_NUM); 1042 MessageParcel data; 1043 MessageParcel reply; 1044 MessageOption option = {MessageOption::TF_SYNC}; 1045 1046 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1047 1048 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1049 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1050 } 1051 1052 /** 1053 * @tc.name: HandleGetBundleImportance01 1054 * @tc.desc: Test HandleGetBundleImportance succeeds. 1055 * @tc.type: FUNC 1056 * @tc.require: issueI5XQ4E 1057 */ 1058 HWTEST_F(AnsManagerStubTest, HandleGetBundleImportance01, Function | SmallTest | Level1) 1059 { 1060 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_BUNDLE_IMPORTANCE); 1061 MessageParcel data; 1062 MessageParcel reply; 1063 MessageOption option = {MessageOption::TF_SYNC}; 1064 1065 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1066 1067 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1068 EXPECT_EQ(ret, (int)NO_ERROR); 1069 } 1070 1071 /** 1072 * @tc.name: HandleSetDoNotDisturbDate01 1073 * @tc.desc: Test HandleSetDoNotDisturbDate succeeds. 1074 * @tc.type: FUNC 1075 * @tc.require: issueI5XQ4E 1076 */ 1077 HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDate01, Function | SmallTest | Level1) 1078 { 1079 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE); 1080 MessageParcel data; 1081 MessageParcel reply; 1082 MessageOption option = {MessageOption::TF_SYNC}; 1083 1084 sptr<NotificationDoNotDisturbDate> date = new NotificationDoNotDisturbDate(); 1085 1086 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1087 data.WriteParcelable(date); 1088 1089 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1090 EXPECT_EQ(ret, (int)NO_ERROR); 1091 } 1092 1093 /** 1094 * @tc.name: HandleSetDoNotDisturbDate02 1095 * @tc.desc: Test if the date in data is null.. 1096 * @tc.type: FUNC 1097 * @tc.require: issueI5XQ4E 1098 */ 1099 HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDate02, Function | SmallTest | Level1) 1100 { 1101 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE); 1102 MessageParcel data; 1103 MessageParcel reply; 1104 MessageOption option = {MessageOption::TF_SYNC}; 1105 1106 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1107 1108 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1109 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1110 } 1111 1112 /** 1113 * @tc.name: HandleGetDoNotDisturbDate01 1114 * @tc.desc: Test HandleGetDoNotDisturbDate succeeds. 1115 * @tc.type: FUNC 1116 * @tc.require: issueI5XQ4E 1117 */ 1118 HWTEST_F(AnsManagerStubTest, HandleGetDoNotDisturbDate01, Function | SmallTest | Level1) 1119 { 1120 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE); 1121 MessageParcel data; 1122 MessageParcel reply; 1123 MessageOption option = {MessageOption::TF_SYNC}; 1124 1125 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1126 1127 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1128 EXPECT_EQ(ret, (int)NO_ERROR); 1129 } 1130 1131 /** 1132 * @tc.name: HandleDoesSupportDoNotDisturbMode01 1133 * @tc.desc: Test HandleDoesSupportDoNotDisturbMode01 succeeds. 1134 * @tc.type: FUNC 1135 * @tc.require: issueI5XQ4E 1136 */ 1137 HWTEST_F(AnsManagerStubTest, HandleDoesSupportDoNotDisturbMode01, Function | SmallTest | Level1) 1138 { 1139 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DOES_SUPPORT_DO_NOT_DISTURB_MODE); 1140 MessageParcel data; 1141 MessageParcel reply; 1142 MessageOption option = {MessageOption::TF_SYNC}; 1143 1144 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1145 1146 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1147 EXPECT_EQ(ret, (int)NO_ERROR); 1148 } 1149 1150 /** 1151 * @tc.name: HandlePublishContinuousTaskNotification01 1152 * @tc.desc: Test HandlePublishContinuousTaskNotification succeeds. 1153 * @tc.type: FUNC 1154 * @tc.require: issueI5XQ4E 1155 */ 1156 HWTEST_F(AnsManagerStubTest, HandlePublishContinuousTaskNotification01, Function | SmallTest | Level1) 1157 { 1158 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_CONTINUOUS_TASK_NOTIFICATION); 1159 MessageParcel data; 1160 MessageParcel reply; 1161 MessageOption option = {MessageOption::TF_SYNC}; 1162 1163 sptr<NotificationRequest> request = new NotificationRequest(); 1164 request->SetSlotType(NotificationConstant::SlotType::CONTENT_INFORMATION); 1165 std::shared_ptr<NotificationLongTextContent> longTextContent = 1166 std::make_shared<NotificationLongTextContent>("longtext"); 1167 std::shared_ptr<NotificationContent> content2 = std::make_shared<NotificationContent>(longTextContent); 1168 request->SetContent(content2); 1169 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1170 data.WriteParcelable(request); 1171 1172 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1173 EXPECT_EQ(ret, (int)NO_ERROR); 1174 } 1175 1176 /** 1177 * @tc.name: HandlePublishContinuousTaskNotification02 1178 * @tc.desc: Test if the request in data is null. 1179 * @tc.type: FUNC 1180 * @tc.require: issueI5XQ4E 1181 */ 1182 HWTEST_F(AnsManagerStubTest, HandlePublishContinuousTaskNotification02, Function | SmallTest | Level1) 1183 { 1184 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::PUBLISH_CONTINUOUS_TASK_NOTIFICATION); 1185 MessageParcel data; 1186 MessageParcel reply; 1187 MessageOption option = {MessageOption::TF_SYNC}; 1188 1189 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1190 1191 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1192 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1193 } 1194 1195 /** 1196 * @tc.name: HandleCancelContinuousTaskNotification01 1197 * @tc.desc: Test HandleCancelContinuousTaskNotification succeeds. 1198 * @tc.type: FUNC 1199 * @tc.require: issueI5XQ4E 1200 */ 1201 HWTEST_F(AnsManagerStubTest, HandleCancelContinuousTaskNotification01, Function | SmallTest | Level1) 1202 { 1203 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_CONTINUOUS_TASK_NOTIFICATION); 1204 MessageParcel data; 1205 MessageParcel reply; 1206 MessageOption option = {MessageOption::TF_SYNC}; 1207 1208 std::string label = "this is a label"; 1209 int32_t notificationId = 3; 1210 1211 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1212 data.WriteString(label); 1213 data.WriteInt32(notificationId); 1214 1215 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1216 EXPECT_EQ(ret, (int)NO_ERROR); 1217 } 1218 1219 /** 1220 * @tc.name: HandleCancelContinuousTaskNotification02 1221 * @tc.desc: Test if the label in data is null. 1222 * @tc.type: FUNC 1223 * @tc.require: issueI5XQ4E 1224 */ 1225 HWTEST_F(AnsManagerStubTest, HandleCancelContinuousTaskNotification02, Function | SmallTest | Level1) 1226 { 1227 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_CONTINUOUS_TASK_NOTIFICATION); 1228 MessageParcel data; 1229 MessageParcel reply; 1230 MessageOption option = {MessageOption::TF_SYNC}; 1231 1232 int32_t notificationId = 3; 1233 1234 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1235 data.WriteInt32(notificationId); 1236 1237 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1238 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1239 } 1240 1241 /** 1242 * @tc.name: HandleCancelContinuousTaskNotification03 1243 * @tc.desc: Test if the notificationId in data is null. 1244 * @tc.type: FUNC 1245 * @tc.require: issueI5XQ4E 1246 */ 1247 HWTEST_F(AnsManagerStubTest, HandleCancelContinuousTaskNotification03, Function | SmallTest | Level1) 1248 { 1249 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_CONTINUOUS_TASK_NOTIFICATION); 1250 MessageParcel data; 1251 MessageParcel reply; 1252 MessageOption option = {MessageOption::TF_SYNC}; 1253 1254 std::string label = "this is a label"; 1255 1256 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1257 data.WriteString(label); 1258 1259 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1260 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1261 } 1262 1263 /** 1264 * @tc.name: HandleIsNotificationPolicyAccessGranted01 1265 * @tc.desc: Test HandleIsNotificationPolicyAccessGranted succeed. 1266 * @tc.type: FUNC 1267 * @tc.require: issueI5XQ4E 1268 */ 1269 HWTEST_F(AnsManagerStubTest, HandleIsNotificationPolicyAccessGranted01, Function | SmallTest | Level1) 1270 { 1271 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_NOTIFICATION_POLICY_ACCESS_GRANTED); 1272 MessageParcel data; 1273 MessageParcel reply; 1274 MessageOption option = {MessageOption::TF_SYNC}; 1275 1276 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1277 1278 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1279 EXPECT_EQ(ret, (int)NO_ERROR); 1280 } 1281 1282 /** 1283 * @tc.name: HandleRemoveNotification01 1284 * @tc.desc: Test HandleRemoveNotification succeed. 1285 * @tc.type: FUNC 1286 * @tc.require: issueI5XQ4E 1287 */ 1288 HWTEST_F(AnsManagerStubTest, HandleRemoveNotification01, Function | SmallTest | Level1) 1289 { 1290 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_NOTIFICATION); 1291 MessageParcel data; 1292 MessageParcel reply; 1293 MessageOption option = {MessageOption::TF_SYNC}; 1294 1295 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 1296 int32_t notificationId = 1; 1297 std::string label = "this is a label"; 1298 int32_t removeReason = 2; 1299 1300 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1301 data.WriteStrongParcelable(bundleOption); 1302 data.WriteInt32(notificationId); 1303 data.WriteString(label); 1304 data.WriteInt32(removeReason); 1305 1306 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1307 EXPECT_EQ(ret, (int)NO_ERROR); 1308 } 1309 1310 /** 1311 * @tc.name: HandleRemoveNotification02 1312 * @tc.desc: Test if the bundleOption in data is null. 1313 * @tc.type: FUNC 1314 * @tc.require: issueI5XQ4E 1315 */ 1316 HWTEST_F(AnsManagerStubTest, HandleRemoveNotification02, Function | SmallTest | Level1) 1317 { 1318 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_NOTIFICATION); 1319 MessageParcel data; 1320 MessageParcel reply; 1321 MessageOption option = {MessageOption::TF_SYNC}; 1322 1323 int32_t notificationId = 1; 1324 std::string label = "this is a label"; 1325 int32_t removeReason = 2; 1326 1327 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1328 data.WriteInt32(notificationId); 1329 data.WriteString(label); 1330 data.WriteInt32(removeReason); 1331 1332 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1333 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1334 } 1335 1336 /** 1337 * @tc.name: HandleRemoveNotification03 1338 * @tc.desc: Test if the notificationId in data is null. 1339 * @tc.type: FUNC 1340 * @tc.require: issueI5XQ4E 1341 */ 1342 HWTEST_F(AnsManagerStubTest, HandleRemoveNotification03, Function | SmallTest | Level1) 1343 { 1344 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_NOTIFICATION); 1345 MessageParcel data; 1346 MessageParcel reply; 1347 MessageOption option = {MessageOption::TF_SYNC}; 1348 1349 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 1350 std::string label = "this is a label"; 1351 int32_t removeReason = 2; 1352 1353 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1354 data.WriteStrongParcelable(bundleOption); 1355 data.WriteString(label); 1356 data.WriteInt32(removeReason); 1357 1358 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1359 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1360 } 1361 1362 /** 1363 * @tc.name: HandleRemoveNotification04 1364 * @tc.desc: Test if the label in data is null. 1365 * @tc.type: FUNC 1366 * @tc.require: issueI5XQ4E 1367 */ 1368 HWTEST_F(AnsManagerStubTest, HandleRemoveNotification04, Function | SmallTest | Level1) 1369 { 1370 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_NOTIFICATION); 1371 MessageParcel data; 1372 MessageParcel reply; 1373 MessageOption option = {MessageOption::TF_SYNC}; 1374 1375 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 1376 int32_t notificationId = 1; 1377 int32_t removeReason = 2; 1378 1379 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1380 data.WriteStrongParcelable(bundleOption); 1381 data.WriteInt32(notificationId); 1382 data.WriteInt32(removeReason); 1383 1384 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1385 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1386 } 1387 1388 /** 1389 * @tc.name: HandleRemoveNotification05 1390 * @tc.desc: Test if the removeReason in data is null. 1391 * @tc.type: FUNC 1392 * @tc.require: issueI5XQ4E 1393 */ 1394 HWTEST_F(AnsManagerStubTest, HandleRemoveNotification05, Function | SmallTest | Level1) 1395 { 1396 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_NOTIFICATION); 1397 MessageParcel data; 1398 MessageParcel reply; 1399 MessageOption option = {MessageOption::TF_SYNC}; 1400 1401 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 1402 int32_t notificationId = 1; 1403 std::string label = "this is a label"; 1404 1405 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1406 data.WriteStrongParcelable(bundleOption); 1407 data.WriteInt32(notificationId); 1408 data.WriteString(label); 1409 1410 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1411 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1412 } 1413 1414 /** 1415 * @tc.name: HandleRemoveAllNotifications01 1416 * @tc.desc: Test HandleRemoveAllNotifications succeed. 1417 * @tc.type: FUNC 1418 * @tc.require: issueI5XQ4E 1419 */ 1420 HWTEST_F(AnsManagerStubTest, HandleRemoveAllNotifications01, Function | SmallTest | Level1) 1421 { 1422 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_ALL_NOTIFICATIONS); 1423 MessageParcel data; 1424 MessageParcel reply; 1425 MessageOption option = {MessageOption::TF_SYNC}; 1426 1427 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 1428 1429 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1430 data.WriteStrongParcelable(bundleOption); 1431 1432 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1433 EXPECT_EQ(ret, (int)NO_ERROR); 1434 } 1435 1436 /** 1437 * @tc.name: HandleRemoveAllNotifications02 1438 * @tc.desc: Test if the bundleOption in data is null. 1439 * @tc.type: FUNC 1440 * @tc.require: issueI5XQ4E 1441 */ 1442 HWTEST_F(AnsManagerStubTest, HandleRemoveAllNotifications02, Function | SmallTest | Level1) 1443 { 1444 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_ALL_NOTIFICATIONS); 1445 MessageParcel data; 1446 MessageParcel reply; 1447 MessageOption option = {MessageOption::TF_SYNC}; 1448 1449 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1450 1451 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1452 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1453 } 1454 1455 /** 1456 * @tc.name: HandleDelete01 1457 * @tc.desc: Test HandleDelete succeed. 1458 * @tc.type: FUNC 1459 * @tc.require: issueI5XQ4E 1460 */ 1461 HWTEST_F(AnsManagerStubTest, HandleDelete01, Function | SmallTest | Level1) 1462 { 1463 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DELETE_NOTIFICATION); 1464 MessageParcel data; 1465 MessageParcel reply; 1466 MessageOption option = {MessageOption::TF_SYNC}; 1467 1468 std::string key = "this is a key"; 1469 int32_t removeReason = 2; 1470 1471 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1472 data.WriteString(key); 1473 data.WriteInt32(removeReason); 1474 1475 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1476 EXPECT_EQ(ret, (int)NO_ERROR); 1477 } 1478 1479 /** 1480 * @tc.name: HandleDelete02 1481 * @tc.desc: Test if the key in data is null. 1482 * @tc.type: FUNC 1483 * @tc.require: issueI5XQ4E 1484 */ 1485 HWTEST_F(AnsManagerStubTest, HandleDelete02, Function | SmallTest | Level1) 1486 { 1487 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DELETE_NOTIFICATION); 1488 MessageParcel data; 1489 MessageParcel reply; 1490 MessageOption option = {MessageOption::TF_SYNC}; 1491 1492 int32_t removeReason = 2; 1493 1494 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1495 data.WriteInt32(removeReason); 1496 1497 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1498 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1499 } 1500 1501 /** 1502 * @tc.name: HandleDelete03 1503 * @tc.desc: Test if the removeReason in data is null. 1504 * @tc.type: FUNC 1505 * @tc.require: issueI5XQ4E 1506 */ 1507 HWTEST_F(AnsManagerStubTest, HandleDelete03, Function | SmallTest | Level1) 1508 { 1509 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DELETE_NOTIFICATION); 1510 MessageParcel data; 1511 MessageParcel reply; 1512 MessageOption option = {MessageOption::TF_SYNC}; 1513 1514 std::string key = "this is a key"; 1515 1516 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1517 data.WriteString(key); 1518 1519 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1520 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1521 } 1522 1523 /** 1524 * @tc.name: HandleDeleteByBundle01 1525 * @tc.desc: Test HandleDeleteByBundle succeed. 1526 * @tc.type: FUNC 1527 * @tc.require: issueI5XQ4E 1528 */ 1529 HWTEST_F(AnsManagerStubTest, HandleDeleteByBundle01, Function | SmallTest | Level1) 1530 { 1531 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DELETE_NOTIFICATION_BY_BUNDLE); 1532 MessageParcel data; 1533 MessageParcel reply; 1534 MessageOption option = {MessageOption::TF_SYNC}; 1535 1536 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 1537 1538 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1539 data.WriteStrongParcelable(bundleOption); 1540 1541 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1542 EXPECT_EQ(ret, (int)NO_ERROR); 1543 } 1544 1545 /** 1546 * @tc.name: HandleDeleteByBundle02 1547 * @tc.desc: Test if the bundleOption in data is null. 1548 * @tc.type: FUNC 1549 * @tc.require: issueI5XQ4E 1550 */ 1551 HWTEST_F(AnsManagerStubTest, HandleDeleteByBundle02, Function | SmallTest | Level1) 1552 { 1553 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DELETE_NOTIFICATION_BY_BUNDLE); 1554 MessageParcel data; 1555 MessageParcel reply; 1556 MessageOption option = {MessageOption::TF_SYNC}; 1557 1558 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1559 1560 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1561 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1562 } 1563 1564 /** 1565 * @tc.name: HandleDeleteAll01 1566 * @tc.desc: Test HandleDeleteAll succeed. 1567 * @tc.type: FUNC 1568 * @tc.require: issueI5XQ4E 1569 */ 1570 HWTEST_F(AnsManagerStubTest, HandleDeleteAll01, Function | SmallTest | Level1) 1571 { 1572 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS); 1573 MessageParcel data; 1574 MessageParcel reply; 1575 MessageOption option = {MessageOption::TF_SYNC}; 1576 1577 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1578 1579 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1580 EXPECT_EQ(ret, (int)NO_ERROR); 1581 } 1582 1583 /** 1584 * @tc.name: HandleGetSlotsByBundle01 1585 * @tc.desc: Test HandleGetSlotsByBundle succeed. 1586 * @tc.type: FUNC 1587 * @tc.require: issueI5XQ4E 1588 */ 1589 HWTEST_F(AnsManagerStubTest, HandleGetSlotsByBundle01, Function | SmallTest | Level1) 1590 { 1591 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOTS_BY_BUNDLE); 1592 MessageParcel data; 1593 MessageParcel reply; 1594 MessageOption option = {MessageOption::TF_SYNC}; 1595 1596 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 1597 1598 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1599 data.WriteParcelable(bundleOption); 1600 1601 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1602 EXPECT_EQ(ret, (int)NO_ERROR); 1603 } 1604 1605 /** 1606 * @tc.name: HandleGetSlotsByBundle02 1607 * @tc.desc: Test if the bundleOption in data is null. 1608 * @tc.type: FUNC 1609 * @tc.require: issueI5XQ4E 1610 */ 1611 HWTEST_F(AnsManagerStubTest, HandleGetSlotsByBundle02, Function | SmallTest | Level1) 1612 { 1613 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOTS_BY_BUNDLE); 1614 MessageParcel data; 1615 MessageParcel reply; 1616 MessageOption option = {MessageOption::TF_SYNC}; 1617 1618 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1619 1620 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1621 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1622 } 1623 1624 /** 1625 * @tc.name: HandleUpdateSlots01 1626 * @tc.desc: Test HandleUpdateSlots succeed. 1627 * @tc.type: FUNC 1628 * @tc.require: issueI5XQ4E 1629 */ 1630 HWTEST_F(AnsManagerStubTest, HandleUpdateSlots01, Function | SmallTest | Level1) 1631 { 1632 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::UPDATE_SLOTS); 1633 MessageParcel data; 1634 MessageParcel reply; 1635 MessageOption option = {MessageOption::TF_SYNC}; 1636 1637 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 1638 int32_t infoSize = 3; 1639 sptr<NotificationSlot> slot1 = new NotificationSlot(); 1640 sptr<NotificationSlot> slot2 = new NotificationSlot(); 1641 sptr<NotificationSlot> slot3 = new NotificationSlot(); 1642 1643 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1644 data.WriteInt32(infoSize); 1645 data.WriteStrongParcelable(slot1); 1646 data.WriteStrongParcelable(slot2); 1647 data.WriteStrongParcelable(slot3); 1648 1649 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1650 EXPECT_EQ(ret, (int)NO_ERROR); 1651 } 1652 1653 /** 1654 * @tc.name: HandleUpdateSlots02 1655 * @tc.desc: Test if the StrongParcelable:info in data is null. 1656 * @tc.type: FUNC 1657 * @tc.require: issueI5XQ4E 1658 */ 1659 HWTEST_F(AnsManagerStubTest, HandleUpdateSlots02, Function | SmallTest | Level1) 1660 { 1661 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::UPDATE_SLOTS); 1662 MessageParcel data; 1663 MessageParcel reply; 1664 MessageOption option = {MessageOption::TF_SYNC}; 1665 1666 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 1667 int32_t infoSize = 3; 1668 1669 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1670 data.WriteInt32(infoSize); 1671 1672 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1673 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1674 } 1675 1676 /** 1677 * @tc.name: HandleUpdateSlots03 1678 * @tc.desc: Test if the StrongParcelable:info in data is null. 1679 * @tc.type: FUNC 1680 * @tc.require: issueI5XQ4E 1681 */ 1682 HWTEST_F(AnsManagerStubTest, HandleUpdateSlots03, Function | SmallTest | Level1) 1683 { 1684 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::UPDATE_SLOTS); 1685 MessageParcel data; 1686 MessageParcel reply; 1687 MessageOption option = {MessageOption::TF_SYNC}; 1688 1689 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1690 1691 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1692 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1693 } 1694 1695 /** 1696 * @tc.name: HandleRequestEnableNotification01 1697 * @tc.desc: Test HandleRequestEnableNotification succeed. 1698 * @tc.type: FUNC 1699 * @tc.require: issueI5XQ4E 1700 */ 1701 HWTEST_F(AnsManagerStubTest, HandleRequestEnableNotification01, Function | SmallTest | Level1) 1702 { 1703 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION); 1704 MessageParcel data; 1705 MessageParcel reply; 1706 MessageOption option = {MessageOption::TF_SYNC}; 1707 std::string deviceId = "this is a deviceId"; 1708 sptr<AnsDialogHostClient> callback = new AnsDialogHostClient(); 1709 1710 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1711 data.WriteString(deviceId); 1712 data.WriteRemoteObject(callback->AsObject()); 1713 data.WriteBool(false); 1714 1715 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1716 EXPECT_EQ(ret, (int)ERR_OK); 1717 } 1718 1719 /** 1720 * @tc.name: HandleRequestEnableNotification03 1721 * @tc.desc: Test HandleRequestEnableNotification succeed. 1722 * @tc.type: FUNC 1723 * @tc.require: issueI5XQ4E 1724 */ 1725 HWTEST_F(AnsManagerStubTest, HandleRequestEnableNotification03, Function | SmallTest | Level1) 1726 { 1727 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION); 1728 MessageParcel data; 1729 MessageParcel reply; 1730 MessageOption option = {MessageOption::TF_SYNC}; 1731 std::string deviceId = "this is a deviceId"; 1732 const sptr<AnsDialogHostClient> callback = new AnsDialogHostClient(); 1733 1734 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1735 data.WriteString(deviceId); 1736 data.WriteRemoteObject(callback->AsObject()); 1737 1738 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1739 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1740 } 1741 1742 /** 1743 * @tc.name: HandleRequestEnableNotification04 1744 * @tc.desc: Test HandleRequestEnableNotification succeed. 1745 * @tc.type: FUNC 1746 * @tc.require: issueI5XQ4E 1747 */ 1748 HWTEST_F(AnsManagerStubTest, HandleRequestEnableNotification04, Function | SmallTest | Level1) 1749 { 1750 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION); 1751 MessageParcel data; 1752 MessageParcel reply; 1753 MessageOption option = {MessageOption::TF_SYNC}; 1754 std::string deviceId = "this is a deviceId"; 1755 1756 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1757 data.WriteString(deviceId); 1758 1759 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1760 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1761 } 1762 1763 /** 1764 * @tc.name: HandleRequestEnableNotification02 1765 * @tc.desc: Test if the deviceId in data is null. 1766 * @tc.type: FUNC 1767 * @tc.require: issueI5XQ4E 1768 */ 1769 HWTEST_F(AnsManagerStubTest, HandleRequestEnableNotification02, Function | SmallTest | Level1) 1770 { 1771 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION); 1772 MessageParcel data; 1773 MessageParcel reply; 1774 MessageOption option = {MessageOption::TF_SYNC}; 1775 1776 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1777 1778 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1779 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1780 } 1781 1782 /** 1783 * @tc.name: HandleSubscribeSelf01 1784 * @tc.desc: Test SubscribeSelf. 1785 * @tc.type: FUNC 1786 * @tc.require: issueI5XQ4E 1787 */ 1788 HWTEST_F(AnsManagerStubTest, HandleSubscribeSelf01, Function | SmallTest | Level1) 1789 { 1790 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION_SELF); 1791 MessageParcel data; 1792 MessageParcel reply; 1793 MessageOption option = {MessageOption::TF_SYNC}; 1794 1795 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1796 1797 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1798 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1799 } 1800 1801 /** 1802 * @tc.name: HandleSubscribeLocalLiveView01 1803 * @tc.desc: Test HandleSubscribeLocalLiveView. 1804 * @tc.type: FUNC 1805 * @tc.require: issueI5XQ4E 1806 */ 1807 HWTEST_F(AnsManagerStubTest, HandleSubscribeLocalLiveView01, Function | SmallTest | Level1) 1808 { 1809 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SUBSCRIBE_LOCAL_LIVE_VIEW_NOTIFICATION); 1810 MessageParcel data; 1811 MessageParcel reply; 1812 MessageOption option = {MessageOption::TF_SYNC}; 1813 sptr<NotificationSubscribeInfo> info = new NotificationSubscribeInfo(); 1814 1815 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1816 data.WriteBool(true); 1817 data.WriteStrongParcelable(info); 1818 data.WriteBool(true); 1819 1820 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1821 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1822 } 1823 1824 /** 1825 * @tc.name: HandleSubscribeLocalLiveView02 1826 * @tc.desc: Test HandleSubscribeLocalLiveView. 1827 * @tc.type: FUNC 1828 * @tc.require: issueI5XQ4E 1829 */ 1830 HWTEST_F(AnsManagerStubTest, HandleSubscribeLocalLiveView02, Function | SmallTest | Level1) 1831 { 1832 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SUBSCRIBE_LOCAL_LIVE_VIEW_NOTIFICATION); 1833 MessageParcel data; 1834 MessageParcel reply; 1835 MessageOption option = {MessageOption::TF_SYNC}; 1836 sptr<NotificationSubscribeInfo> info = nullptr; 1837 1838 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1839 data.WriteBool(true); 1840 data.WriteStrongParcelable(info); 1841 1842 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1843 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1844 } 1845 1846 1847 /** 1848 * @tc.name: HandleSetNotificationsEnabledForBundle01 1849 * @tc.desc: Test HandleSetNotificationsEnabledForBundle succeed. 1850 * @tc.type: FUNC 1851 * @tc.require: issueI5XQ4E 1852 */ 1853 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForBundle01, Function | SmallTest | Level1) 1854 { 1855 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_BUNDLE); 1856 MessageParcel data; 1857 MessageParcel reply; 1858 MessageOption option = {MessageOption::TF_SYNC}; 1859 1860 std::string deviceId = "this is a deviceId"; 1861 bool enabled = false; 1862 1863 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1864 data.WriteString(deviceId); 1865 data.WriteBool(enabled); 1866 1867 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1868 EXPECT_EQ(ret, (int)NO_ERROR); 1869 } 1870 1871 /** 1872 * @tc.name: HandleSetNotificationsEnabledForBundle02 1873 * @tc.desc: Test if the deviceId in data is null. 1874 * @tc.type: FUNC 1875 * @tc.require: issueI5XQ4E 1876 */ 1877 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForBundle02, Function | SmallTest | Level1) 1878 { 1879 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_BUNDLE); 1880 MessageParcel data; 1881 MessageParcel reply; 1882 MessageOption option = {MessageOption::TF_SYNC}; 1883 1884 bool enabled = false; 1885 1886 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1887 data.WriteBool(enabled); 1888 1889 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1890 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1891 } 1892 1893 /** 1894 * @tc.name: HandleSetNotificationsEnabledForBundle03 1895 * @tc.desc: Test if the enabled in data is null. 1896 * @tc.type: FUNC 1897 * @tc.require: issueI5XQ4E 1898 */ 1899 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForBundle03, Function | SmallTest | Level1) 1900 { 1901 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_BUNDLE); 1902 MessageParcel data; 1903 MessageParcel reply; 1904 MessageOption option = {MessageOption::TF_SYNC}; 1905 1906 std::string deviceId = "this is a deviceId"; 1907 1908 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1909 data.WriteString(deviceId); 1910 1911 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1912 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1913 } 1914 1915 /** 1916 * @tc.name: HandleSetNotificationsEnabledForAllBundles01 1917 * @tc.desc: Test HandleSetNotificationsEnabledForAllBundles succeed. 1918 * @tc.type: FUNC 1919 * @tc.require: issueI5XQ4E 1920 */ 1921 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForAllBundles01, Function | SmallTest | Level1) 1922 { 1923 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE); 1924 MessageParcel data; 1925 MessageParcel reply; 1926 MessageOption option = {MessageOption::TF_SYNC}; 1927 1928 std::string deviceId = "this is a deviceId"; 1929 bool enabled = true; 1930 1931 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1932 data.WriteString(deviceId); 1933 data.WriteBool(enabled); 1934 1935 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1936 EXPECT_EQ(ret, (int)NO_ERROR); 1937 } 1938 1939 /** 1940 * @tc.name: HandleSetNotificationsEnabledForAllBundles02 1941 * @tc.desc: Test if the deviceId in data is null. 1942 * @tc.type: FUNC 1943 * @tc.require: issueI5XQ4E 1944 */ 1945 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForAllBundles02, Function | SmallTest | Level1) 1946 { 1947 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE); 1948 MessageParcel data; 1949 MessageParcel reply; 1950 MessageOption option = {MessageOption::TF_SYNC}; 1951 1952 bool enabled = true; 1953 1954 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1955 data.WriteBool(enabled); 1956 1957 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1958 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1959 } 1960 1961 /** 1962 * @tc.name: HandleSetNotificationsEnabledForAllBundles03 1963 * @tc.desc: Test if the enabled in data is null. 1964 * @tc.type: FUNC 1965 * @tc.require: issueI5XQ4E 1966 */ 1967 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForAllBundles03, Function | SmallTest | Level1) 1968 { 1969 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE); 1970 MessageParcel data; 1971 MessageParcel reply; 1972 MessageOption option = {MessageOption::TF_SYNC}; 1973 1974 std::string deviceId = "this is a deviceId"; 1975 1976 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 1977 data.WriteString(deviceId); 1978 1979 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 1980 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 1981 } 1982 1983 /** 1984 * @tc.name: HandleSetNotificationsEnabledForSpecialBundle01 1985 * @tc.desc: Test HandleSetNotificationsEnabledForSpecialBundle succeed. 1986 * @tc.type: FUNC 1987 * @tc.require: issueI5XQ4E 1988 */ 1989 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle01, Function | SmallTest | Level1) 1990 { 1991 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); 1992 MessageParcel data; 1993 MessageParcel reply; 1994 MessageOption option = {MessageOption::TF_SYNC}; 1995 1996 std::string deviceId = "this is a deviceId"; 1997 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 1998 bool enabled = true; 1999 2000 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2001 data.WriteString(deviceId); 2002 data.WriteParcelable(bundleOption); 2003 data.WriteBool(enabled); 2004 2005 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2006 EXPECT_EQ(ret, (int)NO_ERROR); 2007 } 2008 2009 /** 2010 * @tc.name: HandleSetNotificationsEnabledForSpecialBundle02 2011 * @tc.desc: Test if the deviceId in data is null. 2012 * @tc.type: FUNC 2013 * @tc.require: issueI5XQ4E 2014 */ 2015 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle02, Function | SmallTest | Level1) 2016 { 2017 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); 2018 MessageParcel data; 2019 MessageParcel reply; 2020 MessageOption option = {MessageOption::TF_SYNC}; 2021 2022 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2023 bool enabled = true; 2024 2025 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2026 data.WriteParcelable(bundleOption); 2027 data.WriteBool(enabled); 2028 2029 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2030 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2031 } 2032 2033 /** 2034 * @tc.name: HandleSetNotificationsEnabledForSpecialBundle03 2035 * @tc.desc: Test if the bundleOption in data is null. 2036 * @tc.type: FUNC 2037 * @tc.require: issueI5XQ4E 2038 */ 2039 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle03, Function | SmallTest | Level1) 2040 { 2041 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); 2042 MessageParcel data; 2043 MessageParcel reply; 2044 MessageOption option = {MessageOption::TF_SYNC}; 2045 2046 std::string deviceId = "this is a deviceId"; 2047 bool enabled = true; 2048 2049 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2050 data.WriteString(deviceId); 2051 data.WriteBool(enabled); 2052 2053 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2054 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2055 } 2056 2057 /** 2058 * @tc.name: HandleSetNotificationsEnabledForSpecialBundle04 2059 * @tc.desc: Test if the enabled in data is null. 2060 * @tc.type: FUNC 2061 * @tc.require: issueI5XQ4E 2062 */ 2063 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle04, Function | SmallTest | Level1) 2064 { 2065 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); 2066 MessageParcel data; 2067 MessageParcel reply; 2068 MessageOption option = {MessageOption::TF_SYNC}; 2069 2070 std::string deviceId = "this is a deviceId"; 2071 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2072 2073 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2074 data.WriteString(deviceId); 2075 data.WriteParcelable(bundleOption); 2076 2077 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2078 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2079 } 2080 2081 /** 2082 * @tc.name: HandleSetShowBadgeEnabledForBundle01 2083 * @tc.desc: Test HandleSetShowBadgeEnabledForBundle succeed. 2084 * @tc.type: FUNC 2085 * @tc.require: issueI5XQ4E 2086 */ 2087 HWTEST_F(AnsManagerStubTest, HandleSetShowBadgeEnabledForBundle01, Function | SmallTest | Level1) 2088 { 2089 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE); 2090 MessageParcel data; 2091 MessageParcel reply; 2092 MessageOption option = {MessageOption::TF_SYNC}; 2093 2094 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2095 bool enabled = true; 2096 2097 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2098 data.WriteParcelable(bundleOption); 2099 data.WriteBool(enabled); 2100 2101 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2102 EXPECT_EQ(ret, (int)NO_ERROR); 2103 } 2104 2105 /** 2106 * @tc.name: HandleSetShowBadgeEnabledForBundle02 2107 * @tc.desc: Test if the bundleOption in data is null. 2108 * @tc.type: FUNC 2109 * @tc.require: issueI5XQ4E 2110 */ 2111 HWTEST_F(AnsManagerStubTest, HandleSetShowBadgeEnabledForBundle02, Function | SmallTest | Level1) 2112 { 2113 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE); 2114 MessageParcel data; 2115 MessageParcel reply; 2116 MessageOption option = {MessageOption::TF_SYNC}; 2117 2118 bool enabled = true; 2119 2120 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2121 data.WriteBool(enabled); 2122 2123 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2124 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2125 } 2126 2127 /** 2128 * @tc.name: HandleSetShowBadgeEnabledForBundle03 2129 * @tc.desc: Test if the enabled in data is null. 2130 * @tc.type: FUNC 2131 * @tc.require: issueI5XQ4E 2132 */ 2133 HWTEST_F(AnsManagerStubTest, HandleSetShowBadgeEnabledForBundle03, Function | SmallTest | Level1) 2134 { 2135 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE); 2136 MessageParcel data; 2137 MessageParcel reply; 2138 MessageOption option = {MessageOption::TF_SYNC}; 2139 2140 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2141 2142 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2143 data.WriteParcelable(bundleOption); 2144 2145 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2146 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2147 } 2148 2149 /** 2150 * @tc.name: HandleAddSlots01 2151 * @tc.desc: Test if the slots in data is null. 2152 * @tc.type: FUNC 2153 * @tc.require: issueI620XB 2154 */ 2155 HWTEST_F(AnsManagerStubTest, HandleAddSlots01, Function | SmallTest | Level1) 2156 { 2157 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::ADD_SLOTS); 2158 MessageParcel data; 2159 MessageParcel reply; 2160 MessageOption option = {MessageOption::TF_SYNC}; 2161 2162 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2163 2164 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2165 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2166 } 2167 2168 /** 2169 * @tc.name: HandleAddSlots02 2170 * @tc.desc: Test if the result in data is null. 2171 * @tc.type: FUNC 2172 * @tc.require: issueI620XB 2173 */ 2174 HWTEST_F(AnsManagerStubTest, HandleAddSlots02, Function | SmallTest | Level1) 2175 { 2176 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::ADD_SLOTS); 2177 MessageParcel data; 2178 MessageParcel reply; 2179 MessageOption option = {MessageOption::TF_SYNC}; 2180 2181 std::vector<sptr<NotificationSlot>> slots; 2182 sptr<NotificationSlot> slot = new NotificationSlot(); 2183 slots.emplace_back(slot); 2184 2185 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2186 ErrCode result = ansManagerStub_->AddSlots(slots); 2187 ansManagerStub_->WriteParcelableVector(slots, reply, result); 2188 2189 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2190 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2191 } 2192 2193 /** 2194 * @tc.name: HandleGetSlots01 2195 * @tc.desc: Test HandleGetSlots succeed. 2196 * @tc.type: FUNC 2197 * @tc.require: issueI620XB 2198 */ 2199 HWTEST_F(AnsManagerStubTest, HandleGetSlots01, Function | SmallTest | Level1) 2200 { 2201 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOTS); 2202 MessageParcel data; 2203 MessageParcel reply; 2204 MessageOption option = {MessageOption::TF_SYNC}; 2205 2206 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2207 2208 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2209 EXPECT_EQ(ret, (int)ERR_OK); 2210 } 2211 2212 /** 2213 * @tc.name: HandleGetSpecialActiveNotifications01 2214 * @tc.desc: Test HandleGetSpecialActiveNotifications succeed. 2215 * @tc.type: FUNC 2216 * @tc.require: issueI620XB 2217 */ 2218 HWTEST_F(AnsManagerStubTest, HandleGetSpecialActiveNotifications01, Function | SmallTest | Level1) 2219 { 2220 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SPECIAL_ACTIVE_NOTIFICATIONS); 2221 MessageParcel data; 2222 MessageParcel reply; 2223 MessageOption option = {MessageOption::TF_SYNC}; 2224 2225 std::vector<std::string> key; 2226 2227 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2228 data.WriteStringVector(key); 2229 2230 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2231 EXPECT_EQ(ret, (int)ERR_OK); 2232 } 2233 2234 /** 2235 * @tc.name: HandleGetShowBadgeEnabledForBundle01 2236 * @tc.desc: Test HandleGetShowBadgeEnabledForBundle succeed. 2237 * @tc.type: FUNC 2238 * @tc.require: issueI620XB 2239 */ 2240 HWTEST_F(AnsManagerStubTest, HandleGetShowBadgeEnabledForBundle01, Function | SmallTest | Level1) 2241 { 2242 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED_FOR_BUNDLE); 2243 MessageParcel data; 2244 MessageParcel reply; 2245 MessageOption option = {MessageOption::TF_SYNC}; 2246 2247 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2248 bool enabled = true; 2249 2250 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2251 data.WriteParcelable(bundleOption); 2252 data.WriteBool(enabled); 2253 2254 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2255 EXPECT_EQ(ret, (int)ERR_OK); 2256 } 2257 2258 /** 2259 * @tc.name: HandleGetShowBadgeEnabledForBundle02 2260 * @tc.desc: Test if the bundleOption in data is null. 2261 * @tc.type: FUNC 2262 * @tc.require: issueI620XB 2263 */ 2264 HWTEST_F(AnsManagerStubTest, HandleGetShowBadgeEnabledForBundle02, Function | SmallTest | Level1) 2265 { 2266 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED_FOR_BUNDLE); 2267 MessageParcel data; 2268 MessageParcel reply; 2269 MessageOption option = {MessageOption::TF_SYNC}; 2270 2271 bool enabled = true; 2272 2273 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2274 data.WriteBool(enabled); 2275 2276 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2277 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2278 } 2279 2280 /** 2281 * @tc.name: HandleGetShowBadgeEnabledForBundle03 2282 * @tc.desc: Test if the enabled in data is null. 2283 * @tc.type: FUNC 2284 * @tc.require: issueI620XB 2285 */ 2286 HWTEST_F(AnsManagerStubTest, HandleGetShowBadgeEnabledForBundle03, Function | SmallTest | Level1) 2287 { 2288 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED_FOR_BUNDLE); 2289 MessageParcel data; 2290 MessageParcel reply; 2291 MessageOption option = {MessageOption::TF_SYNC}; 2292 2293 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2294 2295 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2296 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2297 } 2298 2299 /** 2300 * @tc.name: HandleGetShowBadgeEnabled01 2301 * @tc.desc: Test HandleGetShowBadgeEnabled succeed. 2302 * @tc.type: FUNC 2303 * @tc.require: issueI620XB 2304 */ 2305 HWTEST_F(AnsManagerStubTest, HandleGetShowBadgeEnabled01, Function | SmallTest | Level1) 2306 { 2307 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED); 2308 MessageParcel data; 2309 MessageParcel reply; 2310 MessageOption option = {MessageOption::TF_SYNC}; 2311 2312 bool enabled = true; 2313 2314 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2315 data.WriteBool(enabled); 2316 2317 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2318 EXPECT_EQ(ret, (int)ERR_OK); 2319 } 2320 2321 /** 2322 * @tc.name: HandleSubscribe01 2323 * @tc.desc: Test HandleSubscribe succeed. 2324 * @tc.type: FUNC 2325 * @tc.require: issueI620XB 2326 */ 2327 HWTEST_F(AnsManagerStubTest, HandleSubscribe01, Function | SmallTest | Level1) 2328 { 2329 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); 2330 MessageParcel parcels; 2331 MessageParcel reply; 2332 MessageOption option = {MessageOption::TF_SYNC}; 2333 2334 sptr<IRemoteObject> subscriber; 2335 bool subcribeInfo = true; 2336 sptr<NotificationSubscribeInfo> info = new NotificationSubscribeInfo(); 2337 2338 parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2339 parcels.WriteParcelable(subscriber); 2340 parcels.WriteBool(subcribeInfo); 2341 parcels.WriteParcelable(info); 2342 2343 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); 2344 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2345 } 2346 2347 /** 2348 * @tc.name: HandleSubscribe02 2349 * @tc.desc: Test if the subcribeInfo in data is null. 2350 * @tc.type: FUNC 2351 * @tc.require: issueI620XB 2352 */ 2353 HWTEST_F(AnsManagerStubTest, HandleSubscribe02, Function | SmallTest | Level1) 2354 { 2355 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); 2356 MessageParcel parcels; 2357 MessageParcel reply; 2358 MessageOption option = {MessageOption::TF_SYNC}; 2359 2360 sptr<IRemoteObject> subscriber; 2361 sptr<NotificationSubscribeInfo> info = new NotificationSubscribeInfo(); 2362 2363 parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2364 parcels.WriteRemoteObject(subscriber); 2365 parcels.WriteParcelable(info); 2366 2367 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); 2368 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2369 } 2370 2371 /** 2372 * @tc.name: HandleSubscribe03 2373 * @tc.desc: Test if the info in parcels is null. 2374 * @tc.type: FUNC 2375 * @tc.require: issueI620XB 2376 */ 2377 HWTEST_F(AnsManagerStubTest, HandleSubscribe03, Function | SmallTest | Level1) 2378 { 2379 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); 2380 MessageParcel parcels; 2381 MessageParcel reply; 2382 MessageOption option = {MessageOption::TF_SYNC}; 2383 2384 sptr<IRemoteObject> subscriber; 2385 bool subcribeInfo = true; 2386 2387 parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2388 parcels.WriteParcelable(subscriber); 2389 parcels.WriteBool(subcribeInfo); 2390 2391 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); 2392 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2393 } 2394 2395 /** 2396 * @tc.name: HandleSubscribe04 2397 * @tc.desc: Test if the subscriber in parcel is null. 2398 * @tc.type: FUNC 2399 * @tc.require: issueI620XB 2400 */ 2401 HWTEST_F(AnsManagerStubTest, HandleSubscribe04, Function | SmallTest | Level1) 2402 { 2403 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); 2404 MessageParcel parcels; 2405 MessageParcel reply; 2406 MessageOption option = {MessageOption::TF_SYNC}; 2407 2408 bool subcribeInfo = true; 2409 sptr<NotificationSubscribeInfo> info = new NotificationSubscribeInfo(); 2410 2411 parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2412 parcels.WriteBool(subcribeInfo); 2413 parcels.WriteParcelable(info); 2414 2415 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); 2416 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2417 } 2418 2419 /** 2420 * @tc.name: HandleUnsubscribe01 2421 * @tc.desc: Test HandleUnsubscribe succeed. 2422 * @tc.type: FUNC 2423 * @tc.require: issueI620XB 2424 */ 2425 HWTEST_F(AnsManagerStubTest, HandleUnsubscribe01, Function | SmallTest | Level1) 2426 { 2427 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION); 2428 MessageParcel data; 2429 MessageParcel reply; 2430 MessageOption option = {MessageOption::TF_SYNC}; 2431 bool subcribeInfo = true; 2432 sptr<NotificationSubscribeInfo> info = new NotificationSubscribeInfo(); 2433 2434 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2435 data.WriteParcelable(info); 2436 data.WriteBool(subcribeInfo); 2437 data.WriteParcelable(info); 2438 2439 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2440 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2441 } 2442 2443 /** 2444 * @tc.name: HandleUnsubscribe02 2445 * @tc.desc: Test if the subcribeInfo in data is null. 2446 * @tc.type: FUNC 2447 * @tc.require: issueI620XB 2448 */ 2449 HWTEST_F(AnsManagerStubTest, HandleUnsubscribe02, Function | SmallTest | Level1) 2450 { 2451 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION); 2452 MessageParcel data; 2453 MessageParcel reply; 2454 MessageOption option = {MessageOption::TF_SYNC}; 2455 2456 sptr<IRemoteObject> subscriber; 2457 sptr<NotificationSubscribeInfo> info = new NotificationSubscribeInfo(); 2458 2459 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2460 data.WriteRemoteObject(subscriber); 2461 data.WriteParcelable(info); 2462 2463 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2464 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2465 } 2466 2467 /** 2468 * @tc.name: HandleUnsubscribe03 2469 * @tc.desc: Test if the info in data is null. 2470 * @tc.type: FUNC 2471 * @tc.require: issueI620XB 2472 */ 2473 HWTEST_F(AnsManagerStubTest, HandleUnsubscribe03, Function | SmallTest | Level1) 2474 { 2475 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION); 2476 MessageParcel data; 2477 MessageParcel reply; 2478 MessageOption option = {MessageOption::TF_SYNC}; 2479 2480 sptr<IRemoteObject> subscriber; 2481 bool subcribeInfo = true; 2482 2483 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2484 data.WriteParcelable(subscriber); 2485 data.WriteBool(subcribeInfo); 2486 2487 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2488 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2489 } 2490 2491 /** 2492 * @tc.name: HandleUnsubscribe04 2493 * @tc.desc: Test if the subscriber in data is null. 2494 * @tc.type: FUNC 2495 * @tc.require: issueI620XB 2496 */ 2497 HWTEST_F(AnsManagerStubTest, HandleUnsubscribe04, Function | SmallTest | Level1) 2498 { 2499 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION); 2500 MessageParcel data; 2501 MessageParcel reply; 2502 MessageOption option = {MessageOption::TF_SYNC}; 2503 2504 bool subcribeInfo = true; 2505 sptr<NotificationSubscribeInfo> info = new NotificationSubscribeInfo(); 2506 2507 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2508 data.WriteBool(subcribeInfo); 2509 data.WriteParcelable(info); 2510 2511 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2512 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2513 } 2514 2515 /** 2516 * @tc.name: HandleCanPopEnableNotificationDialog01 2517 * @tc.desc: Test HandleCanPopEnableNotificationDialog. 2518 * @tc.type: FUNC 2519 * @tc.require: issueI620XB 2520 */ 2521 HWTEST_F(AnsManagerStubTest, HandleCanPopEnableNotificationDialog01, Function | SmallTest | Level1) 2522 { 2523 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CAN_POP_ENABLE_NOTIFICATION_DIALOG); 2524 MessageParcel data; 2525 MessageParcel reply; 2526 MessageOption option = {MessageOption::TF_SYNC}; 2527 2528 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2529 data.WriteParcelable(nullptr); 2530 2531 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2532 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2533 } 2534 2535 /** 2536 * @tc.name: HandleCanPopEnableNotificationDialog2 2537 * @tc.desc: Test HandleCanPopEnableNotificationDialog. 2538 * @tc.type: FUNC 2539 * @tc.require: issueI620XB 2540 */ 2541 HWTEST_F(AnsManagerStubTest, HandleCanPopEnableNotificationDialog02, Function | SmallTest | Level1) 2542 { 2543 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CAN_POP_ENABLE_NOTIFICATION_DIALOG); 2544 MessageParcel data; 2545 MessageParcel reply; 2546 MessageOption option = {MessageOption::TF_SYNC}; 2547 sptr<AnsDialogHostClient> callback = new AnsDialogHostClient(); 2548 2549 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2550 data.WriteParcelable(callback->AsObject()); 2551 2552 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2553 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2554 } 2555 2556 /** 2557 * @tc.name: HandleIsAllowedNotify01 2558 * @tc.desc: Test HandleIsAllowedNotify succeed. 2559 * @tc.type: FUNC 2560 * @tc.require: issueI620XB 2561 */ 2562 HWTEST_F(AnsManagerStubTest, HandleIsAllowedNotify01, Function | SmallTest | Level1) 2563 { 2564 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_ALLOWED_NOTIFY); 2565 MessageParcel data; 2566 MessageParcel reply; 2567 MessageOption option = {MessageOption::TF_SYNC}; 2568 2569 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2570 2571 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2572 EXPECT_EQ(ret, (int)ERR_OK); 2573 } 2574 2575 /** 2576 * @tc.name: HandleIsAllowedNotifySelf01 2577 * @tc.desc: Test HandleIsAllowedNotifySelf succeed. 2578 * @tc.type: FUNC 2579 * @tc.require: issueI620XB 2580 */ 2581 HWTEST_F(AnsManagerStubTest, HandleIsAllowedNotifySelf01, Function | SmallTest | Level1) 2582 { 2583 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_ALLOWED_NOTIFY_SELF); 2584 MessageParcel data; 2585 MessageParcel reply; 2586 MessageOption option = {MessageOption::TF_SYNC}; 2587 2588 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2589 2590 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2591 EXPECT_EQ(ret, (int)ERR_OK); 2592 } 2593 2594 /** 2595 * @tc.name: HandleIsSpecialBundleAllowedNotify01 2596 * @tc.desc: Test HandleIsSpecialBundleAllowedNotify succeed. 2597 * @tc.type: FUNC 2598 * @tc.require: issueI620XB 2599 */ 2600 HWTEST_F(AnsManagerStubTest, HandleIsSpecialBundleAllowedNotify01, Function | SmallTest | Level1) 2601 { 2602 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_SPECIAL_BUNDLE_ALLOWED_NOTIFY); 2603 MessageParcel data; 2604 MessageParcel reply; 2605 MessageOption option = {MessageOption::TF_SYNC}; 2606 2607 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2608 2609 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2610 data.WriteParcelable(bundleOption); 2611 2612 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2613 EXPECT_EQ(ret, (int)ERR_OK); 2614 } 2615 2616 /** 2617 * @tc.name: HandleIsSpecialBundleAllowedNotify02 2618 * @tc.desc: Test if the bundleOption in data is null. 2619 * @tc.type: FUNC 2620 * @tc.require: issueI620XB 2621 */ 2622 HWTEST_F(AnsManagerStubTest, HandleIsSpecialBundleAllowedNotify02, Function | SmallTest | Level1) 2623 { 2624 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_SPECIAL_BUNDLE_ALLOWED_NOTIFY); 2625 MessageParcel data; 2626 MessageParcel reply; 2627 MessageOption option = {MessageOption::TF_SYNC}; 2628 2629 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2630 2631 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2632 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2633 } 2634 2635 /** 2636 * @tc.name: HandleCancelGroup01 2637 * @tc.desc: Test HandleCancelGroup succeed. 2638 * @tc.type: FUNC 2639 * @tc.require: issueI620XB 2640 */ 2641 HWTEST_F(AnsManagerStubTest, HandleCancelGroup01, Function | SmallTest | Level1) 2642 { 2643 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_GROUP); 2644 MessageParcel data; 2645 MessageParcel reply; 2646 MessageOption option = {MessageOption::TF_SYNC}; 2647 2648 std::string groupName = "this is groupName"; 2649 std::string instanceKey = ""; 2650 2651 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2652 data.WriteString(groupName); 2653 data.WriteString(instanceKey); 2654 2655 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2656 EXPECT_EQ(ret, (int)ERR_OK); 2657 } 2658 2659 /** 2660 * @tc.name: HandleCancelGroup02 2661 * @tc.desc: Test if the groupName in data is null. 2662 * @tc.type: FUNC 2663 * @tc.require: issueI620XB 2664 */ 2665 HWTEST_F(AnsManagerStubTest, HandleCancelGroup02, Function | SmallTest | Level1) 2666 { 2667 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::CANCEL_GROUP); 2668 MessageParcel data; 2669 MessageParcel reply; 2670 MessageOption option = {MessageOption::TF_SYNC}; 2671 2672 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2673 2674 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2675 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2676 } 2677 2678 /** 2679 * @tc.name: HandleRemoveGroupByBundle01 2680 * @tc.desc: Test HandleRemoveGroupByBundle succeed. 2681 * @tc.type: FUNC 2682 * @tc.require: issueI620XB 2683 */ 2684 HWTEST_F(AnsManagerStubTest, HandleRemoveGroupByBundle01, Function | SmallTest | Level1) 2685 { 2686 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_GROUP_BY_BUNDLE); 2687 MessageParcel data; 2688 MessageParcel reply; 2689 MessageOption option = {MessageOption::TF_SYNC}; 2690 2691 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2692 std::string groupName = "this is groupName"; 2693 2694 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2695 data.WriteStrongParcelable(bundleOption); 2696 data.WriteString(groupName); 2697 2698 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2699 EXPECT_EQ(ret, (int)ERR_OK); 2700 } 2701 2702 /** 2703 * @tc.name: HandleRemoveGroupByBundle02 2704 * @tc.desc: Test if the groupName in data is null. 2705 * @tc.type: FUNC 2706 * @tc.require: issueI620XB 2707 */ 2708 HWTEST_F(AnsManagerStubTest, HandleRemoveGroupByBundle02, Function | SmallTest | Level1) 2709 { 2710 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_GROUP_BY_BUNDLE); 2711 MessageParcel data; 2712 MessageParcel reply; 2713 MessageOption option = {MessageOption::TF_SYNC}; 2714 2715 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2716 2717 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2718 data.WriteStrongParcelable(bundleOption); 2719 2720 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2721 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2722 } 2723 2724 /** 2725 * @tc.name: HandleRemoveGroupByBundle03 2726 * @tc.desc: Test if the bundleOption in data is null. 2727 * @tc.type: FUNC 2728 * @tc.require: issueI620XB 2729 */ 2730 HWTEST_F(AnsManagerStubTest, HandleRemoveGroupByBundle03, Function | SmallTest | Level1) 2731 { 2732 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REMOVE_GROUP_BY_BUNDLE); 2733 MessageParcel data; 2734 MessageParcel reply; 2735 MessageOption option = {MessageOption::TF_SYNC}; 2736 2737 std::string groupName = "this is groupName"; 2738 2739 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2740 data.WriteString(groupName); 2741 2742 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2743 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2744 } 2745 2746 /** 2747 * @tc.name: HandleIsDistributedEnabled01 2748 * @tc.desc: Test HandleIsDistributedEnabled succeed. 2749 * @tc.type: FUNC 2750 * @tc.require: issueI620XB 2751 */ 2752 HWTEST_F(AnsManagerStubTest, HandleIsDistributedEnabled01, Function | SmallTest | Level1) 2753 { 2754 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED); 2755 MessageParcel data; 2756 MessageParcel reply; 2757 MessageOption option = {MessageOption::TF_SYNC}; 2758 2759 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2760 2761 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2762 EXPECT_EQ(ret, (int)ERR_OK); 2763 } 2764 2765 /** 2766 * @tc.name: HandleEnableDistributed01 2767 * @tc.desc: Test HandleEnableDistributed succeed. 2768 * @tc.type: FUNC 2769 * @tc.require: issueI620XB 2770 */ 2771 HWTEST_F(AnsManagerStubTest, HandleEnableDistributed01, Function | SmallTest | Level1) 2772 { 2773 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::ENABLE_DISTRIBUTED); 2774 MessageParcel data; 2775 MessageParcel reply; 2776 MessageOption option = {MessageOption::TF_SYNC}; 2777 2778 bool enabled = true; 2779 2780 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2781 data.WriteBool(enabled); 2782 2783 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2784 EXPECT_EQ(ret, (int)ERR_OK); 2785 } 2786 2787 /** 2788 * @tc.name: HandleEnableDistributed02 2789 * @tc.desc: Test if the enabled in data is null. 2790 * @tc.type: FUNC 2791 * @tc.require: issueI620XB 2792 */ 2793 HWTEST_F(AnsManagerStubTest, HandleEnableDistributed02, Function | SmallTest | Level1) 2794 { 2795 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::ENABLE_DISTRIBUTED); 2796 MessageParcel data; 2797 MessageParcel reply; 2798 MessageOption option = {MessageOption::TF_SYNC}; 2799 2800 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2801 2802 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2803 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2804 } 2805 2806 /** 2807 * @tc.name: HandleEnableDistributedByBundle01 2808 * @tc.desc: Test HandleEnableDistributedByBundle succeed. 2809 * @tc.type: FUNC 2810 * @tc.require: issueI620XB 2811 */ 2812 HWTEST_F(AnsManagerStubTest, HandleEnableDistributedByBundle01, Function | SmallTest | Level1) 2813 { 2814 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::ENABLE_DISTRIBUTED_BY_BUNDLE); 2815 MessageParcel data; 2816 MessageParcel reply; 2817 MessageOption option = {MessageOption::TF_SYNC}; 2818 2819 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2820 bool enabled = true; 2821 2822 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2823 data.WriteStrongParcelable(bundleOption); 2824 data.WriteBool(enabled); 2825 2826 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2827 EXPECT_EQ(ret, (int)ERR_OK); 2828 } 2829 2830 /** 2831 * @tc.name: HandleEnableDistributedByBundle02 2832 * @tc.desc: Test if the enabled in data is null. 2833 * @tc.type: FUNC 2834 * @tc.require: issueI620XB 2835 */ 2836 HWTEST_F(AnsManagerStubTest, HandleEnableDistributedByBundle02, Function | SmallTest | Level1) 2837 { 2838 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::ENABLE_DISTRIBUTED_BY_BUNDLE); 2839 MessageParcel data; 2840 MessageParcel reply; 2841 MessageOption option = {MessageOption::TF_SYNC}; 2842 2843 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2844 2845 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2846 data.WriteStrongParcelable(bundleOption); 2847 2848 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2849 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2850 } 2851 2852 /** 2853 * @tc.name: HandleEnableDistributedByBundle03 2854 * @tc.desc: Test if the bundleOption in data is null. 2855 * @tc.type: FUNC 2856 * @tc.require: issueI620XB 2857 */ 2858 HWTEST_F(AnsManagerStubTest, HandleEnableDistributedByBundle03, Function | SmallTest | Level1) 2859 { 2860 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::ENABLE_DISTRIBUTED_BY_BUNDLE); 2861 MessageParcel data; 2862 MessageParcel reply; 2863 MessageOption option = {MessageOption::TF_SYNC}; 2864 2865 bool enabled = true; 2866 2867 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2868 data.WriteBool(enabled); 2869 2870 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2871 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2872 } 2873 2874 /** 2875 * @tc.name: HandleEnableDistributedSelf01 2876 * @tc.desc: Test HandleEnableDistributedSelf succeed. 2877 * @tc.type: FUNC 2878 * @tc.require: issueI620XB 2879 */ 2880 HWTEST_F(AnsManagerStubTest, HandleEnableDistributedSelf01, Function | SmallTest | Level1) 2881 { 2882 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::ENABLE_DISTRIBUTED_SELF); 2883 MessageParcel data; 2884 MessageParcel reply; 2885 MessageOption option = {MessageOption::TF_SYNC}; 2886 2887 bool enabled = true; 2888 2889 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2890 data.WriteBool(enabled); 2891 2892 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2893 EXPECT_EQ(ret, (int)ERR_OK); 2894 } 2895 2896 /** 2897 * @tc.name: HandleEnableDistributedSelf02 2898 * @tc.desc: Test if the enabled in data is null. 2899 * @tc.type: FUNC 2900 * @tc.require: issueI620XB 2901 */ 2902 HWTEST_F(AnsManagerStubTest, HandleEnableDistributedSelf02, Function | SmallTest | Level1) 2903 { 2904 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::ENABLE_DISTRIBUTED_SELF); 2905 MessageParcel data; 2906 MessageParcel reply; 2907 MessageOption option = {MessageOption::TF_SYNC}; 2908 2909 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2910 2911 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2912 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2913 } 2914 2915 /** 2916 * @tc.name: HandleIsDistributedEnableByBundle01 2917 * @tc.desc: Test HandleIsDistributedEnableByBundle succeed. 2918 * @tc.type: FUNC 2919 * @tc.require: issueI620XB 2920 */ 2921 HWTEST_F(AnsManagerStubTest, HandleIsDistributedEnableByBundle01, Function | SmallTest | Level1) 2922 { 2923 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED_BY_BUNDLE); 2924 MessageParcel data; 2925 MessageParcel reply; 2926 MessageOption option = {MessageOption::TF_SYNC}; 2927 2928 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 2929 2930 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2931 data.WriteStrongParcelable(bundleOption); 2932 2933 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2934 EXPECT_EQ(ret, (int)ERR_OK); 2935 } 2936 2937 /** 2938 * @tc.name: HandleIsDistributedEnableByBundle02 2939 * @tc.desc: Test if the bundleOption in data is null. 2940 * @tc.type: FUNC 2941 * @tc.require: issueI620XB 2942 */ 2943 HWTEST_F(AnsManagerStubTest, HandleIsDistributedEnableByBundle02, Function | SmallTest | Level1) 2944 { 2945 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED_BY_BUNDLE); 2946 MessageParcel data; 2947 MessageParcel reply; 2948 MessageOption option = {MessageOption::TF_SYNC}; 2949 2950 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2951 2952 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2953 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 2954 } 2955 2956 /** 2957 * @tc.name: HandleGetDeviceRemindType01 2958 * @tc.desc: Test HandleGetDeviceRemindType succeed. 2959 * @tc.type: FUNC 2960 * @tc.require: issueI620XB 2961 */ 2962 HWTEST_F(AnsManagerStubTest, HandleGetDeviceRemindType01, Function | SmallTest | Level1) 2963 { 2964 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_DEVICE_REMIND_TYPE); 2965 MessageParcel data; 2966 MessageParcel reply; 2967 MessageOption option = {MessageOption::TF_SYNC}; 2968 2969 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2970 2971 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2972 EXPECT_EQ(ret, (int)ERR_OK); 2973 } 2974 2975 /** 2976 * @tc.name: HandleShellDump01 2977 * @tc.desc: Test HandleShellDump succeed. 2978 * @tc.type: FUNC 2979 * @tc.require: issueI620XB 2980 */ 2981 HWTEST_F(AnsManagerStubTest, HandleShellDump01, Function | SmallTest | Level1) 2982 { 2983 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SHELL_DUMP); 2984 MessageParcel data; 2985 MessageParcel reply; 2986 MessageOption option = {MessageOption::TF_SYNC}; 2987 2988 std::string cmd = "this is cmd"; 2989 std::string bundle = "this is bundle"; 2990 int32_t userId = 4; 2991 2992 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 2993 data.WriteString(cmd); 2994 data.WriteString(bundle); 2995 data.WriteInt32(userId); 2996 data.WriteInt32(userId); 2997 2998 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 2999 EXPECT_EQ(ret, (int)ERR_OK); 3000 } 3001 3002 /** 3003 * @tc.name: HandleShellDump02 3004 * @tc.desc: Test if the userId in data is null. 3005 * @tc.type: FUNC 3006 * @tc.require: issueI620XB 3007 */ 3008 HWTEST_F(AnsManagerStubTest, HandleShellDump02, Function | SmallTest | Level1) 3009 { 3010 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SHELL_DUMP); 3011 MessageParcel data; 3012 MessageParcel reply; 3013 MessageOption option = {MessageOption::TF_SYNC}; 3014 3015 std::string cmd = "this is cmd"; 3016 std::string bundle = "this is bundle"; 3017 3018 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3019 data.WriteString(cmd); 3020 data.WriteString(bundle); 3021 3022 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3023 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3024 } 3025 /** 3026 * @tc.name: HandleShellDump03 3027 * @tc.desc: Test if the cmd in data is null. 3028 * @tc.type: FUNC 3029 * @tc.require: issueI620XB 3030 */ 3031 HWTEST_F(AnsManagerStubTest, HandleShellDump03, Function | SmallTest | Level1) 3032 { 3033 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SHELL_DUMP); 3034 MessageParcel data; 3035 MessageParcel reply; 3036 MessageOption option = {MessageOption::TF_SYNC}; 3037 3038 std::string bundle = "this is bundle"; 3039 int32_t userId = 4; 3040 3041 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3042 data.WriteString(bundle); 3043 data.WriteInt32(userId); 3044 3045 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3046 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3047 } 3048 /** 3049 * @tc.name: HandleShellDump04 3050 * @tc.desc: Test if the bundle in data is null. 3051 * @tc.type: FUNC 3052 * @tc.require: issueI620XB 3053 */ 3054 HWTEST_F(AnsManagerStubTest, HandleShellDump04, Function | SmallTest | Level1) 3055 { 3056 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SHELL_DUMP); 3057 MessageParcel data; 3058 MessageParcel reply; 3059 MessageOption option = {MessageOption::TF_SYNC}; 3060 3061 std::string cmd = "this is cmd"; 3062 int32_t userId = 4; 3063 3064 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3065 data.WriteString(cmd); 3066 data.WriteInt32(userId); 3067 3068 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3069 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3070 } 3071 3072 /** 3073 * @tc.name: ReadParcelableVector01 3074 * @tc.desc: Test ReadParcelableVector result. 3075 * @tc.type: FUNC 3076 * @tc.require: issueI620XB 3077 */ 3078 HWTEST_F(AnsManagerStubTest, ReadParcelableVector01, Function | SmallTest | Level1) 3079 { 3080 std::vector<sptr<NotificationSlot>> slots; 3081 sptr<NotificationSlot> slot = new NotificationSlot(); 3082 slots.emplace_back(slot); 3083 MessageParcel data; 3084 bool ret = ansManagerStub_->ReadParcelableVector(slots, data); 3085 EXPECT_EQ(ret, false); 3086 } 3087 3088 /** 3089 * @tc.name: ReadParcelableVector02 3090 * @tc.desc: Test ReadParcelableVector result. 3091 * @tc.type: FUNC 3092 * @tc.require: issueI620XB 3093 */ 3094 HWTEST_F(AnsManagerStubTest, ReadParcelableVector02, Function | SmallTest | Level1) 3095 { 3096 std::vector<sptr<NotificationSlot>> slots; 3097 sptr<NotificationSlot> slot = new NotificationSlot(); 3098 slots.emplace_back(slot); 3099 MessageParcel data; 3100 3101 int32_t infoSize = 4; 3102 data.WriteInt32(infoSize); 3103 data.WriteStrongParcelable(slot); 3104 bool ret = ansManagerStub_->ReadParcelableVector(slots, data); 3105 EXPECT_EQ(ret, false); 3106 } 3107 3108 /** 3109 * @tc.name: HandleIsSupportTemplate01 3110 * @tc.desc: Test HandleIsSupportTemplate succeed. 3111 * @tc.type: FUNC 3112 * @tc.require: issueI620XB 3113 */ 3114 HWTEST_F(AnsManagerStubTest, HandleIsSupportTemplate01, Function | SmallTest | Level1) 3115 { 3116 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_SUPPORT_TEMPLATE); 3117 MessageParcel data; 3118 MessageParcel reply; 3119 MessageOption option = {MessageOption::TF_SYNC}; 3120 3121 std::string templateName = "this is templateName"; 3122 3123 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3124 data.WriteString(templateName); 3125 3126 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3127 EXPECT_EQ(ret, (int)ERR_OK); 3128 } 3129 3130 /** 3131 * @tc.name: HandleIsSupportTemplate02 3132 * @tc.desc: Test templateName in data is null. 3133 * @tc.type: FUNC 3134 * @tc.require: issueI620XB 3135 */ 3136 HWTEST_F(AnsManagerStubTest, HandleIsSupportTemplate02, Function | SmallTest | Level1) 3137 { 3138 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_SUPPORT_TEMPLATE); 3139 MessageParcel data; 3140 MessageParcel reply; 3141 MessageOption option = {MessageOption::TF_SYNC}; 3142 3143 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3144 3145 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3146 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3147 } 3148 3149 /** 3150 * @tc.name: HandleIsSpecialUserAllowedNotifyByUser01 3151 * @tc.desc: Test HandleIsSpecialUserAllowedNotifyByUser succeed. 3152 * @tc.type: FUNC 3153 * @tc.require: issueI620XB 3154 */ 3155 HWTEST_F(AnsManagerStubTest, HandleIsSpecialUserAllowedNotifyByUser01, Function | SmallTest | Level1) 3156 { 3157 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_SPECIAL_USER_ALLOWED_NOTIFY); 3158 MessageParcel data; 3159 MessageParcel reply; 3160 MessageOption option = {MessageOption::TF_SYNC}; 3161 3162 int32_t userId = 4; 3163 3164 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3165 data.WriteInt32(userId); 3166 3167 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3168 EXPECT_EQ(ret, (int)ERR_OK); 3169 } 3170 3171 /** 3172 * @tc.name: HandleIsSpecialUserAllowedNotifyByUser02 3173 * @tc.desc: Test userId in data is null. 3174 * @tc.type: FUNC 3175 * @tc.require: issueI620XB 3176 */ 3177 HWTEST_F(AnsManagerStubTest, HandleIsSpecialUserAllowedNotifyByUser02, Function | SmallTest | Level1) 3178 { 3179 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_SPECIAL_USER_ALLOWED_NOTIFY); 3180 MessageParcel data; 3181 MessageParcel reply; 3182 MessageOption option = {MessageOption::TF_SYNC}; 3183 3184 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3185 3186 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3187 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3188 } 3189 3190 /** 3191 * @tc.name: HandleSetNotificationsEnabledByUser01 3192 * @tc.desc: Test HandleSetNotificationsEnabledByUser succeed. 3193 * @tc.type: FUNC 3194 * @tc.require: issueI620XB 3195 */ 3196 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledByUser01, Function | SmallTest | Level1) 3197 { 3198 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER); 3199 MessageParcel parcels; 3200 MessageParcel reply; 3201 MessageOption option = {MessageOption::TF_SYNC}; 3202 3203 int32_t userId = 4; 3204 bool enabled = true; 3205 3206 parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3207 parcels.WriteInt32(userId); 3208 parcels.WriteBool(enabled); 3209 3210 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); 3211 EXPECT_EQ(ret, (int)ERR_OK); 3212 } 3213 3214 /** 3215 * @tc.name: HandleSetNotificationsEnabledByUser02 3216 * @tc.desc: Test userId in data is null. 3217 * @tc.type: FUNC 3218 * @tc.require: issueI620XB 3219 */ 3220 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledByUser02, Function | SmallTest | Level1) 3221 { 3222 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER); 3223 MessageParcel data; 3224 MessageParcel reply; 3225 MessageOption option = {MessageOption::TF_SYNC}; 3226 3227 bool enabled = true; 3228 3229 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3230 data.WriteBool(enabled); 3231 3232 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3233 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3234 } 3235 3236 /** 3237 * @tc.name: HandleSetNotificationsEnabledByUser03 3238 * @tc.desc: Test enabled in data is null. 3239 * @tc.type: FUNC 3240 * @tc.require: issueI620XB 3241 */ 3242 HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledByUser03, Function | SmallTest | Level1) 3243 { 3244 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER); 3245 MessageParcel data; 3246 MessageParcel reply; 3247 MessageOption option = {MessageOption::TF_SYNC}; 3248 3249 int32_t userId = 4; 3250 3251 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3252 data.WriteInt32(userId); 3253 3254 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3255 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3256 } 3257 3258 /** 3259 * @tc.name: HandleDeleteAllByUser01 3260 * @tc.desc: Test HandleDeleteAllByUser succeed. 3261 * @tc.type: FUNC 3262 * @tc.require: issueI620XB 3263 */ 3264 HWTEST_F(AnsManagerStubTest, HandleDeleteAllByUser01, Function | SmallTest | Level1) 3265 { 3266 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER); 3267 MessageParcel data; 3268 MessageParcel reply; 3269 MessageOption option = {MessageOption::TF_SYNC}; 3270 3271 int32_t userId = 4; 3272 3273 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3274 data.WriteInt32(userId); 3275 3276 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3277 EXPECT_EQ(ret, (int)ERR_OK); 3278 } 3279 3280 /** 3281 * @tc.name: HandleDeleteAllByUser02 3282 * @tc.desc: Test userId in data is null. 3283 * @tc.type: FUNC 3284 * @tc.require: issueI620XB 3285 */ 3286 HWTEST_F(AnsManagerStubTest, HandleDeleteAllByUser02, Function | SmallTest | Level1) 3287 { 3288 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER); 3289 MessageParcel data; 3290 MessageParcel reply; 3291 MessageOption option = {MessageOption::TF_SYNC}; 3292 3293 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3294 3295 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3296 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3297 } 3298 3299 /** 3300 * @tc.name: HandleSetDoNotDisturbDateByUser01 3301 * @tc.desc: Test HandleSetDoNotDisturbDateByUser succeed. 3302 * @tc.type: FUNC 3303 * @tc.require: issueI620XB 3304 */ 3305 HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDateByUser01, Function | SmallTest | Level1) 3306 { 3307 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE_BY_USER); 3308 MessageParcel data; 3309 MessageParcel reply; 3310 MessageOption option = {MessageOption::TF_SYNC}; 3311 3312 int32_t userId = 4; 3313 sptr<NotificationDoNotDisturbDate> date = new NotificationDoNotDisturbDate(); 3314 3315 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3316 data.WriteInt32(userId); 3317 data.WriteStrongParcelable(date); 3318 3319 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3320 EXPECT_EQ(ret, (int)ERR_OK); 3321 } 3322 3323 /** 3324 * @tc.name: HandleSetDoNotDisturbDateByUser02 3325 * @tc.desc: Test userId in data is null. 3326 * @tc.type: FUNC 3327 * @tc.require: issueI620XB 3328 */ 3329 HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDateByUser02, Function | SmallTest | Level1) 3330 { 3331 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE_BY_USER); 3332 MessageParcel data; 3333 MessageParcel reply; 3334 MessageOption option = {MessageOption::TF_SYNC}; 3335 3336 sptr<NotificationDoNotDisturbDate> date = new NotificationDoNotDisturbDate(); 3337 3338 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3339 data.WriteParcelable(date); 3340 3341 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3342 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3343 } 3344 3345 /** 3346 * @tc.name: HandleSetDoNotDisturbDateByUser03 3347 * @tc.desc: Test date in data is null. 3348 * @tc.type: FUNC 3349 * @tc.require: issueI620XB 3350 */ 3351 HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDateByUser03, Function | SmallTest | Level1) 3352 { 3353 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE_BY_USER); 3354 MessageParcel data; 3355 MessageParcel reply; 3356 MessageOption option = {MessageOption::TF_SYNC}; 3357 3358 int32_t userId = 4; 3359 3360 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3361 data.WriteInt32(userId); 3362 3363 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3364 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3365 } 3366 3367 /** 3368 * @tc.name: HandleGetDoNotDisturbDateByUser01 3369 * @tc.desc: Test HandleGetDoNotDisturbDateByUser succeed. 3370 * @tc.type: FUNC 3371 * @tc.require: issueI620XB 3372 */ 3373 HWTEST_F(AnsManagerStubTest, HandleGetDoNotDisturbDateByUser01, Function | SmallTest | Level1) 3374 { 3375 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE_BY_USER); 3376 MessageParcel data; 3377 MessageParcel reply; 3378 MessageOption option = {MessageOption::TF_SYNC}; 3379 3380 int32_t userId = 4; 3381 sptr<NotificationDoNotDisturbDate> date = new NotificationDoNotDisturbDate(); 3382 3383 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3384 data.WriteParcelable(date); 3385 data.WriteInt32(userId); 3386 3387 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3388 EXPECT_EQ(ret, (int)ERR_OK); 3389 } 3390 3391 /** 3392 * @tc.name: HandleGetDoNotDisturbDateByUser02 3393 * @tc.desc: Test userId in data is null. 3394 * @tc.type: FUNC 3395 * @tc.require: issueI620XB 3396 */ 3397 HWTEST_F(AnsManagerStubTest, HandleGetDoNotDisturbDateByUser02, Function | SmallTest | Level1) 3398 { 3399 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE_BY_USER); 3400 MessageParcel data; 3401 MessageParcel reply; 3402 MessageOption option = {MessageOption::TF_SYNC}; 3403 3404 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3405 3406 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3407 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3408 } 3409 3410 /** 3411 * @tc.name: HandleSetEnabledForBundleSlot01 3412 * @tc.desc: Test HandleSetEnabledForBundleSlot succeed. 3413 * @tc.type: FUNC 3414 * @tc.require: issueI620XB 3415 */ 3416 HWTEST_F(AnsManagerStubTest, HandleSetEnabledForBundleSlot01, Function | SmallTest | Level1) 3417 { 3418 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT); 3419 MessageParcel data; 3420 MessageParcel reply; 3421 MessageOption option = {MessageOption::TF_SYNC}; 3422 3423 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3424 string bundlename = "bundle1"; 3425 bundleOption->SetBundleName(bundlename); 3426 int32_t type = 4; 3427 bool enabled = true; 3428 bool isForceControl = false; 3429 3430 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3431 data.WriteStrongParcelable(bundleOption); 3432 data.WriteInt32(type); 3433 data.WriteBool(enabled); 3434 data.WriteBool(isForceControl); 3435 3436 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3437 EXPECT_EQ(ret, (int)ERR_OK); 3438 } 3439 3440 /** 3441 * @tc.name: HandleSetEnabledForBundleSlot02 3442 * @tc.desc: Test bundleOption in data is null. 3443 * @tc.type: FUNC 3444 * @tc.require: issueI620XB 3445 */ 3446 HWTEST_F(AnsManagerStubTest, HandleSetEnabledForBundleSlot02, Function | SmallTest | Level1) 3447 { 3448 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT); 3449 MessageParcel data; 3450 MessageParcel reply; 3451 MessageOption option = {MessageOption::TF_SYNC}; 3452 3453 int32_t type = 4; 3454 bool enabled = true; 3455 3456 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3457 data.WriteInt32(type); 3458 data.WriteBool(enabled); 3459 3460 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3461 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3462 } 3463 3464 /** 3465 * @tc.name: HandleSetEnabledForBundleSlot03 3466 * @tc.desc: Test type in data is null. 3467 * @tc.type: FUNC 3468 * @tc.require: issueI620XB 3469 */ 3470 HWTEST_F(AnsManagerStubTest, HandleSetEnabledForBundleSlot03, Function | SmallTest | Level1) 3471 { 3472 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT); 3473 MessageParcel data; 3474 MessageParcel reply; 3475 MessageOption option = {MessageOption::TF_SYNC}; 3476 3477 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3478 bool enabled = true; 3479 3480 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3481 data.WriteStrongParcelable(bundleOption); 3482 data.WriteBool(enabled); 3483 3484 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3485 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3486 } 3487 3488 /** 3489 * @tc.name: HandleSetEnabledForBundleSlot04 3490 * @tc.desc: Test enabled in data is null. 3491 * @tc.type: FUNC 3492 * @tc.require: issueI620XB 3493 */ 3494 HWTEST_F(AnsManagerStubTest, HandleSetEnabledForBundleSlot04, Function | SmallTest | Level1) 3495 { 3496 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT); 3497 MessageParcel data; 3498 MessageParcel reply; 3499 MessageOption option = {MessageOption::TF_SYNC}; 3500 3501 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3502 int32_t type = 4; 3503 3504 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3505 data.WriteStrongParcelable(bundleOption); 3506 data.WriteInt32(type); 3507 3508 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3509 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3510 } 3511 3512 /** 3513 * @tc.name: HandleGetEnabledForBundleSlot01 3514 * @tc.desc: Test HandleGetEnabledForBundleSlot succeed. 3515 * @tc.type: FUNC 3516 * @tc.require: issueI620XB 3517 */ 3518 HWTEST_F(AnsManagerStubTest, HandleGetEnabledForBundleSlot01, Function | SmallTest | Level1) 3519 { 3520 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT); 3521 MessageParcel data; 3522 MessageParcel reply; 3523 MessageOption option = {MessageOption::TF_SYNC}; 3524 3525 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3526 int32_t type = 4; 3527 3528 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3529 data.WriteStrongParcelable(bundleOption); 3530 data.WriteInt32(type); 3531 3532 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3533 EXPECT_EQ(ret, (int)ERR_OK); 3534 } 3535 3536 /** 3537 * @tc.name: HandleGetEnabledForBundleSlot02 3538 * @tc.desc: Test bundleOption in data is null. 3539 * @tc.type: FUNC 3540 * @tc.require: issueI620XB 3541 */ 3542 HWTEST_F(AnsManagerStubTest, HandleGetEnabledForBundleSlot02, Function | SmallTest | Level1) 3543 { 3544 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT); 3545 MessageParcel data; 3546 MessageParcel reply; 3547 MessageOption option = {MessageOption::TF_SYNC}; 3548 3549 int32_t type = 4; 3550 3551 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3552 data.WriteInt32(type); 3553 3554 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3555 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3556 } 3557 3558 /** 3559 * @tc.name: HandleGetEnabledForBundleSlot03 3560 * @tc.desc: Test type in data is null. 3561 * @tc.type: FUNC 3562 * @tc.require: issueI620XB 3563 */ 3564 HWTEST_F(AnsManagerStubTest, HandleGetEnabledForBundleSlot03, Function | SmallTest | Level1) 3565 { 3566 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT); 3567 MessageParcel data; 3568 MessageParcel reply; 3569 MessageOption option = {MessageOption::TF_SYNC}; 3570 3571 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3572 3573 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3574 data.WriteStrongParcelable(bundleOption); 3575 3576 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3577 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3578 } 3579 3580 /** 3581 * @tc.name: HandleGetEnabledForBundleSlotSelf01 3582 * @tc.desc: Test type in data is null. 3583 * @tc.type: FUNC 3584 * @tc.require: issueI620XB 3585 */ 3586 HWTEST_F(AnsManagerStubTest, HandleGetEnabledForBundleSlotSelf01, Function | SmallTest | Level1) 3587 { 3588 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT_SELF); 3589 MessageParcel data; 3590 MessageParcel reply; 3591 MessageOption option = {MessageOption::TF_SYNC}; 3592 int32_t type = 4; 3593 3594 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3595 data.WriteInt32(type); 3596 3597 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3598 EXPECT_EQ(ret, (int)ERR_OK); 3599 } 3600 3601 /** 3602 * @tc.name: HandleSetBadgeNumber03 3603 * @tc.desc: HandleSetBadgeNumber. 3604 * @tc.type: FUNC 3605 * @tc.require: issueI620XB 3606 */ 3607 HWTEST_F(AnsManagerStubTest, HandleSetBadgeNumber03, Function | SmallTest | Level1) 3608 { 3609 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_BADGE_NUMBER); 3610 MessageParcel data; 3611 MessageParcel reply; 3612 MessageOption option = {MessageOption::TF_SYNC}; 3613 int32_t type = 4; 3614 3615 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3616 data.WriteInt32(type); 3617 data.WriteString(""); 3618 3619 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3620 EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); 3621 } 3622 3623 /** 3624 * @tc.name: HandleDistributedSetEnabledWithoutApp01 3625 * @tc.desc: Test HandleDistributedSetEnabledWithoutApp succeed. 3626 * @tc.type: FUNC 3627 * @tc.require: issueI620XB 3628 */ 3629 HWTEST_F(AnsManagerStubTest, HandleDistributedSetEnabledWithoutApp01, Function | SmallTest | Level1) 3630 { 3631 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP); 3632 MessageParcel data; 3633 MessageParcel reply; 3634 MessageOption option = {MessageOption::TF_SYNC}; 3635 3636 int32_t userId = 4; 3637 bool enabled = true; 3638 3639 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3640 data.WriteInt32(userId); 3641 data.WriteBool(enabled); 3642 3643 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3644 EXPECT_EQ(ret, (int)ERR_OK); 3645 } 3646 3647 /** 3648 * @tc.name: HandleDistributedSetEnabledWithoutApp02 3649 * @tc.desc: Test userId in data is null. 3650 * @tc.type: FUNC 3651 * @tc.require: issueI620XB 3652 */ 3653 HWTEST_F(AnsManagerStubTest, HandleDistributedSetEnabledWithoutApp02, Function | SmallTest | Level1) 3654 { 3655 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP); 3656 MessageParcel data; 3657 MessageParcel reply; 3658 MessageOption option = {MessageOption::TF_SYNC}; 3659 3660 bool enabled = true; 3661 3662 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3663 data.WriteBool(enabled); 3664 3665 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3666 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3667 } 3668 3669 /** 3670 * @tc.name: HandleDistributedSetEnabledWithoutApp03 3671 * @tc.desc: Test enabled in data is null. 3672 * @tc.type: FUNC 3673 * @tc.require: issueI620XB 3674 */ 3675 HWTEST_F(AnsManagerStubTest, HandleDistributedSetEnabledWithoutApp03, Function | SmallTest | Level1) 3676 { 3677 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP); 3678 MessageParcel data; 3679 MessageParcel reply; 3680 MessageOption option = {MessageOption::TF_SYNC}; 3681 3682 int32_t userId = 4; 3683 3684 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3685 data.WriteInt32(userId); 3686 3687 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3688 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3689 } 3690 3691 /** 3692 * @tc.name: HandleDistributedGetEnabledWithoutApp01 3693 * @tc.desc: Test HandleDistributedGetEnabledWithoutApp succeed. 3694 * @tc.type: FUNC 3695 * @tc.require: issueI620XB 3696 */ 3697 HWTEST_F(AnsManagerStubTest, HandleDistributedGetEnabledWithoutApp01, Function | SmallTest | Level1) 3698 { 3699 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP); 3700 MessageParcel data; 3701 MessageParcel reply; 3702 MessageOption option = {MessageOption::TF_SYNC}; 3703 3704 int32_t userId = 4; 3705 3706 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3707 data.WriteInt32(userId); 3708 3709 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3710 EXPECT_EQ(ret, (int)ERR_OK); 3711 } 3712 3713 /** 3714 * @tc.name: HandleDistributedGetEnabledWithoutApp02 3715 * @tc.desc: Test userId in data is null. 3716 * @tc.type: FUNC 3717 * @tc.require: issueI620XB 3718 */ 3719 HWTEST_F(AnsManagerStubTest, HandleDistributedGetEnabledWithoutApp02, Function | SmallTest | Level1) 3720 { 3721 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP); 3722 MessageParcel data; 3723 MessageParcel reply; 3724 MessageOption option = {MessageOption::TF_SYNC}; 3725 3726 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 3727 3728 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 3729 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 3730 } 3731 3732 /** 3733 * @tc.name: GetSlots01 3734 * @tc.desc: Test GetSlots return. 3735 * @tc.type: FUNC 3736 * @tc.require: issueI620XB 3737 */ 3738 HWTEST_F(AnsManagerStubTest, GetSlots01, Function | SmallTest | Level1) 3739 { 3740 std::vector<sptr<NotificationSlot>> slots; 3741 sptr<NotificationSlot> slot = new NotificationSlot(); 3742 slots.emplace_back(slot); 3743 3744 ErrCode result = ansManagerStub_->GetSlots(slots); 3745 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3746 } 3747 3748 /** 3749 * @tc.name: GetSpecialActiveNotifications01 3750 * @tc.desc: Test GetSpecialActiveNotifications return. 3751 * @tc.type: FUNC 3752 * @tc.require: issueI620XB 3753 */ 3754 HWTEST_F(AnsManagerStubTest, GetSpecialActiveNotifications01, Function | SmallTest | Level1) 3755 { 3756 std::vector<std::string> keys; 3757 std::string key = "this is key"; 3758 keys.emplace_back(key); 3759 std::vector<sptr<Notification>> notifications; 3760 sptr<Notification> notification = new Notification(); 3761 notifications.emplace_back(notification); 3762 3763 ErrCode result = ansManagerStub_->GetSpecialActiveNotifications(keys, notifications); 3764 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3765 } 3766 3767 /** 3768 * @tc.name: PublishAsBundle01 3769 * @tc.desc: Test PublishAsBundle return. 3770 * @tc.type: FUNC 3771 * @tc.require: issueI620XB 3772 */ 3773 HWTEST_F(AnsManagerStubTest, PublishAsBundle01, Function | SmallTest | Level1) 3774 { 3775 sptr<NotificationRequest> notification = new NotificationRequest(); 3776 std::string representativeBundle = "this is representativeBundle"; 3777 3778 ErrCode result = ansManagerStub_->PublishAsBundle(notification, representativeBundle); 3779 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3780 } 3781 3782 /** 3783 * @tc.name: SetNotificationBadgeNum01 3784 * @tc.desc: Test SetNotificationBadgeNum return. 3785 * @tc.type: FUNC 3786 * @tc.require: issueI620XB 3787 */ 3788 HWTEST_F(AnsManagerStubTest, SetNotificationBadgeNum01, Function | SmallTest | Level1) 3789 { 3790 int num = 2; 3791 ErrCode result = ansManagerStub_->SetNotificationBadgeNum(num); 3792 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3793 } 3794 3795 /** 3796 * @tc.name: GetBundleImportance01 3797 * @tc.desc: Test GetBundleImportance return. 3798 * @tc.type: FUNC 3799 * @tc.require: issueI620XB 3800 */ 3801 HWTEST_F(AnsManagerStubTest, GetBundleImportance01, Function | SmallTest | Level1) 3802 { 3803 int importance = 2; 3804 ErrCode result = ansManagerStub_->GetBundleImportance(importance); 3805 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3806 } 3807 3808 /** 3809 * @tc.name: HasNotificationPolicyAccessPermission01 3810 * @tc.desc: Test HasNotificationPolicyAccessPermission return. 3811 * @tc.type: FUNC 3812 * @tc.require: issueI620XB 3813 */ 3814 HWTEST_F(AnsManagerStubTest, HasNotificationPolicyAccessPermission01, Function | SmallTest | Level1) 3815 { 3816 bool granted = true; 3817 ErrCode result = ansManagerStub_->HasNotificationPolicyAccessPermission(granted); 3818 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3819 } 3820 3821 /** 3822 * @tc.name: RemoveNotification01 3823 * @tc.desc: Test RemoveNotification return. 3824 * @tc.type: FUNC 3825 * @tc.require: issueI620XB 3826 */ 3827 HWTEST_F(AnsManagerStubTest, RemoveNotification01, Function | SmallTest | Level1) 3828 { 3829 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3830 int notificationId = 4; 3831 std::string label = "this is label"; 3832 int32_t removeReason = 2; 3833 ErrCode result = ansManagerStub_->RemoveNotification(bundleOption, notificationId, label, removeReason); 3834 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3835 } 3836 3837 /** 3838 * @tc.name: RemoveAllNotifications01 3839 * @tc.desc: Test RemoveAllNotifications return. 3840 * @tc.type: FUNC 3841 * @tc.require: issueI620XB 3842 */ 3843 HWTEST_F(AnsManagerStubTest, RemoveAllNotifications01, Function | SmallTest | Level1) 3844 { 3845 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3846 ErrCode result = ansManagerStub_->RemoveAllNotifications(bundleOption); 3847 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3848 } 3849 3850 /** 3851 * @tc.name: Delete01 3852 * @tc.desc: Test Delete return. 3853 * @tc.type: FUNC 3854 * @tc.require: issueI620XB 3855 */ 3856 HWTEST_F(AnsManagerStubTest, Delete01, Function | SmallTest | Level1) 3857 { 3858 std::string key = "this is key"; 3859 int32_t removeReason = 2; 3860 ErrCode result = ansManagerStub_->Delete(key, removeReason); 3861 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3862 } 3863 3864 /** 3865 * @tc.name: DeleteByBundle01 3866 * @tc.desc: Test DeleteByBundle return. 3867 * @tc.type: FUNC 3868 * @tc.require: issueI620XB 3869 */ 3870 HWTEST_F(AnsManagerStubTest, DeleteByBundle01, Function | SmallTest | Level1) 3871 { 3872 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3873 ErrCode result = ansManagerStub_->DeleteByBundle(bundleOption); 3874 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3875 } 3876 3877 /** 3878 * @tc.name: DeleteAll01 3879 * @tc.desc: Test DeleteAll return. 3880 * @tc.type: FUNC 3881 * @tc.require: issueI620XB 3882 */ 3883 HWTEST_F(AnsManagerStubTest, DeleteAll01, Function | SmallTest | Level1) 3884 { 3885 ErrCode result = ansManagerStub_->DeleteAll(); 3886 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3887 } 3888 3889 /** 3890 * @tc.name: GetSlotsByBundle01 3891 * @tc.desc: Test GetSlotsByBundle return. 3892 * @tc.type: FUNC 3893 * @tc.require: issueI620XB 3894 */ 3895 HWTEST_F(AnsManagerStubTest, GetSlotsByBundle01, Function | SmallTest | Level1) 3896 { 3897 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3898 std::vector<sptr<NotificationSlot>> slots; 3899 sptr<NotificationSlot> slot = new NotificationSlot(); 3900 slots.emplace_back(slot); 3901 3902 ErrCode result = ansManagerStub_->GetSlotsByBundle(bundleOption, slots); 3903 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3904 } 3905 3906 /** 3907 * @tc.name: UpdateSlots01 3908 * @tc.desc: Test UpdateSlots return. 3909 * @tc.type: FUNC 3910 * @tc.require: issueI620XB 3911 */ 3912 HWTEST_F(AnsManagerStubTest, UpdateSlots01, Function | SmallTest | Level1) 3913 { 3914 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3915 std::vector<sptr<NotificationSlot>> slots; 3916 sptr<NotificationSlot> slot = new NotificationSlot(); 3917 slots.emplace_back(slot); 3918 3919 ErrCode result = ansManagerStub_->UpdateSlots(bundleOption, slots); 3920 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3921 } 3922 3923 /** 3924 * @tc.name: RequestEnableNotification01 3925 * @tc.desc: Test RequestEnableNotification return. 3926 * @tc.type: FUNC 3927 * @tc.require: issueI620XB 3928 */ 3929 HWTEST_F(AnsManagerStubTest, RequestEnableNotification01, Function | SmallTest | Level1) 3930 { 3931 std::string deviceId = "this is deviceId"; 3932 sptr<AnsDialogCallback> callback = nullptr; 3933 sptr<IRemoteObject> callerToken = nullptr; 3934 ErrCode result = ansManagerStub_->RequestEnableNotification(deviceId, callback, callerToken); 3935 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3936 } 3937 3938 /** 3939 * @tc.name: SetNotificationsEnabledForBundle01 3940 * @tc.desc: Test SetNotificationsEnabledForBundle return. 3941 * @tc.type: FUNC 3942 * @tc.require: issueI620XB 3943 */ 3944 HWTEST_F(AnsManagerStubTest, SetNotificationsEnabledForBundle01, Function | SmallTest | Level1) 3945 { 3946 std::string bundle = "this is bundle"; 3947 bool enabled = true; 3948 3949 ErrCode result = ansManagerStub_->SetNotificationsEnabledForBundle(bundle, enabled); 3950 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3951 } 3952 3953 /** 3954 * @tc.name: SetNotificationsEnabledForAllBundles01 3955 * @tc.desc: Test SetNotificationsEnabledForAllBundles return. 3956 * @tc.type: FUNC 3957 * @tc.require: issueI620XB 3958 */ 3959 HWTEST_F(AnsManagerStubTest, SetNotificationsEnabledForAllBundles01, Function | SmallTest | Level1) 3960 { 3961 std::string deviceId = "this is deviceId"; 3962 bool enabled = true; 3963 3964 ErrCode result = ansManagerStub_->SetNotificationsEnabledForAllBundles(deviceId, enabled); 3965 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3966 } 3967 3968 /** 3969 * @tc.name: SetNotificationsEnabledForSpecialBundle01 3970 * @tc.desc: Test SetNotificationsEnabledForSpecialBundle return. 3971 * @tc.type: FUNC 3972 * @tc.require: issueI620XB 3973 */ 3974 HWTEST_F(AnsManagerStubTest, SetNotificationsEnabledForSpecialBundle01, Function | SmallTest | Level1) 3975 { 3976 std::string deviceId = "this is deviceId"; 3977 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3978 bool enabled = true; 3979 3980 ErrCode result = ansManagerStub_->SetNotificationsEnabledForSpecialBundle(deviceId, bundleOption, enabled); 3981 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3982 } 3983 3984 /** 3985 * @tc.name: SetShowBadgeEnabledForBundle01 3986 * @tc.desc: Test SetShowBadgeEnabledForBundle return. 3987 * @tc.type: FUNC 3988 * @tc.require: issueI620XB 3989 */ 3990 HWTEST_F(AnsManagerStubTest, SetShowBadgeEnabledForBundle01, Function | SmallTest | Level1) 3991 { 3992 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 3993 bool enabled = true; 3994 3995 ErrCode result = ansManagerStub_->SetShowBadgeEnabledForBundle(bundleOption, enabled); 3996 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 3997 } 3998 3999 /** 4000 * @tc.name: GetShowBadgeEnabledForBundle01 4001 * @tc.desc: Test GetShowBadgeEnabledForBundle return. 4002 * @tc.type: FUNC 4003 * @tc.require: issueI620XB 4004 */ 4005 HWTEST_F(AnsManagerStubTest, GetShowBadgeEnabledForBundle01, Function | SmallTest | Level1) 4006 { 4007 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4008 bool enabled = true; 4009 4010 ErrCode result = ansManagerStub_->GetShowBadgeEnabledForBundle(bundleOption, enabled); 4011 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4012 } 4013 4014 /** 4015 * @tc.name: GetShowBadgeEnabled01 4016 * @tc.desc: Test GetShowBadgeEnabled return. 4017 * @tc.type: FUNC 4018 * @tc.require: issueI620XB 4019 */ 4020 HWTEST_F(AnsManagerStubTest, GetShowBadgeEnabled01, Function | SmallTest | Level1) 4021 { 4022 bool enabled = true; 4023 4024 ErrCode result = ansManagerStub_->GetShowBadgeEnabled(enabled); 4025 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4026 } 4027 4028 /** 4029 * @tc.name: IsAllowedNotify01 4030 * @tc.desc: Test IsAllowedNotify return. 4031 * @tc.type: FUNC 4032 * @tc.require: issueI620XB 4033 */ 4034 HWTEST_F(AnsManagerStubTest, IsAllowedNotify01, Function | SmallTest | Level1) 4035 { 4036 bool allowed = true; 4037 4038 ErrCode result = ansManagerStub_->IsAllowedNotify(allowed); 4039 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4040 } 4041 4042 /** 4043 * @tc.name: IsAllowedNotifySelf01 4044 * @tc.desc: Test IsAllowedNotifySelf return. 4045 * @tc.type: FUNC 4046 * @tc.require: issueI620XB 4047 */ 4048 HWTEST_F(AnsManagerStubTest, IsAllowedNotifySelf01, Function | SmallTest | Level1) 4049 { 4050 bool allowed = true; 4051 4052 ErrCode result = ansManagerStub_->IsAllowedNotifySelf(allowed); 4053 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4054 } 4055 4056 /** 4057 * @tc.name: IsSpecialBundleAllowedNotify01 4058 * @tc.desc: Test IsSpecialBundleAllowedNotify return. 4059 * @tc.type: FUNC 4060 * @tc.require: issueI620XB 4061 */ 4062 HWTEST_F(AnsManagerStubTest, IsSpecialBundleAllowedNotify01, Function | SmallTest | Level1) 4063 { 4064 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4065 bool allowed = true; 4066 4067 ErrCode result = ansManagerStub_->IsSpecialBundleAllowedNotify(bundleOption, allowed); 4068 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4069 } 4070 4071 /** 4072 * @tc.name: CancelGroup01 4073 * @tc.desc: Test CancelGroup return. 4074 * @tc.type: FUNC 4075 * @tc.require: issueI620XB 4076 */ 4077 HWTEST_F(AnsManagerStubTest, CancelGroup01, Function | SmallTest | Level1) 4078 { 4079 std::string groupName = "this is groupName"; 4080 4081 ErrCode result = ansManagerStub_->CancelGroup(groupName, ""); 4082 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4083 } 4084 4085 /** 4086 * @tc.name: RemoveGroupByBundle01 4087 * @tc.desc: Test RemoveGroupByBundle return. 4088 * @tc.type: FUNC 4089 * @tc.require: issueI620XB 4090 */ 4091 HWTEST_F(AnsManagerStubTest, RemoveGroupByBundle01, Function | SmallTest | Level1) 4092 { 4093 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4094 std::string groupName = "this is groupName"; 4095 4096 ErrCode result = ansManagerStub_->RemoveGroupByBundle(bundleOption, groupName); 4097 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4098 } 4099 4100 /** 4101 * @tc.name: SetDoNotDisturbDate01 4102 * @tc.desc: Test SetDoNotDisturbDate return. 4103 * @tc.type: FUNC 4104 * @tc.require: issueI620XB 4105 */ 4106 HWTEST_F(AnsManagerStubTest, SetDoNotDisturbDate01, Function | SmallTest | Level1) 4107 { 4108 sptr<NotificationDoNotDisturbDate> date = new NotificationDoNotDisturbDate(); 4109 4110 ErrCode result = ansManagerStub_->SetDoNotDisturbDate(date); 4111 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4112 } 4113 4114 /** 4115 * @tc.name: GetDoNotDisturbDate01 4116 * @tc.desc: Test GetDoNotDisturbDate return. 4117 * @tc.type: FUNC 4118 * @tc.require: issueI620XB 4119 */ 4120 HWTEST_F(AnsManagerStubTest, GetDoNotDisturbDate01, Function | SmallTest | Level1) 4121 { 4122 sptr<NotificationDoNotDisturbDate> date = new NotificationDoNotDisturbDate(); 4123 4124 ErrCode result = ansManagerStub_->GetDoNotDisturbDate(date); 4125 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4126 } 4127 4128 /** 4129 * @tc.name: DoesSupportDoNotDisturbMode01 4130 * @tc.desc: Test DoesSupportDoNotDisturbMode return. 4131 * @tc.type: FUNC 4132 * @tc.require: issueI620XB 4133 */ 4134 HWTEST_F(AnsManagerStubTest, DoesSupportDoNotDisturbMode01, Function | SmallTest | Level1) 4135 { 4136 bool doesSupport = true; 4137 4138 ErrCode result = ansManagerStub_->DoesSupportDoNotDisturbMode(doesSupport); 4139 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4140 } 4141 4142 /** 4143 * @tc.name: IsDistributedEnabled01 4144 * @tc.desc: Test IsDistributedEnabled return. 4145 * @tc.type: FUNC 4146 * @tc.require: issueI620XB 4147 */ 4148 HWTEST_F(AnsManagerStubTest, IsDistributedEnabled01, Function | SmallTest | Level1) 4149 { 4150 bool enabled = true; 4151 4152 ErrCode result = ansManagerStub_->IsDistributedEnabled(enabled); 4153 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4154 } 4155 4156 /** 4157 * @tc.name: EnableDistributed01 4158 * @tc.desc: Test EnableDistributed return. 4159 * @tc.type: FUNC 4160 * @tc.require: issueI620XB 4161 */ 4162 HWTEST_F(AnsManagerStubTest, EnableDistributed01, Function | SmallTest | Level1) 4163 { 4164 bool enabled = true; 4165 4166 ErrCode result = ansManagerStub_->EnableDistributed(enabled); 4167 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4168 } 4169 4170 /** 4171 * @tc.name: EnableDistributedByBundle01 4172 * @tc.desc: Test EnableDistributedByBundle return. 4173 * @tc.type: FUNC 4174 * @tc.require: issueI620XB 4175 */ 4176 HWTEST_F(AnsManagerStubTest, EnableDistributedByBundle01, Function | SmallTest | Level1) 4177 { 4178 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4179 bool enabled = true; 4180 4181 ErrCode result = ansManagerStub_->EnableDistributedByBundle(bundleOption, enabled); 4182 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4183 } 4184 4185 /** 4186 * @tc.name: EnableDistributedSelf01 4187 * @tc.desc: Test EnableDistributedSelf return. 4188 * @tc.type: FUNC 4189 * @tc.require: issueI620XB 4190 */ 4191 HWTEST_F(AnsManagerStubTest, EnableDistributedSelf01, Function | SmallTest | Level1) 4192 { 4193 bool enabled = true; 4194 4195 ErrCode result = ansManagerStub_->EnableDistributedSelf(enabled); 4196 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4197 } 4198 4199 /** 4200 * @tc.name: IsDistributedEnableByBundle01 4201 * @tc.desc: Test IsDistributedEnableByBundle return. 4202 * @tc.type: FUNC 4203 * @tc.require: issueI620XB 4204 */ 4205 HWTEST_F(AnsManagerStubTest, IsDistributedEnableByBundle01, Function | SmallTest | Level1) 4206 { 4207 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4208 bool enabled = true; 4209 4210 ErrCode result = ansManagerStub_->IsDistributedEnableByBundle(bundleOption, enabled); 4211 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4212 } 4213 4214 /** 4215 * @tc.name: GetDeviceRemindType01 4216 * @tc.desc: Test GetDeviceRemindType return. 4217 * @tc.type: FUNC 4218 * @tc.require: issueI620XB 4219 */ 4220 HWTEST_F(AnsManagerStubTest, GetDeviceRemindType01, Function | SmallTest | Level1) 4221 { 4222 NotificationConstant::RemindType remindType = NotificationConstant::RemindType::NONE; 4223 4224 ErrCode result = ansManagerStub_->GetDeviceRemindType(remindType); 4225 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4226 } 4227 4228 /** 4229 * @tc.name: PublishContinuousTaskNotification01 4230 * @tc.desc: Test PublishContinuousTaskNotification return. 4231 * @tc.type: FUNC 4232 * @tc.require: issueI620XB 4233 */ 4234 HWTEST_F(AnsManagerStubTest, PublishContinuousTaskNotification01, Function | SmallTest | Level1) 4235 { 4236 sptr<NotificationRequest> request = new NotificationRequest(); 4237 4238 ErrCode result = ansManagerStub_->PublishContinuousTaskNotification(request); 4239 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4240 } 4241 4242 /** 4243 * @tc.name: CancelContinuousTaskNotification01 4244 * @tc.desc: Test CancelContinuousTaskNotification return. 4245 * @tc.type: FUNC 4246 * @tc.require: issueI620XB 4247 */ 4248 HWTEST_F(AnsManagerStubTest, CancelContinuousTaskNotification01, Function | SmallTest | Level1) 4249 { 4250 std::string label = "this is label"; 4251 int32_t notificationId = 4; 4252 4253 ErrCode result = ansManagerStub_->CancelContinuousTaskNotification(label, notificationId); 4254 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4255 } 4256 4257 /** 4258 * @tc.name: IsSupportTemplate01 4259 * @tc.desc: Test IsSupportTemplate return. 4260 * @tc.type: FUNC 4261 * @tc.require: issueI620XB 4262 */ 4263 HWTEST_F(AnsManagerStubTest, IsSupportTemplate01, Function | SmallTest | Level1) 4264 { 4265 std::string templateName = "this is templateName"; 4266 bool support = true; 4267 4268 ErrCode result = ansManagerStub_->IsSupportTemplate(templateName, support); 4269 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4270 } 4271 4272 /** 4273 * @tc.name: IsSpecialUserAllowedNotify01 4274 * @tc.desc: Test IsSpecialUserAllowedNotify return. 4275 * @tc.type: FUNC 4276 * @tc.require: issueI620XB 4277 */ 4278 HWTEST_F(AnsManagerStubTest, IsSpecialUserAllowedNotify01, Function | SmallTest | Level1) 4279 { 4280 int32_t userId = 2; 4281 bool allowed = true; 4282 4283 ErrCode result = ansManagerStub_->IsSpecialUserAllowedNotify(userId, allowed); 4284 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4285 } 4286 4287 /** 4288 * @tc.name: SetNotificationsEnabledByUser01 4289 * @tc.desc: Test SetNotificationsEnabledByUser return. 4290 * @tc.type: FUNC 4291 * @tc.require: issueI620XB 4292 */ 4293 HWTEST_F(AnsManagerStubTest, SetNotificationsEnabledByUser01, Function | SmallTest | Level1) 4294 { 4295 int32_t deviceId = 2; 4296 bool enabled = true; 4297 4298 ErrCode result = ansManagerStub_->SetNotificationsEnabledByUser(deviceId, enabled); 4299 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4300 } 4301 4302 /** 4303 * @tc.name: DeleteAllByUser01 4304 * @tc.desc: Test DeleteAllByUser return. 4305 * @tc.type: FUNC 4306 * @tc.require: issueI620XB 4307 */ 4308 HWTEST_F(AnsManagerStubTest, DeleteAllByUser01, Function | SmallTest | Level1) 4309 { 4310 int32_t userId = 2; 4311 4312 ErrCode result = ansManagerStub_->DeleteAllByUser(userId); 4313 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4314 } 4315 4316 /** 4317 * @tc.name: SetDoNotDisturbDate02 4318 * @tc.desc: Test SetDoNotDisturbDate return. 4319 * @tc.type: FUNC 4320 * @tc.require: issueI620XB 4321 */ 4322 HWTEST_F(AnsManagerStubTest, SetDoNotDisturbDate02, Function | SmallTest | Level1) 4323 { 4324 int32_t userId = 2; 4325 sptr<NotificationDoNotDisturbDate> date = new NotificationDoNotDisturbDate(); 4326 4327 ErrCode result = ansManagerStub_->SetDoNotDisturbDate(userId, date); 4328 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4329 } 4330 4331 /** 4332 * @tc.name: GetDoNotDisturbDate02 4333 * @tc.desc: Test GetDoNotDisturbDate return. 4334 * @tc.type: FUNC 4335 * @tc.require: issueI620XB 4336 */ 4337 HWTEST_F(AnsManagerStubTest, GetDoNotDisturbDate02, Function | SmallTest | Level1) 4338 { 4339 int32_t userId = 2; 4340 sptr<NotificationDoNotDisturbDate> date = new NotificationDoNotDisturbDate(); 4341 4342 ErrCode result = ansManagerStub_->GetDoNotDisturbDate(userId, date); 4343 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4344 } 4345 4346 /** 4347 * @tc.name: SetEnabledForBundleSlot01 4348 * @tc.desc: Test SetEnabledForBundleSlot return. 4349 * @tc.type: FUNC 4350 * @tc.require: issueI620XB 4351 */ 4352 HWTEST_F(AnsManagerStubTest, SetEnabledForBundleSlot01, Function | SmallTest | Level1) 4353 { 4354 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4355 NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER; 4356 bool enabled = true; 4357 4358 ErrCode result = ansManagerStub_->SetEnabledForBundleSlot(bundleOption, slotType, enabled, false); 4359 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4360 } 4361 4362 /** 4363 * @tc.name: GetEnabledForBundleSlot01 4364 * @tc.desc: Test GetEnabledForBundleSlot return. 4365 * @tc.type: FUNC 4366 * @tc.require: issueI620XB 4367 */ 4368 HWTEST_F(AnsManagerStubTest, GetEnabledForBundleSlot01, Function | SmallTest | Level1) 4369 { 4370 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4371 NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER; 4372 bool enabled = true; 4373 4374 ErrCode result = ansManagerStub_->GetEnabledForBundleSlot(bundleOption, slotType, enabled); 4375 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4376 } 4377 4378 /** 4379 * @tc.name: ShellDump01 4380 * @tc.desc: Test ShellDump return. 4381 * @tc.type: FUNC 4382 * @tc.require: issueI620XB 4383 */ 4384 HWTEST_F(AnsManagerStubTest, ShellDump01, Function | SmallTest | Level1) 4385 { 4386 std::string cmd = "this is cmd"; 4387 std::string bundle = "this is bundle"; 4388 int32_t userId = 5; 4389 std::vector<std::string> dumpInfo; 4390 4391 ErrCode result = ansManagerStub_->ShellDump(cmd, bundle, userId, 0, dumpInfo); 4392 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4393 } 4394 4395 /** 4396 * @tc.name: SetSyncNotificationEnabledWithoutApp01 4397 * @tc.desc: Test SetSyncNotificationEnabledWithoutApp return. 4398 * @tc.type: FUNC 4399 * @tc.require: issueI620XB 4400 */ 4401 HWTEST_F(AnsManagerStubTest, SetSyncNotificationEnabledWithoutApp01, Function | SmallTest | Level1) 4402 { 4403 int32_t userId = 2; 4404 bool enabled = true; 4405 4406 ErrCode result = ansManagerStub_->SetSyncNotificationEnabledWithoutApp(userId, enabled); 4407 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4408 } 4409 4410 /** 4411 * @tc.name: GetSyncNotificationEnabledWithoutApp01 4412 * @tc.desc: Test GetSyncNotificationEnabledWithoutApp return. 4413 * @tc.type: FUNC 4414 * @tc.require: issueI620XB 4415 */ 4416 HWTEST_F(AnsManagerStubTest, GetSyncNotificationEnabledWithoutApp01, Function | SmallTest | Level1) 4417 { 4418 int32_t userId = 2; 4419 bool enabled = true; 4420 4421 ErrCode result = ansManagerStub_->GetSyncNotificationEnabledWithoutApp(userId, enabled); 4422 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4423 } 4424 4425 /** 4426 * @tc.name: Subscribe01 4427 * @tc.desc: Test Subscribe return. 4428 * @tc.type: FUNC 4429 * @tc.require: issueI620XB 4430 */ 4431 HWTEST_F(AnsManagerStubTest, Subscribe01, Function | SmallTest | Level1) 4432 { 4433 sptr<NotificationSubscribeInfo> info = new NotificationSubscribeInfo(); 4434 4435 ErrCode result = ansManagerStub_->Subscribe(nullptr, info); 4436 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4437 } 4438 4439 /** 4440 * @tc.name: Unsubscribe01 4441 * @tc.desc: Test Unsubscribe return. 4442 * @tc.type: FUNC 4443 * @tc.require: issueI620XB 4444 */ 4445 HWTEST_F(AnsManagerStubTest, Unsubscribe01, Function | SmallTest | Level1) 4446 { 4447 sptr<NotificationSubscribeInfo> info = new NotificationSubscribeInfo(); 4448 4449 ErrCode result = ansManagerStub_->Unsubscribe(nullptr, info); 4450 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 4451 } 4452 4453 /** 4454 * @tc.name: HandleSetBadgeNumber01 4455 * @tc.desc: Test HandleSetBadgeNumber succeed. 4456 * @tc.type: FUNC 4457 * @tc.require: #I6C2X9 4458 */ 4459 HWTEST_F(AnsManagerStubTest, HandleSetBadgeNumber01, Function | SmallTest | Level1) 4460 { 4461 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER); 4462 MessageParcel data; 4463 MessageParcel reply; 4464 MessageOption option = {MessageOption::TF_SYNC}; 4465 4466 int32_t badgeNumber = 4; 4467 4468 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4469 data.WriteInt32(badgeNumber); 4470 4471 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4472 EXPECT_EQ(ret, (int)ERR_OK); 4473 } 4474 4475 /** 4476 * @tc.name: HandleSetBadgeNumber02 4477 * @tc.desc: Test badgeNumber in data is null. 4478 * @tc.type: FUNC 4479 * @tc.require: #I6C2X9 4480 */ 4481 HWTEST_F(AnsManagerStubTest, HandleSetBadgeNumber02, Function | SmallTest | Level1) 4482 { 4483 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER); 4484 MessageParcel data; 4485 MessageParcel reply; 4486 MessageOption option = {MessageOption::TF_SYNC}; 4487 4488 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4489 4490 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4491 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 4492 } 4493 4494 /** 4495 * @tc.name: HandleSetAdditionConfig01 4496 * @tc.desc: Test HandleSetAdditionConfig. 4497 * @tc.type: FUNC 4498 * @tc.require: #I6C2X9 4499 */ 4500 HWTEST_F(AnsManagerStubTest, HandleSetAdditionConfig01, Function | SmallTest | Level1) 4501 { 4502 MessageParcel data; 4503 MessageParcel reply; 4504 4505 data.WriteString("key"); 4506 data.WriteString("value"); 4507 4508 ErrCode ret = ansManagerStub_->HandleSetAdditionConfig(data, reply); 4509 EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); 4510 } 4511 4512 /** 4513 * @tc.name: HandleSetAdditionConfig02 4514 * @tc.desc: Test HandleSetAdditionConfig. 4515 * @tc.type: FUNC 4516 * @tc.require: #I6C2X9 4517 */ 4518 HWTEST_F(AnsManagerStubTest, HandleSetAdditionConfig02, Function | SmallTest | Level1) 4519 { 4520 MessageParcel data; 4521 MessageParcel reply; 4522 4523 data.WriteString("key"); 4524 4525 ErrCode ret = ansManagerStub_->HandleSetAdditionConfig(data, reply); 4526 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 4527 } 4528 4529 /** 4530 * @tc.name: HandleSetAdditionConfig03 4531 * @tc.desc: Test HandleSetAdditionConfig. 4532 * @tc.type: FUNC 4533 * @tc.require: #I6C2X9 4534 */ 4535 HWTEST_F(AnsManagerStubTest, HandleSetAdditionConfig03, Function | SmallTest | Level1) 4536 { 4537 MessageParcel data; 4538 MessageParcel reply; 4539 4540 ErrCode ret = ansManagerStub_->HandleSetAdditionConfig(data, reply); 4541 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 4542 } 4543 4544 /** 4545 * @tc.name: HandleRemoveNotifications01 4546 * @tc.desc: Test HandleRemoveNotifications function 4547 * @tc.type: FUNC 4548 * @tc.require: #I6C2X9 4549 */ 4550 HWTEST_F(AnsManagerStubTest, HandleRemoveNotifications01, Function | SmallTest | Level1) 4551 { 4552 MessageParcel data; 4553 MessageParcel reply; 4554 ErrCode ret = ansManagerStub_->HandleRemoveNotifications(data, reply); 4555 EXPECT_EQ(ret, (int)ERR_OK); 4556 } 4557 4558 /** 4559 * @tc.name: HandleUnregisterPushCallback01 4560 * @tc.desc: Test HandleUnregisterPushCallback function 4561 * @tc.type: FUNC 4562 * @tc.require: #I6C2X9 4563 */ 4564 HWTEST_F(AnsManagerStubTest, HandleUnregisterPushCallback01, Function | SmallTest | Level1) 4565 { 4566 MessageParcel data; 4567 MessageParcel reply; 4568 ErrCode ret = ansManagerStub_->HandleUnregisterPushCallback(data, reply); 4569 EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); 4570 } 4571 4572 /** 4573 * @tc.name: HandleRegisterPushCallback01 4574 * @tc.desc: Test HandleRegisterPushCallback function 4575 * @tc.type: FUNC 4576 * @tc.require: #I6C2X9 4577 */ 4578 HWTEST_F(AnsManagerStubTest, HandleRegisterPushCallback01, Function | SmallTest | Level1) 4579 { 4580 MessageParcel data; 4581 MessageParcel reply; 4582 ErrCode ret = ansManagerStub_->HandleRegisterPushCallback(data, reply); 4583 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 4584 } 4585 4586 /** 4587 * @tc.name: HandleRegisterPushCallback02 4588 * @tc.desc: Test HandleRegisterPushCallback succeeds. 4589 * @tc.type: FUNC 4590 * @tc.require: issueI5XQ4E 4591 */ 4592 HWTEST_F(AnsManagerStubTest, HandleRegisterPushCallback02, Function | SmallTest | Level1) 4593 { 4594 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REGISTER_PUSH_CALLBACK); 4595 MessageParcel data; 4596 MessageParcel reply; 4597 MessageOption option = {MessageOption::TF_SYNC}; 4598 sptr<AnsDialogHostClient> callback = new AnsDialogHostClient(); 4599 4600 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4601 data.WriteParcelable(callback->AsObject()); 4602 4603 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4604 EXPECT_NE((int)ret, (int)ERR_OK); 4605 } 4606 4607 /** 4608 * @tc.name: HandleRegisterPushCallback03 4609 * @tc.desc: Test HandleRegisterPushCallback succeeds. 4610 * @tc.type: FUNC 4611 * @tc.require: issueI5XQ4E 4612 */ 4613 HWTEST_F(AnsManagerStubTest, HandleRegisterPushCallback03, Function | SmallTest | Level1) 4614 { 4615 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::REGISTER_PUSH_CALLBACK); 4616 MessageParcel data; 4617 MessageParcel reply; 4618 MessageOption option = {MessageOption::TF_SYNC}; 4619 sptr<AnsDialogHostClient> callback = new AnsDialogHostClient(); 4620 sptr<NotificationCheckRequest> checkRequest = nullptr; 4621 4622 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4623 data.WriteParcelable(callback->AsObject()); 4624 data.WriteParcelable(checkRequest); 4625 4626 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4627 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 4628 } 4629 4630 /** 4631 * @tc.name: HandleGetSlotFlagsAsBundle01 4632 * @tc.desc: Test HandleGetSlotFlagsAsBundle succeeds. 4633 * @tc.type: FUNC 4634 * @tc.require: issueI5XQ4E 4635 */ 4636 HWTEST_F(AnsManagerStubTest, HandleGetSlotFlagsAsBundle01, Function | SmallTest | Level1) 4637 { 4638 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOTFLAGS_BY_BUNDLE); 4639 MessageParcel data; 4640 MessageParcel reply; 4641 MessageOption option = {MessageOption::TF_SYNC}; 4642 uint32_t res = 305; 4643 4644 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4645 4646 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4647 data.WriteStrongParcelable(bundleOption); 4648 4649 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4650 EXPECT_NE((int)ret, (int)res); 4651 } 4652 4653 /** 4654 * @tc.name: HandleGetSlotFlagsAsBundle02 4655 * @tc.desc: Test if the bundleOption in data is null. 4656 * @tc.type: FUNC 4657 * @tc.require: issueI5XQ4E 4658 */ 4659 HWTEST_F(AnsManagerStubTest, HandleGetSlotFlagsAsBundle02, Function | SmallTest | Level1) 4660 { 4661 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOTFLAGS_BY_BUNDLE); 4662 MessageParcel data; 4663 MessageParcel reply; 4664 MessageOption option = {MessageOption::TF_SYNC}; 4665 uint32_t res = 305; 4666 4667 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4668 4669 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4670 EXPECT_NE((int)ret, (int)res); 4671 } 4672 4673 /* 4674 * @tc.name: SetSmartReminderEnabled_0100 4675 * @tc.desc: test SetSmartReminderEnabled with parameters 4676 * @tc.type: FUNC 4677 */ 4678 HWTEST_F(AnsManagerStubTest, SetSmartReminderEnabled_0100, TestSize.Level1) 4679 { 4680 MessageParcel data; 4681 MessageParcel reply; 4682 bool enabled = true; 4683 data.WriteString("testDeviceType"); 4684 data.WriteBool(enabled); 4685 4686 ErrCode res = ansManagerStub_->HandleSetSmartReminderEnabled(data, reply); 4687 EXPECT_EQ(res, ERR_OK); 4688 } 4689 4690 /** 4691 * @tc.name: IsSmartReminderEnabled_0100 4692 * @tc.desc: test IsSmartReminderEnabled with parameters 4693 * @tc.type: FUNC 4694 */ 4695 HWTEST_F(AnsManagerStubTest, IsSmartReminderEnabled_0100, TestSize.Level1) 4696 { 4697 bool enable = true; 4698 MessageParcel data; 4699 MessageParcel reply; 4700 data.WriteString("testDeviceType1111"); 4701 data.WriteBool(enable); 4702 ErrCode result = ansManagerStub_->HandleIsSmartReminderEnabled(data, reply); 4703 EXPECT_EQ(result, ERR_OK); 4704 } 4705 4706 /** 4707 * @tc.name: HandleSetSlotFlagsAsBundle01 4708 * @tc.desc: Test HandleSetSlotFlagsAsBundle succeeds. 4709 * @tc.type: FUNC 4710 * @tc.require: issueI5XQ4E 4711 */ 4712 HWTEST_F(AnsManagerStubTest, HandleSetSlotFlagsAsBundle01, Function | SmallTest | Level1) 4713 { 4714 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_SLOTFLAGS_BY_BUNDLE); 4715 MessageParcel data; 4716 MessageParcel reply; 4717 MessageOption option = {MessageOption::TF_SYNC}; 4718 uint32_t res = 305; 4719 4720 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4721 4722 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4723 data.WriteStrongParcelable(bundleOption); 4724 4725 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4726 EXPECT_NE((int)ret, (int)res); 4727 } 4728 4729 /** 4730 * @tc.name: HandleGetAllNotificationEnableStatus 4731 * @tc.desc: Test HandleGetAllNotificationEnableStatus. 4732 * @tc.type: FUNC 4733 * @tc.require: issueI92VGR 4734 */ 4735 HWTEST_F(AnsManagerStubTest, HandleGetAllNotificationEnableStatus01, Function | SmallTest | Level1) 4736 { 4737 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_ALL_NOTIFICATION_ENABLE_STATUS); 4738 MessageParcel data; 4739 MessageParcel reply; 4740 MessageOption option = {MessageOption::TF_SYNC}; 4741 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4742 4743 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4744 EXPECT_EQ(ret, (int)ERR_OK); 4745 } 4746 4747 /** 4748 * @tc.name: HandleSetSlotFlagsAsBundle02 4749 * @tc.desc: Test if the bundleOption in data is null. 4750 * @tc.type: FUNC 4751 * @tc.require: issueI5XQ4E 4752 */ 4753 HWTEST_F(AnsManagerStubTest, HandleSetSlotFlagsAsBundle02, Function | SmallTest | Level1) 4754 { 4755 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::SET_SLOTFLAGS_BY_BUNDLE); 4756 MessageParcel data; 4757 MessageParcel reply; 4758 MessageOption option = {MessageOption::TF_SYNC}; 4759 uint32_t res = 305; 4760 4761 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4762 4763 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4764 EXPECT_NE((int)ret, (int)res); 4765 } 4766 4767 /* 4768 * @tc.name: SetDistributedEnabledByBundle_0100 4769 * @tc.desc: test SetDistributedEnabledByBundle with parameters 4770 * @tc.type: FUNC 4771 */ 4772 HWTEST_F(AnsManagerStubTest, SetDistributedEnabledByBundle_0100, TestSize.Level1) 4773 { 4774 MessageParcel data; 4775 MessageParcel reply; 4776 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4777 bundleOption->SetBundleName("bundleName"); 4778 bundleOption->SetUid(1); 4779 std::string deviceType = "testDeviceType"; 4780 bool enabled = true; 4781 data.WriteParcelable(bundleOption); 4782 data.WriteString(deviceType); 4783 data.WriteBool(enabled); 4784 4785 ErrCode res = ansManagerStub_->HandleSetDistributedEnabledByBundle(data, reply); 4786 EXPECT_EQ(res, ERR_OK); 4787 } 4788 4789 /* 4790 * @tc.name: SetDistributedEnabledByBundle_0200 4791 * @tc.desc: test SetDistributedEnabledByBundle 4792 * @tc.type: FUNC 4793 */ 4794 HWTEST_F(AnsManagerStubTest, SetDistributedEnabledByBundle_0200, TestSize.Level1) 4795 { 4796 MessageParcel data; 4797 MessageParcel reply; 4798 data.WriteParcelable(nullptr); 4799 4800 ErrCode res = ansManagerStub_->HandleSetDistributedEnabledByBundle(data, reply); 4801 EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); 4802 } 4803 4804 /** 4805 * @tc.name: IsDistributedEnabledByBundle_0100 4806 * @tc.desc: test IsDistributedEnabledByBundle with parameters 4807 * @tc.type: FUNC 4808 */ 4809 HWTEST_F(AnsManagerStubTest, IsDistributedEnabledByBundle_0100, TestSize.Level1) 4810 { 4811 sptr<NotificationBundleOption> bundleOption = new NotificationBundleOption(); 4812 bundleOption->SetBundleName("bundleName"); 4813 bundleOption->SetUid(1); 4814 std::string deviceType = "testDeviceType1111"; 4815 bool enable = true; 4816 4817 MessageParcel data; 4818 MessageParcel reply; 4819 data.WriteParcelable(bundleOption); 4820 data.WriteString(deviceType); 4821 data.WriteBool(enable); 4822 ErrCode result = ansManagerStub_->HandleIsDistributedEnabledByBundle(data, reply); 4823 EXPECT_EQ(result, ERR_OK); 4824 } 4825 4826 /** 4827 * @tc.name: IsDistributedEnabledByBundle_0200 4828 * @tc.desc: test IsDistributedEnabledByBundle with parameters 4829 * @tc.type: FUNC 4830 */ 4831 HWTEST_F(AnsManagerStubTest, IsDistributedEnabledByBundle_0200, TestSize.Level1) 4832 { 4833 MessageParcel data; 4834 MessageParcel reply; 4835 4836 data.WriteParcelable(nullptr); 4837 4838 ErrCode result = ansManagerStub_->HandleIsDistributedEnabledByBundle(data, reply); 4839 EXPECT_EQ(result, ERR_ANS_PARCELABLE_FAILED); 4840 } 4841 4842 /** 4843 * @tc.name: HandleSetBadgeNumberByBundle01 4844 * @tc.desc: Test HandleSetBadgeNumberByBundle with invalid data, expect error code ERR_ANS_PARCELABLE_FAILED. 4845 * @tc.type: FUNC 4846 */ 4847 HWTEST_F(AnsManagerStubTest, HandleSetBadgeNumberByBundle01, Function | SmallTest | Level1) 4848 { 4849 ASSERT_NE(ansManagerStub_, nullptr); 4850 MessageParcel data; 4851 MessageParcel reply; 4852 4853 sptr<NotificationBundleOption> bundleOption = new (std::nothrow) NotificationBundleOption(); 4854 EXPECT_NE(bundleOption, nullptr); 4855 data.WriteParcelable(bundleOption); 4856 4857 ErrCode ret = ansManagerStub_->HandleSetBadgeNumberByBundle(data, reply); 4858 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 4859 4860 int32_t badgeNumber = 4; 4861 data.WriteInt32(badgeNumber); 4862 ret = ansManagerStub_->HandleSetBadgeNumberByBundle(data, reply); 4863 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 4864 } 4865 4866 /** 4867 * @tc.name: HandleSetBadgeNumberByBundle02 4868 * @tc.desc: Test HandleSetBadgeNumberByBundle with valid data, expect error code ERR_INVALID_OPERATION. 4869 * @tc.type: FUNC 4870 */ 4871 HWTEST_F(AnsManagerStubTest, HandleSetBadgeNumberByBundle02, Function | SmallTest | Level1) 4872 { 4873 ASSERT_NE(ansManagerStub_, nullptr); 4874 MessageParcel data; 4875 MessageParcel reply; 4876 4877 sptr<NotificationBundleOption> bundleOption = new (std::nothrow) NotificationBundleOption(); 4878 EXPECT_NE(bundleOption, nullptr); 4879 std::string bundleName = "bundleName"; 4880 bundleOption->SetBundleName(bundleName); 4881 data.WriteParcelable(bundleOption); 4882 int32_t badgeNumber = 4; 4883 data.WriteInt32(badgeNumber); 4884 ErrCode ret = ansManagerStub_->HandleSetBadgeNumberByBundle(data, reply); 4885 EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); 4886 } 4887 4888 /** 4889 * @tc.name: HandleAddDoNotDisturbProfiles_0100 4890 * @tc.desc: test HandleAddDoNotDisturbProfiles when ReadParcelableVector return false. 4891 * @tc.type: FUNC 4892 */ 4893 HWTEST_F(AnsManagerStubTest, HandleAddDoNotDisturbProfiles_0100, TestSize.Level1) 4894 { 4895 MessageParcel data; 4896 MessageParcel reply; 4897 ErrCode ret = ansManagerStub_->HandleAddDoNotDisturbProfiles(data, reply); 4898 EXPECT_EQ(ret, ERR_OK); 4899 } 4900 4901 /** 4902 * @tc.name: HandleAddDoNotDisturbProfiles_0200 4903 * @tc.desc: test HandleAddDoNotDisturbProfiles success. 4904 * @tc.type: FUNC 4905 */ 4906 HWTEST_F(AnsManagerStubTest, HandleAddDoNotDisturbProfiles_0200, TestSize.Level1) 4907 { 4908 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOTS); 4909 MessageParcel data; 4910 MessageParcel reply; 4911 MessageOption option = {MessageOption::TF_SYNC}; 4912 4913 int32_t id = 1; 4914 std::string name = "Name"; 4915 std::vector<NotificationBundleOption> trustlist; 4916 std::vector<sptr<NotificationDoNotDisturbProfile>> profiles; 4917 sptr<NotificationDoNotDisturbProfile> disturbProfile = 4918 new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); 4919 profiles.emplace_back(disturbProfile); 4920 4921 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4922 ErrCode result = ansManagerStub_->AddDoNotDisturbProfiles(profiles); 4923 ansManagerStub_->WriteParcelableVector(profiles, reply, result); 4924 4925 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4926 EXPECT_EQ(ret, (int)ERR_OK); 4927 } 4928 4929 /** 4930 * @tc.name: HandleRemoveDoNotDisturbProfiles_0200 4931 * @tc.desc: test HandleRemoveDoNotDisturbProfiles success. 4932 * @tc.type: FUNC 4933 */ 4934 HWTEST_F(AnsManagerStubTest, HandleRemoveDoNotDisturbProfiles, TestSize.Level1) 4935 { 4936 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::GET_SLOTS); 4937 MessageParcel data; 4938 MessageParcel reply; 4939 MessageOption option = {MessageOption::TF_SYNC}; 4940 4941 int32_t id = 1; 4942 std::string name = "Name"; 4943 std::vector<NotificationBundleOption> trustlist; 4944 std::vector<sptr<NotificationDoNotDisturbProfile>> profiles; 4945 sptr<NotificationDoNotDisturbProfile> disturbProfile = 4946 new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); 4947 profiles.emplace_back(disturbProfile); 4948 4949 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 4950 ErrCode result = ansManagerStub_->AddDoNotDisturbProfiles(profiles); 4951 ansManagerStub_->WriteParcelableVector(profiles, reply, result); 4952 4953 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 4954 EXPECT_EQ(ret, (int)ERR_OK); 4955 } 4956 4957 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED 4958 /* 4959 * @tc.name: RegisterSwingCallback_0100 4960 * @tc.desc: test RegisterSwingCallback with parameters 4961 * @tc.type: FUNC 4962 */ 4963 HWTEST_F(AnsManagerStubTest, RegisterSwingCallback_0100, TestSize.Level1) 4964 { 4965 MessageParcel data; 4966 MessageParcel reply; 4967 sptr<IRemoteObject> swingCallback = nullptr; 4968 data.WriteRemoteObject(swingCallback); 4969 ErrCode res = ansManagerStub_->HandleRegisterSwingCallback(data, reply); 4970 EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); 4971 } 4972 4973 /* 4974 * @tc.name: RegisterSwingCallback_0200 4975 * @tc.desc: test RegisterSwingCallback with parameters 4976 * @tc.type: FUNC 4977 */ 4978 HWTEST_F(AnsManagerStubTest, RegisterSwingCallback_0200, TestSize.Level1) 4979 { 4980 MessageParcel data; 4981 MessageParcel reply; 4982 sptr<IRemoteObject> swingCallback = nullptr; 4983 data.WriteRemoteObject(swingCallback); 4984 ErrCode res = ansManagerStub_->HandleRegisterSwingCallback(data, reply); 4985 EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); 4986 } 4987 #endif 4988 4989 /** 4990 * @tc.name: HandleIsNeedSilentInDoNotDisturbMode01 4991 * @tc.desc: Test HandleIsNeedSilentInDoNotDisturbMode01 succeeds. 4992 * @tc.type: FUNC 4993 */ 4994 HWTEST_F(AnsManagerStubTest, HandleIsNeedSilentInDoNotDisturbMode01, Function | SmallTest | Level1) 4995 { 4996 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::IS_NEED_SILENT_IN_DO_NOT_DISTURB_MODE); 4997 MessageParcel data; 4998 MessageParcel reply; 4999 MessageOption option = {MessageOption::TF_SYNC}; 5000 5001 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 5002 5003 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 5004 EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); 5005 } 5006 5007 /** 5008 * @tc.name: IsNeedSilentInDoNotDisturbMode01 5009 * @tc.desc: Test IsNeedSilentInDoNotDisturbMode return. 5010 * @tc.type: FUNC 5011 */ 5012 HWTEST_F(AnsManagerStubTest, IsNeedSilentInDoNotDisturbMode01, Function | SmallTest | Level1) 5013 { 5014 std::string phoneNumber = "11111111111"; 5015 int32_t callerType = 0; 5016 5017 ErrCode result = ansManagerStub_->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); 5018 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 5019 } 5020 5021 /** 5022 * @tc.name: UpdateNotificationTimerByUid_01 5023 * @tc.desc: Test UpdateNotificationTimerByUid return. 5024 * @tc.type: FUNC 5025 */ 5026 HWTEST_F(AnsManagerStubTest, UpdateNotificationTimerByUid_01, Function | SmallTest | Level1) 5027 { 5028 int32_t uid = 20099999; 5029 bool isPaused = true; 5030 ErrCode result = ansManagerStub_->UpdateNotificationTimerByUid(uid, isPaused); 5031 EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); 5032 } 5033 5034 /** 5035 * @tc.name: HandleDisableNotificationFeature_01 5036 * @tc.desc: Test HandleDisableNotificationFeature. 5037 * @tc.type: FUNC 5038 */ 5039 HWTEST_F(AnsManagerStubTest, HandleDisableNotificationFeature_01, Function | SmallTest | Level1) 5040 { 5041 uint32_t code = static_cast<uint32_t>(NotificationInterfaceCode::DISABLE_NOTIFICATION_FEATURE); 5042 MessageParcel data; 5043 MessageParcel reply; 5044 MessageOption option = {MessageOption::TF_SYNC}; 5045 sptr<NotificationDisable> testNotificationDisable = new (std::nothrow) NotificationDisable(); 5046 5047 data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); 5048 data.WriteParcelable(testNotificationDisable); 5049 5050 ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); 5051 EXPECT_EQ(ret, ERR_OK); 5052 } 5053 } 5054 } 5055