diff --git a/frameworks/core/BUILD.gn b/frameworks/core/BUILD.gn index 35b830b1b111a73287d374ea153cf260983362b1..606ba3b08cdd1cd144174bd9747209a0a3814d75 100644 --- a/frameworks/core/BUILD.gn +++ b/frameworks/core/BUILD.gn @@ -94,7 +94,7 @@ ohos_shared_library("ans_core") { "os_account:os_account_innerkits", "relational_store:native_rdb", "samgr:samgr_proxy", - "time_service:time_service", + "time_service:time_client", ] install_images = [ system_base_dir ] relative_install_dir = "platformsdk" diff --git a/frameworks/core/test/unittest/BUILD.gn b/frameworks/core/test/unittest/BUILD.gn index 701d7950b68970d0f1387642638efaec8bfb0775..4176836bfb30dcf15e942d42808b21f17513fbc9 100644 --- a/frameworks/core/test/unittest/BUILD.gn +++ b/frameworks/core/test/unittest/BUILD.gn @@ -19,6 +19,7 @@ group("unittest") { "ans_callback_stub_test:unittest", "ans_image_util_test:unittest", "ans_manager_death_recipient_test:unittest", + "ans_manager_stub_test:unittest", "ans_subscriber_proxy_test:unittest", "ans_subscriber_stub_test:unittest", ] diff --git a/frameworks/core/test/unittest/ans_manager_death_recipient_test/BUILD.gn b/frameworks/core/test/unittest/ans_manager_death_recipient_test/BUILD.gn index 8037e0d5a56341b56ffbb6c149fbe511d0ad1f82..87376bb9b942b4c4f8f7d8760b493cea9074a89f 100644 --- a/frameworks/core/test/unittest/ans_manager_death_recipient_test/BUILD.gn +++ b/frameworks/core/test/unittest/ans_manager_death_recipient_test/BUILD.gn @@ -1,50 +1,50 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/ohos.gni") -import("//build/test.gni") - -module_output_path = "${component_name}/unittest" - -ohos_unittest("ans_manager_death_recipient_test") { - module_out_path = module_output_path - include_dirs = [ - "${core_path}/include", - "//commonlibrary/c_utils/base/include", - ] - - sources = [ "ans_manager_death_recipient_unit_test.cpp" ] - - deps = [ "${core_path}:ans_core" ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "ability_runtime:wantagent_innerkits", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_framework:image_native", - "relational_store:native_rdb", - ] - - subsystem_name = "${subsystem_name}" - part_name = "${component_name}" -} - -group("unittest") { - testonly = true - deps = [] - - deps += [ ":ans_manager_death_recipient_test" ] -} +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +module_output_path = "${component_name}/unittest" + +ohos_unittest("ans_manager_death_recipient_test") { + module_out_path = module_output_path + include_dirs = [ + "${core_path}/include", + "//commonlibrary/c_utils/base/include", + ] + + sources = [ "ans_manager_death_recipient_unit_test.cpp" ] + + deps = [ "${core_path}:ans_core" ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:wantagent_innerkits", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "multimedia_image_framework:image_native", + "relational_store:native_rdb", + ] + + subsystem_name = "${subsystem_name}" + part_name = "${component_name}" +} + +group("unittest") { + testonly = true + deps = [] + + deps += [ ":ans_manager_death_recipient_test" ] +} diff --git a/frameworks/core/test/unittest/ans_manager_stub_test/BUILD.gn b/frameworks/core/test/unittest/ans_manager_stub_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f0b1edc232e5dc511c8f6b1f54becbfff141d3d8 --- /dev/null +++ b/frameworks/core/test/unittest/ans_manager_stub_test/BUILD.gn @@ -0,0 +1,50 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/ohos.gni") +import("//build/test.gni") + +module_output_path = "${component_name}/unittest" + +ohos_unittest("ans_manager_stub_test") { + module_out_path = module_output_path + include_dirs = [ + "${core_path}/include", + "//commonlibrary/c_utils/base/include", + ] + + sources = [ "ans_manager_stub_test.cpp" ] + + deps = [ "${core_path}:ans_core" ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:wantagent_innerkits", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "multimedia_image_framework:image_native", + "relational_store:native_rdb", + ] + + subsystem_name = "${subsystem_name}" + part_name = "${component_name}" +} + +group("unittest") { + testonly = true + deps = [] + + deps += [ ":ans_manager_stub_test" ] +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..357b5ef74fcf7dae2e861853cbd9d19ec56dd43e --- /dev/null +++ b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp @@ -0,0 +1,1797 @@ +/* + * Copyright (c) 2022 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 + +#define private public +#define protected public +#include "ans_manager_stub.h" +#undef private +#undef protected + +#include "ans_inner_errors.h" + + +using namespace testing::ext; +namespace OHOS { +namespace Notification { +class AnsManagerStubTest : public testing::Test { +public: + static void SetUpTestCase() {} + static void TearDownTestCase() {} + void SetUp() + { + ansManagerStub_ = new AnsManagerStub(); + } + void TearDown() {} + sptr ansManagerStub_; +}; + +/** + * @tc.name: OnRemoteRequest01 + * @tc.desc: Test if get the wrong descriptor. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, OnRemoteRequest0001, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + data.WriteInterfaceToken(u"error.GetDescriptor"); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)OBJECT_NULL); +} + +/** + * @tc.name: OnRemoteRequest02 + * @tc.desc: Test if get the wrong code. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, OnRemoteRequest0002, Function | SmallTest | Level1) +{ + uint32_t code = 267; + 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)IPC_STUB_UNKNOW_TRANS_ERR); +} + +/** + * @tc.name: HandlePublish01 + * @tc.desc: Test HandlePublish succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublish01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string label = "this is a notification label"; + sptr notification = new NotificationRequest(); + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(label); + data.WriteParcelable(notification); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandlePublish02 + * @tc.desc: Test if the label is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublish02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr notification = new NotificationRequest(); + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(notification); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandlePublish03 + * @tc.desc: Test if the notification is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublish03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string label = "this is a notification label"; + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(label); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandlePublishToDevice01 + * @tc.desc: Test HandlePublishToDevice succeeds; + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublishToDevice01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION_TO_DEVICE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string deviceId = "this is a deviceId"; + sptr notification = new NotificationRequest(); + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(notification); + data.WriteString(deviceId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandlePublishToDevice02 + * @tc.desc: Test if the notification is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublishToDevice02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION_TO_DEVICE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string deviceId = "this is a deviceId"; + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(deviceId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandlePublishToDevice03 + * @tc.desc: Test if the deviceId in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublishToDevice03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION_TO_DEVICE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr notification = new NotificationRequest(); + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(notification); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleCancel01 + * @tc.desc: Test HandleCancel succeeds + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancel01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + int32_t notificationId = 3; + std::string label = "this is a notification label"; + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(notificationId); + data.WriteString(label); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleCancel02 + * @tc.desc: Test if the notificationId in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancel02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string label = "this is a notification label"; + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(label); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleCancel03 + * @tc.desc: Test if the label in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancel03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + int32_t notificationId = 3; + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(notificationId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleCancelAll01 + * @tc.desc: Test HandleCancelAll succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancelAll01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_ALL_NOTIFICATIONS); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleCancelAsBundle01 + * @tc.desc: Test HandlePublish succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_AS_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + int32_t notificationId = 3; + std::string representativeBundle = "this is a representativeBundle"; + int32_t userId = 4; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(notificationId); + data.WriteString(representativeBundle); + data.WriteInt32(userId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleCancelAsBundle02 + * @tc.desc: Test if the notificationId in data is null.. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_AS_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string representativeBundle = "this is a representativeBundle"; + int32_t userId = 4; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(representativeBundle); + data.WriteInt32(userId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleCancelAsBundle03 + * @tc.desc: Test if the representativeBundle in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_AS_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + int32_t notificationId = 3; + int32_t userId = 4; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(notificationId); + data.WriteInt32(userId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleCancelAsBundle04 + * @tc.desc: Test if the userId in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle04, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_AS_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + int32_t notificationId = 3; + std::string representativeBundle = "this is a representativeBundle"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(notificationId); + data.WriteString(representativeBundle); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleAddSlotByType01 + * @tc.desc: Test HandleAddSlotByType succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleAddSlotByType01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::ADD_SLOT_BY_TYPE); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleRemoveSlotByType01 + * @tc.desc: Test HandleRemoveSlotByType succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRemoveSlotByType01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_SLOT_BY_TYPE); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleRemoveAllSlots01 + * @tc.desc: Test HandleRemoveAllSlots succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRemoveAllSlots01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_ALL_SLOTS); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleGetSlotByType01 + * @tc.desc: Test HandleGetSlotByType succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetSlotByType01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_SLOT_BY_TYPE); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleGetSlotNumAsBundle01 + * @tc.desc: Test HandleGetSlotNumAsBundle succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetSlotNumAsBundle01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_SLOT_NUM_AS_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteStrongParcelable(bundleOption); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleGetSlotNumAsBundle02 + * @tc.desc: Test if the bundleOption in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetSlotNumAsBundle02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_SLOT_NUM_AS_BUNDLE); + 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: HandleGetActiveNotifications01 + * @tc.desc: Test HandleGetActiveNotifications succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetActiveNotifications01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_ACTIVE_NOTIFICATIONS); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleGetActiveNotificationNums01 + * @tc.desc: Test HandleGetActiveNotificationNums succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetActiveNotificationNums01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_ACTIVE_NOTIFICATION_NUMS); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleGetAllActiveNotifications01 + * @tc.desc: Test HandleGetAllActiveNotifications succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetAllActiveNotifications01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_ALL_ACTIVE_NOTIFICATIONS); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleSetNotificationAgent01 + * @tc.desc: Test HandleSetNotificationAgent succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationAgent01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_AGENT); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string agent = "this is a agent"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(agent); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleSetNotificationAgent02 + * @tc.desc: Test if the agent in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationAgent02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_AGENT); + 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: HandleGetNotificationAgent01 + * @tc.desc: Test HandleGetNotificationAgent succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetNotificationAgent01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_NOTIFICATION_AGENT); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleCanPublishAsBundle01 + * @tc.desc: Test HandleCanPublishAsBundle succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCanPublishAsBundle01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CAN_PUBLISH_AS_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string representativeBundle = "this is a representativeBundle"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(representativeBundle); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleCanPublishAsBundle02 + * @tc.desc: Test if the representativeBundle in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCanPublishAsBundle02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CAN_PUBLISH_AS_BUNDLE); + 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: HandlePublishAsBundle01 + * @tc.desc: Test HandlePublishAsBundle succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublishAsBundle01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_AS_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr notification = new NotificationRequest(); + + std::string representativeBundle = "this is a representativeBundle"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(notification); + data.WriteString(representativeBundle); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandlePublishAsBundle02 + * @tc.desc: Test if the notification in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublishAsBundle02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_AS_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string representativeBundle = "this is a representativeBundle"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(representativeBundle); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandlePublishAsBundle03 + * @tc.desc: Test if the representativeBundle in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublishAsBundle03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_AS_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr notification = new NotificationRequest(); + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(notification); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleSetNotificationBadgeNum01 + * @tc.desc: Test HandleSetNotificationBadgeNum succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationBadgeNum01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_BADGE_NUM); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + int32_t num = 4; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(num); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleSetNotificationBadgeNum02 + * @tc.desc: Test if the num in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationBadgeNum02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_BADGE_NUM); + 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: HandleGetBundleImportance01 + * @tc.desc: Test HandleGetBundleImportance succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetBundleImportance01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_BUNDLE_IMPORTANCE); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleSetDoNotDisturbDate01 + * @tc.desc: Test HandleSetDoNotDisturbDate succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDate01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_DO_NOT_DISTURB_DATE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr date = new NotificationDoNotDisturbDate(); + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(date); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleSetDoNotDisturbDate02 + * @tc.desc: Test if the date in data is null.. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDate02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_DO_NOT_DISTURB_DATE); + 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: HandleGetDoNotDisturbDate01 + * @tc.desc: Test HandleGetDoNotDisturbDate succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetDoNotDisturbDate01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_DO_NOT_DISTURB_DATE); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleDoesSupportDoNotDisturbMode01 + * @tc.desc: Test HandleDoesSupportDoNotDisturbMode01 succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleDoesSupportDoNotDisturbMode01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::DOES_SUPPORT_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)NO_ERROR); +} + +/** + * @tc.name: HandlePublishContinuousTaskNotification01 + * @tc.desc: Test HandlePublishContinuousTaskNotification succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublishContinuousTaskNotification01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_CONTINUOUS_TASK_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr request = new NotificationRequest(); + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(request); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandlePublishContinuousTaskNotification02 + * @tc.desc: Test if the request in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandlePublishContinuousTaskNotification02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_CONTINUOUS_TASK_NOTIFICATION); + 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: HandleCancelContinuousTaskNotification01 + * @tc.desc: Test HandleCancelContinuousTaskNotification succeeds. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancelContinuousTaskNotification01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_CONTINUOUS_TASK_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string label = "this is a label"; + int32_t notificationId = 3; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(label); + data.WriteInt32(notificationId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleCancelContinuousTaskNotification02 + * @tc.desc: Test if the label in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancelContinuousTaskNotification02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_CONTINUOUS_TASK_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + int32_t notificationId = 3; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(notificationId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleCancelContinuousTaskNotification03 + * @tc.desc: Test if the notificationId in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleCancelContinuousTaskNotification03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_CONTINUOUS_TASK_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string label = "this is a label"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(label); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleIsNotificationPolicyAccessGranted01 + * @tc.desc: Test HandleIsNotificationPolicyAccessGranted succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleIsNotificationPolicyAccessGranted01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::IS_NOTIFICATION_POLICY_ACCESS_GRANTED); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleSetPrivateNotificationsAllowed02 + * @tc.desc: Test if the allow in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetPrivateNotificationsAllowed02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_PRIVATIVE_NOTIFICATIONS_ALLOWED); + 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: HandleGetPrivateNotificationsAllowed01 + * @tc.desc: Test HandleGetPrivateNotificationsAllowed succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetPrivateNotificationsAllowed01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_PRIVATIVE_NOTIFICATIONS_ALLOWED); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleRemoveNotification01 + * @tc.desc: Test HandleRemoveNotification succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRemoveNotification01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + int32_t notificationId = 1; + std::string label = "this is a label"; + int32_t removeReason = 2; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteStrongParcelable(bundleOption); + data.WriteInt32(notificationId); + data.WriteString(label); + data.WriteInt32(removeReason); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleRemoveNotification02 + * @tc.desc: Test if the bundleOption in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRemoveNotification02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + int32_t notificationId = 1; + std::string label = "this is a label"; + int32_t removeReason = 2; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(notificationId); + data.WriteString(label); + data.WriteInt32(removeReason); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleRemoveNotification03 + * @tc.desc: Test if the notificationId in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRemoveNotification03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + std::string label = "this is a label"; + int32_t removeReason = 2; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteStrongParcelable(bundleOption); + data.WriteString(label); + data.WriteInt32(removeReason); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleRemoveNotification04 + * @tc.desc: Test if the label in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRemoveNotification04, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + int32_t notificationId = 1; + int32_t removeReason = 2; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteStrongParcelable(bundleOption); + data.WriteInt32(notificationId); + data.WriteInt32(removeReason); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleRemoveNotification05 + * @tc.desc: Test if the removeReason in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRemoveNotification05, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + int32_t notificationId = 1; + std::string label = "this is a label"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteStrongParcelable(bundleOption); + data.WriteInt32(notificationId); + data.WriteString(label); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleRemoveAllNotifications01 + * @tc.desc: Test HandleRemoveAllNotifications succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRemoveAllNotifications01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_ALL_NOTIFICATIONS); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteStrongParcelable(bundleOption); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleRemoveAllNotifications02 + * @tc.desc: Test if the bundleOption in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRemoveAllNotifications02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_ALL_NOTIFICATIONS); + 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: HandleDelete01 + * @tc.desc: Test HandleDelete succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleDelete01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string key = "this is a key"; + int32_t removeReason = 2; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(key); + data.WriteInt32(removeReason); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleDelete02 + * @tc.desc: Test if the key in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleDelete02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + int32_t removeReason = 2; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(removeReason); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleDelete03 + * @tc.desc: Test if the removeReason in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleDelete03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string key = "this is a key"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(key); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleDeleteByBundle01 + * @tc.desc: Test HandleDeleteByBundle succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleDeleteByBundle01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_NOTIFICATION_BY_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteStrongParcelable(bundleOption); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleDeleteByBundle02 + * @tc.desc: Test if the bundleOption in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleDeleteByBundle02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_NOTIFICATION_BY_BUNDLE); + 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: HandleDeleteAll01 + * @tc.desc: Test HandleDeleteAll succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleDeleteAll01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_ALL_NOTIFICATIONS); + 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)NO_ERROR); +} + +/** + * @tc.name: HandleGetSlotsByBundle01 + * @tc.desc: Test HandleGetSlotsByBundle succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetSlotsByBundle01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_SLOTS_BY_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(bundleOption); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleGetSlotsByBundle02 + * @tc.desc: Test if the bundleOption in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleGetSlotsByBundle02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_SLOTS_BY_BUNDLE); + 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: HandleUpdateSlots01 + * @tc.desc: Test HandleUpdateSlots succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleUpdateSlots01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::UPDATE_SLOTS); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + int32_t infoSize = 3; + sptr slot1 = new NotificationSlot(); + sptr slot2 = new NotificationSlot(); + sptr slot3 = new NotificationSlot(); + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(infoSize); + data.WriteStrongParcelable(slot1); + data.WriteStrongParcelable(slot2); + data.WriteStrongParcelable(slot3); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleUpdateSlots02 + * @tc.desc: Test if the StrongParcelable:info in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleUpdateSlots02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::UPDATE_SLOTS); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + int32_t infoSize = 3; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteInt32(infoSize); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleUpdateSlots03 + * @tc.desc: Test if the StrongParcelable:info in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleUpdateSlots03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::UPDATE_SLOTS); + 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: HandleRequestEnableNotification01 + * @tc.desc: Test HandleRequestEnableNotification succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRequestEnableNotification01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REQUEST_ENABLE_NOTIFICATION); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string deviceId = "this is a deviceId"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(deviceId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_OK); +} + +/** + * @tc.name: HandleRequestEnableNotification02 + * @tc.desc: Test if the deviceId in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleRequestEnableNotification02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::REQUEST_ENABLE_NOTIFICATION); + 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: HandleSetNotificationsEnabledForBundle01 + * @tc.desc: Test HandleSetNotificationsEnabledForBundle succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForBundle01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string deviceId = "this is a deviceId"; + bool enabled = false; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(deviceId); + data.WriteBool(enabled); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleSetNotificationsEnabledForBundle02 + * @tc.desc: Test if the deviceId in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForBundle02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + bool enabled = false; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteBool(enabled); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleSetNotificationsEnabledForBundle03 + * @tc.desc: Test if the enabled in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForBundle03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string deviceId = "this is a deviceId"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(deviceId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleSetNotificationsEnabledForAllBundles01 + * @tc.desc: Test HandleSetNotificationsEnabledForAllBundles succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForAllBundles01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string deviceId = "this is a deviceId"; + bool enabled = true; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(deviceId); + data.WriteBool(enabled); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleSetNotificationsEnabledForAllBundles02 + * @tc.desc: Test if the deviceId in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForAllBundles02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + bool enabled = true; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteBool(enabled); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleSetNotificationsEnabledForAllBundles03 + * @tc.desc: Test if the enabled in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForAllBundles03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string deviceId = "this is a deviceId"; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(deviceId); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleSetNotificationsEnabledForSpecialBundle01 + * @tc.desc: Test HandleSetNotificationsEnabledForSpecialBundle succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string deviceId = "this is a deviceId"; + sptr bundleOption = new NotificationBundleOption(); + bool enabled = true; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(deviceId); + data.WriteParcelable(bundleOption); + data.WriteBool(enabled); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleSetNotificationsEnabledForSpecialBundle02 + * @tc.desc: Test if the deviceId in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + bool enabled = true; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(bundleOption); + data.WriteBool(enabled); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleSetNotificationsEnabledForSpecialBundle03 + * @tc.desc: Test if the bundleOption in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string deviceId = "this is a deviceId"; + bool enabled = true; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(deviceId); + data.WriteBool(enabled); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleSetNotificationsEnabledForSpecialBundle04 + * @tc.desc: Test if the enabled in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle04, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + std::string deviceId = "this is a deviceId"; + sptr bundleOption = new NotificationBundleOption(); + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteString(deviceId); + data.WriteParcelable(bundleOption); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleSetShowBadgeEnabledForBundle01 + * @tc.desc: Test HandleSetShowBadgeEnabledForBundle succeed. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetShowBadgeEnabledForBundle01, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + bool enabled = true; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(bundleOption); + data.WriteBool(enabled); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)NO_ERROR); +} + +/** + * @tc.name: HandleSetShowBadgeEnabledForBundle02 + * @tc.desc: Test if the bundleOption in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetShowBadgeEnabledForBundle02, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + bool enabled = true; + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteBool(enabled); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} + +/** + * @tc.name: HandleSetShowBadgeEnabledForBundle03 + * @tc.desc: Test if the enabled in data is null. + * @tc.type: FUNC + * @tc.require: issueI5XQ4E + */ +HWTEST_F(AnsManagerStubTest, HandleSetShowBadgeEnabledForBundle03, Function | SmallTest | Level1) +{ + uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE); + MessageParcel data; + MessageParcel reply; + MessageOption option = {MessageOption::TF_SYNC}; + + sptr bundleOption = new NotificationBundleOption(); + + data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); + data.WriteParcelable(bundleOption); + + ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); + EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); +} +} +} \ No newline at end of file diff --git a/frameworks/js/napi/BUILD.gn b/frameworks/js/napi/BUILD.gn index a1aa00bcbce945571656f9053881c582e13073d3..bf8794ab15339ff4f36a1c43eb94d5c83360e1c8 100644 --- a/frameworks/js/napi/BUILD.gn +++ b/frameworks/js/napi/BUILD.gn @@ -76,7 +76,7 @@ ohos_shared_library("notification") { "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_path}/frameworks/native/appkit:app_context", "${core_path}:ans_core", - "//foundation/multimedia/image_framework/interfaces/innerkits:image", + "//foundation/multimedia/image_framework/interfaces/kits/js/common:image", ] external_deps = [ diff --git a/frameworks/js/napi/src/manager/BUILD.gn b/frameworks/js/napi/src/manager/BUILD.gn index 074baef984bd4de7e1e5743f57991011105492bb..ad252fb331f4e08d5ff26243afc720eeb2f4183c 100644 --- a/frameworks/js/napi/src/manager/BUILD.gn +++ b/frameworks/js/napi/src/manager/BUILD.gn @@ -66,7 +66,7 @@ ohos_shared_library("notificationmanager") { "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_path}/frameworks/native/appkit:app_context", "${core_path}:ans_core", - "//foundation/multimedia/image_framework/interfaces/innerkits:image", + "//foundation/multimedia/image_framework/interfaces/kits/js/common:image", ] external_deps = [ diff --git a/frameworks/js/napi/src/reminder/BUILD.gn b/frameworks/js/napi/src/reminder/BUILD.gn index d116b4430f4ddbfb3e11ef5880b0f613db6427f8..57b4ba33e91e99df63d090e2269a34ca314fa9af 100644 --- a/frameworks/js/napi/src/reminder/BUILD.gn +++ b/frameworks/js/napi/src/reminder/BUILD.gn @@ -49,7 +49,7 @@ ohos_shared_library("reminderagent") { deps = [ "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${core_path}:ans_core", - "//foundation/multimedia/image_framework/interfaces/innerkits:image", + "//foundation/multimedia/image_framework/interfaces/kits/js/common:image", ] external_deps = [ @@ -94,7 +94,7 @@ ohos_shared_library("reminderagentmanager") { deps = [ "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${core_path}:ans_core", - "//foundation/multimedia/image_framework/interfaces/innerkits:image", + "//foundation/multimedia/image_framework/interfaces/kits/js/common:image", ] external_deps = [ diff --git a/frameworks/js/napi/src/subscribe/BUILD.gn b/frameworks/js/napi/src/subscribe/BUILD.gn index c18561fa6f9d2885996d70586731456fe40fa685..6d1d3eccacd7ac1ac7a88da5405c3d46c45724a3 100644 --- a/frameworks/js/napi/src/subscribe/BUILD.gn +++ b/frameworks/js/napi/src/subscribe/BUILD.gn @@ -53,7 +53,7 @@ ohos_shared_library("notificationsubscribe") { deps = [ "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${core_path}:ans_core", - "//foundation/multimedia/image_framework/interfaces/innerkits:image", + "//foundation/multimedia/image_framework/interfaces/kits/js/common:image", ] external_deps = [ diff --git a/services/ans/BUILD.gn b/services/ans/BUILD.gn index 7843be17ff5049f6e7f497f3ca8ad725688e8286..c76765868e2952a85a6f2e351620cfbde09ca17f 100644 --- a/services/ans/BUILD.gn +++ b/services/ans/BUILD.gn @@ -76,7 +76,8 @@ ohos_shared_library("libans") { "multimedia_image_framework:image_native", "multimedia_player_framework:media_client", "os_account:os_account_innerkits", - "time_service:time_service", + "relational_store:native_rdb", + "time_service:time_client", "window_manager:libdm", ] external_deps += component_external_deps diff --git a/services/ans/test/unittest/BUILD.gn b/services/ans/test/unittest/BUILD.gn index 1b55a7c8d5c984895bc19ece0496a8bdc0777bd1..d017bfdbb49fd65e9a74b0418c919d8ff826d795 100644 --- a/services/ans/test/unittest/BUILD.gn +++ b/services/ans/test/unittest/BUILD.gn @@ -98,9 +98,10 @@ ohos_unittest("ans_unit_test") { "multimedia_image_framework:image_native", "multimedia_player_framework:media_client", "os_account:os_account_innerkits", + "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "time_service:time_service", + "time_service:time_client", ] if (device_usage) { diff --git a/services/test/moduletest/BUILD.gn b/services/test/moduletest/BUILD.gn index f61ff50735b1250f9440a29e772e7ff540629780..553b20c74e3434d4db758afc224ec67edd56e199 100644 --- a/services/test/moduletest/BUILD.gn +++ b/services/test/moduletest/BUILD.gn @@ -84,9 +84,10 @@ ohos_moduletest("ans_module_test") { "multimedia_image_framework:image_native", "multimedia_player_framework:media_client", "os_account:os_account_innerkits", + "relational_store:native_rdb", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "time_service:time_service", + "time_service:time_client", ] if (device_usage) {