From 619d10acedc0b252c45171fe62fa094ecff7fd25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=AF=E5=BF=97=E9=9B=84?= Date: Thu, 29 Aug 2024 09:54:39 +0800 Subject: [PATCH 1/2] ans MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 侯志雄 --- .../unittest/notification_helper_test.cpp | 15 + .../ans_manager_proxy_unit_test.cpp | 16276 ++++++++-------- .../ans_manager_stub_test.cpp | 32 + .../ans_notification_unit_test.cpp | 3046 +-- noti.diff | 582 + notification.gni | 6 + services/ans/BUILD.gn | 5 + services/ans/BUILD.gn.orig | 224 + .../include/notification_extension_wrapper.h | 6 - .../ans/src/advanced_datashare_helper.cpp | 49 +- ...nced_notification_service_ability.cpp.orig | 113 + ...anced_notification_service_ability.cpp.rej | 27 + .../src/notification_extension_wrapper.cpp | 26 - .../notification_extension_wrapper.cpp.orig | 221 + ...anced_notification_service_branch_test.cpp | 31 + ..._notification_service_branch_test.cpp.orig | 1193 ++ .../advanced_notification_service_test.cpp | 21 + ...dvanced_notification_service_test.cpp.orig | 3736 ++++ ...ication_subscriber_manager_branch_test.cpp | 2655 +-- 19 files changed, 17295 insertions(+), 10969 deletions(-) create mode 100644 noti.diff create mode 100644 services/ans/BUILD.gn.orig create mode 100644 services/ans/src/advanced_notification_service_ability.cpp.orig create mode 100644 services/ans/src/advanced_notification_service_ability.cpp.rej create mode 100644 services/ans/src/notification_extension_wrapper.cpp.orig create mode 100644 services/ans/test/unittest/advanced_notification_service_branch_test.cpp.orig create mode 100644 services/ans/test/unittest/advanced_notification_service_test.cpp.orig diff --git a/frameworks/ans/test/unittest/notification_helper_test.cpp b/frameworks/ans/test/unittest/notification_helper_test.cpp index 85597c7e1..eb49dc9b4 100644 --- a/frameworks/ans/test/unittest/notification_helper_test.cpp +++ b/frameworks/ans/test/unittest/notification_helper_test.cpp @@ -1359,5 +1359,20 @@ HWTEST_F(NotificationHelperTest, RegisterSwingCallback_0100, TestSize.Level1) EXPECT_EQ(ret, ERR_OK); #endif } + +/** + * @tc.name: IsNeedSilentInDoNotDisturbMode_00001 + * @tc.desc: Test IsNeedSilentInDoNotDisturbMode parameters. + * @tc.type: FUNC + * @tc.require: issueI5WRQ2 + */ +HWTEST_F(NotificationHelperTest, IsNeedSilentInDoNotDisturbMode_00001, Function | SmallTest | Level1) +{ + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + NotificationHelper notificationHelper; + ErrCode ret = notificationHelper.IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); + EXPECT_EQ(ret, (int)ERR_OK); +} } } diff --git a/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp b/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp index 326f45052..814dd4393 100644 --- a/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp +++ b/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp @@ -1,8084 +1,8192 @@ -/* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#define private public -#define protected public -#include "ans_manager_proxy.h" -#include "notification_subscriber.h" -#undef private -#undef protected -#include "ans_const_define.h" -#include "ans_dialog_host_client.h" -#include "ans_manager_interface.h" -#include "ans_inner_errors.h" -#include "message_parcel.h" -#include "mock_i_remote_object.h" -#include "notification.h" - -using namespace testing; -using namespace testing::ext; -using namespace OHOS; -using namespace OHOS::Notification; -using namespace std::placeholders; -using namespace OHOS::Media; - -extern void MockWriteInterfaceToken(bool mockRet); - -namespace OHOS { -namespace Notification { -class AnsManagerProxyUnitTest : public testing::Test { -public: - AnsManagerProxyUnitTest() {} - - virtual ~AnsManagerProxyUnitTest() {} - - static void SetUpTestCase(); - - static void TearDownTestCase(); - - void SetUp(); - - void TearDown(); - std::shared_ptr MakeNewPixelMap(int32_t width, int32_t height); -}; - -void AnsManagerProxyUnitTest::SetUpTestCase() -{ - MockWriteInterfaceToken(true); -} - -void AnsManagerProxyUnitTest::TearDownTestCase() {} - -void AnsManagerProxyUnitTest::SetUp() {} - -void AnsManagerProxyUnitTest::TearDown() {} - -int SendRequestReplace(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, - int32_t error, bool setError, bool retBool, bool setRetBool) -{ - if (setError) { - reply.WriteInt32(error); - } - if (setRetBool) { - reply.WriteBool(retBool); - } - return 0; -} - -int SendRequestReplaceNum(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, - int32_t error, bool setError, uint64_t retNum, bool setRetNum) -{ - if (setError) { - reply.WriteInt32(error); - } - if (setRetNum) { - reply.WriteUint64(retNum); - } - return 0; -} - -int SendRequestReplaceString(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, - int32_t error, bool setError, std::string retStr, bool setRetStr) -{ - if (setError) { - reply.WriteInt32(error); - } - if (setRetStr) { - reply.WriteString(retStr); - } - return 0; -} - -int SendRequestGetAllEnableNotifications(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option, int32_t error, int32_t retnum, bool setError, int32_t notificationNum) -{ - if (setError) { - reply.WriteInt32(error); - } - - if (retnum) { - reply.WriteInt32(retnum); - } - - if (notificationNum > 0) { - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - for (int32_t i = 0; i < notificationNum; i++) { - reply.WriteParcelable(bundleOption); - } - } - - return 0; -} - -class TestSubscriber : public NotificationSubscriber { -public: - void OnDisconnected() override - {} - void OnDied() override - {} - void OnUpdate(const std::shared_ptr &sortingMap) override - {} - void OnDoNotDisturbDateChange(const std::shared_ptr &date) override - {} - void OnConnected() override - {} - void OnEnabledNotificationChanged( - const std::shared_ptr &callbackData) override - {} - void OnCanceled(const std::shared_ptr &request, - const std::shared_ptr &sortingMap, int deleteReason) override - {} - void OnBadgeChanged(const std::shared_ptr &badgeData) override - {} - void OnBadgeEnabledChanged(const sptr &callbackData) override - {} - void OnConsumed(const std::shared_ptr &request, - const std::shared_ptr &sortingMap) override - {} - - void OnBatchCanceled(const std::vector> - &requestList, const std::shared_ptr &sortingMap, int32_t deleteReason) override - {} -}; - -/* - * @tc.name: InnerTransactTest_0100 - * @tc.desc: test if AnsManagerProxy's InnerTransact function executed as expected in normal case. - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, InnerTransactTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, InnerTransactTest_0100, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).WillOnce(DoAll(Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - uint32_t code = 0; - MessageOption flags; - MessageParcel data; - MessageParcel reply; - ErrCode res = proxy->InnerTransact(static_cast(code), flags, data, reply); - EXPECT_EQ(ERR_OK, res); -} - -/* - * @tc.name: InnerTransactTest_0200 - * @tc.desc: test AnsManagerProxy's InnerTransact function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, InnerTransactTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, InnerTransactTest_0200, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).WillOnce(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - uint32_t code = 0; - MessageOption flags; - MessageParcel data; - MessageParcel reply; - ErrCode res = proxy->InnerTransact(static_cast(code), flags, data, reply); - EXPECT_EQ(ERR_DEAD_OBJECT, res); -} - -/* - * @tc.name: InnerTransactTest_0300 - * @tc.desc: test AnsManagerProxy's InnerTransact function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, InnerTransactTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, InnerTransactTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).WillOnce(DoAll(Return(-1))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - uint32_t code = 0; - MessageOption flags; - MessageParcel data; - MessageParcel reply; - ErrCode res = proxy->InnerTransact(static_cast(code), flags, data, reply); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, res); -} - -/* - * @tc.name: InnerTransactTest_0400 - * @tc.desc: test AnsManagerProxy's InnerTransact function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, InnerTransactTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, InnerTransactTest_0400, TestSize.Level1"; - std::shared_ptr proxy = std::make_shared(nullptr); - ASSERT_NE(nullptr, proxy); - uint32_t code = 0; - MessageOption flags; - MessageParcel data; - MessageParcel reply; - ErrCode res = proxy->InnerTransact(static_cast(code), flags, data, reply); - EXPECT_EQ(ERR_DEAD_OBJECT, res); -} - -/* - * @tc.name: PublishTest_0100 - * @tc.desc: test Publish function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishTest_0100, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string label = "label"; - sptr notification = nullptr; - int32_t result = proxy->Publish(label, notification); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: PublishTest_0200 - * @tc.desc: test Publish function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string label = "label"; - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - ASSERT_NE(nullptr, notification); - int32_t result = proxy->Publish(label, notification); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: PublishTest_0300 - * @tc.desc: test Publish function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishTest_0300, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string label = ""; - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - ASSERT_NE(nullptr, notification); - int32_t result = proxy->Publish(label, notification); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: PublishTest_0400 - * @tc.desc: test Publish function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string label = "label"; - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - ASSERT_NE(nullptr, notification); - int32_t result = proxy->Publish(label, notification); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: PublishTest_0500 - * @tc.desc: test Publish function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string label = "label"; - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - ASSERT_NE(nullptr, notification); - int32_t result = proxy->Publish(label, notification); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: PublishTest_0600 - * @tc.desc: test Publish function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string label = "label"; - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - ASSERT_NE(nullptr, notification); - int32_t result = proxy->Publish(label, notification); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -std::shared_ptr AnsManagerProxyUnitTest::MakeNewPixelMap(int32_t width, int32_t height) -{ - const int32_t PIXEL_BYTES = 4; - std::shared_ptr pixelMap = std::make_shared(); - if (pixelMap == nullptr) { - return nullptr; - } - ImageInfo info; - info.size.width = width; - info.size.height = height; - info.pixelFormat = PixelFormat::ARGB_8888; - info.colorSpace = ColorSpace::SRGB; - pixelMap->SetImageInfo(info); - int32_t rowDataSize = width * PIXEL_BYTES; - uint32_t bufferSize = rowDataSize * height; - void *buffer = malloc(bufferSize); - if (buffer != nullptr) { - pixelMap->SetPixelsAddr(buffer, nullptr, bufferSize, AllocatorType::HEAP_ALLOC, nullptr); - } - return pixelMap; -} - -/* - * @tc.name: PublishTest_0700 - * @tc.desc: test Publish function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0700, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishTest_0700, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string label = "label"; - auto slotType = NotificationConstant::SlotType::LIVE_VIEW; - NotificationRequest request(1); - request.SetSlotType(slotType); - request.SetNotificationId(1); - - int pictureWidth = 1024; - int pictureLength = 1024 * 2 + 1; - auto basicContent = std::make_shared(); - basicContent->SetLockScreenPicture(MakeNewPixelMap(pictureWidth, pictureLength)); - auto result = request.CheckLockScreenPictureSizeForLiveView(basicContent); - EXPECT_EQ(ERR_ANS_PICTURE_OVER_SIZE, result); - - auto liveContent = std::make_shared(); - liveContent->SetLockScreenPicture(MakeNewPixelMap(1, 1)); - auto content = std::make_shared(liveContent); - request.SetContent(content); - - sptr notification = new (std::nothrow) NotificationRequest(request); - ASSERT_NE(nullptr, notification); - result = proxy->Publish(label, notification); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: CancelTest_0100 - * @tc.desc: test Cancel function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - std::string label = "label"; - int32_t result = proxy->Cancel(notificationId, label, 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelTest_0200 - * @tc.desc: test Cancel function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - std::string label = ""; - int32_t result = proxy->Cancel(notificationId, label, 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelTest_0300 - * @tc.desc: test Cancel function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - std::string label = "label"; - int32_t result = proxy->Cancel(notificationId, label, 0); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: CancelTest_0400 - * @tc.desc: test Cancel function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - std::string label = "label"; - int32_t result = proxy->Cancel(notificationId, label, 0); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: CancelTest_0500 - * @tc.desc: test Cancel function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - std::string label = "label"; - int32_t result = proxy->Cancel(notificationId, label, 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelAllTest_0100 - * @tc.desc: test CancelAll function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAllTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAllTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelAll(0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelAllTest_0200 - * @tc.desc: test CancelAll function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAllTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAllTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelAll(0); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: CancelAllTest_0300 - * @tc.desc: test CancelAll function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAllTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAllTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelAll(0); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: CancelAllTest_0400 - * @tc.desc: test CancelAll function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAllTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAllTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelAll(0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelAsBundleTest_0100 - * @tc.desc: test CancelAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAsBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - std::string representativeBundle = "Bundle"; - int32_t userId = 0; - int32_t result = proxy->CancelAsBundle(notificationId, representativeBundle, userId); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelAsBundleTest_0200 - * @tc.desc: test CancelAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAsBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - std::string representativeBundle = ""; - int32_t userId = 0; - int32_t result = proxy->CancelAsBundle(notificationId, representativeBundle, userId); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelAsBundleTest_0300 - * @tc.desc: test CancelAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAsBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - std::string representativeBundle = "Bundle"; - int32_t userId = 0; - int32_t result = proxy->CancelAsBundle(notificationId, representativeBundle, userId); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: CancelAsBundleTest_0400 - * @tc.desc: test CancelAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAsBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - std::string representativeBundle = "Bundle"; - int32_t userId = 0; - int32_t result = proxy->CancelAsBundle(notificationId, representativeBundle, userId); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: CancelAsBundleTest_0500 - * @tc.desc: test CancelAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAsBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - std::string representativeBundle = "Bundle"; - int32_t userId = 0; - int32_t result = proxy->CancelAsBundle(notificationId, representativeBundle, userId); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelAsBundleTest_0600 - * @tc.desc: test CancelAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAsBundleTest_0600, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->CancelAsBundle(bundleOption, notificationId); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelAsBundleTest_0700 - * @tc.desc: test CancelAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0700, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelAsBundleTest_0700, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t notificationId = 0; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t userId = 0; - int32_t result = proxy->CancelAsBundle(bundleOption, notificationId, userId); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: AddSlotByTypeTest_0100 - * @tc.desc: test AddSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, AddSlotByTypeTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, AddSlotByTypeTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->AddSlotByType(slotType); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: AddSlotByTypeTest_0200 - * @tc.desc: test AddSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, AddSlotByTypeTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, AddSlotByTypeTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->AddSlotByType(slotType); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: AddSlotByTypeTest_0300 - * @tc.desc: test AddSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, AddSlotByTypeTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, AddSlotByTypeTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->AddSlotByType(slotType); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: AddSlotByTypeTest_0400 - * @tc.desc: test AddSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, AddSlotByTypeTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, AddSlotByTypeTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->AddSlotByType(slotType); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: AddSlotsTest_0100 - * @tc.desc: test AddSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, AddSlotsTest_0100, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - int32_t result = proxy->AddSlots(slots); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: AddSlotsTest_0200 - * @tc.desc: test AddSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, AddSlotsTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - int32_t result = proxy->AddSlots(slots); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: AddSlotsTest_0300 - * @tc.desc: test AddSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, AddSlotsTest_0300, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - slots.resize(MAX_SLOT_NUM + 1); // set MAX_SLOT_NUM + 1 slots - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - int32_t result = proxy->AddSlots(slots); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: AddSlotsTest_0400 - * @tc.desc: test AddSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, AddSlotsTest_0400, TestSize.Level1"; - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - int32_t result = proxy->AddSlots(slots); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: AddSlotsTest_0500 - * @tc.desc: test AddSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, AddSlotsTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - int32_t result = proxy->AddSlots(slots); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: AddSlotsTest_0600 - * @tc.desc: test AddSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, AddSlotsTest_0600, TestSize.Level1"; - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - int32_t result = proxy->AddSlots(slots); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RequestEnableNotificationTest_0100 - * @tc.desc: test RequestEnableNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RequestEnableNotificationTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RequestEnableNotificationTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string deviceId = "Device"; - sptr callerToken = nullptr; - sptr client = nullptr; - AnsDialogHostClient::CreateIfNullptr(client); - client = AnsDialogHostClient::GetInstance(); - int32_t result = proxy->RequestEnableNotification(deviceId, client, callerToken); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RequestEnableNotificationTest_0200 - * @tc.desc: test RequestEnableNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RequestEnableNotificationTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RequestEnableNotificationTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string deviceId = ""; - sptr callerToken = nullptr; - sptr client = nullptr; - AnsDialogHostClient::CreateIfNullptr(client); - client = AnsDialogHostClient::GetInstance(); - int32_t result = proxy->RequestEnableNotification(deviceId, client, callerToken); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RequestEnableNotificationTest_0300 - * @tc.desc: test RequestEnableNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RequestEnableNotificationTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RequestEnableNotificationTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string deviceId = "Device"; - sptr callerToken = nullptr; - sptr client = nullptr; - AnsDialogHostClient::CreateIfNullptr(client); - client = AnsDialogHostClient::GetInstance(); - int32_t result = proxy->RequestEnableNotification(deviceId, client, callerToken); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: RequestEnableNotificationTest_0400 - * @tc.desc: test RequestEnableNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RequestEnableNotificationTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RequestEnableNotificationTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string deviceId = "Device"; - sptr callerToken = nullptr; - sptr client = nullptr; - AnsDialogHostClient::CreateIfNullptr(client); - client = AnsDialogHostClient::GetInstance(); - int32_t result = proxy->RequestEnableNotification(deviceId, client, callerToken); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: RemoveSlotByTypeTest_0100 - * @tc.desc: test RemoveSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->RemoveSlotByType(slotType); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RemoveSlotByTypeTest_0200 - * @tc.desc: test RemoveSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->RemoveSlotByType(slotType); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: RemoveSlotByTypeTest_0300 - * @tc.desc: test RemoveSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->RemoveSlotByType(slotType); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: RemoveSlotByTypeTest_0400 - * @tc.desc: test RemoveSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->RemoveSlotByType(slotType); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RemoveAllSlotsTest_0100 - * @tc.desc: test RemoveAllSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveAllSlotsTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveAllSlotsTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->RemoveAllSlots(); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RemoveAllSlotsTest_0200 - * @tc.desc: test RemoveAllSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveAllSlotsTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveAllSlotsTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->RemoveAllSlots(); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: RemoveAllSlotsTest_0300 - * @tc.desc: test RemoveAllSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveAllSlotsTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveAllSlotsTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->RemoveAllSlots(); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: RemoveAllSlotsTest_0400 - * @tc.desc: test RemoveAllSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveAllSlotsTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveAllSlotsTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->RemoveAllSlots(); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -int SendRequestReplaceSlot(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, - int32_t error, bool setError, int32_t slotNum) -{ - if (setError) { - reply.WriteInt32(error); - } - - if (slotNum == 1) { - sptr slot = new (std::nothrow) NotificationSlot(); - reply.WriteParcelable(slot); - } - if (slotNum > 1) { - reply.WriteInt32(slotNum); - for (int32_t i = 0; i < slotNum; i++) { - sptr slot = new (std::nothrow) NotificationSlot(); - reply.WriteStrongParcelable(slot); - } - } - return 0; -} - -/* - * @tc.name: GetSlotByTypeTest_0100 - * @tc.desc: test GetSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotByTypeTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotByTypeTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - sptr slot = nullptr; - int32_t result = proxy->GetSlotByType(slotType, slot); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotByTypeTest_0200 - * @tc.desc: test GetSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotByTypeTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotByTypeTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, - ERR_OK, true, 1)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - sptr slot = nullptr; - int32_t result = proxy->GetSlotByType(slotType, slot); - EXPECT_EQ(ERR_OK, result); - EXPECT_NE(nullptr, slot); -} -/* - * @tc.name: GetSlotByTypeTest_0300 - * @tc.desc: test GetSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotByTypeTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotByTypeTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - sptr slot = nullptr; - int32_t result = proxy->GetSlotByType(slotType, slot); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetSlotByTypeTest_0400 - * @tc.desc: test GetSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotByTypeTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotByTypeTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, - ERR_OK, false, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - sptr slot = nullptr; - int32_t result = proxy->GetSlotByType(slotType, slot); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotByTypeTest_0500 - * @tc.desc: test GetSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotByTypeTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotByTypeTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, - ERR_OK, true, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - sptr slot = nullptr; - int32_t result = proxy->GetSlotByType(slotType, slot); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: GetSlotsTest_0100 - * @tc.desc: test GetSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - int32_t result = proxy->GetSlots(slots); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotsTest_0200 - * @tc.desc: test GetSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, - ERR_OK, true, 2)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - int32_t result = proxy->GetSlots(slots); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(2, slots.size()); -} -/* - * @tc.name: GetSlotsTest_0300 - * @tc.desc: test GetSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - int32_t result = proxy->GetSlots(slots); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetSlotsTest_0400 - * @tc.desc: test GetSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, - ERR_OK, false, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - int32_t result = proxy->GetSlots(slots); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotsTest_0500 - * @tc.desc: test GetSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, - ERR_OK, true, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - int32_t result = proxy->GetSlots(slots); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotNumAsBundleTest_0100 - * @tc.desc: test GetSlotNumAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint64_t num = 0; - int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotNumAsBundleTest_0200 - * @tc.desc: test GetSlotNumAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - uint64_t num = 0; - int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: GetSlotNumAsBundleTest_0300 - * @tc.desc: test GetSlotNumAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, true, 1, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint64_t num = 0; - int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(1, num); -} - -/* - * @tc.name: GetSlotNumAsBundleTest_0400 - * @tc.desc: test GetSlotNumAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint64_t num = 0; - int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetSlotNumAsBundleTest_0500 - * @tc.desc: test GetSlotNumAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, false, 1, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint64_t num = 0; - int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotNumAsBundleTest_0600 - * @tc.desc: test GetSlotNumAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, true, 1, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint64_t num = 0; - int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -int SendRequestReplaceNotifications(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, - int32_t error, bool setError, int32_t notificationNum) -{ - if (setError) { - reply.WriteInt32(error); - } - - if (notificationNum > 0) { - reply.WriteInt32(notificationNum); - for (int32_t i = 0; i < notificationNum; i++) { - sptr request = new (std::nothrow) NotificationRequest(0); - reply.WriteStrongParcelable(request); - } - } - - return 0; -} - -/* - * @tc.name: GetSlotFlagsAsBundleTest_0100 - * @tc.desc: test GetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint32_t soltFlags = 0; - int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotFlagsAsBundleTest_0200 - * @tc.desc: test GetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - uint32_t soltFlags = 0; - int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotFlagsAsBundleTest_0300 - * @tc.desc: test GetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0300, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - uint32_t soltFlags = 0; - int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotFlagsAsBundleTest_0400 - * @tc.desc: test GetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, true, 1, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint32_t soltFlags = 0; - int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_EQ(ERR_OK, result); - EXPECT_NE(ERR_OK, soltFlags); -} - -/* - * @tc.name: GetSlotFlagsAsBundleTest_0500 - * @tc.desc: test GetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint32_t soltFlags = 0; - int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetSlotFlagsAsBundleTest_0600 - * @tc.desc: test GetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, false, 1, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint32_t soltFlags = 0; - uint32_t res = 1; - int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_EQ(res, result); -} - -/* - * @tc.name: GetSlotFlagsAsBundleTest_0700 - * @tc.desc: test GetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0700, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0700, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, true, 1, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint32_t soltFlags = 0; - int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_NE(ERR_OK, result); -} - -/* - * @tc.name: SetSlotFlagsAsBundleTest_0100 - * @tc.desc: test SetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint32_t soltFlags = 0; - int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetSlotFlagsAsBundleTest_0200 - * @tc.desc: test SetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - uint32_t soltFlags = 0; - int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetSlotFlagsAsBundleTest_0300 - * @tc.desc: test SetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0300, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - uint32_t soltFlags = 0; - int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetSlotFlagsAsBundleTest_0400 - * @tc.desc: test SetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, true, 1, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint32_t soltFlags = 0; - int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(ERR_OK, soltFlags); -} - -/* - * @tc.name: SetSlotFlagsAsBundleTest_0500 - * @tc.desc: test SetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint32_t soltFlags = 0; - int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetSlotFlagsAsBundleTest_0600 - * @tc.desc: test SetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, false, 1, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint32_t soltFlags = 0; - uint32_t res = 1; - int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_EQ(res, result); -} - -/* - * @tc.name: SetSlotFlagsAsBundleTest_0700 - * @tc.desc: test SetSlotFlagsAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0700, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0700, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, true, 1, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - uint32_t soltFlags = 0; - int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: GetActiveNotificationsTest_0100 - * @tc.desc: test GetActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationsTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationsTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> notifications; - int32_t result = proxy->GetActiveNotifications(notifications, 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetActiveNotificationsTest_0200 - * @tc.desc: test GetActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationsTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationsTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, - ERR_OK, true, 1)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> notifications; - int32_t result = proxy->GetActiveNotifications(notifications, 0); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(1, notifications.size()); -} -/* - * @tc.name: GetActiveNotificationsTest_0300 - * @tc.desc: test GetActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationsTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationsTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> notifications; - int32_t result = proxy->GetActiveNotifications(notifications, 0); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetActiveNotificationsTest_0400 - * @tc.desc: test GetActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationsTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationsTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, - ERR_OK, false, 1)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> notifications; - int32_t result = proxy->GetActiveNotifications(notifications, 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetActiveNotificationsTest_0500 - * @tc.desc: test GetActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationsTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationsTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, - ERR_OK, true, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> notifications; - int32_t result = proxy->GetActiveNotifications(notifications, 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetActiveNotificationNumsTest_0100 - * @tc.desc: test GetActiveNotificationNums function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - uint64_t num = 0; - int32_t result = proxy->GetActiveNotificationNums(num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetActiveNotificationNumsTest_0200 - * @tc.desc: test GetActiveNotificationNums function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, true, 1, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - uint64_t num = 0; - int32_t result = proxy->GetActiveNotificationNums(num); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(1, num); -} - -/* - * @tc.name: GetActiveNotificationNumsTest_0300 - * @tc.desc: test GetActiveNotificationNums function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - uint64_t num = 0; - int32_t result = proxy->GetActiveNotificationNums(num); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetActiveNotificationNumsTest_0400 - * @tc.desc: test GetActiveNotificationNums function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, false, 1, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - uint64_t num = 0; - int32_t result = proxy->GetActiveNotificationNums(num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetActiveNotificationNumsTest_0500 - * @tc.desc: test GetActiveNotificationNums function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, true, 1, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - uint64_t num = 0; - int32_t result = proxy->GetActiveNotificationNums(num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetAllActiveNotificationsTest_0100 - * @tc.desc: test GetAllActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> notifications; - int32_t result = proxy->GetAllActiveNotifications(notifications); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetAllActiveNotificationsTest_0200 - * @tc.desc: test GetAllActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, - ERR_OK, true, 1)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> notifications; - int32_t result = proxy->GetAllActiveNotifications(notifications); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); - EXPECT_EQ(0, notifications.size()); -} -/* - * @tc.name: GetAllActiveNotificationsTest_0300 - * @tc.desc: test GetAllActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> notifications; - int32_t result = proxy->GetAllActiveNotifications(notifications); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetAllActiveNotificationsTest_0400 - * @tc.desc: test GetAllActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, - ERR_OK, false, 1)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> notifications; - int32_t result = proxy->GetAllActiveNotifications(notifications); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetAllActiveNotificationsTest_0500 - * @tc.desc: test GetAllActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, - ERR_OK, true, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> notifications; - int32_t result = proxy->GetAllActiveNotifications(notifications); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSpecialActiveNotificationsTest_0100 - * @tc.desc: test GetSpecialActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0100, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector key; - std::vector> notifications; - int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: GetSpecialActiveNotificationsTest_0200 - * @tc.desc: test GetSpecialActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector key{"0", "1"}; - std::vector> notifications; - int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSpecialActiveNotificationsTest_0300 - * @tc.desc: test GetSpecialActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0300, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, - ERR_OK, true, 1)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector key{"0", "1"}; - std::vector> notifications; - int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); - EXPECT_EQ(0, notifications.size()); -} -/* - * @tc.name: GetSpecialActiveNotificationsTest_0400 - * @tc.desc: test GetSpecialActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector key{"0", "1"}; - std::vector> notifications; - int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetSpecialActiveNotificationsTest_0500 - * @tc.desc: test GetSpecialActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, - ERR_OK, false, 1)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector key{"0", "1"}; - std::vector> notifications; - int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSpecialActiveNotificationsTest_0600 - * @tc.desc: test GetSpecialActiveNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, - ERR_OK, true, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector key{"0", "1"}; - std::vector> notifications; - int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationAgentTest_0100 - * @tc.desc: test SetNotificationAgent function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationAgentTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationAgentTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string agent = "agent"; - int32_t result = proxy->SetNotificationAgent(agent); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationAgentTest_0200 - * @tc.desc: test SetNotificationAgent function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationAgentTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationAgentTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string agent = ""; - int32_t result = proxy->SetNotificationAgent(agent); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: SetNotificationAgentTest_0300 - * @tc.desc: test SetNotificationAgent function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationAgentTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationAgentTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string agent = "agent"; - int32_t result = proxy->SetNotificationAgent(agent); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetNotificationAgentTest_0400 - * @tc.desc: test SetNotificationAgent function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationAgentTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationAgentTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string agent = "agent"; - int32_t result = proxy->SetNotificationAgent(agent); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetNotificationAgentTest_0500 - * @tc.desc: test SetNotificationAgent function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationAgentTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationAgentTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string agent = "agent"; - int32_t result = proxy->SetNotificationAgent(agent); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetNotificationAgentTest_0100 - * @tc.desc: test GetNotificationAgent function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetNotificationAgentTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetNotificationAgentTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string agent; - int32_t result = proxy->GetNotificationAgent(agent); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetNotificationAgentTest_0200 - * @tc.desc: test GetNotificationAgent function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetNotificationAgentTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetNotificationAgentTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceString, _1, _2, _3, _4, - ERR_OK, true, "0", true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string agent; - int32_t result = proxy->GetNotificationAgent(agent); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: GetNotificationAgentTest_0300 - * @tc.desc: test GetNotificationAgent function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetNotificationAgentTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetNotificationAgentTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string agent; - int32_t result = proxy->GetNotificationAgent(agent); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetNotificationAgentTest_0400 - * @tc.desc: test GetNotificationAgent function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetNotificationAgentTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetNotificationAgentTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceString, _1, _2, _3, _4, - ERR_OK, false, "0", true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string agent; - int32_t result = proxy->GetNotificationAgent(agent); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetNotificationAgentTest_0500 - * @tc.desc: test GetNotificationAgent function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetNotificationAgentTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetNotificationAgentTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceString, _1, _2, _3, _4, - ERR_OK, true, "0", false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string agent; - int32_t result = proxy->GetNotificationAgent(agent); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CanPublishAsBundleTest_0100 - * @tc.desc: test CanPublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string representativeBundle = "Bundle"; - bool canPublish = false; - int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CanPublishAsBundleTest_0200 - * @tc.desc: test CanPublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string representativeBundle = ""; - bool canPublish = false; - int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: CanPublishAsBundleTest_0300 - * @tc.desc: test CanPublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string representativeBundle = "Bundle"; - bool canPublish = false; - int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, canPublish); -} - -/* - * @tc.name: CanPublishAsBundleTest_0400 - * @tc.desc: test CanPublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string representativeBundle = "Bundle"; - bool canPublish = false; - int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: CanPublishAsBundleTest_0500 - * @tc.desc: test CanPublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string representativeBundle = "Bundle"; - bool canPublish = false; - int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CanPublishAsBundleTest_0600 - * @tc.desc: test CanPublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string representativeBundle = "Bundle"; - bool canPublish = false; - int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: PublishAsBundleTest_0100 - * @tc.desc: test PublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishAsBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - std::string representativeBundle = "Bundle"; - int32_t result = proxy->PublishAsBundle(notification, representativeBundle); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: PublishAsBundleTest_0200 - * @tc.desc: test PublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishAsBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr notification = nullptr; - std::string representativeBundle = "Bundle"; - int32_t result = proxy->PublishAsBundle(notification, representativeBundle); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: PublishAsBundleTest_0300 - * @tc.desc: test PublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishAsBundleTest_0300, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - std::string representativeBundle = ""; - int32_t result = proxy->PublishAsBundle(notification, representativeBundle); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: PublishAsBundleTest_0400 - * @tc.desc: test PublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishAsBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - std::string representativeBundle = "Bundle"; - int32_t result = proxy->PublishAsBundle(notification, representativeBundle); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: PublishAsBundleTest_0500 - * @tc.desc: test PublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishAsBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - std::string representativeBundle = "Bundle"; - int32_t result = proxy->PublishAsBundle(notification, representativeBundle); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: PublishAsBundleTest_0600 - * @tc.desc: test PublishAsBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishAsBundleTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - std::string representativeBundle = "Bundle"; - int32_t result = proxy->PublishAsBundle(notification, representativeBundle); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationBadgeNumTest_0100 - * @tc.desc: test SetNotificationBadgeNum function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t num = 0; - int32_t result = proxy->SetNotificationBadgeNum(num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationBadgeNumTest_0200 - * @tc.desc: test SetNotificationBadgeNum function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t num = 0; - int32_t result = proxy->SetNotificationBadgeNum(num); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetNotificationBadgeNumTest_0300 - * @tc.desc: test SetNotificationBadgeNum function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t num = 0; - int32_t result = proxy->SetNotificationBadgeNum(num); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetNotificationBadgeNumTest_0400 - * @tc.desc: test SetNotificationBadgeNum function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t num = 0; - int32_t result = proxy->SetNotificationBadgeNum(num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetBundleImportanceTest_0100 - * @tc.desc: test GetBundleImportance function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetBundleImportanceTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetBundleImportanceTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t num = 0; - int32_t result = proxy->GetBundleImportance(num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetBundleImportanceTest_0200 - * @tc.desc: test GetBundleImportance function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetBundleImportanceTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetBundleImportanceTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, true, 1, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t num = 0; - int32_t result = proxy->GetBundleImportance(num); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(1, num); -} - -/* - * @tc.name: GetBundleImportanceTest_0300 - * @tc.desc: test GetBundleImportance function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetBundleImportanceTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetBundleImportanceTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t num = 0; - int32_t result = proxy->GetBundleImportance(num); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetBundleImportanceTest_0400 - * @tc.desc: test GetBundleImportance function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetBundleImportanceTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetBundleImportanceTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, false, 1, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t num = 0; - int32_t result = proxy->GetBundleImportance(num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetBundleImportanceTest_0500 - * @tc.desc: test GetBundleImportance function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetBundleImportanceTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetBundleImportanceTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, - ERR_OK, true, 1, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t num = 0; - int32_t result = proxy->GetBundleImportance(num); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - - -/* - * @tc.name: HasNotificationPolicyAccessPermissionTest_0100 - * @tc.desc: test HasNotificationPolicyAccessPermission function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool granted = false; - int32_t result = proxy->HasNotificationPolicyAccessPermission(granted); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: HasNotificationPolicyAccessPermissionTest_0200 - * @tc.desc: test HasNotificationPolicyAccessPermission function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool granted = false; - int32_t result = proxy->HasNotificationPolicyAccessPermission(granted); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, granted); -} - -/* - * @tc.name: HasNotificationPolicyAccessPermissionTest_0300 - * @tc.desc: test HasNotificationPolicyAccessPermission function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool granted = false; - int32_t result = proxy->HasNotificationPolicyAccessPermission(granted); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: HasNotificationPolicyAccessPermissionTest_0400 - * @tc.desc: test HasNotificationPolicyAccessPermission function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool granted = false; - int32_t result = proxy->HasNotificationPolicyAccessPermission(granted); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: HasNotificationPolicyAccessPermissionTest_0500 - * @tc.desc: test HasNotificationPolicyAccessPermission function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool granted = false; - int32_t result = proxy->HasNotificationPolicyAccessPermission(granted); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RemoveNotificationTest_0100 - * @tc.desc: test RemoveNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveNotificationTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveNotificationTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RemoveNotificationTest_0200 - * @tc.desc: test RemoveNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveNotificationTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveNotificationTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: RemoveNotificationTest_0300 - * @tc.desc: test RemoveNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveNotificationTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveNotificationTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: RemoveNotificationTest_0400 - * @tc.desc: test RemoveNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveNotificationTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveNotificationTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: RemoveNotificationTest_0500 - * @tc.desc: test RemoveNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveNotificationTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveNotificationTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RemoveAllNotificationsTest_0100 - * @tc.desc: test RemoveAllNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveAllNotifications(bundleOption); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RemoveAllNotificationsTest_0200 - * @tc.desc: test RemoveAllNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - int32_t result = proxy->RemoveAllNotifications(bundleOption); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: RemoveAllNotificationsTest_0300 - * @tc.desc: test RemoveAllNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveAllNotifications(bundleOption); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: RemoveAllNotificationsTest_0400 - * @tc.desc: test RemoveAllNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveAllNotifications(bundleOption); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: RemoveAllNotificationsTest_0500 - * @tc.desc: test RemoveAllNotifications function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveAllNotifications(bundleOption); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DeleteTest_0100 - * @tc.desc: test Delete function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->Delete("key", 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DeleteTest_0200 - * @tc.desc: test Delete function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->Delete("", 0); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: DeleteTest_0300 - * @tc.desc: test Delete function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->Delete("key", 0); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: DeleteTest_0400 - * @tc.desc: test Delete function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->Delete("key", 0); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: DeleteTest_0500 - * @tc.desc: test Delete function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->Delete("key", 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DeleteByBundleTest_0100 - * @tc.desc: test DeleteByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteByBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteByBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->DeleteByBundle(bundleOption); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DeleteByBundleTest_0200 - * @tc.desc: test DeleteByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteByBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteByBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - int32_t result = proxy->DeleteByBundle(bundleOption); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: DeleteByBundleTest_0300 - * @tc.desc: test DeleteByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteByBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteByBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->DeleteByBundle(bundleOption); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: DeleteByBundleTest_0400 - * @tc.desc: test DeleteByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteByBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteByBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->DeleteByBundle(bundleOption); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: DeleteByBundleTest_0500 - * @tc.desc: test DeleteByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteByBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteByBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->DeleteByBundle(bundleOption); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DeleteAllTest_0100 - * @tc.desc: test DeleteAll function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteAllTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteAllTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->DeleteAll(); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DeleteAllTest_0200 - * @tc.desc: test DeleteAll function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteAllTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteAllTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->DeleteAll(); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: DeleteAllTest_0300 - * @tc.desc: test DeleteAll function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteAllTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteAllTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->DeleteAll(); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: DeleteAllTest_0400 - * @tc.desc: test DeleteAll function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteAllTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteAllTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->DeleteAll(); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotsByBundleTest_0100 - * @tc.desc: test GetSlotsByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - std::vector> slots; - int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotsByBundleTest_0200 - * @tc.desc: test GetSlotsByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - std::vector> slots; - int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: GetSlotsByBundleTest_0300 - * @tc.desc: test GetSlotsByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, - ERR_OK, true, 2)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - std::vector> slots; - int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(2, slots.size()); -} -/* - * @tc.name: GetSlotsByBundleTest_0400 - * @tc.desc: test GetSlotsByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - std::vector> slots; - int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetSlotsByBundleTest_0500 - * @tc.desc: test GetSlotsByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, - ERR_OK, false, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - std::vector> slots; - int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSlotsByBundleTest_0600 - * @tc.desc: test GetSlotByType function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, - ERR_OK, true, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - std::vector> slots; - int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: UpdateSlotsTest_0100 - * @tc.desc: test UpdateSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UpdateSlotsTest_0100, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - std::vector> slots; - int32_t result = proxy->UpdateSlots(bundleOption, slots); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: UpdateSlotsTest_0200 - * @tc.desc: test UpdateSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UpdateSlotsTest_0200, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - std::vector> slots; - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - int32_t result = proxy->UpdateSlots(bundleOption, slots); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: UpdateSlotsTest_0300 - * @tc.desc: test UpdateSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UpdateSlotsTest_0300, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - std::vector> slots; - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - int32_t result = proxy->UpdateSlots(bundleOption, slots); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: UpdateSlotsTest_0400 - * @tc.desc: test UpdateSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UpdateSlotsTest_0400, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - slots.resize(MAX_SLOT_NUM + 1); // set MAX_SLOT_NUM + 1 slots - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->UpdateSlots(bundleOption, slots); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: UpdateSlotsTest_0500 - * @tc.desc: test UpdateSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UpdateSlotsTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->UpdateSlots(bundleOption, slots); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: UpdateSlotsTest_0600 - * @tc.desc: test UpdateSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UpdateSlotsTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->UpdateSlots(bundleOption, slots); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: UpdateSlotsTest_0700 - * @tc.desc: test UpdateSlots function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0700, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UpdateSlotsTest_0700, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> slots; - sptr slot = new (std::nothrow) NotificationSlot(); - slots.push_back(slot); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->UpdateSlots(bundleOption, slots); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledForBundleTest_0100 - * @tc.desc: test SetNotificationsEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetNotificationsEnabledForBundle("DeviceId", true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledForBundleTest_0200 - * @tc.desc: test SetNotificationsEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetNotificationsEnabledForBundle("DeviceId", true); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetNotificationsEnabledForBundleTest_0300 - * @tc.desc: test SetNotificationsEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetNotificationsEnabledForBundle("DeviceId", true); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledForBundleTest_0400 - * @tc.desc: test SetNotificationsEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetNotificationsEnabledForBundle("DeviceId", true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledForAllBundlesTest_0100 - * @tc.desc: test SetNotificationsEnabledForAllBundles function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetNotificationsEnabledForAllBundles("DeviceId", true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledForAllBundlesTest_0200 - * @tc.desc: test SetNotificationsEnabledForAllBundles function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetNotificationsEnabledForAllBundles("DeviceId", true); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetNotificationsEnabledForAllBundlesTest_0300 - * @tc.desc: test SetNotificationsEnabledForAllBundles function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetNotificationsEnabledForAllBundles("DeviceId", true); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledForAllBundlesTest_0400 - * @tc.desc: test SetNotificationsEnabledForAllBundles function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetNotificationsEnabledForAllBundles("DeviceId", true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledForSpecialBundleTest_0100 - * @tc.desc: test SetNotificationsEnabledForSpecialBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetNotificationsEnabledForSpecialBundle("DeviceId", bundleOption, true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledForSpecialBundleTest_0200 - * @tc.desc: test SetNotificationsEnabledForSpecialBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetNotificationsEnabledForSpecialBundle("DeviceId", bundleOption, true); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetNotificationsEnabledForSpecialBundleTest_0300 - * @tc.desc: test SetNotificationsEnabledForSpecialBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetNotificationsEnabledForSpecialBundle("DeviceId", bundleOption, true); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledForSpecialBundleTest_0400 - * @tc.desc: test SetNotificationsEnabledForSpecialBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetNotificationsEnabledForSpecialBundle("DeviceId", bundleOption, true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledForSpecialBundleTest_0500 - * @tc.desc: test SetNotificationsEnabledForSpecialBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0500, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - int32_t result = proxy->SetNotificationsEnabledForSpecialBundle("DeviceId", bundleOption, true); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: SetShowBadgeEnabledForBundleTest_0100 - * @tc.desc: test SetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetShowBadgeEnabledForBundle(bundleOption, true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetShowBadgeEnabledForBundleTest_0200 - * @tc.desc: test SetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetShowBadgeEnabledForBundle(bundleOption, true); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetShowBadgeEnabledForBundleTest_0300 - * @tc.desc: test SetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetShowBadgeEnabledForBundle(bundleOption, true); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetShowBadgeEnabledForBundleTest_0400 - * @tc.desc: test SetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetShowBadgeEnabledForBundle(bundleOption, true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetShowBadgeEnabledForBundleTest_0500 - * @tc.desc: test SetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0500, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - int32_t result = proxy->SetShowBadgeEnabledForBundle(bundleOption, true); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: GetShowBadgeEnabledForBundleTest_0100 - * @tc.desc: test GetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetShowBadgeEnabledForBundleTest_0200 - * @tc.desc: test GetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, enabled); -} - -/* - * @tc.name: GetShowBadgeEnabledForBundleTest_0300 - * @tc.desc: test GetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetShowBadgeEnabledForBundleTest_0400 - * @tc.desc: test GetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetShowBadgeEnabledForBundleTest_0500 - * @tc.desc: test GetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetShowBadgeEnabledForBundleTest_0600 - * @tc.desc: test GetShowBadgeEnabledForBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0600, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = nullptr; - int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: GetShowBadgeEnabledTest_0100 - * @tc.desc: test GetShowBadgeEnabled function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->GetShowBadgeEnabled(enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetShowBadgeEnabledTest_0200 - * @tc.desc: test GetShowBadgeEnabled function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->GetShowBadgeEnabled(enabled); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, enabled); -} - -/* - * @tc.name: GetShowBadgeEnabledTest_0300 - * @tc.desc: test GetShowBadgeEnabled function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->GetShowBadgeEnabled(enabled); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetShowBadgeEnabledTest_0400 - * @tc.desc: test GetShowBadgeEnabled function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->GetShowBadgeEnabled(enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetShowBadgeEnabledTest_0500 - * @tc.desc: test GetShowBadgeEnabled function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->GetShowBadgeEnabled(enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SubscribeTest_0100 - * @tc.desc: test Subscribe function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SubscribeTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - auto subscriber = new (std::nothrow) TestSubscriber(); - sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); - int32_t result = proxy->Subscribe(subscriber->GetImpl(), subInfo); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SubscribeTest_0200 - * @tc.desc: test Subscribe function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SubscribeTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - auto subscriber = new (std::nothrow) TestSubscriber(); - sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); - int32_t result = proxy->Subscribe(subscriber->GetImpl(), subInfo); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: SubscribeTest_0300 - * @tc.desc: test Subscribe function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SubscribeTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - auto subscriber = new (std::nothrow) TestSubscriber(); - sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); - int32_t result = proxy->Subscribe(subscriber->GetImpl(), subInfo); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SubscribeTest_0400 - * @tc.desc: test Subscribe function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SubscribeTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - auto subscriber = new (std::nothrow) TestSubscriber(); - sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); - int32_t result = proxy->Subscribe(subscriber->GetImpl(), subInfo); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SubscribeTest_0500 - * @tc.desc: test Subscribe function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SubscribeTest_0500, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); - int32_t result = proxy->Subscribe(nullptr, subInfo); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: UnsubscribeTest_0100 - * @tc.desc: test Unsubscribe function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UnsubscribeTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - auto subscriber = new (std::nothrow) TestSubscriber(); - sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); - int32_t result = proxy->Unsubscribe(subscriber->GetImpl(), subInfo); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: UnsubscribeTest_0200 - * @tc.desc: test Unsubscribe function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UnsubscribeTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - auto subscriber = new (std::nothrow) TestSubscriber(); - sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); - int32_t result = proxy->Unsubscribe(subscriber->GetImpl(), subInfo); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: UnsubscribeTest_0300 - * @tc.desc: test Unsubscribe function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UnsubscribeTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - auto subscriber = new (std::nothrow) TestSubscriber(); - sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); - int32_t result = proxy->Unsubscribe(subscriber->GetImpl(), subInfo); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: UnsubscribeTest_0400 - * @tc.desc: test Unsubscribe function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UnsubscribeTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - auto subscriber = new (std::nothrow) TestSubscriber(); - sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); - int32_t result = proxy->Unsubscribe(subscriber->GetImpl(), subInfo); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: UnsubscribeTest_0500 - * @tc.desc: test Unsubscribe function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UnsubscribeTest_0500, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); - int32_t result = proxy->Unsubscribe(nullptr, subInfo); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: IsAllowedNotifyTest_0100 - * @tc.desc: test IsAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifyTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsAllowedNotifyTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allowed = false; - int32_t result = proxy->IsAllowedNotify(allowed); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsAllowedNotifyTest_0200 - * @tc.desc: test IsAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifyTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsAllowedNotifyTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allowed = false; - int32_t result = proxy->IsAllowedNotify(allowed); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, allowed); -} - -/* - * @tc.name: IsAllowedNotifyTest_0300 - * @tc.desc: test IsAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifyTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsAllowedNotifyTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allowed = false; - int32_t result = proxy->IsAllowedNotify(allowed); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: IsAllowedNotifyTest_0400 - * @tc.desc: test IsAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifyTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsAllowedNotifyTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allowed = false; - int32_t result = proxy->IsAllowedNotify(allowed); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsAllowedNotifyTest_0500 - * @tc.desc: test IsAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifyTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsAllowedNotifyTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allowed = false; - int32_t result = proxy->IsAllowedNotify(allowed); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsAllowedNotifySelfTest_0100 - * @tc.desc: test IsAllowedNotifySelf function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allowed = false; - int32_t result = proxy->IsAllowedNotifySelf(allowed); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsAllowedNotifySelfTest_0200 - * @tc.desc: test IsAllowedNotifySelf function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allowed = false; - int32_t result = proxy->IsAllowedNotifySelf(allowed); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, allowed); -} - -/* - * @tc.name: IsAllowedNotifySelfTest_0300 - * @tc.desc: test IsAllowedNotifySelf function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allowed = false; - int32_t result = proxy->IsAllowedNotifySelf(allowed); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: IsAllowedNotifySelfTest_0400 - * @tc.desc: test IsAllowedNotifySelf function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allowed = false; - int32_t result = proxy->IsAllowedNotifySelf(allowed); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsAllowedNotifySelfTest_0500 - * @tc.desc: test IsAllowedNotifySelf function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allowed = false; - int32_t result = proxy->IsAllowedNotifySelf(allowed); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSpecialBundleAllowedNotifyTest_0100 - * @tc.desc: test IsSpecialBundleAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSpecialBundleAllowedNotifyTest_0200 - * @tc.desc: test IsSpecialBundleAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, enabled); -} - -/* - * @tc.name: IsSpecialBundleAllowedNotifyTest_0300 - * @tc.desc: test IsSpecialBundleAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: IsSpecialBundleAllowedNotifyTest_0400 - * @tc.desc: test IsSpecialBundleAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSpecialBundleAllowedNotifyTest_0500 - * @tc.desc: test IsSpecialBundleAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSpecialBundleAllowedNotifyTest_0600 - * @tc.desc: test IsSpecialBundleAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0600, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = nullptr; - int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: CancelGroupTest_0100 - * @tc.desc: test CancelGroup function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelGroupTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelGroupTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelGroup("GroupName", 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelGroupTest_0200 - * @tc.desc: test CancelGroup function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelGroupTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelGroupTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelGroup("GroupName", 0); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: CancelGroupTest_0300 - * @tc.desc: test CancelGroup function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelGroupTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelGroupTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelGroup("GroupName", 0); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: CancelGroupTest_0400 - * @tc.desc: test CancelGroup function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelGroupTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelGroupTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelGroup("GroupName", 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RemoveGroupByBundleTest_0100 - * @tc.desc: test RemoveGroupByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveGroupByBundle(bundleOption, "GroupName"); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: RemoveGroupByBundleTest_0200 - * @tc.desc: test RemoveGroupByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveGroupByBundle(bundleOption, "GroupName"); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: RemoveGroupByBundleTest_0300 - * @tc.desc: test RemoveGroupByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveGroupByBundle(bundleOption, "GroupName"); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: RemoveGroupByBundleTest_0400 - * @tc.desc: test RemoveGroupByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->RemoveGroupByBundle(bundleOption, "GroupName"); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetDoNotDisturbDateTest_0100 - * @tc.desc: test SetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); - int32_t result = proxy->SetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetDoNotDisturbDateTest_0200 - * @tc.desc: test SetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = nullptr; - int32_t result = proxy->SetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: SetDoNotDisturbDateTest_0300 - * @tc.desc: test SetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); - int32_t result = proxy->SetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetDoNotDisturbDateTest_0400 - * @tc.desc: test SetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); - int32_t result = proxy->SetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetDoNotDisturbDateTest_0500 - * @tc.desc: test SetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); - int32_t result = proxy->SetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetDoNotDisturbDateTest_0100 - * @tc.desc: test GetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = nullptr; - int32_t result = proxy->GetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetDoNotDisturbDateTest_0200 - * @tc.desc: test GetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = nullptr; - int32_t result = proxy->GetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} -/* - * @tc.name: GetDoNotDisturbDateTest_0300 - * @tc.desc: test GetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = nullptr; - int32_t result = proxy->GetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetDoNotDisturbDateTest_0400 - * @tc.desc: test GetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = nullptr; - int32_t result = proxy->GetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DoesSupportDoNotDisturbModeTest_0100 - * @tc.desc: test DoesSupportDoNotDisturbMode function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool doesSupport = false; - int32_t result = proxy->DoesSupportDoNotDisturbMode(doesSupport); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DoesSupportDoNotDisturbModeTest_0200 - * @tc.desc: test DoesSupportDoNotDisturbMode function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool doesSupport = false; - int32_t result = proxy->DoesSupportDoNotDisturbMode(doesSupport); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, doesSupport); -} - -/* - * @tc.name: DoesSupportDoNotDisturbModeTest_0300 - * @tc.desc: test DoesSupportDoNotDisturbMode function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool doesSupport = false; - int32_t result = proxy->DoesSupportDoNotDisturbMode(doesSupport); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: DoesSupportDoNotDisturbModeTest_0400 - * @tc.desc: test DoesSupportDoNotDisturbMode function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool doesSupport = false; - int32_t result = proxy->DoesSupportDoNotDisturbMode(doesSupport); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DoesSupportDoNotDisturbModeTest_0500 - * @tc.desc: test DoesSupportDoNotDisturbMode function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool doesSupport = false; - int32_t result = proxy->DoesSupportDoNotDisturbMode(doesSupport); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsDistributedEnabledTest_0100 - * @tc.desc: test IsDistributedEnabled function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnabledTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnabledTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->IsDistributedEnabled(enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsDistributedEnabledTest_0200 - * @tc.desc: test IsDistributedEnabled function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnabledTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnabledTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->IsDistributedEnabled(enabled); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, enabled); -} - -/* - * @tc.name: IsDistributedEnabledTest_0300 - * @tc.desc: test IsDistributedEnabled function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnabledTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnabledTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->IsDistributedEnabled(enabled); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: IsDistributedEnabledTest_0400 - * @tc.desc: test IsDistributedEnabled function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnabledTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnabledTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->IsDistributedEnabled(enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsDistributedEnabledTest_0500 - * @tc.desc: test IsDistributedEnabled function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnabledTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnabledTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->IsDistributedEnabled(enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: EnableDistributedTest_0100 - * @tc.desc: test EnableDistributed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->EnableDistributed(true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: EnableDistributedTest_0200 - * @tc.desc: test EnableDistributed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->EnableDistributed(true); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: EnableDistributedTest_0300 - * @tc.desc: test EnableDistributed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->EnableDistributed(true); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: EnableDistributedTest_0400 - * @tc.desc: test EnableDistributed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->EnableDistributed(true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: EnableDistributedByBundleTest_0100 - * @tc.desc: test EnableDistributedByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->EnableDistributedByBundle(bundleOption, true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: EnableDistributedByBundleTest_0200 - * @tc.desc: test EnableDistributedByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - int32_t result = proxy->EnableDistributedByBundle(bundleOption, true); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: EnableDistributedByBundleTest_0300 - * @tc.desc: test EnableDistributedByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->EnableDistributedByBundle(bundleOption, true); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: EnableDistributedByBundleTest_0400 - * @tc.desc: test EnableDistributedByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->EnableDistributedByBundle(bundleOption, true); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: EnableDistributedByBundleTest_0500 - * @tc.desc: test EnableDistributedByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->EnableDistributedByBundle(bundleOption, true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: EnableDistributedSelfTest_0100 - * @tc.desc: test EnableDistributedSelf function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedSelfTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedSelfTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->EnableDistributedSelf(true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: EnableDistributedSelfTest_0200 - * @tc.desc: test EnableDistributedSelf function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedSelfTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedSelfTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->EnableDistributedSelf(true); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: EnableDistributedSelfTest_0300 - * @tc.desc: test EnableDistributedSelf function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedSelfTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedSelfTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->EnableDistributedSelf(true); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: EnableDistributedSelfTest_0400 - * @tc.desc: test EnableDistributedSelf function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedSelfTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, EnableDistributedSelfTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->EnableDistributedSelf(true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsDistributedEnableByBundleTest_0100 - * @tc.desc: test IsDistributedEnableByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - bool enabled = false; - int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsDistributedEnableByBundleTest_0200 - * @tc.desc: test IsDistributedEnableByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - bool enabled = false; - int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: IsDistributedEnableByBundleTest_0300 - * @tc.desc: test IsDistributedEnableByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - bool enabled = false; - int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, enabled); -} - -/* - * @tc.name: IsDistributedEnableByBundleTest_0400 - * @tc.desc: test IsDistributedEnableByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - bool enabled = false; - int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: IsDistributedEnableByBundleTest_0500 - * @tc.desc: test IsDistributedEnableByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - bool enabled = false; - int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsDistributedEnableByBundleTest_0600 - * @tc.desc: test IsDistributedEnableByBundle function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - bool enabled = false; - int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: PublishContinuousTaskNotificationTest_0100 - * @tc.desc: test PublishContinuousTaskNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0100, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr notification = nullptr; - int32_t result = proxy->PublishContinuousTaskNotification(notification); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: PublishContinuousTaskNotificationTest_0200 - * @tc.desc: test PublishContinuousTaskNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr ansManagerProxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, ansManagerProxy); - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - ASSERT_NE(nullptr, notification); - int32_t result = ansManagerProxy->PublishContinuousTaskNotification(notification); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: PublishContinuousTaskNotificationTest_0300 - * @tc.desc: test PublishContinuousTaskNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0300, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - ASSERT_NE(nullptr, notification); - int32_t result = proxy->PublishContinuousTaskNotification(notification); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: PublishContinuousTaskNotificationTest_0400 - * @tc.desc: test PublishContinuousTaskNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - ASSERT_NE(nullptr, notification); - int32_t result = proxy->PublishContinuousTaskNotification(notification); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: PublishContinuousTaskNotificationTest_0500 - * @tc.desc: test PublishContinuousTaskNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - NotificationRequest request(1); - sptr notification = new (std::nothrow) NotificationRequest(request); - ASSERT_NE(nullptr, notification); - int32_t result = proxy->PublishContinuousTaskNotification(notification); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: CancelContinuousTaskNotificationTest_0100 - * @tc.desc: test CancelContinuousTaskNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelContinuousTaskNotification("label", 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: CancelContinuousTaskNotificationTest_0200 - * @tc.desc: test CancelContinuousTaskNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelContinuousTaskNotification("label", 0); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: CancelContinuousTaskNotificationTest_0300 - * @tc.desc: test CancelContinuousTaskNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelContinuousTaskNotification("label", 0); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: CancelContinuousTaskNotificationTest_0400 - * @tc.desc: test CancelContinuousTaskNotification function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->CancelContinuousTaskNotification("label", 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSupportTemplateTest_0100 - * @tc.desc: test IsSupportTemplate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string templateName = "TemplateName"; - bool support = false; - int32_t result = proxy->IsSupportTemplate(templateName, support); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSupportTemplateTest_0200 - * @tc.desc: test IsSupportTemplate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string templateName = "TemplateName"; - bool support = false; - int32_t result = proxy->IsSupportTemplate(templateName, support); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSupportTemplateTest_0300 - * @tc.desc: test IsSupportTemplate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string templateName = "TemplateName"; - bool support = false; - int32_t result = proxy->IsSupportTemplate(templateName, support); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, support); -} - -/* - * @tc.name: IsSupportTemplateTest_0400 - * @tc.desc: test IsSupportTemplate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string templateName = "TemplateName"; - bool support = false; - int32_t result = proxy->IsSupportTemplate(templateName, support); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: IsSupportTemplateTest_0500 - * @tc.desc: test IsSupportTemplate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string templateName = "TemplateName"; - bool support = false; - int32_t result = proxy->IsSupportTemplate(templateName, support); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSupportTemplateTest_0600 - * @tc.desc: test IsSupportTemplate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0600, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::string templateName = "TemplateName"; - bool support = false; - int32_t result = proxy->IsSupportTemplate(templateName, support); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSpecialUserAllowedNotifyTest_0100 - * @tc.desc: test IsSpecialUserAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - bool allowed = false; - int32_t result = proxy->IsSpecialUserAllowedNotify(userId, allowed); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSpecialUserAllowedNotifyTest_0200 - * @tc.desc: test IsSpecialUserAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - bool allowed = false; - int32_t result = proxy->IsSpecialUserAllowedNotify(userId, allowed); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, allowed); -} - -/* - * @tc.name: IsSpecialUserAllowedNotifyTest_0300 - * @tc.desc: test IsSpecialUserAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - bool allowed = false; - int32_t result = proxy->IsSpecialUserAllowedNotify(userId, allowed); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: IsSpecialUserAllowedNotifyTest_0400 - * @tc.desc: test IsSpecialUserAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - bool allowed = false; - int32_t result = proxy->IsSpecialUserAllowedNotify(userId, allowed); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: IsSpecialUserAllowedNotifyTest_0500 - * @tc.desc: test IsSpecialUserAllowedNotify function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - bool allowed = false; - int32_t result = proxy->IsSpecialUserAllowedNotify(userId, allowed); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledByUserTest_0100 - * @tc.desc: test SetNotificationsEnabledByUser function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - bool enabled = true; - int32_t result = proxy->SetNotificationsEnabledByUser(userId, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledByUserTest_0200 - * @tc.desc: test SetNotificationsEnabledByUser function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - bool enabled = true; - int32_t result = proxy->SetNotificationsEnabledByUser(userId, enabled); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetNotificationsEnabledByUserTest_0300 - * @tc.desc: test SetNotificationsEnabledByUser function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - bool enabled = true; - int32_t result = proxy->SetNotificationsEnabledByUser(userId, enabled); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetNotificationsEnabledByUserTest_0400 - * @tc.desc: test SetNotificationsEnabledByUser function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - bool enabled = true; - int32_t result = proxy->SetNotificationsEnabledByUser(userId, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DeleteAllByUserTest_0100 - * @tc.desc: test DeleteAllByUser function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteAllByUserTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteAllByUserTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - int32_t result = proxy->DeleteAllByUser(userId); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: DeleteAllByUserTest_0200 - * @tc.desc: test DeleteAllByUser function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteAllByUserTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteAllByUserTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - int32_t result = proxy->DeleteAllByUser(userId); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: DeleteAllByUserTest_0300 - * @tc.desc: test DeleteAllByUser function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteAllByUserTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteAllByUserTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - int32_t result = proxy->DeleteAllByUser(userId); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: DeleteAllByUserTest_0400 - * @tc.desc: test DeleteAllByUser function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, DeleteAllByUserTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DeleteAllByUserTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - int32_t result = proxy->DeleteAllByUser(userId); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetDoNotDisturbDateTest_2_0100 - * @tc.desc: test SetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); - int32_t userId = 100; // 100 default user - int32_t result = proxy->SetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetDoNotDisturbDateTest_2_0200 - * @tc.desc: test SetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = nullptr; - int32_t userId = 100; // 100 default user - int32_t result = proxy->SetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: SetDoNotDisturbDateTest_2_0300 - * @tc.desc: test SetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); - int32_t userId = 100; // 100 default user - int32_t result = proxy->SetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetDoNotDisturbDateTest_2_0400 - * @tc.desc: test SetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); - int32_t userId = 100; // 100 default user - int32_t result = proxy->SetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetDoNotDisturbDateTest_2_0500 - * @tc.desc: test SetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); - int32_t userId = 100; // 100 default user - int32_t result = proxy->SetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetDoNotDisturbDateTest_2_0100 - * @tc.desc: test GetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = nullptr; - int32_t userId = 0; - int32_t result = proxy->GetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetDoNotDisturbDateTest_2_0200 - * @tc.desc: test GetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = nullptr; - int32_t userId = 0; - int32_t result = proxy->GetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} -/* - * @tc.name: GetDoNotDisturbDateTest_2_0300 - * @tc.desc: test GetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = nullptr; - int32_t userId = 0; - int32_t result = proxy->GetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetDoNotDisturbDateTest_2_0400 - * @tc.desc: test GetDoNotDisturbDate function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr doNotDisturbDate = nullptr; - int32_t userId = 0; - int32_t result = proxy->GetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetEnabledForBundleSlotTest_0100 - * @tc.desc: test SetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetEnabledForBundleSlot( - bundleOption, NotificationConstant::SOCIAL_COMMUNICATION, true, false); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetEnabledForBundleSlotTest_0200 - * @tc.desc: test SetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = nullptr; - int32_t result = proxy->SetEnabledForBundleSlot( - bundleOption, NotificationConstant::SOCIAL_COMMUNICATION, true, false); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: SetEnabledForBundleSlotTest_0300 - * @tc.desc: test SetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetEnabledForBundleSlot( - bundleOption, NotificationConstant::SOCIAL_COMMUNICATION, true, false); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: SetEnabledForBundleSlotTest_0400 - * @tc.desc: test SetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetEnabledForBundleSlot( - bundleOption, NotificationConstant::SOCIAL_COMMUNICATION, true, false); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetEnabledForBundleSlotTest_0500 - * @tc.desc: test SetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t result = proxy->SetEnabledForBundleSlot( - bundleOption, NotificationConstant::SOCIAL_COMMUNICATION, true, false); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetEnabledForBundleSlotTest_0100 - * @tc.desc: test GetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetEnabledForBundleSlotTest_0200 - * @tc.desc: test GetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr ansManagerProxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, ansManagerProxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - bool enabled = false; - int32_t result = ansManagerProxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, enabled); -} - -/* - * @tc.name: GetEnabledForBundleSlotTest_0300 - * @tc.desc: test GetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetEnabledForBundleSlotTest_0400 - * @tc.desc: test GetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetEnabledForBundleSlotTest_0500 - * @tc.desc: test GetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetEnabledForBundleSlotTest_0600 - * @tc.desc: test GetEnabledForBundleSlot function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0600, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0600, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - sptr bundleOption = nullptr; - NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; - int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/* - * @tc.name: SetSyncNotificationEnabledWithoutAppTest_0100 - * @tc.desc: test SetSyncNotificationEnabledWithoutApp function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetSyncNotificationEnabledWithoutApp(0, true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetSyncNotificationEnabledWithoutAppTest_0200 - * @tc.desc: test SetSyncNotificationEnabledWithoutApp function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetSyncNotificationEnabledWithoutApp(0, true); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetSyncNotificationEnabledWithoutAppTest_0300 - * @tc.desc: test SetSyncNotificationEnabledWithoutApp function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetSyncNotificationEnabledWithoutApp(0, true); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetSyncNotificationEnabledWithoutAppTest_0400 - * @tc.desc: test SetSyncNotificationEnabledWithoutApp function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t result = proxy->SetSyncNotificationEnabledWithoutApp(0, true); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSyncNotificationEnabledWithoutAppTest_0100 - * @tc.desc: test GetSyncNotificationEnabledWithoutApp function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->GetSyncNotificationEnabledWithoutApp(0, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSyncNotificationEnabledWithoutAppTest_0200 - * @tc.desc: test GetSyncNotificationEnabledWithoutApp function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->GetSyncNotificationEnabledWithoutApp(0, enabled); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, enabled); -} - -/* - * @tc.name: GetSyncNotificationEnabledWithoutAppTest_0300 - * @tc.desc: test GetSyncNotificationEnabledWithoutApp function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->GetSyncNotificationEnabledWithoutApp(0, enabled); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetSyncNotificationEnabledWithoutAppTest_0400 - * @tc.desc: test GetSyncNotificationEnabledWithoutApp function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->GetSyncNotificationEnabledWithoutApp(0, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetSyncNotificationEnabledWithoutAppTest_0500 - * @tc.desc: test GetSyncNotificationEnabledWithoutApp function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool enabled = false; - int32_t result = proxy->GetSyncNotificationEnabledWithoutApp(0, enabled); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -int SendRequestReplaceDumpInfo(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, - int32_t error, bool setError, int32_t num) -{ - if (setError) { - reply.WriteInt32(error); - } - - if (num > 0) { - std::vector vecDump; - for (int32_t i = 0; i < num; i++) { - std::string info = std::to_string(i); - vecDump.push_back(info); - } - reply.WriteStringVector(vecDump); - } - - return 0; -} -/* - * @tc.name: ShellDumpTest_0100 - * @tc.desc: test ShellDump function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, ShellDumpTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector dumpInfo; - int32_t result = proxy->ShellDump("anm dump -A", "BundleName", 0, 0, dumpInfo); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: ShellDumpTest_0200 - * @tc.desc: test ShellDump function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, ShellDumpTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceDumpInfo, _1, _2, _3, _4, - ERR_OK, true, 1)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector dumpInfo; - int32_t result = proxy->ShellDump("anm dump -A", "BundleName", 0, 0, dumpInfo); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(1, dumpInfo.size()); -} - -/* - * @tc.name: ShellDumpTest_0300 - * @tc.desc: test ShellDump function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, ShellDumpTest_0300, TestSize.Level1"; - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceDumpInfo, _1, _2, _3, _4, - ERR_OK, false, 0)), Return(NO_ERROR))); - std::shared_ptr ansManagerProxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, ansManagerProxy); - std::vector dumpInfo; - int32_t result = ansManagerProxy->ShellDump("anm dump -A", "BundleName", 0, 0, dumpInfo); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: ShellDumpTest_0400 - * @tc.desc: test ShellDump function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, ShellDumpTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector dumpInfo; - int32_t result = proxy->ShellDump("anm dump -A", "BundleName", 0, 0, dumpInfo); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: ShellDumpTest_0500 - * @tc.desc: test ShellDump function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, ShellDumpTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceDumpInfo, _1, _2, _3, _4, - ERR_OK, false, 0)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector dumpInfo; - int32_t result = proxy->ShellDump("anm dump -A", "BundleName", 0, 0, dumpInfo); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: PublishReminder_0100 - * @tc.desc: test AnsManagerProxy's PublishReminder function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishReminder_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishReminder_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - - sptr reminder = new ReminderRequest(); - ErrCode res = proxy->PublishReminder(reminder); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, res); -} - -/* - * @tc.name: PublishReminder_0200 - * @tc.desc: test AnsManagerProxy's PublishReminder function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishReminder_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishReminder_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - - sptr reminder = nullptr; - ErrCode res = proxy->PublishReminder(reminder); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, res); -} - -/* - * @tc.name: PublishReminder_0300 - * @tc.desc: test AnsManagerProxy's PublishReminder function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, PublishReminder_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, PublishReminder_0300, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - - sptr reminder = new ReminderRequest(); - ErrCode res = proxy->PublishReminder(reminder); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, res); -} - -/* - * @tc.name: ReadReminders_0100 - * @tc.desc: test AnsManagerProxy's ReadReminders function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, ReadReminders_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, ReadReminders_0100, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - - uint8_t count = 10; - MessageParcel reply; - std::vector> reminders; - ErrCode res = proxy->ReadReminders(count, reply, reminders); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, res); -} - -/* - * @tc.name: SetBadgeNumberTest_0100 - * @tc.desc: test SetBadgeNumber function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetBadgeNumberTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t userId = 0; - int32_t result = proxy->SetBadgeNumber(userId, 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetBadgeNumberTest_0200 - * @tc.desc: test SetBadgeNumber function - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetBadgeNumberTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t badgeNumber = 0; - int32_t result = proxy->SetBadgeNumber(badgeNumber, 0); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetBadgeNumberTest_0300 - * @tc.desc: test SetBadgeNumber function - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetBadgeNumberTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t badgeNumber = 0; - int32_t result = proxy->SetBadgeNumber(badgeNumber, 0); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetBadgeNumberTest_0400 - * @tc.desc: test SetBadgeNumber function - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetBadgeNumberTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t badgeNumber = 0; - int32_t result = proxy->SetBadgeNumber(badgeNumber, 0); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/** - * @tc.name: SetBadgeNumberByBundleTest_0100 - * @tc.desc: test SetBadgeNumberByBundle with null bundleOption, expect ErrCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberByBundleTest_0100, TestSize.Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - int32_t badgeNumber = 0; - int32_t result = proxy->SetBadgeNumberByBundle(nullptr, badgeNumber); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/** - * @tc.name: SetBadgeNumberByBundleTest_0200 - * @tc.desc: test SetBadgeNumberByBundle with invalid proxy object, expect ErrCode ERR_ANS_PARCELABLE_FAILED. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberByBundleTest_0200, TestSize.Level1) -{ - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - ASSERT_NE(nullptr, bundleOption); - std::string bundleName = "bundleName"; - bundleOption->SetBundleName(bundleName); - int32_t badgeNumber = 0; - int32_t result = proxy->SetBadgeNumberByBundle(bundleOption, badgeNumber); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/** - * @tc.name: SetBadgeNumberByBundleTest_0300 - * @tc.desc: test SetBadgeNumberByBundle with empty bundleOption, expect ErrCode ERR_ANS_PARCELABLE_FAILED. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberByBundleTest_0300, TestSize.Level1) -{ - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - ASSERT_NE(nullptr, bundleOption); - std::string bundleName = "bundleName"; - bundleOption->SetBundleName(bundleName); - int32_t badgeNumber = 0; - int32_t result = proxy->SetBadgeNumberByBundle(bundleOption, badgeNumber); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: GetAllNotificationEnabledBundles_0100 - * @tc.desc: test GetAllNotificationEnabledBundles function - * @tc.type: FUNC - * @tc.require: #I92VGR - */ -HWTEST_F(AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector bundleOption; - int32_t result = proxy->GetAllNotificationEnabledBundles(bundleOption); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetAllNotificationEnabledBundles_0200 - * @tc.desc: test GetAllNotificationEnabledBundles function - * @tc.type: FUNC - * @tc.require: #I92VGR - */ -HWTEST_F(AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestGetAllEnableNotifications, _1, _2, _3, _4, - ERR_OK, true, 1, 1)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector bundleOption; - int32_t result = proxy->GetAllNotificationEnabledBundles(bundleOption); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: GetAllNotificationEnabledBundles_0300 - * @tc.desc: test SetBadgeNumber function - * @tc.type: FUNC - * @tc.require: #I92VGR - */ -HWTEST_F(AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0300, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector bundleOption; - int32_t result = proxy->GetAllNotificationEnabledBundles(bundleOption); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetAllNotificationEnabledBundles_0400 - * @tc.desc: test GetAllNotificationEnabledBundles function - * @tc.type: FUNC - * @tc.require: #I92VGR - */ -HWTEST_F(AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0400, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector bundleOption; - int32_t result = proxy->GetAllNotificationEnabledBundles(bundleOption); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetActiveNotificationByFilterTest_0100 - * @tc.desc: test GetActiveNotificationByFilter function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationByFilterTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationByFilterTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - int32_t notificationId = 0; - std::string label = "label"; - std::vector extraInfoKeys; - - NotificationRequest request(1); - sptr liveViewRequest = new (std::nothrow) NotificationRequest(request); - - int32_t result = proxy->GetActiveNotificationByFilter(bundleOption, notificationId, label, - extraInfoKeys, liveViewRequest); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetActiveNotificationByFilterTest_0200 - * @tc.desc: test GetActiveNotificationByFilter function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationByFilterTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetActiveNotificationByFilterTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - - sptr bundleOption = nullptr; - int32_t notificationId = 0; - std::string label = "label"; - std::vector extraInfoKeys; - - NotificationRequest request(1); - sptr liveViewRequest = new (std::nothrow) NotificationRequest(request); - - int32_t result = proxy->GetActiveNotificationByFilter(bundleOption, notificationId, label, - extraInfoKeys, liveViewRequest); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); -} - -/** - * @tc.name: AddDoNotDisturbProfiles_0100 - * @tc.desc: test AddDoNotDisturbProfiles when profiles is empty. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, AddDoNotDisturbProfiles_0100, TestSize.Level1) -{ - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> profiles; - profiles.clear(); - auto res = proxy->AddDoNotDisturbProfiles(profiles); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, res); -} - -/** - * @tc.name: AddDoNotDisturbProfiles_0200 - * @tc.desc: test AddDoNotDisturbProfiles when WriteInterfaceToken return false. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, AddDoNotDisturbProfiles_0200, TestSize.Level1) -{ - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - - int32_t id = 1; - std::string name = "Name"; - std::vector trustlist; - std::vector> profiles; - sptr disturbProfile = - new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); - profiles.emplace_back(disturbProfile); - - MockWriteInterfaceToken(false); - auto res = proxy->AddDoNotDisturbProfiles(profiles); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, res); -} - -/** - * @tc.name: AddDoNotDisturbProfiles_0300 - * @tc.desc: test AddDoNotDisturbProfiles run success and return result. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, AddDoNotDisturbProfiles_0300, TestSize.Level1) -{ - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - - int32_t id = 1; - std::string name = "Name"; - std::vector trustlist; - std::vector> profiles; - sptr disturbProfile = - new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); - profiles.emplace_back(disturbProfile); - - MockWriteInterfaceToken(true); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .Times(1) - .WillRepeatedly( - DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - auto res = proxy->AddDoNotDisturbProfiles(profiles); - EXPECT_NE(ERR_OK, res); - EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, res); -} - -/** - * @tc.name: RemoveDoNotDisturbProfiles_0100 - * @tc.desc: test RemoveDoNotDisturbProfiles when profiles is empty. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveDoNotDisturbProfiles_0100, TestSize.Level1) -{ - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - std::vector> profiles; - profiles.clear(); - auto res = proxy->RemoveDoNotDisturbProfiles(profiles); - EXPECT_EQ(ERR_ANS_INVALID_PARAM, res); -} - -/** - * @tc.name: RemoveDoNotDisturbProfiles_0200 - * @tc.desc: test RemoveDoNotDisturbProfiles when WriteInterfaceToken return false. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveDoNotDisturbProfiles_0200, TestSize.Level1) -{ - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - - int32_t id = 1; - std::string name = "Name"; - std::vector trustlist; - std::vector> profiles; - sptr disturbProfile = - new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); - profiles.emplace_back(disturbProfile); - - MockWriteInterfaceToken(false); - auto res = proxy->RemoveDoNotDisturbProfiles(profiles); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, res); -} - -/** - * @tc.name: RemoveDoNotDisturbProfiles_0300 - * @tc.desc: test RemoveDoNotDisturbProfiles run success and return result. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, RemoveDoNotDisturbProfiles_0300, TestSize.Level1) -{ - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - - int32_t id = 1; - std::string name = "Name"; - std::vector trustlist; - std::vector> profiles; - sptr disturbProfile = - new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); - profiles.emplace_back(disturbProfile); - - MockWriteInterfaceToken(true); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .Times(1) - .WillRepeatedly( - DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - auto res = proxy->RemoveDoNotDisturbProfiles(profiles); - EXPECT_NE(ERR_OK, res); - EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, res); -} -} // namespace Notification -} // namespace OHOS +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#define private public +#define protected public +#include "ans_manager_proxy.h" +#include "notification_subscriber.h" +#undef private +#undef protected +#include "ans_const_define.h" +#include "ans_dialog_host_client.h" +#include "ans_manager_interface.h" +#include "ans_inner_errors.h" +#include "message_parcel.h" +#include "mock_i_remote_object.h" +#include "notification.h" + +using namespace testing; +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::Notification; +using namespace std::placeholders; +using namespace OHOS::Media; + +extern void MockWriteInterfaceToken(bool mockRet); + +namespace OHOS { +namespace Notification { +class AnsManagerProxyUnitTest : public testing::Test { +public: + AnsManagerProxyUnitTest() {} + + virtual ~AnsManagerProxyUnitTest() {} + + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp(); + + void TearDown(); + std::shared_ptr MakeNewPixelMap(int32_t width, int32_t height); +}; + +void AnsManagerProxyUnitTest::SetUpTestCase() +{ + MockWriteInterfaceToken(true); +} + +void AnsManagerProxyUnitTest::TearDownTestCase() {} + +void AnsManagerProxyUnitTest::SetUp() {} + +void AnsManagerProxyUnitTest::TearDown() {} + +int SendRequestReplace(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, + int32_t error, bool setError, bool retBool, bool setRetBool) +{ + if (setError) { + reply.WriteInt32(error); + } + if (setRetBool) { + reply.WriteBool(retBool); + } + return 0; +} + +int SendRequestReplaceNum(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, + int32_t error, bool setError, uint64_t retNum, bool setRetNum) +{ + if (setError) { + reply.WriteInt32(error); + } + if (setRetNum) { + reply.WriteUint64(retNum); + } + return 0; +} + +int SendRequestReplaceString(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, + int32_t error, bool setError, std::string retStr, bool setRetStr) +{ + if (setError) { + reply.WriteInt32(error); + } + if (setRetStr) { + reply.WriteString(retStr); + } + return 0; +} + +int SendRequestGetAllEnableNotifications(uint32_t code, MessageParcel &data, MessageParcel &reply, + MessageOption &option, int32_t error, int32_t retnum, bool setError, int32_t notificationNum) +{ + if (setError) { + reply.WriteInt32(error); + } + + if (retnum) { + reply.WriteInt32(retnum); + } + + if (notificationNum > 0) { + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + for (int32_t i = 0; i < notificationNum; i++) { + reply.WriteParcelable(bundleOption); + } + } + + return 0; +} + +class TestSubscriber : public NotificationSubscriber { +public: + void OnDisconnected() override + {} + void OnDied() override + {} + void OnUpdate(const std::shared_ptr &sortingMap) override + {} + void OnDoNotDisturbDateChange(const std::shared_ptr &date) override + {} + void OnConnected() override + {} + void OnEnabledNotificationChanged( + const std::shared_ptr &callbackData) override + {} + void OnCanceled(const std::shared_ptr &request, + const std::shared_ptr &sortingMap, int deleteReason) override + {} + void OnBadgeChanged(const std::shared_ptr &badgeData) override + {} + void OnBadgeEnabledChanged(const sptr &callbackData) override + {} + void OnConsumed(const std::shared_ptr &request, + const std::shared_ptr &sortingMap) override + {} + + void OnBatchCanceled(const std::vector> + &requestList, const std::shared_ptr &sortingMap, int32_t deleteReason) override + {} +}; + +/* + * @tc.name: InnerTransactTest_0100 + * @tc.desc: test if AnsManagerProxy's InnerTransact function executed as expected in normal case. + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, InnerTransactTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, InnerTransactTest_0100, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).WillOnce(DoAll(Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + uint32_t code = 0; + MessageOption flags; + MessageParcel data; + MessageParcel reply; + ErrCode res = proxy->InnerTransact(static_cast(code), flags, data, reply); + EXPECT_EQ(ERR_OK, res); +} + +/* + * @tc.name: InnerTransactTest_0200 + * @tc.desc: test AnsManagerProxy's InnerTransact function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, InnerTransactTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, InnerTransactTest_0200, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).WillOnce(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + uint32_t code = 0; + MessageOption flags; + MessageParcel data; + MessageParcel reply; + ErrCode res = proxy->InnerTransact(static_cast(code), flags, data, reply); + EXPECT_EQ(ERR_DEAD_OBJECT, res); +} + +/* + * @tc.name: InnerTransactTest_0300 + * @tc.desc: test AnsManagerProxy's InnerTransact function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, InnerTransactTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, InnerTransactTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).WillOnce(DoAll(Return(-1))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + uint32_t code = 0; + MessageOption flags; + MessageParcel data; + MessageParcel reply; + ErrCode res = proxy->InnerTransact(static_cast(code), flags, data, reply); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, res); +} + +/* + * @tc.name: InnerTransactTest_0400 + * @tc.desc: test AnsManagerProxy's InnerTransact function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, InnerTransactTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, InnerTransactTest_0400, TestSize.Level1"; + std::shared_ptr proxy = std::make_shared(nullptr); + ASSERT_NE(nullptr, proxy); + uint32_t code = 0; + MessageOption flags; + MessageParcel data; + MessageParcel reply; + ErrCode res = proxy->InnerTransact(static_cast(code), flags, data, reply); + EXPECT_EQ(ERR_DEAD_OBJECT, res); +} + +/* + * @tc.name: PublishTest_0100 + * @tc.desc: test Publish function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishTest_0100, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string label = "label"; + sptr notification = nullptr; + int32_t result = proxy->Publish(label, notification); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: PublishTest_0200 + * @tc.desc: test Publish function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string label = "label"; + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + ASSERT_NE(nullptr, notification); + int32_t result = proxy->Publish(label, notification); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: PublishTest_0300 + * @tc.desc: test Publish function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishTest_0300, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string label = ""; + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + ASSERT_NE(nullptr, notification); + int32_t result = proxy->Publish(label, notification); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: PublishTest_0400 + * @tc.desc: test Publish function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string label = "label"; + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + ASSERT_NE(nullptr, notification); + int32_t result = proxy->Publish(label, notification); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: PublishTest_0500 + * @tc.desc: test Publish function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string label = "label"; + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + ASSERT_NE(nullptr, notification); + int32_t result = proxy->Publish(label, notification); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: PublishTest_0600 + * @tc.desc: test Publish function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string label = "label"; + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + ASSERT_NE(nullptr, notification); + int32_t result = proxy->Publish(label, notification); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +std::shared_ptr AnsManagerProxyUnitTest::MakeNewPixelMap(int32_t width, int32_t height) +{ + const int32_t PIXEL_BYTES = 4; + std::shared_ptr pixelMap = std::make_shared(); + if (pixelMap == nullptr) { + return nullptr; + } + ImageInfo info; + info.size.width = width; + info.size.height = height; + info.pixelFormat = PixelFormat::ARGB_8888; + info.colorSpace = ColorSpace::SRGB; + pixelMap->SetImageInfo(info); + int32_t rowDataSize = width * PIXEL_BYTES; + uint32_t bufferSize = rowDataSize * height; + void *buffer = malloc(bufferSize); + if (buffer != nullptr) { + pixelMap->SetPixelsAddr(buffer, nullptr, bufferSize, AllocatorType::HEAP_ALLOC, nullptr); + } + return pixelMap; +} + +/* + * @tc.name: PublishTest_0700 + * @tc.desc: test Publish function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishTest_0700, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishTest_0700, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string label = "label"; + auto slotType = NotificationConstant::SlotType::LIVE_VIEW; + NotificationRequest request(1); + request.SetSlotType(slotType); + request.SetNotificationId(1); + + int pictureWidth = 1024; + int pictureLength = 1024 * 2 + 1; + auto basicContent = std::make_shared(); + basicContent->SetLockScreenPicture(MakeNewPixelMap(pictureWidth, pictureLength)); + auto result = request.CheckLockScreenPictureSizeForLiveView(basicContent); + EXPECT_EQ(ERR_ANS_PICTURE_OVER_SIZE, result); + + auto liveContent = std::make_shared(); + liveContent->SetLockScreenPicture(MakeNewPixelMap(1, 1)); + auto content = std::make_shared(liveContent); + request.SetContent(content); + + sptr notification = new (std::nothrow) NotificationRequest(request); + ASSERT_NE(nullptr, notification); + result = proxy->Publish(label, notification); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: CancelTest_0100 + * @tc.desc: test Cancel function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + std::string label = "label"; + int32_t result = proxy->Cancel(notificationId, label, 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelTest_0200 + * @tc.desc: test Cancel function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + std::string label = ""; + int32_t result = proxy->Cancel(notificationId, label, 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelTest_0300 + * @tc.desc: test Cancel function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + std::string label = "label"; + int32_t result = proxy->Cancel(notificationId, label, 0); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: CancelTest_0400 + * @tc.desc: test Cancel function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + std::string label = "label"; + int32_t result = proxy->Cancel(notificationId, label, 0); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: CancelTest_0500 + * @tc.desc: test Cancel function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + std::string label = "label"; + int32_t result = proxy->Cancel(notificationId, label, 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelAllTest_0100 + * @tc.desc: test CancelAll function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAllTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAllTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelAll(0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelAllTest_0200 + * @tc.desc: test CancelAll function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAllTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAllTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelAll(0); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: CancelAllTest_0300 + * @tc.desc: test CancelAll function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAllTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAllTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelAll(0); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: CancelAllTest_0400 + * @tc.desc: test CancelAll function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAllTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAllTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelAll(0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelAsBundleTest_0100 + * @tc.desc: test CancelAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAsBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + std::string representativeBundle = "Bundle"; + int32_t userId = 0; + int32_t result = proxy->CancelAsBundle(notificationId, representativeBundle, userId); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelAsBundleTest_0200 + * @tc.desc: test CancelAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAsBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + std::string representativeBundle = ""; + int32_t userId = 0; + int32_t result = proxy->CancelAsBundle(notificationId, representativeBundle, userId); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelAsBundleTest_0300 + * @tc.desc: test CancelAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAsBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + std::string representativeBundle = "Bundle"; + int32_t userId = 0; + int32_t result = proxy->CancelAsBundle(notificationId, representativeBundle, userId); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: CancelAsBundleTest_0400 + * @tc.desc: test CancelAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAsBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + std::string representativeBundle = "Bundle"; + int32_t userId = 0; + int32_t result = proxy->CancelAsBundle(notificationId, representativeBundle, userId); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: CancelAsBundleTest_0500 + * @tc.desc: test CancelAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAsBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + std::string representativeBundle = "Bundle"; + int32_t userId = 0; + int32_t result = proxy->CancelAsBundle(notificationId, representativeBundle, userId); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelAsBundleTest_0600 + * @tc.desc: test CancelAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAsBundleTest_0600, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->CancelAsBundle(bundleOption, notificationId); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelAsBundleTest_0700 + * @tc.desc: test CancelAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleTest_0700, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAsBundleTest_0700, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t notificationId = 0; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t userId = 0; + int32_t result = proxy->CancelAsBundle(bundleOption, notificationId, userId); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: AddSlotByTypeTest_0100 + * @tc.desc: test AddSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, AddSlotByTypeTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, AddSlotByTypeTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->AddSlotByType(slotType); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: AddSlotByTypeTest_0200 + * @tc.desc: test AddSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, AddSlotByTypeTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, AddSlotByTypeTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->AddSlotByType(slotType); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: AddSlotByTypeTest_0300 + * @tc.desc: test AddSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, AddSlotByTypeTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, AddSlotByTypeTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->AddSlotByType(slotType); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: AddSlotByTypeTest_0400 + * @tc.desc: test AddSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, AddSlotByTypeTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, AddSlotByTypeTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->AddSlotByType(slotType); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: AddSlotsTest_0100 + * @tc.desc: test AddSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, AddSlotsTest_0100, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + int32_t result = proxy->AddSlots(slots); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: AddSlotsTest_0200 + * @tc.desc: test AddSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, AddSlotsTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + int32_t result = proxy->AddSlots(slots); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: AddSlotsTest_0300 + * @tc.desc: test AddSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, AddSlotsTest_0300, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + slots.resize(MAX_SLOT_NUM + 1); // set MAX_SLOT_NUM + 1 slots + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + int32_t result = proxy->AddSlots(slots); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: AddSlotsTest_0400 + * @tc.desc: test AddSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, AddSlotsTest_0400, TestSize.Level1"; + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + int32_t result = proxy->AddSlots(slots); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: AddSlotsTest_0500 + * @tc.desc: test AddSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, AddSlotsTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + int32_t result = proxy->AddSlots(slots); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: AddSlotsTest_0600 + * @tc.desc: test AddSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, AddSlotsTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, AddSlotsTest_0600, TestSize.Level1"; + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + int32_t result = proxy->AddSlots(slots); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RequestEnableNotificationTest_0100 + * @tc.desc: test RequestEnableNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RequestEnableNotificationTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RequestEnableNotificationTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string deviceId = "Device"; + sptr callerToken = nullptr; + sptr client = nullptr; + AnsDialogHostClient::CreateIfNullptr(client); + client = AnsDialogHostClient::GetInstance(); + int32_t result = proxy->RequestEnableNotification(deviceId, client, callerToken); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RequestEnableNotificationTest_0200 + * @tc.desc: test RequestEnableNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RequestEnableNotificationTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RequestEnableNotificationTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string deviceId = ""; + sptr callerToken = nullptr; + sptr client = nullptr; + AnsDialogHostClient::CreateIfNullptr(client); + client = AnsDialogHostClient::GetInstance(); + int32_t result = proxy->RequestEnableNotification(deviceId, client, callerToken); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RequestEnableNotificationTest_0300 + * @tc.desc: test RequestEnableNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RequestEnableNotificationTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RequestEnableNotificationTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string deviceId = "Device"; + sptr callerToken = nullptr; + sptr client = nullptr; + AnsDialogHostClient::CreateIfNullptr(client); + client = AnsDialogHostClient::GetInstance(); + int32_t result = proxy->RequestEnableNotification(deviceId, client, callerToken); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: RequestEnableNotificationTest_0400 + * @tc.desc: test RequestEnableNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RequestEnableNotificationTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RequestEnableNotificationTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string deviceId = "Device"; + sptr callerToken = nullptr; + sptr client = nullptr; + AnsDialogHostClient::CreateIfNullptr(client); + client = AnsDialogHostClient::GetInstance(); + int32_t result = proxy->RequestEnableNotification(deviceId, client, callerToken); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: RemoveSlotByTypeTest_0100 + * @tc.desc: test RemoveSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->RemoveSlotByType(slotType); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RemoveSlotByTypeTest_0200 + * @tc.desc: test RemoveSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->RemoveSlotByType(slotType); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: RemoveSlotByTypeTest_0300 + * @tc.desc: test RemoveSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->RemoveSlotByType(slotType); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: RemoveSlotByTypeTest_0400 + * @tc.desc: test RemoveSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveSlotByTypeTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->RemoveSlotByType(slotType); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RemoveAllSlotsTest_0100 + * @tc.desc: test RemoveAllSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveAllSlotsTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveAllSlotsTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->RemoveAllSlots(); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RemoveAllSlotsTest_0200 + * @tc.desc: test RemoveAllSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveAllSlotsTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveAllSlotsTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->RemoveAllSlots(); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: RemoveAllSlotsTest_0300 + * @tc.desc: test RemoveAllSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveAllSlotsTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveAllSlotsTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->RemoveAllSlots(); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: RemoveAllSlotsTest_0400 + * @tc.desc: test RemoveAllSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveAllSlotsTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveAllSlotsTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->RemoveAllSlots(); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +int SendRequestReplaceSlot(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, + int32_t error, bool setError, int32_t slotNum) +{ + if (setError) { + reply.WriteInt32(error); + } + + if (slotNum == 1) { + sptr slot = new (std::nothrow) NotificationSlot(); + reply.WriteParcelable(slot); + } + if (slotNum > 1) { + reply.WriteInt32(slotNum); + for (int32_t i = 0; i < slotNum; i++) { + sptr slot = new (std::nothrow) NotificationSlot(); + reply.WriteStrongParcelable(slot); + } + } + return 0; +} + +/* + * @tc.name: GetSlotByTypeTest_0100 + * @tc.desc: test GetSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotByTypeTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotByTypeTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + sptr slot = nullptr; + int32_t result = proxy->GetSlotByType(slotType, slot); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotByTypeTest_0200 + * @tc.desc: test GetSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotByTypeTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotByTypeTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, + ERR_OK, true, 1)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + sptr slot = nullptr; + int32_t result = proxy->GetSlotByType(slotType, slot); + EXPECT_EQ(ERR_OK, result); + EXPECT_NE(nullptr, slot); +} +/* + * @tc.name: GetSlotByTypeTest_0300 + * @tc.desc: test GetSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotByTypeTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotByTypeTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + sptr slot = nullptr; + int32_t result = proxy->GetSlotByType(slotType, slot); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetSlotByTypeTest_0400 + * @tc.desc: test GetSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotByTypeTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotByTypeTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, + ERR_OK, false, 0)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + sptr slot = nullptr; + int32_t result = proxy->GetSlotByType(slotType, slot); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotByTypeTest_0500 + * @tc.desc: test GetSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotByTypeTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotByTypeTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, + ERR_OK, true, 0)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + sptr slot = nullptr; + int32_t result = proxy->GetSlotByType(slotType, slot); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: GetSlotsTest_0100 + * @tc.desc: test GetSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + int32_t result = proxy->GetSlots(slots); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotsTest_0200 + * @tc.desc: test GetSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, + ERR_OK, true, 2)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + int32_t result = proxy->GetSlots(slots); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(2, slots.size()); +} +/* + * @tc.name: GetSlotsTest_0300 + * @tc.desc: test GetSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + int32_t result = proxy->GetSlots(slots); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetSlotsTest_0400 + * @tc.desc: test GetSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, + ERR_OK, false, 0)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + int32_t result = proxy->GetSlots(slots); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotsTest_0500 + * @tc.desc: test GetSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, + ERR_OK, true, 0)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + int32_t result = proxy->GetSlots(slots); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotNumAsBundleTest_0100 + * @tc.desc: test GetSlotNumAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint64_t num = 0; + int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotNumAsBundleTest_0200 + * @tc.desc: test GetSlotNumAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + uint64_t num = 0; + int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: GetSlotNumAsBundleTest_0300 + * @tc.desc: test GetSlotNumAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, true, 1, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint64_t num = 0; + int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(1, num); +} + +/* + * @tc.name: GetSlotNumAsBundleTest_0400 + * @tc.desc: test GetSlotNumAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint64_t num = 0; + int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetSlotNumAsBundleTest_0500 + * @tc.desc: test GetSlotNumAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, false, 1, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint64_t num = 0; + int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotNumAsBundleTest_0600 + * @tc.desc: test GetSlotNumAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotNumAsBundleTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, true, 1, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint64_t num = 0; + int32_t result = proxy->GetSlotNumAsBundle(bundleOption, num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +int SendRequestReplaceNotifications(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, + int32_t error, bool setError, int32_t notificationNum) +{ + if (setError) { + reply.WriteInt32(error); + } + + if (notificationNum > 0) { + reply.WriteInt32(notificationNum); + for (int32_t i = 0; i < notificationNum; i++) { + sptr request = new (std::nothrow) NotificationRequest(0); + reply.WriteStrongParcelable(request); + } + } + + return 0; +} + +/* + * @tc.name: GetSlotFlagsAsBundleTest_0100 + * @tc.desc: test GetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint32_t soltFlags = 0; + int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotFlagsAsBundleTest_0200 + * @tc.desc: test GetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + uint32_t soltFlags = 0; + int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotFlagsAsBundleTest_0300 + * @tc.desc: test GetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0300, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + uint32_t soltFlags = 0; + int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotFlagsAsBundleTest_0400 + * @tc.desc: test GetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, true, 1, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint32_t soltFlags = 0; + int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_EQ(ERR_OK, result); + EXPECT_NE(ERR_OK, soltFlags); +} + +/* + * @tc.name: GetSlotFlagsAsBundleTest_0500 + * @tc.desc: test GetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint32_t soltFlags = 0; + int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetSlotFlagsAsBundleTest_0600 + * @tc.desc: test GetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, false, 1, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint32_t soltFlags = 0; + uint32_t res = 1; + int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_EQ(res, result); +} + +/* + * @tc.name: GetSlotFlagsAsBundleTest_0700 + * @tc.desc: test GetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0700, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0700, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, true, 1, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint32_t soltFlags = 0; + int32_t result = proxy->GetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_NE(ERR_OK, result); +} + +/* + * @tc.name: SetSlotFlagsAsBundleTest_0100 + * @tc.desc: test SetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint32_t soltFlags = 0; + int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetSlotFlagsAsBundleTest_0200 + * @tc.desc: test SetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + uint32_t soltFlags = 0; + int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetSlotFlagsAsBundleTest_0300 + * @tc.desc: test SetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0300, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + uint32_t soltFlags = 0; + int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetSlotFlagsAsBundleTest_0400 + * @tc.desc: test SetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, true, 1, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint32_t soltFlags = 0; + int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(ERR_OK, soltFlags); +} + +/* + * @tc.name: SetSlotFlagsAsBundleTest_0500 + * @tc.desc: test SetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint32_t soltFlags = 0; + int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetSlotFlagsAsBundleTest_0600 + * @tc.desc: test SetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotFlagsAsBundleTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, false, 1, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint32_t soltFlags = 0; + uint32_t res = 1; + int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_EQ(res, result); +} + +/* + * @tc.name: SetSlotFlagsAsBundleTest_0700 + * @tc.desc: test SetSlotFlagsAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0700, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetSlotFlagsAsBundleTest_0700, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, true, 1, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + uint32_t soltFlags = 0; + int32_t result = proxy->SetSlotFlagsAsBundle(bundleOption, soltFlags); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: GetActiveNotificationsTest_0100 + * @tc.desc: test GetActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationsTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationsTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> notifications; + int32_t result = proxy->GetActiveNotifications(notifications, 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetActiveNotificationsTest_0200 + * @tc.desc: test GetActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationsTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationsTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, + ERR_OK, true, 1)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> notifications; + int32_t result = proxy->GetActiveNotifications(notifications, 0); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(1, notifications.size()); +} +/* + * @tc.name: GetActiveNotificationsTest_0300 + * @tc.desc: test GetActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationsTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationsTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> notifications; + int32_t result = proxy->GetActiveNotifications(notifications, 0); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetActiveNotificationsTest_0400 + * @tc.desc: test GetActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationsTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationsTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, + ERR_OK, false, 1)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> notifications; + int32_t result = proxy->GetActiveNotifications(notifications, 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetActiveNotificationsTest_0500 + * @tc.desc: test GetActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationsTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationsTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, + ERR_OK, true, 0)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> notifications; + int32_t result = proxy->GetActiveNotifications(notifications, 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetActiveNotificationNumsTest_0100 + * @tc.desc: test GetActiveNotificationNums function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + uint64_t num = 0; + int32_t result = proxy->GetActiveNotificationNums(num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetActiveNotificationNumsTest_0200 + * @tc.desc: test GetActiveNotificationNums function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, true, 1, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + uint64_t num = 0; + int32_t result = proxy->GetActiveNotificationNums(num); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(1, num); +} + +/* + * @tc.name: GetActiveNotificationNumsTest_0300 + * @tc.desc: test GetActiveNotificationNums function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + uint64_t num = 0; + int32_t result = proxy->GetActiveNotificationNums(num); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetActiveNotificationNumsTest_0400 + * @tc.desc: test GetActiveNotificationNums function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, false, 1, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + uint64_t num = 0; + int32_t result = proxy->GetActiveNotificationNums(num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetActiveNotificationNumsTest_0500 + * @tc.desc: test GetActiveNotificationNums function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationNumsTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, true, 1, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + uint64_t num = 0; + int32_t result = proxy->GetActiveNotificationNums(num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetAllActiveNotificationsTest_0100 + * @tc.desc: test GetAllActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> notifications; + int32_t result = proxy->GetAllActiveNotifications(notifications); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetAllActiveNotificationsTest_0200 + * @tc.desc: test GetAllActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, + ERR_OK, true, 1)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> notifications; + int32_t result = proxy->GetAllActiveNotifications(notifications); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); + EXPECT_EQ(0, notifications.size()); +} +/* + * @tc.name: GetAllActiveNotificationsTest_0300 + * @tc.desc: test GetAllActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> notifications; + int32_t result = proxy->GetAllActiveNotifications(notifications); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetAllActiveNotificationsTest_0400 + * @tc.desc: test GetAllActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, + ERR_OK, false, 1)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> notifications; + int32_t result = proxy->GetAllActiveNotifications(notifications); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetAllActiveNotificationsTest_0500 + * @tc.desc: test GetAllActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetAllActiveNotificationsTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, + ERR_OK, true, 0)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> notifications; + int32_t result = proxy->GetAllActiveNotifications(notifications); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSpecialActiveNotificationsTest_0100 + * @tc.desc: test GetSpecialActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0100, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector key; + std::vector> notifications; + int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: GetSpecialActiveNotificationsTest_0200 + * @tc.desc: test GetSpecialActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector key{"0", "1"}; + std::vector> notifications; + int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSpecialActiveNotificationsTest_0300 + * @tc.desc: test GetSpecialActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0300, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, + ERR_OK, true, 1)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector key{"0", "1"}; + std::vector> notifications; + int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); + EXPECT_EQ(0, notifications.size()); +} +/* + * @tc.name: GetSpecialActiveNotificationsTest_0400 + * @tc.desc: test GetSpecialActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector key{"0", "1"}; + std::vector> notifications; + int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetSpecialActiveNotificationsTest_0500 + * @tc.desc: test GetSpecialActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, + ERR_OK, false, 1)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector key{"0", "1"}; + std::vector> notifications; + int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSpecialActiveNotificationsTest_0600 + * @tc.desc: test GetSpecialActiveNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSpecialActiveNotificationsTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNotifications, _1, _2, _3, _4, + ERR_OK, true, 0)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector key{"0", "1"}; + std::vector> notifications; + int32_t result = proxy->GetSpecialActiveNotifications(key, notifications); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationAgentTest_0100 + * @tc.desc: test SetNotificationAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationAgentTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationAgentTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string agent = "agent"; + int32_t result = proxy->SetNotificationAgent(agent); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationAgentTest_0200 + * @tc.desc: test SetNotificationAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationAgentTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationAgentTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string agent = ""; + int32_t result = proxy->SetNotificationAgent(agent); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: SetNotificationAgentTest_0300 + * @tc.desc: test SetNotificationAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationAgentTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationAgentTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string agent = "agent"; + int32_t result = proxy->SetNotificationAgent(agent); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetNotificationAgentTest_0400 + * @tc.desc: test SetNotificationAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationAgentTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationAgentTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string agent = "agent"; + int32_t result = proxy->SetNotificationAgent(agent); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetNotificationAgentTest_0500 + * @tc.desc: test SetNotificationAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationAgentTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationAgentTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string agent = "agent"; + int32_t result = proxy->SetNotificationAgent(agent); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetNotificationAgentTest_0100 + * @tc.desc: test GetNotificationAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetNotificationAgentTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetNotificationAgentTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string agent; + int32_t result = proxy->GetNotificationAgent(agent); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetNotificationAgentTest_0200 + * @tc.desc: test GetNotificationAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetNotificationAgentTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetNotificationAgentTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceString, _1, _2, _3, _4, + ERR_OK, true, "0", true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string agent; + int32_t result = proxy->GetNotificationAgent(agent); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: GetNotificationAgentTest_0300 + * @tc.desc: test GetNotificationAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetNotificationAgentTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetNotificationAgentTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string agent; + int32_t result = proxy->GetNotificationAgent(agent); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetNotificationAgentTest_0400 + * @tc.desc: test GetNotificationAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetNotificationAgentTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetNotificationAgentTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceString, _1, _2, _3, _4, + ERR_OK, false, "0", true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string agent; + int32_t result = proxy->GetNotificationAgent(agent); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetNotificationAgentTest_0500 + * @tc.desc: test GetNotificationAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetNotificationAgentTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetNotificationAgentTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceString, _1, _2, _3, _4, + ERR_OK, true, "0", false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string agent; + int32_t result = proxy->GetNotificationAgent(agent); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CanPublishAsBundleTest_0100 + * @tc.desc: test CanPublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string representativeBundle = "Bundle"; + bool canPublish = false; + int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CanPublishAsBundleTest_0200 + * @tc.desc: test CanPublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string representativeBundle = ""; + bool canPublish = false; + int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: CanPublishAsBundleTest_0300 + * @tc.desc: test CanPublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string representativeBundle = "Bundle"; + bool canPublish = false; + int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, canPublish); +} + +/* + * @tc.name: CanPublishAsBundleTest_0400 + * @tc.desc: test CanPublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string representativeBundle = "Bundle"; + bool canPublish = false; + int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: CanPublishAsBundleTest_0500 + * @tc.desc: test CanPublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string representativeBundle = "Bundle"; + bool canPublish = false; + int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CanPublishAsBundleTest_0600 + * @tc.desc: test CanPublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CanPublishAsBundleTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CanPublishAsBundleTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string representativeBundle = "Bundle"; + bool canPublish = false; + int32_t result = proxy->CanPublishAsBundle(representativeBundle, canPublish); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: PublishAsBundleTest_0100 + * @tc.desc: test PublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishAsBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + std::string representativeBundle = "Bundle"; + int32_t result = proxy->PublishAsBundle(notification, representativeBundle); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: PublishAsBundleTest_0200 + * @tc.desc: test PublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishAsBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr notification = nullptr; + std::string representativeBundle = "Bundle"; + int32_t result = proxy->PublishAsBundle(notification, representativeBundle); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: PublishAsBundleTest_0300 + * @tc.desc: test PublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishAsBundleTest_0300, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + std::string representativeBundle = ""; + int32_t result = proxy->PublishAsBundle(notification, representativeBundle); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: PublishAsBundleTest_0400 + * @tc.desc: test PublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishAsBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + std::string representativeBundle = "Bundle"; + int32_t result = proxy->PublishAsBundle(notification, representativeBundle); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: PublishAsBundleTest_0500 + * @tc.desc: test PublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishAsBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + std::string representativeBundle = "Bundle"; + int32_t result = proxy->PublishAsBundle(notification, representativeBundle); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: PublishAsBundleTest_0600 + * @tc.desc: test PublishAsBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishAsBundleTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishAsBundleTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + std::string representativeBundle = "Bundle"; + int32_t result = proxy->PublishAsBundle(notification, representativeBundle); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationBadgeNumTest_0100 + * @tc.desc: test SetNotificationBadgeNum function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t num = 0; + int32_t result = proxy->SetNotificationBadgeNum(num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationBadgeNumTest_0200 + * @tc.desc: test SetNotificationBadgeNum function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t num = 0; + int32_t result = proxy->SetNotificationBadgeNum(num); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetNotificationBadgeNumTest_0300 + * @tc.desc: test SetNotificationBadgeNum function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t num = 0; + int32_t result = proxy->SetNotificationBadgeNum(num); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetNotificationBadgeNumTest_0400 + * @tc.desc: test SetNotificationBadgeNum function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationBadgeNumTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t num = 0; + int32_t result = proxy->SetNotificationBadgeNum(num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetBundleImportanceTest_0100 + * @tc.desc: test GetBundleImportance function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetBundleImportanceTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetBundleImportanceTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t num = 0; + int32_t result = proxy->GetBundleImportance(num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetBundleImportanceTest_0200 + * @tc.desc: test GetBundleImportance function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetBundleImportanceTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetBundleImportanceTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, true, 1, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t num = 0; + int32_t result = proxy->GetBundleImportance(num); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(1, num); +} + +/* + * @tc.name: GetBundleImportanceTest_0300 + * @tc.desc: test GetBundleImportance function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetBundleImportanceTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetBundleImportanceTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t num = 0; + int32_t result = proxy->GetBundleImportance(num); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetBundleImportanceTest_0400 + * @tc.desc: test GetBundleImportance function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetBundleImportanceTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetBundleImportanceTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, false, 1, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t num = 0; + int32_t result = proxy->GetBundleImportance(num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetBundleImportanceTest_0500 + * @tc.desc: test GetBundleImportance function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetBundleImportanceTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetBundleImportanceTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceNum, _1, _2, _3, _4, + ERR_OK, true, 1, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t num = 0; + int32_t result = proxy->GetBundleImportance(num); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + + +/* + * @tc.name: HasNotificationPolicyAccessPermissionTest_0100 + * @tc.desc: test HasNotificationPolicyAccessPermission function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool granted = false; + int32_t result = proxy->HasNotificationPolicyAccessPermission(granted); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: HasNotificationPolicyAccessPermissionTest_0200 + * @tc.desc: test HasNotificationPolicyAccessPermission function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool granted = false; + int32_t result = proxy->HasNotificationPolicyAccessPermission(granted); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, granted); +} + +/* + * @tc.name: HasNotificationPolicyAccessPermissionTest_0300 + * @tc.desc: test HasNotificationPolicyAccessPermission function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool granted = false; + int32_t result = proxy->HasNotificationPolicyAccessPermission(granted); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: HasNotificationPolicyAccessPermissionTest_0400 + * @tc.desc: test HasNotificationPolicyAccessPermission function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool granted = false; + int32_t result = proxy->HasNotificationPolicyAccessPermission(granted); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: HasNotificationPolicyAccessPermissionTest_0500 + * @tc.desc: test HasNotificationPolicyAccessPermission function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool granted = false; + int32_t result = proxy->HasNotificationPolicyAccessPermission(granted); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RemoveNotificationTest_0100 + * @tc.desc: test RemoveNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveNotificationTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveNotificationTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RemoveNotificationTest_0200 + * @tc.desc: test RemoveNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveNotificationTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveNotificationTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: RemoveNotificationTest_0300 + * @tc.desc: test RemoveNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveNotificationTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveNotificationTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: RemoveNotificationTest_0400 + * @tc.desc: test RemoveNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveNotificationTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveNotificationTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: RemoveNotificationTest_0500 + * @tc.desc: test RemoveNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveNotificationTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveNotificationTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RemoveAllNotificationsTest_0100 + * @tc.desc: test RemoveAllNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveAllNotifications(bundleOption); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RemoveAllNotificationsTest_0200 + * @tc.desc: test RemoveAllNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + int32_t result = proxy->RemoveAllNotifications(bundleOption); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: RemoveAllNotificationsTest_0300 + * @tc.desc: test RemoveAllNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveAllNotifications(bundleOption); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: RemoveAllNotificationsTest_0400 + * @tc.desc: test RemoveAllNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveAllNotifications(bundleOption); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: RemoveAllNotificationsTest_0500 + * @tc.desc: test RemoveAllNotifications function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveAllNotificationsTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveAllNotifications(bundleOption); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DeleteTest_0100 + * @tc.desc: test Delete function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->Delete("key", 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DeleteTest_0200 + * @tc.desc: test Delete function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->Delete("", 0); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: DeleteTest_0300 + * @tc.desc: test Delete function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->Delete("key", 0); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: DeleteTest_0400 + * @tc.desc: test Delete function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->Delete("key", 0); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: DeleteTest_0500 + * @tc.desc: test Delete function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->Delete("key", 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DeleteByBundleTest_0100 + * @tc.desc: test DeleteByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteByBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteByBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->DeleteByBundle(bundleOption); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DeleteByBundleTest_0200 + * @tc.desc: test DeleteByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteByBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteByBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + int32_t result = proxy->DeleteByBundle(bundleOption); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: DeleteByBundleTest_0300 + * @tc.desc: test DeleteByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteByBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteByBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->DeleteByBundle(bundleOption); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: DeleteByBundleTest_0400 + * @tc.desc: test DeleteByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteByBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteByBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->DeleteByBundle(bundleOption); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: DeleteByBundleTest_0500 + * @tc.desc: test DeleteByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteByBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteByBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->DeleteByBundle(bundleOption); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DeleteAllTest_0100 + * @tc.desc: test DeleteAll function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteAllTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteAllTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->DeleteAll(); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DeleteAllTest_0200 + * @tc.desc: test DeleteAll function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteAllTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteAllTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->DeleteAll(); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: DeleteAllTest_0300 + * @tc.desc: test DeleteAll function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteAllTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteAllTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->DeleteAll(); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: DeleteAllTest_0400 + * @tc.desc: test DeleteAll function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteAllTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteAllTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->DeleteAll(); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotsByBundleTest_0100 + * @tc.desc: test GetSlotsByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + std::vector> slots; + int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotsByBundleTest_0200 + * @tc.desc: test GetSlotsByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + std::vector> slots; + int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: GetSlotsByBundleTest_0300 + * @tc.desc: test GetSlotsByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, + ERR_OK, true, 2)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + std::vector> slots; + int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(2, slots.size()); +} +/* + * @tc.name: GetSlotsByBundleTest_0400 + * @tc.desc: test GetSlotsByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + std::vector> slots; + int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetSlotsByBundleTest_0500 + * @tc.desc: test GetSlotsByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, + ERR_OK, false, 0)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + std::vector> slots; + int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSlotsByBundleTest_0600 + * @tc.desc: test GetSlotByType function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSlotsByBundleTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSlotsByBundleTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceSlot, _1, _2, _3, _4, + ERR_OK, true, 0)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + std::vector> slots; + int32_t result = proxy->GetSlotsByBundle(bundleOption, slots); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: UpdateSlotsTest_0100 + * @tc.desc: test UpdateSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UpdateSlotsTest_0100, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + std::vector> slots; + int32_t result = proxy->UpdateSlots(bundleOption, slots); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: UpdateSlotsTest_0200 + * @tc.desc: test UpdateSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UpdateSlotsTest_0200, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + std::vector> slots; + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + int32_t result = proxy->UpdateSlots(bundleOption, slots); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: UpdateSlotsTest_0300 + * @tc.desc: test UpdateSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UpdateSlotsTest_0300, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + std::vector> slots; + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + int32_t result = proxy->UpdateSlots(bundleOption, slots); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: UpdateSlotsTest_0400 + * @tc.desc: test UpdateSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UpdateSlotsTest_0400, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + slots.resize(MAX_SLOT_NUM + 1); // set MAX_SLOT_NUM + 1 slots + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->UpdateSlots(bundleOption, slots); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: UpdateSlotsTest_0500 + * @tc.desc: test UpdateSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UpdateSlotsTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->UpdateSlots(bundleOption, slots); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: UpdateSlotsTest_0600 + * @tc.desc: test UpdateSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UpdateSlotsTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->UpdateSlots(bundleOption, slots); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: UpdateSlotsTest_0700 + * @tc.desc: test UpdateSlots function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UpdateSlotsTest_0700, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UpdateSlotsTest_0700, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> slots; + sptr slot = new (std::nothrow) NotificationSlot(); + slots.push_back(slot); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->UpdateSlots(bundleOption, slots); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledForBundleTest_0100 + * @tc.desc: test SetNotificationsEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetNotificationsEnabledForBundle("DeviceId", true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledForBundleTest_0200 + * @tc.desc: test SetNotificationsEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetNotificationsEnabledForBundle("DeviceId", true); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetNotificationsEnabledForBundleTest_0300 + * @tc.desc: test SetNotificationsEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetNotificationsEnabledForBundle("DeviceId", true); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledForBundleTest_0400 + * @tc.desc: test SetNotificationsEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetNotificationsEnabledForBundle("DeviceId", true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledForAllBundlesTest_0100 + * @tc.desc: test SetNotificationsEnabledForAllBundles function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetNotificationsEnabledForAllBundles("DeviceId", true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledForAllBundlesTest_0200 + * @tc.desc: test SetNotificationsEnabledForAllBundles function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetNotificationsEnabledForAllBundles("DeviceId", true); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetNotificationsEnabledForAllBundlesTest_0300 + * @tc.desc: test SetNotificationsEnabledForAllBundles function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetNotificationsEnabledForAllBundles("DeviceId", true); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledForAllBundlesTest_0400 + * @tc.desc: test SetNotificationsEnabledForAllBundles function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForAllBundlesTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetNotificationsEnabledForAllBundles("DeviceId", true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledForSpecialBundleTest_0100 + * @tc.desc: test SetNotificationsEnabledForSpecialBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetNotificationsEnabledForSpecialBundle("DeviceId", bundleOption, true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledForSpecialBundleTest_0200 + * @tc.desc: test SetNotificationsEnabledForSpecialBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetNotificationsEnabledForSpecialBundle("DeviceId", bundleOption, true); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetNotificationsEnabledForSpecialBundleTest_0300 + * @tc.desc: test SetNotificationsEnabledForSpecialBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetNotificationsEnabledForSpecialBundle("DeviceId", bundleOption, true); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledForSpecialBundleTest_0400 + * @tc.desc: test SetNotificationsEnabledForSpecialBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetNotificationsEnabledForSpecialBundle("DeviceId", bundleOption, true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledForSpecialBundleTest_0500 + * @tc.desc: test SetNotificationsEnabledForSpecialBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledForSpecialBundleTest_0500, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + int32_t result = proxy->SetNotificationsEnabledForSpecialBundle("DeviceId", bundleOption, true); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: SetShowBadgeEnabledForBundleTest_0100 + * @tc.desc: test SetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetShowBadgeEnabledForBundle(bundleOption, true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetShowBadgeEnabledForBundleTest_0200 + * @tc.desc: test SetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetShowBadgeEnabledForBundle(bundleOption, true); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetShowBadgeEnabledForBundleTest_0300 + * @tc.desc: test SetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetShowBadgeEnabledForBundle(bundleOption, true); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetShowBadgeEnabledForBundleTest_0400 + * @tc.desc: test SetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetShowBadgeEnabledForBundle(bundleOption, true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetShowBadgeEnabledForBundleTest_0500 + * @tc.desc: test SetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetShowBadgeEnabledForBundleTest_0500, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + int32_t result = proxy->SetShowBadgeEnabledForBundle(bundleOption, true); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: GetShowBadgeEnabledForBundleTest_0100 + * @tc.desc: test GetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetShowBadgeEnabledForBundleTest_0200 + * @tc.desc: test GetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, enabled); +} + +/* + * @tc.name: GetShowBadgeEnabledForBundleTest_0300 + * @tc.desc: test GetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetShowBadgeEnabledForBundleTest_0400 + * @tc.desc: test GetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetShowBadgeEnabledForBundleTest_0500 + * @tc.desc: test GetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetShowBadgeEnabledForBundleTest_0600 + * @tc.desc: test GetShowBadgeEnabledForBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledForBundleTest_0600, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = nullptr; + int32_t result = proxy->GetShowBadgeEnabledForBundle(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: GetShowBadgeEnabledTest_0100 + * @tc.desc: test GetShowBadgeEnabled function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->GetShowBadgeEnabled(enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetShowBadgeEnabledTest_0200 + * @tc.desc: test GetShowBadgeEnabled function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->GetShowBadgeEnabled(enabled); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, enabled); +} + +/* + * @tc.name: GetShowBadgeEnabledTest_0300 + * @tc.desc: test GetShowBadgeEnabled function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->GetShowBadgeEnabled(enabled); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetShowBadgeEnabledTest_0400 + * @tc.desc: test GetShowBadgeEnabled function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->GetShowBadgeEnabled(enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetShowBadgeEnabledTest_0500 + * @tc.desc: test GetShowBadgeEnabled function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetShowBadgeEnabledTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->GetShowBadgeEnabled(enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SubscribeTest_0100 + * @tc.desc: test Subscribe function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SubscribeTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + auto subscriber = new (std::nothrow) TestSubscriber(); + sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); + int32_t result = proxy->Subscribe(subscriber->GetImpl(), subInfo); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SubscribeTest_0200 + * @tc.desc: test Subscribe function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SubscribeTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + auto subscriber = new (std::nothrow) TestSubscriber(); + sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); + int32_t result = proxy->Subscribe(subscriber->GetImpl(), subInfo); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: SubscribeTest_0300 + * @tc.desc: test Subscribe function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SubscribeTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + auto subscriber = new (std::nothrow) TestSubscriber(); + sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); + int32_t result = proxy->Subscribe(subscriber->GetImpl(), subInfo); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SubscribeTest_0400 + * @tc.desc: test Subscribe function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SubscribeTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + auto subscriber = new (std::nothrow) TestSubscriber(); + sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); + int32_t result = proxy->Subscribe(subscriber->GetImpl(), subInfo); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SubscribeTest_0500 + * @tc.desc: test Subscribe function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SubscribeTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SubscribeTest_0500, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); + int32_t result = proxy->Subscribe(nullptr, subInfo); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: UnsubscribeTest_0100 + * @tc.desc: test Unsubscribe function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UnsubscribeTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + auto subscriber = new (std::nothrow) TestSubscriber(); + sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); + int32_t result = proxy->Unsubscribe(subscriber->GetImpl(), subInfo); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: UnsubscribeTest_0200 + * @tc.desc: test Unsubscribe function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UnsubscribeTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + auto subscriber = new (std::nothrow) TestSubscriber(); + sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); + int32_t result = proxy->Unsubscribe(subscriber->GetImpl(), subInfo); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: UnsubscribeTest_0300 + * @tc.desc: test Unsubscribe function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UnsubscribeTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + auto subscriber = new (std::nothrow) TestSubscriber(); + sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); + int32_t result = proxy->Unsubscribe(subscriber->GetImpl(), subInfo); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: UnsubscribeTest_0400 + * @tc.desc: test Unsubscribe function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UnsubscribeTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + auto subscriber = new (std::nothrow) TestSubscriber(); + sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); + int32_t result = proxy->Unsubscribe(subscriber->GetImpl(), subInfo); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: UnsubscribeTest_0500 + * @tc.desc: test Unsubscribe function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, UnsubscribeTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UnsubscribeTest_0500, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr subInfo = new (std::nothrow) NotificationSubscribeInfo(); + int32_t result = proxy->Unsubscribe(nullptr, subInfo); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: IsAllowedNotifyTest_0100 + * @tc.desc: test IsAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifyTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsAllowedNotifyTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool allowed = false; + int32_t result = proxy->IsAllowedNotify(allowed); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsAllowedNotifyTest_0200 + * @tc.desc: test IsAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifyTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsAllowedNotifyTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool allowed = false; + int32_t result = proxy->IsAllowedNotify(allowed); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, allowed); +} + +/* + * @tc.name: IsAllowedNotifyTest_0300 + * @tc.desc: test IsAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifyTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsAllowedNotifyTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool allowed = false; + int32_t result = proxy->IsAllowedNotify(allowed); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: IsAllowedNotifyTest_0400 + * @tc.desc: test IsAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifyTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsAllowedNotifyTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool allowed = false; + int32_t result = proxy->IsAllowedNotify(allowed); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsAllowedNotifyTest_0500 + * @tc.desc: test IsAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifyTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsAllowedNotifyTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool allowed = false; + int32_t result = proxy->IsAllowedNotify(allowed); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsAllowedNotifySelfTest_0100 + * @tc.desc: test IsAllowedNotifySelf function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool allowed = false; + int32_t result = proxy->IsAllowedNotifySelf(allowed); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsAllowedNotifySelfTest_0200 + * @tc.desc: test IsAllowedNotifySelf function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool allowed = false; + int32_t result = proxy->IsAllowedNotifySelf(allowed); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, allowed); +} + +/* + * @tc.name: IsAllowedNotifySelfTest_0300 + * @tc.desc: test IsAllowedNotifySelf function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool allowed = false; + int32_t result = proxy->IsAllowedNotifySelf(allowed); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: IsAllowedNotifySelfTest_0400 + * @tc.desc: test IsAllowedNotifySelf function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool allowed = false; + int32_t result = proxy->IsAllowedNotifySelf(allowed); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsAllowedNotifySelfTest_0500 + * @tc.desc: test IsAllowedNotifySelf function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsAllowedNotifySelfTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool allowed = false; + int32_t result = proxy->IsAllowedNotifySelf(allowed); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSpecialBundleAllowedNotifyTest_0100 + * @tc.desc: test IsSpecialBundleAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSpecialBundleAllowedNotifyTest_0200 + * @tc.desc: test IsSpecialBundleAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, enabled); +} + +/* + * @tc.name: IsSpecialBundleAllowedNotifyTest_0300 + * @tc.desc: test IsSpecialBundleAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: IsSpecialBundleAllowedNotifyTest_0400 + * @tc.desc: test IsSpecialBundleAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSpecialBundleAllowedNotifyTest_0500 + * @tc.desc: test IsSpecialBundleAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSpecialBundleAllowedNotifyTest_0600 + * @tc.desc: test IsSpecialBundleAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialBundleAllowedNotifyTest_0600, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = nullptr; + int32_t result = proxy->IsSpecialBundleAllowedNotify(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: CancelGroupTest_0100 + * @tc.desc: test CancelGroup function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelGroupTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelGroupTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelGroup("GroupName", 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelGroupTest_0200 + * @tc.desc: test CancelGroup function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelGroupTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelGroupTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelGroup("GroupName", 0); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: CancelGroupTest_0300 + * @tc.desc: test CancelGroup function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelGroupTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelGroupTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelGroup("GroupName", 0); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: CancelGroupTest_0400 + * @tc.desc: test CancelGroup function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelGroupTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelGroupTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelGroup("GroupName", 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RemoveGroupByBundleTest_0100 + * @tc.desc: test RemoveGroupByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveGroupByBundle(bundleOption, "GroupName"); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: RemoveGroupByBundleTest_0200 + * @tc.desc: test RemoveGroupByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveGroupByBundle(bundleOption, "GroupName"); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: RemoveGroupByBundleTest_0300 + * @tc.desc: test RemoveGroupByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveGroupByBundle(bundleOption, "GroupName"); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: RemoveGroupByBundleTest_0400 + * @tc.desc: test RemoveGroupByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, RemoveGroupByBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveGroupByBundle(bundleOption, "GroupName"); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetDoNotDisturbDateTest_0100 + * @tc.desc: test SetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); + int32_t result = proxy->SetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetDoNotDisturbDateTest_0200 + * @tc.desc: test SetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = nullptr; + int32_t result = proxy->SetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: SetDoNotDisturbDateTest_0300 + * @tc.desc: test SetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); + int32_t result = proxy->SetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetDoNotDisturbDateTest_0400 + * @tc.desc: test SetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); + int32_t result = proxy->SetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetDoNotDisturbDateTest_0500 + * @tc.desc: test SetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); + int32_t result = proxy->SetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetDoNotDisturbDateTest_0100 + * @tc.desc: test GetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = nullptr; + int32_t result = proxy->GetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetDoNotDisturbDateTest_0200 + * @tc.desc: test GetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = nullptr; + int32_t result = proxy->GetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} +/* + * @tc.name: GetDoNotDisturbDateTest_0300 + * @tc.desc: test GetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = nullptr; + int32_t result = proxy->GetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetDoNotDisturbDateTest_0400 + * @tc.desc: test GetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = nullptr; + int32_t result = proxy->GetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DoesSupportDoNotDisturbModeTest_0100 + * @tc.desc: test DoesSupportDoNotDisturbMode function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool doesSupport = false; + int32_t result = proxy->DoesSupportDoNotDisturbMode(doesSupport); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DoesSupportDoNotDisturbModeTest_0200 + * @tc.desc: test DoesSupportDoNotDisturbMode function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool doesSupport = false; + int32_t result = proxy->DoesSupportDoNotDisturbMode(doesSupport); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, doesSupport); +} + +/* + * @tc.name: DoesSupportDoNotDisturbModeTest_0300 + * @tc.desc: test DoesSupportDoNotDisturbMode function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool doesSupport = false; + int32_t result = proxy->DoesSupportDoNotDisturbMode(doesSupport); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: DoesSupportDoNotDisturbModeTest_0400 + * @tc.desc: test DoesSupportDoNotDisturbMode function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool doesSupport = false; + int32_t result = proxy->DoesSupportDoNotDisturbMode(doesSupport); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DoesSupportDoNotDisturbModeTest_0500 + * @tc.desc: test DoesSupportDoNotDisturbMode function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DoesSupportDoNotDisturbModeTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool doesSupport = false; + int32_t result = proxy->DoesSupportDoNotDisturbMode(doesSupport); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsDistributedEnabledTest_0100 + * @tc.desc: test IsDistributedEnabled function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnabledTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnabledTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->IsDistributedEnabled(enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsDistributedEnabledTest_0200 + * @tc.desc: test IsDistributedEnabled function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnabledTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnabledTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->IsDistributedEnabled(enabled); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, enabled); +} + +/* + * @tc.name: IsDistributedEnabledTest_0300 + * @tc.desc: test IsDistributedEnabled function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnabledTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnabledTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->IsDistributedEnabled(enabled); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: IsDistributedEnabledTest_0400 + * @tc.desc: test IsDistributedEnabled function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnabledTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnabledTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->IsDistributedEnabled(enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsDistributedEnabledTest_0500 + * @tc.desc: test IsDistributedEnabled function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnabledTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnabledTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->IsDistributedEnabled(enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: EnableDistributedTest_0100 + * @tc.desc: test EnableDistributed function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->EnableDistributed(true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: EnableDistributedTest_0200 + * @tc.desc: test EnableDistributed function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->EnableDistributed(true); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: EnableDistributedTest_0300 + * @tc.desc: test EnableDistributed function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->EnableDistributed(true); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: EnableDistributedTest_0400 + * @tc.desc: test EnableDistributed function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->EnableDistributed(true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: EnableDistributedByBundleTest_0100 + * @tc.desc: test EnableDistributedByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->EnableDistributedByBundle(bundleOption, true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: EnableDistributedByBundleTest_0200 + * @tc.desc: test EnableDistributedByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + int32_t result = proxy->EnableDistributedByBundle(bundleOption, true); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: EnableDistributedByBundleTest_0300 + * @tc.desc: test EnableDistributedByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->EnableDistributedByBundle(bundleOption, true); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: EnableDistributedByBundleTest_0400 + * @tc.desc: test EnableDistributedByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->EnableDistributedByBundle(bundleOption, true); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: EnableDistributedByBundleTest_0500 + * @tc.desc: test EnableDistributedByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedByBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->EnableDistributedByBundle(bundleOption, true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: EnableDistributedSelfTest_0100 + * @tc.desc: test EnableDistributedSelf function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedSelfTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedSelfTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->EnableDistributedSelf(true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: EnableDistributedSelfTest_0200 + * @tc.desc: test EnableDistributedSelf function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedSelfTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedSelfTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->EnableDistributedSelf(true); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: EnableDistributedSelfTest_0300 + * @tc.desc: test EnableDistributedSelf function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedSelfTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedSelfTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->EnableDistributedSelf(true); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: EnableDistributedSelfTest_0400 + * @tc.desc: test EnableDistributedSelf function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, EnableDistributedSelfTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, EnableDistributedSelfTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->EnableDistributedSelf(true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsDistributedEnableByBundleTest_0100 + * @tc.desc: test IsDistributedEnableByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + bool enabled = false; + int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsDistributedEnableByBundleTest_0200 + * @tc.desc: test IsDistributedEnableByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + bool enabled = false; + int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: IsDistributedEnableByBundleTest_0300 + * @tc.desc: test IsDistributedEnableByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + bool enabled = false; + int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, enabled); +} + +/* + * @tc.name: IsDistributedEnableByBundleTest_0400 + * @tc.desc: test IsDistributedEnableByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + bool enabled = false; + int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: IsDistributedEnableByBundleTest_0500 + * @tc.desc: test IsDistributedEnableByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + bool enabled = false; + int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsDistributedEnableByBundleTest_0600 + * @tc.desc: test IsDistributedEnableByBundle function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsDistributedEnableByBundleTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + bool enabled = false; + int32_t result = proxy->IsDistributedEnableByBundle(bundleOption, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: PublishContinuousTaskNotificationTest_0100 + * @tc.desc: test PublishContinuousTaskNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0100, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr notification = nullptr; + int32_t result = proxy->PublishContinuousTaskNotification(notification); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: PublishContinuousTaskNotificationTest_0200 + * @tc.desc: test PublishContinuousTaskNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr ansManagerProxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, ansManagerProxy); + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + ASSERT_NE(nullptr, notification); + int32_t result = ansManagerProxy->PublishContinuousTaskNotification(notification); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: PublishContinuousTaskNotificationTest_0300 + * @tc.desc: test PublishContinuousTaskNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0300, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + ASSERT_NE(nullptr, notification); + int32_t result = proxy->PublishContinuousTaskNotification(notification); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: PublishContinuousTaskNotificationTest_0400 + * @tc.desc: test PublishContinuousTaskNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + ASSERT_NE(nullptr, notification); + int32_t result = proxy->PublishContinuousTaskNotification(notification); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: PublishContinuousTaskNotificationTest_0500 + * @tc.desc: test PublishContinuousTaskNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishContinuousTaskNotificationTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + NotificationRequest request(1); + sptr notification = new (std::nothrow) NotificationRequest(request); + ASSERT_NE(nullptr, notification); + int32_t result = proxy->PublishContinuousTaskNotification(notification); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: CancelContinuousTaskNotificationTest_0100 + * @tc.desc: test CancelContinuousTaskNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelContinuousTaskNotification("label", 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: CancelContinuousTaskNotificationTest_0200 + * @tc.desc: test CancelContinuousTaskNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelContinuousTaskNotification("label", 0); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: CancelContinuousTaskNotificationTest_0300 + * @tc.desc: test CancelContinuousTaskNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelContinuousTaskNotification("label", 0); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: CancelContinuousTaskNotificationTest_0400 + * @tc.desc: test CancelContinuousTaskNotification function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelContinuousTaskNotificationTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->CancelContinuousTaskNotification("label", 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSupportTemplateTest_0100 + * @tc.desc: test IsSupportTemplate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string templateName = "TemplateName"; + bool support = false; + int32_t result = proxy->IsSupportTemplate(templateName, support); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSupportTemplateTest_0200 + * @tc.desc: test IsSupportTemplate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string templateName = "TemplateName"; + bool support = false; + int32_t result = proxy->IsSupportTemplate(templateName, support); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSupportTemplateTest_0300 + * @tc.desc: test IsSupportTemplate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string templateName = "TemplateName"; + bool support = false; + int32_t result = proxy->IsSupportTemplate(templateName, support); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, support); +} + +/* + * @tc.name: IsSupportTemplateTest_0400 + * @tc.desc: test IsSupportTemplate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string templateName = "TemplateName"; + bool support = false; + int32_t result = proxy->IsSupportTemplate(templateName, support); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: IsSupportTemplateTest_0500 + * @tc.desc: test IsSupportTemplate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string templateName = "TemplateName"; + bool support = false; + int32_t result = proxy->IsSupportTemplate(templateName, support); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSupportTemplateTest_0600 + * @tc.desc: test IsSupportTemplate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSupportTemplateTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSupportTemplateTest_0600, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string templateName = "TemplateName"; + bool support = false; + int32_t result = proxy->IsSupportTemplate(templateName, support); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSpecialUserAllowedNotifyTest_0100 + * @tc.desc: test IsSpecialUserAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + bool allowed = false; + int32_t result = proxy->IsSpecialUserAllowedNotify(userId, allowed); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSpecialUserAllowedNotifyTest_0200 + * @tc.desc: test IsSpecialUserAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + bool allowed = false; + int32_t result = proxy->IsSpecialUserAllowedNotify(userId, allowed); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, allowed); +} + +/* + * @tc.name: IsSpecialUserAllowedNotifyTest_0300 + * @tc.desc: test IsSpecialUserAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + bool allowed = false; + int32_t result = proxy->IsSpecialUserAllowedNotify(userId, allowed); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: IsSpecialUserAllowedNotifyTest_0400 + * @tc.desc: test IsSpecialUserAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + bool allowed = false; + int32_t result = proxy->IsSpecialUserAllowedNotify(userId, allowed); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsSpecialUserAllowedNotifyTest_0500 + * @tc.desc: test IsSpecialUserAllowedNotify function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsSpecialUserAllowedNotifyTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + bool allowed = false; + int32_t result = proxy->IsSpecialUserAllowedNotify(userId, allowed); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledByUserTest_0100 + * @tc.desc: test SetNotificationsEnabledByUser function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + bool enabled = true; + int32_t result = proxy->SetNotificationsEnabledByUser(userId, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledByUserTest_0200 + * @tc.desc: test SetNotificationsEnabledByUser function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + bool enabled = true; + int32_t result = proxy->SetNotificationsEnabledByUser(userId, enabled); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetNotificationsEnabledByUserTest_0300 + * @tc.desc: test SetNotificationsEnabledByUser function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + bool enabled = true; + int32_t result = proxy->SetNotificationsEnabledByUser(userId, enabled); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetNotificationsEnabledByUserTest_0400 + * @tc.desc: test SetNotificationsEnabledByUser function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetNotificationsEnabledByUserTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + bool enabled = true; + int32_t result = proxy->SetNotificationsEnabledByUser(userId, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DeleteAllByUserTest_0100 + * @tc.desc: test DeleteAllByUser function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteAllByUserTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteAllByUserTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + int32_t result = proxy->DeleteAllByUser(userId); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: DeleteAllByUserTest_0200 + * @tc.desc: test DeleteAllByUser function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteAllByUserTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteAllByUserTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + int32_t result = proxy->DeleteAllByUser(userId); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: DeleteAllByUserTest_0300 + * @tc.desc: test DeleteAllByUser function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteAllByUserTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteAllByUserTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + int32_t result = proxy->DeleteAllByUser(userId); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: DeleteAllByUserTest_0400 + * @tc.desc: test DeleteAllByUser function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, DeleteAllByUserTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DeleteAllByUserTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + int32_t result = proxy->DeleteAllByUser(userId); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetDoNotDisturbDateTest_2_0100 + * @tc.desc: test SetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); + int32_t userId = 100; // 100 default user + int32_t result = proxy->SetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetDoNotDisturbDateTest_2_0200 + * @tc.desc: test SetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = nullptr; + int32_t userId = 100; // 100 default user + int32_t result = proxy->SetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: SetDoNotDisturbDateTest_2_0300 + * @tc.desc: test SetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); + int32_t userId = 100; // 100 default user + int32_t result = proxy->SetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetDoNotDisturbDateTest_2_0400 + * @tc.desc: test SetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); + int32_t userId = 100; // 100 default user + int32_t result = proxy->SetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetDoNotDisturbDateTest_2_0500 + * @tc.desc: test SetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetDoNotDisturbDateTest_2_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = new (std::nothrow) NotificationDoNotDisturbDate(); + int32_t userId = 100; // 100 default user + int32_t result = proxy->SetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetDoNotDisturbDateTest_2_0100 + * @tc.desc: test GetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = nullptr; + int32_t userId = 0; + int32_t result = proxy->GetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetDoNotDisturbDateTest_2_0200 + * @tc.desc: test GetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = nullptr; + int32_t userId = 0; + int32_t result = proxy->GetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} +/* + * @tc.name: GetDoNotDisturbDateTest_2_0300 + * @tc.desc: test GetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = nullptr; + int32_t userId = 0; + int32_t result = proxy->GetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetDoNotDisturbDateTest_2_0400 + * @tc.desc: test GetDoNotDisturbDate function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetDoNotDisturbDateTest_2_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr doNotDisturbDate = nullptr; + int32_t userId = 0; + int32_t result = proxy->GetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetEnabledForBundleSlotTest_0100 + * @tc.desc: test SetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetEnabledForBundleSlot( + bundleOption, NotificationConstant::SOCIAL_COMMUNICATION, true, false); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetEnabledForBundleSlotTest_0200 + * @tc.desc: test SetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = nullptr; + int32_t result = proxy->SetEnabledForBundleSlot( + bundleOption, NotificationConstant::SOCIAL_COMMUNICATION, true, false); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: SetEnabledForBundleSlotTest_0300 + * @tc.desc: test SetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetEnabledForBundleSlot( + bundleOption, NotificationConstant::SOCIAL_COMMUNICATION, true, false); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: SetEnabledForBundleSlotTest_0400 + * @tc.desc: test SetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetEnabledForBundleSlot( + bundleOption, NotificationConstant::SOCIAL_COMMUNICATION, true, false); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetEnabledForBundleSlotTest_0500 + * @tc.desc: test SetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetEnabledForBundleSlotTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->SetEnabledForBundleSlot( + bundleOption, NotificationConstant::SOCIAL_COMMUNICATION, true, false); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetEnabledForBundleSlotTest_0100 + * @tc.desc: test GetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetEnabledForBundleSlotTest_0200 + * @tc.desc: test GetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr ansManagerProxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, ansManagerProxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + bool enabled = false; + int32_t result = ansManagerProxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, enabled); +} + +/* + * @tc.name: GetEnabledForBundleSlotTest_0300 + * @tc.desc: test GetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetEnabledForBundleSlotTest_0400 + * @tc.desc: test GetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetEnabledForBundleSlotTest_0500 + * @tc.desc: test GetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetEnabledForBundleSlotTest_0600 + * @tc.desc: test GetEnabledForBundleSlot function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0600, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetEnabledForBundleSlotTest_0600, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + sptr bundleOption = nullptr; + NotificationConstant::SlotType slotType = NotificationConstant::SOCIAL_COMMUNICATION; + int32_t result = proxy->GetEnabledForBundleSlot(bundleOption, slotType, enabled); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/* + * @tc.name: SetSyncNotificationEnabledWithoutAppTest_0100 + * @tc.desc: test SetSyncNotificationEnabledWithoutApp function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetSyncNotificationEnabledWithoutApp(0, true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetSyncNotificationEnabledWithoutAppTest_0200 + * @tc.desc: test SetSyncNotificationEnabledWithoutApp function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetSyncNotificationEnabledWithoutApp(0, true); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetSyncNotificationEnabledWithoutAppTest_0300 + * @tc.desc: test SetSyncNotificationEnabledWithoutApp function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetSyncNotificationEnabledWithoutApp(0, true); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetSyncNotificationEnabledWithoutAppTest_0400 + * @tc.desc: test SetSyncNotificationEnabledWithoutApp function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetSyncNotificationEnabledWithoutAppTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t result = proxy->SetSyncNotificationEnabledWithoutApp(0, true); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSyncNotificationEnabledWithoutAppTest_0100 + * @tc.desc: test GetSyncNotificationEnabledWithoutApp function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->GetSyncNotificationEnabledWithoutApp(0, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSyncNotificationEnabledWithoutAppTest_0200 + * @tc.desc: test GetSyncNotificationEnabledWithoutApp function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->GetSyncNotificationEnabledWithoutApp(0, enabled); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(true, enabled); +} + +/* + * @tc.name: GetSyncNotificationEnabledWithoutAppTest_0300 + * @tc.desc: test GetSyncNotificationEnabledWithoutApp function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->GetSyncNotificationEnabledWithoutApp(0, enabled); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetSyncNotificationEnabledWithoutAppTest_0400 + * @tc.desc: test GetSyncNotificationEnabledWithoutApp function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->GetSyncNotificationEnabledWithoutApp(0, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetSyncNotificationEnabledWithoutAppTest_0500 + * @tc.desc: test GetSyncNotificationEnabledWithoutApp function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetSyncNotificationEnabledWithoutAppTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool enabled = false; + int32_t result = proxy->GetSyncNotificationEnabledWithoutApp(0, enabled); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +int SendRequestReplaceDumpInfo(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option, + int32_t error, bool setError, int32_t num) +{ + if (setError) { + reply.WriteInt32(error); + } + + if (num > 0) { + std::vector vecDump; + for (int32_t i = 0; i < num; i++) { + std::string info = std::to_string(i); + vecDump.push_back(info); + } + reply.WriteStringVector(vecDump); + } + + return 0; +} +/* + * @tc.name: ShellDumpTest_0100 + * @tc.desc: test ShellDump function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, ShellDumpTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector dumpInfo; + int32_t result = proxy->ShellDump("anm dump -A", "BundleName", 0, 0, dumpInfo); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: ShellDumpTest_0200 + * @tc.desc: test ShellDump function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, ShellDumpTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceDumpInfo, _1, _2, _3, _4, + ERR_OK, true, 1)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector dumpInfo; + int32_t result = proxy->ShellDump("anm dump -A", "BundleName", 0, 0, dumpInfo); + EXPECT_EQ(ERR_OK, result); + EXPECT_EQ(1, dumpInfo.size()); +} + +/* + * @tc.name: ShellDumpTest_0300 + * @tc.desc: test ShellDump function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, ShellDumpTest_0300, TestSize.Level1"; + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + EXPECT_CALL(*iremoteObjects, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceDumpInfo, _1, _2, _3, _4, + ERR_OK, false, 0)), Return(NO_ERROR))); + std::shared_ptr ansManagerProxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, ansManagerProxy); + std::vector dumpInfo; + int32_t result = ansManagerProxy->ShellDump("anm dump -A", "BundleName", 0, 0, dumpInfo); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: ShellDumpTest_0400 + * @tc.desc: test ShellDump function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, ShellDumpTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector dumpInfo; + int32_t result = proxy->ShellDump("anm dump -A", "BundleName", 0, 0, dumpInfo); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: ShellDumpTest_0500 + * @tc.desc: test ShellDump function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, ShellDumpTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, ShellDumpTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplaceDumpInfo, _1, _2, _3, _4, + ERR_OK, false, 0)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector dumpInfo; + int32_t result = proxy->ShellDump("anm dump -A", "BundleName", 0, 0, dumpInfo); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: PublishReminder_0100 + * @tc.desc: test AnsManagerProxy's PublishReminder function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishReminder_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishReminder_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + sptr reminder = new ReminderRequest(); + ErrCode res = proxy->PublishReminder(reminder); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, res); +} + +/* + * @tc.name: PublishReminder_0200 + * @tc.desc: test AnsManagerProxy's PublishReminder function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishReminder_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishReminder_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + sptr reminder = nullptr; + ErrCode res = proxy->PublishReminder(reminder); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, res); +} + +/* + * @tc.name: PublishReminder_0300 + * @tc.desc: test AnsManagerProxy's PublishReminder function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, PublishReminder_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, PublishReminder_0300, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + sptr reminder = new ReminderRequest(); + ErrCode res = proxy->PublishReminder(reminder); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, res); +} + +/* + * @tc.name: ReadReminders_0100 + * @tc.desc: test AnsManagerProxy's ReadReminders function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, ReadReminders_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, ReadReminders_0100, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + uint8_t count = 10; + MessageParcel reply; + std::vector> reminders; + ErrCode res = proxy->ReadReminders(count, reply, reminders); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, res); +} + +/* + * @tc.name: SetBadgeNumberTest_0100 + * @tc.desc: test SetBadgeNumber function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetBadgeNumberTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t userId = 0; + int32_t result = proxy->SetBadgeNumber(userId, 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: SetBadgeNumberTest_0200 + * @tc.desc: test SetBadgeNumber function + * @tc.type: FUNC + * @tc.require: #I6C2X9 + */ +HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetBadgeNumberTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t badgeNumber = 0; + int32_t result = proxy->SetBadgeNumber(badgeNumber, 0); + EXPECT_EQ(ERR_OK, result); +} +/* + * @tc.name: SetBadgeNumberTest_0300 + * @tc.desc: test SetBadgeNumber function + * @tc.type: FUNC + * @tc.require: #I6C2X9 + */ +HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetBadgeNumberTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t badgeNumber = 0; + int32_t result = proxy->SetBadgeNumber(badgeNumber, 0); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: SetBadgeNumberTest_0400 + * @tc.desc: test SetBadgeNumber function + * @tc.type: FUNC + * @tc.require: #I6C2X9 + */ +HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetBadgeNumberTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t badgeNumber = 0; + int32_t result = proxy->SetBadgeNumber(badgeNumber, 0); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/** + * @tc.name: SetBadgeNumberByBundleTest_0100 + * @tc.desc: test SetBadgeNumberByBundle with null bundleOption, expect ErrCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberByBundleTest_0100, TestSize.Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + int32_t badgeNumber = 0; + int32_t result = proxy->SetBadgeNumberByBundle(nullptr, badgeNumber); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/** + * @tc.name: SetBadgeNumberByBundleTest_0200 + * @tc.desc: test SetBadgeNumberByBundle with invalid proxy object, expect ErrCode ERR_ANS_PARCELABLE_FAILED. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberByBundleTest_0200, TestSize.Level1) +{ + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + ASSERT_NE(nullptr, bundleOption); + std::string bundleName = "bundleName"; + bundleOption->SetBundleName(bundleName); + int32_t badgeNumber = 0; + int32_t result = proxy->SetBadgeNumberByBundle(bundleOption, badgeNumber); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/** + * @tc.name: SetBadgeNumberByBundleTest_0300 + * @tc.desc: test SetBadgeNumberByBundle with empty bundleOption, expect ErrCode ERR_ANS_PARCELABLE_FAILED. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, SetBadgeNumberByBundleTest_0300, TestSize.Level1) +{ + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + ASSERT_NE(nullptr, bundleOption); + std::string bundleName = "bundleName"; + bundleOption->SetBundleName(bundleName); + int32_t badgeNumber = 0; + int32_t result = proxy->SetBadgeNumberByBundle(bundleOption, badgeNumber); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: GetAllNotificationEnabledBundles_0100 + * @tc.desc: test GetAllNotificationEnabledBundles function + * @tc.type: FUNC + * @tc.require: #I92VGR + */ +HWTEST_F(AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector bundleOption; + int32_t result = proxy->GetAllNotificationEnabledBundles(bundleOption); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetAllNotificationEnabledBundles_0200 + * @tc.desc: test GetAllNotificationEnabledBundles function + * @tc.type: FUNC + * @tc.require: #I92VGR + */ +HWTEST_F(AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestGetAllEnableNotifications, _1, _2, _3, _4, + ERR_OK, true, 1, 1)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector bundleOption; + int32_t result = proxy->GetAllNotificationEnabledBundles(bundleOption); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: GetAllNotificationEnabledBundles_0300 + * @tc.desc: test SetBadgeNumber function + * @tc.type: FUNC + * @tc.require: #I92VGR + */ +HWTEST_F(AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0300, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector bundleOption; + int32_t result = proxy->GetAllNotificationEnabledBundles(bundleOption); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: GetAllNotificationEnabledBundles_0400 + * @tc.desc: test GetAllNotificationEnabledBundles function + * @tc.type: FUNC + * @tc.require: #I92VGR + */ +HWTEST_F(AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0400, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector bundleOption; + int32_t result = proxy->GetAllNotificationEnabledBundles(bundleOption); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetActiveNotificationByFilterTest_0100 + * @tc.desc: test GetActiveNotificationByFilter function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationByFilterTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationByFilterTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t notificationId = 0; + std::string label = "label"; + std::vector extraInfoKeys; + + NotificationRequest request(1); + sptr liveViewRequest = new (std::nothrow) NotificationRequest(request); + + int32_t result = proxy->GetActiveNotificationByFilter(bundleOption, notificationId, label, + extraInfoKeys, liveViewRequest); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: GetActiveNotificationByFilterTest_0200 + * @tc.desc: test GetActiveNotificationByFilter function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, GetActiveNotificationByFilterTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, GetActiveNotificationByFilterTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + sptr bundleOption = nullptr; + int32_t notificationId = 0; + std::string label = "label"; + std::vector extraInfoKeys; + + NotificationRequest request(1); + sptr liveViewRequest = new (std::nothrow) NotificationRequest(request); + + int32_t result = proxy->GetActiveNotificationByFilter(bundleOption, notificationId, label, + extraInfoKeys, liveViewRequest); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, result); +} + +/** + * @tc.name: AddDoNotDisturbProfiles_0100 + * @tc.desc: test AddDoNotDisturbProfiles when profiles is empty. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, AddDoNotDisturbProfiles_0100, TestSize.Level1) +{ + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> profiles; + profiles.clear(); + auto res = proxy->AddDoNotDisturbProfiles(profiles); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, res); +} + +/** + * @tc.name: AddDoNotDisturbProfiles_0200 + * @tc.desc: test AddDoNotDisturbProfiles when WriteInterfaceToken return false. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, AddDoNotDisturbProfiles_0200, TestSize.Level1) +{ + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + int32_t id = 1; + std::string name = "Name"; + std::vector trustlist; + std::vector> profiles; + sptr disturbProfile = + new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); + profiles.emplace_back(disturbProfile); + + MockWriteInterfaceToken(false); + auto res = proxy->AddDoNotDisturbProfiles(profiles); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, res); +} + +/** + * @tc.name: AddDoNotDisturbProfiles_0300 + * @tc.desc: test AddDoNotDisturbProfiles run success and return result. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, AddDoNotDisturbProfiles_0300, TestSize.Level1) +{ + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + int32_t id = 1; + std::string name = "Name"; + std::vector trustlist; + std::vector> profiles; + sptr disturbProfile = + new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); + profiles.emplace_back(disturbProfile); + + MockWriteInterfaceToken(true); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .Times(1) + .WillRepeatedly( + DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + auto res = proxy->AddDoNotDisturbProfiles(profiles); + EXPECT_NE(ERR_OK, res); + EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, res); +} + +/** + * @tc.name: RemoveDoNotDisturbProfiles_0100 + * @tc.desc: test RemoveDoNotDisturbProfiles when profiles is empty. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveDoNotDisturbProfiles_0100, TestSize.Level1) +{ + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::vector> profiles; + profiles.clear(); + auto res = proxy->RemoveDoNotDisturbProfiles(profiles); + EXPECT_EQ(ERR_ANS_INVALID_PARAM, res); +} + +/** + * @tc.name: RemoveDoNotDisturbProfiles_0200 + * @tc.desc: test RemoveDoNotDisturbProfiles when WriteInterfaceToken return false. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveDoNotDisturbProfiles_0200, TestSize.Level1) +{ + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + int32_t id = 1; + std::string name = "Name"; + std::vector trustlist; + std::vector> profiles; + sptr disturbProfile = + new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); + profiles.emplace_back(disturbProfile); + + MockWriteInterfaceToken(false); + auto res = proxy->RemoveDoNotDisturbProfiles(profiles); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, res); +} + +/** + * @tc.name: RemoveDoNotDisturbProfiles_0300 + * @tc.desc: test RemoveDoNotDisturbProfiles run success and return result. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, RemoveDoNotDisturbProfiles_0300, TestSize.Level1) +{ + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + int32_t id = 1; + std::string name = "Name"; + std::vector trustlist; + std::vector> profiles; + sptr disturbProfile = + new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); + profiles.emplace_back(disturbProfile); + + MockWriteInterfaceToken(true); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .Times(1) + .WillRepeatedly( + DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, true, true)), Return(NO_ERROR))); + auto res = proxy->RemoveDoNotDisturbProfiles(profiles); + EXPECT_NE(ERR_OK, res); + EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, res); +} + +/* + * @tc.name: IsNeedSilentInDoNotDisturbModeTest_0100 + * @tc.desc: test IsNeedSilentInDoNotDisturbMode function + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + int32_t result = proxy->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsNeedSilentInDoNotDisturbModeTest_0200 + * @tc.desc: test IsNeedSilentInDoNotDisturbMode function + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, true)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + int32_t result = proxy->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: IsNeedSilentInDoNotDisturbModeTest_0300 + * @tc.desc: test IsNeedSilentInDoNotDisturbMode function + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0300, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0300, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + int32_t result = proxy->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); + EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); +} + +/* + * @tc.name: IsNeedSilentInDoNotDisturbModeTest_0400 + * @tc.desc: test IsNeedSilentInDoNotDisturbMode function + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0400, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0400, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, false, false, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + int32_t result = proxy->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); + EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); +} + +/* + * @tc.name: IsNeedSilentInDoNotDisturbModeTest_0500 + * @tc.desc: test IsNeedSilentInDoNotDisturbMode function + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0500, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0500, TestSize.Level1"; + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) + .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, + ERR_OK, true, true, false)), Return(NO_ERROR))); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + int32_t result = proxy->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); + EXPECT_EQ(ERR_OK, result); +} +} // namespace Notification +} // namespace OHOS diff --git a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp index 0190cf750..f6a05e050 100644 --- a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp +++ b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp @@ -5428,5 +5428,37 @@ HWTEST_F(AnsManagerStubTest, RegisterSwingCallback_0200, TestSize.Level1) EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); } #endif + +/** + * @tc.name: HandleIsNeedSilentInDoNotDisturbMode01 + * @tc.desc: Test HandleIsNeedSilentInDoNotDisturbMode01 succeeds. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerStubTest, HandleIsNeedSilentInDoNotDisturbMode01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(NotificationInterfaceCode::IS_NEED_SILENT_IN_DO_NOT_DISTURB_MODE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: IsNeedSilentInDoNotDisturbMode01 + * @tc.desc: Test IsNeedSilentInDoNotDisturbMode return. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerStubTest, IsNeedSilentInDoNotDisturbMode01, Function | SmallTest | Level1) +{ + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + + ErrCode result = ansManagerStub_->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); + EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); +} } } diff --git a/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp b/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp index 2b59696a1..e0ab0c470 100644 --- a/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp +++ b/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp @@ -1,1513 +1,1533 @@ -/* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ans_dialog_callback_stub.h" -#include "errors.h" -#include "notification_slot.h" -#include -#include - -#define private public -#define protected public -#include "ans_notification.h" -#include "ans_subscriber_proxy.h" -#include "ans_manager_proxy.h" -#undef private -#undef protected -#include "ans_inner_errors.h" -#include "ipc_types.h" -#include "mock_i_remote_object.h" -#include "notification.h" -#include "singleton.h" -#include "notification_subscriber.h" - -using namespace testing; -using namespace testing::ext; -using namespace OHOS; -using namespace OHOS::Notification; - -extern void MockWriteInterfaceToken(bool mockRet); - -namespace OHOS { -namespace Notification { -class AnsNotificationUnitTest : public testing::Test { -public: - AnsNotificationUnitTest() {} - - virtual ~AnsNotificationUnitTest() {} - - static void SetUpTestCase(); - - static void TearDownTestCase(); - - void SetUp(); - - void TearDown(); - std::shared_ptr ans_; - sptr ansManagerProxy_{nullptr}; -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED - void UpdateStatuts(bool isEnable, int status) {} -#endif -}; - -void AnsNotificationUnitTest::SetUpTestCase() -{ - MockWriteInterfaceToken(true); -} - -void AnsNotificationUnitTest::TearDownTestCase() {} - -void AnsNotificationUnitTest::SetUp() -{ - if (!ans_) { - ans_ = DelayedSingleton::GetInstance(); - } -} - -void AnsNotificationUnitTest::TearDown() {} - -class TestAnsSubscriber : public NotificationSubscriber { -public: - void OnConnected() override - {} - void OnDisconnected() override - {} - void OnUpdate(const std::shared_ptr &sortingMap) override - {} - void OnDied() override - {} - void OnEnabledNotificationChanged( - const std::shared_ptr &callbackData) override - {} - void OnDoNotDisturbDateChange(const std::shared_ptr &date) override - {} - void OnCanceled(const std::shared_ptr &request, - const std::shared_ptr &sortingMap, int deleteReason) override - {} - void OnConsumed(const std::shared_ptr &request, - const std::shared_ptr &sortingMap) override - {} - void OnBadgeChanged(const std::shared_ptr &badgeData) override - {} - void OnBadgeEnabledChanged(const sptr &callbackData) override - {} - void OnBatchCanceled(const std::vector> - &requestList, const std::shared_ptr &sortingMap, int32_t deleteReason) override - {} -}; - -/* - * @tc.name: GetAnsManagerProxy_0100 - * @tc.desc: test GetAnsManagerProxy return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetAnsManagerProxy_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool res = ans_->GetAnsManagerProxy(); - EXPECT_EQ(res, false); -} - -/* - * @tc.name: AddSlotByType_0100 - * @tc.desc: test AddSlotByType ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, AddSlotByType_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOM; - ErrCode ret1 = ans_->AddSlotByType(slotType); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret3 = ans_->RemoveNotificationSlot(slotType); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: RemoveAllSlots_0100 - * @tc.desc: test RemoveAllSlots ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, RemoveAllSlots_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - ErrCode ret1 = ans_->RemoveAllSlots(); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetNotificationSlot_0100 - * @tc.desc: test GetNotificationSlot ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetNotificationSlot_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOM; - sptr slot = new NotificationSlot(); - ErrCode ret1 = ans_->GetNotificationSlot(slotType, slot); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - std::vector> slots; - slots.emplace_back(slot); - ErrCode ret2 = ans_->GetNotificationSlots(slots); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); - std::vector nslots; - NotificationSlot notificationSlot; - nslots.emplace_back(notificationSlot); - ErrCode ret3 = ans_->AddNotificationSlots(nslots); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetNotificationSlotNumAsBundle_0100 - * @tc.desc: test GetNotificationSlotNumAsBundle ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotNumAsBundle_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationBundleOption bundleOptions; - std::string bundleName = "bundleName"; - bundleOptions.SetBundleName(bundleName); - uint64_t num = 10; - ErrCode ret1 = ans_->GetNotificationSlotNumAsBundle(bundleOptions, num); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetNotificationSlotFlagsAsBundle_0100 - * @tc.desc: test GetNotificationSlotFlagsAsBundle. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotFlagsAsBundle_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationBundleOption bundleOptions; - std::string bundleName = "bundleName"; - bundleOptions.SetBundleName(bundleName); - uint32_t num = 10; - ErrCode ret1 = ans_->GetNotificationSlotFlagsAsBundle(bundleOptions, num); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetNotificationSlotFlagsAsBundle_0200 - * @tc.desc: test GetNotificationSlotFlagsAsBundle. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotFlagsAsBundle_0200, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationBundleOption bundleOptions; - bundleOptions.SetBundleName(""); - uint32_t num = 10; - ErrCode ret1 = ans_->GetNotificationSlotFlagsAsBundle(bundleOptions, num); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: SetNotificationSlotFlagsAsBundle_0200 - * @tc.desc: test GetNotificationSlotFlagsAsBundle. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetNotificationSlotFlagsAsBundle_0200, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationBundleOption bundleOptions; - bundleOptions.SetBundleName(""); - uint64_t num = 10; - ErrCode ret1 = ans_->SetNotificationSlotFlagsAsBundle(bundleOptions, num); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: CanPopEnableNotificationDialog_0100 - * @tc.desc: test CanPopEnableNotificationDialog. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, CanPopEnableNotificationDialog_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - sptr client = nullptr; - bool enable = true; - std::string bundleName = ""; - ErrCode ret1 = ans_->CanPopEnableNotificationDialog(client, enable, bundleName); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: RemoveNotifications_0100 - * @tc.desc: test RemoveNotifications. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, RemoveNotifications_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::vector hashCodes = {"data1", "data2"}; - ErrCode ret1 = ans_->RemoveNotifications(hashCodes, 1); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetNotificationSlotForBundle_0100 - * @tc.desc: test GetNotificationSlotForBundle. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotForBundle_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationBundleOption bundleOptions; - bundleOptions.SetBundleName("name"); - sptr slot = new NotificationSlot(); - ErrCode ret1 = ans_->GetNotificationSlotForBundle(bundleOptions, - NotificationConstant::SlotType::CONTENT_INFORMATION, slot); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetNotificationSlotForBundle_0200 - * @tc.desc: test GetNotificationSlotForBundle. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotForBundle_0200, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationBundleOption bundleOptions; - bundleOptions.SetBundleName(""); - sptr slot = new NotificationSlot(); - ErrCode ret1 = ans_->GetNotificationSlotForBundle(bundleOptions, - NotificationConstant::SlotType::CONTENT_INFORMATION, slot); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: GetEnabledForBundleSlotSelf_0100 - * @tc.desc: test GetEnabledForBundleSlotSelf. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetEnabledForBundleSlotSelf_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - bool enable = true; - ErrCode ret1 = ans_->GetEnabledForBundleSlotSelf( - NotificationConstant::SlotType::CONTENT_INFORMATION, enable); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: RegisterPushCallback_0100 - * @tc.desc: test RegisterPushCallback. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, RegisterPushCallback_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - sptr callback = new AnsDialogHostClient(); - sptr checkRequest = nullptr; - ErrCode ret1 = ans_->RegisterPushCallback(callback->AsObject(), checkRequest); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: UnregisterPushCallback_0100 - * @tc.desc: test UnregisterPushCallback. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, UnregisterPushCallback_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - ErrCode ret1 = ans_->UnregisterPushCallback(); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetAdditionConfig_0100 - * @tc.desc: test SetAdditionConfig. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetAdditionConfig_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::string key = "key"; - std::string value = "value"; - ErrCode ret1 = ans_->SetAdditionConfig(key, value); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetAdditionConfig_0200 - * @tc.desc: test SetAdditionConfig. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetAdditionConfig_0200, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::string key = ""; - std::string value = "value"; - ErrCode ret1 = ans_->SetAdditionConfig(key, value); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: CancelAsBundleWithAgent_0100 - * @tc.desc: test CancelAsBundleWithAgent. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, CancelAsBundleWithAgent_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - int32_t id = 1; - NotificationBundleOption bundleOption = NotificationBundleOption(); - ErrCode ret1 = ans_->CancelAsBundleWithAgent(bundleOption, id); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetTargetDeviceStatus_0100 - * @tc.desc: test SetAdditionConfig. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetTargetDeviceStatus_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::string deviceType = "device"; - const uint32_t status = 1; - ErrCode ret1 = ans_->SetTargetDeviceStatus(deviceType, status); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: PublishNotification_0100 - * @tc.desc: test PublishNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, PublishNotification_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::string label = "this is label"; - NotificationRequest request; - std::shared_ptr normalContent = std::make_shared(); - std::shared_ptr content = std::make_shared(normalContent); - request.SetContent(content); - ErrCode ret1 = ans_->PublishNotification(label, request); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - int32_t notificationId = 10; - ErrCode ret3 = ans_->CancelNotification(label, notificationId); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret4 = ans_->CancelAllNotifications(); - EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); - std::string representativeBundle = "this is representativeBundle"; - int32_t userId = 5; - ErrCode ret5 = ans_->CancelAsBundle(notificationId, representativeBundle, userId); - EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetActiveNotificationNums_0100 - * @tc.desc: test GetActiveNotificationNums ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetActiveNotificationNums_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - uint64_t num = 4; - ErrCode ret1 = ans_->GetActiveNotificationNums(num); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - std::vector> request; - ErrCode ret2 = ans_->GetActiveNotifications(request); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); - std::string agent = "this is agent"; - ErrCode ret4 = ans_->SetNotificationAgent(agent); - EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret5 = ans_->GetNotificationAgent(agent); - EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: CanPublishNotificationAsBundle_0100 - * @tc.desc: test CanPublishNotificationAsBundle ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, CanPublishNotificationAsBundle_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::string representativeBundle = "this is representativeBundle"; - bool canPublish = true; - ErrCode ret1 = ans_->CanPublishNotificationAsBundle(representativeBundle, canPublish); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - std::string representativeBundle0 = ""; - ErrCode ret2 = ans_->CanPublishNotificationAsBundle(representativeBundle0, canPublish); - EXPECT_EQ(ret2, ERR_ANS_INVALID_PARAM); - NotificationRequest request; - ErrCode ret3 = ans_->PublishNotificationAsBundle(representativeBundle0, request); - EXPECT_EQ(ret3, ERR_ANS_INVALID_PARAM); - std::shared_ptr normalContent = std::make_shared(); - std::shared_ptr content = std::make_shared(normalContent); - request.SetContent(content); - ErrCode ret5 = ans_->PublishNotificationAsBundle(representativeBundle, request); - EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetNotificationBadgeNum_0100 - * @tc.desc: test SetNotificationBadgeNum ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetNotificationBadgeNum_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - ErrCode ret1 = ans_->SetNotificationBadgeNum(); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - int32_t num = 3; - ErrCode ret2 = ans_->SetNotificationBadgeNum(num); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: IsAllowedNotify_0100 - * @tc.desc: test IsAllowedNotify ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, IsAllowedNotify_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - bool allowed = true; - ErrCode ret1 = ans_->IsAllowedNotify(allowed); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret2 = ans_->IsAllowedNotifySelf(allowed); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - ErrCode ret3 = ans_->IsAllowedNotify(bundleOption, allowed); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: RequestEnableNotification_0100 - * @tc.desc: test RequestEnableNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, RequestEnableNotification_0100, Function | MediumTest | Level1) -{ - ans_->GetAnsManagerProxy(); - std::string deviceId = "this is deviceId"; - sptr callerToken = nullptr; - sptr client = nullptr; - AnsDialogHostClient::CreateIfNullptr(client); - client = AnsDialogHostClient::GetInstance(); - ErrCode ret1 = ans_->RequestEnableNotification(deviceId, client, callerToken); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - bool hasPermission = true; - ErrCode ret3 = ans_->HasNotificationPolicyAccessPermission(hasPermission); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetBundleImportance_0100 - * @tc.desc: test GetBundleImportance ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetBundleImportance_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationSlot::NotificationLevel importance = NotificationSlot::NotificationLevel::LEVEL_NONE; - ErrCode ret1 = ans_->GetBundleImportance(importance); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: RemoveNotification_0100 - * @tc.desc: test RemoveNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, RemoveNotification_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::string key = ""; - int32_t removeReason = 10; - ErrCode ret1 = ans_->RemoveNotification(key, removeReason); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); - std::string key1 = "this is key1"; - ErrCode ret2 = ans_->RemoveNotification(key1, removeReason); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - int32_t notificationId = 2; - std::string label = "this is label"; - ErrCode ret3 = ans_->RemoveNotification(bundleOption, notificationId, label, removeReason); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret4 = ans_->RemoveAllNotifications(bundleOption); - EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret5 = ans_->RemoveNotificationsByBundle(bundleOption); - EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret6 = ans_->RemoveNotifications(); - EXPECT_EQ(ret6, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetNotificationSlotsForBundle_0100 - * @tc.desc: test GetNotificationSlotsForBundle ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotsForBundle_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - sptr slot = new NotificationSlot(); - std::vector> slots; - slots.emplace_back(slot); - ErrCode ret1 = ans_->GetNotificationSlotsForBundle(bundleOption, slots); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret2 = ans_->UpdateNotificationSlots(bundleOption, slots); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetNotificationsEnabledForAllBundles_0100 - * @tc.desc: test SetNotificationsEnabledForAllBundles ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetNotificationsEnabledForAllBundles_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::string deviceId = "this is deviceId"; - bool enabled = true; - ErrCode ret1 = ans_->SetNotificationsEnabledForAllBundles(deviceId, enabled); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret2 = ans_->SetNotificationsEnabledForDefaultBundle(deviceId, enabled); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - ErrCode ret3 = ans_->SetNotificationsEnabledForSpecifiedBundle(bundleOption, deviceId, enabled); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret4 = ans_->SetShowBadgeEnabledForBundle(bundleOption, enabled); - EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret5 = ans_->GetShowBadgeEnabledForBundle(bundleOption, enabled); - EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret6 = ans_->GetShowBadgeEnabled(enabled); - EXPECT_EQ(ret6, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: CancelGroup_0100 - * @tc.desc: test CancelGroup ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, CancelGroup_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::string groupName = "this is groupName"; - ErrCode ret1 = ans_->CancelGroup(groupName); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - ErrCode ret2 = ans_->RemoveGroupByBundle(bundleOption, groupName); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetDoNotDisturbDate_0100 - * @tc.desc: test SetDoNotDisturbDate ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetDoNotDisturbDate_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationDoNotDisturbDate doNotDisturbDate; - ErrCode ret1 = ans_->SetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret2 = ans_->GetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); - bool doesSupport = true; - ErrCode ret3 = ans_->DoesSupportDoNotDisturbMode(doesSupport); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: PublishContinuousTaskNotification_0100 - * @tc.desc: test PublishContinuousTaskNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, PublishContinuousTaskNotification_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationRequest request; - std::shared_ptr normalContent = std::make_shared(); - std::shared_ptr content = std::make_shared(normalContent); - request.SetContent(content); - ErrCode ret1 = ans_->PublishContinuousTaskNotification(request); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - std::string label = "this is label"; - int32_t notificationId = 3; - ErrCode ret2 = ans_->CancelContinuousTaskNotification(label, notificationId); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: IsDistributedEnabled_0100 - * @tc.desc: test IsDistributedEnabled ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, IsDistributedEnabled_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - bool enabled = true; - ErrCode ret1 = ans_->IsDistributedEnabled(enabled); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret2 = ans_->EnableDistributed(enabled); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); - NotificationBundleOption bundleOption; - ErrCode ret3 = ans_->EnableDistributedByBundle(bundleOption, enabled); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret4 = ans_->EnableDistributedSelf(enabled); - EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret5 = ans_->IsDistributedEnableByBundle(bundleOption, enabled); - EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetDeviceRemindType_0100 - * @tc.desc: test GetDeviceRemindType ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetDeviceRemindType_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - - NotificationConstant::RemindType remindType = NotificationConstant::RemindType::NONE; - ErrCode ret1 = ans_->GetDeviceRemindType(remindType); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - ReminderRequest reminder; - ErrCode ret2 = ans_->PublishReminder(reminder); - EXPECT_EQ(ret2, ERR_ANS_INVALID_PARAM); - int32_t reminderId = 1; - ErrCode ret3 = ans_->CancelReminder(reminderId); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret4 = ans_->CancelAllReminders(); - EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); - std::vector> validReminders; - ErrCode ret5 = ans_->GetValidReminders(validReminders); - EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: IsSupportTemplate_0100 - * @tc.desc: test IsSupportTemplate ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, IsSupportTemplate_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::string templateName = "this is templateName"; - bool support = true; - ErrCode ret1 = ans_->IsSupportTemplate(templateName, support); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - int32_t userId = -1; - bool allowed = true; - ErrCode ret2 = ans_->IsAllowedNotify(userId, allowed); - EXPECT_EQ(ret2, ERR_ANS_INVALID_PARAM); - int32_t userId1 = 2; - ErrCode ret3 = ans_->IsAllowedNotify(userId1, allowed); - EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); - bool enabled = true; - ErrCode ret4 = ans_->SetNotificationsEnabledForAllBundles(userId, enabled); - EXPECT_EQ(ret4, ERR_ANS_INVALID_PARAM); - ErrCode ret5 = ans_->SetNotificationsEnabledForAllBundles(userId1, enabled); - EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret6 = ans_->RemoveNotifications(userId); - EXPECT_EQ(ret6, ERR_ANS_INVALID_PARAM); - ErrCode ret7 = ans_->RemoveNotifications(userId1); - EXPECT_EQ(ret7, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetDoNotDisturbDate_0200 - * @tc.desc: test SetDoNotDisturbDate ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetDoNotDisturbDate_0200, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - int32_t userId = -1; - NotificationDoNotDisturbDate doNotDisturbDate; - ErrCode ret1 = ans_->SetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); - int32_t userId1 = 2; - ErrCode ret2 = ans_->SetDoNotDisturbDate(userId1, doNotDisturbDate); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret3 = ans_->GetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ret3, ERR_ANS_INVALID_PARAM); - ErrCode ret4 = ans_->GetDoNotDisturbDate(userId1, doNotDisturbDate); - EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetEnabledForBundleSlot_0100 - * @tc.desc: test SetEnabledForBundleSlot ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetEnabledForBundleSlot_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject_ = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject_); - std::shared_ptr proxy = std::make_shared(iremoteObject_); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - NotificationBundleOption bundleOption; - std::string bundleName = "bundleName"; - bundleOption.SetBundleName(bundleName); - NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOM; - bool enabled = true; - bool isForceControl = false; - ErrCode ret1 = ans_->SetEnabledForBundleSlot(bundleOption, slotType, enabled, isForceControl); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret2 = ans_->GetEnabledForBundleSlot(bundleOption, slotType, enabled); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: ShellDump_0100 - * @tc.desc: test ShellDump ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, ShellDump_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::string cmd = "this is cmd"; - std::string bundle = "this is bundle"; - int32_t userId = 1; - std::vector dumpInfo; - ErrCode ret1 = ans_->ShellDump(cmd, bundle, userId, 0, dumpInfo); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetSyncNotificationEnabledWithoutApp_0100 - * @tc.desc: test SetSyncNotificationEnabledWithoutApp ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetSyncNotificationEnabledWithoutApp_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - int32_t userId = -1; - bool enabled = true; - ErrCode ret1 = ans_->SetSyncNotificationEnabledWithoutApp(userId, enabled); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); - int32_t userId1 = 2; - ErrCode ret2 = ans_->SetSyncNotificationEnabledWithoutApp(userId1, enabled); - EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); - ErrCode ret3 = ans_->GetSyncNotificationEnabledWithoutApp(userId, enabled); - EXPECT_EQ(ret3, ERR_ANS_INVALID_PARAM); - ErrCode ret4 = ans_->GetSyncNotificationEnabledWithoutApp(userId1, enabled); - EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SubscribeNotification_0100 - * @tc.desc: test SubscribeNotification return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SubscribeNotification_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject_ = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject_); - std::shared_ptr proxy = std::make_shared(iremoteObject_); - ASSERT_NE(nullptr, proxy); - bool res = ans_->GetAnsManagerProxy(); - EXPECT_EQ(res, false); - - auto subscriber = TestAnsSubscriber(); - NotificationSubscribeInfo info; - ErrCode ret1 = ans_->SubscribeNotification(subscriber, info); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SubscribeNotification_0200 - * @tc.desc: test SubscribeNotification return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SubscribeNotification_0200, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool res = ans_->GetAnsManagerProxy(); - EXPECT_EQ(res, false); - - auto subscriber = TestAnsSubscriber(); - ErrCode ret1 = ans_->SubscribeNotification(subscriber); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetAllActiveNotifications_0100 - * @tc.desc: test GetAllActiveNotifications return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetAllActiveNotifications_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool res = ans_->GetAnsManagerProxy(); - EXPECT_EQ(res, false); - - std::vector> notification; - ErrCode ret1 = ans_->GetAllActiveNotifications(notification); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: GetAllActiveNotifications_0200 - * @tc.desc: test GetAllActiveNotifications return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, GetAllActiveNotifications_0200, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool res = ans_->GetAnsManagerProxy(); - EXPECT_EQ(res, false); - - std::vector key; - std::vector> notification; - ErrCode ret1 = ans_->GetAllActiveNotifications(key, notification); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: UnSubscribeNotification_0100 - * @tc.desc: test UnSubscribeNotification return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, UnSubscribeNotification_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool res = ans_->GetAnsManagerProxy(); - EXPECT_EQ(res, false); - - auto subscriber = TestAnsSubscriber(); - ErrCode ret1 = ans_->UnSubscribeNotification(subscriber); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: UnSubscribeNotification_0200 - * @tc.desc: test UnSubscribeNotification return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, UnSubscribeNotification_0200, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool res = ans_->GetAnsManagerProxy(); - EXPECT_EQ(res, false); - - auto subscriber = TestAnsSubscriber(); - NotificationSubscribeInfo info; - ErrCode ret1 = ans_->UnSubscribeNotification(subscriber, info); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetNotificationsEnabledForSpecifiedBundle_0100 - * @tc.desc: test SetNotificationsEnabledForSpecifiedBundle ErrCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SetNotificationsEnabledForSpecifiedBundle_0100, Function | MediumTest | Level1) -{ - std::string deviceId = "this is deviceId"; - bool enabled = true; - NotificationBundleOption bundleOption; - std::string bundleName = ""; - bundleOption.SetBundleName(bundleName); - ErrCode ret3 = ans_->SetNotificationsEnabledForSpecifiedBundle(bundleOption, deviceId, enabled); - EXPECT_EQ(ret3, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: GetAllNotificationEnabledBundles_0100 - * @tc.desc: test GetAllNotificationEnabledBundles ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I92VGR - */ -HWTEST_F(AnsNotificationUnitTest, GetAllNotificationEnabledBundles_0100, Function | MediumTest | Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObjects); - std::shared_ptr proxy = std::make_shared(iremoteObjects); - ASSERT_NE(nullptr, proxy); - ans_->GetAnsManagerProxy(); - std::vector bundleOption; - ErrCode ret = ans_->GetAllNotificationEnabledBundles(bundleOption); - EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: CancelGroup_0200 - * @tc.desc: test CancelGroup ErrCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, CancelGroup_0200, Function | MediumTest | Level1) -{ - std::string groupName = ""; - ErrCode ret1 = ans_->CancelGroup(groupName); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: SetSmartReminderEnabled_0100 - * @tc.desc: test SetSmartReminderEnabled with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, SetSmartReminderEnabled_0100, TestSize.Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool ret = ans_->GetAnsManagerProxy(); - EXPECT_EQ(ret, false); - ErrCode res = ans_->SetSmartReminderEnabled("testDeviceType", true); - EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/** - * @tc.name: IsSmartReminderEnabled_0100 - * @tc.desc: test IsSmartReminderEnabled with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, IsSmartReminderEnabled_0100, TestSize.Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool ret = ans_->GetAnsManagerProxy(); - EXPECT_EQ(ret, false); - bool enable = true; - ErrCode result = ans_->IsSmartReminderEnabled("testDeviceType1111", enable); - EXPECT_EQ(result, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetBadgeNumberByBundle_0100 - * @tc.desc: test SetBadgeNumberByBundle with empty bundleOption, expect ErrCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, SetBadgeNumberByBundle_0100, TestSize.Level1) -{ - NotificationBundleOption bundleOption; - int32_t badgeNumber = 0; - ErrCode res = ans_->SetBadgeNumberByBundle(bundleOption, badgeNumber); - EXPECT_EQ(res, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: SetBadgeNumberByBundle_0200 - * @tc.desc: test SetBadgeNumberByBundle with invalid AnsManagerProxy, expect ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, SetBadgeNumberByBundle_0200, TestSize.Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool ret = ans_->GetAnsManagerProxy(); - EXPECT_EQ(ret, false); - - NotificationBundleOption bundleOption; - std::string bundleName = "bundleName"; - bundleOption.SetBundleName(bundleName); - int32_t badgeNumber = 0; - ErrCode res = ans_->SetBadgeNumberByBundle(bundleOption, badgeNumber); - EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SetDistributedEnabledByBundle_0100 - * @tc.desc: test SetDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, SetDistributedEnabledByBundle_0100, TestSize.Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool ret = ans_->GetAnsManagerProxy(); - EXPECT_EQ(ret, false); - - NotificationBundleOption bundleOption; - std::string bundleName = "bundleName"; - bundleOption.SetBundleName(bundleName); - bundleOption.SetUid(1); - std::string deviceType = "testDeviceType"; - - ErrCode res = ans_->SetDistributedEnabledByBundle(bundleOption, deviceType, true); - EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/** - * @tc.name: SetDistributedEnabledByBundle_0200 - * @tc.desc: test SetDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, SetDistributedEnabledByBundle_0200, TestSize.Level1) -{ - NotificationBundleOption bundleOption; - std::string deviceType = "testDeviceType"; - ErrCode ret = ans_->SetDistributedEnabledByBundle(bundleOption, deviceType, true); - EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.name: SetDistributedEnabledByBundle_0300 - * @tc.desc: test SetDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, SetDistributedEnabledByBundle_0300, TestSize.Level1) -{ - NotificationBundleOption bundleOption; - bundleOption.SetBundleName(""); - bundleOption.SetUid(1); - std::string deviceType = "testDeviceType"; - ErrCode ret = ans_->SetDistributedEnabledByBundle(bundleOption, deviceType, true); - EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); -} - - -/** - * @tc.name: IsDistributedEnabledByBundle_0100 - * @tc.desc: test IsDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, IsDistributedEnabledByBundle_0100, TestSize.Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool ret = ans_->GetAnsManagerProxy(); - EXPECT_EQ(ret, false); - - NotificationBundleOption bundleOption; - std::string bundleName = "bundleName"; - bundleOption.SetBundleName(bundleName); - bundleOption.SetUid(1); - std::string deviceType = "testDeviceType1111"; - bool enable = true; - ErrCode result = ans_->IsDistributedEnabledByBundle(bundleOption, deviceType, enable); - EXPECT_EQ(result, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/** - * @tc.name: IsDistributedEnabledByBundle_0200 - * @tc.desc: test IsDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, IsDistributedEnabledByBundle_0200, TestSize.Level1) -{ - MockWriteInterfaceToken(true); - NotificationBundleOption bundleOption; - std::string deviceType = "testDeviceType"; - - bool enable = true; - ErrCode ret = ans_->IsDistributedEnabledByBundle(bundleOption, deviceType, enable); - EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.name: IsDistributedEnabledByBundle_0300 - * @tc.desc: test IsDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, IsDistributedEnabledByBundle_0300, TestSize.Level1) -{ - MockWriteInterfaceToken(true); - NotificationBundleOption bundleOption; - bundleOption.SetBundleName(""); - bundleOption.SetUid(1); - std::string deviceType = "testDeviceType"; - - bool enable = true; - ErrCode ret = ans_->IsDistributedEnabledByBundle(bundleOption, deviceType, enable); - EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: AddDoNotDisturbProfiles_0100 - * @tc.desc: test AddDoNotDisturbProfiles ErrCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, AddDoNotDisturbProfiles_0100, TestSize.Level1) -{ - std::vector> profiles; - profiles.clear(); - ErrCode ret1 = ans_->AddDoNotDisturbProfiles(profiles); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: AddDoNotDisturbProfiles_0200 - * @tc.desc: test AddDoNotDisturbProfiles ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, AddDoNotDisturbProfiles_0200, TestSize.Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool res = ans_->GetAnsManagerProxy(); - EXPECT_EQ(res, false); - - int32_t id = 1; - std::string name = "Name"; - std::vector trustlist; - std::vector> profiles; - sptr disturbProfile = - new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); - profiles.emplace_back(disturbProfile); - - ErrCode ret1 = ans_->AddDoNotDisturbProfiles(profiles); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: RemoveDoNotDisturbProfiles_0100 - * @tc.desc: test RemoveDoNotDisturbProfiles ErrCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, RemoveDoNotDisturbProfiles_0100, TestSize.Level1) -{ - vector> profiles; - profiles.clear(); - ErrCode ret1 = ans_->RemoveDoNotDisturbProfiles(profiles); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: RemoveDoNotDisturbProfiles_0200 - * @tc.desc: test RemoveDoNotDisturbProfiles ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, RemoveDoNotDisturbProfiles_0200, TestSize.Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool res = ans_->GetAnsManagerProxy(); - EXPECT_EQ(res, false); - - int32_t id = 1; - std::string name = "Name"; - std::vector trustlist; - std::vector> profiles; - sptr disturbProfile = - new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); - profiles.emplace_back(disturbProfile); - - ErrCode ret1 = ans_->RemoveDoNotDisturbProfiles(profiles); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED -/* - * @tc.name: RegisterSwingCallback_0100 - * @tc.desc: test RegisterSwingCallback with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, RegisterSwingCallback_0100, TestSize.Level1) -{ - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool ret = ans_->GetAnsManagerProxy(); - EXPECT_EQ(ret, false); - std::function swingCbFunc = - std::bind(&AnsNotificationUnitTest::UpdateStatuts, this, std::placeholders::_1, std::placeholders::_2); - ErrCode res = ans_->RegisterSwingCallback(swingCbFunc); - EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); -} -#endif -} // namespace Notification -} // namespace OHOS +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ans_dialog_callback_stub.h" +#include "errors.h" +#include "notification_slot.h" +#include +#include + +#define private public +#define protected public +#include "ans_notification.h" +#include "ans_subscriber_proxy.h" +#include "ans_manager_proxy.h" +#undef private +#undef protected +#include "ans_inner_errors.h" +#include "ipc_types.h" +#include "mock_i_remote_object.h" +#include "notification.h" +#include "singleton.h" +#include "notification_subscriber.h" + +using namespace testing; +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::Notification; + +extern void MockWriteInterfaceToken(bool mockRet); + +namespace OHOS { +namespace Notification { +class AnsNotificationUnitTest : public testing::Test { +public: + AnsNotificationUnitTest() {} + + virtual ~AnsNotificationUnitTest() {} + + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp(); + + void TearDown(); + std::shared_ptr ans_; + sptr ansManagerProxy_{nullptr}; +#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED + void UpdateStatuts(bool isEnable, int status) {} +#endif +}; + +void AnsNotificationUnitTest::SetUpTestCase() +{ + MockWriteInterfaceToken(true); +} + +void AnsNotificationUnitTest::TearDownTestCase() {} + +void AnsNotificationUnitTest::SetUp() +{ + if (!ans_) { + ans_ = DelayedSingleton::GetInstance(); + } +} + +void AnsNotificationUnitTest::TearDown() {} + +class TestAnsSubscriber : public NotificationSubscriber { +public: + void OnConnected() override + {} + void OnDisconnected() override + {} + void OnUpdate(const std::shared_ptr &sortingMap) override + {} + void OnDied() override + {} + void OnEnabledNotificationChanged( + const std::shared_ptr &callbackData) override + {} + void OnDoNotDisturbDateChange(const std::shared_ptr &date) override + {} + void OnCanceled(const std::shared_ptr &request, + const std::shared_ptr &sortingMap, int deleteReason) override + {} + void OnConsumed(const std::shared_ptr &request, + const std::shared_ptr &sortingMap) override + {} + void OnBadgeChanged(const std::shared_ptr &badgeData) override + {} + void OnBadgeEnabledChanged(const sptr &callbackData) override + {} + void OnBatchCanceled(const std::vector> + &requestList, const std::shared_ptr &sortingMap, int32_t deleteReason) override + {} +}; + +/* + * @tc.name: GetAnsManagerProxy_0100 + * @tc.desc: test GetAnsManagerProxy return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetAnsManagerProxy_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool res = ans_->GetAnsManagerProxy(); + EXPECT_EQ(res, false); +} + +/* + * @tc.name: AddSlotByType_0100 + * @tc.desc: test AddSlotByType ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, AddSlotByType_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOM; + ErrCode ret1 = ans_->AddSlotByType(slotType); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret3 = ans_->RemoveNotificationSlot(slotType); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: RemoveAllSlots_0100 + * @tc.desc: test RemoveAllSlots ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, RemoveAllSlots_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + ErrCode ret1 = ans_->RemoveAllSlots(); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetNotificationSlot_0100 + * @tc.desc: test GetNotificationSlot ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetNotificationSlot_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOM; + sptr slot = new NotificationSlot(); + ErrCode ret1 = ans_->GetNotificationSlot(slotType, slot); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + std::vector> slots; + slots.emplace_back(slot); + ErrCode ret2 = ans_->GetNotificationSlots(slots); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); + std::vector nslots; + NotificationSlot notificationSlot; + nslots.emplace_back(notificationSlot); + ErrCode ret3 = ans_->AddNotificationSlots(nslots); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetNotificationSlotNumAsBundle_0100 + * @tc.desc: test GetNotificationSlotNumAsBundle ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotNumAsBundle_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationBundleOption bundleOptions; + std::string bundleName = "bundleName"; + bundleOptions.SetBundleName(bundleName); + uint64_t num = 10; + ErrCode ret1 = ans_->GetNotificationSlotNumAsBundle(bundleOptions, num); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetNotificationSlotFlagsAsBundle_0100 + * @tc.desc: test GetNotificationSlotFlagsAsBundle. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotFlagsAsBundle_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationBundleOption bundleOptions; + std::string bundleName = "bundleName"; + bundleOptions.SetBundleName(bundleName); + uint32_t num = 10; + ErrCode ret1 = ans_->GetNotificationSlotFlagsAsBundle(bundleOptions, num); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetNotificationSlotFlagsAsBundle_0200 + * @tc.desc: test GetNotificationSlotFlagsAsBundle. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotFlagsAsBundle_0200, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationBundleOption bundleOptions; + bundleOptions.SetBundleName(""); + uint32_t num = 10; + ErrCode ret1 = ans_->GetNotificationSlotFlagsAsBundle(bundleOptions, num); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: SetNotificationSlotFlagsAsBundle_0200 + * @tc.desc: test GetNotificationSlotFlagsAsBundle. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetNotificationSlotFlagsAsBundle_0200, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationBundleOption bundleOptions; + bundleOptions.SetBundleName(""); + uint64_t num = 10; + ErrCode ret1 = ans_->SetNotificationSlotFlagsAsBundle(bundleOptions, num); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: CanPopEnableNotificationDialog_0100 + * @tc.desc: test CanPopEnableNotificationDialog. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, CanPopEnableNotificationDialog_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + sptr client = nullptr; + bool enable = true; + std::string bundleName = ""; + ErrCode ret1 = ans_->CanPopEnableNotificationDialog(client, enable, bundleName); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: RemoveNotifications_0100 + * @tc.desc: test RemoveNotifications. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, RemoveNotifications_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::vector hashCodes = {"data1", "data2"}; + ErrCode ret1 = ans_->RemoveNotifications(hashCodes, 1); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetNotificationSlotForBundle_0100 + * @tc.desc: test GetNotificationSlotForBundle. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotForBundle_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationBundleOption bundleOptions; + bundleOptions.SetBundleName("name"); + sptr slot = new NotificationSlot(); + ErrCode ret1 = ans_->GetNotificationSlotForBundle(bundleOptions, + NotificationConstant::SlotType::CONTENT_INFORMATION, slot); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetNotificationSlotForBundle_0200 + * @tc.desc: test GetNotificationSlotForBundle. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotForBundle_0200, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationBundleOption bundleOptions; + bundleOptions.SetBundleName(""); + sptr slot = new NotificationSlot(); + ErrCode ret1 = ans_->GetNotificationSlotForBundle(bundleOptions, + NotificationConstant::SlotType::CONTENT_INFORMATION, slot); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: GetEnabledForBundleSlotSelf_0100 + * @tc.desc: test GetEnabledForBundleSlotSelf. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetEnabledForBundleSlotSelf_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + bool enable = true; + ErrCode ret1 = ans_->GetEnabledForBundleSlotSelf( + NotificationConstant::SlotType::CONTENT_INFORMATION, enable); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: RegisterPushCallback_0100 + * @tc.desc: test RegisterPushCallback. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, RegisterPushCallback_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + sptr callback = new AnsDialogHostClient(); + sptr checkRequest = nullptr; + ErrCode ret1 = ans_->RegisterPushCallback(callback->AsObject(), checkRequest); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: UnregisterPushCallback_0100 + * @tc.desc: test UnregisterPushCallback. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, UnregisterPushCallback_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + ErrCode ret1 = ans_->UnregisterPushCallback(); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetAdditionConfig_0100 + * @tc.desc: test SetAdditionConfig. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetAdditionConfig_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string key = "key"; + std::string value = "value"; + ErrCode ret1 = ans_->SetAdditionConfig(key, value); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetAdditionConfig_0200 + * @tc.desc: test SetAdditionConfig. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetAdditionConfig_0200, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string key = ""; + std::string value = "value"; + ErrCode ret1 = ans_->SetAdditionConfig(key, value); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: CancelAsBundleWithAgent_0100 + * @tc.desc: test CancelAsBundleWithAgent. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, CancelAsBundleWithAgent_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + int32_t id = 1; + NotificationBundleOption bundleOption = NotificationBundleOption(); + ErrCode ret1 = ans_->CancelAsBundleWithAgent(bundleOption, id); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetTargetDeviceStatus_0100 + * @tc.desc: test SetAdditionConfig. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetTargetDeviceStatus_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string deviceType = "device"; + const uint32_t status = 1; + ErrCode ret1 = ans_->SetTargetDeviceStatus(deviceType, status); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: PublishNotification_0100 + * @tc.desc: test PublishNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, PublishNotification_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string label = "this is label"; + NotificationRequest request; + std::shared_ptr normalContent = std::make_shared(); + std::shared_ptr content = std::make_shared(normalContent); + request.SetContent(content); + ErrCode ret1 = ans_->PublishNotification(label, request); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + int32_t notificationId = 10; + ErrCode ret3 = ans_->CancelNotification(label, notificationId); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret4 = ans_->CancelAllNotifications(); + EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); + std::string representativeBundle = "this is representativeBundle"; + int32_t userId = 5; + ErrCode ret5 = ans_->CancelAsBundle(notificationId, representativeBundle, userId); + EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetActiveNotificationNums_0100 + * @tc.desc: test GetActiveNotificationNums ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetActiveNotificationNums_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + uint64_t num = 4; + ErrCode ret1 = ans_->GetActiveNotificationNums(num); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + std::vector> request; + ErrCode ret2 = ans_->GetActiveNotifications(request); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); + std::string agent = "this is agent"; + ErrCode ret4 = ans_->SetNotificationAgent(agent); + EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret5 = ans_->GetNotificationAgent(agent); + EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: CanPublishNotificationAsBundle_0100 + * @tc.desc: test CanPublishNotificationAsBundle ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, CanPublishNotificationAsBundle_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string representativeBundle = "this is representativeBundle"; + bool canPublish = true; + ErrCode ret1 = ans_->CanPublishNotificationAsBundle(representativeBundle, canPublish); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + std::string representativeBundle0 = ""; + ErrCode ret2 = ans_->CanPublishNotificationAsBundle(representativeBundle0, canPublish); + EXPECT_EQ(ret2, ERR_ANS_INVALID_PARAM); + NotificationRequest request; + ErrCode ret3 = ans_->PublishNotificationAsBundle(representativeBundle0, request); + EXPECT_EQ(ret3, ERR_ANS_INVALID_PARAM); + std::shared_ptr normalContent = std::make_shared(); + std::shared_ptr content = std::make_shared(normalContent); + request.SetContent(content); + ErrCode ret5 = ans_->PublishNotificationAsBundle(representativeBundle, request); + EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetNotificationBadgeNum_0100 + * @tc.desc: test SetNotificationBadgeNum ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetNotificationBadgeNum_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + ErrCode ret1 = ans_->SetNotificationBadgeNum(); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + int32_t num = 3; + ErrCode ret2 = ans_->SetNotificationBadgeNum(num); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: IsAllowedNotify_0100 + * @tc.desc: test IsAllowedNotify ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, IsAllowedNotify_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + bool allowed = true; + ErrCode ret1 = ans_->IsAllowedNotify(allowed); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret2 = ans_->IsAllowedNotifySelf(allowed); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + ErrCode ret3 = ans_->IsAllowedNotify(bundleOption, allowed); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: RequestEnableNotification_0100 + * @tc.desc: test RequestEnableNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, RequestEnableNotification_0100, Function | MediumTest | Level1) +{ + ans_->GetAnsManagerProxy(); + std::string deviceId = "this is deviceId"; + sptr callerToken = nullptr; + sptr client = nullptr; + AnsDialogHostClient::CreateIfNullptr(client); + client = AnsDialogHostClient::GetInstance(); + ErrCode ret1 = ans_->RequestEnableNotification(deviceId, client, callerToken); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + bool hasPermission = true; + ErrCode ret3 = ans_->HasNotificationPolicyAccessPermission(hasPermission); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetBundleImportance_0100 + * @tc.desc: test GetBundleImportance ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetBundleImportance_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationSlot::NotificationLevel importance = NotificationSlot::NotificationLevel::LEVEL_NONE; + ErrCode ret1 = ans_->GetBundleImportance(importance); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: RemoveNotification_0100 + * @tc.desc: test RemoveNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, RemoveNotification_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string key = ""; + int32_t removeReason = 10; + ErrCode ret1 = ans_->RemoveNotification(key, removeReason); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); + std::string key1 = "this is key1"; + ErrCode ret2 = ans_->RemoveNotification(key1, removeReason); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + int32_t notificationId = 2; + std::string label = "this is label"; + ErrCode ret3 = ans_->RemoveNotification(bundleOption, notificationId, label, removeReason); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret4 = ans_->RemoveAllNotifications(bundleOption); + EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret5 = ans_->RemoveNotificationsByBundle(bundleOption); + EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret6 = ans_->RemoveNotifications(); + EXPECT_EQ(ret6, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetNotificationSlotsForBundle_0100 + * @tc.desc: test GetNotificationSlotsForBundle ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetNotificationSlotsForBundle_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + sptr slot = new NotificationSlot(); + std::vector> slots; + slots.emplace_back(slot); + ErrCode ret1 = ans_->GetNotificationSlotsForBundle(bundleOption, slots); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret2 = ans_->UpdateNotificationSlots(bundleOption, slots); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetNotificationsEnabledForAllBundles_0100 + * @tc.desc: test SetNotificationsEnabledForAllBundles ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetNotificationsEnabledForAllBundles_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string deviceId = "this is deviceId"; + bool enabled = true; + ErrCode ret1 = ans_->SetNotificationsEnabledForAllBundles(deviceId, enabled); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret2 = ans_->SetNotificationsEnabledForDefaultBundle(deviceId, enabled); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + ErrCode ret3 = ans_->SetNotificationsEnabledForSpecifiedBundle(bundleOption, deviceId, enabled); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret4 = ans_->SetShowBadgeEnabledForBundle(bundleOption, enabled); + EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret5 = ans_->GetShowBadgeEnabledForBundle(bundleOption, enabled); + EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret6 = ans_->GetShowBadgeEnabled(enabled); + EXPECT_EQ(ret6, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: CancelGroup_0100 + * @tc.desc: test CancelGroup ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, CancelGroup_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string groupName = "this is groupName"; + ErrCode ret1 = ans_->CancelGroup(groupName); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + ErrCode ret2 = ans_->RemoveGroupByBundle(bundleOption, groupName); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetDoNotDisturbDate_0100 + * @tc.desc: test SetDoNotDisturbDate ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetDoNotDisturbDate_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationDoNotDisturbDate doNotDisturbDate; + ErrCode ret1 = ans_->SetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret2 = ans_->GetDoNotDisturbDate(doNotDisturbDate); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); + bool doesSupport = true; + ErrCode ret3 = ans_->DoesSupportDoNotDisturbMode(doesSupport); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: PublishContinuousTaskNotification_0100 + * @tc.desc: test PublishContinuousTaskNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, PublishContinuousTaskNotification_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationRequest request; + std::shared_ptr normalContent = std::make_shared(); + std::shared_ptr content = std::make_shared(normalContent); + request.SetContent(content); + ErrCode ret1 = ans_->PublishContinuousTaskNotification(request); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + std::string label = "this is label"; + int32_t notificationId = 3; + ErrCode ret2 = ans_->CancelContinuousTaskNotification(label, notificationId); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: IsDistributedEnabled_0100 + * @tc.desc: test IsDistributedEnabled ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, IsDistributedEnabled_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + bool enabled = true; + ErrCode ret1 = ans_->IsDistributedEnabled(enabled); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret2 = ans_->EnableDistributed(enabled); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); + NotificationBundleOption bundleOption; + ErrCode ret3 = ans_->EnableDistributedByBundle(bundleOption, enabled); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret4 = ans_->EnableDistributedSelf(enabled); + EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret5 = ans_->IsDistributedEnableByBundle(bundleOption, enabled); + EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetDeviceRemindType_0100 + * @tc.desc: test GetDeviceRemindType ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetDeviceRemindType_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + + NotificationConstant::RemindType remindType = NotificationConstant::RemindType::NONE; + ErrCode ret1 = ans_->GetDeviceRemindType(remindType); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + ReminderRequest reminder; + ErrCode ret2 = ans_->PublishReminder(reminder); + EXPECT_EQ(ret2, ERR_ANS_INVALID_PARAM); + int32_t reminderId = 1; + ErrCode ret3 = ans_->CancelReminder(reminderId); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret4 = ans_->CancelAllReminders(); + EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); + std::vector> validReminders; + ErrCode ret5 = ans_->GetValidReminders(validReminders); + EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: IsSupportTemplate_0100 + * @tc.desc: test IsSupportTemplate ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, IsSupportTemplate_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string templateName = "this is templateName"; + bool support = true; + ErrCode ret1 = ans_->IsSupportTemplate(templateName, support); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + int32_t userId = -1; + bool allowed = true; + ErrCode ret2 = ans_->IsAllowedNotify(userId, allowed); + EXPECT_EQ(ret2, ERR_ANS_INVALID_PARAM); + int32_t userId1 = 2; + ErrCode ret3 = ans_->IsAllowedNotify(userId1, allowed); + EXPECT_EQ(ret3, ERR_ANS_SERVICE_NOT_CONNECTED); + bool enabled = true; + ErrCode ret4 = ans_->SetNotificationsEnabledForAllBundles(userId, enabled); + EXPECT_EQ(ret4, ERR_ANS_INVALID_PARAM); + ErrCode ret5 = ans_->SetNotificationsEnabledForAllBundles(userId1, enabled); + EXPECT_EQ(ret5, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret6 = ans_->RemoveNotifications(userId); + EXPECT_EQ(ret6, ERR_ANS_INVALID_PARAM); + ErrCode ret7 = ans_->RemoveNotifications(userId1); + EXPECT_EQ(ret7, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetDoNotDisturbDate_0200 + * @tc.desc: test SetDoNotDisturbDate ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetDoNotDisturbDate_0200, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + int32_t userId = -1; + NotificationDoNotDisturbDate doNotDisturbDate; + ErrCode ret1 = ans_->SetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); + int32_t userId1 = 2; + ErrCode ret2 = ans_->SetDoNotDisturbDate(userId1, doNotDisturbDate); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret3 = ans_->GetDoNotDisturbDate(userId, doNotDisturbDate); + EXPECT_EQ(ret3, ERR_ANS_INVALID_PARAM); + ErrCode ret4 = ans_->GetDoNotDisturbDate(userId1, doNotDisturbDate); + EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetEnabledForBundleSlot_0100 + * @tc.desc: test SetEnabledForBundleSlot ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetEnabledForBundleSlot_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject_ = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject_); + std::shared_ptr proxy = std::make_shared(iremoteObject_); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + NotificationBundleOption bundleOption; + std::string bundleName = "bundleName"; + bundleOption.SetBundleName(bundleName); + NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CUSTOM; + bool enabled = true; + bool isForceControl = false; + ErrCode ret1 = ans_->SetEnabledForBundleSlot(bundleOption, slotType, enabled, isForceControl); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret2 = ans_->GetEnabledForBundleSlot(bundleOption, slotType, enabled); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: ShellDump_0100 + * @tc.desc: test ShellDump ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, ShellDump_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string cmd = "this is cmd"; + std::string bundle = "this is bundle"; + int32_t userId = 1; + std::vector dumpInfo; + ErrCode ret1 = ans_->ShellDump(cmd, bundle, userId, 0, dumpInfo); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetSyncNotificationEnabledWithoutApp_0100 + * @tc.desc: test SetSyncNotificationEnabledWithoutApp ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetSyncNotificationEnabledWithoutApp_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + int32_t userId = -1; + bool enabled = true; + ErrCode ret1 = ans_->SetSyncNotificationEnabledWithoutApp(userId, enabled); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); + int32_t userId1 = 2; + ErrCode ret2 = ans_->SetSyncNotificationEnabledWithoutApp(userId1, enabled); + EXPECT_EQ(ret2, ERR_ANS_SERVICE_NOT_CONNECTED); + ErrCode ret3 = ans_->GetSyncNotificationEnabledWithoutApp(userId, enabled); + EXPECT_EQ(ret3, ERR_ANS_INVALID_PARAM); + ErrCode ret4 = ans_->GetSyncNotificationEnabledWithoutApp(userId1, enabled); + EXPECT_EQ(ret4, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SubscribeNotification_0100 + * @tc.desc: test SubscribeNotification return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SubscribeNotification_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject_ = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject_); + std::shared_ptr proxy = std::make_shared(iremoteObject_); + ASSERT_NE(nullptr, proxy); + bool res = ans_->GetAnsManagerProxy(); + EXPECT_EQ(res, false); + + auto subscriber = TestAnsSubscriber(); + NotificationSubscribeInfo info; + ErrCode ret1 = ans_->SubscribeNotification(subscriber, info); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SubscribeNotification_0200 + * @tc.desc: test SubscribeNotification return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SubscribeNotification_0200, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool res = ans_->GetAnsManagerProxy(); + EXPECT_EQ(res, false); + + auto subscriber = TestAnsSubscriber(); + ErrCode ret1 = ans_->SubscribeNotification(subscriber); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetAllActiveNotifications_0100 + * @tc.desc: test GetAllActiveNotifications return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetAllActiveNotifications_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool res = ans_->GetAnsManagerProxy(); + EXPECT_EQ(res, false); + + std::vector> notification; + ErrCode ret1 = ans_->GetAllActiveNotifications(notification); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: GetAllActiveNotifications_0200 + * @tc.desc: test GetAllActiveNotifications return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, GetAllActiveNotifications_0200, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool res = ans_->GetAnsManagerProxy(); + EXPECT_EQ(res, false); + + std::vector key; + std::vector> notification; + ErrCode ret1 = ans_->GetAllActiveNotifications(key, notification); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: UnSubscribeNotification_0100 + * @tc.desc: test UnSubscribeNotification return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, UnSubscribeNotification_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool res = ans_->GetAnsManagerProxy(); + EXPECT_EQ(res, false); + + auto subscriber = TestAnsSubscriber(); + ErrCode ret1 = ans_->UnSubscribeNotification(subscriber); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: UnSubscribeNotification_0200 + * @tc.desc: test UnSubscribeNotification return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, UnSubscribeNotification_0200, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool res = ans_->GetAnsManagerProxy(); + EXPECT_EQ(res, false); + + auto subscriber = TestAnsSubscriber(); + NotificationSubscribeInfo info; + ErrCode ret1 = ans_->UnSubscribeNotification(subscriber, info); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetNotificationsEnabledForSpecifiedBundle_0100 + * @tc.desc: test SetNotificationsEnabledForSpecifiedBundle ErrCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SetNotificationsEnabledForSpecifiedBundle_0100, Function | MediumTest | Level1) +{ + std::string deviceId = "this is deviceId"; + bool enabled = true; + NotificationBundleOption bundleOption; + std::string bundleName = ""; + bundleOption.SetBundleName(bundleName); + ErrCode ret3 = ans_->SetNotificationsEnabledForSpecifiedBundle(bundleOption, deviceId, enabled); + EXPECT_EQ(ret3, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: GetAllNotificationEnabledBundles_0100 + * @tc.desc: test GetAllNotificationEnabledBundles ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I92VGR + */ +HWTEST_F(AnsNotificationUnitTest, GetAllNotificationEnabledBundles_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::vector bundleOption; + ErrCode ret = ans_->GetAllNotificationEnabledBundles(bundleOption); + EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: CancelGroup_0200 + * @tc.desc: test CancelGroup ErrCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, CancelGroup_0200, Function | MediumTest | Level1) +{ + std::string groupName = ""; + ErrCode ret1 = ans_->CancelGroup(groupName); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: SetSmartReminderEnabled_0100 + * @tc.desc: test SetSmartReminderEnabled with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, SetSmartReminderEnabled_0100, TestSize.Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool ret = ans_->GetAnsManagerProxy(); + EXPECT_EQ(ret, false); + ErrCode res = ans_->SetSmartReminderEnabled("testDeviceType", true); + EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/** + * @tc.name: IsSmartReminderEnabled_0100 + * @tc.desc: test IsSmartReminderEnabled with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, IsSmartReminderEnabled_0100, TestSize.Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool ret = ans_->GetAnsManagerProxy(); + EXPECT_EQ(ret, false); + bool enable = true; + ErrCode result = ans_->IsSmartReminderEnabled("testDeviceType1111", enable); + EXPECT_EQ(result, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetBadgeNumberByBundle_0100 + * @tc.desc: test SetBadgeNumberByBundle with empty bundleOption, expect ErrCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, SetBadgeNumberByBundle_0100, TestSize.Level1) +{ + NotificationBundleOption bundleOption; + int32_t badgeNumber = 0; + ErrCode res = ans_->SetBadgeNumberByBundle(bundleOption, badgeNumber); + EXPECT_EQ(res, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: SetBadgeNumberByBundle_0200 + * @tc.desc: test SetBadgeNumberByBundle with invalid AnsManagerProxy, expect ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, SetBadgeNumberByBundle_0200, TestSize.Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool ret = ans_->GetAnsManagerProxy(); + EXPECT_EQ(ret, false); + + NotificationBundleOption bundleOption; + std::string bundleName = "bundleName"; + bundleOption.SetBundleName(bundleName); + int32_t badgeNumber = 0; + ErrCode res = ans_->SetBadgeNumberByBundle(bundleOption, badgeNumber); + EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetDistributedEnabledByBundle_0100 + * @tc.desc: test SetDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, SetDistributedEnabledByBundle_0100, TestSize.Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool ret = ans_->GetAnsManagerProxy(); + EXPECT_EQ(ret, false); + + NotificationBundleOption bundleOption; + std::string bundleName = "bundleName"; + bundleOption.SetBundleName(bundleName); + bundleOption.SetUid(1); + std::string deviceType = "testDeviceType"; + + ErrCode res = ans_->SetDistributedEnabledByBundle(bundleOption, deviceType, true); + EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/** + * @tc.name: SetDistributedEnabledByBundle_0200 + * @tc.desc: test SetDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, SetDistributedEnabledByBundle_0200, TestSize.Level1) +{ + NotificationBundleOption bundleOption; + std::string deviceType = "testDeviceType"; + ErrCode ret = ans_->SetDistributedEnabledByBundle(bundleOption, deviceType, true); + EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.name: SetDistributedEnabledByBundle_0300 + * @tc.desc: test SetDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, SetDistributedEnabledByBundle_0300, TestSize.Level1) +{ + NotificationBundleOption bundleOption; + bundleOption.SetBundleName(""); + bundleOption.SetUid(1); + std::string deviceType = "testDeviceType"; + ErrCode ret = ans_->SetDistributedEnabledByBundle(bundleOption, deviceType, true); + EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); +} + + +/** + * @tc.name: IsDistributedEnabledByBundle_0100 + * @tc.desc: test IsDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, IsDistributedEnabledByBundle_0100, TestSize.Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool ret = ans_->GetAnsManagerProxy(); + EXPECT_EQ(ret, false); + + NotificationBundleOption bundleOption; + std::string bundleName = "bundleName"; + bundleOption.SetBundleName(bundleName); + bundleOption.SetUid(1); + std::string deviceType = "testDeviceType1111"; + bool enable = true; + ErrCode result = ans_->IsDistributedEnabledByBundle(bundleOption, deviceType, enable); + EXPECT_EQ(result, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/** + * @tc.name: IsDistributedEnabledByBundle_0200 + * @tc.desc: test IsDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, IsDistributedEnabledByBundle_0200, TestSize.Level1) +{ + MockWriteInterfaceToken(true); + NotificationBundleOption bundleOption; + std::string deviceType = "testDeviceType"; + + bool enable = true; + ErrCode ret = ans_->IsDistributedEnabledByBundle(bundleOption, deviceType, enable); + EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.name: IsDistributedEnabledByBundle_0300 + * @tc.desc: test IsDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, IsDistributedEnabledByBundle_0300, TestSize.Level1) +{ + MockWriteInterfaceToken(true); + NotificationBundleOption bundleOption; + bundleOption.SetBundleName(""); + bundleOption.SetUid(1); + std::string deviceType = "testDeviceType"; + + bool enable = true; + ErrCode ret = ans_->IsDistributedEnabledByBundle(bundleOption, deviceType, enable); + EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: AddDoNotDisturbProfiles_0100 + * @tc.desc: test AddDoNotDisturbProfiles ErrCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, AddDoNotDisturbProfiles_0100, TestSize.Level1) +{ + std::vector> profiles; + profiles.clear(); + ErrCode ret1 = ans_->AddDoNotDisturbProfiles(profiles); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: AddDoNotDisturbProfiles_0200 + * @tc.desc: test AddDoNotDisturbProfiles ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, AddDoNotDisturbProfiles_0200, TestSize.Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool res = ans_->GetAnsManagerProxy(); + EXPECT_EQ(res, false); + + int32_t id = 1; + std::string name = "Name"; + std::vector trustlist; + std::vector> profiles; + sptr disturbProfile = + new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); + profiles.emplace_back(disturbProfile); + + ErrCode ret1 = ans_->AddDoNotDisturbProfiles(profiles); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: RemoveDoNotDisturbProfiles_0100 + * @tc.desc: test RemoveDoNotDisturbProfiles ErrCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, RemoveDoNotDisturbProfiles_0100, TestSize.Level1) +{ + vector> profiles; + profiles.clear(); + ErrCode ret1 = ans_->RemoveDoNotDisturbProfiles(profiles); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: RemoveDoNotDisturbProfiles_0200 + * @tc.desc: test RemoveDoNotDisturbProfiles ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, RemoveDoNotDisturbProfiles_0200, TestSize.Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool res = ans_->GetAnsManagerProxy(); + EXPECT_EQ(res, false); + + int32_t id = 1; + std::string name = "Name"; + std::vector trustlist; + std::vector> profiles; + sptr disturbProfile = + new (std::nothrow) NotificationDoNotDisturbProfile(id, name, trustlist); + profiles.emplace_back(disturbProfile); + + ErrCode ret1 = ans_->RemoveDoNotDisturbProfiles(profiles); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED +/* + * @tc.name: RegisterSwingCallback_0100 + * @tc.desc: test RegisterSwingCallback with parameters, expect errorCode ERR_ANS_SERVICE_NOT_CONNECTED + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, RegisterSwingCallback_0100, TestSize.Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + bool ret = ans_->GetAnsManagerProxy(); + EXPECT_EQ(ret, false); + std::function swingCbFunc = + std::bind(&AnsNotificationUnitTest::UpdateStatuts, this, std::placeholders::_1, std::placeholders::_2); + ErrCode res = ans_->RegisterSwingCallback(swingCbFunc); + EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); +} +#endif + +/* + * @tc.name: IsNeedSilentInDoNotDisturbMode_0100 + * @tc.desc: test IsNeedSilentInDoNotDisturbMode. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, IsNeedSilentInDoNotDisturbMode_0100, Function | MediumTest | Level1) +{ + MockWriteInterfaceToken(false); + sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObjects); + std::shared_ptr proxy = std::make_shared(iremoteObjects); + ASSERT_NE(nullptr, proxy); + ans_->GetAnsManagerProxy(); + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + ErrCode ret = ans_->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); + EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); +} +} // namespace Notification +} // namespace OHOS diff --git a/noti.diff b/noti.diff new file mode 100644 index 000000000..3f44b0ec9 --- /dev/null +++ b/noti.diff @@ -0,0 +1,582 @@ +diff --git a/frameworks/ans/test/unittest/notification_helper_test.cpp b/frameworks/ans/test/unittest/notification_helper_test.cpp +index 85597c7e..eb49dc9b 100644 +--- a/frameworks/ans/test/unittest/notification_helper_test.cpp ++++ b/frameworks/ans/test/unittest/notification_helper_test.cpp +@@ -1359,5 +1359,20 @@ HWTEST_F(NotificationHelperTest, RegisterSwingCallback_0100, TestSize.Level1) + EXPECT_EQ(ret, ERR_OK); + #endif + } ++ ++/** ++ * @tc.name: IsNeedSilentInDoNotDisturbMode_00001 ++ * @tc.desc: Test IsNeedSilentInDoNotDisturbMode parameters. ++ * @tc.type: FUNC ++ * @tc.require: issueI5WRQ2 ++ */ ++HWTEST_F(NotificationHelperTest, IsNeedSilentInDoNotDisturbMode_00001, Function | SmallTest | Level1) ++{ ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ NotificationHelper notificationHelper; ++ ErrCode ret = notificationHelper.IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); ++ EXPECT_EQ(ret, (int)ERR_OK); ++} + } + } +diff --git a/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp b/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp +index 326f4505..545d065b 100644 +--- a/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp ++++ b/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp +@@ -8080,5 +8080,113 @@ HWTEST_F(AnsManagerProxyUnitTest, RemoveDoNotDisturbProfiles_0300, TestSize.Leve + EXPECT_NE(ERR_OK, res); + EXPECT_NE(ERR_ANS_PARCELABLE_FAILED, res); + } ++ ++/* ++ * @tc.name: IsNeedSilentInDoNotDisturbModeTest_0100 ++ * @tc.desc: test IsNeedSilentInDoNotDisturbMode function ++ * @tc.type: FUNC ++ */ ++HWTEST_F(AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0100, Function | MediumTest | Level1) ++{ ++ GTEST_LOG_(INFO) ++ << "AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0100, TestSize.Level1"; ++ MockWriteInterfaceToken(false); ++ sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); ++ ASSERT_NE(nullptr, iremoteObject); ++ std::shared_ptr proxy = std::make_shared(iremoteObject); ++ ASSERT_NE(nullptr, proxy); ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ int32_t result = proxy->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); ++ EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); ++} ++ ++/* ++ * @tc.name: IsNeedSilentInDoNotDisturbModeTest_0200 ++ * @tc.desc: test IsNeedSilentInDoNotDisturbMode function ++ * @tc.type: FUNC ++ */ ++HWTEST_F(AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0200, Function | MediumTest | Level1) ++{ ++ GTEST_LOG_(INFO) ++ << "AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0200, TestSize.Level1"; ++ MockWriteInterfaceToken(true); ++ sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); ++ ASSERT_NE(nullptr, iremoteObject); ++ EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) ++ .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, ++ ERR_OK, true, true, true)), Return(NO_ERROR))); ++ std::shared_ptr proxy = std::make_shared(iremoteObject); ++ ASSERT_NE(nullptr, proxy); ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ int32_t result = proxy->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); ++ EXPECT_EQ(ERR_OK, result); ++} ++ ++/* ++ * @tc.name: IsNeedSilentInDoNotDisturbModeTest_0300 ++ * @tc.desc: test IsNeedSilentInDoNotDisturbMode function ++ * @tc.type: FUNC ++ */ ++HWTEST_F(AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0300, Function | MediumTest | Level1) ++{ ++ GTEST_LOG_(INFO) ++ << "AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0300, TestSize.Level1"; ++ sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); ++ ASSERT_NE(nullptr, iremoteObject); ++ EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) ++ .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); ++ std::shared_ptr proxy = std::make_shared(iremoteObject); ++ ASSERT_NE(nullptr, proxy); ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ int32_t result = proxy->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); ++ EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); ++} ++ ++/* ++ * @tc.name: IsNeedSilentInDoNotDisturbModeTest_0400 ++ * @tc.desc: test IsNeedSilentInDoNotDisturbMode function ++ * @tc.type: FUNC ++ */ ++HWTEST_F(AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0400, Function | MediumTest | Level1) ++{ ++ GTEST_LOG_(INFO) ++ << "AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0400, TestSize.Level1"; ++ sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); ++ ASSERT_NE(nullptr, iremoteObject); ++ EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) ++ .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, ++ ERR_OK, false, false, false)), Return(NO_ERROR))); ++ std::shared_ptr proxy = std::make_shared(iremoteObject); ++ ASSERT_NE(nullptr, proxy); ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ int32_t result = proxy->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); ++ EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); ++} ++ ++/* ++ * @tc.name: IsNeedSilentInDoNotDisturbModeTest_0500 ++ * @tc.desc: test IsNeedSilentInDoNotDisturbMode function ++ * @tc.type: FUNC ++ */ ++HWTEST_F(AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0500, Function | MediumTest | Level1) ++{ ++ GTEST_LOG_(INFO) ++ << "AnsManagerProxyUnitTest, IsNeedSilentInDoNotDisturbModeTest_0500, TestSize.Level1"; ++ sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); ++ ASSERT_NE(nullptr, iremoteObject); ++ EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) ++ .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, ++ ERR_OK, true, true, false)), Return(NO_ERROR))); ++ std::shared_ptr proxy = std::make_shared(iremoteObject); ++ ASSERT_NE(nullptr, proxy); ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ int32_t result = proxy->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); ++ EXPECT_EQ(ERR_OK, result); ++} + } // namespace Notification + } // namespace OHOS +diff --git a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp +index e7dc9849..2a567339 100644 +--- a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp ++++ b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp +@@ -5428,5 +5428,37 @@ HWTEST_F(AnsManagerStubTest, RegisterSwingCallback_0200, TestSize.Level1) + EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); + } + #endif ++ ++/** ++ * @tc.name: HandleIsNeedSilentInDoNotDisturbMode01 ++ * @tc.desc: Test HandleIsNeedSilentInDoNotDisturbMode01 succeeds. ++ * @tc.type: FUNC ++ */ ++HWTEST_F(AnsManagerStubTest, HandleIsNeedSilentInDoNotDisturbMode01, Function | SmallTest | Level1) ++{ ++ uint32_t code = static_cast(NotificationInterfaceCode::IS_NEED_SILENT_IN_DO_NOT_DISTURB_MODE); ++ MessageParcel data; ++ MessageParcel reply; ++ MessageOption option = {MessageOption::TF_SYNC}; ++ ++ data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); ++ ++ ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); ++ EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); ++} ++ ++/** ++ * @tc.name: IsNeedSilentInDoNotDisturbMode01 ++ * @tc.desc: Test IsNeedSilentInDoNotDisturbMode return. ++ * @tc.type: FUNC ++ */ ++HWTEST_F(AnsManagerStubTest, IsNeedSilentInDoNotDisturbMode01, Function | SmallTest | Level1) ++{ ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ ++ ErrCode result = ansManagerStub_->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); ++ EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); ++} + } + } +diff --git a/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp b/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp +index 2b59696a..b6079c82 100644 +--- a/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp ++++ b/frameworks/core/test/unittest/ans_notification_test/ans_notification_unit_test.cpp +@@ -1509,5 +1509,25 @@ HWTEST_F(AnsNotificationUnitTest, RegisterSwingCallback_0100, TestSize.Level1) + EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); + } + #endif ++ ++/* ++ * @tc.name: IsNeedSilentInDoNotDisturbMode_0100 ++ * @tc.desc: test IsNeedSilentInDoNotDisturbMode. ++ * @tc.type: FUNC ++ * @tc.require: #I62SME ++ */ ++HWTEST_F(AnsNotificationUnitTest, IsNeedSilentInDoNotDisturbMode_0100, Function | MediumTest | Level1) ++{ ++ MockWriteInterfaceToken(false); ++ sptr iremoteObjects = new (std::nothrow) MockIRemoteObject(); ++ ASSERT_NE(nullptr, iremoteObjects); ++ std::shared_ptr proxy = std::make_shared(iremoteObjects); ++ ASSERT_NE(nullptr, proxy); ++ ans_->GetAnsManagerProxy(); ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ ErrCode ret = ans_->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); ++ EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); ++} + } // namespace Notification + } // namespace OHOS +diff --git a/notification.gni b/notification.gni +index 519394c2..5a995932 100755 +--- a/notification.gni ++++ b/notification.gni +@@ -58,6 +58,7 @@ declare_args() { + notification_smart_reminder_supported = true + ans_config_policy_enable = true + screenlock_mgr_enable = true ++ telephony_cust = true + + if (defined(global_parts_info) && + !defined(global_parts_info.resourceschedule_device_usage_statistics)) { +@@ -95,6 +96,11 @@ declare_args() { + notification_smart_reminder_supported = false + } + ++ if (defined(global_parts_info) && ++ !defined(global_parts_info.telephony_telephony_cust)) { ++ telephony_cust = false ++ } ++ + print("hisysevent_usage = " + "$hisysevent_usage") + print("ans_hitrace_usage = " + "$ans_hitrace_usage") + } +diff --git a/services/ans/BUILD.gn b/services/ans/BUILD.gn +index afa5eac9..f0c1b619 100644 +--- a/services/ans/BUILD.gn ++++ b/services/ans/BUILD.gn +@@ -97,6 +97,7 @@ ohos_shared_library("libans") { + "src/reminder_timer_info.cpp", + "src/system_dialog_connect_stb.cpp", + "src/system_event_observer.cpp", ++ "src/telephony_extension_wrapper.cpp", + ] + + configs = [ ":public_ans_config" ] +@@ -206,6 +207,10 @@ ohos_shared_library("libans") { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + ++ if (telephony_cust) { ++ defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] ++ } ++ + subsystem_name = "${subsystem_name}" + part_name = "${component_name}" + } +diff --git a/services/ans/include/notification_extension_wrapper.h b/services/ans/include/notification_extension_wrapper.h +index 36106c80..88d465c8 100644 +--- a/services/ans/include/notification_extension_wrapper.h ++++ b/services/ans/include/notification_extension_wrapper.h +@@ -25,7 +25,6 @@ + #include "notification_unified_group_Info.h" + #include "singleton.h" + #include "advanced_aggregation_data_roaming_observer.h" +-#include "datashare_helper.h" + + namespace OHOS::Notification { + class ExtensionWrapper final { +@@ -33,7 +32,6 @@ class ExtensionWrapper final { + public: + DISALLOW_COPY_AND_MOVE(ExtensionWrapper); + void InitExtentionWrapper(); +- void InitTelExtentionWrapper(); + typedef ErrCode (*SYNC_ADDITION_CONFIG)(const std::string& key, const std::string& value); + typedef void (*UPDATE_BY_CANCEL)(const std::vector>& notifications, int deleteType); + typedef ErrCode (*GET_UNIFIED_GROUP_INFO)(const sptr &request); +@@ -43,7 +41,6 @@ public: + typedef int32_t (*LOCAL_CONTROL)(const sptr &request); + typedef void (*UPDATE_BY_BUNDLE)(const std::string bundleName, int deleteType); + typedef int32_t (*REMINDER_CONTROL)(const std::string &bundleName); +- typedef ErrCode (*GET_CALLER_INDEX)(std::shared_ptr resultSet, std::string compNum); + + ErrCode SyncAdditionConfig(const std::string& key, const std::string& value); + void UpdateByCancel(const std::vector>& notifications, int deleteReason); +@@ -54,13 +51,11 @@ public: + int32_t LocalControl(const sptr &request); + void UpdateByBundle(const std::string bundleName, int deleteType); + int32_t ReminderControl(const std::string &bundleName); +- ErrCode GetCallerIndex(std::shared_ptr resultSet, std::string compNum); + + private: + static int32_t convertToDelType(int32_t deleteReason); + + void* extensionWrapperHandle_ = nullptr; +- void* telephonyCustHandle_ = nullptr; + SYNC_ADDITION_CONFIG syncAdditionConfig_ = nullptr; + UPDATE_BY_CANCEL updateByCancel_ = nullptr; + GET_UNIFIED_GROUP_INFO getUnifiedGroupInfo_ = nullptr; +@@ -70,7 +65,6 @@ private: + UPDATE_BY_BUNDLE updateByBundle_ = nullptr; + REMINDER_CONTROL reminderControl_ = nullptr; + bool isRegisterDataSettingObserver = false; +- GET_CALLER_INDEX getCallerIndex_ = nullptr; + }; + + #define EXTENTION_WRAPPER ::OHOS::DelayedSingleton::GetInstance() +diff --git a/services/ans/src/advanced_datashare_helper.cpp b/services/ans/src/advanced_datashare_helper.cpp +index b197da46..fdeeca14 100644 +--- a/services/ans/src/advanced_datashare_helper.cpp ++++ b/services/ans/src/advanced_datashare_helper.cpp +@@ -23,7 +23,7 @@ + #include "singleton.h" + #include "system_ability_definition.h" + #include "ipc_skeleton.h" +-#include "notification_extension_wrapper.h" ++#include "telephony_extension_wrapper.h" + + namespace OHOS { + namespace Notification { +@@ -156,8 +156,9 @@ bool AdvancedDatashareHelper::QueryContact(Uri &uri, const std::string &phoneNum + ANS_LOGI("Query success, but rowCount is 0."); + } else { + int resultId = -1; +-#ifdef ENABLE_ANS_EXT_WRAPPER +- resultId = EXTENTION_WRAPPER->GetCallerIndex(resultSet, phoneNumber); ++#ifdef ENABLE_ANS_TELEPHONY_CUST_WRAPPER ++ resultId = TEL_EXTENTION_WRAPPER->GetCallerIndex(resultSet, phoneNumber); ++ ANS_LOGI("QueryContact resultId: %{public}d.", resultId); + #endif + if ((phoneNumber.size() >= PHONE_NUMBER_LENGTH && resultSet->GoToRow(resultId) == DataShare::E_OK) || + (phoneNumber.size() < PHONE_NUMBER_LENGTH && resultSet->GoToFirstRow() == DataShare::E_OK)) { +@@ -172,35 +173,41 @@ bool AdvancedDatashareHelper::QueryContact(Uri &uri, const std::string &phoneNum + bool AdvancedDatashareHelper::dealWithContactResult(std::shared_ptr helper, + std::shared_ptr resultSet, const std::string &policy) + { +- bool isNeedSilent = false; ++ bool isNoNeedSilent = false; + int32_t columnIndex; + int32_t favorite; + std::string focus_mode_list; + switch (atoi(policy.c_str())) { + case ContactPolicy::ALLOW_FAVORITE_CONTACTS: +- resultSet->GetColumnIndex(FAVORITE, columnIndex); +- resultSet->GetInt(columnIndex, favorite); +- ANS_LOGI("dealWithContactResult: favorite = %{public}d", favorite); +- isNeedSilent = favorite == 1; ++ do { ++ resultSet->GetColumnIndex(FAVORITE, columnIndex); ++ resultSet->GetInt(columnIndex, favorite); ++ ANS_LOGI("dealWithContactResult: favorite = %{public}d", favorite); ++ isNoNeedSilent = favorite == 1; ++ if (isNoNeedSilent) { ++ break; ++ } ++ } while(resultSet->GoToNextRow() == DataShare::E_OK); + break; + case ContactPolicy::ALLOW_SPECIFIED_CONTACTS: +- resultSet->GetColumnIndex(FOCUS_MODE_LIST, columnIndex); +- resultSet->GetString(columnIndex, focus_mode_list); +- ANS_LOGI("dealWithContactResult: focus_mode_list = %{public}s", focus_mode_list.c_str()); +- if (focus_mode_list.empty() || focus_mode_list.c_str()[0] == '0') { +- isNeedSilent = false; +- break; +- } +- if (focus_mode_list.c_str()[0] == '1') { +- isNeedSilent = true; +- break; +- } ++ do { ++ resultSet->GetColumnIndex(FOCUS_MODE_LIST, columnIndex); ++ resultSet->GetString(columnIndex, focus_mode_list); ++ ANS_LOGI("dealWithContactResult: focus_mode_list = %{public}s", focus_mode_list.c_str()); ++ if (focus_mode_list.empty() || focus_mode_list.c_str()[0] == '0') { ++ isNoNeedSilent = false; ++ } ++ if (focus_mode_list.c_str()[0] == '1') { ++ isNoNeedSilent = true; ++ break; ++ } ++ } while(resultSet->GoToNextRow() == DataShare::E_OK); + break; + default: +- isNeedSilent = true; ++ isNoNeedSilent = true; + break; + } +- return isNeedSilent; ++ return isNoNeedSilent; + } + + bool AdvancedDatashareHelper::isRepeatCall(const std::string &phoneNumber) +diff --git a/services/ans/src/advanced_notification_service_ability.cpp b/services/ans/src/advanced_notification_service_ability.cpp +index 82ffa663..8c542f79 100644 +--- a/services/ans/src/advanced_notification_service_ability.cpp ++++ b/services/ans/src/advanced_notification_service_ability.cpp +@@ -17,6 +17,7 @@ + #include "notification_extension_wrapper.h" + #include "system_event_observer.h" + #include "common_event_manager.h" ++#include "telephony_extension_wrapper.h" + + namespace OHOS { + namespace Notification { +@@ -47,12 +48,15 @@ void AdvancedNotificationServiceAbility::OnStart() + + #ifdef ENABLE_ANS_EXT_WRAPPER + EXTENTION_WRAPPER->InitExtentionWrapper(); +- EXTENTION_WRAPPER->InitTelExtentionWrapper(); + AddSystemAbilityListener(DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID); + AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); + #else + ANS_LOGD("Not enabled ans_ext"); + #endif ++ ++#ifdef ENABLE_ANS_TELEPHONY_CUST_WRAPPER ++ TEL_EXTENTION_WRAPPER->InitTelExtentionWrapper(); ++#endif + } + + void AdvancedNotificationServiceAbility::OnStop() +diff --git a/services/ans/src/notification_extension_wrapper.cpp b/services/ans/src/notification_extension_wrapper.cpp +index d950a24d..60fea60a 100644 +--- a/services/ans/src/notification_extension_wrapper.cpp ++++ b/services/ans/src/notification_extension_wrapper.cpp +@@ -29,7 +29,6 @@ + + namespace OHOS::Notification { + const std::string EXTENTION_WRAPPER_PATH = "libans_ext.z.so"; +-const std::string EXTENTION_TELEPHONY_PATH = "libtelephony_cust_api.z.so"; + const int32_t ACTIVE_DELETE = 0; + const int32_t PASSITIVE_DELETE = 1; + static constexpr const char *SETTINGS_DATA_UNIFIED_GROUP_ENABLE_URI = +@@ -85,22 +84,6 @@ void ExtensionWrapper::InitExtentionWrapper() + ANS_LOGD("extension wrapper init success"); + } + +-void ExtensionWrapper::InitTelExtentionWrapper() +-{ +- telephonyCustHandle_ = dlopen(EXTENTION_TELEPHONY_PATH.c_str(), RTLD_NOW); +- if (telephonyCustHandle_ == nullptr) { +- ANS_LOGE("telephony cust symbol failed, error: %{public}s", dlerror()); +- return; +- } +- +- getCallerIndex_ = (GET_CALLER_INDEX)dlsym(telephonyCustHandle_, "GetCallerNumIndex"); +- if (getCallerIndex_ == nullptr) { +- ANS_LOGE("telephony cust symbol failed, error: %{public}s", dlerror()); +- return; +- } +- ANS_LOGD("extension wrapper init success"); +-} +- + void ExtensionWrapper::CheckIfSetlocalSwitch() + { + ANS_LOGD("CheckIfSetlocalSwitch enter"); +@@ -211,13 +194,4 @@ int32_t ExtensionWrapper::convertToDelType(int32_t deleteReason) + ANS_LOGD("convertToDelType from delete reason %d to delete type %d", deleteReason, delType); + return delType; + } +- +-ErrCode ExtensionWrapper::GetCallerIndex(std::shared_ptr resultSet, std::string compNum) +-{ +- if (getCallerIndex_ == nullptr) { +- ANS_LOGE("GetCallerIndex wrapper symbol failed"); +- return -1; +- } +- return getCallerIndex_(resultSet, compNum); +-} + } // namespace OHOS::Notification +diff --git a/services/ans/test/unittest/advanced_notification_service_branch_test.cpp b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp +index 9668561f..6195ae5e 100644 +--- a/services/ans/test/unittest/advanced_notification_service_branch_test.cpp ++++ b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp +@@ -1188,5 +1188,36 @@ HWTEST_F(AnsBranchTest, AnsBranchTest_279002, Function | SmallTest | Level1) + ASSERT_EQ(record->notification->GetFinishTimer(), NotificationConstant::INVALID_TIMER_ID); + } + ++/** ++ * @tc.number : AnsBranchTest_285000 ++ * @tc.name : IsNeedSilentInDoNotDisturbMode_1000 ++ * @tc.desc : Test IsNeedSilentInDoNotDisturbMode function return ERR_ANS_NON_SYSTEM_APP. ++ */ ++HWTEST_F(AnsBranchTest, AnsBranchTest_285000, Function | SmallTest | Level1) ++{ ++ MockIsSystemApp(false); ++ MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); ++ ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ ASSERT_EQ(advancedNotificationService_->IsNeedSilentInDoNotDisturbMode( ++ phoneNumber, callerType), ERR_ANS_PERMISSION_DENIED); ++} ++ ++/** ++ * @tc.number : AnsBranchTest_286000 ++ * @tc.name : IsNeedSilentInDoNotDisturbMode_2000 ++ * @tc.desc : Test IsNeedSilentInDoNotDisturbMode function return ERR_ANS_PERMISSION_DENIED. ++ */ ++HWTEST_F(AnsBranchTest, AnsBranchTest_286000, Function | SmallTest | Level1) ++{ ++ MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); ++ MockIsVerfyPermisson(false); ++ ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ ASSERT_EQ(advancedNotificationService_->IsNeedSilentInDoNotDisturbMode( ++ phoneNumber, callerType), ERR_ANS_PERMISSION_DENIED); ++} + } // namespace Notification + } // namespace OHOS +diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp +index 5b57db45..23097b85 100644 +--- a/services/ans/test/unittest/advanced_notification_service_test.cpp ++++ b/services/ans/test/unittest/advanced_notification_service_test.cpp +@@ -1550,6 +1550,10 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17100, + + ASSERT_EQ(advancedNotificationService_->GetSyncNotificationEnabledWithoutApp(userId, enable), ERR_OK); + ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ ASSERT_EQ(advancedNotificationService_->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType), ERR_OK); ++ + GTEST_LOG_(INFO) << "ANS_GetActiveNotifications_0100 test end"; + } + +@@ -2417,6 +2421,23 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_220000 + ASSERT_EQ(result.size(), ret); + } + ++/** ++ * @tc.number : AdvancedNotificationServiceTest_22600 ++ * @tc.name : ANS_IsNeedSilentInDoNotDisturbMode_0100 ++ * @tc.desc : Test IsNeedSilentInDoNotDisturbMode function when the result is ERR_OK ++ * @tc.require : issueI5S4VP ++ */ ++HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_22600, Function | SmallTest | Level1) ++{ ++ TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); ++ sptr req = new NotificationRequest(); ++ EXPECT_NE(req, nullptr); ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ auto ret = advancedNotificationService_->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); ++ ASSERT_EQ(ret, (int)ERR_OK); ++} ++ + /** + * @tc.number : AdvancedNotificationServiceTest_00001 + * @tc.name : PrepareNotificationRequest +diff --git a/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp b/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp +index d640882e..125426ef 100644 +--- a/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp ++++ b/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp +@@ -1315,5 +1315,22 @@ HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_06 + AdvancedNotificationService advancedNotificationService; + ASSERT_EQ(advancedNotificationService.GetEnabledForBundleSlotSelf(slotType, enabled), ERR_ANS_INVALID_BUNDLE); + } ++ ++/** ++ * @tc.number : AdvancedNotificationService_06900 ++ * @tc.name : AdvancedNotificationService_06900 ++ * @tc.desc : Test IsNeedSilentInDoNotDisturbMode function and CheckPermission is false ++ */ ++HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_06900, Function | SmallTest | Level1) ++{ ++ std::string phoneNumber = "11111111111"; ++ int32_t callerType = 0; ++ ++ MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); ++ MockIsSystemApp(false); ++ AdvancedNotificationService advancedNotificationService; ++ ASSERT_EQ(advancedNotificationService.IsNeedSilentInDoNotDisturbMode( ++ phoneNumber, callerType), ERR_ANS_GET_ACTIVE_USER_FAILED); ++} + } // namespace Notification + } // namespace OHOS diff --git a/notification.gni b/notification.gni index b04f143f4..08b20e2f3 100644 --- a/notification.gni +++ b/notification.gni @@ -58,6 +58,7 @@ declare_args() { notification_smart_reminder_supported = true ans_config_policy_enable = true screenlock_mgr_enable = true + telephony_cust = true if (defined(global_parts_info) && !defined(global_parts_info.resourceschedule_device_usage_statistics)) { @@ -95,6 +96,11 @@ declare_args() { notification_smart_reminder_supported = false } + if (defined(global_parts_info) && + !defined(global_parts_info.telephony_telephony_cust)) { + telephony_cust = false + } + print("hisysevent_usage = " + "$hisysevent_usage") print("ans_hitrace_usage = " + "$ans_hitrace_usage") } diff --git a/services/ans/BUILD.gn b/services/ans/BUILD.gn index d2a104550..e57749b21 100644 --- a/services/ans/BUILD.gn +++ b/services/ans/BUILD.gn @@ -97,6 +97,7 @@ ohos_shared_library("libans") { "src/reminder_timer_info.cpp", "src/system_dialog_connect_stb.cpp", "src/system_event_observer.cpp", + "src/telephony_extension_wrapper.cpp", ] configs = [ ":public_ans_config" ] @@ -205,6 +206,10 @@ ohos_shared_library("libans") { defines += [ "SCREENLOCK_MGR_ENABLE" ] } + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + subsystem_name = "${subsystem_name}" part_name = "${component_name}" } diff --git a/services/ans/BUILD.gn.orig b/services/ans/BUILD.gn.orig new file mode 100644 index 000000000..d2a104550 --- /dev/null +++ b/services/ans/BUILD.gn.orig @@ -0,0 +1,224 @@ +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/ohos.gni") + +group("ans_targets") { + deps = [ ":libans" ] +} + +config("public_ans_config") { + include_dirs = [ + "${services_path}/ans/include", + "${core_path}/include", + ] +} + +ohos_shared_library("libans") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" + + shlib_type = "sa" + version_script = "libans.map" + include_dirs = [ + "include", + "${ffrt_path}/interfaces/kits", + ] + + sources = [ + "src/access_token_helper.cpp", + "src/advanced_aggregation_data_roaming_observer.cpp", + "src/advanced_datashare_helper.cpp", + "src/advanced_datashare_helper_ext.cpp", + "src/advanced_datashare_observer.cpp", + "src/advanced_notification_event_service.cpp", + "src/advanced_notification_inline.cpp", + "src/advanced_notification_live_view_service.cpp", + "src/advanced_notification_publish/base_publish_process.cpp", + "src/advanced_notification_publish/common_notification_publish_process.cpp", + "src/advanced_notification_publish/live_publish_process.cpp", + "src/advanced_notification_publish_service.cpp", + "src/advanced_notification_reminder_service.cpp", + "src/advanced_notification_service.cpp", + "src/advanced_notification_service_ability.cpp", + "src/advanced_notification_slot_service.cpp", + "src/advanced_notification_subscriber_service.cpp", + "src/advanced_notification_utils.cpp", + "src/bundle_manager_helper.cpp", + "src/common/file_utils.cpp", + "src/common/notification_analytics_util.cpp", + "src/common/notification_config_parse.cpp", + "src/distributed_device_status.cpp", + "src/event_report.cpp", + "src/notification_dialog.cpp", + "src/notification_dialog_manager.cpp", + "src/notification_extension_wrapper.cpp", + "src/notification_local_live_view_subscriber_manager.cpp", + "src/notification_preferences.cpp", + "src/notification_preferences_database.cpp", + "src/notification_preferences_info.cpp", + "src/notification_rdb_data_mgr.cpp", + "src/notification_slot_filter.cpp", + "src/notification_smart_reminder/reminder_affected.cpp", + "src/notification_smart_reminder/smart_reminder_center.cpp", + "src/notification_smart_reminder/string_utils.cpp", + "src/notification_subscriber_manager.cpp", + "src/notification_timer_info.cpp", + "src/notification_trust_list.cpp", + "src/os_account_manager_helper.cpp", + "src/permission_filter.cpp", + "src/reminder_config_change_observer.cpp", + "src/reminder_data_manager.cpp", + "src/reminder_data_manager_inner.cpp", + "src/reminder_event_manager.cpp", + "src/reminder_store.cpp", + "src/reminder_store_strategy.cpp", + "src/reminder_swing_decision_center.cpp", + "src/reminder_table.cpp", + "src/reminder_table_old.cpp", + "src/reminder_timer_info.cpp", + "src/system_dialog_connect_stb.cpp", + "src/system_event_observer.cpp", + ] + + configs = [ ":public_ans_config" ] + + defines = [] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + + deps = [ + "${frameworks_module_ans_path}:ans_innerkits", + "../ans:ans.para", + "../ans:ans.para.dac", + "//third_party/icu/icu4c:shared_icuuc", + "//third_party/libxml2:libxml2", + ] + + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + subsystem_name = "${subsystem_name}" + part_name = "${component_name}" +} + +ohos_prebuilt_etc("ans.para") { + source = "etc/ans.para" + relative_install_dir = "param" + subsystem_name = "${subsystem_name}" + part_name = "${component_name}" +} + +ohos_prebuilt_etc("ans.para.dac") { + source = "etc/ans.para.dac" + relative_install_dir = "param" + subsystem_name = "${subsystem_name}" + part_name = "${component_name}" +} diff --git a/services/ans/include/notification_extension_wrapper.h b/services/ans/include/notification_extension_wrapper.h index 36106c80c..88d465c85 100644 --- a/services/ans/include/notification_extension_wrapper.h +++ b/services/ans/include/notification_extension_wrapper.h @@ -25,7 +25,6 @@ #include "notification_unified_group_Info.h" #include "singleton.h" #include "advanced_aggregation_data_roaming_observer.h" -#include "datashare_helper.h" namespace OHOS::Notification { class ExtensionWrapper final { @@ -33,7 +32,6 @@ class ExtensionWrapper final { public: DISALLOW_COPY_AND_MOVE(ExtensionWrapper); void InitExtentionWrapper(); - void InitTelExtentionWrapper(); typedef ErrCode (*SYNC_ADDITION_CONFIG)(const std::string& key, const std::string& value); typedef void (*UPDATE_BY_CANCEL)(const std::vector>& notifications, int deleteType); typedef ErrCode (*GET_UNIFIED_GROUP_INFO)(const sptr &request); @@ -43,7 +41,6 @@ public: typedef int32_t (*LOCAL_CONTROL)(const sptr &request); typedef void (*UPDATE_BY_BUNDLE)(const std::string bundleName, int deleteType); typedef int32_t (*REMINDER_CONTROL)(const std::string &bundleName); - typedef ErrCode (*GET_CALLER_INDEX)(std::shared_ptr resultSet, std::string compNum); ErrCode SyncAdditionConfig(const std::string& key, const std::string& value); void UpdateByCancel(const std::vector>& notifications, int deleteReason); @@ -54,13 +51,11 @@ public: int32_t LocalControl(const sptr &request); void UpdateByBundle(const std::string bundleName, int deleteType); int32_t ReminderControl(const std::string &bundleName); - ErrCode GetCallerIndex(std::shared_ptr resultSet, std::string compNum); private: static int32_t convertToDelType(int32_t deleteReason); void* extensionWrapperHandle_ = nullptr; - void* telephonyCustHandle_ = nullptr; SYNC_ADDITION_CONFIG syncAdditionConfig_ = nullptr; UPDATE_BY_CANCEL updateByCancel_ = nullptr; GET_UNIFIED_GROUP_INFO getUnifiedGroupInfo_ = nullptr; @@ -70,7 +65,6 @@ private: UPDATE_BY_BUNDLE updateByBundle_ = nullptr; REMINDER_CONTROL reminderControl_ = nullptr; bool isRegisterDataSettingObserver = false; - GET_CALLER_INDEX getCallerIndex_ = nullptr; }; #define EXTENTION_WRAPPER ::OHOS::DelayedSingleton::GetInstance() diff --git a/services/ans/src/advanced_datashare_helper.cpp b/services/ans/src/advanced_datashare_helper.cpp index b197da46f..fdeeca141 100644 --- a/services/ans/src/advanced_datashare_helper.cpp +++ b/services/ans/src/advanced_datashare_helper.cpp @@ -23,7 +23,7 @@ #include "singleton.h" #include "system_ability_definition.h" #include "ipc_skeleton.h" -#include "notification_extension_wrapper.h" +#include "telephony_extension_wrapper.h" namespace OHOS { namespace Notification { @@ -156,8 +156,9 @@ bool AdvancedDatashareHelper::QueryContact(Uri &uri, const std::string &phoneNum ANS_LOGI("Query success, but rowCount is 0."); } else { int resultId = -1; -#ifdef ENABLE_ANS_EXT_WRAPPER - resultId = EXTENTION_WRAPPER->GetCallerIndex(resultSet, phoneNumber); +#ifdef ENABLE_ANS_TELEPHONY_CUST_WRAPPER + resultId = TEL_EXTENTION_WRAPPER->GetCallerIndex(resultSet, phoneNumber); + ANS_LOGI("QueryContact resultId: %{public}d.", resultId); #endif if ((phoneNumber.size() >= PHONE_NUMBER_LENGTH && resultSet->GoToRow(resultId) == DataShare::E_OK) || (phoneNumber.size() < PHONE_NUMBER_LENGTH && resultSet->GoToFirstRow() == DataShare::E_OK)) { @@ -172,35 +173,41 @@ bool AdvancedDatashareHelper::QueryContact(Uri &uri, const std::string &phoneNum bool AdvancedDatashareHelper::dealWithContactResult(std::shared_ptr helper, std::shared_ptr resultSet, const std::string &policy) { - bool isNeedSilent = false; + bool isNoNeedSilent = false; int32_t columnIndex; int32_t favorite; std::string focus_mode_list; switch (atoi(policy.c_str())) { case ContactPolicy::ALLOW_FAVORITE_CONTACTS: - resultSet->GetColumnIndex(FAVORITE, columnIndex); - resultSet->GetInt(columnIndex, favorite); - ANS_LOGI("dealWithContactResult: favorite = %{public}d", favorite); - isNeedSilent = favorite == 1; + do { + resultSet->GetColumnIndex(FAVORITE, columnIndex); + resultSet->GetInt(columnIndex, favorite); + ANS_LOGI("dealWithContactResult: favorite = %{public}d", favorite); + isNoNeedSilent = favorite == 1; + if (isNoNeedSilent) { + break; + } + } while(resultSet->GoToNextRow() == DataShare::E_OK); break; case ContactPolicy::ALLOW_SPECIFIED_CONTACTS: - resultSet->GetColumnIndex(FOCUS_MODE_LIST, columnIndex); - resultSet->GetString(columnIndex, focus_mode_list); - ANS_LOGI("dealWithContactResult: focus_mode_list = %{public}s", focus_mode_list.c_str()); - if (focus_mode_list.empty() || focus_mode_list.c_str()[0] == '0') { - isNeedSilent = false; - break; - } - if (focus_mode_list.c_str()[0] == '1') { - isNeedSilent = true; - break; - } + do { + resultSet->GetColumnIndex(FOCUS_MODE_LIST, columnIndex); + resultSet->GetString(columnIndex, focus_mode_list); + ANS_LOGI("dealWithContactResult: focus_mode_list = %{public}s", focus_mode_list.c_str()); + if (focus_mode_list.empty() || focus_mode_list.c_str()[0] == '0') { + isNoNeedSilent = false; + } + if (focus_mode_list.c_str()[0] == '1') { + isNoNeedSilent = true; + break; + } + } while(resultSet->GoToNextRow() == DataShare::E_OK); break; default: - isNeedSilent = true; + isNoNeedSilent = true; break; } - return isNeedSilent; + return isNoNeedSilent; } bool AdvancedDatashareHelper::isRepeatCall(const std::string &phoneNumber) diff --git a/services/ans/src/advanced_notification_service_ability.cpp.orig b/services/ans/src/advanced_notification_service_ability.cpp.orig new file mode 100644 index 000000000..89a173ad7 --- /dev/null +++ b/services/ans/src/advanced_notification_service_ability.cpp.orig @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "advanced_notification_service_ability.h" +#include "notification_extension_wrapper.h" +#include "system_event_observer.h" + +namespace OHOS { +namespace Notification { +namespace { +REGISTER_SYSTEM_ABILITY_BY_ID(AdvancedNotificationServiceAbility, ADVANCED_NOTIFICATION_SERVICE_ABILITY_ID, true); +} + +AdvancedNotificationServiceAbility::AdvancedNotificationServiceAbility(const int32_t systemAbilityId, bool runOnCreate) + : SystemAbility(systemAbilityId, runOnCreate), service_(nullptr) +{} + +AdvancedNotificationServiceAbility::~AdvancedNotificationServiceAbility() +{} + +void AdvancedNotificationServiceAbility::OnStart() +{ + if (service_ != nullptr) { + return; + } + + service_ = AdvancedNotificationService::GetInstance(); + if (!Publish(service_)) { + return; + } + service_->CreateDialogManager(); + service_->InitPublishProcess(); + reminderAgent_ = ReminderDataManager::InitInstance(service_); + +#ifdef ENABLE_ANS_EXT_WRAPPER + EXTENTION_WRAPPER->InitExtentionWrapper(); + EXTENTION_WRAPPER->InitTelExtentionWrapper(); + AddSystemAbilityListener(DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID); + AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); +#else + ANS_LOGI("Not enabled ans_ext"); +#endif +} + +void AdvancedNotificationServiceAbility::OnStop() +{ + service_ = nullptr; + reminderAgent_ = nullptr; +} + +void AdvancedNotificationServiceAbility::OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) +{ + ANS_LOGD("SubSystemAbilityListener::OnAddSystemAbility enter !"); + if (systemAbilityId == DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID) { + if (AdvancedDatashareObserver::GetInstance().CheckIfSettingsDataReady()) { + if (isDatashaReready_) { + return; + } + EXTENTION_WRAPPER->CheckIfSetlocalSwitch(); + isDatashaReready_ = true; + } + } else if (systemAbilityId == COMMON_EVENT_SERVICE_ID) { + if (isDatashaReready_) { + return; + } + EventFwk::MatchingSkills matchingSkills; + matchingSkills.AddEvent("usual.event.DATA_SHARE_READY"); + EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills); + subscriber_ = std::make_shared( + subscribeInfo, std::bind(&AdvancedNotificationServiceAbility::OnReceiveEvent, this, std::placeholders::_1)); + if (subscriber_ == nullptr) { + ANS_LOGD("subscriber_ is nullptr"); + return; + } + EventFwk::CommonEventManager::SubscribeCommonEvent(subscriber_); + } +} + +void AdvancedNotificationServiceAbility::OnReceiveEvent(const EventFwk::CommonEventData &data) +{ + ANS_LOGI("CheckIfSettingsDataReady() ok!"); + if (isDatashaReready_) { + return; + } + auto const &want = data.GetWant(); + std::string action = want.GetAction(); + if (action == "usual.event.DATA_SHARE_READY") { + isDatashaReready_ = true; + ANS_LOGI("COMMON_EVENT_SERVICE_ID OnReceiveEvent ok!"); + EXTENTION_WRAPPER->CheckIfSetlocalSwitch(); + } +} + +void AdvancedNotificationServiceAbility::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) +{ + if (systemAbilityId != COMMON_EVENT_SERVICE_ID) { + return; + } +} +} // namespace Notification +} // namespace OHOS diff --git a/services/ans/src/advanced_notification_service_ability.cpp.rej b/services/ans/src/advanced_notification_service_ability.cpp.rej new file mode 100644 index 000000000..d71dc04ed --- /dev/null +++ b/services/ans/src/advanced_notification_service_ability.cpp.rej @@ -0,0 +1,27 @@ +--- services/ans/src/advanced_notification_service_ability.cpp ++++ services/ans/src/advanced_notification_service_ability.cpp +@@ -17,6 +17,7 @@ + #include "notification_extension_wrapper.h" + #include "system_event_observer.h" + #include "common_event_manager.h" ++#include "telephony_extension_wrapper.h" + + namespace OHOS { + namespace Notification { +@@ -47,12 +48,15 @@ void AdvancedNotificationServiceAbility::OnStart() + + #ifdef ENABLE_ANS_EXT_WRAPPER + EXTENTION_WRAPPER->InitExtentionWrapper(); +- EXTENTION_WRAPPER->InitTelExtentionWrapper(); + AddSystemAbilityListener(DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID); + AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); + #else + ANS_LOGD("Not enabled ans_ext"); + #endif ++ ++#ifdef ENABLE_ANS_TELEPHONY_CUST_WRAPPER ++ TEL_EXTENTION_WRAPPER->InitTelExtentionWrapper(); ++#endif + } + + void AdvancedNotificationServiceAbility::OnStop() diff --git a/services/ans/src/notification_extension_wrapper.cpp b/services/ans/src/notification_extension_wrapper.cpp index 47be2d010..d39ccdcda 100644 --- a/services/ans/src/notification_extension_wrapper.cpp +++ b/services/ans/src/notification_extension_wrapper.cpp @@ -27,7 +27,6 @@ namespace OHOS::Notification { const std::string EXTENTION_WRAPPER_PATH = "libans_ext.z.so"; -const std::string EXTENTION_TELEPHONY_PATH = "libtelephony_cust_api.z.so"; const int32_t ACTIVE_DELETE = 0; const int32_t PASSITIVE_DELETE = 1; static constexpr const char *SETTINGS_DATA_UNIFIED_GROUP_ENABLE_URI = @@ -83,22 +82,6 @@ void ExtensionWrapper::InitExtentionWrapper() ANS_LOGD("extension wrapper init success"); } -void ExtensionWrapper::InitTelExtentionWrapper() -{ - telephonyCustHandle_ = dlopen(EXTENTION_TELEPHONY_PATH.c_str(), RTLD_NOW); - if (telephonyCustHandle_ == nullptr) { - ANS_LOGE("telephony cust symbol failed, error: %{public}s", dlerror()); - return; - } - - getCallerIndex_ = (GET_CALLER_INDEX)dlsym(telephonyCustHandle_, "GetCallerNumIndex"); - if (getCallerIndex_ == nullptr) { - ANS_LOGE("telephony cust symbol failed, error: %{public}s", dlerror()); - return; - } - ANS_LOGD("extension wrapper init success"); -} - void ExtensionWrapper::CheckIfSetlocalSwitch() { ANS_LOGD("CheckIfSetlocalSwitch enter"); @@ -209,13 +192,4 @@ int32_t ExtensionWrapper::convertToDelType(int32_t deleteReason) ANS_LOGD("convertToDelType from delete reason %d to delete type %d", deleteReason, delType); return delType; } - -ErrCode ExtensionWrapper::GetCallerIndex(std::shared_ptr resultSet, std::string compNum) -{ - if (getCallerIndex_ == nullptr) { - ANS_LOGE("GetCallerIndex wrapper symbol failed"); - return -1; - } - return getCallerIndex_(resultSet, compNum); -} } // namespace OHOS::Notification diff --git a/services/ans/src/notification_extension_wrapper.cpp.orig b/services/ans/src/notification_extension_wrapper.cpp.orig new file mode 100644 index 000000000..47be2d010 --- /dev/null +++ b/services/ans/src/notification_extension_wrapper.cpp.orig @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include + +#include "advanced_notification_service.h" +#include "notification_extension_wrapper.h" +#include "notification_preferences.h" +#include "advanced_datashare_observer.h" +#include "common_event_manager.h" +#include "common_event_support.h" + +#include "common_event_subscriber.h" +#include "system_event_observer.h" + +namespace OHOS::Notification { +const std::string EXTENTION_WRAPPER_PATH = "libans_ext.z.so"; +const std::string EXTENTION_TELEPHONY_PATH = "libtelephony_cust_api.z.so"; +const int32_t ACTIVE_DELETE = 0; +const int32_t PASSITIVE_DELETE = 1; +static constexpr const char *SETTINGS_DATA_UNIFIED_GROUP_ENABLE_URI = + "datashare:///com.ohos.settingsdata/entry/settingsdata/" + "USER_SETTINGSDATA_SECURE_100?Proxy=true&key=unified_group_enable"; +ExtensionWrapper::ExtensionWrapper() = default; +ExtensionWrapper::~ExtensionWrapper() = default; + + +#ifdef __cplusplus +extern "C" { +#endif + +void UpdateUnifiedGroupInfo(const std::string &key, std::shared_ptr &groupInfo) +{ + AdvancedNotificationService::GetInstance()->UpdateUnifiedGroupInfo(key, groupInfo); +} + +#ifdef __cplusplus +} +#endif + +void ExtensionWrapper::InitExtentionWrapper() +{ + extensionWrapperHandle_ = dlopen(EXTENTION_WRAPPER_PATH.c_str(), RTLD_NOW); + if (extensionWrapperHandle_ == nullptr) { + ANS_LOGE("extension wrapper symbol failed, error: %{public}s", dlerror()); + return; + } + + syncAdditionConfig_ = (SYNC_ADDITION_CONFIG)dlsym(extensionWrapperHandle_, "SyncAdditionConfig"); + localControl_ = (LOCAL_CONTROL)dlsym(extensionWrapperHandle_, "LocalControl"); + reminderControl_ = (REMINDER_CONTROL)dlsym(extensionWrapperHandle_, "ReminderControl"); + if (syncAdditionConfig_ == nullptr + || localControl_ == nullptr + || reminderControl_ == nullptr) { + ANS_LOGE("extension wrapper symbol failed, error: %{public}s", dlerror()); + return; + } + + std::string ctrlConfig = NotificationPreferences::GetInstance()->GetAdditionalConfig("NOTIFICATION_CTL_LIST_PKG"); + if (!ctrlConfig.empty()) { + syncAdditionConfig_("NOTIFICATION_CTL_LIST_PKG", ctrlConfig); + } + + std::string aggregateConfig = NotificationPreferences::GetInstance()->GetAdditionalConfig("AGGREGATE_CONFIG"); + if (!aggregateConfig.empty()) { + syncAdditionConfig_("AGGREGATE_CONFIG", aggregateConfig); + } + if (initSummary_ != nullptr) { + initSummary_(UpdateUnifiedGroupInfo); + } + ANS_LOGD("extension wrapper init success"); +} + +void ExtensionWrapper::InitTelExtentionWrapper() +{ + telephonyCustHandle_ = dlopen(EXTENTION_TELEPHONY_PATH.c_str(), RTLD_NOW); + if (telephonyCustHandle_ == nullptr) { + ANS_LOGE("telephony cust symbol failed, error: %{public}s", dlerror()); + return; + } + + getCallerIndex_ = (GET_CALLER_INDEX)dlsym(telephonyCustHandle_, "GetCallerNumIndex"); + if (getCallerIndex_ == nullptr) { + ANS_LOGE("telephony cust symbol failed, error: %{public}s", dlerror()); + return; + } + ANS_LOGD("extension wrapper init success"); +} + +void ExtensionWrapper::CheckIfSetlocalSwitch() +{ + ANS_LOGD("CheckIfSetlocalSwitch enter"); + if (extensionWrapperHandle_ == nullptr) { + return; + } + if (!isRegisterDataSettingObserver) { + RegisterDataSettingObserver(); + isRegisterDataSettingObserver = true; + } + std::string enable = ""; + AdvancedNotificationService::GetInstance()->GetUnifiedGroupInfoFromDb(enable); + SetlocalSwitch(enable); +} + +void ExtensionWrapper::SetlocalSwitch(std::string &enable) +{ + if (setLocalSwitch_ == nullptr) { + return; + } + bool status = (enable == "false" ? false : true); + setLocalSwitch_(status); +} + +void ExtensionWrapper::RegisterDataSettingObserver() +{ + ANS_LOGD("ExtensionWrapper::RegisterDataSettingObserver enter"); + sptr aggregationRoamingObserver; + if (aggregationRoamingObserver == nullptr) { + aggregationRoamingObserver = new (std::nothrow) AdvancedAggregationDataRoamingObserver(); + } + + if (aggregationRoamingObserver == nullptr) { + return; + } + + Uri dataEnableUri(SETTINGS_DATA_UNIFIED_GROUP_ENABLE_URI); + AdvancedDatashareObserver::GetInstance().RegisterSettingsObserver(dataEnableUri, aggregationRoamingObserver); +} + +ErrCode ExtensionWrapper::SyncAdditionConfig(const std::string& key, const std::string& value) +{ + if (syncAdditionConfig_ == nullptr) { + ANS_LOGE("syncAdditionConfig wrapper symbol failed"); + return 0; + } + return syncAdditionConfig_(key, value); +} + +void ExtensionWrapper::UpdateByCancel(const std::vector>& notifications, int deleteReason) +{ + if (updateByCancel_ == nullptr) { + return; + } + int32_t deleteType = convertToDelType(deleteReason); + updateByCancel_(notifications, deleteType); +} + +ErrCode ExtensionWrapper::GetUnifiedGroupInfo(const sptr &request) +{ + if (getUnifiedGroupInfo_ == nullptr) { + return 0; + } + return getUnifiedGroupInfo_(request); +} + +int32_t ExtensionWrapper::ReminderControl(const std::string &bundleName) +{ + if (reminderControl_ == nullptr) { + ANS_LOGE("ReminderControl wrapper symbol failed"); + return 0; + } + return reminderControl_(bundleName); +} + +__attribute__((no_sanitize("cfi"))) int32_t ExtensionWrapper::LocalControl(const sptr &request) +{ + if (localControl_ == nullptr) { + ANS_LOGE("LocalControl wrapper symbol failed"); + return 0; + } + return localControl_(request); +} + +void ExtensionWrapper::UpdateByBundle(const std::string bundleName, int deleteReason) +{ + if (updateByBundle_ == nullptr) { + return; + } + int32_t deleteType = convertToDelType(deleteReason); + updateByBundle_(bundleName, deleteType); +} + +int32_t ExtensionWrapper::convertToDelType(int32_t deleteReason) +{ + int32_t delType = ACTIVE_DELETE; + switch (deleteReason) { + case NotificationConstant::PACKAGE_CHANGED_REASON_DELETE: + case NotificationConstant::USER_REMOVED_REASON_DELETE: + case NotificationConstant::DISABLE_SLOT_REASON_DELETE: + case NotificationConstant::DISABLE_NOTIFICATION_REASON_DELETE: + delType = PASSITIVE_DELETE; + break; + default: + delType = ACTIVE_DELETE; + } + + ANS_LOGD("convertToDelType from delete reason %d to delete type %d", deleteReason, delType); + return delType; +} + +ErrCode ExtensionWrapper::GetCallerIndex(std::shared_ptr resultSet, std::string compNum) +{ + if (getCallerIndex_ == nullptr) { + ANS_LOGE("GetCallerIndex wrapper symbol failed"); + return -1; + } + return getCallerIndex_(resultSet, compNum); +} +} // namespace OHOS::Notification diff --git a/services/ans/test/unittest/advanced_notification_service_branch_test.cpp b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp index 29e5a8809..68115327d 100644 --- a/services/ans/test/unittest/advanced_notification_service_branch_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp @@ -1189,5 +1189,36 @@ HWTEST_F(AnsBranchTest, AnsBranchTest_279002, Function | SmallTest | Level1) ASSERT_EQ(record->notification->GetFinishTimer(), NotificationConstant::INVALID_TIMER_ID); } +/** + * @tc.number : AnsBranchTest_285000 + * @tc.name : IsNeedSilentInDoNotDisturbMode_1000 + * @tc.desc : Test IsNeedSilentInDoNotDisturbMode function return ERR_ANS_NON_SYSTEM_APP. + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_285000, Function | SmallTest | Level1) +{ + MockIsSystemApp(false); + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + ASSERT_EQ(advancedNotificationService_->IsNeedSilentInDoNotDisturbMode( + phoneNumber, callerType), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_286000 + * @tc.name : IsNeedSilentInDoNotDisturbMode_2000 + * @tc.desc : Test IsNeedSilentInDoNotDisturbMode function return ERR_ANS_PERMISSION_DENIED. + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_286000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + ASSERT_EQ(advancedNotificationService_->IsNeedSilentInDoNotDisturbMode( + phoneNumber, callerType), ERR_ANS_PERMISSION_DENIED); +} } // namespace Notification } // namespace OHOS diff --git a/services/ans/test/unittest/advanced_notification_service_branch_test.cpp.orig b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp.orig new file mode 100644 index 000000000..29e5a8809 --- /dev/null +++ b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp.orig @@ -0,0 +1,1193 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include "gtest/gtest.h" + +#define private public + +#include "advanced_notification_service.h" +#include "ans_const_define.h" +#include "ans_inner_errors.h" +#include "ans_log_wrapper.h" +#include "ans_ut_constant.h" +#include "iremote_object.h" +#include "want_agent_info.h" +#include "want_agent_helper.h" +#include "want_params.h" +#include "mock_ipc_skeleton.h" +#include "notification_preferences.h" +#include "notification_constant.h" +#include "notification_record.h" +#include "notification_subscriber.h" +#include "refbase.h" + +extern void MockVerifyNativeToken(bool mockRet); +extern void MockVerifyShellToken(bool mockRet); +extern void MockGetDistributedEnableInApplicationInfo(bool mockRet, uint8_t mockCase = 0); +extern void MockGetOsAccountLocalIdFromUid(bool mockRet, uint8_t mockCase = 0); + +using namespace testing::ext; +using namespace OHOS::Media; +using namespace OHOS::Security::AccessToken; + +namespace OHOS { +namespace Notification { +extern void MockIsVerfyPermisson(bool isVerify); +extern void MockGetTokenTypeFlag(ATokenTypeEnum mockRet); +extern void MockIsSystemApp(bool isSystemApp); +extern void MockDistributedNotificationEnabled(bool isEnable); +extern void MockIsNonBundleName(bool isNonBundleName); + +class AnsBranchTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); + static void InitNotificationRecord(std::shared_ptr &record, + const NotificationLiveViewContent::LiveViewStatus &status); +private: + void TestAddSlot(NotificationConstant::SlotType type); + +private: + static sptr advancedNotificationService_; +}; + +sptr AnsBranchTest::advancedNotificationService_ = nullptr; + +void AnsBranchTest::SetUpTestCase() {} + +void AnsBranchTest::TearDownTestCase() {} + +void AnsBranchTest::SetUp() +{ + GTEST_LOG_(INFO) << "SetUp start"; + + advancedNotificationService_ = new (std::nothrow) AdvancedNotificationService(); + IPCSkeleton::SetCallingTokenID(NATIVE_TOKEN); + IPCSkeleton::SetCallingUid(SYSTEM_APP_UID); + NotificationPreferences::GetInstance()->ClearNotificationInRestoreFactorySettings(); + advancedNotificationService_->CancelAll(0); + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE); + MockIsSystemApp(true); + GTEST_LOG_(INFO) << "SetUp end"; +} + +void AnsBranchTest::TearDown() +{ + IPCSkeleton::SetCallingUid(SYSTEM_APP_UID); + advancedNotificationService_ = nullptr; + GTEST_LOG_(INFO) << "TearDown"; +} + +inline void SleepForFC() +{ + // For ANS Flow Control + std::this_thread::sleep_for(std::chrono::seconds(1)); +} + +class TestAnsSubscriber : public NotificationSubscriber { +public: + void OnDied() override + {} + void OnConnected() override + {} + void OnDisconnected() override + {} + void OnUpdate(const std::shared_ptr &sortingMap) override + {} + void OnDoNotDisturbDateChange(const std::shared_ptr &date) override + {} + void OnCanceled(const std::shared_ptr &request, + const std::shared_ptr &sortingMap, int32_t deleteReason) override + {} + void OnEnabledNotificationChanged( + const std::shared_ptr &callbackData) override + {} + void OnConsumed(const std::shared_ptr &request, + const std::shared_ptr &sortingMap) override + {} + void OnBadgeChanged(const std::shared_ptr &badgeData) override + {} + void OnBadgeEnabledChanged(const sptr &callbackData) override + {} + void OnBatchCanceled(const std::vector> + &requestList, const std::shared_ptr &sortingMap, int32_t deleteReason) override + {} +}; + +void AnsBranchTest::TestAddSlot(NotificationConstant::SlotType type) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + MockIsVerfyPermisson(true); + std::vector> slots; + sptr slot = new NotificationSlot(type); + slots.push_back(slot); + ASSERT_EQ(advancedNotificationService_->AddSlots(slots), (int)ERR_OK); +} + +/** + * @tc.number : AnsBranchTest_222000 + * @tc.name : PrepareNotificationRequest_1000 + * @tc.desc : Test PrepareNotificationRequest function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_222000, Function | SmallTest | Level1) +{ + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + + req->SetIsAgentNotification(true); + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + MockIsVerfyPermisson(false); + + ASSERT_EQ(advancedNotificationService_->PrepareNotificationRequest(req), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_223000 + * @tc.name : PrepareNotificationRequest_2000 + * @tc.desc : Test PrepareNotificationRequest function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_223000, Function | SmallTest | Level1) +{ + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + + req->SetIsAgentNotification(true); + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + ASSERT_EQ(advancedNotificationService_->PrepareNotificationRequest(req), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_224000 + * @tc.name : Publish_1000 + * @tc.desc : Test Publish function req is false. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_224000, Function | SmallTest | Level1) +{ + std::string label = "publish's label"; + ASSERT_EQ(advancedNotificationService_->Publish(label, nullptr), ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AnsBranchTest_225000 + * @tc.name : CancelAsBundle_1000 + * @tc.desc : Test CancelAsBundle function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_225000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + int32_t notificationId = 1; + std::string representativeBundle = "RepresentativeBundle"; + int32_t userId = 1; + ASSERT_EQ(advancedNotificationService_->CancelAsBundle( + notificationId, representativeBundle, userId), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_226000 + * @tc.name : CancelAsBundle_2000 + * @tc.desc : Test CancelAsBundle function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_226000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + int32_t notificationId = 1; + std::string representativeBundle = "RepresentativeBundle"; + int32_t userId = 1; + ASSERT_EQ(advancedNotificationService_->CancelAsBundle( + notificationId, representativeBundle, userId), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_227000 + * @tc.name : AddSlots_2000 + * @tc.desc : Test AddSlots function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_227000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + std::vector> slots; + sptr slot0 = new NotificationSlot(NotificationConstant::OTHER); + sptr slot1 = new NotificationSlot(NotificationConstant::OTHER); + slots.push_back(slot0); + slots.push_back(slot1); + ASSERT_EQ(advancedNotificationService_->AddSlots(slots), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_228000 + * @tc.name : Delete_1000 + * @tc.desc : Test Delete function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_228000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + const std::string key = "key"; + ASSERT_EQ(advancedNotificationService_->Delete( + key, NotificationConstant::CANCEL_REASON_DELETE), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_229000 + * @tc.name : DeleteByBundle_1000 + * @tc.desc : Test DeleteByBundle function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_229000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + ASSERT_EQ(advancedNotificationService_->DeleteByBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID)), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_230000 + * @tc.name : DeleteByBundle_2000 + * @tc.desc : Test DeleteByBundle function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_230000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + ASSERT_EQ(advancedNotificationService_->DeleteByBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID)), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_231000 + * @tc.name : DeleteAll_1000 + * @tc.desc : Test DeleteAll function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_231000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + ASSERT_EQ(advancedNotificationService_->DeleteAll(), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_232000 + * @tc.name : GetSlotsByBundle_1000 + * @tc.desc : Test GetSlotsByBundle function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_232000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + std::vector> slots; + ASSERT_EQ(advancedNotificationService_->GetSlotsByBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), slots), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_233000 + * @tc.name : GetSlotsByBundle_2000 + * @tc.desc : Test GetSlotsByBundle function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_233000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + std::vector> slots; + ASSERT_EQ(advancedNotificationService_->GetSlotsByBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), slots), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_234000 + * @tc.name : UpdateSlots_1000 + * @tc.desc : Test UpdateSlots function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_234000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + std::vector> slots; + sptr slot0 = new NotificationSlot(NotificationConstant::OTHER); + slots.push_back(slot0); + ASSERT_EQ(advancedNotificationService_->UpdateSlots( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), slots), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_235000 + * @tc.name : UpdateSlots_1000 + * @tc.desc : Test UpdateSlots function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_235000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + std::vector> slots; + sptr slot0 = new NotificationSlot(NotificationConstant::OTHER); + slots.push_back(slot0); + ASSERT_EQ(advancedNotificationService_->UpdateSlots( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), slots), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_236000 + * @tc.name : SetShowBadgeEnabledForBundle_1000 + * @tc.desc : Test SetShowBadgeEnabledForBundle function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_236000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + ASSERT_EQ(advancedNotificationService_->SetShowBadgeEnabledForBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), true), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_237000 + * @tc.name : GetShowBadgeEnabledForBundle_1000 + * @tc.desc : Test GetShowBadgeEnabledForBundle function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_237000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + bool allow = false; + ASSERT_EQ(advancedNotificationService_->GetShowBadgeEnabledForBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), allow), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_238000 + * @tc.name : GetShowBadgeEnabledForBundle_2000 + * @tc.desc : Test GetShowBadgeEnabledForBundle function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_238000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + bool allow = false; + ASSERT_EQ(advancedNotificationService_->GetShowBadgeEnabledForBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), allow), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_239000 + * @tc.name : Subscribe_1000 + * @tc.desc : Test Subscribe function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_239000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + auto subscriber = new TestAnsSubscriber(); + sptr info = new NotificationSubscribeInfo(); + ASSERT_EQ(advancedNotificationService_->Subscribe(subscriber->GetImpl(), info), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_240000 + * @tc.name : Subscribe_1000 + * @tc.desc : Test Subscribe function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_240000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + auto subscriber = new TestAnsSubscriber(); + sptr info = new NotificationSubscribeInfo(); + ASSERT_EQ(advancedNotificationService_->Subscribe(subscriber->GetImpl(), info), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_241000 + * @tc.name : Unsubscribe_1000 + * @tc.desc : Test Unsubscribe function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_241000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + auto subscriber = new TestAnsSubscriber(); + sptr info = new NotificationSubscribeInfo(); + ASSERT_EQ(advancedNotificationService_->Unsubscribe(subscriber->GetImpl(), info), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_242000 + * @tc.name : GetAllActiveNotifications_1000 + * @tc.desc : Test GetAllActiveNotifications function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_242000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + std::vector> allNotifications; + ASSERT_EQ(advancedNotificationService_->GetAllActiveNotifications(allNotifications), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_243000 + * @tc.name : GetSpecialActiveNotifications_1000 + * @tc.desc : Test GetSpecialActiveNotifications function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_243000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + std::vector keys; + std::vector> specialActiveNotifications; + ASSERT_EQ(advancedNotificationService_->GetSpecialActiveNotifications( + keys, specialActiveNotifications), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_244000 + * @tc.name : GetSpecialActiveNotifications_2000 + * @tc.desc : Test GetSpecialActiveNotifications function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_244000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + std::vector keys; + std::vector> specialActiveNotifications; + ASSERT_EQ(advancedNotificationService_->GetSpecialActiveNotifications( + keys, specialActiveNotifications), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_245000 + * @tc.name : SetNotificationsEnabledForAllBundles_2000 + * @tc.desc : Test SetNotificationsEnabledForAllBundles function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_245000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + ASSERT_EQ(advancedNotificationService_->SetNotificationsEnabledForAllBundles( + std::string(), true), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_246000 + * @tc.name : SetNotificationsEnabledForAllBundles_1000 + * @tc.desc : Test SetNotificationsEnabledForAllBundles function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_246000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + ASSERT_EQ(advancedNotificationService_->SetNotificationsEnabledForAllBundles( + std::string(), true), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_247000 + * @tc.name : SetNotificationsEnabledForSpecialBundle_1000 + * @tc.desc : Test SetNotificationsEnabledForSpecialBundle function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_247000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + ASSERT_EQ(advancedNotificationService_->SetNotificationsEnabledForSpecialBundle( + std::string(), new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), false), + ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_248000 + * @tc.name : IsAllowedNotify_1000 + * @tc.desc : Test IsAllowedNotify function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_248000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + bool allowed = false; + ASSERT_EQ(advancedNotificationService_->IsAllowedNotify(allowed), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_249000 + * @tc.name : IsAllowedNotify_2000 + * @tc.desc : Test IsAllowedNotify function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_249000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + bool allowed = false; + ASSERT_EQ(advancedNotificationService_->IsAllowedNotify(allowed), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_250000 + * @tc.name : GetAppTargetBundle_1000 + * @tc.desc : Test GetAppTargetBundle function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_250000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + sptr targetBundle(nullptr); + bundleOption->SetBundleName("test"); + ASSERT_EQ(advancedNotificationService_->GetAppTargetBundle(bundleOption, targetBundle), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_251000 + * @tc.name : IsSpecialBundleAllowedNotify_1000 + * @tc.desc : Test IsSpecialBundleAllowedNotify function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_251000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + bool allowed = true; + ASSERT_EQ(advancedNotificationService_->IsSpecialBundleAllowedNotify( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), allowed), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_252000 + * @tc.name : IsSpecialBundleAllowedNotify_2000 + * @tc.desc : Test IsSpecialBundleAllowedNotify function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_252000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + bool allowed = true; + ASSERT_EQ(advancedNotificationService_->IsSpecialBundleAllowedNotify( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), allowed), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_254000 + * @tc.name : IsSpecialBundleAllowedNotify_4000 + * @tc.desc : Test IsSpecialBundleAllowedNotify function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_254000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(true); + + MockIsNonBundleName(true); + bool allowed = true; + ASSERT_EQ(advancedNotificationService_->IsSpecialBundleAllowedNotify( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), allowed), ERR_ANS_INVALID_BUNDLE); +} + +/** + * @tc.number : AnsBranchTest_255000 + * @tc.name : RemoveNotification_1000 + * @tc.desc : Test RemoveNotification function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_255000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + int32_t notificationId = 1; + std::string label = "testRemove"; + auto result = advancedNotificationService_->RemoveNotification( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), + notificationId, label, NotificationConstant::CANCEL_REASON_DELETE); + ASSERT_EQ(result, ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_256000 + * @tc.name : RemoveAllNotifications_1000 + * @tc.desc : Test RemoveAllNotifications function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_256000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + ASSERT_EQ(advancedNotificationService_->RemoveAllNotifications(bundleOption), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_257000 + * @tc.name : GetSlotNumAsBundle_1000 + * @tc.desc : Test GetSlotNumAsBundle function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_257000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + uint64_t num = 1; + ASSERT_EQ(advancedNotificationService_->GetSlotNumAsBundle(bundleOption, num), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_258000 + * @tc.name : GetSlotNumAsBundle_2000 + * @tc.desc : Test GetSlotNumAsBundle function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_258000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + uint64_t num = 1; + ASSERT_EQ(advancedNotificationService_->GetSlotNumAsBundle(bundleOption, num), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_259000 + * @tc.name : RemoveGroupByBundle_2000 + * @tc.desc : Test RemoveGroupByBundle function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_259000, Function | SmallTest | Level1) +{ + MockVerifyNativeToken(false); + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + std::string groupName = "group"; + ASSERT_EQ(advancedNotificationService_->RemoveGroupByBundle(bundleOption, groupName), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_260000 + * @tc.name : SetDoNotDisturbDate_1000 + * @tc.desc : Test SetDoNotDisturbDate function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_260000, Function | SmallTest | Level1) +{ + MockVerifyNativeToken(false); + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + sptr date = + new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::NONE, 0, 0); + ASSERT_EQ(advancedNotificationService_->SetDoNotDisturbDate(date), ERR_ANS_NON_SYSTEM_APP); + ASSERT_EQ(advancedNotificationService_->GetDoNotDisturbDate(date), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_261000 + * @tc.name : SetDoNotDisturbDate_2000 + * @tc.desc : Test SetDoNotDisturbDate function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_261000, Function | SmallTest | Level1) +{ + MockVerifyNativeToken(false); + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + sptr date = + new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::NONE, 0, 0); + ASSERT_EQ(advancedNotificationService_->SetDoNotDisturbDate(date), ERR_ANS_PERMISSION_DENIED); + ASSERT_EQ(advancedNotificationService_->GetDoNotDisturbDate(date), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_262000 + * @tc.name : DoesSupportDoNotDisturbMode_1000 + * @tc.desc : Test DoesSupportDoNotDisturbMode function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_262000, Function | SmallTest | Level1) +{ + MockIsSystemApp(false); + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + + bool doesSupport = true; + ASSERT_EQ(advancedNotificationService_->DoesSupportDoNotDisturbMode(doesSupport), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_263000 + * @tc.name : DoesSupportDoNotDisturbMode_2000 + * @tc.desc : Test DoesSupportDoNotDisturbMode function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_263000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + bool doesSupport = true; + ASSERT_EQ(advancedNotificationService_->DoesSupportDoNotDisturbMode(doesSupport), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_264000 + * @tc.name : EnableDistributed_1000 + * @tc.desc : Test EnableDistributed function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_264000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + bool enabled = true; + sptr bundleOption = + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + ASSERT_EQ(advancedNotificationService_->EnableDistributed(enabled), ERR_ANS_NON_SYSTEM_APP); + ASSERT_EQ(advancedNotificationService_->EnableDistributedByBundle(bundleOption, enabled), ERR_ANS_NON_SYSTEM_APP); + ASSERT_EQ(advancedNotificationService_->IsDistributedEnableByBundle(bundleOption, enabled), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_284000 + * @tc.name : EnableDistributed_2000 + * @tc.desc : Test EnableDistributed function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_284000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + bool enabled = true; + sptr bundleOption = + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + ASSERT_EQ(advancedNotificationService_->EnableDistributed(enabled), ERR_ANS_PERMISSION_DENIED); + ASSERT_EQ(advancedNotificationService_->EnableDistributedByBundle( + bundleOption, enabled), ERR_ANS_PERMISSION_DENIED); + ASSERT_EQ(advancedNotificationService_->IsDistributedEnableByBundle( + bundleOption, enabled), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_265000 + * @tc.name : GetDeviceRemindType_1000 + * @tc.desc : Test GetDeviceRemindType function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_265000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; + ASSERT_EQ(advancedNotificationService_->GetDeviceRemindType(remindType), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_266000 + * @tc.name : GetDeviceRemindType_2000 + * @tc.desc : Test GetDeviceRemindType function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_266000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; + ASSERT_EQ(advancedNotificationService_->GetDeviceRemindType(remindType), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_267000 + * @tc.name : IsSpecialUserAllowedNotify_1000 + * @tc.desc : Test IsSpecialUserAllowedNotify function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_267000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + int32_t userId = 3; + bool allowed = true; + bool enable = true; + ASSERT_EQ(advancedNotificationService_->IsSpecialUserAllowedNotify( + userId, allowed), (int)ERR_ANS_PERMISSION_DENIED); + ASSERT_EQ(advancedNotificationService_->SetNotificationsEnabledByUser( + userId, enable), (int)ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_267100 + * @tc.name : IsSpecialUserAllowedNotify_1000 + * @tc.desc : Test IsSpecialUserAllowedNotify function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_267100, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + int32_t userId = 3; + bool allowed = true; + bool enable = true; + ASSERT_EQ(advancedNotificationService_->IsSpecialUserAllowedNotify( + userId, allowed), (int)ERR_ANS_NON_SYSTEM_APP); + ASSERT_EQ(advancedNotificationService_->SetNotificationsEnabledByUser( + userId, enable), (int)ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_268000 + * @tc.name : SetDoNotDisturbDate_1000 + * @tc.desc : Test SetDoNotDisturbDate function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_268000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + int32_t userId = 3; + sptr date = nullptr; + ASSERT_EQ(advancedNotificationService_->SetDoNotDisturbDate(userId, date), ERR_ANS_NON_SYSTEM_APP); + ASSERT_EQ(advancedNotificationService_->GetDoNotDisturbDate(userId, date), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_269000 + * @tc.name : SetDoNotDisturbDate_2000 + * @tc.desc : Test SetDoNotDisturbDate function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_269000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + int32_t userId = 3; + sptr date = nullptr; + ASSERT_EQ(advancedNotificationService_->SetDoNotDisturbDate(userId, date), ERR_ANS_PERMISSION_DENIED); + ASSERT_EQ(advancedNotificationService_->GetDoNotDisturbDate(userId, date), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_270000 + * @tc.name : SetEnabledForBundleSlot_1000 + * @tc.desc : Test SetEnabledForBundleSlot function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_270000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + bool enabled = false; + bool isForceControl = false; + auto result = advancedNotificationService_->SetEnabledForBundleSlot( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), + NotificationConstant::SlotType::SOCIAL_COMMUNICATION, enabled, false); + + ASSERT_EQ(result, ERR_ANS_PERMISSION_DENIED); + auto result1 = advancedNotificationService_->GetEnabledForBundleSlot( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), + NotificationConstant::SlotType::SOCIAL_COMMUNICATION, enabled); + ASSERT_EQ(result1, ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_271000 + * @tc.name : SetEnabledForBundleSlot_1000 + * @tc.desc : Test SetEnabledForBundleSlot function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_271000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockVerifyShellToken(false); + + std::string cmd = "CMD"; + std::string bundle = "Bundle"; + int32_t userId = 4; + std::vector dumpInfo; + ASSERT_EQ(advancedNotificationService_->ShellDump( + cmd, bundle, userId, 0, dumpInfo), (int)ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_272000 + * @tc.name : SetSyncNotificationEnabledWithoutApp_1000 + * @tc.desc : Test SetSyncNotificationEnabledWithoutApp function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_272000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + + int32_t userId = 3; + bool enabled = true; + ASSERT_EQ(advancedNotificationService_->SetSyncNotificationEnabledWithoutApp( + userId, enabled), ERR_ANS_NON_SYSTEM_APP); + ASSERT_EQ(advancedNotificationService_->GetSyncNotificationEnabledWithoutApp( + userId, enabled), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_273000 + * @tc.name : SetSyncNotificationEnabledWithoutApp_2000 + * @tc.desc : Test SetSyncNotificationEnabledWithoutApp function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_273000, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + + int32_t userId = 3; + bool enabled = true; + ASSERT_EQ(advancedNotificationService_->SetSyncNotificationEnabledWithoutApp( + userId, enabled), ERR_ANS_PERMISSION_DENIED); + ASSERT_EQ(advancedNotificationService_->GetSyncNotificationEnabledWithoutApp( + userId, enabled), ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_274000 + * @tc.name : EnableDistributedByBundle_3000 + * @tc.desc : Test EnableDistributedByBundle function return ERR_ANS_NON_SYSTEM_APP. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_274000, Function | SmallTest | Level1) +{ + MockGetDistributedEnableInApplicationInfo(false, 2); + MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + bool enabled = true; + sptr bundleOption = + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + ASSERT_EQ(advancedNotificationService_->EnableDistributedByBundle( + bundleOption, enabled), ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.number : AnsBranchTest_275000 + * @tc.name : EnableDistributedSelf_2000 + * @tc.desc : Test EnableDistributedSelf function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_275000, Function | SmallTest | Level1) +{ + MockDistributedNotificationEnabled(false); + MockIsNonBundleName(false); + bool enabled = true; + ASSERT_EQ(advancedNotificationService_->EnableDistributedSelf(enabled), (int)ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.number : AnsBranchTest_276000 + * @tc.name : IsDistributedEnableByBundle_3000 + * @tc.desc : Test IsDistributedEnableByBundle function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_276000, Function | SmallTest | Level1) +{ + MockVerifyNativeToken(true); + MockGetDistributedEnableInApplicationInfo(true, 2); + sptr bundleOption = new NotificationBundleOption( + TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + bool enabled = false; + ASSERT_EQ(advancedNotificationService_->IsDistributedEnableByBundle(bundleOption, enabled), ERR_OK); +} + +/** + * @tc.number : AnsBranchTest_277000 + * @tc.name : DoDistributedPublish_3000 + * @tc.desc : Test DoDistributedPublish function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_277000, Function | SmallTest | Level1) +{ + MockGetDistributedEnableInApplicationInfo(false, 2); + MockGetOsAccountLocalIdFromUid(false, 1); + MockDistributedNotificationEnabled(false); + sptr bundleOption = new NotificationBundleOption( + TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + std::shared_ptr record = nullptr; + ASSERT_EQ(advancedNotificationService_->DoDistributedPublish(bundleOption, record), ERR_OK); +} + +/** + * @tc.number : AnsBranchTest_278000 + * @tc.name : GetDistributedEnableInApplicationInfo_3000 + * @tc.desc : Test GetDistributedEnableInApplicationInfo function return ERR_ANS_PERMISSION_DENIED. + * @tc.require : #I6P8UI + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_278000, Function | SmallTest | Level1) +{ + MockGetOsAccountLocalIdFromUid(false, 3); + sptr bundleOption = new NotificationBundleOption( + TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + bool enabled = false;; + ASSERT_EQ(advancedNotificationService_->GetDistributedEnableInApplicationInfo( + bundleOption, enabled), ERR_ANS_INVALID_PARAM); +} + +void AnsBranchTest::InitNotificationRecord(std::shared_ptr &record, + const NotificationLiveViewContent::LiveViewStatus &status) +{ + NotificationRequest notificationRequest; + notificationRequest.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + auto liveContent = std::make_shared(); + liveContent->SetLiveViewStatus(status); + auto content = std::make_shared(liveContent); + notificationRequest.SetContent(content); + + record->request = sptr::MakeSptr(notificationRequest); + record->notification = new (std::nothrow) Notification(record->request); +} + +/** + * @tc.number : AnsBranchTest_279000 + * @tc.name : UpdateNotificationTimerInfo_0001 + * @tc.desc : Check set update and finish timer when create notification request + * @tc.require : issue + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_279000, Function | SmallTest | Level1) +{ + using Status = NotificationLiveViewContent::LiveViewStatus; + auto record = std::make_shared(); + InitNotificationRecord(record, Status::LIVE_VIEW_CREATE); + ASSERT_EQ(record->notification->GetFinishTimer(), NotificationConstant::INVALID_TIMER_ID); + ASSERT_EQ(record->notification->GetUpdateTimer(), NotificationConstant::INVALID_TIMER_ID); + auto result = advancedNotificationService_->UpdateNotificationTimerInfo(record); + ASSERT_EQ(result, ERR_OK); + EXPECT_NE(record->notification->GetFinishTimer(), NotificationConstant::INVALID_TIMER_ID); + EXPECT_NE(record->notification->GetUpdateTimer(), NotificationConstant::INVALID_TIMER_ID); +} + +/** + * @tc.number : AnsBranchTest_279001 + * @tc.name : UpdateNotificationTimerInfo_0002 + * @tc.desc : Check set update and finish timer when update notification request + * @tc.require : issue + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_279001, Function | SmallTest | Level1) +{ + using Status = NotificationLiveViewContent::LiveViewStatus; + auto record = std::make_shared(); + InitNotificationRecord(record, Status::LIVE_VIEW_INCREMENTAL_UPDATE); + record->notification->SetUpdateTimer(2); + record->notification->SetFinishTimer(3); + auto result = advancedNotificationService_->UpdateNotificationTimerInfo(record); + ASSERT_EQ(result, ERR_OK); + /* finish timer not change, but update timer changed */ + EXPECT_NE(record->notification->GetUpdateTimer(), 2); + ASSERT_EQ(record->notification->GetFinishTimer(), 3); +} + +/** + * @tc.number : AnsBranchTest_279002 + * @tc.name : UpdateNotificationTimerInfo_0003 + * @tc.desc : Check cancel update and finish timer when end notification request + * @tc.require : issue + */ +HWTEST_F(AnsBranchTest, AnsBranchTest_279002, Function | SmallTest | Level1) +{ + using Status = NotificationLiveViewContent::LiveViewStatus; + auto record = std::make_shared(); + InitNotificationRecord(record, Status::LIVE_VIEW_END); + record->notification->SetUpdateTimer(2); + record->notification->SetFinishTimer(3); + + auto result = advancedNotificationService_->UpdateNotificationTimerInfo(record); + ASSERT_EQ(result, ERR_OK); + /* finish timer not change, but update timer changed */ + ASSERT_EQ(record->notification->GetUpdateTimer(), NotificationConstant::INVALID_TIMER_ID); + ASSERT_EQ(record->notification->GetFinishTimer(), NotificationConstant::INVALID_TIMER_ID); +} + +} // namespace Notification +} // namespace OHOS diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index ead5526cf..c4d103b58 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -1552,6 +1552,10 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17100, ASSERT_EQ(advancedNotificationService_->GetSyncNotificationEnabledWithoutApp(userId, enable), ERR_OK); + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + ASSERT_EQ(advancedNotificationService_->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType), ERR_OK); + GTEST_LOG_(INFO) << "ANS_GetActiveNotifications_0100 test end"; } @@ -2419,6 +2423,23 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_220000 ASSERT_EQ(result.size(), ret); } +/** + * @tc.number : AdvancedNotificationServiceTest_22600 + * @tc.name : ANS_IsNeedSilentInDoNotDisturbMode_0100 + * @tc.desc : Test IsNeedSilentInDoNotDisturbMode function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_22600, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + std::string phoneNumber = "11111111111"; + int32_t callerType = 0; + auto ret = advancedNotificationService_->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); + ASSERT_EQ(ret, (int)ERR_OK); +} + /** * @tc.number : AdvancedNotificationServiceTest_00001 * @tc.name : PrepareNotificationRequest diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp.orig b/services/ans/test/unittest/advanced_notification_service_test.cpp.orig new file mode 100644 index 000000000..ead5526cf --- /dev/null +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp.orig @@ -0,0 +1,3736 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "errors.h" +#include "notification_content.h" +#include "notification_record.h" +#include "notification_request.h" +#include +#include +#include +#include + +#include "gtest/gtest.h" +#include + +#define private public + +#include "advanced_notification_service.h" +#include "ans_const_define.h" +#include "ans_inner_errors.h" +#include "ans_log_wrapper.h" +#include "ans_notification.h" +#include "ans_ut_constant.h" +#include "common_event_manager.h" +#include "common_event_support.h" +#include "iremote_object.h" +#include "mock_ipc_skeleton.h" +#include "notification_preferences.h" +#include "notification_subscriber.h" +#include "notification_subscriber_manager.h" +#include "mock_push_callback_stub.h" +#include "system_event_observer.h" +#include "notification_constant.h" +#include "want_agent_info.h" +#include "want_agent_helper.h" +#include "want_params.h" +#include "bundle_manager_helper.h" + +extern void MockIsOsAccountExists(bool mockRet); + +using namespace testing::ext; +using namespace OHOS::Media; + +namespace OHOS { +namespace Notification { +extern void MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum mockRet); +extern void MockIsSystemApp(bool isSystemApp); +extern void MockIsNonBundleName(bool isNonBundleName); +extern void MockIsVerfyPermisson(bool isVerify); + +class AdvancedNotificationServiceTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); + +private: + void TestAddSlot(NotificationConstant::SlotType type); + void TestAddLiveViewSlot(bool isForceControl); + void MockSystemApp(); + +private: + static sptr advancedNotificationService_; +}; + +sptr AdvancedNotificationServiceTest::advancedNotificationService_ = nullptr; + +void AdvancedNotificationServiceTest::SetUpTestCase() +{ + MockIsOsAccountExists(true); +} + +void AdvancedNotificationServiceTest::TearDownTestCase() {} + +void AdvancedNotificationServiceTest::SetUp() +{ + GTEST_LOG_(INFO) << "SetUp start"; + + advancedNotificationService_ = new (std::nothrow) AdvancedNotificationService(); + IPCSkeleton::SetCallingTokenID(NATIVE_TOKEN); + NotificationPreferences::GetInstance()->ClearNotificationInRestoreFactorySettings(); + IPCSkeleton::SetCallingUid(SYSTEM_APP_UID); + advancedNotificationService_->CancelAll(0); + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE); + GTEST_LOG_(INFO) << "SetUp end"; +} + +void AdvancedNotificationServiceTest::TearDown() +{ + IPCSkeleton::SetCallingUid(SYSTEM_APP_UID); + advancedNotificationService_ = nullptr; + GTEST_LOG_(INFO) << "TearDown"; +} + +inline void SleepForFC() +{ + // For ANS Flow Control + std::this_thread::sleep_for(std::chrono::seconds(1)); +} + +class TestAnsSubscriber : public NotificationSubscriber { +public: + void OnDoNotDisturbDateChange(const std::shared_ptr &date) override + {} + void OnConnected() override + {} + void OnDisconnected() override + {} + void OnDied() override + {} + void OnUpdate(const std::shared_ptr &sortingMap) override + {} + void OnBadgeChanged(const std::shared_ptr &badgeData) override + {} + void OnBadgeEnabledChanged( + const sptr &callbackData) override + {} + void OnEnabledNotificationChanged( + const std::shared_ptr &callbackData) override + {} + void OnCanceled(const std::shared_ptr &request, + const std::shared_ptr &sortingMap, int32_t deleteReason) override + {} + void OnConsumed(const std::shared_ptr &request, + const std::shared_ptr &sortingMap) override + {} + void OnBatchCanceled(const std::vector> + &requestList, const std::shared_ptr &sortingMap, int32_t deleteReason) override + {} +}; + +void AdvancedNotificationServiceTest::TestAddSlot(NotificationConstant::SlotType type) +{ + MockSystemApp(); + std::vector> slots; + sptr slot = new NotificationSlot(type); + slots.push_back(slot); + ASSERT_EQ(advancedNotificationService_->AddSlots(slots), (int)ERR_OK); +} + +void AdvancedNotificationServiceTest::MockSystemApp() +{ + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + MockIsVerfyPermisson(true); +} + +void AdvancedNotificationServiceTest::TestAddLiveViewSlot(bool isForceControl) +{ + MockSystemApp(); + std::vector> slots; + sptr slot = new NotificationSlot(NotificationConstant::SlotType::LIVE_VIEW); + slot->SetForceControl(isForceControl); + slots.push_back(slot); + ASSERT_EQ(advancedNotificationService_->AddSlots(slots), (int)ERR_OK); +} + + +/** + * @tc.number : AdvancedNotificationServiceTest_01600 + * @tc.name : ANS_GetSlot_0200 + * @tc.desc : Test GetSlots function when add two identical data + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_01600, Function | SmallTest | Level1) +{ + MockSystemApp(); + std::vector> slots; + sptr slot0 = new NotificationSlot(NotificationConstant::OTHER); + sptr slot1 = new NotificationSlot(NotificationConstant::OTHER); + slots.push_back(slot0); + slots.push_back(slot1); + std::vector> slotsResult; + advancedNotificationService_->AddSlots(slots); + advancedNotificationService_->GetSlots(slotsResult); + ASSERT_EQ((int)slots.size(), 2); + ASSERT_EQ((int)slotsResult.size(), 1); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_01800 + * @tc.name : ANS_SetNotificationBadgeNum_0100 + * @tc.desc : Test SetNotificationBadgeNum function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_01800, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + ASSERT_EQ((int)advancedNotificationService_->SetNotificationBadgeNum(2), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_01900 + * @tc.name : ANS_GetBundleImportance_0100 + * @tc.desc : Test GetBundleImportance function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_01900, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + int importance; + ASSERT_EQ((int)advancedNotificationService_->GetBundleImportance(importance), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_02200 + * @tc.name : ANS_UpdateSlots_0100 + * @tc.desc : Test UpdateSlots function when no slot + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_02200, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + std::vector> slots; + sptr slot0 = new NotificationSlot(NotificationConstant::OTHER); + slots.push_back(slot0); + ASSERT_EQ((int)advancedNotificationService_->UpdateSlots( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), slots), + (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_TYPE_NOT_EXIST); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_02300 + * @tc.name : ANS_UpdateSlots_0200 + * @tc.desc : Test UpdateSlots function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_02300, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + std::vector> slots; + sptr slot0 = new NotificationSlot(NotificationConstant::OTHER); + slots.push_back(slot0); + ASSERT_EQ((int)advancedNotificationService_->UpdateSlots( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), slots), + (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_02700 + * @tc.name : ANS_SetShowBadgeEnabledForBundle_0100 + * @tc.desc : Test the SetShowBadgeEnabledForBundle function when the parameter is wrong + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_02700, Function | SmallTest | Level1) +{ + ASSERT_EQ(advancedNotificationService_->SetShowBadgeEnabledForBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), true), + (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_02800 + * @tc.name : ANS_GetShowBadgeEnabledForBundle_0100 + * @tc.desc : Test GetShowBadgeEnabledForBundle function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_02800, Function | SmallTest | Level1) +{ + ASSERT_EQ(advancedNotificationService_->SetShowBadgeEnabledForBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), true), + (int)ERR_OK); + bool allow = false; + ASSERT_EQ((int)advancedNotificationService_->GetShowBadgeEnabledForBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), allow), + (int)ERR_OK); + EXPECT_TRUE(allow); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_02900 + * @tc.name : ANS_GetActiveNotifications_0100 + * @tc.desc : Test GetActiveNotifications function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_02900, Function | SmallTest | Level1) +{ + std::vector> notifications; + ASSERT_EQ((int)advancedNotificationService_->GetActiveNotifications(notifications, 0), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_03000 + * @tc.name : ANS_SetTargetDeviceStatus_0100 + * @tc.desc : Test SetTargetDeviceStatus function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03000, Function | SmallTest | Level1) +{ + const std::string device = "current"; + const uint32_t status = 1; + ASSERT_EQ((int)advancedNotificationService_->SetTargetDeviceStatus(device, status), + (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_03100 + * @tc.name : ANS_ClearAllNotificationGroupInfo_0100 + * @tc.desc : Test ClearAllNotificationGroupInfo function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03100, Function | SmallTest | Level1) +{ + const std::string localSwitch = "current"; + advancedNotificationService_->ClearAllNotificationGroupInfo(localSwitch); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_03200 + * @tc.name : ANS_UpdateUnifiedGroupInfo_0100 + * @tc.desc : Test UpdateUnifiedGroupInfo function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03200, Function | SmallTest | Level1) +{ + const std::string key = "key"; + std::shared_ptr groupInfo; + advancedNotificationService_->UpdateUnifiedGroupInfo(key, groupInfo); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_03300 + * @tc.name : ANS_RemoveSystemLiveViewNotificationsOfSa_0100 + * @tc.desc : Test RemoveSystemLiveViewNotificationsOfSa function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03300, Function | SmallTest | Level1) +{ + sptr request = new (std::nothrow) NotificationRequest(); + sptr notification = new (std::nothrow) Notification(request); + auto record = std::make_shared(); + record->request = request; + record->notification = notification; + advancedNotificationService_->notificationList_.push_back(record); + int32_t uid = 0; + ASSERT_EQ((int)advancedNotificationService_->RemoveSystemLiveViewNotificationsOfSa(uid), + (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_03400 + * @tc.name : ANS_IsAllowedNotifyForBundle_0100 + * @tc.desc : Test IsAllowedNotifyForBundle function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03400, Function | SmallTest | Level1) +{ + bool allowed = false; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + auto ret = advancedNotificationService_->IsAllowedNotifyForBundle(bundleOption, allowed); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_03500 + * @tc.name : ANS_CancelAsBundleWithAgent_0100 + * @tc.desc : Test CancelAsBundleWithAgent function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03500, Function | SmallTest | Level1) +{ + int32_t id = 0; + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + auto ret = advancedNotificationService_->CancelAsBundleWithAgent(bundleOption, id); + ASSERT_EQ(ret, (int)ERR_ANS_NOTIFICATION_NOT_EXISTS); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_03600 + * @tc.name : ANS_AddDoNotDisturbProfiles_0100 + * @tc.desc : Test AddDoNotDisturbProfiles function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03600, Function | SmallTest | Level1) +{ + sptr date = nullptr; + std::vector> profiles = { date }; + auto ret = advancedNotificationService_->AddDoNotDisturbProfiles(profiles); + ASSERT_EQ(ret, (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_03700 + * @tc.name : ANS_Delete_0100 + * @tc.desc : Test Delete function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03700, Function | SmallTest | Level1) +{ + const std::string key = "key"; + ASSERT_EQ((int)advancedNotificationService_->Delete(key, NotificationConstant::CANCEL_REASON_DELETE), + (int)ERR_ANS_NOTIFICATION_NOT_EXISTS); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_03800 + * @tc.name : ANS_DeleteByBundle_0100 + * @tc.desc : Test DeleteByBundle function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03800, Function | SmallTest | Level1) +{ + ASSERT_EQ(advancedNotificationService_->DeleteByBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID)), + ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_03900 + * @tc.name : ANS_DeleteAll_0100 + * @tc.desc : Test DeleteAll function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03900, Function | SmallTest | Level1) +{ + ASSERT_EQ(advancedNotificationService_->DeleteAll(), ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_04000 + * @tc.name : ANS_GetSlotsByBundle_0100 + * @tc.desc : Test GetSlotsByBundle function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_04000, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + std::vector> slots; + ASSERT_EQ(advancedNotificationService_->GetSlotsByBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), slots), + ERR_OK); + ASSERT_EQ(slots.size(), (size_t)1); +} + + +/** + * @tc.number : AdvancedNotificationServiceTest_04200 + * @tc.name : ANS_AddDoNotDisturbProfiles_0100 + * @tc.desc : Test AddDoNotDisturbProfiles function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_04200, Function | SmallTest | Level1) +{ + sptr date = nullptr; + std::vector> profiles = { date }; + auto ret = advancedNotificationService_->RemoveDoNotDisturbProfiles(profiles); + ASSERT_EQ(ret, (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_04300 + * @tc.name : ANS_AddDoNotDisturbProfiles_0100 + * @tc.desc : Test AddDoNotDisturbProfiles function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_04300, Function | SmallTest | Level1) +{ + sptr request(new NotificationRequest()); + std::string bundleName = "bundleName"; + advancedNotificationService_->SetAgentNotification(request, bundleName); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_04400 + * @tc.name : ANS_AddDoNotDisturbProfiles_0100 + * @tc.desc : Test AddDoNotDisturbProfiles function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_04400, Function | SmallTest | Level1) +{ + std::string enable = "enable"; + auto ret = advancedNotificationService_->GetUnifiedGroupInfoFromDb(enable); + ASSERT_EQ(ret, -1); +} + + +/** + * @tc.number : AdvancedNotificationServiceTest_05100 + * @tc.name : ANS_AddSlots_0100 + * @tc.desc : Test AddSlots function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_05100, Function | SmallTest | Level1) +{ + MockSystemApp(); + std::vector> slots; + sptr slot0 = new NotificationSlot(NotificationConstant::OTHER); + sptr slot1 = new NotificationSlot(NotificationConstant::OTHER); + slots.push_back(slot0); + slots.push_back(slot1); + ASSERT_EQ(advancedNotificationService_->AddSlots(slots), ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_05200 + * @tc.name : ANS_RemoveSlotByType_0100 + * @tc.desc : Test RemoveSlotByType function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_05200, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + ASSERT_EQ(advancedNotificationService_->RemoveSlotByType(NotificationConstant::OTHER), ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_05300 + * @tc.name : ANS_RemoveSlotByType_0200 + * @tc.desc : Test RemoveSlotByType function when no type + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_05300, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + ASSERT_EQ((int)advancedNotificationService_->RemoveSlotByType(NotificationConstant::CUSTOM), 0); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_05600 + * @tc.name : ANS_GetSlot_0100 + * @tc.desc : Test GetSlot function for data + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_05600, Function | SmallTest | Level1) +{ + std::vector> slots; + sptr slot = new NotificationSlot(NotificationConstant::OTHER); + sptr slot0 = new NotificationSlot(NotificationConstant::OTHER); + slots.push_back(slot0); + advancedNotificationService_->AddSlots(slots); + ASSERT_EQ((int)advancedNotificationService_->GetSlotByType(NotificationConstant::OTHER, slot), ERR_OK); + ASSERT_EQ(slot->GetName(), slot0->GetName()); + ASSERT_EQ(slot->GetId(), slot0->GetId()); + ASSERT_EQ(slot->GetLevel(), slot0->GetLevel()); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_05900 + * @tc.name : ANS_SetNotificationBadgeNum_0100 + * @tc.desc : Test SetNotificationBadgeNum function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_05900, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + ASSERT_EQ((int)advancedNotificationService_->SetNotificationBadgeNum(2), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_06000 + * @tc.name : ANS_GetBundleImportance_0100 + * @tc.desc : Test GetBundleImportance function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06000, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + int importance = 0; + ASSERT_EQ((int)advancedNotificationService_->GetBundleImportance(importance), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_06300 + * @tc.name : ANS_UpdateSlots_0100 + * @tc.desc : Test UpdateSlots function when no slot + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06300, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + std::vector> slots; + sptr slot0 = new NotificationSlot(NotificationConstant::OTHER); + slots.push_back(slot0); + ASSERT_EQ((int)advancedNotificationService_->UpdateSlots( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), slots), + (int)ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_TYPE_NOT_EXIST); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_06400 + * @tc.name : ANS_UpdateSlots_0200 + * @tc.desc : Test UpdateSlots function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06400, Function | SmallTest | Level1) +{ + std::vector> slots; + TestAddSlot(NotificationConstant::SlotType::OTHER); + sptr slot0 = new NotificationSlot(NotificationConstant::OTHER); + slots.push_back(slot0); + ASSERT_EQ((int)advancedNotificationService_->UpdateSlots( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), slots), + (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_06800 + * @tc.name : ANS_SetShowBadgeEnabledForBundle_0100 + * @tc.desc : Test the SetShowBadgeEnabledForBundle function when the parameter is wrong + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06800, Function | SmallTest | Level1) +{ + ASSERT_EQ(advancedNotificationService_->SetShowBadgeEnabledForBundle( + new NotificationBundleOption("", SYSTEM_APP_UID), true), + (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_06900 + * @tc.name : ANS_GetShowBadgeEnabledForBundle_0100 + * @tc.desc : Test GetShowBadgeEnabledForBundle function when no bundle + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06900, Function | SmallTest | Level1) +{ + bool allow = false; + ASSERT_EQ((int)advancedNotificationService_->GetShowBadgeEnabledForBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), allow), + (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_07000 + * @tc.name : ANS_GetActiveNotifications_0100 + * @tc.desc : Test GetActiveNotifications function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_07000, Function | SmallTest | Level1) +{ + std::vector> notifications; + ASSERT_EQ((int)advancedNotificationService_->GetActiveNotifications(notifications, 0), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_07800 + * @tc.name : ANS_Delete_0100 + * @tc.desc : Test Delete function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_07800, Function | SmallTest | Level1) +{ + const std::string key = "key"; + ASSERT_EQ((int)advancedNotificationService_->Delete(key, NotificationConstant::CANCEL_REASON_DELETE), + (int)ERR_ANS_NOTIFICATION_NOT_EXISTS); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_07900 + * @tc.name : ANS_DeleteByBundle_0100 + * @tc.desc : Test DeleteByBundle function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_07900, Function | SmallTest | Level1) +{ + ASSERT_EQ(advancedNotificationService_->DeleteByBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID)), + ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_08000 + * @tc.name : ANS_DeleteAll_0100 + * @tc.desc : Test DeleteAll function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_08000, Function | SmallTest | Level1) +{ + ASSERT_EQ(advancedNotificationService_->DeleteAll(), ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_08300 + * @tc.name : ANS_Subscribe_0100 + * @tc.desc : Test Subscribe function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_08300, Function | SmallTest | Level1) +{ + auto subscriber = new TestAnsSubscriber(); + sptr info = new NotificationSubscribeInfo(); + EXPECT_NE((int)advancedNotificationService_->Subscribe(subscriber->GetImpl(), info), (int)ERR_OK); + ASSERT_EQ((int)advancedNotificationService_->Subscribe(nullptr, info), (int)ERR_ANS_INVALID_PARAM); + EXPECT_NE((int)advancedNotificationService_->Unsubscribe(subscriber->GetImpl(), nullptr), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_08600 + * @tc.name : ANS_GetShowBadgeEnabledForBundle_0200 + * @tc.desc : Test GetShowBadgeEnabledForBundle function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_08600, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + ASSERT_EQ((int)advancedNotificationService_->SetShowBadgeEnabledForBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), true), + (int)ERR_OK); + bool allow = false; + ASSERT_EQ((int)advancedNotificationService_->GetShowBadgeEnabledForBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), allow), + (int)ERR_OK); + EXPECT_TRUE(allow); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_08700 + * @tc.name : ANS_GetSlotByType_0100 + * @tc.desc : Test GetSlotByType function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_08700, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + sptr slot = new NotificationSlot(NotificationConstant::SlotType::OTHER); + ASSERT_EQ((int)advancedNotificationService_->GetSlotByType(NotificationConstant::OTHER, slot), (int)ERR_OK); + ASSERT_EQ(slot->GetType(), NotificationConstant::SlotType::OTHER); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_09000 + * @tc.name : ANS_GetAllActiveNotifications_0100 + * @tc.desc : Test GetAllActiveNotifications function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_09000, Function | SmallTest | Level1) +{ + std::vector> notifications; + ASSERT_EQ(advancedNotificationService_->GetAllActiveNotifications(notifications), ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_09200 + * @tc.name : ANS_SetNotificationsEnabledForAllBundles_0200 + * @tc.desc : Test SetNotificationsEnabledForAllBundles function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_09200, Function | SmallTest | Level1) +{ + ASSERT_EQ( + (int)advancedNotificationService_->SetNotificationsEnabledForAllBundles(std::string(), true), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_09300 + * @tc.name : ANS_SetNotificationsEnabledForSpecialBundle_0100 + * @tc.desc : Test SetNotificationsEnabledForSpecialBundle function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_09300, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + std::vector> notifications; + ASSERT_EQ((int)advancedNotificationService_->SetNotificationsEnabledForSpecialBundle( + std::string(), new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), true), + (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_09500 + * @tc.name : ANS_IsAllowedNotify_0100 + * @tc.desc : Test IsAllowedNotify function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_09500, Function | SmallTest | Level1) +{ + ASSERT_EQ( + (int)advancedNotificationService_->SetNotificationsEnabledForAllBundles(std::string(), true), (int)ERR_OK); + bool allowed = false; + ASSERT_EQ((int)advancedNotificationService_->IsAllowedNotify(allowed), (int)ERR_OK); + EXPECT_TRUE(allowed); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_09600 + * @tc.name : ANS_IsAllowedNotifySelf_0100 + * @tc.desc : Test IsAllowedNotifySelf function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_09600, Function | SmallTest | Level1) +{ + MockSystemApp(); + ASSERT_EQ( + (int)advancedNotificationService_->SetNotificationsEnabledForAllBundles(std::string(), true), (int)ERR_OK); + bool allowed = false; + ASSERT_EQ((int)advancedNotificationService_->IsAllowedNotifySelf(allowed), (int)ERR_OK); + EXPECT_TRUE(allowed); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_09700 + * @tc.name : ANS_IsSpecialBundleAllowedNotify_0100 + * @tc.desc : Test IsSpecialBundleAllowedNotify function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_09700, Function | SmallTest | Level1) +{ + ASSERT_EQ( + (int)advancedNotificationService_->SetNotificationsEnabledForAllBundles(std::string(), true), (int)ERR_OK); + TestAddSlot(NotificationConstant::SlotType::OTHER); + bool allowed = true; + ASSERT_EQ((int)advancedNotificationService_->IsSpecialBundleAllowedNotify( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), allowed), + (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_09800 + * @tc.name : ANS_IsSpecialBundleAllowedNotify_0200 + * @tc.desc : Test IsSpecialBundleAllowedNotify function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_09800, Function | SmallTest | Level1) +{ + ASSERT_EQ( + (int)advancedNotificationService_->SetNotificationsEnabledForAllBundles(std::string(), true), (int)ERR_OK); + std::vector> notifications; + bool allowed = true; + ASSERT_EQ((int)advancedNotificationService_->IsSpecialBundleAllowedNotify( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID), allowed), + (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_09900 + * @tc.name : ANS_GetSlotsByBundle_0200 + * @tc.desc : Test GetSlotsByBundle function when no bundle + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_09900, Function | SmallTest | Level1) +{ + std::vector> slots; + ASSERT_EQ((int)advancedNotificationService_->GetSlotsByBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), slots), + (int)ERR_OK); +} + + +/** + * @tc.number : AdvancedNotificationServiceTest_10500 + * @tc.name : ANS_SetDisturbMode_10500 + * @tc.desc : Test SetDisturbMode function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_10500, Function | SmallTest | Level1) +{ + sptr date = + new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::NONE, 0, 0); + ASSERT_EQ((int)advancedNotificationService_->SetDoNotDisturbDate(date), (int)ERR_OK); + + std::chrono::system_clock::time_point timePoint = std::chrono::system_clock::now(); + auto beginDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + int64_t beginDate = beginDuration.count(); + timePoint += std::chrono::hours(1); + auto endDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + int64_t endDate = endDuration.count(); + date = new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::ONCE, beginDate, endDate); + ASSERT_EQ((int)advancedNotificationService_->SetDoNotDisturbDate(date), (int)ERR_OK); + + timePoint = std::chrono::system_clock::now(); + beginDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + beginDate = beginDuration.count(); + timePoint += std::chrono::hours(1); + endDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + endDate = endDuration.count(); + date = new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::DAILY, beginDate, endDate); + ASSERT_EQ((int)advancedNotificationService_->SetDoNotDisturbDate(date), (int)ERR_OK); + + timePoint = std::chrono::system_clock::now(); + beginDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + beginDate = beginDuration.count(); + timePoint += std::chrono::hours(1); + endDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + endDate = endDuration.count(); + date = new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::CLEARLY, beginDate, endDate); + ASSERT_EQ((int)advancedNotificationService_->SetDoNotDisturbDate(date), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_10600 + * @tc.name : ANS_GetDisturbMode_10600 + * @tc.desc : Test GetDisturbMode function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_10600, Function | SmallTest | Level1) +{ + sptr date = + new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::NONE, 0, 0); + + ASSERT_EQ((int)advancedNotificationService_->SetDoNotDisturbDate(date), (int)ERR_OK); + + sptr result = nullptr; + ASSERT_EQ((int)advancedNotificationService_->GetDoNotDisturbDate(result), (int)ERR_OK); + ASSERT_NE(result, nullptr); + ASSERT_EQ(result->GetDoNotDisturbType(), NotificationConstant::DoNotDisturbType::NONE); + ASSERT_EQ(result->GetBeginDate(), 0); + ASSERT_EQ(result->GetEndDate(), 0); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_10700 + * @tc.name : ANS_GetDisturbMode_10700 + * @tc.desc : Test GetDisturbMode function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_10700, Function | SmallTest | Level1) +{ + std::chrono::system_clock::time_point timePoint = std::chrono::system_clock::now(); + timePoint = std::chrono::time_point_cast(timePoint); + timePoint += std::chrono::hours(1); + auto beginDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + int64_t beginDate = beginDuration.count(); + timePoint += std::chrono::hours(1); + auto endDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + int64_t endDate = endDuration.count(); + + sptr date = + new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::ONCE, beginDate, endDate); + ASSERT_EQ((int)advancedNotificationService_->SetDoNotDisturbDate(date), (int)ERR_OK); + + sptr result = nullptr; + ASSERT_EQ((int)advancedNotificationService_->GetDoNotDisturbDate(result), (int)ERR_OK); + ASSERT_NE(result, nullptr); + ASSERT_EQ(result->GetDoNotDisturbType(), NotificationConstant::DoNotDisturbType::ONCE); + ASSERT_EQ(result->GetBeginDate(), beginDate); + ASSERT_EQ(result->GetEndDate(), endDate); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_10800 + * @tc.name : ANS_GetDisturbMode_10800 + * @tc.desc : Test GetDisturbMode function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_10800, Function | SmallTest | Level1) +{ + std::chrono::system_clock::time_point timePoint = std::chrono::system_clock::now(); + timePoint = std::chrono::time_point_cast(timePoint); + timePoint += std::chrono::hours(1); + auto beginDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + int64_t beginDate = beginDuration.count(); + timePoint += std::chrono::hours(1); + auto endDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + int64_t endDate = endDuration.count(); + + sptr date = + new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::DAILY, beginDate, endDate); + + ASSERT_EQ((int)advancedNotificationService_->SetDoNotDisturbDate(date), (int)ERR_OK); + sptr result = nullptr; + ASSERT_EQ((int)advancedNotificationService_->GetDoNotDisturbDate(result), (int)ERR_OK); + ASSERT_NE(result, nullptr); + ASSERT_EQ(result->GetDoNotDisturbType(), NotificationConstant::DoNotDisturbType::DAILY); + ASSERT_EQ(result->GetBeginDate(), beginDate); + ASSERT_EQ(result->GetEndDate(), endDate); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_10900 + * @tc.name : ANS_GetDisturbMode_10900 + * @tc.desc : Test GetDisturbMode function + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_10900, Function | SmallTest | Level1) +{ + std::chrono::system_clock::time_point timePoint = std::chrono::system_clock::now(); + timePoint = std::chrono::time_point_cast(timePoint); + timePoint += std::chrono::hours(1); + auto beginDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + int64_t beginDate = beginDuration.count(); + timePoint += std::chrono::hours(1); + auto endDuration = std::chrono::duration_cast(timePoint.time_since_epoch()); + int64_t endDate = endDuration.count(); + + sptr date = + new NotificationDoNotDisturbDate(NotificationConstant::DoNotDisturbType::CLEARLY, beginDate, endDate); + ASSERT_EQ((int)advancedNotificationService_->SetDoNotDisturbDate(date), (int)ERR_OK); + + sptr result = nullptr; + ASSERT_EQ((int)advancedNotificationService_->GetDoNotDisturbDate(result), (int)ERR_OK); + ASSERT_NE(result, nullptr); + ASSERT_EQ(result->GetDoNotDisturbType(), NotificationConstant::DoNotDisturbType::CLEARLY); + ASSERT_EQ(result->GetBeginDate(), beginDate); + ASSERT_EQ(result->GetEndDate(), endDate); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_12900 + * @tc.name : ANS_HasNotificationPolicyAccessPermission_0100 + * @tc.desc : Test HasNotificationPolicyAccessPermission function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12900, Function | SmallTest | Level1) +{ + bool granted = true; + ASSERT_EQ(advancedNotificationService_->HasNotificationPolicyAccessPermission(granted), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13000 + * @tc.name : ANS_GetShowBadgeEnabled_0100 + * @tc.desc : Test GetShowBadgeEnabled function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13000, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + bool enabled = false; + ASSERT_EQ(advancedNotificationService_->GetShowBadgeEnabled(enabled), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13100 + * @tc.name : ANS_RequestEnableNotification_0100 + * @tc.desc : Test whether to pop dialog + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13100, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + std::string deviceId = "DeviceId"; + sptr callback = nullptr; + sptr callerToken = nullptr; + ASSERT_EQ(advancedNotificationService_->RequestEnableNotification(deviceId, callback, callerToken), + (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13500 + * @tc.name : ANS_GetValidReminders_0100 + * @tc.desc : Test GetValidReminders function when the result is ERR_NO_INIT + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13500, Function | SmallTest | Level1) +{ + std::vector> reminders; + ASSERT_EQ(advancedNotificationService_->GetValidReminders(reminders), (int)ERR_NO_INIT); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13600 + * @tc.name : ANS_ActiveNotificationDump_0100 + * @tc.desc : Test ActiveNotificationDump function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13600, Function | SmallTest | Level1) +{ + std::string bundle = "Bundle"; + int32_t userId = 2; + std::vector dumpInfo; + ASSERT_EQ(advancedNotificationService_->ActiveNotificationDump(bundle, userId, 0, dumpInfo), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13700 + * @tc.name : ANS_RecentNotificationDump_0100 + * @tc.desc : Test RecentNotificationDump function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13700, Function | SmallTest | Level1) +{ + std::string bundle = "Bundle"; + int32_t userId = 3; + std::vector dumpInfo; + ASSERT_EQ(advancedNotificationService_->RecentNotificationDump(bundle, userId, 0, dumpInfo), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13800 + * @tc.name : ANS_SetRecentNotificationCount_0100 + * @tc.desc : Test SetRecentNotificationCount function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13800, Function | SmallTest | Level1) +{ + std::string arg = "Arg"; + ASSERT_EQ(advancedNotificationService_->SetRecentNotificationCount(arg), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13900 + * @tc.name : ANS_RemoveAllSlots_0100 + * @tc.desc : Test RemoveAllSlots function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13900, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + ASSERT_EQ(advancedNotificationService_->RemoveAllSlots(), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14200 + * @tc.name : ANS_DoesSupportDoNotDisturbMode_0100 + * @tc.desc : Test DoesSupportDoNotDisturbMode function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14200, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + bool doesSupport = true; + ASSERT_EQ(advancedNotificationService_->DoesSupportDoNotDisturbMode(doesSupport), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14300 + * @tc.name : ANS_IsDistributedEnabled_0100 + * @tc.desc : Test IsDistributedEnabled function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14300, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + bool enabled = true; + ASSERT_EQ(advancedNotificationService_->IsDistributedEnabled(enabled), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14400 + * @tc.name : ANS_EnableDistributed_0100 + * @tc.desc : Test EnableDistributed function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14400, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + bool enabled = true; + ASSERT_EQ(advancedNotificationService_->EnableDistributed(enabled), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14600 + * @tc.name : ANS_EnableDistributedSelf_0100 + * @tc.desc : Test EnableDistributedSelf function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14600, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + bool enabled = true; + ASSERT_EQ(advancedNotificationService_->EnableDistributedSelf(enabled), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14800 + * @tc.name : ANS_IsSpecialUserAllowedNotify_0100 + * @tc.desc : Test IsSpecialUserAllowedNotify function when the result is ERR_ANS_INVALID_PARAM + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14800, Function | SmallTest | Level1) +{ + int32_t userId = 3; + bool allowed = true; + ASSERT_EQ(advancedNotificationService_->IsSpecialUserAllowedNotify(userId, allowed), (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14900 + * @tc.name : ANS_SetNotificationsEnabledByUser_0100 + * @tc.desc : Test SetNotificationsEnabledByUser function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14900, Function | SmallTest | Level1) +{ + int32_t userId = 3; + bool enabled = true; + ASSERT_EQ(advancedNotificationService_->SetNotificationsEnabledByUser(userId, enabled), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15000 + * @tc.name : ANS_GetDoNotDisturbDate_0100 + * @tc.desc : Test GetDoNotDisturbDate function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15000, Function | SmallTest | Level1) +{ + int32_t userId = 3; + sptr date = nullptr; + ASSERT_EQ(advancedNotificationService_->GetDoNotDisturbDate(userId, date), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15200 + * @tc.name : ANS_GetHasPoppedDialog_0100 + * @tc.desc : Test GetHasPoppedDialog function when the result is ERR_ANS_INVALID_PARAM + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15200, Function | SmallTest | Level1) +{ + sptr bundleOption = nullptr; + bool hasPopped = true; + ASSERT_EQ(advancedNotificationService_->GetHasPoppedDialog(bundleOption, hasPopped), (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15300 + * @tc.name : ANS_ShellDump_0100 + * @tc.desc : Test ShellDump function when the result is ERR_ANS_INVALID_PARAM + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15300, Function | SmallTest | Level1) +{ + std::string cmd = "CMD"; + std::string bundle = "Bundle"; + int32_t userId = 4; + std::vector dumpInfo; + ASSERT_EQ(advancedNotificationService_->ShellDump(cmd, bundle, userId, 0, dumpInfo), (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15400 + * @tc.name : ANS_Dump_0100 + * @tc.desc : Test Dump function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15400, Function | SmallTest | Level1) +{ + int fd = 1; + std::vector args; + ASSERT_EQ(advancedNotificationService_->Dump(fd, args), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15700 + * @tc.name : PrepareNotificationRequest_0100 + * @tc.desc : Test PrepareNotificationRequest function when notification is agent. + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15700, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "PrepareNotificationRequest_0100 test start"; + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + + req->SetSlotType(NotificationConstant::SlotType::OTHER); + req->SetLabel("req's label"); + std::string label = "publish's label"; + std::shared_ptr normalContent = std::make_shared(); + EXPECT_NE(normalContent, nullptr); + + normalContent->SetText("normalContent's text"); + normalContent->SetTitle("normalContent's title"); + std::shared_ptr content = std::make_shared(normalContent); + EXPECT_NE(content, nullptr); + + req->SetContent(content); + req->SetIsAgentNotification(true); + ASSERT_EQ(advancedNotificationService_->PrepareNotificationRequest(req), ERR_OK); + GTEST_LOG_(INFO) << "PrepareNotificationRequest_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15800 + * @tc.name : GenerateBundleOption_0100 + * @tc.desc : Test GenerateBundleOption function when bundle name is null. + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15800, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GenerateBundleOption_0100 test start"; + MockSystemApp(); + MockIsNonBundleName(true); + ASSERT_EQ(advancedNotificationService_->GenerateBundleOption(), nullptr); + MockIsNonBundleName(false); + GTEST_LOG_(INFO) << "GenerateBundleOption_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_16000 + * @tc.name : CancelPreparedNotification_1000 + * @tc.desc : Test CancelPreparedNotification function. + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_16000, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "CancelPreparedNotification_1000 test start"; + + int32_t notificationId = 0; + std::string label = "testLabel"; + sptr bundleOption = nullptr; + ASSERT_EQ(advancedNotificationService_->CancelPreparedNotification(notificationId, label, bundleOption, 8), + ERR_ANS_INVALID_BUNDLE); + + GTEST_LOG_(INFO) << "CancelPreparedNotification_1000 test end"; +} + + +/** + * @tc.number : AdvancedNotificationServiceTest_16200 + * @tc.name : ANS_CancelAsBundle_0200 + * @tc.desc : Test CancelAsBundle function + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_16200, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_CancelAsBundle_0200 test start"; + + TestAddSlot(NotificationConstant::SlotType::OTHER); + int32_t notificationId = 1; + std::string representativeBundle = "RepresentativeBundle"; + int32_t userId = 1; + int result = ERR_ANS_NOTIFICATION_NOT_EXISTS; + ASSERT_EQ(advancedNotificationService_->CancelAsBundle(notificationId, representativeBundle, userId), result); + + GTEST_LOG_(INFO) << "ANS_CancelAsBundle_0200 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_16300 + * @tc.name : ANS_CancelAsBundle_0300 + * @tc.desc : Test CancelAsBundle function when uid is less than 0. + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_16300, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_CancelAsBundle_0300 test start"; + + TestAddSlot(NotificationConstant::SlotType::OTHER); + int32_t notificationId = 1; + std::string representativeBundle = "RepresentativeBundle"; + int32_t userId = 0; + int result = ERR_ANS_INVALID_UID; + ASSERT_EQ(advancedNotificationService_->CancelAsBundle(notificationId, representativeBundle, userId), result); + + GTEST_LOG_(INFO) << "ANS_CancelAsBundle_0300 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_16500 + * @tc.name : ANS_CancelAsBundle_0400 + * @tc.desc : Test CancelAsBundle function + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_16500, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_CancelAsBundle_0400 test start"; + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + int32_t notificationId = 1; + + int result = ERR_ANS_NOTIFICATION_NOT_EXISTS; + ASSERT_EQ(advancedNotificationService_->CancelAsBundle(bundleOption, notificationId), result); + + GTEST_LOG_(INFO) << "ANS_CancelAsBundle_0400 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_16400 + * @tc.name : ANS_AddSlots_0100 + * @tc.desc : Test AddSlots function whith not system app + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_16400, Function | SmallTest | Level1) +{ + MockSystemApp(); + GTEST_LOG_(INFO) << "ANS_AddSlots_0100 test start"; + std::vector> slots; + sptr slot = new NotificationSlot(NotificationConstant::SlotType::OTHER); + slots.push_back(slot); + ASSERT_EQ(advancedNotificationService_->AddSlots(slots), ERR_OK); + + GTEST_LOG_(INFO) << "ANS_AddSlots_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_16600 + * @tc.name : ANS_AddSlots_0300 + * @tc.desc : Test AddSlots function with bundle option is null + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_16600, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_AddSlots_0300 test start"; + MockIsNonBundleName(true); + MockSystemApp(); + std::vector> slots; + sptr slot = new NotificationSlot(NotificationConstant::SlotType::OTHER); + slots.push_back(slot); + ASSERT_EQ(advancedNotificationService_->AddSlots(slots), ERR_ANS_INVALID_BUNDLE); + MockIsNonBundleName(false); + GTEST_LOG_(INFO) << "ANS_AddSlots_0300 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_16700 + * @tc.name : ANS_AddSlots_0400 + * @tc.desc : Test AddSlots function with invalid bundle option + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_16700, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_AddSlots_0400 test start"; + + std::vector> slots; + ASSERT_EQ(advancedNotificationService_->AddSlots(slots), ERR_ANS_INVALID_PARAM); + + GTEST_LOG_(INFO) << "ANS_AddSlots_0400 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_16800 + * @tc.name : ANS_GetSlots_0100 + * @tc.desc : Test GetSlots function with bundle option is null + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_16800, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_GetSlots_0100 test start"; + MockIsNonBundleName(true); + MockSystemApp(); + std::vector> slots; + sptr slot = new NotificationSlot(NotificationConstant::SlotType::OTHER); + slots.push_back(slot); + ASSERT_EQ(advancedNotificationService_->GetSlots(slots), ERR_ANS_INVALID_BUNDLE); + MockIsNonBundleName(false); + GTEST_LOG_(INFO) << "ANS_GetSlots_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_16900 + * @tc.name : ANS_GetActiveNotifications_0100 + * @tc.desc : Test function with bundle option is null + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_16900, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_GetActiveNotifications_0100 test start"; + + MockIsNonBundleName(true); + MockSystemApp(); + std::vector> notifications; + ASSERT_EQ(advancedNotificationService_->GetActiveNotifications(notifications, 0), ERR_ANS_INVALID_BUNDLE); + uint64_t num = 1; + ASSERT_EQ(advancedNotificationService_->GetActiveNotificationNums(num), ERR_ANS_INVALID_BUNDLE); + ASSERT_EQ(advancedNotificationService_->SetNotificationBadgeNum(num), ERR_ANS_INVALID_BUNDLE); + int32_t importance = 2; + ASSERT_EQ(advancedNotificationService_->GetBundleImportance(importance), ERR_ANS_INVALID_BUNDLE); + bool allow = true; + ASSERT_EQ(advancedNotificationService_->GetShowBadgeEnabled(allow), ERR_ANS_INVALID_BUNDLE); + + sptr slot = new NotificationSlot(NotificationConstant::OTHER); + ASSERT_EQ(advancedNotificationService_->GetSlotByType(NotificationConstant::OTHER, slot), ERR_ANS_INVALID_BUNDLE); + ASSERT_EQ(advancedNotificationService_->RemoveSlotByType(NotificationConstant::OTHER), ERR_ANS_INVALID_BUNDLE); + + std::string deviceId = "DeviceId"; + bool needPop = false; + ASSERT_EQ(advancedNotificationService_->IsAllowedNotifySelf(needPop), ERR_ANS_INVALID_BUNDLE); + sptr bundleOption; + ASSERT_EQ(advancedNotificationService_->IsAllowedNotifySelf(bundleOption, needPop), ERR_ANS_INVALID_BUNDLE); + + ASSERT_EQ(advancedNotificationService_->GetAppTargetBundle(bundleOption, bundleOption), ERR_ANS_INVALID_BUNDLE); + + int32_t reminderId = 1; + ASSERT_EQ(advancedNotificationService_->CancelReminder(reminderId), ERR_ANS_INVALID_BUNDLE); + + ASSERT_EQ(advancedNotificationService_->CancelAllReminders(), ERR_ANS_INVALID_BUNDLE); + + std::vector> reminders; + ASSERT_EQ(advancedNotificationService_->GetValidReminders(reminders), ERR_ANS_INVALID_BUNDLE); + + ASSERT_EQ(advancedNotificationService_->RemoveAllSlots(), ERR_ANS_INVALID_BUNDLE); + + ASSERT_EQ(advancedNotificationService_->AddSlotByType(NotificationConstant::SlotType::OTHER), + ERR_ANS_INVALID_BUNDLE); + + std::string groupName = "name"; + ASSERT_EQ(advancedNotificationService_->CancelGroup(groupName, 0), ERR_ANS_INVALID_BUNDLE); + + bool enabled = true; + ASSERT_EQ(advancedNotificationService_->EnableDistributedSelf(enabled), ERR_ANS_INVALID_BUNDLE); + MockIsNonBundleName(false); + GTEST_LOG_(INFO) << "ANS_GetActiveNotifications_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_17000 + * @tc.name : ANS_GetSetActiveNotifications_0100 + * @tc.desc : Test SetNotificationAgent and GetNotificationAgent function with bundle option is null + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17000, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_GetActiveNotifications_0100 test start"; + + std::string agent = "agent"; + ASSERT_EQ(advancedNotificationService_->SetNotificationAgent(agent), ERR_INVALID_OPERATION); + ASSERT_EQ(advancedNotificationService_->GetNotificationAgent(agent), ERR_INVALID_OPERATION); + + GTEST_LOG_(INFO) << "ANS_GetActiveNotifications_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_17100 + * @tc.name : ANS_GetSetActiveNotifications_0100 + * @tc.desc : Test function with NON_SYSTEM_APP_UID + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17100, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_GetActiveNotifications_0100 test start"; + + std::string key = "key"; + int32_t removeReason = 0; + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + ASSERT_EQ(advancedNotificationService_->Delete(key, removeReason), ERR_ANS_NOTIFICATION_NOT_EXISTS); + + ASSERT_EQ(advancedNotificationService_->DeleteByBundle(bundleOption), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->DeleteAll(), ERR_OK); + + bool enable = true; + bool isForceControl = false; + ASSERT_EQ(advancedNotificationService_->SetShowBadgeEnabledForBundle(bundleOption, enable), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->GetShowBadgeEnabledForBundle(bundleOption, enable), ERR_OK); + + std::vector> notifications; + ASSERT_EQ(advancedNotificationService_->GetAllActiveNotifications(notifications), ERR_OK); + + std::vector keys; + ASSERT_EQ(advancedNotificationService_->GetSpecialActiveNotifications(keys, notifications), + ERR_OK); + + ASSERT_EQ(advancedNotificationService_->SetNotificationsEnabledForAllBundles(key, enable), + ERR_OK); + + ASSERT_EQ(advancedNotificationService_->SetNotificationsEnabledForSpecialBundle( + std::string(), bundleOption, enable), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->IsAllowedNotify(enable), ERR_ANS_INVALID_PARAM); + + int32_t notificationId = 1; + ASSERT_EQ(advancedNotificationService_->RemoveNotification(bundleOption, notificationId, + key, removeReason), ERR_ANS_NOTIFICATION_NOT_EXISTS); + + ASSERT_EQ(advancedNotificationService_->RemoveAllNotifications(bundleOption), ERR_OK); + + uint64_t num = 1; + ASSERT_EQ(advancedNotificationService_->GetSlotNumAsBundle(bundleOption, num), ERR_OK); + + std::string groupName = "group"; + ASSERT_EQ(advancedNotificationService_->RemoveGroupByBundle(bundleOption, groupName), ERR_OK); + + sptr date = nullptr; + ASSERT_EQ(advancedNotificationService_->SetDoNotDisturbDate(date), ERR_ANS_INVALID_PARAM); + ASSERT_EQ(advancedNotificationService_->GetDoNotDisturbDate(date), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->DoesSupportDoNotDisturbMode(enable), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->EnableDistributed(enable), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->EnableDistributedByBundle(bundleOption, enable), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->IsDistributedEnableByBundle(bundleOption, enable), ERR_OK); + + NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; + ASSERT_EQ(advancedNotificationService_->GetDeviceRemindType(remindType), ERR_OK); + + int32_t userId = 1; + ASSERT_EQ(advancedNotificationService_->IsSpecialUserAllowedNotify(userId, enable), ERR_ANS_INVALID_PARAM); + + ASSERT_EQ(advancedNotificationService_->SetNotificationsEnabledByUser(userId, enable), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->DeleteAllByUser(userId), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->SetDoNotDisturbDate(userId, date), ERR_ANS_INVALID_PARAM); + ASSERT_EQ(advancedNotificationService_->GetDoNotDisturbDate(userId, date), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->SetEnabledForBundleSlot(bundleOption, + NotificationConstant::SlotType::OTHER, enable, false), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->GetEnabledForBundleSlot(bundleOption, + NotificationConstant::SlotType::OTHER, enable), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->SetSyncNotificationEnabledWithoutApp(userId, enable), ERR_OK); + + ASSERT_EQ(advancedNotificationService_->GetSyncNotificationEnabledWithoutApp(userId, enable), ERR_OK); + + GTEST_LOG_(INFO) << "ANS_GetActiveNotifications_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_17300 + * @tc.name : ANS_GetSlotsByBundle_0100 + * @tc.desc : Test GetSlotsByBundle function + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17300, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_GetSlotsByBundle_0100 test start"; + std::vector> slots; + ASSERT_EQ(advancedNotificationService_->GetSlotsByBundle( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), slots), + ERR_OK); + + ASSERT_EQ(advancedNotificationService_->UpdateSlots( + new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID), slots), + ERR_ANS_INVALID_PARAM); + + GTEST_LOG_(INFO) << "ANS_GetSlotsByBundle_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_17400 + * @tc.name : Subscribe_1000 + * @tc.desc : Test Subscribe function. + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17400, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "Subscribe_1000 test start"; + + auto subscriber = new TestAnsSubscriber(); + sptr info = new NotificationSubscribeInfo(); + EXPECT_NE(advancedNotificationService_->Subscribe(subscriber->GetImpl(), info), ERR_OK); + EXPECT_NE(advancedNotificationService_->Unsubscribe(subscriber->GetImpl(), info), ERR_OK); + + GTEST_LOG_(INFO) << "Subscribe_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_17500 + * @tc.name : Unsubscribe_1000 + * @tc.desc : Test Subscribe function. + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17500, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "Unsubscribe_1000 test start"; + + auto subscriber = new TestAnsSubscriber(); + sptr info = new NotificationSubscribeInfo(); + EXPECT_NE(advancedNotificationService_->Subscribe(subscriber->GetImpl(), info), ERR_OK); + ASSERT_EQ(advancedNotificationService_->Unsubscribe(nullptr, info), ERR_ANS_INVALID_PARAM); + + GTEST_LOG_(INFO) << "Unsubscribe_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_17600 + * @tc.name : GetAppTargetBundle_1000 + * @tc.desc : Test GetAppTargetBundle function. + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17600, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GetAppTargetBundle_1000 test start"; + + sptr bundleOption = nullptr; + + ASSERT_EQ(advancedNotificationService_->GetAppTargetBundle(bundleOption, bundleOption), ERR_OK); + + GTEST_LOG_(INFO) << "GetAppTargetBundle_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_17700 + * @tc.name : GetAppTargetBundle_2000 + * @tc.desc : Test GetAppTargetBundle function. + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17700, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GetAppTargetBundle_2000 test start"; + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + sptr targetBundle = nullptr; + bundleOption->SetBundleName("test"); + ASSERT_EQ(advancedNotificationService_->GetAppTargetBundle(bundleOption, targetBundle), ERR_OK); + + GTEST_LOG_(INFO) << "GetAppTargetBundle_2000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_17800 + * @tc.name : GetAppTargetBundle_3000 + * @tc.desc : Test GetAppTargetBundle function. + * @tc.require : #I60KYN + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17800, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GetAppTargetBundle_3000 test start"; + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + sptr targetBundle = nullptr; + bundleOption->SetBundleName("test"); + ASSERT_EQ(advancedNotificationService_->GetAppTargetBundle(bundleOption, targetBundle), ERR_OK); + + GTEST_LOG_(INFO) << "GetAppTargetBundle_3000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_18100 + * @tc.name : ActiveNotificationDump_1000 + * @tc.desc : Test ActiveNotificationDump function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18100, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ActiveNotificationDump_1000 test start"; + + std::string bundle = "Bundle"; + int32_t userId = -1; + std::vector dumpInfo; + + ASSERT_EQ(advancedNotificationService_->ActiveNotificationDump(bundle, userId, userId, dumpInfo), ERR_OK); + + GTEST_LOG_(INFO) << "ActiveNotificationDump_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_18200 + * @tc.name : RecentNotificationDump_1000 + * @tc.desc : Test RecentNotificationDump function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18200, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "RecentNotificationDump_1000 test start"; + + std::string bundle = "Bundle"; + int32_t userId = -1; + std::vector dumpInfo; + + ASSERT_EQ(advancedNotificationService_->RecentNotificationDump(bundle, userId, userId, dumpInfo), ERR_OK); + + GTEST_LOG_(INFO) << "RecentNotificationDump_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_18300 + * @tc.name : DistributedNotificationDump_1000 + * @tc.desc : Test DistributedNotificationDump function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18300, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "DistributedNotificationDump_1000 test start"; + + std::string bundle = "Bundle"; + int32_t userId = -1; + std::vector dumpInfo; + + ASSERT_EQ(advancedNotificationService_->DistributedNotificationDump(bundle, userId, userId, dumpInfo), ERR_OK); + + GTEST_LOG_(INFO) << "DistributedNotificationDump_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_18400 + * @tc.name : SetRecentNotificationCount_1000 + * @tc.desc : Test SetRecentNotificationCount function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18400, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "SetRecentNotificationCount_1000 test start"; + + std::string arg = "1100"; + ASSERT_EQ(advancedNotificationService_->SetRecentNotificationCount(arg), ERR_ANS_INVALID_PARAM); + + GTEST_LOG_(INFO) << "SetRecentNotificationCount_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_18500 + * @tc.name : OnBundleRemoved_1000 + * @tc.desc : Test OnBundleRemoved function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18500, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "OnBundleRemoved_1000 test start"; + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->OnBundleRemoved(bundleOption); + + GTEST_LOG_(INFO) << "OnBundleRemoved_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_18600 + * @tc.name : OnScreenOn_1000 + * @tc.desc : Test OnScreenOn function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18600, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "OnScreenOn_1000 test start"; + + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->OnScreenOn(); + advancedNotificationService_->OnScreenOff(); + + GTEST_LOG_(INFO) << "OnScreenOn_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_18700 + * @tc.name : AddSlotByType_1000 + * @tc.desc : Test AddSlotByType function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18700, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AddSlotByType_1000 test start"; + MockSystemApp(); + ASSERT_EQ(advancedNotificationService_->AddSlotByType(NotificationConstant::SlotType::SERVICE_REMINDER), + ERR_OK); + + GTEST_LOG_(INFO) << "AddSlotByType_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_18800 + * @tc.name : GetSlotNumAsBundle_1000 + * @tc.desc : Test GetSlotNumAsBundle function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18800, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GetSlotNumAsBundle_1000 test start"; + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + uint64_t num = 1; + ASSERT_EQ(advancedNotificationService_->GetSlotNumAsBundle(bundleOption, num), ERR_OK); + + GTEST_LOG_(INFO) << "GetSlotNumAsBundle_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_18900 + * @tc.name : CancelGroup_1000 + * @tc.desc : Test CancelGroup function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18900, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "CancelGroup_1000 test start"; + + std::string groupName = ""; + ASSERT_EQ(advancedNotificationService_->CancelGroup(groupName, 0), ERR_ANS_INVALID_PARAM); + + GTEST_LOG_(INFO) << "CancelGroup_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_19000 + * @tc.name : RemoveGroupByBundle_1000 + * @tc.desc : Test RemoveGroupByBundle function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19000, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "RemoveGroupByBundle_1000 test start"; + + std::string groupName = "group"; + sptr bundleOption = nullptr; + ASSERT_EQ(advancedNotificationService_->RemoveGroupByBundle(bundleOption, groupName), ERR_ANS_INVALID_PARAM); + + GTEST_LOG_(INFO) << "RemoveGroupByBundle_1000 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_19100 + * @tc.name : ANS_IsDistributedEnabled_0100 + * @tc.desc : Test IsDistributedEnabled function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19100, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "ANS_IsDistributedEnabled_0100 test start"; + + bool enabled = false; + ASSERT_EQ(advancedNotificationService_->IsDistributedEnabled(enabled), ERR_OK); + + GTEST_LOG_(INFO) << "ANS_IsDistributedEnabled_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_19200 + * @tc.name : EnableDistributedByBundle_0100 + * @tc.desc : Test EnableDistributedByBundle function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19200, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "EnableDistributedByBundle_0100 test start"; + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + bool enabled = false; + ASSERT_EQ(advancedNotificationService_->EnableDistributedByBundle(bundleOption, enabled), ERR_OK); + + GTEST_LOG_(INFO) << "EnableDistributedByBundle_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_19300 + * @tc.name : IsDistributedEnableByBundle_0100 + * @tc.desc : Test IsDistributedEnableByBundle function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19300, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsDistributedEnableByBundle_0100 test start"; + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + bool enabled = true; + ASSERT_EQ(advancedNotificationService_->IsDistributedEnableByBundle(bundleOption, enabled), ERR_OK); + + GTEST_LOG_(INFO) << "IsDistributedEnableByBundle_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_19400 + * @tc.name : IsDistributedEnableByBundle_0200 + * @tc.desc : Test IsDistributedEnableByBundle function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19400, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsDistributedEnableByBundle_0200 test start"; + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + bool enabled = false; + ASSERT_EQ(advancedNotificationService_->IsDistributedEnableByBundle(bundleOption, enabled), ERR_OK); + + GTEST_LOG_(INFO) << "IsDistributedEnableByBundle_0200 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_19500 + * @tc.name : GetDeviceRemindType_0100 + * @tc.desc : Test GetDeviceRemindType function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19500, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GetDeviceRemindType_0100 test start"; + + NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; + ASSERT_EQ(advancedNotificationService_->GetDeviceRemindType(remindType), ERR_OK); + + GTEST_LOG_(INFO) << "GetDeviceRemindType_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_19600 + * @tc.name : GetLocalNotificationKeys_0100 + * @tc.desc : Test GetLocalNotificationKeys function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19600, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GetLocalNotificationKeys_0100 test start"; + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->GetLocalNotificationKeys(bundleOption); + + GTEST_LOG_(INFO) << "GetLocalNotificationKeys_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_19700 + * @tc.name : CheckDistributedNotificationType_0100 + * @tc.desc : Test CheckDistributedNotificationType function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19700, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "CheckDistributedNotificationType_0100 test start"; + + sptr req = new NotificationRequest(); + ASSERT_EQ(advancedNotificationService_->CheckDistributedNotificationType(req), true); + + GTEST_LOG_(INFO) << "CheckDistributedNotificationType_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_19800 + * @tc.name : CheckDistributedNotificationType_0200 + * @tc.desc : Test CheckDistributedNotificationType function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19800, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "CheckDistributedNotificationType_0200 test start"; + + sptr req = new NotificationRequest(); + std::vector devices; + devices.push_back("a"); + devices.push_back("b"); + devices.push_back("c"); + req->GetNotificationDistributedOptions().SetDevicesSupportDisplay(devices); + ASSERT_EQ(advancedNotificationService_->CheckDistributedNotificationType(req), true); + + GTEST_LOG_(INFO) << "CheckDistributedNotificationType_0200 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_19900 + * @tc.name : OnDistributedPublish_0100 + * @tc.desc : Test OnDistributedPublish function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19900, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "CheckDistributedNotificationType_0100 test start"; + + std::string deviceId = "DeviceId"; + std::string bundleName = "BundleName"; + sptr request = new NotificationRequest(); + + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->OnDistributedPublish(deviceId, bundleName, request); + + GTEST_LOG_(INFO) << "CheckDistributedNotificationType_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_20000 + * @tc.name : OnDistributedUpdate_0100 + * @tc.desc : Test OnDistributedUpdate function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20000, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "OnDistributedUpdate_0100 test start"; + + std::string deviceId = "DeviceId"; + std::string bundleName = "BundleName"; + sptr request = new NotificationRequest(); + + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->OnDistributedUpdate(deviceId, bundleName, request); + + GTEST_LOG_(INFO) << "OnDistributedUpdate_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_20100 + * @tc.name : OnDistributedDelete_0100 + * @tc.desc : Test OnDistributedDelete function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20100, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "OnDistributedDelete_0100 test start"; + + std::string deviceId = "DeviceId"; + std::string bundleName = "BundleName"; + std::string label = "testLabel"; + int32_t id = 1; + + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->OnDistributedDelete(deviceId, bundleName, label, id); + + GTEST_LOG_(INFO) << "OnDistributedDelete_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_20200 + * @tc.name : CheckPublishWithoutApp_0100 + * @tc.desc : Test CheckPublishWithoutApp function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20200, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "CheckPublishWithoutApp_0100 test start"; + + int32_t userId = 1; + sptr request = new NotificationRequest(); + ASSERT_EQ(advancedNotificationService_->CheckPublishWithoutApp(userId, request), false); + + GTEST_LOG_(INFO) << "CheckPublishWithoutApp_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_20300 + * @tc.name : CheckPublishWithoutApp_0200 + * @tc.desc : Test CheckPublishWithoutApp function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20300, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "CheckPublishWithoutApp_0200 test start"; + + int32_t userId = SYSTEM_APP_UID; + sptr request = new NotificationRequest(); + ASSERT_EQ(advancedNotificationService_->CheckPublishWithoutApp(userId, request), false); + + GTEST_LOG_(INFO) << "CheckPublishWithoutApp_0200 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_20400 + * @tc.name : TriggerRemoveWantAgent_0100 + * @tc.desc : Test TriggerRemoveWantAgent function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20400, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "TriggerRemoveWantAgent_0100 test start"; + + sptr request = new NotificationRequest(); + AbilityRuntime::WantAgent::WantAgentInfo paramsInfo; + std::shared_ptr wantAgent = + AbilityRuntime::WantAgent::WantAgentHelper::GetWantAgent(paramsInfo); + + request->SetRemovalWantAgent(wantAgent); + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->TriggerRemoveWantAgent(request); + + GTEST_LOG_(INFO) << "TriggerRemoveWantAgent_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_20500 + * @tc.name : DeleteAllByUser_0100 + * @tc.desc : Test DeleteAllByUser function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20500, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "DeleteAllByUser_0100 test start"; + + int32_t userId = -2; + ASSERT_EQ(advancedNotificationService_->DeleteAllByUser(userId), ERR_ANS_INVALID_PARAM); + + sptr date = nullptr; + ASSERT_EQ(advancedNotificationService_->SetDoNotDisturbDate(userId, date), ERR_ANS_INVALID_PARAM); + ASSERT_EQ(advancedNotificationService_->GetDoNotDisturbDate(userId, date), ERR_ANS_INVALID_PARAM); + ASSERT_EQ(advancedNotificationService_->SetDoNotDisturbDateByUser(userId, date), ERR_ANS_INVALID_PARAM); + GTEST_LOG_(INFO) << "DeleteAllByUser_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_20600 + * @tc.name : OnResourceRemove_0100 + * @tc.desc : Test OnResourceRemove function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20600, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "OnResourceRemove_0100 test start"; + + int32_t userId = -2; + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->OnResourceRemove(userId); + + GTEST_LOG_(INFO) << "OnResourceRemove_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_20700 + * @tc.name : OnBundleDataCleared_0100 + * @tc.desc : Test OnBundleDataCleared function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20700, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "OnBundleDataCleared_0100 test start"; + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->OnBundleDataCleared(bundleOption); + + GTEST_LOG_(INFO) << "OnBundleDataCleared_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_20900 + * @tc.name : GetDumpInfo_0100 + * @tc.desc : Test GetDumpInfo function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20900, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GetDumpInfo_0100 test start"; + + std::vector args; + args.push_back(Str8ToStr16("args")); + std::string result = "result"; + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->GetDumpInfo(args, result); + + GTEST_LOG_(INFO) << "GetDumpInfo_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_21000 + * @tc.name : GetDumpInfo_0200 + * @tc.desc : Test GetDumpInfo function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21000, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GetDumpInfo_0200 test start"; + + std::vector args; + args.push_back(Str8ToStr16("-h")); + std::string result = "result"; + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->GetDumpInfo(args, result); + + GTEST_LOG_(INFO) << "GetDumpInfo_0200 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_21100 + * @tc.name : SendFlowControlOccurHiSysEvent_0100 + * @tc.desc : Test SendFlowControlOccurHiSysEvent function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21100, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "SendFlowControlOccurHiSysEvent_0100 test start"; + + std::shared_ptr record = nullptr; + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->SendFlowControlOccurHiSysEvent(record); + + GTEST_LOG_(INFO) << "SendFlowControlOccurHiSysEvent_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_21200 + * @tc.name : SendFlowControlOccurHiSysEvent_0200 + * @tc.desc : Test SendFlowControlOccurHiSysEvent function + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21200, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "SendFlowControlOccurHiSysEvent_0200 test start"; + + std::shared_ptr record = std::make_shared(); + record->request = new NotificationRequest(); + record->bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_NE(nullptr, advancedNotificationService_); + advancedNotificationService_->SendFlowControlOccurHiSysEvent(record); + + GTEST_LOG_(INFO) << "SendFlowControlOccurHiSysEvent_0200 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_21300 + * @tc.name : PrepareNotificationRequest_0200 + * @tc.desc : Test PrepareNotificationRequest function when uid < 0. + * @tc.require : issueI62D8C + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21300, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "PrepareNotificationRequest_0200 test start"; + sptr req = new NotificationRequest(); + int32_t myNotificationId = 10; + bool isAgentTrue = true; + NotificationRequest notificationRequest(myNotificationId); + notificationRequest.SetIsAgentNotification(isAgentTrue); + + std::shared_ptr bundleManager = nullptr; + + ASSERT_EQ(advancedNotificationService_->PrepareNotificationRequest(req), ERR_OK); + GTEST_LOG_(INFO) << "PrepareNotificationRequest_0200 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_21400 + * @tc.name : PrepareNotificationInfo_2000 + * @tc.desc : Test PrepareNotificationInfo function. + * @tc.require : issueI62D8C + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21400, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "PrepareNotificationInfo_2000 test start"; + + sptr req = new (std::nothrow) NotificationRequest(1); + EXPECT_NE(req, nullptr); + sptr bundleOption = nullptr; + + ASSERT_EQ(advancedNotificationService_->PrepareNotificationInfo(req, bundleOption), ERR_OK); + + GTEST_LOG_(INFO) << "PrepareNotificationInfo_2000 test end"; +} + + + +/** + * @tc.number : AdvancedNotificationServiceTest_21600 + * @tc.name : RegisterPushCallback_0100 + * @tc.desc : Test RegisterPushCallback function. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21600, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "RegisterPushCallback_0100 test start"; + + auto pushCallbackProxy = new (std::nothrow)MockPushCallBackStub(); + EXPECT_NE(pushCallbackProxy, nullptr); + sptr pushCallback = pushCallbackProxy->AsObject(); + sptr checkRequest = new (std::nothrow) NotificationCheckRequest(); + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + ASSERT_EQ(advancedNotificationService_->RegisterPushCallback(pushCallback, checkRequest), ERR_OK); + + advancedNotificationService_->UnregisterPushCallback(); + + GTEST_LOG_(INFO) << "RegisterPushCallback_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_21700 + * @tc.name : RegisterPushCallback_0200 + * @tc.desc : Test RegisterPushCallback function. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21700, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "RegisterPushCallback_0200 test start"; + + auto pushCallbackProxy = new (std::nothrow)MockPushCallBackStub(); + EXPECT_NE(pushCallbackProxy, nullptr); + sptr pushCallback = pushCallbackProxy->AsObject(); + sptr checkRequest = new (std::nothrow) NotificationCheckRequest(); + ASSERT_EQ(advancedNotificationService_->RegisterPushCallback(pushCallback, checkRequest), + (int)ERR_OK); + advancedNotificationService_->UnregisterPushCallback(); + + + GTEST_LOG_(INFO) << "RegisterPushCallback_0200 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_21800 + * @tc.name : RegisterPushCallback_0200 + * @tc.desc : Test RegisterPushCallback function. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21800, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "RegisterPushCallback_0300 test start"; + + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + auto pushCallbackProxy = new (std::nothrow)MockPushCallBackStub(); + EXPECT_NE(pushCallbackProxy, nullptr); + sptr pushCallback = pushCallbackProxy->AsObject(); + sptr pushCallBack = iface_cast(pushCallback); + sptr checkRequest = new (std::nothrow) NotificationCheckRequest(); + + advancedNotificationService_->pushCallBacks_.insert_or_assign(checkRequest->GetSlotType(), pushCallBack); + + ASSERT_EQ(advancedNotificationService_->RegisterPushCallback(pushCallback, checkRequest), (int)ERR_OK); + + advancedNotificationService_->UnregisterPushCallback(); + + GTEST_LOG_(INFO) << "RegisterPushCallback_0200 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_21900 + * @tc.name : UnregisterPushCallback_0100 + * @tc.desc : Test UnregisterPushCallback function. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21900, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "UnregisterPushCallback_0100 test start"; + + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + auto pushCallbackProxy = new (std::nothrow)MockPushCallBackStub(); + EXPECT_NE(pushCallbackProxy, nullptr); + sptr pushCallback = pushCallbackProxy->AsObject(); + sptr pushCallBack = iface_cast(pushCallback); + sptr checkRequest = new (std::nothrow) NotificationCheckRequest(); + + advancedNotificationService_->pushCallBacks_.insert_or_assign(checkRequest->GetSlotType(), pushCallBack); + + ASSERT_EQ(advancedNotificationService_->UnregisterPushCallback(), ERR_OK); + + GTEST_LOG_(INFO) << "UnregisterPushCallback_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_22000 + * @tc.name : UnregisterPushCallback_0200 + * @tc.desc : Test UnregisterPushCallback function. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_22000, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "UnregisterPushCallback_0200 test start"; + ASSERT_EQ(advancedNotificationService_->UnregisterPushCallback(), (int)ERR_ANS_NON_SYSTEM_APP); + + GTEST_LOG_(INFO) << "UnregisterPushCallback_0200 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_22100 + * @tc.name : UnregisterPushCallback_0300 + * @tc.desc : Test UnregisterPushCallback function. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_22100, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "UnregisterPushCallback_0300 test start"; + + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + ASSERT_EQ(advancedNotificationService_->UnregisterPushCallback(), (int)ERR_INVALID_OPERATION); + + GTEST_LOG_(INFO) << "UnregisterPushCallback_0300 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_22500 + * @tc.name : PushCheck_0100 + * @tc.desc : Test PushCheck function. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_22500, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "PushCheck_0100 test start"; + + sptr req = new (std::nothrow) NotificationRequest(); + ASSERT_EQ(advancedNotificationService_->PushCheck(req), ERR_ANS_PUSH_CHECK_UNREGISTERED); + + GTEST_LOG_(INFO) << "PushCheck_0100 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_220000 + * @tc.name : TimeToString_1000 + * @tc.desc : Test TimeToString function. + * @tc.require : #I61RF2 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_220000, Function | SmallTest | Level1) +{ + int64_t time = 60; + int64_t ret = 20; + std::string result = advancedNotificationService_->TimeToString(time); + ASSERT_EQ(result.size(), ret); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00001 + * @tc.name : PrepareNotificationRequest + * @tc.desc : Test PrepareNotificationRequest function. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00001, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00001 test start"; + ASSERT_EQ(advancedNotificationService_->PrepareNotificationRequest(nullptr), ERR_ANS_INVALID_PARAM); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00001 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00002 + * @tc.name : IsNotificationExists + * @tc.desc : Test IsNotificationExists function. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00002, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00002 test start"; + std::string key = "aa"; + sptr request = new (std::nothrow) NotificationRequest(); + EXPECT_NE(request, nullptr); + sptr notification = new (std::nothrow) Notification(request); + EXPECT_NE(notification, nullptr); + auto record = std::make_shared(); + record->request = request; + record->notification = notification; + advancedNotificationService_->notificationList_.push_back(record); + ASSERT_EQ(advancedNotificationService_->IsNotificationExists(key), false); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00002 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00003 + * @tc.name : UpdateInNotificationList + * @tc.desc : Test UpdateInNotificationList function and notificationList_ is not empty. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00003, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00003 test start"; + std::string key = "aa"; + sptr request = new (std::nothrow) NotificationRequest(); + EXPECT_NE(request, nullptr); + sptr notification = new (std::nothrow) Notification(request); + EXPECT_NE(notification, nullptr); + auto record = std::make_shared(); + record->request = request; + record->notification = notification; + advancedNotificationService_->notificationList_.push_back(record); + advancedNotificationService_->UpdateInNotificationList(record); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00003 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00004 + * @tc.name : SetBadgeNumber + * @tc.desc : Test SetBadgeNumber function and handler_ is nullptr. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00004, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00004 test start"; + int32_t badgeNumber = 1; + ASSERT_EQ(advancedNotificationService_->SetBadgeNumber(badgeNumber, 0), ERR_OK); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00004 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00005 + * @tc.name : SetBadgeNumber + * @tc.desc : Test SetBadgeNumber function and handler_ is not nullptr. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00005, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00005 test start"; + int32_t badgeNumber = 1; + advancedNotificationService_->runner_ = OHOS::AppExecFwk::EventRunner::Create("NotificationSvrMain"); + advancedNotificationService_->handler_ = + std::make_shared(advancedNotificationService_->runner_); + ASSERT_EQ(advancedNotificationService_->SetBadgeNumber(badgeNumber, 0), ERR_OK); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00005 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00006 + * @tc.name : ResetPushCallbackProxy + * @tc.desc : Test ResetPushCallbackProxy function and pushCallBack_ is nullptr. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00006, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00006 test start"; + EXPECT_NE(advancedNotificationService_, nullptr); + advancedNotificationService_->ResetPushCallbackProxy(); + ASSERT_EQ(advancedNotificationService_->pushCallBacks_.empty(), true); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00006 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00007 + * @tc.name : ResetPushCallbackProxy + * @tc.desc : Test ResetPushCallbackProxy function and pushCallBack_ is not nullptr. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00007, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00007 test start"; + EXPECT_NE(advancedNotificationService_, nullptr); + auto pushCallbackProxy = new (std::nothrow)MockPushCallBackStub(); + EXPECT_NE(pushCallbackProxy, nullptr); + sptr pushCallback = pushCallbackProxy->AsObject(); + sptr pushCallBack = iface_cast(pushCallback); + sptr checkRequest = new (std::nothrow) NotificationCheckRequest(); + + advancedNotificationService_->pushCallBacks_.insert_or_assign(checkRequest->GetSlotType(), pushCallBack); + advancedNotificationService_->ResetPushCallbackProxy(); + ASSERT_TRUE(advancedNotificationService_->pushCallBacks_.empty()); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00007 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00008 + * @tc.name : SendEnableNotificationSlotHiSysEvent + * @tc.desc : Test SendEnableNotificationSlotHiSysEvent function and bundleOption is nullptr. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00008, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00008 test start"; + sptr bundleOption = nullptr; + NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CONTENT_INFORMATION; + bool enabled = false; + ErrCode errCode = ERR_OK; + EXPECT_NE(advancedNotificationService_, nullptr); + advancedNotificationService_->SendEnableNotificationSlotHiSysEvent(bundleOption, slotType, enabled, errCode); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00008 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00009 + * @tc.name : SendEnableNotificationSlotHiSysEvent + * @tc.desc : Test SendEnableNotificationSlotHiSysEvent function and errCode != ERR_OK. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00009, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00009 test start"; + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + NotificationConstant::SlotType slotType = NotificationConstant::SlotType::CONTENT_INFORMATION; + bool enabled = false; + ErrCode errCode = ERR_ANS_TASK_ERR; + EXPECT_NE(advancedNotificationService_, nullptr); + advancedNotificationService_->SendEnableNotificationSlotHiSysEvent(bundleOption, slotType, enabled, errCode); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00009 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00010 + * @tc.name : SendRemoveHiSysEvent + * @tc.desc : Test SendRemoveHiSysEvent function and errCode is ERR_OK bundleOption is not nullptr. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00010, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00010 test start"; + int32_t notificationId = 1; + std::string label = "aa"; + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ErrCode errCode = ERR_OK; + EXPECT_NE(advancedNotificationService_, nullptr); + advancedNotificationService_->SendRemoveHiSysEvent(notificationId, label, bundleOption, errCode); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00010 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00011 + * @tc.name : SendEnableNotificationHiSysEvent + * @tc.desc : Test SendEnableNotificationHiSysEvent function andbundleOption is nullptr. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00011, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00011 test start"; + sptr bundleOption = nullptr; + bool enabled = false; + ErrCode errCode = ERR_ANS_TASK_ERR; + EXPECT_NE(advancedNotificationService_, nullptr); + advancedNotificationService_->SendEnableNotificationHiSysEvent(bundleOption, enabled, errCode); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00011 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00012 + * @tc.name : SendCancelHiSysEvent + * @tc.desc : Test SendCancelHiSysEvent function and errCode is ERR_OK bundleOption is not nullptr. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00012, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00012 test start"; + int32_t notificationId = 1; + std::string label = "aa"; + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ErrCode errCode = ERR_OK; + EXPECT_NE(advancedNotificationService_, nullptr); + advancedNotificationService_->SendCancelHiSysEvent(notificationId, label, bundleOption, errCode); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00012 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00013 + * @tc.name : SendPublishHiSysEvent + * @tc.desc : Test SendPublishHiSysEvent function and request is nullptr. + * @tc.require : #I6Z5I4 + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00013, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00013 test start"; + sptr request = nullptr; + ErrCode errCode = ERR_OK; + EXPECT_NE(advancedNotificationService_, nullptr); + advancedNotificationService_->SendPublishHiSysEvent(request, errCode); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00013 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00014 + * @tc.name : GetTargetRecordList + * @tc.desc : Test GetTargetRecordList function and get empty. + * @tc.require : #I8B8PI + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00014, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00014 test start"; + std::shared_ptr record = std::make_shared(); + record->request = new NotificationRequest(); + record->bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + const int32_t uid = 0; + auto slotType = NotificationConstant::SlotType::LIVE_VIEW; + auto contentType = NotificationContent::Type::LOCAL_LIVE_VIEW; + advancedNotificationService_->notificationList_.clear(); + std::vector> recordList; + ASSERT_EQ(advancedNotificationService_->GetTargetRecordList(uid, slotType, contentType, recordList), + ERR_ANS_NOTIFICATION_NOT_EXISTS); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00014 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00015 + * @tc.name : GetTargetRecordList + * @tc.desc : Test GetTargetRecordList function and get success. + * @tc.require : #I8B8PI + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00015, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00015 test start"; + std::string bundleName = "testBundle"; + const int32_t uid = 0; + auto slotType = NotificationConstant::SlotType::LIVE_VIEW; + auto contentType = NotificationContent::Type::LOCAL_LIVE_VIEW; + + sptr request = new (std::nothrow) NotificationRequest(); + EXPECT_NE(request, nullptr); + request->SetSlotType(slotType); + auto liveContent = std::make_shared(); + auto content = std::make_shared(liveContent); + request->SetContent(content); + request->SetCreatorUid(uid); + sptr notification = new (std::nothrow) Notification(request); + EXPECT_NE(notification, nullptr); + auto record = std::make_shared(); + record->request = request; + record->notification = notification; + advancedNotificationService_->notificationList_.push_back(record); + std::vector> recordList; + ASSERT_EQ(advancedNotificationService_->GetTargetRecordList(uid, slotType, contentType, recordList), + ERR_OK); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00015 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00016 + * @tc.name : RemoveNotificationFromRecordList + * @tc.desc : Test RemoveNotificationFromRecordList function and remove success. + * @tc.require : #I8B8PI + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00016, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00016 test start"; + std::string bundleName = "testBundle"; + auto slotType = NotificationConstant::SlotType::LIVE_VIEW; + auto contentType = NotificationContent::Type::LOCAL_LIVE_VIEW; + + sptr request = new (std::nothrow) NotificationRequest(); + EXPECT_NE(request, nullptr); + request->SetSlotType(slotType); + auto liveContent = std::make_shared(); + auto content = std::make_shared(liveContent); + request->SetContent(content); + request->SetOwnerBundleName(bundleName); + sptr notification = new (std::nothrow) Notification(request); + EXPECT_NE(notification, nullptr); + auto record = std::make_shared(); + record->request = request; + record->notification = notification; + advancedNotificationService_->notificationList_.push_back(record); + std::vector> recordList; + recordList.push_back(record); + ASSERT_EQ(advancedNotificationService_->RemoveNotificationFromRecordList(recordList), ERR_OK); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00016 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00017 + * @tc.name : RemoveSystemLiveViewNotifications + * @tc.desc : Test RemoveNotificationFromRecordList function and remove success. + * @tc.require : #I8B8PI + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00017, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00016 test start"; + std::string bundleName = "testBundle"; + auto slotType = NotificationConstant::SlotType::LIVE_VIEW; + sptr request = new (std::nothrow) NotificationRequest(); + EXPECT_NE(request, nullptr); + request->SetSlotType(slotType); + auto liveContent = std::make_shared(); + auto content = std::make_shared(liveContent); + request->SetContent(content); + request->SetOwnerBundleName(bundleName); + sptr notification = new (std::nothrow) Notification(request); + EXPECT_NE(notification, nullptr); + auto record = std::make_shared(); + record->request = request; + record->notification = notification; + advancedNotificationService_->notificationList_.push_back(record); + int32_t uid = 0; + ASSERT_EQ(advancedNotificationService_->RemoveSystemLiveViewNotifications(bundleName, uid), ERR_OK); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00017 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00018 + * @tc.name : RemoveSystemLiveViewNotifications + * @tc.desc : Test RemoveNotificationFromRecordList function and remove success. + * @tc.require : #I8B8PI + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00018, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00018 test start"; + std::string bundleName = "testBundle"; + int32_t uid = 0; + ASSERT_EQ(advancedNotificationService_->RemoveSystemLiveViewNotifications(bundleName, uid), + ERR_ANS_NOTIFICATION_NOT_EXISTS); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00018 test end"; +} + +/** + * @tc.number : AdvancedNotificationServiceTest_00019 + * @tc.name : RemoveSystemLiveViewNotifications + * @tc.desc : Test RemoveNotificationFromRecordList function and remove success. + * @tc.require : #I8B8PI + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_00019, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00019 test start"; + std::string bundleName = "testBundle"; + auto slotType = NotificationConstant::SlotType::LIVE_VIEW; + sptr request = new (std::nothrow) NotificationRequest(); + EXPECT_NE(request, nullptr); + request->SetSlotType(slotType); + auto liveContent = std::make_shared(); + auto content = std::make_shared(liveContent); + request->SetContent(content); + request->SetOwnerBundleName(bundleName); + sptr notification = new (std::nothrow) Notification(request); + EXPECT_NE(notification, nullptr); + auto record = std::make_shared(); + record->request = request; + record->notification = notification; + advancedNotificationService_->notificationList_.push_back(record); + advancedNotificationService_->notificationSvrQueue_ = nullptr; + int32_t uid = 0; + ASSERT_EQ(advancedNotificationService_->RemoveSystemLiveViewNotifications(bundleName, uid), ERR_ANS_INVALID_PARAM); + GTEST_LOG_(INFO) << "AdvancedNotificationServiceTest_00019 test end"; +} +/** + * @tc.number : IsLiveViewCanRecoverTest_0001 + * @tc.name : IsLiveViewCanRecover + * @tc.desc : Test IsLiveViewCanRecover and liveview is nullptr. + */ +HWTEST_F(AdvancedNotificationServiceTest, IsLiveViewCanRecoverTest_0001, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsLiveViewCanRecoverTest_0001 test start"; + ASSERT_EQ(advancedNotificationService_->IsLiveViewCanRecover(nullptr), false); + GTEST_LOG_(INFO) << "IsLiveViewCanRecoverTest_0001 test end"; +} + +/** + * @tc.number : IsLiveViewCanRecoverTest_0002 + * @tc.name : IsLiveViewCanRecover + * @tc.desc : Test IsLiveViewCanRecover and liveview status is invalid. + */ +HWTEST_F(AdvancedNotificationServiceTest, IsLiveViewCanRecoverTest_0002, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsLiveViewCanRecoverTest_0002 test start"; + sptr request = new NotificationRequest(); + std::shared_ptr liveViewContent = std::make_shared(); + std::shared_ptr content = std::make_shared(liveViewContent); + liveViewContent->SetLiveViewStatus(NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_END); + request->SetContent(content); + + ASSERT_EQ(advancedNotificationService_->IsLiveViewCanRecover(request), false); + GTEST_LOG_(INFO) << "IsLiveViewCanRecoverTest_0002 test end"; +} + +/** + * @tc.number : IsLiveViewCanRecoverTest_0003 + * @tc.name : IsLiveViewCanRecover + * @tc.desc : Test IsLiveViewCanRecover and liveview is expired. + */ +HWTEST_F(AdvancedNotificationServiceTest, IsLiveViewCanRecoverTest_0003, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsLiveViewCanRecoverTest_0003 test start"; + sptr request = new NotificationRequest(); + std::shared_ptr liveViewContent = std::make_shared(); + std::shared_ptr content = std::make_shared(liveViewContent); + liveViewContent->SetLiveViewStatus(NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE); + request->SetContent(content); + request->SetFinishDeadLine(0); + + ASSERT_EQ(advancedNotificationService_->IsLiveViewCanRecover(request), false); + GTEST_LOG_(INFO) << "IsLiveViewCanRecoverTest_0003 test end"; +} + +/** + * @tc.number : IsLiveViewCanRecoverTest_0004 + * @tc.name : IsLiveViewCanRecover + * @tc.desc : Test IsLiveViewCanRecover and liveview status is create and not expired. + */ +HWTEST_F(AdvancedNotificationServiceTest, IsLiveViewCanRecoverTest_0004, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsLiveViewCanRecoverTest_0004 test start"; + sptr request = new NotificationRequest(); + std::shared_ptr liveViewContent = std::make_shared(); + std::shared_ptr content = std::make_shared(liveViewContent); + liveViewContent->SetLiveViewStatus(NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE); + request->SetContent(content); + + auto now = std::chrono::system_clock::now(); + auto duration = std::chrono::duration_cast(now.time_since_epoch()); + request->SetFinishDeadLine(duration.count() + NotificationConstant::MAX_FINISH_TIME); + request->SetUpdateDeadLine(duration.count() + NotificationConstant::MAX_UPDATE_TIME); + + ASSERT_EQ(advancedNotificationService_->IsLiveViewCanRecover(request), true); + GTEST_LOG_(INFO) << "IsLiveViewCanRecoverTest_0004 test end"; +} + +/** + * @tc.number : FillNotificationRecordTest_0001 + * @tc.name : FillNotificationRecord + * @tc.desc : Test FillNotificationRecord and request is nullptr. + */ +HWTEST_F(AdvancedNotificationServiceTest, FillNotificationRecordTest_0001, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "FillNotificationRecordTest_0001 test start"; + AdvancedNotificationService::NotificationRequestDb requestDbObj = { .request = nullptr, .bundleOption = nullptr}; + auto record = std::make_shared(); + + EXPECT_NE(advancedNotificationService_->FillNotificationRecord(requestDbObj, record), ERR_OK); + GTEST_LOG_(INFO) << "FillNotificationRecordTest_0001 test end"; +} + +/** + * @tc.number : FillNotificationRecordTest_0002 + * @tc.name : FillNotificationRecord + * @tc.desc : Test FillNotificationRecord and request/bundleOption is valid. + */ +HWTEST_F(AdvancedNotificationServiceTest, FillNotificationRecordTest_0002, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "FillNotificationRecordTest_0002 test start"; + sptr request = new NotificationRequest(); + request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + std::string bundleName = "BundleName"; + int32_t uid = 10; + sptr bundleOption = new NotificationBundleOption(bundleName, uid); + AdvancedNotificationService::NotificationRequestDb requestDbObj = + { .request = request, .bundleOption = bundleOption }; + auto record = std::make_shared(); + + ASSERT_EQ(advancedNotificationService_->FillNotificationRecord(requestDbObj, record), ERR_OK); + GTEST_LOG_(INFO) << "FillNotificationRecordTest_0002 test end"; +} + +/** + * @tc.number : RecoverLiveViewFromDb_0002 + * @tc.name : RecoverLiveViewFromDb + * @tc.desc : Test RecoverLiveViewFromDb and liveView can't recover from db. + */ +HWTEST_F(AdvancedNotificationServiceTest, RecoverLiveViewFromDb_0002, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "RecoverLiveViewFromDb_0002 test start"; + advancedNotificationService_->notificationList_.clear(); + sptr request = new NotificationRequest(1); + std::shared_ptr liveViewContent = std::make_shared(); + std::shared_ptr content = std::make_shared(liveViewContent); + liveViewContent->SetLiveViewStatus(NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_END); + request->SetContent(content); + request->SetCreatorUid(1); + request->SetCreatorUserId(2); + request->SetLabel("test_2"); + + std::string bundleName = "BundleName_02"; + int32_t uid = 11; + sptr bundleOption = new NotificationBundleOption(bundleName, uid); + AdvancedNotificationService::NotificationRequestDb requestDbObj = + { .request = request, .bundleOption = bundleOption }; + auto result = advancedNotificationService_->SetNotificationRequestToDb(requestDbObj); + ASSERT_EQ(result, ERR_OK); + + advancedNotificationService_->RecoverLiveViewFromDb(); + ASSERT_EQ(advancedNotificationService_->notificationList_.size(), 0); + + result = advancedNotificationService_->DeleteNotificationRequestFromDb(request->GetKey(), 0); + ASSERT_EQ(result, ERR_OK); + + GTEST_LOG_(INFO) << "RecoverLiveViewFromDb_0002 test end"; +} + +/** + * @tc.number : IsNeedPushCheckTest_0001 + * @tc.name : IsNeedPushCheckTest + * @tc.desc : Test live view notification need pushCheck. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, IsNeedPushCheckTest_0001, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0001 test start"; + sptr request = new NotificationRequest(); + std::shared_ptr liveViewContent = std::make_shared(); + auto status = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE; + liveViewContent->SetLiveViewStatus(status); + std::shared_ptr content = std::make_shared(liveViewContent); + request->SetContent(content); + request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + MockIsVerfyPermisson(false); + ASSERT_EQ(advancedNotificationService_->IsNeedPushCheck(request), true); + + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0001 test end"; +} + +/** + * @tc.number : IsNeedPushCheckTest_0002 + * @tc.name : IsNeedPushCheckTest + * @tc.desc : Test notification except live view registered need push check. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, IsNeedPushCheckTest_0002, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0002 test start"; + + auto pushCallbackProxy = new (std::nothrow)MockPushCallBackStub(); + EXPECT_NE(pushCallbackProxy, nullptr); + sptr pushCallback = pushCallbackProxy->AsObject(); + sptr pushCallBack = iface_cast(pushCallback); + + std::shared_ptr normalContent = std::make_shared(); + EXPECT_NE(normalContent, nullptr); + normalContent->SetText("normalContent's text"); + normalContent->SetTitle("normalContent's title"); + std::shared_ptr content = std::make_shared(normalContent); + + advancedNotificationService_->pushCallBacks_.clear(); + advancedNotificationService_->checkRequests_.clear(); + sptr notificationCheckRequest = new (std::nothrow)NotificationCheckRequest(); + notificationCheckRequest->SetSlotType(NotificationConstant::SlotType::CUSTOM); + notificationCheckRequest->SetContentType(NotificationContent::Type::BASIC_TEXT); + advancedNotificationService_->pushCallBacks_.insert_or_assign( + notificationCheckRequest->GetSlotType(), pushCallBack); + advancedNotificationService_->checkRequests_.insert_or_assign( + notificationCheckRequest->GetSlotType(), notificationCheckRequest); + + sptr request = new NotificationRequest(); + request->SetContent(content); + request->SetSlotType(NotificationConstant::SlotType::CUSTOM); + ASSERT_EQ(advancedNotificationService_->IsNeedPushCheck(request), true); + advancedNotificationService_->pushCallBacks_.clear(); + advancedNotificationService_->checkRequests_.clear(); + + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0002 test end"; +} + +/** + * @tc.number : IsNeedPushCheckTest_0003 + * @tc.name : IsNeedPushCheckTest + * @tc.desc : Test notification except live view unregistered don't need push check. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, IsNeedPushCheckTest_0003, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0003 test start"; + sptr request = new NotificationRequest(); + request->SetSlotType(NotificationConstant::SlotType::CUSTOM); + ASSERT_EQ(advancedNotificationService_->IsNeedPushCheck(request), false); + + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0003 test end"; +} + +/** + * @tc.number : IsNeedPushCheckTest_0004 + * @tc.name : IsNeedPushCheckTest + * @tc.desc : Test notification published by system app don't need push check. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, IsNeedPushCheckTest_0004, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0004 test start"; + + sptr request = new NotificationRequest(); + request->SetSlotType(NotificationConstant::SlotType::CUSTOM); + ASSERT_EQ(advancedNotificationService_->IsNeedPushCheck(request), false); + + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0004 test end"; +} + +/** + * @tc.number : IsNeedPushCheckTest_0005 + * @tc.name : IsNeedPushCheckTest + * @tc.desc : Test live view notification except create status don't need pushCheck. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, IsNeedPushCheckTest_0005, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0005 test start"; + sptr request = new NotificationRequest(); + std::shared_ptr liveViewContent = std::make_shared(); + auto status = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE; + liveViewContent->SetLiveViewStatus(status); + std::shared_ptr content = std::make_shared(liveViewContent); + request->SetContent(content); + request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + ASSERT_EQ(advancedNotificationService_->IsNeedPushCheck(request), false); + + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0005 test end"; +} + +/** + * @tc.number : IsNeedPushCheckTest_0006 + * @tc.name : IsNeedPushCheckTest + * @tc.desc : Test notification except live view registered but has inconsistent contentType dont't need push check. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, IsNeedPushCheckTest_0006, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0006 test start"; + + auto pushCallbackProxy = new (std::nothrow)MockPushCallBackStub(); + EXPECT_NE(pushCallbackProxy, nullptr); + sptr pushCallback = pushCallbackProxy->AsObject(); + sptr pushCallBack = iface_cast(pushCallback); + + std::shared_ptr normalContent = std::make_shared(); + EXPECT_NE(normalContent, nullptr); + normalContent->SetText("normalContent's text"); + normalContent->SetTitle("normalContent's title"); + std::shared_ptr content = std::make_shared(normalContent); + + sptr notificationCheckRequest = new (std::nothrow)NotificationCheckRequest(); + notificationCheckRequest->SetSlotType(NotificationConstant::SlotType::CUSTOM); + notificationCheckRequest->SetContentType(NotificationContent::Type::PICTURE); + advancedNotificationService_->pushCallBacks_.insert_or_assign( + notificationCheckRequest->GetSlotType(), pushCallBack); + advancedNotificationService_->checkRequests_.insert_or_assign( + notificationCheckRequest->GetSlotType(), notificationCheckRequest); + + sptr request = new NotificationRequest(); + request->SetContent(content); + request->SetSlotType(NotificationConstant::SlotType::CUSTOM); + ASSERT_EQ(advancedNotificationService_->IsNeedPushCheck(request), false); + advancedNotificationService_->pushCallBacks_.clear(); + advancedNotificationService_->checkRequests_.clear(); + + GTEST_LOG_(INFO) << "IsNeedPushCheckTest_0006 test end"; +} +/** + * @tc.number : PushCheckTest_0001 + * @tc.name : PushCheckTest + * @tc.desc : Test registerer of push check is allowed. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, PushCheckTest_0001, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "PushCheckTest_0001 test start"; + + auto pushCallbackProxy = new (std::nothrow)MockPushCallBackStub(); + EXPECT_NE(pushCallbackProxy, nullptr); + sptr pushCallback = pushCallbackProxy->AsObject(); + sptr notificationCheckRequest = new (std::nothrow)NotificationCheckRequest(); + notificationCheckRequest->SetSlotType(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr pushCallBack = iface_cast(pushCallback); + advancedNotificationService_->pushCallBacks_.insert_or_assign( + notificationCheckRequest->GetSlotType(), pushCallBack); + advancedNotificationService_->checkRequests_.insert_or_assign( + notificationCheckRequest->GetSlotType(), notificationCheckRequest); + + sptr request = new NotificationRequest(); + request->SetSlotType(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + + ASSERT_EQ(advancedNotificationService_->PushCheck(request), ERR_OK); + + advancedNotificationService_->pushCallBacks_.clear(); + advancedNotificationService_->checkRequests_.clear(); + + GTEST_LOG_(INFO) << "PushCheckTest_0001 test end"; +} + +/** + * @tc.number : GetActiveNotificationByFilter_0001 + * @tc.name : GetActiveNotificationByFilter + * @tc.desc : Test get non-existent live view notification request by filter. + * @tc.require : #I6Z5OV + */ +HWTEST_F(AdvancedNotificationServiceTest, GetActiveNotificationByFilter_0001, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GetActiveNotificationByFilter_0001 test start"; + + TestAddSlot(NotificationConstant::SlotType::LIVE_VIEW); + sptr req; + + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + int32_t notificationId = 1; + std::string label = "GetActiveNotificationByFilter's label"; + std::vector extraInfoKeys; + + ASSERT_EQ(advancedNotificationService_->GetActiveNotificationByFilter(bundleOption, notificationId, label, + extraInfoKeys, req), (int)ERR_ANS_NOTIFICATION_NOT_EXISTS); + + GTEST_LOG_(INFO) << "GetActiveNotificationByFilter_0001 test end"; +} + +/** + * @tc.number : IsAllowedRemoveSlot_0001 + * @tc.name : IsAllowedRemoveSlot + * @tc.desc : Test IsAllowedRemoveSlot and slotType is not liveView. + */ +HWTEST_F(AdvancedNotificationServiceTest, IsAllowedRemoveSlot_0001, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsAllowedRemoveSlot_0001 test start"; + sptr bundleOption = new NotificationBundleOption(); + ASSERT_EQ(advancedNotificationService_->IsAllowedRemoveSlot(bundleOption, NotificationConstant::SlotType::OTHER), + (int)ERR_OK); + GTEST_LOG_(INFO) << "IsAllowedRemoveSlot_0001 test end"; +} + +/** + * @tc.number : IsAllowedRemoveSlot_0002 + * @tc.name : IsAllowedRemoveSlot + * @tc.desc : Test IsAllowedRemoveSlot and slot is not exist. + */ +HWTEST_F(AdvancedNotificationServiceTest, IsAllowedRemoveSlot_0002, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsAllowedRemoveSlot_0002 test start"; + sptr bundleOption = new NotificationBundleOption(); + ASSERT_EQ(advancedNotificationService_->IsAllowedRemoveSlot(bundleOption, + NotificationConstant::SlotType::LIVE_VIEW), (int)ERR_OK); + GTEST_LOG_(INFO) << "IsAllowedRemoveSlot_0002 test end"; +} + +/** + * @tc.number : IsAllowedRemoveSlot_0003 + * @tc.name : IsAllowedRemoveSlot + * @tc.desc : Test IsAllowedRemoveSlot and slot is forcecontrol is false + */ +HWTEST_F(AdvancedNotificationServiceTest, IsAllowedRemoveSlot_0003, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsAllowedRemoveSlot_0003 test start"; + TestAddLiveViewSlot(false); + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_EQ(advancedNotificationService_->IsAllowedRemoveSlot(bundleOption, + NotificationConstant::SlotType::LIVE_VIEW), (int)ERR_OK); + GTEST_LOG_(INFO) << "IsAllowedRemoveSlot_0003 test end"; +} + +/** + * @tc.number : IsAllowedRemoveSlot_0004 + * @tc.name : IsAllowedRemoveSlot + * @tc.desc : Test IsAllowedRemoveSlot and caller not sa or systemapp + */ +HWTEST_F(AdvancedNotificationServiceTest, IsAllowedRemoveSlot_0004, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsAllowedRemoveSlot_0004 test start"; + TestAddLiveViewSlot(true); + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_EQ(advancedNotificationService_->IsAllowedRemoveSlot(bundleOption, + NotificationConstant::SlotType::LIVE_VIEW), (int)ERR_ANS_NON_SYSTEM_APP); + GTEST_LOG_(INFO) << "IsAllowedRemoveSlot_0004 test end"; +} + +/** + * @tc.number : IsAllowedRemoveSlot_0005 + * @tc.name : IsAllowedRemoveSlot + * @tc.desc : Test IsAllowedRemoveSlot and caller is systemapp + */ +HWTEST_F(AdvancedNotificationServiceTest, IsAllowedRemoveSlot_0005, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsAllowedRemoveSlot_0005 test start"; + TestAddLiveViewSlot(true); + sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_EQ(advancedNotificationService_->IsAllowedRemoveSlot(bundleOption, + NotificationConstant::SlotType::LIVE_VIEW), (int)ERR_OK); + GTEST_LOG_(INFO) << "IsAllowedRemoveSlot_0005 test end"; +} + +/** + * @tc.name: NotificationSvrQueue_00001 + * @tc.desc: Test notificationSvrQueue is nullptr + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, NotificationSvrQueue_00001, Function | SmallTest | Level1) +{ + advancedNotificationService_->notificationSvrQueue_ = nullptr; + auto bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + auto request = new (std::nothrow) NotificationRequest(); + + auto ret = advancedNotificationService_->CancelPreparedNotification(1, "label", bundle, 8); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + std::vector> requests; + ret = advancedNotificationService_->GetActiveNotifications(requests, 0); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + uint64_t num = 0; + ret = advancedNotificationService_->GetActiveNotificationNums(num); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + int importance = 0; + ret = advancedNotificationService_->GetBundleImportance(importance); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + std::vector> notifications; + ret = advancedNotificationService_->GetAllActiveNotifications(notifications); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + std::vector keys; + ret = advancedNotificationService_->GetSpecialActiveNotifications(keys, notifications); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + bool enabled = false; + ret = advancedNotificationService_->IsDistributedEnabled(enabled); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + ret = advancedNotificationService_->EnableDistributed(enabled); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.name: NotificationSvrQueue_00002 + * @tc.desc: Test notificationSvrQueue is nullptr + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, NotificationSvrQueue_00002, Function | SmallTest | Level1) +{ + advancedNotificationService_->notificationSvrQueue_ = nullptr; + auto bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + sptr bundle1 = nullptr; + auto request = new (std::nothrow) NotificationRequest(); + + auto ret = advancedNotificationService_->EnableDistributedSelf(true); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + bool enable = false; + ret = advancedNotificationService_->IsDistributedEnableByBundle(bundle, enable); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + ret = advancedNotificationService_->GetHasPoppedDialog(bundle1, enable); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + ret = advancedNotificationService_->SetSyncNotificationEnabledWithoutApp(1, enable); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + ret = advancedNotificationService_->GetSyncNotificationEnabledWithoutApp(1, enable); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + request->SetIsCoverActionButtons(true); + advancedNotificationService_->FillActionButtons(request); +} + +/** + * @tc.name: AssignToNotificationList_00001 + * @tc.desc: Test AssignToNotificationList + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, AssignToNotificationList_00001, Function | SmallTest | Level1) +{ + auto slotType = NotificationConstant::SlotType::LIVE_VIEW; + sptr request = new (std::nothrow) NotificationRequest(); + auto bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + auto liveViewContent = std::make_shared(); + std::shared_ptr content = std::make_shared(liveViewContent); + request->SetContent(content); + request->SetSlotType(slotType); + request->SetNotificationId(1); + auto record = advancedNotificationService_->MakeNotificationRecord(request, bundle); + auto ret = advancedNotificationService_->AssignToNotificationList(record); + + ret = advancedNotificationService_->AssignToNotificationList(record); + ASSERT_EQ(ret, (int)ERR_OK); + ASSERT_EQ(advancedNotificationService_->notificationList_.size(), 1); +} + +/** + * @tc.name: StartArchiveTimer_00001 + * @tc.desc: Test StartArchiveTimer + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, StartArchiveTimer_00001, Function | SmallTest | Level1) +{ + auto slotType = NotificationConstant::SlotType::LIVE_VIEW; + sptr request = new (std::nothrow) NotificationRequest(); + request->SetSlotType(slotType); + request->SetAutoDeletedTime(NotificationConstant::NO_DELAY_DELETE_TIME); + auto bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + auto record = advancedNotificationService_->MakeNotificationRecord(request, bundle); + advancedNotificationService_->StartArchiveTimer(record); + ASSERT_EQ(request->GetAutoDeletedTime(), 0); +} + +/** + * @tc.name: Filter_00001 + * @tc.desc: Test Filter + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, Filter_00001, Function | SmallTest | Level1) +{ + auto bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + auto request = new (std::nothrow) NotificationRequest(); + auto record = advancedNotificationService_->MakeNotificationRecord(request, bundle); + + advancedNotificationService_->notificationSlotFilter_ = nullptr; + auto ret = advancedNotificationService_->Filter(record, true); + ASSERT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.name: ChangeNotificationByControlFlags_00001 + * @tc.desc: Test ChangeNotificationByControlFlags + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, ChangeNotificationByControlFlags_00001, Function | SmallTest | Level1) +{ + auto bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + auto request = new (std::nothrow) NotificationRequest(); + uint32_t notificationControlFlags = 0; + notificationControlFlags |= NotificationConstant::ReminderFlag::SOUND_FLAG; + notificationControlFlags |= NotificationConstant::ReminderFlag::LOCKSCREEN_FLAG; + notificationControlFlags |= NotificationConstant::ReminderFlag::BANNER_FLAG; + notificationControlFlags |= NotificationConstant::ReminderFlag::LIGHTSCREEN_FLAG; + notificationControlFlags |= NotificationConstant::ReminderFlag::VIBRATION_FLAG; + notificationControlFlags |= NotificationConstant::ReminderFlag::STATUSBAR_ICON_FLAG; + request->SetNotificationControlFlags(notificationControlFlags); + + std::shared_ptr flags = std::make_shared(); + flags->SetSoundEnabled(NotificationConstant::FlagStatus::OPEN); + flags->SetVibrationEnabled(NotificationConstant::FlagStatus::OPEN); + flags->SetLockScreenVisblenessEnabled(true); + flags->SetBannerEnabled(true); + flags->SetLightScreenEnabled(true); + flags->SetStatusIconEnabled(true); + request->SetFlags(flags); + + auto record = advancedNotificationService_->MakeNotificationRecord(request, bundle); + advancedNotificationService_->ChangeNotificationByControlFlags(record); + + u_int32_t reminderFlags = flags->GetReminderFlags(); + ASSERT_EQ(reminderFlags, 0); +} + +/** + * @tc.name: CheckPublishPreparedNotification_00001 + * @tc.desc: Test CheckPublishPreparedNotification + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, CheckPublishPreparedNotification_00001, Function | SmallTest | Level1) +{ + auto bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + auto request = new (std::nothrow) NotificationRequest(); + auto record = advancedNotificationService_->MakeNotificationRecord(request, bundle); + + auto ret = advancedNotificationService_->CheckPublishPreparedNotification(record, true); + ASSERT_EQ(ret, (int)ERR_OK); +} + +/** + * @tc.name: GetRecordFromNotificationList_00001 + * @tc.desc: Test GetRecordFromNotificationList + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, GetRecordFromNotificationList_00001, Function | SmallTest | Level1) +{ + sptr request = new (std::nothrow) NotificationRequest(); + auto bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + request->SetLabel("label"); + request->SetNotificationId(1); + auto record = advancedNotificationService_->MakeNotificationRecord(request, bundle); + auto ret = advancedNotificationService_->AssignToNotificationList(record); + + auto res = advancedNotificationService_->GetRecordFromNotificationList( + 1, SYSTEM_APP_UID, "label", TEST_DEFUALT_BUNDLE); + EXPECT_NE(res, nullptr); +} + +/** + * @tc.name: RegisterPushCallback_00001 + * @tc.desc: Test RegisterPushCallback + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, RegisterPushCallback_00001, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + MockIsVerfyPermisson(false); + + sptr pushCallback = nullptr; + sptr request = nullptr; + + auto ret = advancedNotificationService_->RegisterPushCallback(pushCallback, request); + ASSERT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); + + MockIsVerfyPermisson(true); + ret = advancedNotificationService_->RegisterPushCallback(pushCallback, request); + ASSERT_EQ(ret, (int)ERR_INVALID_VALUE); + + auto pushCallbackProxy = new (std::nothrow)MockPushCallBackStub(); + EXPECT_NE(pushCallbackProxy, nullptr); + pushCallback = pushCallbackProxy->AsObject(); + ret = advancedNotificationService_->RegisterPushCallback(pushCallback, request); + ASSERT_EQ(ret, (int)ERR_INVALID_VALUE); +} + +/** + * @tc.name: UnregisterPushCallback_00001 + * @tc.desc: Test UnregisterPushCallback + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, UnregisterPushCallback_00001, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + MockIsVerfyPermisson(false); + + auto ret = advancedNotificationService_->UnregisterPushCallback(); + ASSERT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.name: CreateDialogManager_00001 + * @tc.desc: Test CreateDialogManager + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, CreateDialogManager_00001, Function | SmallTest | Level1) +{ + advancedNotificationService_->dialogManager_ = nullptr; + bool ret = advancedNotificationService_->CreateDialogManager(); + ASSERT_EQ(ret, true); + + ret = advancedNotificationService_->CreateDialogManager(); + ASSERT_EQ(ret, true); +} + +/** + * @tc.number : IsNeedNotifyConsumed_00001 + * @tc.name : IsNeedNotifyConsumed + * @tc.desc : Test IsNeedNotifyConsumed function. + */ +HWTEST_F(AdvancedNotificationServiceTest, IsNeedNotifyConsumed_00001, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsNeedNotifyConsumed_00001 test start"; + sptr request = new (std::nothrow) NotificationRequest(); + request->SetSlotType(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + ASSERT_EQ(advancedNotificationService_->IsNeedNotifyConsumed(request), true); + GTEST_LOG_(INFO) << "IsNeedNotifyConsumed_00001 test end"; +} + +/** + * @tc.number : IsNeedNotifyConsumed_00002 + * @tc.name : IsNeedNotifyConsumed + * @tc.desc : Test IsNeedNotifyConsumed function. + */ +HWTEST_F(AdvancedNotificationServiceTest, IsNeedNotifyConsumed_00002, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsNeedNotifyConsumed_00002 test start"; + sptr request = new (std::nothrow) NotificationRequest(); + request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + auto liveViewContent = std::make_shared(); + liveViewContent->SetLiveViewStatus(NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE); + std::shared_ptr content = std::make_shared(liveViewContent); + request->SetContent(content); + ASSERT_EQ(advancedNotificationService_->IsNeedNotifyConsumed(request), true); + GTEST_LOG_(INFO) << "IsNeedNotifyConsumed_00002 test end"; +} + +/** + * @tc.number : GetAllNotificationEnabledBundles_0001 + * @tc.name : GetAllNotificationEnabledBundles + * @tc.desc : Test GetAllNotificationEnabledBundles function if not systemapp. + * @tc.require : #I92VGR + */ +HWTEST_F(AdvancedNotificationServiceTest, GetAllNotificationEnabledBundles_0001, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "GetAllNotificationEnabledBundles_0001 test start"; + + std::vector vec; + ASSERT_EQ(advancedNotificationService_->GetAllNotificationEnabledBundles(vec), ERR_ANS_NON_SYSTEM_APP); + + GTEST_LOG_(INFO) << "GetAllNotificationEnabledBundles_0001 test end"; +} + +/** + * @tc.number : IsNeedNotifyConsumed_00003 + * @tc.name : IsNeedNotifyConsumed + * @tc.desc : Test IsNeedNotifyConsumed function. + */ +HWTEST_F(AdvancedNotificationServiceTest, IsNeedNotifyConsumed_00003, Function | SmallTest | Level1) +{ + GTEST_LOG_(INFO) << "IsNeedNotifyConsumed_00003 test start"; + sptr request = new (std::nothrow) NotificationRequest(); + request->SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + auto liveViewContent = std::make_shared(); + liveViewContent->SetLiveViewStatus(NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_END); + std::shared_ptr content = std::make_shared(liveViewContent); + request->SetContent(content); + request->SetAutoDeletedTime(0); + ASSERT_EQ(advancedNotificationService_->IsNeedNotifyConsumed(request), false); + GTEST_LOG_(INFO) << "IsNeedNotifyConsumed_00003 test end"; +} + +/** + * @tc.number : SetBadgeNumberByBundle_00001 + * @tc.name : SetBadgeNumberByBundle + * @tc.desc : Test SetBadgeNumberByBundle with valid parameters, expect error code ERR_OK. + */ +HWTEST_F(AdvancedNotificationServiceTest, SetBadgeNumberByBundle_00001, Function | SmallTest | Level1) +{ + ASSERT_NE(advancedNotificationService_, nullptr); + MockIsSystemApp(true); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + ASSERT_NE(bundleOption, nullptr); + std::string bundleName = "invalidBundleName"; + bundleOption->SetBundleName(bundleName); + int32_t badgeNumber = 1; + ASSERT_EQ(advancedNotificationService_->SetBadgeNumberByBundle(bundleOption, badgeNumber), ERR_OK); +} + +/** + * @tc.number : SetBadgeNumberByBundle_00002 + * @tc.name : SetBadgeNumberByBundle + * @tc.desc : Test SetBadgeNumberByBundle with nullptr bundle option, expect error code ERR_ANS_INVALID_PARAM. + */ +HWTEST_F(AdvancedNotificationServiceTest, SetBadgeNumberByBundle_00002, Function | SmallTest | Level1) +{ + ASSERT_NE(advancedNotificationService_, nullptr); + MockIsSystemApp(true); + sptr bundleOption = nullptr; + int32_t badgeNumber = 1; + ASSERT_EQ(advancedNotificationService_->SetBadgeNumberByBundle(bundleOption, badgeNumber), ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.name: QueryDoNotDisturbProfile_0100 + * @tc.desc: test QueryDoNotDisturbProfile successfully called + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, QueryDoNotDisturbProfile_0100, TestSize.Level1) +{ + std::string enable; + std::string profileId; + int32_t userId = 100; + EXPECT_NE(advancedNotificationService_, nullptr); + advancedNotificationService_->QueryDoNotDisturbProfile(userId, enable, profileId); +} + +/** + * @tc.name: CheckDoNotDisturbProfile_0100 + * @tc.desc: test CheckDoNotDisturbProfile successfully called + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, CheckDoNotDisturbProfile_0100, TestSize.Level1) +{ + auto bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + auto request = new (std::nothrow) NotificationRequest(); + auto record = advancedNotificationService_->MakeNotificationRecord(request, bundle); + EXPECT_NE(advancedNotificationService_, nullptr); + advancedNotificationService_->CheckDoNotDisturbProfile(record); +} + +/** + * @tc.name: DoNotDisturbUpdataReminderFlags_0100 + * @tc.desc: test DoNotDisturbUpdataReminderFlags can turn off all reminders. + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, DoNotDisturbUpdataReminderFlags_0100, TestSize.Level1) +{ + auto bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + auto request = new (std::nothrow) NotificationRequest(); + auto record = advancedNotificationService_->MakeNotificationRecord(request, bundle); + std::shared_ptr flagsSet = std::make_shared(); + record->request->SetFlags(flagsSet); + sptr notification = new (std::nothrow) Notification(request); + record->request = request; + record->notification = notification; + advancedNotificationService_->DoNotDisturbUpdataReminderFlags(record); + auto flags = record->request->GetFlags(); + EXPECT_NE(flags, nullptr); + auto res = flags->IsStatusIconEnabled(); + ASSERT_EQ(res, false); +} + +#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED +/** + * @tc.name: RegisterSwingCallback_00001 + * @tc.desc: Test RegisterSwingCallback + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, RegisterSwingCallback_00001, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + MockIsVerfyPermisson(false); + sptr swingCallback = nullptr; + auto ret = advancedNotificationService_->RegisterSwingCallback(swingCallback); + ASSERT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.name: RegisterSwingCallback_00002 + * @tc.desc: Test RegisterSwingCallback + * @tc.type: FUNC + */ +HWTEST_F(AdvancedNotificationServiceTest, RegisterSwingCallback_00002, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + MockIsVerfyPermisson(true); + sptr swingCallback = nullptr; + auto ret = advancedNotificationService_->RegisterSwingCallback(swingCallback); + ASSERT_EQ(ret, (int)ERR_ANS_NON_SYSTEM_APP); +} +#endif + +/** + * @tc.number : AddExcludeDate_00001 + * @tc.name : Test AddExcludeDate + * @tc.desc : Test AddExcludeDate function when the result is ERR_NO_INIT + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AddExcludeDate_00001, Function | SmallTest | Level1) +{ + int32_t reminderId = 10; + uint64_t time = 124325; + ASSERT_EQ(advancedNotificationService_->AddExcludeDate(reminderId, time), (int)ERR_REMINDER_PERMISSION_DENIED); + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + MockIsNonBundleName(true); + ASSERT_EQ(advancedNotificationService_->AddExcludeDate(reminderId, time), (int)ERR_ANS_INVALID_BUNDLE); + MockIsNonBundleName(false); + ASSERT_EQ(advancedNotificationService_->AddExcludeDate(reminderId, time), (int)ERR_NO_INIT); + MockIsVerfyPermisson(false); +} + +/** + * @tc.number : DelExcludeDates_00002 + * @tc.name : Test DelExcludeDates + * @tc.desc : Test DelExcludeDates function when the result is ERR_NO_INIT + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, DelExcludeDates_00002, Function | SmallTest | Level1) +{ + int32_t reminderId = 10; + ASSERT_EQ(advancedNotificationService_->DelExcludeDates(reminderId), (int)ERR_REMINDER_PERMISSION_DENIED); + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + MockIsNonBundleName(true); + ASSERT_EQ(advancedNotificationService_->DelExcludeDates(reminderId), (int)ERR_ANS_INVALID_BUNDLE); + MockIsNonBundleName(false); + ASSERT_EQ(advancedNotificationService_->DelExcludeDates(reminderId), (int)ERR_NO_INIT); + MockIsVerfyPermisson(false); +} + +/** + * @tc.number : GetExcludeDates_00001 + * @tc.name : Test GetExcludeDates + * @tc.desc : Test GetExcludeDates function when the result is ERR_NO_INIT + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, GetExcludeDates_00001, Function | SmallTest | Level1) +{ + int32_t reminderId = 10; + std::vector times; + ASSERT_EQ(advancedNotificationService_->GetExcludeDates(reminderId, times), (int)ERR_REMINDER_PERMISSION_DENIED); + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + MockIsNonBundleName(true); + ASSERT_EQ(advancedNotificationService_->GetExcludeDates(reminderId, times), (int)ERR_ANS_INVALID_BUNDLE); + MockIsNonBundleName(false); + ASSERT_EQ(advancedNotificationService_->GetExcludeDates(reminderId, times), (int)ERR_NO_INIT); + MockIsVerfyPermisson(false); +} +} // namespace Notification +} // namespace OHOS diff --git a/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp b/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp index d640882e6..f87a6ce8c 100644 --- a/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp +++ b/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp @@ -1,1319 +1,1336 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "ans_inner_errors.h" -#include "ans_ut_constant.h" -#define private public -#define protected public -#include "advanced_notification_service.h" -#include "notification_subscriber_manager.h" -#undef private -#undef protected -#include "ans_inner_errors.h" -#include "mock_ipc_skeleton.h" - -extern void MockGetUserId(bool mockRet); -extern void MockGetBundleName(bool mockRet); -extern void MockGetNotificationSlotRet(bool mockRet); -extern void MockQueryActiveOsAccountIds(bool mockRet, uint8_t mockCase); - -using namespace OHOS::Security::AccessToken; -using namespace testing::ext; -namespace OHOS { -namespace Notification { -extern void MockGetTokenTypeFlag(ATokenTypeEnum mockRet); -extern void MockIsSystemApp(bool isSystemApp); -extern void MockIsVerfyPermisson(bool isVerify); - -class NotificationSubscriberManagerBranchTest : public testing::Test { -public: - static void SetUpTestCase() {}; - static void TearDownTestCase() {}; - void SetUp() {}; - void TearDown() {}; -}; - -/** - * @tc.number : NotificationSubscriberManager_00100 - * @tc.name : NotificationSubscriberManager_00100 - * @tc.desc : test NotifyConsumed function and notificationSubQueue_ == nullptr - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00100, Function | SmallTest | Level1) -{ - std::shared_ptr notificationSubscriberManager = - std::make_shared(); - ASSERT_NE(nullptr, notificationSubscriberManager); - sptr notification = nullptr; - sptr notificationMap = nullptr; - notificationSubscriberManager->notificationSubQueue_ = nullptr; - notificationSubscriberManager->NotifyConsumed(notification, notificationMap); -} - -/** - * @tc.number : NotificationSubscriberManager_00200 - * @tc.name : NotificationSubscriberManager_00200 - * @tc.desc : test NotifyCanceled function and notificationSubQueue_ == nullptr - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00200, Function | SmallTest | Level1) -{ - std::shared_ptr notificationSubscriberManager = - std::make_shared(); - ASSERT_NE(nullptr, notificationSubscriberManager); - sptr notification = nullptr; - sptr notificationMap = nullptr; - int32_t deleteReason = 1; - notificationSubscriberManager->notificationSubQueue_ = nullptr; - notificationSubscriberManager->NotifyCanceled(notification, notificationMap, deleteReason); -} - -/** - * @tc.number : NotificationSubscriberManager_00300 - * @tc.name : NotificationSubscriberManager_00300 - * @tc.desc : test NotifyUpdated function and notificationSubQueue_ == nullptr - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00300, Function | SmallTest | Level1) -{ - std::shared_ptr notificationSubscriberManager = - std::make_shared(); - ASSERT_NE(nullptr, notificationSubscriberManager); - sptr notificationMap = nullptr; - notificationSubscriberManager->notificationSubQueue_ = nullptr; - notificationSubscriberManager->NotifyUpdated(notificationMap); -} - -/** - * @tc.number : NotificationSubscriberManager_00400 - * @tc.name : NotificationSubscriberManager_00400 - * @tc.desc : test NotifyDoNotDisturbDateChanged function and notificationSubQueue_ == nullptr - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00400, Function | SmallTest | Level1) -{ - std::shared_ptr notificationSubscriberManager = - std::make_shared(); - ASSERT_NE(nullptr, notificationSubscriberManager); - sptr date = nullptr; - notificationSubscriberManager->notificationSubQueue_ = nullptr; - notificationSubscriberManager->NotifyDoNotDisturbDateChanged(0, date); -} - -/** - * @tc.number : NotificationSubscriberManager_00500 - * @tc.name : NotificationSubscriberManager_00500 - * @tc.desc : test NotifyEnabledNotificationChanged function and notificationSubQueue_ == nullptr - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00500, Function | SmallTest | Level1) -{ - std::shared_ptr notificationSubscriberManager = - std::make_shared(); - ASSERT_NE(nullptr, notificationSubscriberManager); - sptr callbackData = nullptr; - notificationSubscriberManager->notificationSubQueue_ = nullptr; - notificationSubscriberManager->NotifyEnabledNotificationChanged(callbackData); -} - -/** - * @tc.number : NotificationSubscriberManager_00600 - * @tc.name : NotificationSubscriberManager_00600 - * @tc.desc : test OnRemoteDied function and record == nullptr - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00600, Function | SmallTest | Level1) -{ - std::shared_ptr notificationSubscriberManager = - std::make_shared(); - ASSERT_NE(nullptr, notificationSubscriberManager); - wptr object = nullptr; - notificationSubscriberManager->OnRemoteDied(object); -} - -/** - * @tc.number : NotificationSubscriberManager_00700 - * @tc.name : NotificationSubscriberManager_00700 - * @tc.desc : test AddRecordInfo function and subscribeInfo == nullptr - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00700, Function | SmallTest | Level1) -{ - std::shared_ptr notificationSubscriberManager = - std::make_shared(); - ASSERT_NE(nullptr, notificationSubscriberManager); - std::shared_ptr record = - notificationSubscriberManager->CreateSubscriberRecord(nullptr); - sptr subscribeInfo = nullptr; - notificationSubscriberManager->AddRecordInfo(record, subscribeInfo); -} - -/** - * @tc.number : NotificationSubscriberManager_00800 - * @tc.name : NotificationSubscriberManager_00800 - * @tc.desc : test RemoveSubscriberInner function and record == nullptr - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00800, Function | SmallTest | Level1) -{ - NotificationSubscriberManager notificationSubscriberManager; - sptr subscriber = nullptr; - sptr subscribeInfo = nullptr; - ASSERT_EQ(ERR_ANS_INVALID_PARAM, notificationSubscriberManager.RemoveSubscriberInner(subscriber, subscribeInfo)); -} - -/** - * @tc.number : AdvancedNotificationService_00200 - * @tc.name : AdvancedNotificationService_00200 - * @tc.desc : test ActiveNotificationDump function and userId != SUBSCRIBE_USER_INIT - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_00200, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = 1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = new Notification(); - record->request = new NotificationRequest(); - advancedNotificationService.notificationList_.push_back(record); - MockGetUserId(false); - ASSERT_EQ(advancedNotificationService.ActiveNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationService_00300 - * @tc.name : AdvancedNotificationService_00300 - * @tc.desc : test ActiveNotificationDump function and bundle != record->notification->GetBundleName(). - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_00300, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = -1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = new Notification(); - record->request = new NotificationRequest(); - advancedNotificationService.notificationList_.push_back(record); - MockGetUserId(false); - MockGetBundleName(false); - ASSERT_EQ(advancedNotificationService.ActiveNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationService_00400 - * @tc.name : AdvancedNotificationService_00400 - * @tc.desc : test ActiveNotificationDump function and record->deviceId is not empty. - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_00400, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = -1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = new Notification(); - record->request = new NotificationRequest(); - record->deviceId = ""; - advancedNotificationService.notificationList_.push_back(record); - MockGetUserId(false); - MockGetBundleName(false); - ASSERT_EQ(advancedNotificationService.ActiveNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationService_00500 - * @tc.name : AdvancedNotificationService_00500 - * @tc.desc : test ActiveNotificationDump function and record->request->GetOwnerUid() > 0. - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_00500, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = -1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = new Notification(); - record->request = new NotificationRequest(); - int32_t uid = 1; - record->request->SetOwnerUid(uid); - record->deviceId = ""; - advancedNotificationService.notificationList_.push_back(record); - MockGetUserId(false); - MockGetBundleName(false); - ASSERT_EQ(advancedNotificationService.ActiveNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationService_00600 - * @tc.name : AdvancedNotificationService_00600 - * @tc.desc : test ActiveNotificationDump function and record->request->GetOwnerUid() < 0. - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_00600, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = -1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = new Notification(); - record->request = new NotificationRequest(); - int32_t uid = -1; - record->request->SetOwnerUid(uid); - record->deviceId = ""; - advancedNotificationService.notificationList_.push_back(record); - MockGetUserId(false); - MockGetBundleName(false); - ASSERT_EQ(advancedNotificationService.ActiveNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationService_00700 - * @tc.name : AdvancedNotificationService_00700 - * @tc.desc : test DistributedNotificationDump function and record->notification == nullptr. - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_00700, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = 1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = nullptr; - advancedNotificationService.notificationList_.push_back(record); - ASSERT_EQ(advancedNotificationService.DistributedNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationService_00800 - * @tc.name : AdvancedNotificationService_00800 - * @tc.desc : test DistributedNotificationDump function and userId != SUBSCRIBE_USER_INIT. - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_00800, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = 1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = new Notification(); - MockGetUserId(false); - advancedNotificationService.notificationList_.push_back(record); - ASSERT_EQ(advancedNotificationService.DistributedNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationService_00900 - * @tc.name : AdvancedNotificationService_00900 - * @tc.desc : test DistributedNotificationDump function and bundle is not empty. - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_00900, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = -1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = new Notification(); - MockGetUserId(false); - MockGetBundleName(false); - advancedNotificationService.notificationList_.push_back(record); - ASSERT_EQ(advancedNotificationService.DistributedNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationService_01000 - * @tc.name : AdvancedNotificationService_01000 - * @tc.desc : test DistributedNotificationDump function and record->deviceId is empty. - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_01000, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = -1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = new Notification(); - record->deviceId = ""; - MockGetUserId(false); - MockGetBundleName(false); - advancedNotificationService.notificationList_.push_back(record); - ASSERT_EQ(advancedNotificationService.DistributedNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationService_01100 - * @tc.name : AdvancedNotificationService_01100 - * @tc.desc : test DistributedNotificationDump function and record->request->GetOwnerUid() > 0. - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_01100, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = -1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = new Notification(); - record->request = new NotificationRequest(); - int32_t uid = 1; - record->request->SetOwnerUid(uid); - record->deviceId = ""; - MockGetUserId(false); - MockGetBundleName(false); - advancedNotificationService.notificationList_.push_back(record); - ASSERT_EQ(advancedNotificationService.DistributedNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationService_01200 - * @tc.name : AdvancedNotificationService_01200 - * @tc.desc : test DistributedNotificationDump function and record->request->GetOwnerUid() < 0. - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_01200, Function | SmallTest | Level1) -{ - std::string bundle = ""; - int32_t userId = -1; - std::vector dumpInfo; - AdvancedNotificationService advancedNotificationService; - std::shared_ptr record = std::make_shared(); - record->notification = new Notification(); - record->request = new NotificationRequest(); - int32_t uid = -1; - record->request->SetOwnerUid(uid); - record->deviceId = ""; - MockGetUserId(false); - MockGetBundleName(false); - advancedNotificationService.notificationList_.push_back(record); - ASSERT_EQ(advancedNotificationService.DistributedNotificationDump(bundle, userId, 0, dumpInfo), ERR_OK); -} - - -/** - * @tc.number : AdvancedNotificationService_01400 - * @tc.name : AdvancedNotificationService_01400 - * @tc.desc : Test PrepareNotificationRequest function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_01400, Function | SmallTest | Level1) -{ - sptr req = new NotificationRequest(); - bool isAgentTrue = true; - req->SetIsAgentNotification(isAgentTrue); - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.PrepareNotificationRequest(req), ERR_ANS_INVALID_BUNDLE); -} - -/** - * @tc.number : AdvancedNotificationService_01500 - * @tc.name : AdvancedNotificationService_01500 - * @tc.desc : Test CancelAsBundle function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_01500, Function | SmallTest | Level1) -{ - int32_t notificationId = 1; - std::string representativeBundle = ""; - int32_t userId = 2; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.CancelAsBundle(notificationId, representativeBundle, userId), - ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_01600 - * @tc.name : AdvancedNotificationService_01600 - * @tc.desc : Test AddSlots function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_01600, Function | SmallTest | Level1) -{ - std::vector> slots; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.AddSlots(slots), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_01700 - * @tc.name : AdvancedNotificationService_01700 - * @tc.desc : Test Delete function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_01700, Function | SmallTest | Level1) -{ - std::string key = ""; - int32_t removeReason = 1; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.Delete(key, removeReason), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_01800 - * @tc.name : AdvancedNotificationService_01800 - * @tc.desc : Test DeleteByBundle function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_01800, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.DeleteByBundle(bundleOption), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_01900 - * @tc.name : AdvancedNotificationService_01900 - * @tc.desc : Test DeleteAll function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_01900, Function | SmallTest | Level1) -{ - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.DeleteAll(), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_02000 - * @tc.name : AdvancedNotificationService_02000 - * @tc.desc : Test GetSlotsByBundle function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_02000, Function | SmallTest | Level1) -{ - IPCSkeleton::SetCallingUid(SYSTEM_APP_UID); - - sptr bundleOption = nullptr; - std::vector> slots; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.GetSlotsByBundle(bundleOption, slots), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_02100 - * @tc.name : AdvancedNotificationService_02100 - * @tc.desc : Test UpdateSlots function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_02100, Function | SmallTest | Level1) -{ - IPCSkeleton::SetCallingUid(SYSTEM_APP_UID); - - sptr bundleOption = nullptr; - std::vector> slots; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.UpdateSlots(bundleOption, slots), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_02200 - * @tc.name : AdvancedNotificationService_02200 - * @tc.desc : Test SetShowBadgeEnabledForBundle function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_02200, Function | SmallTest | Level1) -{ - IPCSkeleton::SetCallingUid(SYSTEM_APP_UID); - - sptr bundleOption = nullptr; - bool enabled = true; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.SetShowBadgeEnabledForBundle(bundleOption, enabled), - ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_02300 - * @tc.name : AdvancedNotificationService_02300 - * @tc.desc : Test GetShowBadgeEnabledForBundle function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_02300, Function | SmallTest | Level1) -{ - IPCSkeleton::SetCallingUid(SYSTEM_APP_UID); - - sptr bundleOption = nullptr; - bool enabled = true; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.GetShowBadgeEnabledForBundle(bundleOption, enabled), - ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_02400 - * @tc.name : AdvancedNotificationService_02400 - * @tc.desc : Test Unsubscribe function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_02400, Function | SmallTest | Level1) -{ - sptr subscriber = nullptr; - sptr info = nullptr; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.Unsubscribe(subscriber, info), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_02500 - * @tc.name : AdvancedNotificationService_02500 - * @tc.desc : Test GetAllActiveNotifications function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_02500, Function | SmallTest | Level1) -{ - std::vector> notifications; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.GetAllActiveNotifications(notifications), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_02600 - * @tc.name : AdvancedNotificationService_02600 - * @tc.desc : Test GetSpecialActiveNotifications function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_02600, Function | SmallTest | Level1) -{ - std::vector key; - std::vector> notifications; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ( - advancedNotificationService.GetSpecialActiveNotifications(key, notifications), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_02700 - * @tc.name : AdvancedNotificationService_02700 - * @tc.desc : Test SetNotificationsEnabledForAllBundles function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_02700, Function | SmallTest | Level1) -{ - std::string deviceId = ""; - bool enabled = true; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.SetNotificationsEnabledForAllBundles(deviceId, enabled), - ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_02800 - * @tc.name : AdvancedNotificationService_02800 - * @tc.desc : Test SetNotificationsEnabledForAllBundles function and GetActiveUserId is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_02800, Function | SmallTest | Level1) -{ - std::string deviceId = ""; - bool enabled = true; - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_NATIVE); - MockQueryActiveOsAccountIds(false, 1); - - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.SetNotificationsEnabledForAllBundles(deviceId, enabled), - ERR_ANS_GET_ACTIVE_USER_FAILED); -} - -/** - * @tc.number : AdvancedNotificationService_02900 - * @tc.name : AdvancedNotificationService_02900 - * @tc.desc : Test SetNotificationsEnabledForSpecialBundle function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_02900, Function | SmallTest | Level1) -{ - std::string deviceId = ""; - sptr bundleOption = nullptr; - bool enabled = true; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.SetNotificationsEnabledForSpecialBundle(deviceId, bundleOption, enabled), - ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_03000 - * @tc.name : AdvancedNotificationService_03000 - * @tc.desc : Test IsAllowedNotify function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_03000, Function | SmallTest | Level1) -{ - bool enabled = true; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.IsAllowedNotify(enabled), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_03100 - * @tc.name : AdvancedNotificationService_03100 - * @tc.desc : Test IsAllowedNotify function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_03100, Function | SmallTest | Level1) -{ - bool enabled = true; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_NATIVE); - MockQueryActiveOsAccountIds(false, 1); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.IsAllowedNotify(enabled), ERR_ANS_GET_ACTIVE_USER_FAILED); -} - -/** - * @tc.number : AdvancedNotificationService_03200 - * @tc.name : AdvancedNotificationService_03200 - * @tc.desc : Test IsSpecialBundleAllowedNotify function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_03200, Function | SmallTest | Level1) -{ - sptr bundleOption = nullptr; - bool allowed = true; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); - MockIsSystemApp(false); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ( - advancedNotificationService.IsSpecialBundleAllowedNotify(bundleOption, allowed), ERR_ANS_NON_SYSTEM_APP); -} - -/** - * @tc.number : AdvancedNotificationService_03300 - * @tc.name : AdvancedNotificationService_03300 - * @tc.desc : Test IsSpecialBundleAllowedNotify function and targetBundle == nullptr - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_03300, Function | SmallTest | Level1) -{ - sptr bundleOption = nullptr; - bool allowed = true; - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_NATIVE); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ( - advancedNotificationService.IsSpecialBundleAllowedNotify(bundleOption, allowed), ERR_ANS_INVALID_BUNDLE); -} - -/** - * @tc.number : AdvancedNotificationService_03400 - * @tc.name : AdvancedNotificationService_03400 - * @tc.desc : Test IsSpecialBundleAllowedNotify function and GetActiveUserId is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_03400, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - MockQueryActiveOsAccountIds(false, 1); - bool allowed = true; - - int32_t uid = 2; - bundleOption->SetUid(uid); - - MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_NATIVE); - AdvancedNotificationService advancedNotificationService; - ASSERT_EQ(advancedNotificationService.IsSpecialBundleAllowedNotify(bundleOption, allowed), - ERR_ANS_GET_ACTIVE_USER_FAILED); -} - -/** - * @tc.number : AdvancedNotificationService_03500 - * @tc.name : AdvancedNotificationService_03500 - * @tc.desc : Test RemoveNotification function and CheckPermission is false - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_03500, Function | SmallTest | Level1) -{ - sptr bundleOption = nullptr; - int32_t notificationId = 1; - std::string label = "