diff --git a/frameworks/ans/test/unittest/notification_helper_test.cpp b/frameworks/ans/test/unittest/notification_helper_test.cpp index 85597c7e18daf491e5903bc2fa118efd7525c44f..eb49dc9b470bb54dfc87abbf9f2e5f861bcdd1b2 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 326f4505289f248b9eb135c53399d169bb73ea40..814dd4393ea1ccf0fd5f8bef3a55f25c0491316b 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 0190cf750955254684444cc7b2e3267dc927ea2c..f6a05e0509e5ee1a9d028aba89219d72019658a8 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 2b59696a15f14d98c1037f02affc1e5aefe73898..e0ab0c470cd6e5a4820c02fa2bc497ba92b8664c 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/notification.gni b/notification.gni index b04f143f40ab3ddf00f221111f085bbcdbb057f4..08b20e2f3aacc1a17beb43d1a76d136b6c4acbbd 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 d2a104550069ade98562465b5d6e761b7cc8fb0c..e57749b219f87dc81d21f4a2d373ba269aa5ea10 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/include/notification_extension_wrapper.h b/services/ans/include/notification_extension_wrapper.h index 36106c80cabc8dee43cef3bfec0acd5652d0e837..88d465c857969d6c7cee0830d3f855014dd95a09 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 b197da46f037adaec5c7983380cde45bed65e711..fdeeca1418589005d07cf703ffa5f3a5d1cdea96 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.rej b/services/ans/src/advanced_notification_service_ability.cpp.rej new file mode 100644 index 0000000000000000000000000000000000000000..d71dc04ed07e9671b13f46b55b303d86759c35b0 --- /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 47be2d010a5b7a458ed65fe695e8a70394e0b94b..d39ccdcda70233ef0407d31a7795130ceafe77eb 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/test/unittest/advanced_notification_service_branch_test.cpp b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp index 29e5a880939f0ca734f8b69d68e2e09942e4b987..68115327d537b97296f7649689aaa47017210f0e 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_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index ead5526cfc42aeaafa23f46c4d0c90dd4130adf5..c4d103b58b37d78db22fade8b6365956e16f1fc3 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/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 d640882e670bb1d13144ffeffb94bae4afadef22..f87a6ce8caa0aa4a20197499a78c47dcf5cce3be 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 = "