diff --git a/frameworks/ans/BUILD.gn b/frameworks/ans/BUILD.gn index 80a21b60fc19a8271b2afd250913596d6fff409b..ad5f354b2f239d01a179f75a22cc9599320b2fa8 100644 --- a/frameworks/ans/BUILD.gn +++ b/frameworks/ans/BUILD.gn @@ -54,6 +54,14 @@ idl_gen_interface("ans_subscriber_interface") { part_name = "distributed_notification_service" } +idl_gen_interface("ans_manager_interface") { + sources = [ "IAnsManager.idl" ] + log_domainid = "0xD001203" + log_tag = "Ans" + subsystem_name = "notification" + part_name = "distributed_notification_service" +} + group("ans_client") { deps = [ ":ans_innerkits" ] } @@ -204,13 +212,6 @@ ohos_shared_library("ans_innerkits") { "${core_path}/src/listener/ans_subscriber_listener.cpp", "${core_path}/src/listener/swing_callback_service.cpp", "${core_path}/src/manager/ans_manager_death_recipient.cpp", - "${core_path}/src/manager/ans_manager_proxy.cpp", - "${core_path}/src/manager/ans_manager_proxy_bundle.cpp", - "${core_path}/src/manager/ans_manager_proxy_distributed.cpp", - "${core_path}/src/manager/ans_manager_proxy_disturb.cpp", - "${core_path}/src/manager/ans_manager_proxy_slot.cpp", - "${core_path}/src/manager/ans_manager_proxy_subscribe.cpp", - "${core_path}/src/manager/ans_manager_proxy_utils.cpp", "${frameworks_module_ans_path}/src/ans_dialog_host_client.cpp", "${frameworks_module_ans_path}/src/badge_number_callback_data.cpp", "${frameworks_module_ans_path}/src/enabled_notification_callback_data.cpp", @@ -259,6 +260,9 @@ ohos_shared_library("ans_innerkits") { "${frameworks_module_ans_path}/src/push_promise_callback.cpp", ] + output_values = get_target_outputs(":ans_manager_interface") + sources += filter_include(output_values, [ "*_proxy.cpp" ]) + public_configs = [ ":ans_innerkits_public_config" ] defines = [] @@ -266,6 +270,7 @@ ohos_shared_library("ans_innerkits") { deps = [ ":ans_dialog_callback_proxy", ":ans_dialog_callback_stub", + ":ans_manager_interface", ":ans_operation_callback_proxy", ":ans_operation_callback_stub", ":ans_subscriber_local_live_view_proxy", @@ -523,3 +528,32 @@ ohos_source_set("ans_subscriber_stub") { subsystem_name = "notification" part_name = "distributed_notification_service" } + +ohos_source_set("ans_manager_stub") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + debug = false + } + public_configs = [ ":ans_innerkits_config" ] + output_values = get_target_outputs(":ans_manager_interface") + sources = filter_include(output_values, [ "*_stub.cpp" ]) + deps = [ ":ans_manager_interface" ] + external_deps = [ + "c_utils:utils", + "hicollie:libhicollie", + "hilog:libhilog", + "i18n:intl_util", + "ipc:ipc_core", + "samgr:samgr_proxy", + ] + public_external_deps = [ + "ability_runtime:wantagent_innerkits", + "image_framework:image_native", + ] + subsystem_name = "notification" + part_name = "distributed_notification_service" +} diff --git a/frameworks/ans/IAnsManager.idl b/frameworks/ans/IAnsManager.idl new file mode 100644 index 0000000000000000000000000000000000000000..92ecf2280fedd1bbc89dd3d0556e2eda8696e113 --- /dev/null +++ b/frameworks/ans/IAnsManager.idl @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2025 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. + */ + +interface OHOS.Notification.IAnsDialogCallback; +interface OHOS.Notification.IAnsSubscriberLocalLiveView; +interface OHOS.Notification.IAnsSubscriber; +interface OHOS.Notification.IAnsOperationCallback; + +sequenceable OHOS.Notification.NotificationBundleOption; +sequenceable OHOS.Notification.NotificationDisable; +sequenceable OHOS.Notification.NotificationDoNotDisturbDate; +sequenceable OHOS.Notification.NotificationDoNotDisturbProfile; +sequenceable OHOS.Notification.NotificationRequest; +sequenceable OHOS.Notification.NotificationSlot; +sequenceable OHOS.Notification.NotificationSubscribeInfo; +sequenceable OHOS.Notification.NotificationOperationInfo; +sequenceable OHOS.Notification.Notification; +sequenceable OHOS.Notification.NotificationButtonOption; +sequenceable OHOS.Notification.NotificationCheckRequest; +sequenceable OHOS.IRemoteObject; + +interface OHOS.Notification.IAnsManager { + void Publish([in] String label, [in] sptr notification); + [ipcincapacity 520] void PublishWithMaxCapacity([in] String label, [in] sptr notification); + + void PublishNotificationForIndirectProxy([in] sptr notification); + [ipcincapacity 520] void PublishNotificationForIndirectProxyWithMaxCapacity([in] sptr notification); + + void Cancel([in] int notificationId, [in] String label, [in] String instanceKey); + + void CancelAll([in] String instanceKey); + + void CancelAsBundle([in] int notificationId, [in] String representativeBundle, [in] int userId); + + void CancelAsBundle([in] sptr bundleOption, [in] int notificationId); + + void CancelAsBundle([in] sptr bundleOption, [in] int notificationId, [in] int userId); + + void AddSlotByType([in] int slotTypeInt); + + void AddSlots([in] sptr[] slots); + + void RemoveSlotByType([in] int slotTypeInt); + + void RemoveAllSlots(); + + void GetSlotByType([in] int slotTypeInt, [out] null_sptr slot); + + void GetSlots([out] sptr[] slots); + + void GetSlotNumAsBundle([in] sptr bundleOption, [out] unsigned long num); + + void GetActiveNotifications([out] sptr[] notifications, [in] String instanceKey); + + void GetActiveNotificationNums([out] unsigned long num); + + void GetAllActiveNotifications([out] sptr[] notifications); + + void GetAllNotificationsBySlotType([out] sptr[] notifications, [in] int slotTypeInt); + + void GetSpecialActiveNotifications([in] String[] key, [out] sptr[] notifications); + + [ipcoutcapacity 520] void GetActiveNotificationByFilter( + [in] sptr bundleOption, + [in] int notificationId, + [in] String label, + [in] String[] extraInfoKeys, + [out] null_sptr request); + + void CanPublishAsBundle([in] String representativeBundle, [out] boolean canPublish); + + void PublishAsBundle([in] sptr notification, [in] String representativeBundle); + [ipcincapacity 520] void PublishAsBundleWithMaxCapacity([in] sptr notification, [in] String representativeBundle); + + void SetNotificationBadgeNum([in] int num); + + void GetBundleImportance([out] int importance); + + void HasNotificationPolicyAccessPermission([out] boolean granted); + + void TriggerLocalLiveView( + [in] sptr bundleOption, + [in] int notificationId, + [in] sptr buttonOption); + + void RemoveNotification( + [in] sptr bundleOption, + [in] FileDescriptor notificationId, + [in] String label, + [in] int removeReason); + + void RemoveAllNotifications([in] sptr bundleOption); + + void RemoveNotifications([in] String[] hashcodes, [in] int removeReason); + + void Delete([in] String key, [in] int removeReason); + + void DeleteByBundle([in] sptr bundleOption); + + void DeleteAll(); + + void GetSlotsByBundle([in] sptr bundleOption, [out] sptr[] slots); + + void GetSlotByBundle([in] sptr bundleOption, [in] int slotTypeInt, + [out] null_sptr slot); + + void UpdateSlots([in] sptr bundleOption, [in] sptr[] slots); + + void RequestEnableNotification([in] String deviceId, [in] IAnsDialogCallback ansDialogCallback); + void RequestEnableNotification([in] String deviceId, [in] IAnsDialogCallback ansDialogCallback, [in] IRemoteObject callerToken); + + void RequestEnableNotification([in] String bundleName, [in] int uid); + + void SetNotificationsEnabledForBundle([in] String deviceId, [in] boolean enabled); + + void SetNotificationsEnabledForAllBundles([in] String deviceId, [in] boolean enabled); + + void SetNotificationsEnabledForSpecialBundle( + [in] String deviceId, [in] sptr bundleOption, [in] boolean enabled); + + void SetShowBadgeEnabledForBundle([in] sptr bundleOption, [in] boolean enabled); + + void GetShowBadgeEnabledForBundle([in] sptr bundleOption, [out] boolean enabled); + + void GetShowBadgeEnabled([out] boolean enabled); + + void Subscribe([in] IAnsSubscriber subscriber); + void Subscribe([in] IAnsSubscriber subscriber, [in] sptr info); + + void SubscribeSelf([in] IAnsSubscriber subscriber); + + void SubscribeLocalLiveView( + [in] IAnsSubscriberLocalLiveView subscriber, + [in] boolean isNative); + void SubscribeLocalLiveView( + [in] IAnsSubscriberLocalLiveView subscriber, + [in] sptr info, + [in] boolean isNative); + + void Unsubscribe([in] IAnsSubscriber subscriber); + void Unsubscribe([in] IAnsSubscriber subscriber, [in] sptr info); + + void IsAllowedNotify([out] boolean allowed); + + void IsAllowedNotifySelf([out] boolean allowed); + + void CanPopEnableNotificationDialog([in] IAnsDialogCallback ansDialogCallback, [out] boolean canPop, [out] String bundleName); + + void RemoveEnableNotificationDialog(); + + void IsSpecialBundleAllowedNotify([in] sptr bundleOption, [out] boolean allowed); + + void SetDoNotDisturbDate([in] sptr date); + + void GetDoNotDisturbDate([out] sptr date); + + void AddDoNotDisturbProfiles([in] sptr[] profiles); + + void RemoveDoNotDisturbProfiles([in] sptr[] profiles); + + void DoesSupportDoNotDisturbMode([out] boolean doesSupport); + + void IsNeedSilentInDoNotDisturbMode([in] String phoneNumber, [in] int callerType); + + void CancelGroup([in] String groupName, [in] String instanceKey); + + void RemoveGroupByBundle([in] sptr bundleOption, [in] String groupName); + + void IsDistributedEnabled([out] boolean enabled); + + void SetDistributedEnabledBySlot( + [in] int slotTypeInt, [in] String deviceType, [in] boolean enabled); + + void IsDistributedEnabledBySlot( + [in] int slotTypeInt, [in] String deviceType, [out] boolean enabled); + + void EnableDistributed([in] boolean enabled); + + void EnableDistributedByBundle([in] sptr bundleOption, [in] boolean enabled); + + void EnableDistributedSelf([in] boolean enabled); + + void IsDistributedEnableByBundle([in] sptr bundleOption, [out] boolean enabled); + + void GetDeviceRemindType([out] int remindTypeInt); + + void PublishContinuousTaskNotification([in] sptr request); + + void CancelContinuousTaskNotification([in] String label, [in] int notificationId); + + void IsSupportTemplate([in] String templateName, [out] boolean support); + + void IsSpecialUserAllowedNotify([in] int userId, [out] boolean allowed); + + void SetNotificationsEnabledByUser([in] int userId, [in] boolean enabled); + + void DeleteAllByUser([in] int userId); + + void SetDoNotDisturbDate([in] int userId, [in] sptr date); + + void GetDoNotDisturbDate([in] int userId, [out] sptr date); + + void SetEnabledForBundleSlot( + [in] sptr bundleOption, + [in] int slotTypeInt, + [in] boolean enabled, + [in] boolean isForceControl); + + void GetEnabledForBundleSlot( + [in] sptr bundleOption, + [in] int slotTypeInt, + [out] boolean enabled); + + void GetEnabledForBundleSlotSelf([in] int slotTypeInt, [out] boolean enabled); + + void ShellDump( + [in] String cmd, + [in] String bundle, + [in] int userId, + [in] int recvUserId, + [out] String[] dumpInfo); + + void SetSyncNotificationEnabledWithoutApp([in] int userId, [in] boolean enabled); + + void GetSyncNotificationEnabledWithoutApp([in] int userId, [out] boolean enabled); + + void SetBadgeNumber([in] int badgeNumber, [in] String instanceKey); + + void SetBadgeNumberByBundle([in] sptr bundleOption, [in] int badgeNumber); + + void SetBadgeNumberForDhByBundle([in] sptr bundleOption, [in] int badgeNumber); + + void GetSlotFlagsAsBundle([in] sptr bundleOption, [out] unsigned int slotFlags); + + void SetSlotFlagsAsBundle([in] sptr bundleOption, [in] unsigned int slotFlags); + + void GetAllNotificationEnabledBundles([out] NotificationBundleOption[] bundleOption); + + void GetAllLiveViewEnabledBundles([out] NotificationBundleOption[] bundleOption); + + void GetAllDistribuedEnabledBundles([in] String deviceType, [out] NotificationBundleOption[] bundleOption); + + void RegisterPushCallback([in] IRemoteObject pushCallback, [in] sptr notificationCheckRequest); + + void UnregisterPushCallback(); + + void SetAdditionConfig([in] String key, [in] String value); + + void SetDistributedEnabledByBundle( + [in] sptr bundleOption, [in] String deviceType, [in] boolean enabled); + + void IsSmartReminderEnabled([in] String deviceType, [out] boolean enabled); + + void SetSmartReminderEnabled([in] String deviceType, [in] boolean enabled); + + void IsDistributedEnabledByBundle([in] sptr bundleOption, [in] String deviceType, [out] boolean enabled); + + void CancelAsBundleWithAgent([in] sptr bundleOption, [in] int id); + + void SetTargetDeviceStatus([in] String deviceType, [in] unsigned int status, [in] String deveiceId); + + void SetTargetDeviceStatus([in] String deviceType, [in] unsigned int status, [in] unsigned int controlFlag, [in] String deveiceId); + + void GetDoNotDisturbProfile([in] long id, [out] sptr profile); + + void AllowUseReminder([in] String bundleName, [out] boolean isAllowUseReminder); + + void UpdateNotificationTimerByUid([in] int uid, [in] boolean isPaused); + + void DisableNotificationFeature([in] sptr notificationDisable); + + void GetTargetDeviceStatus([in] String deviceType, [out] int status); + + void DistributeOperation([out] null_sptr operationInfo, [in] IAnsOperationCallback operationCallback); + + void ReplyDistributeOperation([in] String hashCode, [in] int resultCode); + + void GetNotificationRequestByHashCode( + [in] String hashCode, [out] null_sptr notificationRequest); + + void SetHashCodeRule([in] unsigned int type); + + [macrodef NOTIFICATION_SMART_REMINDER_SUPPORTED] void RegisterSwingCallback([in] IRemoteObject swingCallback); +} \ No newline at end of file diff --git a/frameworks/ans/src/notification_local_live_view_subscriber.cpp b/frameworks/ans/src/notification_local_live_view_subscriber.cpp index 62189ce67b395f3f11c47c8d4d486a388904eec3..cd110f22efd03a1668c77b632de9d5c48b2f577f 100644 --- a/frameworks/ans/src/notification_local_live_view_subscriber.cpp +++ b/frameworks/ans/src/notification_local_live_view_subscriber.cpp @@ -43,7 +43,7 @@ NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::SubscriberLoca ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnConnected() { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (proxy != nullptr) { proxy->AsObject()->AddDeathRecipient(recipient_); ANS_LOGD("%s, Add death recipient.", __func__); @@ -55,7 +55,7 @@ ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnConn ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnDisconnected() { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (proxy != nullptr) { proxy->AsObject()->RemoveDeathRecipient(recipient_); ANS_LOGD("%s, Remove death recipient.", __func__); @@ -72,7 +72,7 @@ ErrCode NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::OnResp return ERR_OK; } -sptr NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::GetAnsManagerProxy() +sptr NotificationLocalLiveViewSubscriber::SubscriberLocalLiveViewImpl::GetAnsManagerProxy() { sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); @@ -86,7 +86,7 @@ sptr NotificationLocalLiveViewSubscriber::SubscriberLocalLi return nullptr; } - sptr proxy = iface_cast(remoteObject); + sptr proxy = iface_cast(remoteObject); if ((proxy == nullptr) || (proxy->AsObject() == nullptr)) { return nullptr; } diff --git a/frameworks/ans/src/notification_subscriber.cpp b/frameworks/ans/src/notification_subscriber.cpp index 6fd51f541073169d231da97c76eead14af904ec0..9383fde6bda12289a33ba8b831116e3127251f5b 100644 --- a/frameworks/ans/src/notification_subscriber.cpp +++ b/frameworks/ans/src/notification_subscriber.cpp @@ -117,7 +117,7 @@ NotificationSubscriber::SubscriberImpl::SubscriberImpl(NotificationSubscriber &s ErrCode NotificationSubscriber::SubscriberImpl::OnConnected() { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (proxy != nullptr) { proxy->AsObject()->AddDeathRecipient(recipient_); ANS_LOGD("%s, Add death recipient.", __func__); @@ -129,7 +129,7 @@ ErrCode NotificationSubscriber::SubscriberImpl::OnConnected() ErrCode NotificationSubscriber::SubscriberImpl::OnDisconnected() { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (proxy != nullptr) { proxy->AsObject()->RemoveDeathRecipient(recipient_); ANS_LOGD("%s, Remove death recipient.", __func__); @@ -291,7 +291,7 @@ ErrCode NotificationSubscriber::SubscriberImpl::OnOperationResponse( return subscriber_.OnOperationResponse(std::make_shared(*operationInfo)); } -sptr NotificationSubscriber::SubscriberImpl::GetAnsManagerProxy() +sptr NotificationSubscriber::SubscriberImpl::GetAnsManagerProxy() { sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); @@ -305,7 +305,7 @@ sptr NotificationSubscriber::SubscriberImpl::GetAnsManagerP return nullptr; } - sptr proxy = iface_cast(remoteObject); + sptr proxy = iface_cast(remoteObject); if ((proxy == nullptr) || (proxy->AsObject() == nullptr)) { return nullptr; } diff --git a/frameworks/core/include/ans_manager_interface.h b/frameworks/core/include/ans_manager_interface.h deleted file mode 100644 index e3901d9dab56894748c70465bba60135bcea31fb..0000000000000000000000000000000000000000 --- a/frameworks/core/include/ans_manager_interface.h +++ /dev/null @@ -1,1062 +0,0 @@ -/* - * Copyright (c) 2021-2025 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. - */ - -#ifndef BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_INTERFACE_H -#define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_INTERFACE_H - -#include -#include - -#include "ians_dialog_callback.h" -#include "ians_subscriber.h" -#include "ians_subscriber_local_live_view.h" -#include "iremote_broker.h" -#include "notification_bundle_option.h" -#include "notification_constant.h" -#include "notification_disable.h" -#include "notification_do_not_disturb_date.h" -#include "notification_do_not_disturb_profile.h" -#include "notification_request.h" -#include "notification_slot.h" -#include "notification_subscribe_info.h" -#include "reminder_request.h" -#include "ians_operation_callback.h" - -namespace OHOS { -namespace Notification { -class AnsManagerInterface : public IRemoteBroker { -public: - AnsManagerInterface() = default; - virtual ~AnsManagerInterface() = default; - DISALLOW_COPY_AND_MOVE(AnsManagerInterface); - - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Notification.AnsManagerInterface"); - - /** - * @brief Publishes a notification with a specified label. - * @note If a notification with the same ID has been published by the current application and has not been deleted, - * this method will update the notification. - * - * @param label Indicates the label of the notification to publish. - * @param notification Indicates the NotificationRequest object for setting the notification content. - * This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode Publish(const std::string &label, const sptr ¬ification) = 0; - - /** - * @brief Publishes a notification. - * @note If a notification with the same ID has been published by the current application and has not been deleted, - * this method will update the notification. - * - * @param notification Indicates the NotificationRequest object for setting the notification content. - * This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode PublishNotificationForIndirectProxy(const sptr ¬ification) = 0; - - /** - * @brief Cancels a published notification matching the specified label and notificationId. - * - * @param notificationId Indicates the ID of the notification to cancel. - * @param label Indicates the label of the notification to cancel. - * @param instanceKey Indicates the application instance key. - * @return Returns cancel notification result. - */ - virtual ErrCode Cancel(int notificationId, const std::string &label, const std::string &instanceKey) = 0; - - /** - * @brief Cancels all the published notifications. - * - * @param instanceKey Indicates the application instance key. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CancelAll(const std::string &instanceKey) = 0; - - /** - * @brief Cancels a published agent notification. - * - * @param notificationId Indicates the unique notification ID in the application. - * The value must be the ID of a published notification. - * Otherwise, this method does not take effect. - * @param representativeBundle Indicates the name of application bundle your application is representing. - * @param userId Indicates the specific user. - * @return Returns cancel notification result. - */ - virtual ErrCode CancelAsBundle( - int32_t notificationId, const std::string &representativeBundle, int32_t userId) = 0; - - /** - * @brief Cancels a published agent notification. - * - * @param bundleOption Indicates the bundle of application your application is representing. - * @param notificationId Indicates the unique notification ID in the application. - * The value must be the ID of a published notification. - * Otherwise, this method does not take effect. - * @return Returns cancel notification result. - */ - virtual ErrCode CancelAsBundle(const sptr &bundleOption, int32_t notificationId) = 0; - - /** - * @brief Cancels a published agent notification. - * - * @param bundleOption Indicates the bundle of application bundle your application is representing. - * @param notificationId Indicates the unique notification ID in the application. - * The value must be the ID of a published notification. - * Otherwise, this method does not take effect. - * @param userId Indicates the specific user. - * @return Returns cancel notification result. - */ - virtual ErrCode CancelAsBundle( - const sptr &bundleOption, int32_t notificationId, int32_t userId) = 0; - - /** - * @brief Adds a notification slot by type. - * - * @param slotType Indicates the notification slot type to be added. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode AddSlotByType(NotificationConstant::SlotType slotType) = 0; - - /** - * @brief Creates multiple notification slots. - * - * @param slots Indicates the notification slots to create. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode AddSlots(const std::vector> &slots) = 0; - - /** - * @brief Deletes a created notification slot based on the slot ID. - * - * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot - * This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) = 0; - - /** - * @brief Deletes all notification slots. - * - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveAllSlots() = 0; - - /** - * @brief Queries a created notification slot. - * - * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This - * parameter must be specified. - * @param slot Indicates the created NotificationSlot. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) = 0; - - /** - * @brief Obtains all notification slots of this application. - * - * @param slots Indicates the created NotificationSlot. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlots(std::vector> &slots) = 0; - - /** - * @brief Obtains the number of slot. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param num Indicates the number of slot. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) = 0; - - /** - * @brief Obtains active notifications of the current application in the system. - * - * @param notifications Indicates active NotificationRequest objects of the current application. - * @param instanceKey Indicates the application instance key. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetActiveNotifications( - std::vector> ¬ifications, const std::string &instanceKey) = 0; - - /** - * @brief Obtains the number of active notifications of the current application in the system. - * - * @param num Indicates the number of active notifications of the current application. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetActiveNotificationNums(uint64_t &num) = 0; - - /** - * @brief Obtains all active notifications in the current system. The caller must have system permissions to - * call this method. - * - * @param notifications Indicates all active notifications of this application. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetAllActiveNotifications(std::vector> ¬ifications) = 0; - - /** - * @brief Obtains all active notifications by slottype in the current system. The caller must have system - * permissions to call this method. - * - * @param notifications Indicates all active notifications of this application. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetAllNotificationsBySlotType(std::vector> ¬ifications, - const NotificationConstant::SlotType slotType) = 0; - - /** - * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method - * to obtain particular active notifications, you must have received the notifications and obtained the key - * via {Notification::GetKey()}. - * - * @param key Indicates the key array for querying corresponding active notifications. - * If this parameter is null, this method returns all active notifications in the system. - * @param notification Indicates the set of active notifications corresponding to the specified key. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSpecialActiveNotifications( - const std::vector &key, std::vector> ¬ifications) = 0; - - /** - * @brief Obtains the live view notification extra info by the extraInfoKeys. To call this method - * to obtain particular live view notification extra info, you must have received the - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param notificationId Indicates the id of the notification to get the extra info by extra info keys. - * @param extraInfoKeys - * @param extraInfo - * @return - */ - virtual ErrCode GetActiveNotificationByFilter( - const sptr &bundleOption, const int32_t notificationId, const std::string &label, - std::vector extraInfoKeys, sptr &request) = 0; - - /** - * @brief Checks whether your application has permission to publish notifications by calling - * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the - * given representativeBundle. - * - * @param representativeBundle Indicates the name of application bundle your application is representing. - * @param canPublish Indicates whether your application has permission to publish notifications. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) = 0; - - /** - * @brief Publishes a notification in the name of a specified application bundle. - * @note If the notification to be published has the same ID as a published notification that has not been canceled, - * the existing notification will be replaced by the new one. - * - * @param notification Indicates the NotificationRequest object for setting the notification content. - * This parameter must be specified. - * @param representativeBundle Indicates the name of the application bundle that allows your application to publish - * notifications for it by calling setNotificationAgent. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode PublishAsBundle( - const sptr notification, const std::string &representativeBundle) = 0; - - /** - * @brief Sets the number of active notifications of the current application as the number to be displayed on the - * notification badge. - * - * @param num Indicates the badge number. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationBadgeNum(int num) = 0; - - /** - * @brief Obtains the importance level of this application. - * - * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, - LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetBundleImportance(int &importance) = 0; - - /** - * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. - * - * @param granted True if the application has permission; false for otherwise. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) = 0; - - /** - * @brief Trigger the local live view after the button has been clicked. - * @note Your application must have platform signature to use this method. - * - * @param bundleOption Indicates the bundle name and uid of the application whose notifications has been clicked. - * @param notificationId Indicates the id of the notification. - * @param buttonOption Indicates which button has been clicked. - * @return Returns trigger localLiveView result. - */ - virtual ErrCode TriggerLocalLiveView(const sptr &bundleOption, - const int32_t notificationId, const sptr &buttonOption) = 0; - - /** - * @brief Delete notification based on key. - * - * @param key Indicates the key to delete notification. - * @param removeReason Indicates the reason of remove notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode Delete(const std::string &key, int32_t removeReason) = 0; - - /** - * @brief Delete notification. - * - * @param bundleOption Indicates the NotificationBundleOption of the notification. - * @param notificationId Indicates the id of the notification. - * @param label Indicates the label of the notification. - * @param removeReason Indicates the reason of remove notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveNotification(const sptr &bundleOption, int notificationId, - const std::string &label, int32_t removeReason) = 0; - - /** - * @brief Delete all notifications. - * - * @param bundleOption Indicates the NotificationBundleOption of notifications. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveAllNotifications(const sptr &bundleOption) = 0; - - virtual ErrCode RemoveNotifications(const std::vector &hashcodes, int32_t removeReason) = 0; - - /** - * @brief Remove notifications based on bundle. - * - * @param bundleOption Indicates the NotificationBundleOption of notifications. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode DeleteByBundle(const sptr &bundleOption) = 0; - - /** - * @brief Remove all notifications. - * - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode DeleteAll() = 0; - - /** - * @brief Get all the slots corresponding to the bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param slots Indicates the notification slots. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotsByBundle( - const sptr &bundleOption, std::vector> &slots) = 0; - - /** - * @brief Get the specified slot corresponding to the bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This - * parameter must be specified. - * @param slot Indicates the notification slot. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotByBundle( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, - sptr &slot) = 0; - - /** - * @brief Update slots according to bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param slots Indicates the notification slots to be updated. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode UpdateSlots( - const sptr &bundleOption, const std::vector> &slots) = 0; - - /** - * @brief Allow notifications to be sent based on the deviceId. - * - * @param deviceId Indicates the device Id. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RequestEnableNotification(const std::string &deviceId, - const sptr &callback, - const sptr &callerToken) = 0; - - /** - * @brief Allow application to publish notifications. - * - * @param bundleName bundle name. - * @param uid uid. - * @return Returns set notifications enabled for the bundle result. - */ - virtual ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) = 0; - - /** - * @brief Set whether to allow the specified deviceId to send notifications for current bundle. - * - * @param deviceId Indicates the device Id. - * @param enabled Indicates the flag that allows notification to be pulished. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) = 0; - - /** - * @brief Set whether to allow the specified deviceId to send notifications for all bundles. - * - * @param deviceId Indicates the device Id. - * @param enabled Indicates the flag that allows notification to be pulished. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) = 0; - - /** - * @brief Set whether to allow the specified bundle to send notifications. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the flag that allows notification to be pulished. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationsEnabledForSpecialBundle( - const std::string &deviceId, const sptr &bundleOption, bool enabled) = 0; - - /** - * @brief Sets whether the bundle allows the banner to display notification. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the flag that allows badge to be shown. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) = 0; - - /** - * @brief Gets whether the bundle allows the badge to display the status of notifications. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the flag that allows badge to be shown. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) = 0; - - /** - * @brief Gets whether allows the badge to display the status of notifications. - * - * @param enabled Indicates the flag that allows badge to be shown. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetShowBadgeEnabled(bool &enabled) = 0; - - /** - * @brief Subscribes notifications. - * - * @param subscriber Indicates the subscriber. - * @param info Indicates the NotificationSubscribeInfo object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode Subscribe(const sptr &subscriber, - const sptr &info) = 0; - - /** - * @brief Subscribes notifications self. - * - * @param subscriber Indicates the subscriber. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SubscribeSelf(const sptr &subscriber) = 0; - - /** - * @brief Subscribes local live view notifications. - * - * @param subscriber Indicates the subscriber. - * @param info Indicates the NotificationSubscribeInfo object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SubscribeLocalLiveView(const sptr &subscriber, - const sptr &info, const bool isNative) = 0; - - /** - * @brief Unsubscribes notifications. - * - * @param subscriber Indicates the subscriber. - * @param info Indicates the NotificationSubscribeInfo object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode Unsubscribe( - const sptr &subscriber, const sptr &info) = 0; - - /** - * @brief Checks whether this device is allowed to publish notifications. - * - * @param allowed Indicates the flag that allows notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsAllowedNotify(bool &allowed) = 0; - - /** - * @brief Checks whether this application is allowed to publish notifications. - * - * @param allowed Indicates the flag that allows notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsAllowedNotifySelf(bool &allowed) = 0; - - /** - * @brief Checks whether this application can pop enable notification dialog. - * - * @param canPop True if can pop enable notification dialog - * @return Returns is canPop result. - */ - virtual ErrCode CanPopEnableNotificationDialog(const sptr &callback, - bool &canPop, std::string &bundleName) = 0; - - /** - * @brief remove enable notification dialog. - * - * @return Returns remove dialog result. - */ - virtual ErrCode RemoveEnableNotificationDialog() = 0; - - /** - * @brief Checks whether notifications are allowed for a specific bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param allowed Indicates the flag that allows notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) = 0; - - /** - * @brief Set do not disturb date. - * - * @param date Indicates the NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetDoNotDisturbDate(const sptr &date) = 0; - - /** - * @brief Get do not disturb date. - * - * @param date Indicates the NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetDoNotDisturbDate(sptr &date) = 0; - - /** - * @brief Add do not disturb profiles. - * - * @param profiles Indicates the NotificationDoNotDisturbProfile objects. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode AddDoNotDisturbProfiles(const std::vector> &profiles) = 0; - - /** - * @brief Remove do not disturb profiles. - * - * @param profiles Indicates the NotificationDoNotDisturbProfile objects. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveDoNotDisturbProfiles(const std::vector> &profiles) = 0; - - /** - * @brief Get whether Do Not Disturb mode is supported. - * - * @param doesSupport Indicates the flag that supports DND mode. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) = 0; - - /** - * @brief Is coming call need silent in do not disturb mode. - * - * @param phoneNumber the calling format number. - * @return Returns silent in do not disturb mode. - */ - virtual ErrCode IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) = 0; - - /** - * @brief Cancel notifications according to group. - * - * @param groupName Indicates the group name. - * @param instanceKey Indicates the application instance key. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CancelGroup(const std::string &groupName, const std::string &instanceKey) = 0; - - /** - * @brief Delete notifications according to bundle and group. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param groupName Indicates the group name. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveGroupByBundle( - const sptr &bundleOption, const std::string &groupName) = 0; - - /** - * @brief Gets whether distributed notification is enabled. - * - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsDistributedEnabled(bool &enabled) = 0; - - /** - * @brief Set the channel switch for collaborative reminders. - The caller must have system permissions to call this method. - * - * @param slotType Indicates the slot type of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Indicates slot switch status. - * @return Returns set channel switch result. - */ - virtual ErrCode SetDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled) = 0; - - /** - * @brief Query the channel switch for collaborative reminders. - The caller must have system permissions to call this method. - * - * @param slotType Indicates the slot type of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Indicates slot switch status. - * @return Returns channel switch result. - */ - virtual ErrCode IsDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) = 0; - - /** - * @brief Sets distributed notification enabled or disabled. - * - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode EnableDistributed(bool enabled) = 0; - - /** - * @brief Sets distributed notification enabled or disabled for specific bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode EnableDistributedByBundle(const sptr &bundleOption, bool enabled) = 0; - - /** - * @brief Sets distributed notification enabled or disabled for current bundle. - * - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode EnableDistributedSelf(bool enabled) = 0; - - /** - * @brief Gets whether distributed notification is enabled for specific bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) = 0; - - /** - * @brief Get the reminder type of the current device. - * - * @param remindType Reminder type for the device. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) = 0; - - /** - * @brief Publishes a continuous notification. - * - * @param request Notification requests that need to be posted. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode PublishContinuousTaskNotification(const sptr &request) = 0; - - /** - * @brief Cancels a continuous notification. - * - * @param label Identifies the label of the specified notification. - * @param notificationId Identifies the id of the specified notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) = 0; - - /** - * @brief Checks whether this device is support template. - * - * @param templateName Identifies the template name for searching as a condition. - * @param support Identifies the support flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsSupportTemplate(const std::string &templateName, bool &support) = 0; - - /** - * @brief Checks Whether the specified users is allowed to publish notifications. - * - * @param userId Identifies the user's id. - * @param allowed Identifies the allowed flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) = 0; - - /** - * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must - * have system permissions to call this method. - * - * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only - * be null or an empty string, indicating the current device. - * @param enabled Specifies whether to allow all applications to publish notifications. The value true - * indicates that notifications are allowed, and the value false indicates that notifications - * are not allowed. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) = 0; - - /** - * @brief Delete all notifications by user. - * - * @param userId Indicates the user id. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode DeleteAllByUser(const int32_t &userId) = 0; - - /** - * @brief Set do not disturb date by user. - * - * @param userId Indicates the user id. - * @param date Indicates NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr &date) = 0; - - /** - * @brief Get the do not disturb date by user. - * - * @param userId Indicates the user id. - * @param date Indicates the NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date) = 0; - virtual ErrCode SetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) = 0; - virtual ErrCode GetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool &enabled) = 0; - virtual ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) = 0; - - /** - * @brief Obtains specific datas via specified dump option. - * - * @param cmd Indicates the specified dump command. - * @param bundle Indicates the specified bundle name. - * @param userId Indicates the specified userId. - * @param recvUserId Indicates the specified receiver UserId - * @param dumpInfo Indicates the container containing datas. - * @return Returns check result. - */ - virtual ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, int32_t recvUserId, - std::vector &dumpInfo) = 0; - - /** - * @brief Set whether to sync notifications to devices that do not have the app installed. - * - * @param userId Indicates the specific user. - * @param enabled Allow or disallow sync notifications. - * @return Returns set enabled result. - */ - virtual ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) = 0; - - /** - * @brief Obtains whether to sync notifications to devices that do not have the app installed. - * - * @param userId Indicates the specific user. - * @param enabled Allow or disallow sync notifications. - * @return Returns get enabled result. - */ - virtual ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) = 0; - - /** - * @brief Set badge number. - * - * @param badgeNumber The badge number. - * @return Returns set badge number result. - */ - virtual ErrCode SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) = 0; - - /** - * @brief Set badge number by bundle. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param badgeNumber The badge number. - * @return Returns set badge number by bundle result. - */ - virtual ErrCode SetBadgeNumberByBundle(const sptr &bundleOption, int32_t badgeNumber) = 0; - - /** - * @brief Set badge number for dh by bundle. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param badgeNumber The badge number. - * @return Returns set badge number by bundle result. - */ - virtual ErrCode SetBadgeNumberForDhByBundle( - const sptr &bundleOption, int32_t badgeNumber) = 0; - - /** - * @brief Obtains the number of slotFlags. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param slot Indicates the specified slot object - * @param slotFlags Indicates the slogFlags of slot. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotFlagsAsBundle(const sptr& bundleOption, uint32_t &slotFlags) = 0; - - /** - * @brief Set the slotFlags of slot. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param slot Indicates the specified slot object - * @param slotFlags Indicates the slogFlags of slot to set. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetSlotFlagsAsBundle(const sptr& bundleOption, uint32_t slotFlags) = 0; - - /** - * @brief Obtains allow notification application list. - * - * @param bundleOption Indicates the bundle bundleOption. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetAllNotificationEnabledBundles(std::vector &bundleOption) = 0; - - /** - * @brief Obtains allow liveview application list. - * - * @param bundleOption Indicates the bundle bundleOption. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetAllLiveViewEnabledBundles(std::vector &bundleOption) = 0; - - /** - * @brief Obtains allow distributed application list. - * - * @param deviceType Indicates device type. - * @param bundleOption Indicates the bundle bundleOption. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetAllDistribuedEnabledBundles(const std::string& deviceType, - std::vector &bundleOption) = 0; - - /** - * @brief Register Push Callback. - * - * @param pushCallback PushCallBack. - * @return Returns register PushCallback result. - */ - virtual ErrCode RegisterPushCallback( - const sptr &pushCallback, const sptr ¬ificationCheckRequest) = 0; - - /** - * @brief Unregister Push Callback. - * - * @return Returns unregister push Callback result. - */ - virtual ErrCode UnregisterPushCallback() = 0; - - /** - * @brief Set agent relationship. - * - * @param key Indicates storing agent relationship if the value is "PROXY_PKG". - * @param value Indicates key-value pair of agent relationship. - * @return Returns set result. - */ - virtual ErrCode SetAdditionConfig(const std::string &key, const std::string &value) = 0; - - /** - * @brief Sets whether to allow a specified application to publish notifications cross - * device collaboration. The caller must have system permissions to call this method. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given application to publish notifications. - * The value true indicates that notifications are allowed, and the value - * false indicates that notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - virtual ErrCode SetDistributedEnabledByBundle( - const sptr &bundleOption, const std::string &deviceType, const bool enabled) = 0; - - /** - * @brief Get Enable smartphone to collaborate with other devices for intelligent reminders - * - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given device to publish notifications. - * The value true indicates that notifications are allowed, and the value - * false indicates that notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - virtual ErrCode IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) = 0; - - /** - * @brief Set Enable smartphone to collaborate with other devices for intelligent reminders - * - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given device to publish notifications. - * The value true indicates that notifications are allowed, and the value - * false indicates that notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - virtual ErrCode SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) = 0; - - /** - * @brief get whether to allow a specified application to publish notifications cross - * device collaboration. The caller must have system permissions to call this method. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given application to publish notifications. - * The value true indicates that notifications are allowed, and the value - * false indicates that notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - virtual ErrCode IsDistributedEnabledByBundle( - const sptr &bundleOption, const std::string &deviceType, bool &enabled) = 0; - - /** - * @brief Cancels a published agent notification. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param id Indicates the unique notification ID in the application. - * @return Returns cancel result. - */ - virtual ErrCode CancelAsBundleWithAgent(const sptr &bundleOption, const int32_t id) = 0; - - /** - * @brief Set the status of the target device. - * - * @param deviceType Type of the device whose status you want to set. - * @param status The status. - * @return Returns set result. - */ - virtual ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const std::string deveiceId = std::string()) = 0; - - /** - * @brief Set the status of the target device. - * - * @param deviceType Type of the device whose status you want to set. - * @param status The status. - * @param controlFlag The control flag. - * @return Returns set result. - */ - virtual ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const uint32_t controlFlag, const std::string deveiceId = std::string()) = 0; - - /** - * @brief Get do not disturb profile by id. - * - * @param id Profile id. - * @param status Indicates the NotificationDoNotDisturbProfile objects. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetDoNotDisturbProfile(int64_t id, sptr &profile) = 0; - - /** - * @brief Whether reminders are allowed. - * - * @param bundleName app bundleName - * @param isAllowUseReminder is allow use reminder - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder) = 0; -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED - /** - * @brief Register Swing Callback. - * - * @param swingCallback SwingCallBack. - * @return Returns register SwingCallback result. - */ - virtual ErrCode RegisterSwingCallback(const sptr& swingCallback) = 0; -#endif - - /** - * @brief Update Notification Timer by uid. - * - * @param uid uid. - * @return Returns Update result. - */ - virtual ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) = 0; - - /** - * @brief Set switch and bundle list of disable notification feature. - * - * @param notificationDisable Switch and bundle list of disable notification feature. - * @return Returns set result. - */ - virtual ErrCode DisableNotificationFeature(const sptr ¬ificationDisable) = 0; - - /** - * @brief Get the status of the target device. - * - * @param deviceType Type of the device whose status you want to set. - * @param status The status. - * @return Returns set result. - */ - virtual ErrCode GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) = 0; - - /** - * @brief Distribution operation based on hashCode. - * - * @param hashCode Unique ID of the notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback) = 0; - - /** - * @brief Reply distribute operation. - * - * @param hashCode Unique ID of the notification. - * @param result The result of the distribute operation. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode ReplyDistributeOperation(const std::string& hashCode, const int32_t result) = 0; - - /** - * @brief Get notificationRequest by hashCode. - * - * @param hashCode Unique ID of the notification. - * @param notificationRequest The request of of the notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetNotificationRequestByHashCode( - const std::string& hashCode, sptr& notificationRequest) = 0; - - /** - * @brief set rule of generate hashCode. - * - * @param type generate hashCode. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetHashCodeRule(const uint32_t type) = 0; -}; -} // namespace Notification -} // namespace OHOS - -#endif // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_INTERFACE_H diff --git a/frameworks/core/include/ans_manager_proxy.h b/frameworks/core/include/ans_manager_proxy.h deleted file mode 100644 index f5f192474576d32e9668900c88ba198ab4483163..0000000000000000000000000000000000000000 --- a/frameworks/core/include/ans_manager_proxy.h +++ /dev/null @@ -1,1095 +0,0 @@ -/* - * Copyright (c) 2021-2025 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. - */ - -#ifndef BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_PROXY_H -#define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_PROXY_H - -#include "ans_manager_interface.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "iremote_proxy.h" -#include "want_params.h" - -namespace OHOS { -namespace Notification { -class AnsManagerProxy : public IRemoteProxy { -public: - AnsManagerProxy() = delete; - explicit AnsManagerProxy(const sptr &impl); - ~AnsManagerProxy() override; - DISALLOW_COPY_AND_MOVE(AnsManagerProxy); - - /** - * @brief Publishes a notification with a specified label. - * @note If a notification with the same ID has been published by the current application and has not been deleted, - * this method will update the notification. - * - * @param label Indicates the label of the notification to publish. - * @param notification Indicates the NotificationRequest object for setting the notification content. - * This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode Publish(const std::string &label, const sptr ¬ification) override; - - /** - * @brief Publishes a notification. - * @note If a notification with the same ID has been published by the current application and has not been deleted, - * this method will update the notification. - * - * @param notification Indicates the NotificationRequest object for setting the notification content. - * This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode PublishNotificationForIndirectProxy(const sptr ¬ification) override; - - /** - * @brief Cancels a published notification matching the specified label and notificationId. - * - * @param notificationId Indicates the ID of the notification to cancel. - * @param label Indicates the label of the notification to cancel. - * @param instanceKey Indicates the application instance key. - * @return Returns cancel notification result. - */ - ErrCode Cancel(int32_t notificationId, const std::string &label, const std::string &instanceKey) override; - - /** - * @brief Cancels all the published notifications. - * - * @param instanceKey Indicates the application instance key. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode CancelAll(const std::string &instanceKey) override; - - /** - * @brief Cancels a published agent notification. - * - * @param notificationId Indicates the unique notification ID in the application. - * The value must be the ID of a published notification. - * Otherwise, this method does not take effect. - * @param representativeBundle Indicates the name of application bundle your application is representing. - * @param userId Indicates the specific user. - * @return Returns cancel notification result. - */ - ErrCode CancelAsBundle(int32_t notificationId, const std::string &representativeBundle, int32_t userId) override; - - /** - * @brief Cancels a published agent notification. - * - * @param bundleOption Indicates the bundle of application your application is representing. - * @param notificationId Indicates the unique notification ID in the application. - * The value must be the ID of a published notification. - * Otherwise, this method does not take effect. - * @return Returns cancel notification result. - */ - ErrCode CancelAsBundle(const sptr &bundleOption, int32_t notificationId) override; - - /** - * @brief Cancels a published agent notification. - * - * @param bundleOption Indicates the bundle of application bundle your application is representing. - * @param notificationId Indicates the unique notification ID in the application. - * The value must be the ID of a published notification. - * Otherwise, this method does not take effect. - * @param userId Indicates the specific user. - * @return Returns cancel notification result. - */ - ErrCode CancelAsBundle( - const sptr &bundleOption, int32_t notificationId, int32_t userId) override; - - /** - * @brief Adds a notification slot by type. - * - * @param slotType Indicates the notification slot type to be added. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode AddSlotByType(NotificationConstant::SlotType slotType) override; - - /** - * @brief Creates multiple notification slots. - * - * @param slots Indicates the notification slots to create. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode AddSlots(const std::vector> &slots) override; - - /** - * @brief Deletes a created notification slot based on the slot ID. - * - * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot - * This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) override; - - /** - * @brief Deletes all notification slots. - * - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RemoveAllSlots() override; - - /** - * @brief Queries a created notification slot. - * - * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This - * parameter must be specified. - * @param slot Indicates the created NotificationSlot. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) override; - - /** - * @brief Obtains all notification slots of this application. - * - * @param slots Indicates the created NotificationSlot. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSlots(std::vector> &slots) override; - - /** - * @brief Obtains the number of slot. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param num Indicates the number of slot. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override; - - /** - * @brief Obtains active notifications of the current application in the system. - * - * @param notifications Indicates active NotificationRequest objects of the current application. - * @param instanceKey Indicates the application instance key. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetActiveNotifications(std::vector> ¬ifications, - const std::string &instanceKey) override; - - /** - * @brief Obtains the number of active notifications of the current application in the system. - * - * @param num Indicates the number of active notifications of the current application. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetActiveNotificationNums(uint64_t &num) override; - - /** - * @brief Obtains all active notifications in the current system. The caller must have system permissions to - * call this method. - * - * @param notifications Indicates all active notifications of this application. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetAllActiveNotifications(std::vector> ¬ifications) override; - - ErrCode GetAllNotificationsBySlotType(std::vector> ¬ifications, - const NotificationConstant::SlotType slotType) override; - - /** - * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method - * to obtain particular active notifications, you must have received the notifications and obtained the key - * via {Notification::GetKey()}. - * - * @param key Indicates the key array for querying corresponding active notifications. - * If this parameter is null, this method returns all active notifications in the system. - * @param notification Indicates the set of active notifications corresponding to the specified key. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSpecialActiveNotifications( - const std::vector &key, std::vector> ¬ifications) override; - - /** - * @brief Obtains the live view notification extra info by the extraInfoKeys. To call this method - * to obtain particular live view notification extra info, you must have received the - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param notificationId Indicates the id of the notification to get the extra info by extra info keys. - * @param label - * @param extraInfoKeys - * @param extraInfo - * @return - */ - ErrCode GetActiveNotificationByFilter( - const sptr &bundleOption, const int32_t notificationId, const std::string &label, - const std::vector extraInfoKeys, sptr &request) override; - - /** - * @brief Checks whether your application has permission to publish notifications by calling - * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the - * given representativeBundle. - * - * @param representativeBundle Indicates the name of application bundle your application is representing. - * @param canPublish Indicates whether your application has permission to publish notifications. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) override; - - /** - * @brief Publishes a notification in the name of a specified application bundle. - * @note If the notification to be published has the same ID as a published notification that has not been canceled, - * the existing notification will be replaced by the new one. - * - * @param notification Indicates the NotificationRequest object for setting the notification content. - * This parameter must be specified. - * @param representativeBundle Indicates the name of the application bundle that allows your application to publish - * notifications for it by calling setNotificationAgent. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode PublishAsBundle( - const sptr notification, const std::string &representativeBundle) override; - - /** - * @brief Sets the number of active notifications of the current application as the number to be displayed on the - * notification badge. - * - * @param num Indicates the badge number. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetNotificationBadgeNum(int32_t num) override; - - /** - * @brief Obtains the importance level of this application. - * - * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, - LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetBundleImportance(int32_t &importance) override; - - /** - * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. - * - * @param granted True if the application has permission; false for otherwise. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode HasNotificationPolicyAccessPermission(bool &granted) override; - - /** - * @brief Trigger the local live view after the button has been clicked. - * @note Your application must have platform signature to use this method. - * - * @param bundleOption Indicates the bundle name and uid of the application whose notifications has been clicked. - * @param notificationId Indicates the id of the notification. - * @param buttonOption Indicates which button has been clicked. - * @return Returns trigger localLiveView result. - */ - ErrCode TriggerLocalLiveView(const sptr &bundleOption, - const int32_t notificationId, const sptr &buttonOption) override; - - /** - * @brief Delete notification. - * - * @param bundleOption Indicates the NotificationBundleOption of the notification. - * @param notificationId Indicates the id of the notification. - * @param label Indicates the label of the notification. - * @param removeReason Indicates the reason of remove notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RemoveNotification(const sptr &bundleOption, int32_t notificationId, - const std::string &label, int32_t removeReason) override; - - /** - * @brief Delete all notifications. - * - * @param bundleOption Indicates the NotificationBundleOption of notifications. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RemoveAllNotifications(const sptr &bundleOption) override; - - ErrCode RemoveNotifications(const std::vector &hashcodes, int32_t removeReason) override; - - /** - * @brief Delete notification based on key. - * - * @param key Indicates the key to delete notification. - * @param removeReason Indicates the reason of remove notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode Delete(const std::string &key, int32_t removeReason) override; - - /** - * @brief Remove notifications based on bundle. - * - * @param bundleOption Indicates the NotificationBundleOption of notifications. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode DeleteByBundle(const sptr &bundleOption) override; - - /** - * @brief Remove all notifications. - * - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode DeleteAll() override; - - /** - * @brief Get all the slots corresponding to the bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param slots Indicates the notification slots. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSlotsByBundle( - const sptr &bundleOption, std::vector> &slots) override; - - /** - * @brief Get the specified slot corresponding to the bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This - * parameter must be specified. - * @param slot Indicates the notification slot. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSlotByBundle( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, - sptr &slot) override; - - /** - * @brief Update slots according to bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param slots Indicates the notification slots to be updated. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode UpdateSlots( - const sptr &bundleOption, const std::vector> &slots) override; - - /** - * @brief Allow notifications to be sent based on the deviceId. - * - * @param deviceId Indicates the device Id. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RequestEnableNotification(const std::string &deviceId, - const sptr &callback, - const sptr &callerToken) override; - - /** - * @brief Allow application to publish notifications. - * - * @param bundleName bundle name. - * @param uid uid. - * @return Returns set notifications enabled for the bundle result. - */ - ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) override; - - /** - * @brief Set whether to allow the specified deviceId to send notifications for current bundle. - * - * @param deviceId Indicates the device Id. - * @param enabled Indicates the flag that allows notification to be pulished. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override; - - /** - * @brief Set whether to allow the specified deviceId to send notifications for all bundles. - * - * @param deviceId Indicates the device Id. - * @param enabled Indicates the flag that allows notification to be pulished. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) override; - - /** - * @brief Set whether to allow the specified bundle to send notifications. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the flag that allows notification to be pulished. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetNotificationsEnabledForSpecialBundle( - const std::string &deviceId, const sptr &bundleOption, bool enabled) override; - - /** - * @brief Sets whether the bundle allows the banner to display notification. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the flag that allows badge to be shown. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) override; - - /** - * @brief Gets whether the bundle allows the badge to display the status of notifications. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the flag that allows badge to be shown. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) override; - - /** - * @brief Gets whether allows the badge to display the status of notifications. - * - * @param enabled Indicates the flag that allows badge to be shown. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetShowBadgeEnabled(bool &enabled) override; - - /** - * @brief Subscribes notifications. - * - * @param subscriber Indicates the subscriber. - * @param info Indicates the NotificationSubscribeInfo object. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode Subscribe(const sptr &subscriber, - const sptr &info) override; - - /** - * @brief Subscribes notifications self. - * - * @param subscriber Indicates the subscriber. - * @param info Indicates the NotificationSubscribeInfo object. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SubscribeSelf(const sptr &subscriber) override; - - /** - * @brief Subscribes notifications. - * - * @param subscriber Indicates the subscriber. - * @param info Indicates the NotificationSubscribeInfo object. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SubscribeLocalLiveView(const sptr &subscriber, - const sptr &info, const bool isNative) override; - - /** - * @brief Unsubscribes notifications. - * - * @param subscriber Indicates the subscriber. - * @param info Indicates the NotificationSubscribeInfo object. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode Unsubscribe(const sptr &subscriber, - const sptr &info) override; - - /** - * @brief Checks whether this device is allowed to publish notifications. - * - * @param allowed Indicates the flag that allows notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode IsAllowedNotify(bool &allowed) override; - - /** - * @brief Checks whether this application is allowed to publish notifications. - * - * @param allowed Indicates the flag that allows notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode IsAllowedNotifySelf(bool &allowed) override; - - /** - * @brief Checks whether this application can pop enable notification dialog. - * - * @param canPop True if can pop enable notification dialog - * @return Returns is canPop result. - */ - ErrCode CanPopEnableNotificationDialog(const sptr &callback, - bool &canPop, std::string &bundleName) override; - - /** - * @brief remove enable notification dialog. - * - * @return Returns remove dialog result. - */ - ErrCode RemoveEnableNotificationDialog() override; - - /** - * @brief Checks whether notifications are allowed for a specific bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param allowed Indicates the flag that allows notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) override; - - /** - * @brief Set do not disturb date. - * - * @param date Indicates the NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetDoNotDisturbDate(const sptr &date) override; - - /** - * @brief Get do not disturb date. - * - * @param date Indicates the NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetDoNotDisturbDate(sptr &date) override; - - /** - * @brief Add do not disturb Profiles. - * - * @param profiles Indicates the NotificationDoNotDisturbProfile objects. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode AddDoNotDisturbProfiles(const std::vector> &profiles) override; - - /** - * @brief Remove do not disturb Profiles. - * - * @param profiles Indicates the NotificationDoNotDisturbProfile objects. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RemoveDoNotDisturbProfiles(const std::vector> &profiles) override; - - /** - * @brief Get whether Do Not Disturb mode is supported. - * - * @param doesSupport Indicates the flag that supports DND mode. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) override; - - /** - * @brief Is coming call need silent in do not disturb mode. - * - * @param phoneNumber the calling format number. - * @return Returns silent in do not disturb mode. - */ - ErrCode IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) override; - - /** - * @brief Cancel notifications according to group. - * - * @param groupName Indicates the group name. - * @param instanceKey Indicates the application instance key. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode CancelGroup(const std::string &groupName, const std::string &instanceKey) override; - - /** - * @brief Delete notifications according to bundle and group. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param groupName Indicates the group name. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RemoveGroupByBundle( - const sptr &bundleOption, const std::string &groupName) override; - - /** - * @brief Gets whether distributed notification is enabled. - * - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode IsDistributedEnabled(bool &enabled) override; - - /** - * @brief Sets distributed notification enabled or disabled. - * - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode EnableDistributed(bool enabled) override; - - /** - * @brief Sets distributed notification enabled or disabled for specific bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode EnableDistributedByBundle(const sptr &bundleOption, bool enabled) override; - - /** - * @brief Sets distributed notification enabled or disabled for current bundle. - * - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode EnableDistributedSelf(bool enabled) override; - - /** - * @brief Gets whether distributed notification is enabled for specific bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) override; - - /** - * @brief Get the reminder type of the current device. - * - * @param remindType Reminder type for the device. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) override; - - /** - * @brief Publishes a continuous notification. - * - * @param request Notification requests that need to be posted. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode PublishContinuousTaskNotification(const sptr &request) override; - - /** - * @brief Cancels a continuous notification. - * - * @param label Identifies the label of the specified notification. - * @param notificationId Identifies the id of the specified notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) override; - - /** - * @brief Checks whether this device is support template. - * - * @param templateName Identifies the template name for searching as a condition. - * @param support Identifies the support flag. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode IsSupportTemplate(const std::string &templateName, bool &support) override; - - /** - * @brief Checks Whether the specified users is allowed to publish notifications. - * - * @param userId Identifies the user's id. - * @param allowed Identifies the allowed flag. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) override; - - /** - * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must - * have system permissions to call this method. - * - * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only - * be null or an empty string, indicating the current device. - * @param enabled Specifies whether to allow all applications to publish notifications. The value true - * indicates that notifications are allowed, and the value false indicates that notifications - * are not allowed. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetNotificationsEnabledByUser(const int32_t &userId, bool enabled) override; - - /** - * @brief Delete all notifications by user. - * - * @param userId Indicates the user id. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode DeleteAllByUser(const int32_t &userId) override; - - /** - * @brief Set do not disturb date by user. - * - * @param userId Indicates the user id. - * @param date Indicates NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr &date) override; - - /** - * @brief Get the do not disturb date by user. - * - * @param userId Indicates the user id. - * @param date Indicates the NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date) override; - ErrCode SetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) override; - ErrCode GetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool &enabled) override; - ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) override; - - /** - * @brief Obtains specific datas via specified dump option. - * - * @param cmd Indicates the specified dump command. - * @param bundle Indicates the specified bundle name. - * @param userId Indicates the specified userId. - * @param dumpInfo Indicates the container containing datas. - * @return Returns check result. - */ - ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, int32_t recvUserId, - std::vector &dumpInfo) override; - - /** - * @brief Set whether to sync notifications to devices that do not have the app installed. - * - * @param userId Indicates the specific user. - * @param enabled Allow or disallow sync notifications. - * @return Returns set enabled result. - */ - ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) override; - - /** - * @brief Obtains whether to sync notifications to devices that do not have the app installed. - * - * @param userId Indicates the specific user. - * @param enabled Allow or disallow sync notifications. - * @return Returns get enabled result. - */ - ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) override; - - /** - * @brief Set badge number. - * - * @param badgeNumber The badge number. - * @return Returns set badge number result. - */ - ErrCode SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) override; - - /** - * @brief Set badge number by bundle. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param badgeNumber The badge number. - * @return Returns set badge number by bundle result. - */ - ErrCode SetBadgeNumberByBundle(const sptr &bundleOption, int32_t badgeNumber) override; - - /** - * @brief Set badge number for dh by bundle. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param badgeNumber The badge number. - * @return Returns set badge number by bundle result. - */ - ErrCode SetBadgeNumberForDhByBundle( - const sptr &bundleOption, int32_t badgeNumber) override; - - /** - * @brief Get the slotFlags of slot. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param slot Indicates the specified slot object - * @param slotFlags Indicates the slogFlags of slot to get. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetSlotFlagsAsBundle(const sptr &bundleOption, uint32_t &slotFlags) override; - - /** - * @brief Set the slotFlags of slot. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param slot Indicates the specified slot object - * @param slotFlags Indicates the slogFlags of slot to set. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetSlotFlagsAsBundle(const sptr &bundleOption, uint32_t slotFlags) override; - - /** - * @brief Obtains allow notification application list. - * - * @param bundleOption Indicates the bundle bundleOption. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetAllNotificationEnabledBundles(std::vector &bundleOption) override; - - /** - * @brief Obtains allow liveview application list. - * - * @param bundleOption Indicates the bundle bundleOption. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetAllLiveViewEnabledBundles(std::vector &bundleOption) override; - - /** - * @brief Obtains allow distributed application list. - * - * @param deviceType Indicates device type. - * @param bundleOption Indicates the bundle bundleOption. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetAllDistribuedEnabledBundles(const std::string& deviceType, - std::vector &bundleOption) override; - - /** - * @brief Register Push Callback. - * - * @param pushCallback PushCallBack. - * @param notificationCheckRequest Filter conditions for push check. - * @return Returns register PushCallback result. - */ - ErrCode RegisterPushCallback(const sptr &pushCallback, - const sptr ¬ificationCheckRequest) override; - - /** - * @brief Unregister Push Callback. - * - * @return Returns unregister push Callback result. - */ - ErrCode UnregisterPushCallback() override; - - /** - * @brief Set agent relationship. - * - * @param key Indicates storing agent relationship if the value is "PROXY_PKG". - * @param value Indicates key-value pair of agent relationship. - * @return Returns set result. - */ - ErrCode SetAdditionConfig(const std::string &key, const std::string &value) override; - - /** - * @brief Sets whether to allow a specified application to publish notifications cross - * device collaboration. The caller must have system permissions to call this method. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given application to publish notifications. The value - * true indicates that notifications are allowed, and the value false indicates that - * notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - ErrCode SetDistributedEnabledByBundle( - const sptr &bundleOption, const std::string &deviceType, const bool enabled) override; - - /** - * @brief get whether to allow a specified application to publish notifications cross - * device collaboration. The caller must have system permissions to call this method. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given application to publish notifications. The value - * true indicates that notifications are allowed, and the value false indicates that - * notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - ErrCode IsDistributedEnabledByBundle( - const sptr &bundleOption, const std::string &deviceType, bool &enabled) override; - - /** - * @brief Get Enable smartphone to collaborate with other devices for intelligent reminders - * - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given device to publish notifications. - * The value true indicates that notifications are allowed, and the value - * false indicates that notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - ErrCode IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) override; - - /** - * @brief Set Enable smartphone to collaborate with other devices for intelligent reminders - * - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given device to publish notifications. - * The value true indicates that notifications are allowed, and the value - * false indicates that notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - ErrCode SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) override; - - /** - * @brief Set the channel switch for collaborative reminders. - The caller must have system permissions to call this method. - * - * @param slotType Indicates the slot type of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Indicates slot switch status. - * @return Returns set channel switch result. - */ - ErrCode SetDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled) override; - - /** - * @brief Query the channel switch for collaborative reminders. - The caller must have system permissions to call this method. - * - * @param slotType Indicates the slot type of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Indicates slot switch status. - * @return Returns channel switch result. - */ - ErrCode IsDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) override; - - /** - * @brief Cancels a published agent notification. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param id Indicates the unique notification ID in the application. - * @return Returns cancel result. - */ - ErrCode CancelAsBundleWithAgent(const sptr &bundleOption, const int32_t id) override; - - /** - * @brief Set the status of the target device. - * - * @param deviceType Type of the device whose status you want to set. - * @param status The status. - * @return Returns set result. - */ - ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const std::string deveiceId = std::string()) override; - - /** - * @brief Set the status of the target device. - * - * @param deviceType Type of the device whose status you want to set. - * @param status The status. - * @param controlFlag The control flag. - * @return Returns set result. - */ - ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const uint32_t controlFlag, const std::string deveiceId = std::string()) override; - - /** - * @brief Get do not disturb profile by id. - * - * @param id Profile id. - * @param status Indicates the NotificationDoNotDisturbProfile objects. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetDoNotDisturbProfile(int64_t id, sptr &profile) override; - - /** - * @brief Whether reminders are allowed. - * - * @param bundleName app bundleName - * @param isAllowUseReminder is allow use reminder - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder) override; - -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED - /** - * @brief Register Swing Callback. - * - * @param swingCallback SwingCallBack. - * @return Returns register SwingCallback result. - */ - ErrCode RegisterSwingCallback(const sptr &swingCallback) override; -#endif - - /** - * @brief Update Notification Timer by uid. - * - * @param uid uid. - * @return Returns Update result. - */ - ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) override; - - /** - * @brief Set switch and bundle list of disable notification feature. - * - * @param notificationDisable Switch and bundle list of disable notification feature. - * @return Returns set result. - */ - ErrCode DisableNotificationFeature(const sptr ¬ificationDisable) override; - - /** - * @brief Get the status of the target device. - * - * @param deviceType Type of the device whose status you want to set. - * @param status The status. - * @return Returns set result. - */ - ErrCode GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) override; - - /** - * @brief Distribution operation based on hashCode. - * - * @param hashCode Unique ID of the notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback) override; - - /** - * @brief Reply distribute operation. - * - * @param hashCode Unique ID of the notification. - * @param result The result of the distribute operation. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode ReplyDistributeOperation(const std::string& hashCode, const int32_t result) override; - - /** - * @brief Get notificationRequest by hashCode. - * - * @param hashCode Unique ID of the notification. - * @param notificationRequest The request of of the notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetNotificationRequestByHashCode( - const std::string& hashCode, sptr& notificationRequest) override; - - /** - * @brief set rule of generate hashCode. - * - * @param type generate hashCode. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetHashCodeRule(const uint32_t type) override; - -private: - ErrCode InnerTransact(NotificationInterfaceCode code, MessageOption &flags, - MessageParcel &data, MessageParcel &reply); - - template - bool WriteParcelableVector(const std::vector> &parcelableVector, MessageParcel &data) - { - if (!data.WriteInt32(parcelableVector.size())) { - ANS_LOGE("Failed to write ParcelableVector size."); - return false; - } - - for (auto &parcelable : parcelableVector) { - if (!data.WriteStrongParcelable(parcelable)) { - ANS_LOGE("Failed to write ParcelableVector"); - return false; - } - } - return true; - } - - template - bool ReadParcelableVector(std::vector> &parcelableInfos, MessageParcel &reply, ErrCode &result) - { - if (!reply.ReadInt32(result)) { - ANS_LOGE("read result failed."); - return false; - } - - int32_t infoSize = 0; - if (!reply.ReadInt32(infoSize)) { - ANS_LOGE("read Parcelable size failed."); - return false; - } - - parcelableInfos.clear(); - infoSize = (infoSize < MAX_PARCELABLE_VECTOR_NUM) ? infoSize : MAX_PARCELABLE_VECTOR_NUM; - for (int32_t index = 0; index < infoSize; index++) { - sptr info = reply.ReadStrongParcelable(); - if (info == nullptr) { - ANS_LOGE("read Parcelable infos failed."); - return false; - } - parcelableInfos.emplace_back(info); - } - - return true; - } - static inline BrokerDelegator delegator_; - - ErrCode ReadReminders(uint8_t &count, MessageParcel &reply, std::vector> &reminders); -}; -} // namespace Notification -} // namespace OHOS - -#endif // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_PROXY_H diff --git a/frameworks/core/include/ans_manager_stub.h b/frameworks/core/include/ans_manager_stub.h deleted file mode 100644 index 06e8942c72624d38225fd516512ef0a5c49b0943..0000000000000000000000000000000000000000 --- a/frameworks/core/include/ans_manager_stub.h +++ /dev/null @@ -1,1204 +0,0 @@ -/* - * Copyright (c) 2021-2025 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. - */ - -#ifndef BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_STUB_H -#define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_STUB_H - -#include -#include - -#include "ans_manager_interface.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "ians_subscriber_local_live_view.h" -#include "iremote_stub.h" - -namespace OHOS { -namespace Notification { -class AnsManagerStub : public IRemoteStub { -public: - AnsManagerStub(); - ~AnsManagerStub() override; - DISALLOW_COPY_AND_MOVE(AnsManagerStub); - - /** - * @brief Handle remote request. - * - * @param data Indicates the input parcel. - * @param reply Indicates the output parcel. - * @param option Indicates the message option. - * @return Returns ERR_OK on success, others on failure. - */ - virtual int OnRemoteRequest( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - - /** - * @brief Publishes a notification with a specified label. - * @note If a notification with the same ID has been published by the current application and has not been deleted, - * this method will update the notification. - * - * @param label Indicates the label of the notification to publish. - * @param notification Indicates the NotificationRequest object for setting the notification content. - * This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode Publish(const std::string &label, const sptr ¬ification) override; - - /** - * @brief Publishes a notification. - * @note If a notification with the same ID has been published by the current application and has not been deleted, - * this method will update the notification. - * - * @param notification Indicates the NotificationRequest object for setting the notification content. - * This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode PublishNotificationForIndirectProxy(const sptr ¬ification) override; - - /** - * @brief Cancels a published notification matching the specified label and notificationId. - * - * @param notificationId Indicates the ID of the notification to cancel. - * @param label Indicates the label of the notification to cancel. - * @param instanceKey Indicates the application instance key. - * @return Returns cancel notification result. - */ - virtual ErrCode Cancel(int32_t notificationId, const std::string &label, const std::string &instanceKey) override; - - /** - * @brief Cancels all the published notifications. - * - * @param instanceKey Indicates the application instance key. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CancelAll(const std::string &instanceKey) override; - - /** - * @brief Cancels a published agent notification. - * - * @param notificationId Indicates the unique notification ID in the application. - * The value must be the ID of a published notification. - * Otherwise, this method does not take effect. - * @param representativeBundle Indicates the name of application bundle your application is representing. - * @param userId Indicates the specific user. - * @return Returns cancel notification result. - */ - virtual ErrCode CancelAsBundle( - int32_t notificationId, const std::string &representativeBundle, int32_t userId) override; - - /** - * @brief Cancels a published agent notification. - * - * @param bundleOption Indicates the bundle of application your application is representing. - * @param notificationId Indicates the unique notification ID in the application. - * The value must be the ID of a published notification. - * Otherwise, this method does not take effect. - * @return Returns cancel notification result. - */ - virtual ErrCode CancelAsBundle(const sptr &bundleOption, int32_t notificationId) override; - - /** - * @brief Cancels a published agent notification. - * - * @param bundleOption Indicates the bundle of application bundle your application is representing. - * @param notificationId Indicates the unique notification ID in the application. - * The value must be the ID of a published notification. - * Otherwise, this method does not take effect. - * @param userId Indicates the specific user. - * @return Returns cancel notification result. - */ - virtual ErrCode CancelAsBundle( - const sptr &bundleOption, int32_t notificationId, int32_t userId) override; - - /** - * @brief Adds a notification slot by type. - * - * @param slotType Indicates the notification slot type to be added. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode AddSlotByType(NotificationConstant::SlotType slotType) override; - - /** - * @brief Creates multiple notification slots. - * - * @param slots Indicates the notification slots to create. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode AddSlots(const std::vector> &slots) override; - - /** - * @brief Deletes a created notification slot based on the slot ID. - * - * @param slotType Indicates the type of the slot, which is created by AddNotificationSlot - * This parameter must be specified. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) override; - - /** - * @brief Deletes all notification slots. - * - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveAllSlots() override; - - /** - * @brief Queries a created notification slot. - * - * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This - * parameter must be specified. - * @param slot Indicates the created NotificationSlot. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotByType( - const NotificationConstant::SlotType &slotType, sptr &slot) override; - - /** - * @brief Obtains all notification slots of this application. - * - * @param slots Indicates the created NotificationSlot. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlots(std::vector> &slots) override; - - /** - * @brief Obtains the number of slot. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param num Indicates the number of slot. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override; - - /** - * @brief Obtains active notifications of the current application in the system. - * - * @param notifications Indicates active NotificationRequest objects of the current application. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetActiveNotifications( - std::vector> ¬ifications, const std::string &instanceKey) override; - - /** - * @brief Obtains the number of active notifications of the current application in the system. - * - * @param num Indicates the number of active notifications of the current application. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetActiveNotificationNums(uint64_t &num) override; - - /** - * @brief Obtains all active notifications in the current system. The caller must have system permissions to - * call this method. - * - * @param notifications Indicates all active notifications of this application. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetAllActiveNotifications(std::vector> ¬ifications) override; - - virtual ErrCode GetAllNotificationsBySlotType(std::vector> ¬ifications, - const NotificationConstant::SlotType slotType) override; - - /** - * @brief Obtains the active notifications corresponding to the specified key in the system. To call this method - * to obtain particular active notifications, you must have received the notifications and obtained the key - * via {Notification::GetKey()}. - * - * @param key Indicates the key array for querying corresponding active notifications. - * If this parameter is null, this method returns all active notifications in the system. - * @param notification Indicates the set of active notifications corresponding to the specified key. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSpecialActiveNotifications( - const std::vector &key, std::vector> ¬ifications) override; - - virtual ErrCode GetActiveNotificationByFilter( - const sptr &bundleOption, const int32_t notificationId, const std::string &label, - std::vector extraInfoKeys, sptr &request) override; - - /** - * @brief Checks whether your application has permission to publish notifications by calling - * PublishNotificationAsBundle(string, NotificationRequest) in the name of another application indicated by the - * given representativeBundle. - * - * @param representativeBundle Indicates the name of application bundle your application is representing. - * @param canPublish Indicates whether your application has permission to publish notifications. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) override; - - /** - * @brief Publishes a notification in the name of a specified application bundle. - * @note If the notification to be published has the same ID as a published notification that has not been canceled, - * the existing notification will be replaced by the new one. - * - * @param notification Indicates the NotificationRequest object for setting the notification content. - * This parameter must be specified. - * @param representativeBundle Indicates the name of the application bundle that allows your application to publish - * notifications for it by calling setNotificationAgent. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode PublishAsBundle( - const sptr notification, const std::string &representativeBundle) override; - - /** - * @brief Sets the number of active notifications of the current application as the number to be displayed on the - * notification badge. - * - * @param num Indicates the badge number. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationBadgeNum(int32_t num) override; - - /** - * @brief Obtains the importance level of this application. - * - * @param importance Indicates the importance level of this application, which can be LEVEL_NONE, - LEVEL_MIN, LEVEL_LOW, LEVEL_DEFAULT, LEVEL_HIGH, or LEVEL_UNDEFINED. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetBundleImportance(int32_t &importance) override; - - /** - * @brief Checks whether this application has permission to modify the Do Not Disturb (DND) notification policy. - * - * @param granted True if the application has permission; false for otherwise. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) override; - - /** - * @brief Trigger the local live view after the button has been clicked. - * @note Your application must have platform signature to use this method. - * - * @param bundleOption Indicates the bundle name and uid of the application whose notifications has been clicked. - * @param notificationId Indicates the id of the notification. - * @param buttonOption Indicates which button has been clicked. - * @return Returns trigger localLiveView result. - */ - virtual ErrCode TriggerLocalLiveView(const sptr &bundleOption, - const int32_t notificationId, const sptr &buttonOption) override; - - /** - * @brief Delete notification. - * - * @param bundleOption Indicates the NotificationBundleOption of the notification. - * @param notificationId Indicates the id of the notification. - * @param label Indicates the label of the notification. - * @param removeReason Indicates the reason of remove notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveNotification(const sptr &bundleOption, int32_t notificationId, - const std::string &label, int32_t removeReason) override; - - /** - * @brief Delete all notifications. - * - * @param bundleOption Indicates the NotificationBundleOption of notifications. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveAllNotifications(const sptr &bundleOption) override; - - ErrCode RemoveNotifications(const std::vector &keys, int32_t removeReason) override; - - /** - * @brief Delete notification based on key. - * - * @param key Indicates the key to delete notification. - * @param removeReason Indicates the reason of remove notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode Delete(const std::string &key, int32_t removeReason) override; - - /** - * @brief Remove notifications based on bundle. - * - * @param bundleOption Indicates the NotificationBundleOption of notifications. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode DeleteByBundle(const sptr &bundleOption) override; - - /** - * @brief Remove all notifications. - * - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode DeleteAll() override; - - /** - * @brief Get all the slots corresponding to the bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param slots Indicates the notification slots. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotsByBundle( - const sptr &bundleOption, std::vector> &slots) override; - - /** - * @brief Get the specified slot corresponding to the bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param slotType Indicates the ID of the slot, which is created by AddNotificationSlot(NotificationSlot). This - * parameter must be specified. - * @param slot Indicates the notification slot. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetSlotByBundle( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, - sptr &slot) override; - - /** - * @brief Update slots according to bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param slots Indicates the notification slots to be updated. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode UpdateSlots( - const sptr &bundleOption, const std::vector> &slots) override; - - /** - * @brief Allow notifications to be sent based on the deviceId. - * - * @param deviceId Indicates the device Id. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RequestEnableNotification(const std::string &deviceId, - const sptr &callback, - const sptr &callerToken) override; - - /** - * @brief Allow application to publish notifications. - * - * @param bundleName bundle name. - * @param uid uid. - * @return Returns set notifications enabled for the bundle result. - */ - ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) override; - - /** - * @brief Set whether to allow the specified deviceId to send notifications for current bundle. - * - * @param deviceId Indicates the device Id. - * @param enabled Indicates the flag that allows notification to be pulished. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override; - - /** - * @brief Set whether to allow the specified deviceId to send notifications for all bundles. - * - * @param deviceId Indicates the device Id. - * @param enabled Indicates the flag that allows notification to be pulished. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) override; - - /** - * @brief Set whether to allow the specified bundle to send notifications. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the flag that allows notification to be pulished. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationsEnabledForSpecialBundle( - const std::string &deviceId, const sptr &bundleOption, bool enabled) override; - - /** - * @brief Sets whether the bundle allows the banner to display notification. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the flag that allows badge to be shown. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetShowBadgeEnabledForBundle( - const sptr &bundleOption, bool enabled) override; - - /** - * @brief Gets whether the bundle allows the badge to display the status of notifications. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the flag that allows badge to be shown. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetShowBadgeEnabledForBundle( - const sptr &bundleOption, bool &enabled) override; - - /** - * @brief Gets whether allows the badge to display the status of notifications. - * - * @param enabled Indicates the flag that allows badge to be shown. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetShowBadgeEnabled(bool &enabled) override; - - /** - * @brief Subscribes notifications. - * - * @param subscriber Indicates the subscriber. - * @param info Indicates the NotificationSubscribeInfo object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode Subscribe( - const sptr &subscriber, const sptr &info) override; - - /** - * @brief Subscribes notifications self. - * - * @param subscriber Indicates the subscriber. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SubscribeSelf(const sptr &subscriber) override; - - virtual ErrCode SubscribeLocalLiveView( - const sptr &subscriber, - const sptr &info, const bool isNative) override; - - /** - * @brief Unsubscribes notifications. - * - * @param subscriber Indicates the subscriber. - * @param info Indicates the NotificationSubscribeInfo object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode Unsubscribe( - const sptr &subscriber, const sptr &info) override; - - /** - * @brief Checks whether this device is allowed to publish notifications. - * - * @param allowed Indicates the flag that allows notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsAllowedNotify(bool &allowed) override; - - /** - * @brief Checks whether this application is allowed to publish notifications. - * - * @param allowed Indicates the flag that allows notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsAllowedNotifySelf(bool &allowed) override; - - /** - * @brief Checks whether this application can pop enable notification dialog. - * - * @param canPop True if can pop enable notification dialog - * @return Returns is canPop result. - */ - ErrCode CanPopEnableNotificationDialog(const sptr &callback, - bool &canPop, std::string &bundleName) override; - - /** - * @brief remove enable notification dialog. - * - * @return Returns remove dialog result. - */ - ErrCode RemoveEnableNotificationDialog() override; - - /** - * @brief Checks whether notifications are allowed for a specific bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param allowed Indicates the flag that allows notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsSpecialBundleAllowedNotify( - const sptr &bundleOption, bool &allowed) override; - - /** - * @brief Set do not disturb date. - * - * @param date Indicates the NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetDoNotDisturbDate(const sptr &date) override; - - /** - * @brief Get do not disturb date. - * - * @param date Indicates the NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetDoNotDisturbDate(sptr &date) override; - - /** - * @brief Add do not disturb profiles. - * - * @param profiles Indicates the NotificationDoNotDisturbProfile objects. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode AddDoNotDisturbProfiles(const std::vector> &profiles) override; - - /** - * @brief Remove do not disturb profiles. - * - * @param profiles Indicates the NotificationDoNotDisturbProfile objects. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode RemoveDoNotDisturbProfiles(const std::vector> &profiles) override; - - /** - * @brief Get whether Do Not Disturb mode is supported. - * - * @param doesSupport Indicates the flag that supports DND mode. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) override; - - /** - * @brief Is coming call need silent in do not disturb mode. - * - * @param phoneNumber the calling format number. - * @return Returns silent in do not disturb mode. - */ - virtual ErrCode IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) override; - - /** - * @brief Cancel notifications according to group. - * - * @param groupName Indicates the group name. - * @param instanceKey Indicates the application instance key. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CancelGroup(const std::string &groupName, const std::string &instanceKey) override; - - /** - * @brief Delete notifications according to bundle and group. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param groupName Indicates the group name. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode RemoveGroupByBundle( - const sptr &bundleOption, const std::string &groupName) override; - - /** - * @brief Gets whether distributed notification is enabled. - * - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsDistributedEnabled(bool &enabled) override; - - /** - * @brief Sets distributed notification enabled or disabled. - * - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode EnableDistributed(bool enabled) override; - - /** - * @brief Sets distributed notification enabled or disabled for specific bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode EnableDistributedByBundle( - const sptr &bundleOption, bool enabled) override; - - /** - * @brief Sets distributed notification enabled or disabled for current bundle. - * - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode EnableDistributedSelf(bool enabled) override; - - /** - * @brief Gets whether distributed notification is enabled for specific bundle. - * - * @param bundleOption Indicates the NotificationBundleOption object. - * @param enabled Indicates the enabled flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsDistributedEnableByBundle( - const sptr &bundleOption, bool &enabled) override; - - /** - * @brief Get the reminder type of the current device. - * - * @param remindType Reminder type for the device. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) override; - - /** - * @brief Publishes a continuous notification. - * - * @param request Notification requests that need to be posted. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode PublishContinuousTaskNotification(const sptr &request) override; - - /** - * @brief Cancels a continuous notification. - * - * @param label Identifies the label of the specified notification. - * @param notificationId Identifies the id of the specified notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) override; - - /** - * @brief Checks whether this device is support template. - * - * @param templateName Identifies the template name for searching as a condition. - * @param support Identifies the support flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsSupportTemplate(const std::string &templateName, bool &support) override; - - /** - * @brief Checks Whether the specified users is allowed to publish notifications. - * - * @param userId Identifies the user's id. - * @param allowed Identifies the allowed flag. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) override; - - /** - * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must - * have system permissions to call this method. - * - * @param deviceId Indicates the ID of the device running the application. At present, this parameter can only - * be null or an empty string, indicating the current device. - * @param enabled Specifies whether to allow all applications to publish notifications. The value true - * indicates that notifications are allowed, and the value false indicates that notifications - * are not allowed. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) override; - - /** - * @brief Delete all notifications by user. - * - * @param userId Indicates the user id. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode DeleteAllByUser(const int32_t &userId) override; - - /** - * @brief Set do not disturb date by user. - * - * @param userId Indicates the user id. - * @param date Indicates NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr &date) override; - - /** - * @brief Get the do not disturb date by user. - * - * @param userId Indicates the user id. - * @param date Indicates the NotificationDoNotDisturbDate object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date) override; - virtual ErrCode SetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) override; - virtual ErrCode GetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool &enabled) override; - virtual ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) override; - - /** - * @brief Obtains specific datas via specified dump option. - * - * @param cmd Indicates the specified dump command. - * @param bundle Indicates the specified bundle name. - * @param userId Indicates the specified userId. - * @param dumpInfo Indicates the container containing datas. - * @return Returns check result. - */ - virtual ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, int32_t recvUserId, - std::vector &dumpInfo) override; - - /** - * @brief Set whether to sync notifications to devices that do not have the app installed. - * - * @param userId Indicates the specific user. - * @param enabled Allow or disallow sync notifications. - * @return Returns set enabled result. - */ - virtual ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) override; - - /** - * @brief Obtains whether to sync notifications to devices that do not have the app installed. - * - * @param userId Indicates the specific user. - * @param enabled Allow or disallow sync notifications. - * @return Returns get enabled result. - */ - virtual ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) override; - - /** - * @brief Set badge number. - * - * @param badgeNumber The badge number. - * @return Returns set badge number result. - */ - virtual ErrCode SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) override; - - /** - * @brief Set badge number by bundle. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param badgeNumber The badge number. - * @return Returns set badge number by bundle result. - */ - virtual ErrCode SetBadgeNumberByBundle( - const sptr &bundleOption, int32_t badgeNumber) override; - - /** - * @brief Set badge number for dh by bundle. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param badgeNumber The badge number. - * @return Returns set badge number by bundle result. - */ - virtual ErrCode SetBadgeNumberForDhByBundle( - const sptr &bundleOption, int32_t badgeNumber) override; - - /** - * @brief Get slotFlags. - * - * @param badgeNumber The slotFlags. - * @return Returns get slotFlags result. - */ - virtual ErrCode GetSlotFlagsAsBundle(const sptr &bundleOption, - uint32_t &slotFlags) override; - - /** - * @brief Set slotFlags. - * - * @param badgeNumber The slotFlags. - * @return Returns set slotFlags result. - */ - virtual ErrCode SetSlotFlagsAsBundle(const sptr &bundleOption, - uint32_t slotFlags) override; - - /** - * @brief Obtains allow notification application list. - * - * @param bundleOption Indicates the bundleOption vector. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetAllNotificationEnabledBundles(std::vector &bundleOption) override; - - /** - * @brief Obtains allow liveview application list. - * - * @param bundleOption Indicates the bundle bundleOption. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetAllLiveViewEnabledBundles(std::vector &bundleOption) override; - - /** - * @brief Obtains allow distributed application list. - * - * @param deviceType Indicates device type. - * @param bundleOption Indicates the bundle bundleOption. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetAllDistribuedEnabledBundles(const std::string& deviceType, - std::vector &bundleOption) override; - - /** - * @brief Register Push Callback. - * - * @param pushCallback PushCallBack. - * @param notificationCheckRequest Filter conditions for push check - * @return Returns register PushCallback result. - */ - ErrCode RegisterPushCallback(const sptr& pushCallback, - const sptr& notificationCheckRequest) override; - - /** - * @brief Unregister Push Callback. - * - * @return Returns unregister push Callback result. - */ - ErrCode UnregisterPushCallback() override; - - /** - * @brief Set agent relationship. - * - * @param key Indicates storing agent relationship if the value is "PROXY_PKG". - * @param value Indicates key-value pair of agent relationship. - * @return Returns set result. - */ - virtual ErrCode SetAdditionConfig(const std::string &key, const std::string &value) override; - - /** - * @brief Cancels a published agent notification. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param id Indicates the unique notification ID in the application. - * @return Returns cancel result. - */ - virtual ErrCode CancelAsBundleWithAgent( - const sptr &bundleOption, const int32_t id) override; - - /** - * @brief Sets whether to allow a specified application to publish notifications cross - * device collaboration. The caller must have system permissions to call this method. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given application to publish notifications. The value - * true indicates that notifications are allowed, and the value false indicates that - * notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - ErrCode SetDistributedEnabledByBundle( - const sptr &bundleOption, const std::string &deviceType, const bool enabled) override; - - /** - * @brief get whether to allow a specified application to publish notifications cross - * device collaboration. The caller must have system permissions to call this method. - * - * @param bundleOption Indicates the bundle name and uid of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given application to publish notifications. The value - * true indicates that notifications are allowed, and the value false indicates that - * notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - ErrCode IsDistributedEnabledByBundle( - const sptr &bundleOption, const std::string &deviceType, bool &enabled) override; - - /** - * @brief Get Enable smartphone to collaborate with other devices for intelligent reminders - * - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given application to publish notifications. - * The value true indicates that notifications are allowed, and the value - * false indicates that notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - ErrCode IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) override; - - /** - * @brief Set Enable smartphone to collaborate with other devices for intelligent reminders - * - * @param deviceType Indicates the type of the device running the application. - * @param enabled Specifies whether to allow the given application to publish notifications. - * The value true indicates that notifications are allowed, and the value - * false indicates that notifications are not allowed. - * @return Returns set notifications enabled for specified bundle result. - */ - ErrCode SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) override; - - /** - * @brief Set the channel switch for collaborative reminders. - The caller must have system permissions to call this method. - * - * @param slotType Indicates the slot type of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Indicates slot switch status. - * @return Returns set channel switch result. - */ - ErrCode SetDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled) override; - - /** - * @brief Query the channel switch for collaborative reminders. - The caller must have system permissions to call this method. - * - * @param slotType Indicates the slot type of the application. - * @param deviceType Indicates the type of the device running the application. - * @param enabled Indicates slot switch status. - * @return Returns channel switch result. - */ - ErrCode IsDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) override; - - /** - * @brief Get the status of the target device. - * - * @param deviceType Type of the device whose status you want to set. - * @param status The status. - * @return Returns set result. - */ - ErrCode GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) override; - - /** - * @brief Set the status of the target device. - * - * @param deviceType Type of the device whose status you want to set. - * @param status The status. - * @return Returns set result. - */ - virtual ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const std::string deveiceId = std::string()) override; - - /** - * @brief Set the status of the target device. - * - * @param deviceType Type of the device whose status you want to set. - * @param status The status. - * @param controlFlag The control flag. - * @return Returns set result. - */ - virtual ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const uint32_t controlFlag, const std::string deveiceId = std::string()) override; - - /** - * @brief Get do not disturb profile by id. - * - * @param id Profile id. - * @param status Indicates the NotificationDoNotDisturbProfile object. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetDoNotDisturbProfile(int64_t id, sptr &profile) override; - - /** - * @brief Whether reminders are allowed. - * - * @param bundleName app bundleName - * @param isAllowUseReminder is allow use reminder - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder) override; - -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED - /** - * @brief Register Swing Callback. - * - * @param swingCallback SwingCallBack. - * @return Returns register SwingCallback result. - */ - ErrCode RegisterSwingCallback(const sptr& swingCallback) override; -#endif - - /** - * @brief Update Notification Timer by uid. - * - * @param uid uid. - * @return Returns Update result. - */ - virtual ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) override; - - /** - * @brief Set switch and bundle list of disable notification feature. - * - * @param notificationDisable Switch and bundle list of disable notification feature. - * @return Returns set result. - */ - virtual ErrCode DisableNotificationFeature(const sptr ¬ificationDisable) override; - - /** - * @brief Distribution operation based on hashCode. - * - * @param hashCode Unique ID of the notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback) override; - - /** - * @brief Reply distribute operation. - * - * @param hashCode Unique ID of the notification. - * @param result The result of the distribute operation. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode ReplyDistributeOperation(const std::string& hashCode, const int32_t result) override; - - /** - * @brief Get notificationRequest by hashCode. - * - * @param hashCode Unique ID of the notification. - * @param notificationRequest The request of of the notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetNotificationRequestByHashCode( - const std::string& hashCode, sptr& notificationRequest) override; - - /** - * @brief set rule of generate hashCode. - * - * @param type generate hashCode. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetHashCodeRule(const uint32_t type) override; - -private: - - ErrCode HandlePublish(MessageParcel &data, MessageParcel &reply); - ErrCode HandlePublishNotificationForIndirectProxy(MessageParcel &data, MessageParcel &reply); - ErrCode HandleCancel(MessageParcel &data, MessageParcel &reply); - ErrCode HandleCancelAll(MessageParcel &data, MessageParcel &reply); - ErrCode HandleCancelAsBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleCancelAsBundleOption(MessageParcel &data, MessageParcel &reply); - ErrCode HandleCancelAsBundleAndUser(MessageParcel &data, MessageParcel &reply); - ErrCode HandleAddSlotByType(MessageParcel &data, MessageParcel &reply); - ErrCode HandleAddSlots(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRemoveSlotByType(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRemoveAllSlots(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetSlots(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetSlotByType(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetSlotNumAsBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetActiveNotifications(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetActiveNotificationNums(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetAllActiveNotifications(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetSpecialActiveNotifications(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetActiveNotificationByFilter(MessageParcel &data, MessageParcel &reply); - ErrCode HandleCanPublishAsBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandlePublishAsBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetNotificationBadgeNum(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetBundleImportance(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsNotificationPolicyAccessGranted(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRemoveNotification(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRemoveAllNotifications(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRemoveNotifications(MessageParcel &data, MessageParcel &reply); - ErrCode HandleDelete(MessageParcel &data, MessageParcel &reply); - ErrCode HandleDeleteByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleDeleteAll(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetSlotsByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetSlotByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleUpdateSlots(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRequestEnableNotification(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRequestEnableNotificationByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetNotificationsEnabledForBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetNotificationsEnabledForAllBundles(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetNotificationsEnabledForSpecialBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetShowBadgeEnabled(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSubscribe(MessageParcel &data, MessageParcel &reply); - ErrCode HandleUnsubscribe(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsAllowedNotify(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsAllowedNotifySelf(MessageParcel &data, MessageParcel &reply); - ErrCode HandleCanPopEnableNotificationDialog(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRemoveEnableNotificationDialog(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsSpecialBundleAllowedNotify(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsDistributedEnabled(MessageParcel &data, MessageParcel &reply); - ErrCode HandleEnableDistributed(MessageParcel &data, MessageParcel &reply); - ErrCode HandleEnableDistributedByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleEnableDistributedSelf(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsDistributedEnableByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleShellDump(MessageParcel &data, MessageParcel &reply); - ErrCode HandleCancelGroup(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRemoveGroupByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply); - ErrCode HandleDoesSupportDoNotDisturbMode(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsNeedSilentInDoNotDisturbMode(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetDeviceRemindType(MessageParcel &data, MessageParcel &reply); - ErrCode HandlePublishContinuousTaskNotification(MessageParcel &data, MessageParcel &reply); - ErrCode HandleCancelContinuousTaskNotification(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsSupportTemplate(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsSpecialUserAllowedNotifyByUser(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetNotificationsEnabledByUser(MessageParcel &data, MessageParcel &reply); - ErrCode HandleDeleteAllByUser(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetEnabledForBundleSlotSelf(MessageParcel &data, MessageParcel &reply); - ErrCode HandleDistributedSetEnabledWithoutApp(MessageParcel &data, MessageParcel &reply); - ErrCode HandleDistributedGetEnabledWithoutApp(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetBadgeNumber(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetBadgeNumberByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetBadgeNumberForDhByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRegisterPushCallback(MessageParcel &data, MessageParcel &reply); - ErrCode HandleUnregisterPushCallback(MessageParcel &data, MessageParcel &reply); - ErrCode HandleDistributeOperation(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSubscribeLocalLiveView(MessageParcel &data, MessageParcel &reply); - ErrCode HandleTriggerLocalLiveView(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSubscribeSelf(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetAllNotificationEnableStatus(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetSlotFlagsAsBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetSlotFlagsAsBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetAdditionConfig(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetDistributedEnabledByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsDistributedEnabledByBundle(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetSmartReminderEnabled(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsSmartReminderEnabled(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetDistributedEnabledBySlot(MessageParcel &data, MessageParcel &reply); - ErrCode HandleIsDistributedEnabledBySlot(MessageParcel &data, MessageParcel &reply); - ErrCode HandleCancelAsBundleWithAgent(MessageParcel &data, MessageParcel &reply); - ErrCode HandleAddDoNotDisturbProfiles(MessageParcel &data, MessageParcel &reply); - ErrCode HandleRemoveDoNotDisturbProfiles(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetTargetDeviceStatus(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetDoNotDisturbProfile(MessageParcel &data, MessageParcel &reply); - ErrCode HandleAllowUseReminder(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetDeviceStatus(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetAllLiveViewEnabledBundles(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetAllDistributedEnabledBundles(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetDeviceStatus(MessageParcel &data, MessageParcel &reply); -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED - ErrCode HandleRegisterSwingCallback(MessageParcel &data, MessageParcel &reply); -#endif - ErrCode HandleUpdateNotificationTimerByUid(MessageParcel &data, MessageParcel &reply); - ErrCode HandleDisableNotificationFeature(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetNotificationRequest(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetHashCodeRule(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetAllNotificationsBySlotType(MessageParcel &data, MessageParcel &reply); - ErrCode HandleReplyDistributeOperation(MessageParcel &data, MessageParcel &reply); - - template - bool WriteParcelableVector(const std::vector> &parcelableVector, MessageParcel &reply, ErrCode &result) - { - if (!reply.WriteInt32(result)) { - ANS_LOGE("write result failed, ErrCode=%{public}d", result); - return false; - } - - if (!reply.WriteInt32(parcelableVector.size())) { - ANS_LOGE("write ParcelableVector size failed"); - return false; - } - - for (auto &parcelable : parcelableVector) { - if (!reply.WriteStrongParcelable(parcelable)) { - ANS_LOGE("write ParcelableVector failed"); - return false; - } - } - return true; - } - - template - bool ReadParcelableVector(std::vector> &parcelableInfos, MessageParcel &data) - { - int32_t infoSize = 0; - if (!data.ReadInt32(infoSize)) { - ANS_LOGE("Failed to read Parcelable size."); - return false; - } - - parcelableInfos.clear(); - infoSize = (infoSize < MAX_PARCELABLE_VECTOR_NUM) ? infoSize : MAX_PARCELABLE_VECTOR_NUM; - for (int32_t index = 0; index < infoSize; index++) { - sptr info = data.ReadStrongParcelable(); - if (info == nullptr) { - ANS_LOGE("Failed to read Parcelable infos."); - return false; - } - parcelableInfos.emplace_back(info); - } - - return true; - } -}; -} // namespace Notification -} // namespace OHOS - -#endif // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_STUB_H diff --git a/frameworks/core/include/ans_notification.h b/frameworks/core/include/ans_notification.h index 45d3b30318a7264ba022122416d63e81f63a1275..10d86a05afa49c51994793d2274b6e5b456c0cf0 100644 --- a/frameworks/core/include/ans_notification.h +++ b/frameworks/core/include/ans_notification.h @@ -20,10 +20,10 @@ #include #include "ans_dialog_host_client.h" -#include "ans_manager_interface.h" #include "ans_subscriber_listener.h" -#include "notification_subscriber.h" +#include "ians_manager.h" #include "notification_local_live_view_subscriber.h" +#include "notification_subscriber.h" #include "want_params.h" #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED #include "swing_callback_service.h" @@ -1286,7 +1286,7 @@ private: * * @return Returns true if succeed; returns false otherwise. */ - sptr GetAnsManagerProxy(); + sptr GetAnsManagerProxy(); /** * @brief Checks if the MediaContent can be published. diff --git a/frameworks/core/include/ans_subscriber_listener.h b/frameworks/core/include/ans_subscriber_listener.h index 2ae48915576dc5c1e84a781126eb378fb455f3bd..e54b45a5fcebe5eeea70d827bfa3ed8ff6971971 100644 --- a/frameworks/core/include/ans_subscriber_listener.h +++ b/frameworks/core/include/ans_subscriber_listener.h @@ -16,8 +16,8 @@ #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_CORE_NOTIFICATION_SUBSCRIBER_LISTENER_H #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_CORE_NOTIFICATION_SUBSCRIBER_LISTENER_H -#include "ans_manager_interface.h" #include "ans_subscriber_stub.h" +#include "ians_manager.h" #include "notification_request.h" #include "notification_sorting.h" #include "notification_sorting_map.h" diff --git a/frameworks/core/src/ans_notification.cpp b/frameworks/core/src/ans_notification.cpp index 34f0ecde63eb613f8326577f637e9c5346c7eb81..8de5bc0fe85d77b2b92e32a814f080b8f3b9a7d7 100644 --- a/frameworks/core/src/ans_notification.cpp +++ b/frameworks/core/src/ans_notification.cpp @@ -38,6 +38,7 @@ const int32_t SLEEP_TIME = 1000; const uint32_t MAX_PUBLISH_DELAY_TIME = 5; const std::string DOWNLOAD_TITLE = "title"; const std::string DOWNLOAD_FILENAME = "fileName"; +const static int MAX_SLOT_FLAGS = 0b111111; } ErrCode AnsNotification::AddNotificationSlot(const NotificationSlot &slot) { @@ -48,7 +49,7 @@ ErrCode AnsNotification::AddNotificationSlot(const NotificationSlot &slot) ErrCode AnsNotification::AddSlotByType(const NotificationConstant::SlotType &slotType) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -63,7 +64,7 @@ ErrCode AnsNotification::AddNotificationSlots(const std::vector proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -79,13 +80,19 @@ ErrCode AnsNotification::AddNotificationSlots(const std::vector MAX_SLOT_NUM) { + ANS_LOGE("[AddSlots] fail: slotsSize over max size."); + return ERR_ANS_INVALID_PARAM; + } + return proxy->AddSlots(slotsSptr); } ErrCode AnsNotification::RemoveNotificationSlot(const NotificationConstant::SlotType &slotType) { ANS_LOGI("enter RemoveNotificationSlot, slotType:%{public}d", slotType); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -95,7 +102,7 @@ ErrCode AnsNotification::RemoveNotificationSlot(const NotificationConstant::Slot ErrCode AnsNotification::RemoveAllSlots() { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -106,7 +113,7 @@ ErrCode AnsNotification::RemoveAllSlots() ErrCode AnsNotification::GetNotificationSlot( const NotificationConstant::SlotType &slotType, sptr &slot) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -116,7 +123,7 @@ ErrCode AnsNotification::GetNotificationSlot( ErrCode AnsNotification::GetNotificationSlots(std::vector> &slots) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -131,13 +138,17 @@ ErrCode AnsNotification::GetNotificationSlotNumAsBundle(const NotificationBundle return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Fail to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("[GetSlotNumAsBundle] fail: bundle is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->GetSlotNumAsBundle(bo, num); } @@ -149,13 +160,17 @@ ErrCode AnsNotification::GetNotificationSlotFlagsAsBundle(const NotificationBund return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Fail to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("Fail: bundleOption is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->GetSlotFlagsAsBundle(bo, slotFlags); } @@ -169,14 +184,27 @@ ErrCode AnsNotification::SetNotificationSlotFlagsAsBundle(const NotificationBund ANS_LOGI("SetNotificationSlotFlagsAsBundle,bundleName:%{public}s, %{public}d", bundleOption.GetBundleName().c_str(), (int)slotFlags); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Fail to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); - return proxy->SetSlotFlagsAsBundle(bo, slotFlags); + + if (bo == nullptr) { + ANS_LOGE("[SetSlotFlagsAsBundle] fail: bundleOption is empty."); + return ERR_ANS_INVALID_PARAM; + } + + if (slotFlags > MAX_SLOT_FLAGS) { + ANS_LOGE("[SetSlotFlagsAsBundle] fail: Invalid slotFlags."); + return ERR_ANS_INVALID_PARAM; + } + // got the LSB 6 bits as slotflags; + uint32_t validSlotFlag = MAX_SLOT_FLAGS & slotFlags; + + return proxy->SetSlotFlagsAsBundle(bo, validSlotFlag); } ErrCode AnsNotification::PublishNotification(const NotificationRequest &request, std::string instanceKey) @@ -217,7 +245,7 @@ ErrCode AnsNotification::PublishNotification(const std::string &label, const Not return checkErr; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Failed to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -232,7 +260,9 @@ ErrCode AnsNotification::PublishNotification(const std::string &label, const Not reqPtr->SetDistributed(false); } reqPtr->SetAppInstanceKey(instanceKey); - + if (reqPtr->IsCommonLiveView()) { + return proxy->PublishWithMaxCapacity(label, reqPtr); + } return proxy->Publish(label, reqPtr); } @@ -267,7 +297,7 @@ ErrCode AnsNotification::PublishNotificationForIndirectProxy(const NotificationR return checkErr; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Failed to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -281,7 +311,9 @@ ErrCode AnsNotification::PublishNotificationForIndirectProxy(const NotificationR if (IsNonDistributedNotificationType(reqPtr->GetNotificationType())) { reqPtr->SetDistributed(false); } - + if (reqPtr->IsCommonLiveView()) { + return proxy->PublishNotificationForIndirectProxyWithMaxCapacity(reqPtr); + } return proxy->PublishNotificationForIndirectProxy(reqPtr); } @@ -295,7 +327,7 @@ ErrCode AnsNotification::CancelNotification(const std::string &label, int32_t no { ANS_LOGI("enter CancelNotification,notificationId:%{public}d", notificationId); HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -307,7 +339,7 @@ ErrCode AnsNotification::CancelAllNotifications(std::string instanceKey) { ANS_LOGI("CancelAllNotifications called."); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -319,7 +351,7 @@ ErrCode AnsNotification::CancelAsBundle( int32_t notificationId, const std::string &representativeBundle, int32_t userId) { ANS_LOGI("enter CancelAsBundle,notificationId:%{public}d", notificationId); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -331,7 +363,7 @@ ErrCode AnsNotification::CancelAsBundle( const NotificationBundleOption &bundleOption, int32_t notificationId) { ANS_LOGI("enter CancelAsBundle,notificationId:%{public}d", notificationId); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -342,7 +374,7 @@ ErrCode AnsNotification::CancelAsBundle( ErrCode AnsNotification::GetActiveNotificationNums(uint64_t &num) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -353,7 +385,7 @@ ErrCode AnsNotification::GetActiveNotificationNums(uint64_t &num) ErrCode AnsNotification::GetActiveNotifications(std::vector> &request, std::string instanceKey) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -368,7 +400,7 @@ ErrCode AnsNotification::CanPublishNotificationAsBundle(const std::string &repre return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -408,7 +440,7 @@ ErrCode AnsNotification::PublishNotificationAsBundle( return checkErr; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -422,12 +454,15 @@ ErrCode AnsNotification::PublishNotificationAsBundle( if (IsNonDistributedNotificationType(reqPtr->GetNotificationType())) { reqPtr->SetDistributed(false); } + if (reqPtr->IsCommonLiveView()) { + return proxy->PublishAsBundleWithMaxCapacity(reqPtr, representativeBundle); + } return proxy->PublishAsBundle(reqPtr, representativeBundle); } ErrCode AnsNotification::SetNotificationBadgeNum() { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -438,7 +473,7 @@ ErrCode AnsNotification::SetNotificationBadgeNum() ErrCode AnsNotification::SetNotificationBadgeNum(int32_t num) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -448,7 +483,7 @@ ErrCode AnsNotification::SetNotificationBadgeNum(int32_t num) ErrCode AnsNotification::IsAllowedNotify(bool &allowed) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -459,7 +494,7 @@ ErrCode AnsNotification::IsAllowedNotify(bool &allowed) ErrCode AnsNotification::IsAllowedNotifySelf(bool &allowed) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -471,7 +506,7 @@ ErrCode AnsNotification::CanPopEnableNotificationDialog(sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -482,7 +517,7 @@ ErrCode AnsNotification::CanPopEnableNotificationDialog(sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -495,18 +530,25 @@ ErrCode AnsNotification::RequestEnableNotification(std::string &deviceId, sptr &callerToken) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } + if (hostClient == nullptr) { + ANS_LOGE("[RequestEnableNotification] fail: hostClient is null"); + return ERR_ANS_INVALID_PARAM; + } + if (callerToken == nullptr) { + return proxy->RequestEnableNotification(deviceId, hostClient); + } return proxy->RequestEnableNotification(deviceId, hostClient, callerToken); } ErrCode AnsNotification::RequestEnableNotification(const std::string bundleName, const int32_t uid) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -516,7 +558,7 @@ ErrCode AnsNotification::RequestEnableNotification(const std::string bundleName, ErrCode AnsNotification::HasNotificationPolicyAccessPermission(bool &hasPermission) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -526,7 +568,7 @@ ErrCode AnsNotification::HasNotificationPolicyAccessPermission(bool &hasPermissi ErrCode AnsNotification::GetBundleImportance(NotificationSlot::NotificationLevel &importance) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -544,7 +586,7 @@ ErrCode AnsNotification::GetBundleImportance(NotificationSlot::NotificationLevel ErrCode AnsNotification::SubscribeNotification(const NotificationSubscriber &subscriber) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -555,13 +597,13 @@ ErrCode AnsNotification::SubscribeNotification(const NotificationSubscriber &sub ANS_LOGE("Failed to subscribe with SubscriberImpl null ptr."); return ERR_ANS_INVALID_PARAM; } - return proxy->Subscribe(subscriberSptr, nullptr); + return proxy->Subscribe(subscriberSptr); } ErrCode AnsNotification::SubscribeNotificationSelf(const NotificationSubscriber &subscriber) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -579,7 +621,7 @@ ErrCode AnsNotification::SubscribeLocalLiveViewNotification(const NotificationLo const bool isNative) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -590,14 +632,14 @@ ErrCode AnsNotification::SubscribeLocalLiveViewNotification(const NotificationLo ANS_LOGE("Failed to subscribe with SubscriberImpl null ptr."); return ERR_ANS_INVALID_PARAM; } - return proxy->SubscribeLocalLiveView(subscriberSptr, nullptr, isNative); + return proxy->SubscribeLocalLiveView(subscriberSptr, isNative); } ErrCode AnsNotification::SubscribeNotification( const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Failed to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -621,7 +663,7 @@ ErrCode AnsNotification::SubscribeNotification( ErrCode AnsNotification::UnSubscribeNotification(NotificationSubscriber &subscriber) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -632,14 +674,14 @@ ErrCode AnsNotification::UnSubscribeNotification(NotificationSubscriber &subscri ANS_LOGE("Failed to unsubscribe with SubscriberImpl null ptr."); return ERR_ANS_INVALID_PARAM; } - return proxy->Unsubscribe(subscriberSptr, nullptr); + return proxy->Unsubscribe(subscriberSptr); } ErrCode AnsNotification::UnSubscribeNotification( NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -673,7 +715,7 @@ ErrCode AnsNotification::SubscribeNotificationSelf(const std::shared_ptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -698,7 +740,7 @@ ErrCode AnsNotification::SubscribeNotification(const std::shared_ptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Failed to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -714,6 +756,10 @@ ErrCode AnsNotification::SubscribeNotification(const std::shared_ptrSetDeviceType(subscribeInfo->GetDeviceType()); } DelayedSingleton::GetInstance()->SubscribeSAManager(); + + if (subscribeInfo == nullptr) { + return proxy->Subscribe(listener); + } return proxy->Subscribe(listener, subscribeInfo); } @@ -732,7 +778,7 @@ ErrCode AnsNotification::UnSubscribeNotification(const std::shared_ptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -741,7 +787,12 @@ ErrCode AnsNotification::UnSubscribeNotification(const std::shared_ptr listener = item->second; - int32_t ret = proxy->Unsubscribe(listener, subscribeInfo); + int32_t ret = -1; + if (subscribeInfo == nullptr) { + ret = proxy->Unsubscribe(listener); + } else { + ret = proxy->Unsubscribe(listener, subscribeInfo); + } if (ret == ERR_OK) { subscribers_.erase(item); } @@ -763,7 +814,7 @@ ErrCode AnsNotification::TriggerLocalLiveView(const NotificationBundleOption &bu ANS_LOGI("TriggerLocalLiveView,notificationId:%{public}u,bundleName:%{public}s,button:%{public}s", notificationId, bundleOption.GetBundleName().c_str(), buttonOption.GetButtonName().c_str()); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Fail to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -771,6 +822,10 @@ ErrCode AnsNotification::TriggerLocalLiveView(const NotificationBundleOption &bu sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); sptr button(new (std::nothrow) NotificationButtonOption(buttonOption)); + if (bo == nullptr) { + ANS_LOGE("[TriggerLocalLiveView] fail: bundle is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->TriggerLocalLiveView(bo, notificationId, button); } @@ -784,7 +839,7 @@ ErrCode AnsNotification::RemoveNotification(const std::string &key, int32_t remo return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -803,13 +858,17 @@ ErrCode AnsNotification::RemoveNotification(const NotificationBundleOption &bund return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Fail to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("[RemoveNotification] fail: bundle is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->RemoveNotification(bo, notificationId, label, removeReason); } @@ -821,13 +880,17 @@ ErrCode AnsNotification::RemoveAllNotifications(const NotificationBundleOption & return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy defeat."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("[RemoveAllNotifications] fail: bundle is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->RemoveAllNotifications(bo); } @@ -839,7 +902,7 @@ ErrCode AnsNotification::RemoveNotifications(const std::vector hash return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -856,19 +919,23 @@ ErrCode AnsNotification::RemoveNotificationsByBundle(const NotificationBundleOpt return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Defeated to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("[DeleteByBundle] fail: bundle is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->DeleteByBundle(bo); } ErrCode AnsNotification::RemoveNotifications() { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -884,13 +951,17 @@ ErrCode AnsNotification::GetNotificationSlotsForBundle( return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("[GetSlotsByBundle] fail: bundleOption is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->GetSlotsByBundle(bo, slots); } @@ -903,13 +974,17 @@ ErrCode AnsNotification::GetNotificationSlotForBundle( return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("[GetSlotByBundle] fail: bundleOption is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->GetSlotByBundle(bo, slotType, slot); } @@ -921,19 +996,36 @@ ErrCode AnsNotification::UpdateNotificationSlots( return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy flop."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + + if (bo == nullptr) { + ANS_LOGE("Fail: bundleOption is empty."); + return ERR_ANS_INVALID_PARAM; + } + + if (slots.empty()) { + ANS_LOGE("Fail: slots is empty."); + return ERR_ANS_INVALID_PARAM; + } + + size_t slotSize = slots.size(); + if (slotSize > MAX_SLOT_NUM) { + ANS_LOGE("[UpdateSlots] fail: slotSize over max size."); + return ERR_ANS_INVALID_PARAM; + } + return proxy->UpdateSlots(bo, slots); } ErrCode AnsNotification::GetAllActiveNotifications(std::vector> ¬ification) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -944,11 +1036,15 @@ ErrCode AnsNotification::GetAllActiveNotifications(std::vector key, std::vector> ¬ification) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } + if (key.empty()) { + ANS_LOGE("[GetSpecialActiveNotifications] fail: key is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->GetSpecialActiveNotifications(key, notification); } @@ -964,13 +1060,17 @@ ErrCode AnsNotification::GetActiveNotificationByFilter(const LiveViewFilter &fil filter.bundle.GetBundleName().c_str(), filter.bundle.GetUid(), filter.notificationKey.id, filter.notificationKey.label.c_str()); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(filter.bundle)); + if (bo == nullptr) { + ANS_LOGE("[GetActiveNotificationByFilter] fail: bundle is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->GetActiveNotificationByFilter(bo, filter.notificationKey.id, filter.notificationKey.label, filter.extraInfoKeys, request); } @@ -982,19 +1082,23 @@ ErrCode AnsNotification::IsAllowedNotify(const NotificationBundleOption &bundleO return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("Fail: bundle is nullptr."); + return ERR_ANS_INVALID_PARAM; + } return proxy->IsSpecialBundleAllowedNotify(bo, allowed); } ErrCode AnsNotification::SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1004,7 +1108,7 @@ ErrCode AnsNotification::SetNotificationsEnabledForAllBundles(const std::string ErrCode AnsNotification::SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1021,13 +1125,17 @@ ErrCode AnsNotification::SetNotificationsEnabledForSpecifiedBundle( return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("Fail: bundle is nullptr."); + return ERR_ANS_INVALID_PARAM; + } return proxy->SetNotificationsEnabledForSpecialBundle(deviceId, bo, enabled); } @@ -1038,13 +1146,17 @@ ErrCode AnsNotification::SetShowBadgeEnabledForBundle(const NotificationBundleOp return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("Fail: bundle is nullptr."); + return ERR_ANS_INVALID_PARAM; + } return proxy->SetShowBadgeEnabledForBundle(bo, enabled); } @@ -1055,19 +1167,23 @@ ErrCode AnsNotification::GetShowBadgeEnabledForBundle(const NotificationBundleOp return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("Fail: bundle is nullptr."); + return ERR_ANS_INVALID_PARAM; + } return proxy->GetShowBadgeEnabledForBundle(bo, enabled); } ErrCode AnsNotification::GetShowBadgeEnabled(bool &enabled) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1084,7 +1200,7 @@ ErrCode AnsNotification::CancelGroup(const std::string &groupName, std::string i return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1101,7 +1217,7 @@ ErrCode AnsNotification::RemoveGroupByBundle( return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1113,7 +1229,7 @@ ErrCode AnsNotification::RemoveGroupByBundle( ErrCode AnsNotification::SetDoNotDisturbDate(const NotificationDoNotDisturbDate &doNotDisturbDate) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1126,12 +1242,16 @@ ErrCode AnsNotification::SetDoNotDisturbDate(const NotificationDoNotDisturbDate } sptr dndDate(dndDatePtr); + if (dndDate == nullptr) { + ANS_LOGE("Fail: dndDate is nullptr."); + return ERR_ANS_INVALID_PARAM; + } return proxy->SetDoNotDisturbDate(dndDate); } ErrCode AnsNotification::GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1159,11 +1279,19 @@ ErrCode AnsNotification::AddDoNotDisturbProfiles(const std::vector proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGW("Get ans manager proxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } + if (profiles.empty()) { + ANS_LOGW("The profiles is empty."); + return ERR_ANS_INVALID_PARAM; + } + if (profiles.size() > MAX_STATUS_VECTOR_NUM) { + ANS_LOGE("The profiles is exceeds limit."); + return ERR_ANS_INVALID_PARAM; + } return proxy->AddDoNotDisturbProfiles(profiles); } @@ -1173,17 +1301,21 @@ ErrCode AnsNotification::RemoveDoNotDisturbProfiles(const std::vector proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGW("Get ans manager proxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } + if (profiles.size() > MAX_STATUS_VECTOR_NUM) { + ANS_LOGE("The profiles is exceeds limit."); + return ERR_ANS_INVALID_PARAM; + } return proxy->RemoveDoNotDisturbProfiles(profiles); } ErrCode AnsNotification::DoesSupportDoNotDisturbMode(bool &doesSupport) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1194,7 +1326,7 @@ ErrCode AnsNotification::DoesSupportDoNotDisturbMode(bool &doesSupport) ErrCode AnsNotification::IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1227,7 +1359,7 @@ ErrCode AnsNotification::PublishContinuousTaskNotification(const NotificationReq return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1243,13 +1375,17 @@ ErrCode AnsNotification::PublishContinuousTaskNotification(const NotificationReq if (IsNonDistributedNotificationType(sptrReq->GetNotificationType())) { sptrReq->SetDistributed(false); } + if (sptrReq == nullptr) { + ANS_LOGE("[PublishContinuousTaskNotification] fail: notification request is null ptr."); + return ERR_ANS_INVALID_PARAM; + } return proxy->PublishContinuousTaskNotification(sptrReq); } ErrCode AnsNotification::CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) { ANS_LOGI("enter CancelContinuousTaskNotification,notificationId:%{public}d", notificationId); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1260,7 +1396,7 @@ ErrCode AnsNotification::CancelContinuousTaskNotification(const std::string &lab ErrCode AnsNotification::IsDistributedEnabled(bool &enabled) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1271,7 +1407,7 @@ ErrCode AnsNotification::IsDistributedEnabled(bool &enabled) ErrCode AnsNotification::EnableDistributed(const bool enabled) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1282,19 +1418,23 @@ ErrCode AnsNotification::EnableDistributed(const bool enabled) ErrCode AnsNotification::EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("Fail: bundle is nullptr."); + return ERR_ANS_INVALID_PARAM; + } return proxy->EnableDistributedByBundle(bo, enabled); } ErrCode AnsNotification::EnableDistributedSelf(const bool enabled) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1305,25 +1445,31 @@ ErrCode AnsNotification::EnableDistributedSelf(const bool enabled) ErrCode AnsNotification::IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("Fail: bundle is nullptr."); + return ERR_ANS_INVALID_PARAM; + } return proxy->IsDistributedEnableByBundle(bo, enabled); } ErrCode AnsNotification::GetDeviceRemindType(NotificationConstant::RemindType &remindType) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } - - return proxy->GetDeviceRemindType(remindType); + int32_t remindTypeTemp = -1; + auto ret = proxy->GetDeviceRemindType(remindTypeTemp); + remindType = static_cast(remindTypeTemp); + return ret; } void AnsNotification::ResetAnsManagerProxy() @@ -1334,7 +1480,7 @@ void AnsNotification::Reconnect() ANS_LOGD("enter"); for (int32_t i = 0; i < MAX_RETRY_TIME; i++) { // try to connect ans - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { // Sleep 1000 milliseconds before reconnect. std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME)); @@ -1347,7 +1493,7 @@ void AnsNotification::Reconnect() } } -sptr AnsNotification::GetAnsManagerProxy() +sptr AnsNotification::GetAnsManagerProxy() { sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); @@ -1363,7 +1509,7 @@ sptr AnsNotification::GetAnsManagerProxy() return nullptr; } - sptr proxy = iface_cast(remoteObject); + sptr proxy = iface_cast(remoteObject); if ((!proxy) || (!proxy->AsObject())) { ANS_LOGE("Failed to get notification Manager's proxy"); return nullptr; @@ -1482,7 +1628,7 @@ ErrCode AnsNotification::CheckImageSize(const NotificationRequest &request) ErrCode AnsNotification::IsSupportTemplate(const std::string &templateName, bool &support) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1505,7 +1651,7 @@ ErrCode AnsNotification::IsAllowedNotify(const int32_t &userId, bool &allowed) return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1521,7 +1667,7 @@ ErrCode AnsNotification::SetNotificationsEnabledForAllBundles(const int32_t &use return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1536,7 +1682,7 @@ ErrCode AnsNotification::RemoveNotifications(const int32_t &userId) return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1553,7 +1699,7 @@ ErrCode AnsNotification::SetDoNotDisturbDate(const int32_t &userId, return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1566,6 +1712,10 @@ ErrCode AnsNotification::SetDoNotDisturbDate(const int32_t &userId, } sptr dndDate(dndDatePtr); + if (dndDate == nullptr) { + ANS_LOGE("Fail: dndDate is nullptr."); + return ERR_ANS_INVALID_PARAM; + } return proxy->SetDoNotDisturbDate(dndDate); } @@ -1576,7 +1726,7 @@ ErrCode AnsNotification::GetDoNotDisturbDate(const int32_t &userId, Notification return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1607,13 +1757,17 @@ ErrCode AnsNotification::SetEnabledForBundleSlot(const NotificationBundleOption return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("SetEnabledForBundleSlot fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("Fail: bundleOption is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->SetEnabledForBundleSlot(bo, slotType, enabled, isForceControl); } @@ -1625,19 +1779,23 @@ ErrCode AnsNotification::GetEnabledForBundleSlot( return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetEnabledForBundleSlot fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("[GetEnabledForBundleSlot] fail: bundle is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->GetEnabledForBundleSlot(bo, slotType, enabled); } ErrCode AnsNotification::GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetEnabledForBundleSlotSelf fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1649,7 +1807,7 @@ ErrCode AnsNotification::GetEnabledForBundleSlotSelf(const NotificationConstant: ErrCode AnsNotification::ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, int32_t recvUserId, std::vector &dumpInfo) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1665,7 +1823,7 @@ ErrCode AnsNotification::SetSyncNotificationEnabledWithoutApp(const int32_t user return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1681,7 +1839,7 @@ ErrCode AnsNotification::GetSyncNotificationEnabledWithoutApp(const int32_t user return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1692,7 +1850,7 @@ ErrCode AnsNotification::GetSyncNotificationEnabledWithoutApp(const int32_t user ErrCode AnsNotification::SetBadgeNumber(int32_t badgeNumber, std::string instanceKey) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("SetBadgeNumber fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1707,7 +1865,7 @@ ErrCode AnsNotification::SetBadgeNumberByBundle(const NotificationBundleOption & return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Unable to connect to ANS service."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1729,7 +1887,7 @@ ErrCode AnsNotification::SetBadgeNumberForDhByBundle( return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Unable to connect to ANS service."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1745,7 +1903,7 @@ ErrCode AnsNotification::SetBadgeNumberForDhByBundle( ErrCode AnsNotification::GetAllNotificationEnabledBundles(std::vector &bundleOption) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Fail to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1755,7 +1913,7 @@ ErrCode AnsNotification::GetAllNotificationEnabledBundles(std::vector &bundleOption) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Fail to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1766,7 +1924,7 @@ ErrCode AnsNotification::GetAllLiveViewEnabledBundles(std::vector &bundleOption) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Fail to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1777,7 +1935,7 @@ ErrCode AnsNotification::GetAllDistribuedEnabledBundles(const std::string& devic ErrCode AnsNotification::RegisterPushCallback( const sptr& pushCallback, const sptr ¬ificationCheckRequest) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("RegisterPushCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1788,7 +1946,7 @@ ErrCode AnsNotification::RegisterPushCallback( ErrCode AnsNotification::UnregisterPushCallback() { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("UnregisterPushCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1803,7 +1961,7 @@ ErrCode AnsNotification::SetAdditionConfig(const std::string &key, const std::st ANS_LOGE("Set package config fail: key is empty."); return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Get ans manager proxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1821,13 +1979,17 @@ ErrCode AnsNotification::SetDistributedEnabledByBundle(const NotificationBundleO return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("SetDistributedEnabledByBundleCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("Fail: bundleOption is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->SetDistributedEnabledByBundle(bo, deviceType, enabled); } @@ -1840,20 +2002,24 @@ ErrCode AnsNotification::IsDistributedEnabledByBundle(const NotificationBundleOp return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("IsDistributedEnabledByBundleCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bo(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bo == nullptr) { + ANS_LOGE("Fail: bundleOption is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->IsDistributedEnabledByBundle(bo, deviceType, enabled); } ErrCode AnsNotification::SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("UnregisterPushCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1866,7 +2032,7 @@ ErrCode AnsNotification::SetDistributedEnabledBySlot( const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("UnregisterPushCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1879,7 +2045,7 @@ ErrCode AnsNotification::IsDistributedEnabledBySlot( const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("UnregisterPushCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1892,20 +2058,24 @@ ErrCode AnsNotification::CancelAsBundleWithAgent(const NotificationBundleOption { ANS_LOGI("enter CancelAsBundleWithAgent,bundleName:%{public}s,id:%{public}d", bundleOption.GetBundleName().c_str(), id); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; } sptr bundle(new (std::nothrow) NotificationBundleOption(bundleOption)); + if (bundle == nullptr) { + ANS_LOGE("Bundle is empty."); + return ERR_ANS_INVALID_PARAM; + } return proxy->CancelAsBundleWithAgent(bundle, id); } ErrCode AnsNotification::IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("UnregisterPushCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1918,7 +2088,7 @@ ErrCode AnsNotification::SetTargetDeviceStatus(const std::string &deviceType, co const std::string deveiceId) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("UnregisterPushCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1931,7 +2101,7 @@ ErrCode AnsNotification::SetTargetDeviceStatus(const std::string &deviceType, co const uint32_t controlFlag, const std::string deveiceId) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("UnregisterPushCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1943,7 +2113,7 @@ ErrCode AnsNotification::SetTargetDeviceStatus(const std::string &deviceType, co ErrCode AnsNotification::GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("UnregisterPushCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1977,7 +2147,7 @@ bool AnsNotification::IsValidDelayTime(const NotificationRequest &request) cons ErrCode AnsNotification::GetDoNotDisturbProfile(int64_t id, sptr &profile) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Fail to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -1988,7 +2158,7 @@ ErrCode AnsNotification::GetDoNotDisturbProfile(int64_t id, sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("Fail to GetAnsManagerProxy."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -2026,7 +2196,7 @@ void AnsNotification::OnServiceDied() ErrCode AnsNotification::RegisterSwingCallback(const std::function swingCbFunc) { ANS_LOGD("enter"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("RegisterSwingCallback fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -2042,7 +2212,7 @@ ErrCode AnsNotification::RegisterSwingCallback(const std::function proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("UpdateNotificationTimerByUid fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -2058,7 +2228,7 @@ std::string AnsNotification::GetAppInstanceKey() const ErrCode AnsNotification::DisableNotificationFeature(const NotificationDisable ¬ificationDisable) { ANS_LOGD("enter DisableNotificationFeature"); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("DisableNotificationFeature fail"); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -2080,7 +2250,7 @@ ErrCode AnsNotification::DistributeOperation(sptr& op return ERR_ANS_INVALID_PARAM; } - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -2092,7 +2262,7 @@ ErrCode AnsNotification::ReplyDistributeOperation(const std::string& hashCode, c { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -2106,7 +2276,7 @@ ErrCode AnsNotification::GetNotificationRequestByHashCode( ANS_LOGI("Get notification request by hashCode, hashCode:%{public}s", hashCode.c_str()); HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -2120,7 +2290,7 @@ ErrCode AnsNotification::SetHashCodeRule( ANS_LOGI("SetHashCodeRule type = %{public}d", type); HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -2131,7 +2301,7 @@ ErrCode AnsNotification::SetHashCodeRule( ErrCode AnsNotification::GetAllNotificationsBySlotType(std::vector> ¬ifications, const NotificationConstant::SlotType slotType) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; diff --git a/frameworks/core/src/manager/ans_manager_proxy.cpp b/frameworks/core/src/manager/ans_manager_proxy.cpp deleted file mode 100644 index db53ce5905f6f5cd1a2aa7cdec3639ffc4c18992..0000000000000000000000000000000000000000 --- a/frameworks/core/src/manager/ans_manager_proxy.cpp +++ /dev/null @@ -1,1179 +0,0 @@ -/* - * Copyright (c) 2021-2025 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 "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "ians_subscriber_local_live_view.h" -#include "message_option.h" -#include "message_parcel.h" -#include "notification_bundle_option.h" -#include "parcel.h" -#include "ans_manager_proxy.h" - -namespace OHOS { -namespace Notification { -AnsManagerProxy::AnsManagerProxy(const sptr &impl) : IRemoteProxy(impl) -{} - -AnsManagerProxy::~AnsManagerProxy() -{} - -ErrCode AnsManagerProxy::Publish(const std::string &label, const sptr ¬ification) -{ - if (notification == nullptr) { - ANS_LOGE("[Publish] fail: notification is null ptr."); - return ERR_ANS_INVALID_PARAM; - } - ANS_LOGD("Publish instanceKey: %{public}s", notification->GetAppInstanceKey().c_str()); - MessageParcel data; - if (notification->IsCommonLiveView()) { - if (!data.SetMaxCapacity(NotificationConstant::NOTIFICATION_MAX_LIVE_VIEW_SIZE)) { - return ERR_ANS_PARCELABLE_FAILED; - } - } - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[Publish] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(label)) { - ANS_LOGE("[Publish] fail: write label failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(notification)) { - ANS_LOGE("[Publish] fail: write notification parcelable failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::PUBLISH_NOTIFICATION, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[Publish] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[Publish] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::PublishNotificationForIndirectProxy(const sptr ¬ification) -{ - if (notification == nullptr) { - ANS_LOGE("[PublishNotificationForIndirectProxy] fail: notification is null ptr."); - return ERR_ANS_INVALID_PARAM; - } - ANS_LOGD("PublishNotificationForIndirectProxy instanceKey: %{public}s", notification->GetAppInstanceKey().c_str()); - MessageParcel data; - if (notification->IsCommonLiveView()) { - if (!data.SetMaxCapacity(NotificationConstant::NOTIFICATION_MAX_LIVE_VIEW_SIZE)) { - return ERR_ANS_PARCELABLE_FAILED; - } - } - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[PublishNotificationForIndirectProxy] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(notification)) { - ANS_LOGE("[PublishNotificationForIndirectProxy] fail: write notification parcelable failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::PUBLISH_NOTIFICATION_INDIRECTPROXY, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[PublishNotificationForIndirectProxy] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[PublishNotificationForIndirectProxy] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::Cancel(int32_t notificationId, const std::string &label, const std::string &instanceKey) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[Cancel] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(notificationId)) { - ANS_LOGE("[Cancel] fail: write notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(label)) { - ANS_LOGE("[Cancel] fail: write label failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(instanceKey)) { - ANS_LOGE("[Cancel] fail: write instanceKey failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - ANS_LOGD("Cancel instanceKey: %{public}s", instanceKey.c_str()); - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::CANCEL_NOTIFICATION, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[Cancel] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[Cancel] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::CancelAll(const std::string &instanceKey) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[CancelAll] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(instanceKey)) { - ANS_LOGE("[CancelAll] fail: write instanceKey failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - ANS_LOGD("CancelAll instanceKey: %{public}s", instanceKey.c_str()); - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::CANCEL_ALL_NOTIFICATIONS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[CancelAll] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[CancelAll] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::CancelAsBundle( - int32_t notificationId, const std::string &representativeBundle, int32_t userId) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[CancelAsBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(notificationId)) { - ANS_LOGE("[CancelAsBundle] fail: write notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(representativeBundle)) { - ANS_LOGE("[CancelAsBundle] fail: write representativeBundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(userId)) { - ANS_LOGE("[CancelAsBundle] fail: write userId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::CANCEL_AS_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[CancelAsBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[CancelAsBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::CancelAsBundle( - const sptr &bundleOption, int32_t notificationId) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[CancelAsBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[CancelAsBundle] fail: write BundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(notificationId)) { - ANS_LOGE("[CancelAsBundle] fail: write notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::CANCEL_AS_BUNDLE_OPTION, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[CancelAsBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[CancelAsBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::CancelAsBundle( - const sptr &bundleOption, int32_t notificationId, int32_t userId) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[CancelAsBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[CancelAsBundle] fail: write BundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(notificationId)) { - ANS_LOGE("[CancelAsBundle] fail: write notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!data.WriteInt32(userId)) { - ANS_LOGE("[CancelAsBundle] fail: write notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::CANCEL_AS_BUNDLE_AND_USER, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[CancelAsBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[CancelAsBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetActiveNotifications( - std::vector> ¬ifications, const std::string &instanceKey) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetActiveNotifications] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(instanceKey)) { - ANS_LOGE("[GetActiveNotifications] fail: write instanceKey failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - ANS_LOGD("GetActiveNotifications instanceKey: %{public}s", instanceKey.c_str()); - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATIONS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetActiveNotifications] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!ReadParcelableVector(notifications, reply, result)) { - ANS_LOGE("[GetActiveNotifications] fail: read notifications failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetActiveNotificationNums(uint64_t &num) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetActiveNotificationNums] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_NUMS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetActiveNotificationNums] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetActiveNotificationNums] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadUint64(num)) { - ANS_LOGE("[GetActiveNotificationNums] fail: read notification num failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetAllActiveNotifications(std::vector> ¬ifications) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetAllActiveNotifications] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_ALL_ACTIVE_NOTIFICATIONS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetAllActiveNotifications] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!ReadParcelableVector(notifications, reply, result)) { - ANS_LOGE("[GetAllActiveNotifications] fail: read notifications failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetSpecialActiveNotifications( - const std::vector &key, std::vector> ¬ifications) -{ - if (key.empty()) { - ANS_LOGE("[GetSpecialActiveNotifications] fail: key is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetSpecialActiveNotifications] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStringVector(key)) { - ANS_LOGE("[GetSpecialActiveNotifications] fail:: write key failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SPECIAL_ACTIVE_NOTIFICATIONS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetSpecialActiveNotifications] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!ReadParcelableVector(notifications, reply, result)) { - ANS_LOGE("[GetSpecialActiveNotifications] fail: read notifications failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetActiveNotificationByFilter( - const sptr &bundleOption, const int32_t notificationId, const std::string &label, - const std::vector extraInfoKeys, sptr &request) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[GetActiveNotificationByFilter] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetActiveNotificationByFilter] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[GetActiveNotificationByFilter] fail: write bundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(notificationId)) { - ANS_LOGE("[GetActiveNotificationByFilter] fail: write notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(label)) { - ANS_LOGE("[GetActiveNotificationByFilter] fail: write label failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStringVector(extraInfoKeys)) { - ANS_LOGE("[GetActiveNotificationByFilter] fail:: write extraInfoKeys failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - if (!reply.SetMaxCapacity(NotificationConstant::NOTIFICATION_MAX_LIVE_VIEW_SIZE)) { - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_BY_FILTER, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetActiveNotificationByFilter] fail: transact ErrCode=%{public}d", result); - return result; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetActiveNotificationByFilter] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - request = reply.ReadParcelable(); - if (request == nullptr) { - ANS_LOGE("[GetActiveNotificationByFilter] fail: read request is nullptr."); - } - - return result; -} - -ErrCode AnsManagerProxy::GetAllNotificationsBySlotType(std::vector> ¬ifications, - const NotificationConstant::SlotType slotType) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetAllNotificationsBySlotType] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotType)) { - ANS_LOGE("[GetAllNotificationsBySlotType] fail: write slotType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_ALL_NOTIFICATIONS_BY_SLOTTYPE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetAllNotificationsBySlotType] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!ReadParcelableVector(notifications, reply, result)) { - ANS_LOGE("[GetAllNotificationsBySlotType] fail: read notifications failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) -{ - if (representativeBundle.empty()) { - ANS_LOGE("[CanPublishAsBundle] fail: representativeBundle is null."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[CanPublishAsBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(representativeBundle)) { - ANS_LOGE("[CanPublishAsBundle] fail: write representativeBundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::CAN_PUBLISH_AS_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[CanPublishAsBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[CanPublishAsBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(canPublish)) { - ANS_LOGE("[CanPublishAsBundle] fail: read canPublish failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::PublishAsBundle( - const sptr notification, const std::string &representativeBundle) -{ - if (notification == nullptr) { - ANS_LOGE("[PublishAsBundle] fail: notification is null ptr."); - return ERR_ANS_INVALID_PARAM; - } - - if (representativeBundle.empty()) { - ANS_LOGE("[PublishAsBundle] fail: representativeBundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (notification->IsCommonLiveView()) { - if (!data.SetMaxCapacity(NotificationConstant::NOTIFICATION_MAX_LIVE_VIEW_SIZE)) { - return ERR_ANS_PARCELABLE_FAILED; - } - } - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[PublishAsBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(notification)) { - ANS_LOGE("[PublishAsBundle] fail: write notification failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(representativeBundle)) { - ANS_LOGE("[PublishAsBundle] fail: write representativeBundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::PUBLISH_AS_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[PublishAsBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[PublishAsBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::TriggerLocalLiveView(const sptr &bundleOption, - const int32_t notificationId, const sptr &buttonOption) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[TriggerLocalLiveView] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[TriggerLocalLiveView] fail:, write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStrongParcelable(bundleOption)) { - ANS_LOGE("[TriggerLocalLiveView] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(notificationId)) { - ANS_LOGE("[TriggerLocalLiveView] fail: write notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStrongParcelable(buttonOption)) { - ANS_LOGE("[TriggerLocalLiveView] fail: write label failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_NOTIFICATION, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[TriggerLocalLiveView] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[TriggerLocalLiveView] fail: read result error."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::Delete(const std::string &key, int32_t removeReason) -{ - if (key.empty()) { - ANS_LOGE("[Delete] fail: key is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[Delete] fail:, write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(key)) { - ANS_LOGE("[Delete] fail:: write key failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(removeReason)) { - ANS_LOGE("[Delete] fail: write removeReason failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::DELETE_NOTIFICATION, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[Delete] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[Delete] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::DeleteByBundle(const sptr &bundleOption) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[DeleteByBundle] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[DeleteByBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStrongParcelable(bundleOption)) { - ANS_LOGE("[DeleteByBundle] fail: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::DELETE_NOTIFICATION_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[DeleteByBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[DeleteByBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::DeleteAll() -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[DeleteAll] fail:, write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[DeleteAll] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[DeleteAll] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::CancelGroup(const std::string &groupName, const std::string &instanceKey) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[CancelGroup] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(groupName)) { - ANS_LOGE("[CancelGroup] fail: write groupName failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(instanceKey)) { - ANS_LOGE("[CancelGroup] fail: write instanceKey failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - ANS_LOGD("CancelGroup instanceKey: %{public}s", instanceKey.c_str()); - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::CANCEL_GROUP, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[CancelGroup] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[CancelGroup] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::RemoveGroupByBundle( - const sptr &bundleOption, const std::string &groupName) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[RemoveGroupByBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[RemoveGroupByBundle] fail:: write bundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(groupName)) { - ANS_LOGE("[RemoveGroupByBundle] fail: write groupName failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::REMOVE_GROUP_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[RemoveGroupByBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[RemoveGroupByBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::PublishContinuousTaskNotification(const sptr &request) -{ - if (request == nullptr) { - ANS_LOGE("[PublishContinuousTaskNotification] fail: notification request is null ptr."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[PublishContinuousTaskNotification] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(request)) { - ANS_LOGE("[PublishContinuousTaskNotification] fail: write request failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::PUBLISH_CONTINUOUS_TASK_NOTIFICATION, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[PublishContinuousTaskNotification] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[PublishContinuousTaskNotification] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[CancelContinuousTaskNotification] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(label)) { - ANS_LOGE("[CancelContinuousTaskNotification] fail: write label failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(notificationId)) { - ANS_LOGE("[CancelContinuousTaskNotification] fail: write notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::CANCEL_CONTINUOUS_TASK_NOTIFICATION, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[CancelContinuousTaskNotification] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[CancelContinuousTaskNotification] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::IsSupportTemplate(const std::string &templateName, bool &support) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsSupportTemplate] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(templateName)) { - ANS_LOGE("[IsSupportTemplate] fail: write template name failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::IS_SUPPORT_TEMPLATE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsSupportTemplate] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsSupportTemplate] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(support)) { - ANS_LOGE("[IsSupportTemplate] fail: read support failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::DeleteAllByUser(const int32_t &userId) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[DeleteAllByUser] fail:, write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(userId)) { - ANS_LOGE("[DeleteAllByUser] fail: write userId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[DeleteAllByUser] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[DeleteAllByUser] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::CancelAsBundleWithAgent(const sptr &bundleOption, const int32_t id) -{ - if (bundleOption == nullptr) { - ANS_LOGE("Bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStrongParcelable(bundleOption)) { - ANS_LOGE("Write bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(id)) { - ANS_LOGE("Write notification id failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::CANCEL_AS_BUNDLE_WITH_AGENT, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Transact fail: ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("Read result error."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(uid)) { - ANS_LOGE("write uid failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(isPaused)) { - ANS_LOGE("write isPaused failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::UPDATE_NOTIFICATION_TIMER, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::DisableNotificationFeature(const sptr ¬ificationDisable) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(notificationDisable)) { - ANS_LOGE("write notificationDisable failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::DISABLE_NOTIFICATION_FEATURE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::DistributeOperation(sptr& operationInfo, - const sptr &callback) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteRemoteObject(callback->AsObject().GetRefPtr())) { - ANS_LOGE("write parcel failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(operationInfo)) { - ANS_LOGE("[Subscribe] fail: write operationInfo failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::DISTRIBUTE_OPERATION, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::ReplyDistributeOperation(const std::string& hashCode, const int32_t result) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(hashCode)) { - ANS_LOGE("write hashCode failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(result)) { - ANS_LOGE("write result failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode ret = - InnerTransact(NotificationInterfaceCode::REPLY_DISTRIBUTE_OPERATION, option, data, reply); - if (ret != ERR_OK) { - ANS_LOGE("transact ErrCode=%{public}d", ret); - return ret; - } - - if (!reply.ReadInt32(ret)) { - ANS_LOGE("read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ret; -} - -ErrCode AnsManagerProxy::GetNotificationRequestByHashCode( - const std::string& hashCode, sptr& notificationRequest) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(hashCode)) { - ANS_LOGE("write hashCode failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = - InnerTransact(NotificationInterfaceCode::GET_NOTIFICATION_REQUEST_BY_HASHCODE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("transact ErrCode=%{public}d", result); - return result; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - notificationRequest = reply.ReadParcelable(); - if (notificationRequest == nullptr) { - ANS_LOGE("read request is nullptr."); - } - return result; -} - -ErrCode AnsManagerProxy::SetHashCodeRule(const uint32_t type) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(type)) { - ANS_LOGE("write type failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = - InnerTransact(NotificationInterfaceCode::Set_HASH_CODE_RULE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("transact ErrCode=%{public}d", result); - return result; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} -} // namespace Notification -} // namespace OHOS diff --git a/frameworks/core/src/manager/ans_manager_proxy_bundle.cpp b/frameworks/core/src/manager/ans_manager_proxy_bundle.cpp deleted file mode 100644 index afcd5eb657362aff8ba2e72867fd44c2a1450dbe..0000000000000000000000000000000000000000 --- a/frameworks/core/src/manager/ans_manager_proxy_bundle.cpp +++ /dev/null @@ -1,963 +0,0 @@ -/* - * Copyright (c) 2024-2025 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 "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "ians_subscriber_local_live_view.h" -#include "message_option.h" -#include "message_parcel.h" -#include "parcel.h" -#include "ans_manager_proxy.h" - -namespace OHOS { -namespace Notification { -ErrCode AnsManagerProxy::SetNotificationBadgeNum(int32_t num) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetNotificationBadgeNum] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(num)) { - ANS_LOGE("[SetNotificationBadgeNum] fail: write num failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_NOTIFICATION_BADGE_NUM, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetNotificationBadgeNum] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetNotificationBadgeNum] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetBundleImportance(int32_t &importance) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetBundleImportance] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_BUNDLE_IMPORTANCE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetBundleImportance] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetBundleImportance] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadInt32(importance)) { - ANS_LOGE("[GetBundleImportance] fail: read importance failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::HasNotificationPolicyAccessPermission(bool &granted) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[HasNotificationPolicyAccessPermission] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::IS_NOTIFICATION_POLICY_ACCESS_GRANTED, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[HasNotificationPolicyAccessPermission] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[HasNotificationPolicyAccessPermission] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(granted)) { - ANS_LOGE("[HasNotificationPolicyAccessPermission] fail: read granted failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::RequestEnableNotification(const std::string &deviceId, - const sptr &callback, - const sptr &callerToken) -{ - ANS_LOGD("enter"); - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[RequestEnableNotification] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceId)) { - ANS_LOGE("[RequestEnableNotification] fail: write deviceId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (callback == nullptr || !data.WriteRemoteObject(callback->AsObject())) { - ANS_LOGE("[RequestEnableNotification] fail: write callback failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(callerToken != nullptr)) { - ANS_LOGE("fail: write callerToken failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - if (callerToken != nullptr) { - if (!data.WriteRemoteObject(callerToken)) { - ANS_LOGE("fail: write callerToken failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[RequestEnableNotification] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[RequestEnableNotification] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerProxy::RequestEnableNotification(const std::string bundleName, const int32_t uid) -{ - ANS_LOGD("enter"); - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[RequestEnableNotification] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(bundleName)) { - ANS_LOGE("[RequestEnableNotification] fail: write bundleName failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(uid)) { - ANS_LOGE("[RequestEnableNotification] fail: write uid failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION_BY_BUNDLE, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[RequestEnableNotification] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[RequestEnableNotification] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerProxy::SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetNotificationsEnabledForBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceId)) { - ANS_LOGE("[SetNotificationsEnabledForBundle] fail: write deviceId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[SetNotificationsEnabledForBundle] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetNotificationsEnabledForBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetNotificationsEnabledForBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetNotificationsEnabledForAllBundles] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceId)) { - ANS_LOGE("[SetNotificationsEnabledForAllBundles] fail: write deviceId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[SetNotificationsEnabledForAllBundles] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetNotificationsEnabledForAllBundles] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetNotificationsEnabledForAllBundles] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetNotificationsEnabledForSpecialBundle( - const std::string &deviceId, const sptr &bundleOption, bool enabled) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: bundleOption is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceId)) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: write deviceId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: write bundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[SetShowBadgeEnabledForBundle] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetShowBadgeEnabledForBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[SetShowBadgeEnabledForBundle] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[SetShowBadgeEnabledForBundle] fail:: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetShowBadgeEnabledForBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetShowBadgeEnabledForBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[GetShowBadgeEnabledForBundle] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetShowBadgeEnabledForBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[GetShowBadgeEnabledForBundle] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED_FOR_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetShowBadgeEnabledForBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetShowBadgeEnabledForBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(enabled)) { - ANS_LOGE("[GetShowBadgeEnabledForBundle] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetShowBadgeEnabled(bool &enabled) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetShowBadgeEnabled] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetShowBadgeEnabled] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetShowBadgeEnabled] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(enabled)) { - ANS_LOGE("[GetShowBadgeEnabled] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::IsAllowedNotify(bool &allowed) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsAllowedNotify] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::IS_ALLOWED_NOTIFY, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsAllowedNotify] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsAllowedNotify] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(allowed)) { - ANS_LOGE("[IsAllowedNotify] fail: read allowed failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::IsAllowedNotifySelf(bool &allowed) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsAllowedNotifySelf] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::IS_ALLOWED_NOTIFY_SELF, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsAllowedNotifySelf] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsAllowedNotifySelf] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(allowed)) { - ANS_LOGE("[IsAllowedNotifySelf] fail: read allowed failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::CanPopEnableNotificationDialog(const sptr &callback, - bool &canPop, std::string &bundleName) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[CanPopEnableNotificationDialog] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (callback == nullptr || !data.WriteRemoteObject(callback->AsObject())) { - ANS_LOGE("[CanPopEnableNotificationDialog] fail: write callback failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::CAN_POP_ENABLE_NOTIFICATION_DIALOG, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[CanPopEnableNotificationDialog] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[CanPopEnableNotificationDialog] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(canPop)) { - ANS_LOGE("[CanPopEnableNotificationDialog] fail: read canPop failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!reply.ReadString(bundleName)) { - ANS_LOGE("[CanPopEnableNotificationDialog] fail: read bundleName failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::RemoveEnableNotificationDialog() -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[CanPopEnableNotificationDialog] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::REMOVE_ENABLE_NOTIFICATION_DIALOG, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[RemoveEnableNotificationDialog] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - if (!reply.ReadInt32(result)) { - ANS_LOGE("[CanPopEnableNotificationDialog] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerProxy::IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::IS_SPECIAL_BUNDLE_ALLOWED_NOTIFY, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(allowed)) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: read allowed error."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsSpecialUserAllowedNotify] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(userId)) { - ANS_LOGE("[IsSpecialUserAllowedNotify] fail: write userId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::IS_SPECIAL_USER_ALLOWED_NOTIFY, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(allowed)) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: read allowed failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetNotificationsEnabledByUser(const int32_t &userId, bool enabled) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetNotificationsEnabledByUser] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(userId)) { - ANS_LOGE("[SetNotificationsEnabledByUser] fail: write userId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[SetNotificationsEnabledByUser] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetNotificationsEnabledByUser] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetNotificationsEnabledByUser] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetSyncNotificationEnabledWithoutApp] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(userId)) { - ANS_LOGE("[SetSyncNotificationEnabledWithoutApp] fail:: write userId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[SetSyncNotificationEnabledWithoutApp] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetSyncNotificationEnabledWithoutApp] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetSyncNotificationEnabledWithoutApp] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetSyncNotificationEnabledWithoutApp] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(userId)) { - ANS_LOGE("[GetSyncNotificationEnabledWithoutApp] fail:: write userId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetSyncNotificationEnabledWithoutApp] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetSyncNotificationEnabledWithoutApp] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(enabled)) { - ANS_LOGE("[GetSyncNotificationEnabledWithoutApp] fail: read enable failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetBadgeNumber] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(badgeNumber)) { - ANS_LOGE("[SetBadgeNumber] fail:: write badgeNumber failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(instanceKey)) { - ANS_LOGE("[SetBadgeNumber] fail:: write instancekey failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_BADGE_NUMBER, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetBadgeNumber] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetBadgeNumber] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetBadgeNumberByBundle(const sptr &bundleOption, int32_t badgeNumber) -{ - if (bundleOption == nullptr) { - ANS_LOGE("Bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("Write bundle option failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!data.WriteInt32(badgeNumber)) { - ANS_LOGE("Write badge number failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_BADGE_NUMBER_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Transact error code is: %{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - if (!reply.ReadInt32(result)) { - ANS_LOGE("Read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerProxy::SetBadgeNumberForDhByBundle( - const sptr &bundleOption, int32_t badgeNumber) -{ - if (bundleOption == nullptr) { - ANS_LOGE("Bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("Write bundle option failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!data.WriteInt32(badgeNumber)) { - ANS_LOGE("Write badge number failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_BADGE_NUMBER_FOR_DH_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Transact error code is: %{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - if (!reply.ReadInt32(result)) { - ANS_LOGE("Read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerProxy::GetAllNotificationEnabledBundles(std::vector &bundleOption) -{ - ANS_LOGD("Called."); - MessageParcel data; - int32_t vectorSize = 0; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_ALL_NOTIFICATION_ENABLE_STATUS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("Fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadInt32(vectorSize)) { - ANS_LOGE("Fail: read vectorSize failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (vectorSize > MAX_STATUS_VECTOR_NUM) { - ANS_LOGE("Bundle status vector is over size"); - return ERR_ANS_PARCELABLE_FAILED; - } - - for (auto i = 0; i < vectorSize; i++) { - sptr obj = reply.ReadParcelable(); - if (obj == nullptr) { - ANS_LOGE("The obj of Bundle status vector is nullptr."); - return ERR_ANS_PARCELABLE_FAILED; - } - bundleOption.emplace_back(*obj); - } - - return result; -} - -ErrCode AnsManagerProxy::GetAllLiveViewEnabledBundles(std::vector &bundleOption) -{ - ANS_LOGD("Called."); - MessageParcel data; - int32_t vectorSize = 0; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_ALL_LIVEVIEW_ENABLE_STATUS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("Fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadInt32(vectorSize)) { - ANS_LOGE("Fail: read vectorSize failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (vectorSize > MAX_STATUS_VECTOR_NUM) { - ANS_LOGE("Bundle status vector is over size"); - return ERR_ANS_PARCELABLE_FAILED; - } - - for (auto i = 0; i < vectorSize; i++) { - sptr obj = reply.ReadParcelable(); - if (obj == nullptr) { - ANS_LOGE("The obj of Bundle status vector is nullptr."); - return ERR_ANS_PARCELABLE_FAILED; - } - bundleOption.emplace_back(*obj); - } - - return result; -} - -ErrCode AnsManagerProxy::GetAllDistribuedEnabledBundles(const std::string& deviceType, - std::vector &bundleOption) -{ - ANS_LOGD("Called."); - MessageParcel data; - int32_t vectorSize = 0; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceType)) { - ANS_LOGE("[GetAllDistribuedEnabledBundles] fail: write deviceType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_ALL_DISTRIBUTED_ENABLE_STATUS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("Fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadInt32(vectorSize)) { - ANS_LOGE("Fail: read vectorSize failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (vectorSize > MAX_STATUS_VECTOR_NUM) { - ANS_LOGE("Bundle status vector is over size"); - return ERR_ANS_PARCELABLE_FAILED; - } - - for (auto i = 0; i < vectorSize; i++) { - sptr obj = reply.ReadParcelable(); - if (obj == nullptr) { - ANS_LOGE("The obj of Bundle status vector is nullptr."); - return ERR_ANS_PARCELABLE_FAILED; - } - bundleOption.emplace_back(*obj); - } - - return result; -} -} // namespace Notification -} // namespace OHOS diff --git a/frameworks/core/src/manager/ans_manager_proxy_distributed.cpp b/frameworks/core/src/manager/ans_manager_proxy_distributed.cpp deleted file mode 100644 index 181038b5e257c6ac3c4b000cbe101f66fea4fe46..0000000000000000000000000000000000000000 --- a/frameworks/core/src/manager/ans_manager_proxy_distributed.cpp +++ /dev/null @@ -1,403 +0,0 @@ -/* - * Copyright (c) 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 "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "message_option.h" -#include "message_parcel.h" -#include "parcel.h" -#include "ans_manager_proxy.h" - -namespace OHOS { -namespace Notification { -ErrCode AnsManagerProxy::IsDistributedEnabled(bool &enabled) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsDistributedEnabled] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsDistributedEnabled] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsDistributedEnabled] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(enabled)) { - ANS_LOGE("[IsDistributedEnabled] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::EnableDistributed(bool enabled) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[EnableDistributed] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[EnableDistributed] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::ENABLE_DISTRIBUTED, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[EnableDistributed] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[EnableDistributed] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::EnableDistributedByBundle(const sptr &bundleOption, bool enabled) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[EnableDistributedByBundle] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[EnableDistributedByBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[EnableDistributedByBundle] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[EnableDistributedByBundle] fail:: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::ENABLE_DISTRIBUTED_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[EnableDistributedByBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[EnableDistributedByBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::EnableDistributedSelf(bool enabled) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[EnableDistributedSelf] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[EnableDistributedSelf] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::ENABLE_DISTRIBUTED_SELF, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[EnableDistributedSelf] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[EnableDistributedSelf] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[IsDistributedEnableByBundle] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsDistributedEnableByBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[IsDistributedEnableByBundle] fail: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsDistributedEnableByBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsDistributedEnableByBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(enabled)) { - ANS_LOGE("[IsDistributedEnableByBundle] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetDeviceRemindType(NotificationConstant::RemindType &remindType) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetDeviceRemindType] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_DEVICE_REMIND_TYPE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetDeviceRemindType] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetDeviceRemindType] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (result == ERR_OK) { - int32_t rType {-1}; - if (!reply.ReadInt32(rType)) { - ANS_LOGE("[GetDeviceRemindType] fail: read remind type failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - remindType = static_cast(rType); - } - - return result; -} - -ErrCode AnsManagerProxy::SetDistributedEnabledByBundle(const sptr &bundleOption, - const std::string &deviceType, const bool enabled) -{ - ANS_LOGD("enter"); - if (bundleOption == nullptr) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: bundleOption is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: write bundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceType)) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: write deviceType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_DISTRIBUTED_ENABLED_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetNotificationsEnabledForSpecialBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::IsDistributedEnabledByBundle(const sptr &bundleOption, - const std::string &deviceType, bool &enabled) -{ - ANS_LOGD("enter"); - if (bundleOption == nullptr) { - ANS_LOGE("[IsDistributedEnabledByBundle] fail: bundleOption is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsDistributedEnabledByBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[IsDistributedEnabledByBundle] fail: write bundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceType)) { - ANS_LOGE("[IsDistributedEnabledByBundle] fail: write deviceType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_DISTRIBUTED_ENABLED_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsDistributedEnabledByBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsDistributedEnabledByBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(enabled)) { - ANS_LOGE("[IsDistributedEnabledByBundle] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} -ErrCode AnsManagerProxy::SetDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled) -{ - ANS_LOGD("enter"); - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetDistributedEnabledBySlot] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotType)) { - ANS_LOGE("[SetDistributedEnabledBySlot] fail: write slotType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceType)) { - ANS_LOGE("[SetDistributedEnabledBySlot] fail: write deviceType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[SetDistributedEnabledBySlot] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_DISTRIBUTED_ENABLED_BY_SLOT, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetDistributedEnabledBySlot] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetDistributedEnabledBySlot] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::IsDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) -{ - ANS_LOGD("enter"); - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsDistributedEnabledBySlot] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotType)) { - ANS_LOGE("[IsDistributedEnabledBySlot] fail: write slotType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceType)) { - ANS_LOGE("[IsDistributedEnabledBySlot] fail: write deviceType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_DISTRIBUTED_ENABLED_BY_SLOT, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsDistributedEnabledBySlot] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsDistributedEnabledBySlot] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(enabled)) { - ANS_LOGE("[IsDistributedEnabledBySlot] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} -} // namespace Notification -} // namespace OHOS diff --git a/frameworks/core/src/manager/ans_manager_proxy_disturb.cpp b/frameworks/core/src/manager/ans_manager_proxy_disturb.cpp deleted file mode 100644 index 94639ac9690a2ff8950aa0a5679c6a9ee6e10ec8..0000000000000000000000000000000000000000 --- a/frameworks/core/src/manager/ans_manager_proxy_disturb.cpp +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (c) 2021-2025 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 "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "ians_subscriber_local_live_view.h" -#include "message_option.h" -#include "message_parcel.h" -#include "parcel.h" -#include "ans_manager_proxy.h" - -namespace OHOS { -namespace Notification { -ErrCode AnsManagerProxy::SetDoNotDisturbDate(const sptr &date) -{ - if (date == nullptr) { - ANS_LOGE("[SetDoNotDisturbDate] fail: date is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetDoNotDisturbDate] fail: write interface token error."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(date)) { - ANS_LOGE("[SetDoNotDisturbDate] fail: write date failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetDoNotDisturbDate] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetDoNotDisturbDate] fail: read result error."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetDoNotDisturbDate(sptr &date) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetDoNotDisturbDate] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetDoNotDisturbDate] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetDoNotDisturbDate] fail: read result error."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (result == ERR_OK) { - date = reply.ReadParcelable(); - if (date == nullptr) { - ANS_LOGE("[GetDoNotDisturbDate] fail: read date error."); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - return result; -} - -ErrCode AnsManagerProxy::AddDoNotDisturbProfiles(const std::vector> &profiles) -{ - if (profiles.empty()) { - ANS_LOGW("The profiles is empty."); - return ERR_ANS_INVALID_PARAM; - } - if (profiles.size() > MAX_STATUS_VECTOR_NUM) { - ANS_LOGE("The profiles is exceeds limit."); - return ERR_ANS_INVALID_PARAM; - } - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Write interface token error."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!WriteParcelableVector(profiles, data)) { - ANS_LOGE("Write profiles vector error."); - return ERR_ANS_PARCELABLE_FAILED; - } - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::ADD_DO_NOTDISTURB_PROFILES, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Transact ErrCode is %{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("Read result error."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerProxy::RemoveDoNotDisturbProfiles(const std::vector> &profiles) -{ - if (profiles.empty()) { - ANS_LOGW("The profiles is empty."); - return ERR_ANS_INVALID_PARAM; - } - if (profiles.size() > MAX_STATUS_VECTOR_NUM) { - ANS_LOGE("The profiles is exceeds limit."); - return ERR_ANS_INVALID_PARAM; - } - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Write interface token error."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!WriteParcelableVector(profiles, data)) { - ANS_LOGE("Write profiles vector error."); - return ERR_ANS_PARCELABLE_FAILED; - } - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::REMOVE_DO_NOT_DISTURB_PROFILES, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Transact ErrCode is %{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - if (!reply.ReadInt32(result)) { - ANS_LOGE("Read result error."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerProxy::DoesSupportDoNotDisturbMode(bool &doesSupport) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[DoesSupportDoNotDisturbMode] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::DOES_SUPPORT_DO_NOT_DISTURB_MODE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[DoesSupportDoNotDisturbMode] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[DoesSupportDoNotDisturbMode] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(doesSupport)) { - ANS_LOGE("[DoesSupportDoNotDisturbMode] fail: read doesSupport failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetDoNotDisturbDate(const int32_t &userId, const sptr &date) -{ - if (date == nullptr) { - ANS_LOGE("[SetDoNotDisturbDate] fail: date is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetDoNotDisturbDate] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(userId)) { - ANS_LOGE("[SetDoNotDisturbDate] fail: write userId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(date)) { - ANS_LOGE("[SetDoNotDisturbDate] fail: write date failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE_BY_USER, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetDoNotDisturbDate] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetDoNotDisturbDate] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetDoNotDisturbDate(const int32_t &userId, sptr &date) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetDoNotDisturbDate] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(userId)) { - ANS_LOGE("[GetDoNotDisturbDate] fail: write userId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE_BY_USER, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetDoNotDisturbDate] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetDoNotDisturbDate] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (result == ERR_OK) { - date = reply.ReadParcelable(); - if (date == nullptr) { - ANS_LOGE("[GetDoNotDisturbDate] fail: read date failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - return result; -} - -ErrCode AnsManagerProxy::IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsNeedSilentInDoNotDisturbMode] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(phoneNumber)) { - ANS_LOGE("[IsNeedSilentInDoNotDisturbMode] fail: write phoneNumber failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(callerType)) { - ANS_LOGE("[IsNeedSilentInDoNotDisturbMode] fail: write callerType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::IS_NEED_SILENT_IN_DO_NOT_DISTURB_MODE, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsNeedSilentInDoNotDisturbMode] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsNeedSilentInDoNotDisturbMode] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetDoNotDisturbProfile(int64_t id, sptr &profile) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("GetDoNotDisturbProfile write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt64(id)) { - ANS_LOGE("GetDoNotDisturbProfile write id failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_DONOTDISTURB_PROFILE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("GetDoNotDisturbProfile transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("GetDoNotDisturbProfile read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (result != ERR_OK) { - ANS_LOGE("GetDoNotDisturbProfile result failed %{public}d.", result); - return result; - } - - profile = reply.ReadParcelable(); - if (profile == nullptr) { - ANS_LOGE("GetDoNotDisturbProfile read data failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} -} // namespace Notification -} // namespace OHOS diff --git a/frameworks/core/src/manager/ans_manager_proxy_slot.cpp b/frameworks/core/src/manager/ans_manager_proxy_slot.cpp deleted file mode 100644 index d122cfcea5ae341c4ce99169cf941c79092bfdc3..0000000000000000000000000000000000000000 --- a/frameworks/core/src/manager/ans_manager_proxy_slot.cpp +++ /dev/null @@ -1,605 +0,0 @@ -/* - * Copyright (c) 2021-2025 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 "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "ians_subscriber_local_live_view.h" -#include "message_option.h" -#include "message_parcel.h" -#include "parcel.h" -#include "ans_manager_proxy.h" - -namespace OHOS { -namespace Notification { -const static int MAX_SLOT_FLAGS = 0b111111; -ErrCode AnsManagerProxy::AddSlotByType(NotificationConstant::SlotType slotType) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[AddSlotByType] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotType)) { - ANS_LOGE("[AddSlotByType] fail:: write slotIds failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::ADD_SLOT_BY_TYPE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[AddSlotByType] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[AddSlotByType] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::AddSlots(const std::vector> &slots) -{ - if (slots.empty()) { - ANS_LOGE("[AddSlots] fail: slots is empty."); - return ERR_ANS_INVALID_PARAM; - } - - size_t slotsSize = slots.size(); - if (slotsSize > MAX_SLOT_NUM) { - ANS_LOGE("[AddSlots] fail: slotsSize over max size."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[AddSlots] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!WriteParcelableVector(slots, data)) { - ANS_LOGE("[AddSlots] fail: write slots failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::ADD_SLOTS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[AddSlots] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[AddSlots] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::RemoveSlotByType(const NotificationConstant::SlotType &slotType) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[RemoveSlotByType] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotType)) { - ANS_LOGE("[RemoveSlotByType] fail:: write slotIds failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::REMOVE_SLOT_BY_TYPE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[RemoveSlotByType] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[RemoveSlotByType] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::RemoveAllSlots() -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[RemoveAllSlots] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::REMOVE_ALL_SLOTS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[RemoveAllSlots] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[RemoveAllSlots] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetSlotByType] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotType)) { - ANS_LOGE("[GetSlotByType] fail:: write slotId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SLOT_BY_TYPE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetSlotByType] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetSlotByType] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (result == ERR_OK) { - slot = reply.ReadParcelable(); - if (slot == nullptr) { - ANS_LOGE("[GetSlotByType] slot is null"); - } - } - - return result; -} - -ErrCode AnsManagerProxy::GetSlots(std::vector> &slots) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetSlots] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SLOTS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetSlots] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!ReadParcelableVector(slots, reply, result)) { - ANS_LOGE("[GetSlots] fail: read slots failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[GetSlotNumAsBundle] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetSlotNumAsBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStrongParcelable(bundleOption)) { - ANS_LOGE("[GetSlotNumAsBundle] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SLOT_NUM_AS_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetShowBadgeEnabledForBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetShowBadgeEnabledForBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadUint64(num)) { - ANS_LOGE("[GetShowBadgeEnabledForBundle] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetSlotsByBundle( - const sptr &bundleOption, std::vector> &slots) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[GetSlotsByBundle] fail: bundleOption is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetSlotsByBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[GetSlotsByBundle] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SLOTS_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetSlotsByBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!ReadParcelableVector(slots, reply, result)) { - ANS_LOGE("[GetSlotsByBundle] fail: read slots failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetSlotByBundle( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, - sptr &slot) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[GetSlotByBundle] fail: bundleOption is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetSlotByBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[GetSlotByBundle] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotType)) { - ANS_LOGE("[GetSlotByBundle] fail:: write slotId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SLOT_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetSlotByBundle] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetSlotByBundle] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (result == ERR_OK) { - slot = reply.ReadParcelable(); - if (slot == nullptr) { - ANS_LOGE("[GetSlotByBundle] slot is null"); - } - } - - return result; -} - -ErrCode AnsManagerProxy::UpdateSlots( - const sptr &bundleOption, const std::vector> &slots) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[UpdateSlots] fail: bundleOption is empty."); - return ERR_ANS_INVALID_PARAM; - } - - if (slots.empty()) { - ANS_LOGE("[UpdateSlots] fail: slots is empty."); - return ERR_ANS_INVALID_PARAM; - } - - size_t slotSize = slots.size(); - if (slotSize > MAX_SLOT_NUM) { - ANS_LOGE("[UpdateSlots] fail: slotSize over max size."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[UpdateSlots] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[UpdateSlots] fail:: write bundleoption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!WriteParcelableVector(slots, data)) { - ANS_LOGE("[UpdateSlots] fail: write slots failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::UPDATE_SLOTS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[UpdateSlots] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[UpdateSlots] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[SetEnabledForBundleSlot] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetEnabledForBundleSlot] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStrongParcelable(bundleOption)) { - ANS_LOGE("[SetEnabledForBundleSlot] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotType)) { - ANS_LOGE("[SetEnabledForBundleSlot] fail:: write slotType failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[SetEnabledForBundleSlot] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(isForceControl)) { - ANS_LOGE("[SetEnabledForBundleSlot] fail: write isForceControl failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetEnabledForBundleSlot] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetEnabledForBundleSlot] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetEnabledForBundleSlot( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[GetEnabledForBundleSlot] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetEnabledForBundleSlot] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStrongParcelable(bundleOption)) { - ANS_LOGE("[GetEnabledForBundleSlot] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotType)) { - ANS_LOGE("[GetEnabledForBundleSlot] fail:: write slotType failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetEnabledForBundleSlot] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetEnabledForBundleSlot] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(enabled)) { - ANS_LOGE("[GetEnabledForBundleSlot] fail: read enable failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetEnabledForBundleSlotSelf] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotType)) { - ANS_LOGE("[GetEnabledForBundleSlotSelf] fail:: write slotType failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT_SELF, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetEnabledForBundleSlotSelf] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetEnabledForBundleSlotSelf] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(enabled)) { - ANS_LOGE("[GetEnabledForBundleSlotSelf] fail: read enable failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetSlotFlagsAsBundle(const sptr &bundleOption, uint32_t& slotFlags) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[GetSlotFlagsAsBundle] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetSlotFlagsAsBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStrongParcelable(bundleOption)) { - ANS_LOGE("[GetSlotFlagsAsBundle] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(slotFlags)) { - ANS_LOGE("[GetSlotFlagsAsBundle] fail: write slots failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SLOTFLAGS_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadUint32(slotFlags)) { - ANS_LOGE("[GetSlotFlagsAsBundle] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetSlotFlagsAsBundle(const sptr &bundleOption, uint32_t slotFlags) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[SetSlotFlagsAsBundle] fail: bundleOption is empty."); - return ERR_ANS_INVALID_PARAM; - } - - if (slotFlags > MAX_SLOT_FLAGS) { - ANS_LOGE("[SetSlotFlagsAsBundle] fail: Invalid slotFlags."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetSlotFlagsAsBundle] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(bundleOption)) { - ANS_LOGE("[SetSlotFlagsAsBundle] fail:: write bundleoption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - // got the LSB 6 bits as slotflags; - uint32_t validSlotFlag = MAX_SLOT_FLAGS & slotFlags; - if (!data.WriteInt32(validSlotFlag)) { - ANS_LOGE("[SetSlotFlagsAsBundle] fail: write slots failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_SLOTFLAGS_BY_BUNDLE, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} -} // namespace Notification -} // namespace OHOS diff --git a/frameworks/core/src/manager/ans_manager_proxy_subscribe.cpp b/frameworks/core/src/manager/ans_manager_proxy_subscribe.cpp deleted file mode 100644 index 75b4c84652fa7eb66ee053cf4e620684654824c8..0000000000000000000000000000000000000000 --- a/frameworks/core/src/manager/ans_manager_proxy_subscribe.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (c) 2021-2025 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 "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "ians_subscriber_local_live_view.h" -#include "message_option.h" -#include "message_parcel.h" -#include "parcel.h" -#include "ans_manager_proxy.h" - -namespace OHOS { -namespace Notification { -ErrCode AnsManagerProxy::RemoveNotification(const sptr &bundleOption, - int32_t notificationId, const std::string &label, int32_t removeReason) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[RemoveNotification] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[RemoveNotification] fail:, write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStrongParcelable(bundleOption)) { - ANS_LOGE("[RemoveNotification] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(notificationId)) { - ANS_LOGE("[RemoveNotification] fail: write notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(label)) { - ANS_LOGE("[RemoveNotification] fail: write label failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(removeReason)) { - ANS_LOGE("[RemoveNotification] fail: write removeReason failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::REMOVE_NOTIFICATION, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[RemoveNotification] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[RemoveNotification] fail: read result error."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::RemoveAllNotifications(const sptr &bundleOption) -{ - if (bundleOption == nullptr) { - ANS_LOGE("[RemoveAllNotifications] fail: bundle is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[RemoveAllNotifications] fail:, write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteStrongParcelable(bundleOption)) { - ANS_LOGE("[RemoveAllNotifications] fail:: write bundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::REMOVE_ALL_NOTIFICATIONS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[RemoveNotification] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[RemoveNotification] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::RemoveNotifications(const std::vector &keys, int32_t removeReason) -{ - if (keys.empty()) { - ANS_LOGE("fail: keys is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("fail:, write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(keys.size())) { - ANS_LOGE("write keys size failed"); - return false; - } - - if (!data.WriteStringVector(keys)) { - ANS_LOGE("fail: write keys failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(removeReason)) { - ANS_LOGE("fail: write removeReason failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::REMOVE_NOTIFICATIONS_BY_KEYS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::Subscribe(const sptr &subscriber, - const sptr &info) -{ - if (subscriber == nullptr) { - ANS_LOGE("[Subscribe] fail: subscriber is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[Subscribe] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool ret = data.WriteRemoteObject(subscriber->AsObject()); - if (!ret) { - ANS_LOGE("[Subscribe] fail: write subscriber failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(info != nullptr)) { - ANS_LOGE("[Subscribe] fail: write isSubcribeInfo failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (info != nullptr) { - if (!data.WriteParcelable(info)) { - ANS_LOGE("[Subscribe] fail: write subcribeInfo failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[Subscribe] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[Subscribe] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SubscribeSelf(const sptr &subscriber) -{ - if (subscriber == nullptr) { - ANS_LOGE("[SubscribeSelf] fail: subscriber is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SubscribeSelf] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool ret = data.WriteRemoteObject(subscriber->AsObject()); - if (!ret) { - ANS_LOGE("[SubscribeSelf] fail: write subscriber failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION_SELF, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SubscribeSelf] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SubscribeSelf] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SubscribeLocalLiveView(const sptr &subscriber, - const sptr &info, const bool isNative) -{ - if (subscriber == nullptr) { - ANS_LOGE("[SubscribeLocalLiveView] fail: subscriber is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SubscribeLocalLiveView] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool ret = data.WriteRemoteObject(subscriber->AsObject()); - if (!ret) { - ANS_LOGE("[SubscribeLocalLiveView] fail: write subscriber failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(info != nullptr)) { - ANS_LOGE("[SubscribeLocalLiveView] fail: write isSubcribeInfo failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (info != nullptr) { - if (!data.WriteParcelable(info)) { - ANS_LOGE("[SubscribeLocalLiveView] fail: write subcribeInfo failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - if (!data.WriteBool(isNative)) { - ANS_LOGE("[SubscribeLocalLiveView] fail: write isNative failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SUBSCRIBE_LOCAL_LIVE_VIEW_NOTIFICATION, - option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[Subscribe] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[Subscribe] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerProxy::Unsubscribe( - const sptr &subscriber, const sptr &info) -{ - if (subscriber == nullptr) { - ANS_LOGE("[Unsubscribe] fail: subscriber is empty."); - return ERR_ANS_INVALID_PARAM; - } - - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[Unsubscribe] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool ret = data.WriteRemoteObject(subscriber->AsObject()); - if (!ret) { - ANS_LOGE("[Unsubscribe] fail: write subscriber failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(info != nullptr)) { - ANS_LOGE("[Unsubscribe] fail: write isSubcribeInfo failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (info != nullptr) { - if (!data.WriteParcelable(info)) { - ANS_LOGE("[Unsubscribe] fail: write subcribeInfo failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[Unsubscribe] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[Unsubscribe] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} -} // namespace Notification -} // namespace OHOS diff --git a/frameworks/core/src/manager/ans_manager_proxy_utils.cpp b/frameworks/core/src/manager/ans_manager_proxy_utils.cpp deleted file mode 100644 index 013e4dbda85cb180dbff2185e7bac876d8bae305..0000000000000000000000000000000000000000 --- a/frameworks/core/src/manager/ans_manager_proxy_utils.cpp +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Copyright (c) 2021-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 "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "distributed_notification_service_ipc_interface_code.h" -#include "message_option.h" -#include "message_parcel.h" -#include "parcel.h" -#include "ans_manager_proxy.h" - -namespace OHOS { -namespace Notification { -ErrCode AnsManagerProxy::InnerTransact(NotificationInterfaceCode code, - MessageOption &flags, MessageParcel &data, MessageParcel &reply) -{ - auto remote = Remote(); - if (remote == nullptr) { - ANS_LOGE("[InnerTransact] defeat: get Remote defeat code %{public}u", code); - return ERR_DEAD_OBJECT; - } - int32_t err = remote->SendRequest(static_cast(code), data, reply, flags); - switch (err) { - case NO_ERROR: { - return ERR_OK; - } - case DEAD_OBJECT: { - ANS_LOGE("[InnerTransact] defeat: ipcErr=%{public}d code %{public}d", err, code); - return ERR_DEAD_OBJECT; - } - default: { - ANS_LOGE("[InnerTransact] defeat: ipcErr=%{public}d code %{public}d", err, code); - return ERR_ANS_TRANSACT_FAILED; - } - } -} - -ErrCode AnsManagerProxy::RegisterPushCallback( - const sptr &pushCallback, const sptr ¬ificationCheckRequest) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteRemoteObject(pushCallback)) { - ANS_LOGE("write pushCallback failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteParcelable(notificationCheckRequest)) { - ANS_LOGE("write notificationCheckRequest failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::REGISTER_PUSH_CALLBACK, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::UnregisterPushCallback() -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::UNREGISTER_PUSH_CALLBACK, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const std::string deveiceId) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Set package config fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceType)) { - ANS_LOGE("Set package config fail:: write deviceType failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(status)) { - ANS_LOGE("Set package config fail:: write status failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Transact fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("Set package config fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const uint32_t controlFlag, const std::string deveiceId) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Set package config fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceType)) { - ANS_LOGE("Set package config fail:: write deviceType failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(status)) { - ANS_LOGE("Set package config fail:: write status failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteInt32(controlFlag)) { - ANS_LOGE("Set package config fail:: write controlFlag failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS_WITH_FLAG, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Transact fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("Set package config fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Set package config fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceType)) { - ANS_LOGE("Set package config fail:: write deviceType failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_TARGET_DEVICE_STATUS, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Transact fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("Set package config fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (result == ERR_OK) { - status = reply.ReadInt32(); - } - - return result; -} - -ErrCode AnsManagerProxy::SetAdditionConfig(const std::string &key, const std::string &value) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("Set package config fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(key)) { - ANS_LOGE("Set package config fail:: write key failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(value)) { - ANS_LOGE("Set package config fail:: write value failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_NOTIFICATION_AGENT_RELATIONSHIP, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("Transact fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("Set package config fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED -ErrCode AnsManagerProxy::RegisterSwingCallback(const sptr &swingCallback) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteRemoteObject(swingCallback)) { - ANS_LOGE("write swingCallback failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = { MessageOption::TF_SYNC }; - ErrCode result = InnerTransact(NotificationInterfaceCode::REGISTER_SWING_CALLBACK, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} -#endif - -ErrCode AnsManagerProxy::SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) -{ - ANS_LOGD("enter"); - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetSmartReminderEnabled] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceType)) { - ANS_LOGE("[SetSmartReminderEnabled] fail: write deviceType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(enabled)) { - ANS_LOGE("[SetSmartReminderEnabled] fail: write enabled failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SET_SMART_REMINDER_ENABLED, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetSmartReminderEnabled] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetSmartReminderEnabled] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) -{ - ANS_LOGD("enter"); - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[IsSmartReminderEnabled] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(deviceType)) { - ANS_LOGE("[IsSmartReminderEnabled] fail: write deviceType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::GET_SMART_REMINDER_ENABLED, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[IsSmartReminderEnabled] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[IsSmartReminderEnabled] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(enabled)) { - ANS_LOGE("[IsSmartReminderEnabled] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder) -{ - ANS_LOGD("enter"); - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteString(bundleName)) { - ANS_LOGE("fail: write bundleName failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::ALLOW_USE_REMINDER, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(isAllowUseReminder)) { - ANS_LOGE("fail: read isAllowUseReminder failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, - int32_t recvUserId, std::vector &dumpInfo) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[ShellDump] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!data.WriteString(cmd)) { - ANS_LOGE("[ShellDump] fail: write dump cmd failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!data.WriteString(bundle)) { - ANS_LOGE("[ShellDump] fail: write dump bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!data.WriteInt32(userId)) { - ANS_LOGE("[ShellDump] fail: write dump userId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!data.WriteInt32(recvUserId)) { - ANS_LOGE("[ShellDump] fail: write dump recvUserId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(NotificationInterfaceCode::SHELL_DUMP, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[ShellDump] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - if (!reply.ReadInt32(result)) { - ANS_LOGE("[ShellDump] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!reply.ReadStringVector(&dumpInfo)) { - ANS_LOGE("[ShellDump] fail: read dumpInfo failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} -} // namespace Notification -} // namespace OHOS diff --git a/frameworks/core/src/manager/ans_manager_stub_invalid.cpp b/frameworks/core/src/manager/ans_manager_stub_invalid.cpp deleted file mode 100644 index ecbbb1639d7214fe2dfe9f1e3abc153478cb253c..0000000000000000000000000000000000000000 --- a/frameworks/core/src/manager/ans_manager_stub_invalid.cpp +++ /dev/null @@ -1,713 +0,0 @@ -/* - * Copyright (c) 2021-2025 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_manager_stub.h" -#include "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "message_option.h" -#include "message_parcel.h" -#include "parcel.h" -#include "reminder_request_alarm.h" -#include "reminder_request_calendar.h" -#include "reminder_request_timer.h" - -namespace OHOS { -namespace Notification { -ErrCode AnsManagerStub::Publish(const std::string &label, const sptr ¬ification) -{ - ANS_LOGE("AnsManagerStub::Publish called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::PublishNotificationForIndirectProxy(const sptr ¬ification) -{ - ANS_LOGE("AnsManagerStub::PublishNotificationForIndirectProxy called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::Cancel(int notificationId, const std::string &label, const std::string &instanceKey) -{ - ANS_LOGE("AnsManagerStub::Cancel called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAll(const std::string &instanceKey) -{ - ANS_LOGE("AnsManagerStub::CancelAll called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAsBundle(int32_t notificationId, const std::string &representativeBundle, int32_t userId) -{ - ANS_LOGE("AnsManagerStub::CancelAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAsBundle(const sptr &bundleOption, int32_t notificationId) -{ - ANS_LOGE("AnsManagerStub::CancelAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAsBundle( - const sptr &bundleOption, int32_t notificationId, int32_t userId) -{ - ANS_LOGE("AnsManagerStub::CancelAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::AddSlotByType(NotificationConstant::SlotType slotType) -{ - ANS_LOGE("AnsManagerStub::AddSlotByType called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::AddSlots(const std::vector> &slots) -{ - ANS_LOGE("AnsManagerStub::AddSlots called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveSlotByType(const NotificationConstant::SlotType &slotType) -{ - ANS_LOGE("AnsManagerStub::RemoveSlotByType called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveAllSlots() -{ - ANS_LOGE("AnsManagerStub::RemoveAllSlots called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) -{ - ANS_LOGE("AnsManagerStub::GetSlotByType called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlots(std::vector> &slots) -{ - ANS_LOGE("AnsManagerStub::GetSlots called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) -{ - ANS_LOGE("AnsManagerStub::GetSlotNumAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetActiveNotifications( - std::vector> ¬ifications, const std::string &instanceKey) -{ - ANS_LOGE("AnsManagerStub::GetActiveNotifications called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetActiveNotificationNums(uint64_t &num) -{ - ANS_LOGE("AnsManagerStub::GetActiveNotificationNums called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetAllActiveNotifications(std::vector> ¬ifications) -{ - ANS_LOGE("AnsManagerStub::GetAllActiveNotifications called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetAllNotificationsBySlotType(std::vector> ¬ifications, - const NotificationConstant::SlotType slotType) -{ - ANS_LOGE("AnsManagerStub::GetAllNotificationsBySlotType called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSpecialActiveNotifications( - const std::vector &key, std::vector> ¬ifications) -{ - ANS_LOGE("AnsManagerStub::GetSpecialActiveNotifications called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetActiveNotificationByFilter( - const sptr &bundleOption, const int32_t notificationId, const std::string &label, - std::vector extraInfoKeys, sptr &request) -{ - ANS_LOGE("AnsManagerStub::GetActiveNotificationByFilter called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) -{ - ANS_LOGE("AnsManagerStub::CanPublishAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::PublishAsBundle( - const sptr notification, const std::string &representativeBundle) -{ - ANS_LOGE("AnsManagerStub::PublishAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetNotificationBadgeNum(int num) -{ - ANS_LOGE("AnsManagerStub::SetNotificationBadgeNum called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetBundleImportance(int &importance) -{ - ANS_LOGE("AnsManagerStub::GetBundleImportance called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotFlagsAsBundle(const sptr &bundleOption, uint32_t &slotFlags) -{ - ANS_LOGE("AnsManagerStub::GetSlotFlagsAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetSlotFlagsAsBundle(const sptr &bundleOption, uint32_t slotFlags) -{ - ANS_LOGE("AnsManagerStub::SetSlotFlagsAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::HasNotificationPolicyAccessPermission(bool &granted) -{ - ANS_LOGE("AnsManagerStub::HasNotificationPolicyAccessPermission called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::TriggerLocalLiveView(const sptr &bundleOption, - const int32_t notificationId, const sptr &buttonOption) -{ - ANS_LOGE("AnsManagerStub::TriggerLocalLiveView called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveNotification(const sptr &bundleOption, - int notificationId, const std::string &label, int32_t removeReason) -{ - ANS_LOGE("AnsManagerStub::RemoveNotification called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveAllNotifications(const sptr &bundleOption) -{ - ANS_LOGE("AnsManagerStub::RemoveAllNotifications called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveNotifications(const std::vector &keys, int32_t removeReason) -{ - ANS_LOGD("called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::Delete(const std::string &key, int32_t removeReason) -{ - ANS_LOGE("AnsManagerStub::Delete called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DeleteByBundle(const sptr &bundleOption) -{ - ANS_LOGE("AnsManagerStub::DeleteByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DeleteAll() -{ - ANS_LOGE("AnsManagerStub::DeleteAll called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotsByBundle( - const sptr &bundleOption, std::vector> &slots) -{ - ANS_LOGE("AnsManagerStub::GetSlotsByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotByBundle( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, - sptr &slot) -{ - ANS_LOGE("AnsManagerStub::GetSlotByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::UpdateSlots( - const sptr &bundleOption, const std::vector> &slots) -{ - ANS_LOGE("AnsManagerStub::UpdateSlots called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RequestEnableNotification(const std::string &deviceId, - const sptr &callback, - const sptr &callerToken) -{ - ANS_LOGE("AnsManagerStub::RequestEnableNotification called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RequestEnableNotification(const std::string bundleName, const int32_t uid) -{ - ANS_LOGE("AnsManagerStub::RequestEnableNotification called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetNotificationsEnabledForBundle(const std::string &bundle, bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetNotificationsEnabledForBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetNotificationsEnabledForAllBundles called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetNotificationsEnabledForSpecialBundle( - const std::string &deviceId, const sptr &bundleOption, bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetNotificationsEnabledForSpecialBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetShowBadgeEnabledForBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) -{ - ANS_LOGE("AnsManagerStub::GetShowBadgeEnabledForBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetShowBadgeEnabled(bool &enabled) -{ - ANS_LOGE("AnsManagerStub::GetShowBadgeEnabled called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::Subscribe(const sptr &subscriber, - const sptr &info) -{ - ANS_LOGE("AnsManagerStub::Subscribe called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SubscribeSelf(const sptr &subscriber) -{ - ANS_LOGE("AnsManagerStub::SubscribeSelf called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SubscribeLocalLiveView(const sptr &subscriber, - const sptr &info, const bool isNative) -{ - ANS_LOGE("AnsManagerStub::SubscribeLocalLiveView called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::Unsubscribe(const sptr &subscriber, - const sptr &info) -{ - ANS_LOGE("AnsManagerStub::Unsubscribe called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsAllowedNotify(bool &allowed) -{ - ANS_LOGE("AnsManagerStub::IsAllowedNotify called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsAllowedNotifySelf(bool &allowed) -{ - ANS_LOGE("AnsManagerStub::IsAllowedNotifySelf called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CanPopEnableNotificationDialog(const sptr &callback, - bool &canPop, std::string &bundleName) -{ - ANS_LOGE("AnsManagerStub::CanPopEnableNotificationDialog called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveEnableNotificationDialog() -{ - ANS_LOGE("AnsManagerStub::RemoveEnableNotificationDialog called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) -{ - ANS_LOGE("AnsManagerStub::IsSpecialBundleAllowedNotify called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelGroup(const std::string &groupName, const std::string &instanceKey) -{ - ANS_LOGE("AnsManagerStub::CancelGroup called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveGroupByBundle( - const sptr &bundleOption, const std::string &groupName) -{ - ANS_LOGE("AnsManagerStub::RemoveGroupByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetDoNotDisturbDate(const sptr &date) -{ - ANS_LOGE("AnsManagerStub::SetDoNotDisturbDate called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetDoNotDisturbDate(sptr &date) -{ - ANS_LOGE("AnsManagerStub::GetDoNotDisturbDate called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::AddDoNotDisturbProfiles(const std::vector> &profiles) -{ - ANS_LOGD("Called."); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveDoNotDisturbProfiles(const std::vector> &profiles) -{ - ANS_LOGD("Called."); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DoesSupportDoNotDisturbMode(bool &doesSupport) -{ - ANS_LOGE("AnsManagerStub::DoesSupportDoNotDisturbMode called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) -{ - ANS_LOGE("AnsManagerStub::IsNeedSilentInDoNotDisturbMode called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsDistributedEnabled(bool &enabled) -{ - ANS_LOGE("AnsManagerStub::IsDistributedEnabled called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::EnableDistributed(bool enabled) -{ - ANS_LOGE("AnsManagerStub::EnableDistributed called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::EnableDistributedByBundle(const sptr &bundleOption, bool enabled) -{ - ANS_LOGE("AnsManagerStub::EnableDistributedByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::EnableDistributedSelf(bool enabled) -{ - ANS_LOGE("AnsManagerStub::EnableDistributedSelf called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) -{ - ANS_LOGE("AnsManagerStub::IsDistributedEnableByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetDeviceRemindType(NotificationConstant::RemindType &remindType) -{ - ANS_LOGE("AnsManagerStub::GetDeviceRemindType called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::PublishContinuousTaskNotification(const sptr &request) -{ - ANS_LOGE("AnsManagerStub::PublishContinuousTaskNotification called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) -{ - ANS_LOGE("AnsManagerStub::CancelContinuousTaskNotification called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsSupportTemplate(const std::string &templateName, bool &support) -{ - ANS_LOGE("AnsManagerStub::IsSupportTemplate called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) -{ - ANS_LOGE("AnsManagerStub::IsSpecialUserAllowedNotify called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetNotificationsEnabledByUser called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DeleteAllByUser(const int32_t &userId) -{ - ANS_LOGE("AnsManagerStub::DeleteAllByUser called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetDoNotDisturbDate(const int32_t &userId, const sptr &date) -{ - ANS_LOGE("AnsManagerStub::SetDoNotDisturbDate called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetDoNotDisturbDate(const int32_t &userId, sptr &date) -{ - ANS_LOGE("AnsManagerStub::GetDoNotDisturbDate called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) -{ - ANS_LOGE("AnsManagerStub::SetEnabledForBundleSlot called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetEnabledForBundleSlot( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled) -{ - ANS_LOGE("AnsManagerStub::GetEnabledForBundleSlot called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) -{ - ANS_LOGE("AnsManagerStub::GetEnabledForBundleSlotSelf called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, - int32_t recvUserId, std::vector &dumpInfo) -{ - ANS_LOGE("AnsManagerStub::ShellDump called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetSyncNotificationEnabledWithoutApp called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) -{ - ANS_LOGE("AnsManagerStub::GetSyncNotificationEnabledWithoutApp called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) -{ - ANS_LOGE("AnsManagerStub::SetBadgeNumber called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetBadgeNumberByBundle(const sptr &bundleOption, int32_t badgeNumber) -{ - ANS_LOGD("Called."); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetBadgeNumberForDhByBundle( - const sptr &bundleOption, int32_t badgeNumber) -{ - ANS_LOGD("Called."); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetAllNotificationEnabledBundles(std::vector &bundleOption) -{ - ANS_LOGE("AnsManagerStub::GetAllNotificationEnabledBundles called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RegisterPushCallback( - const sptr& pushCallback, const sptr ¬ificationCheckRequest) -{ - ANS_LOGE("RegisterPushCallback called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::UnregisterPushCallback() -{ - ANS_LOGE("UnregisterPushCallback called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetDistributedEnabledByBundle(const sptr &bundleOption, - const std::string &deviceType, const bool enabled) -{ - ANS_LOGE("SetDistributedEnabledByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsDistributedEnabledByBundle(const sptr &bundleOption, - const std::string &deviceType, bool &enabled) -{ - ANS_LOGE("IsDistributedEnabledByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) -{ - ANS_LOGE("SetSmartReminderEnabled called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) -{ - ANS_LOGE("IsSmartReminderEnabled called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled) -{ - ANS_LOGE("SetDistributedEnabledBySlot called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) -{ - ANS_LOGE("IsDistributedEnabledBySlot called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetAdditionConfig(const std::string &key, const std::string &value) -{ - ANS_LOGE("Called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) -{ - ANS_LOGE("GetTargetDeviceStatus called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DistributeOperation(sptr& operationInfo, - const sptr &callback) -{ - ANS_LOGE("DistributeOperation called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::ReplyDistributeOperation(const std::string& hashCode, const int32_t result) -{ - ANS_LOGE("ReplyDistributeOperation called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAsBundleWithAgent(const sptr &bundleOption, const int32_t id) -{ - ANS_LOGE("Called."); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetAllLiveViewEnabledBundles(std::vector &bundleOption) -{ - ANS_LOGE("AnsManagerStub::GetAllLiveViewEnabledBundles called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetAllDistribuedEnabledBundles(const std::string& deviceType, - std::vector &bundleOption) -{ - ANS_LOGE("AnsManagerStub::GetAllDistribuedEnabledBundles called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const std::string deveiceId) -{ - ANS_LOGE("SetTargetDeviceStatus called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const uint32_t controlFlag, const std::string deveiceId) -{ - ANS_LOGE("SetTargetDeviceStatus called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetDoNotDisturbProfile(int64_t id, sptr &profile) -{ - ANS_LOGE("GetDoNotDisturbProfile called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder) -{ - ANS_LOGE("AllowUseReminder called!"); - return ERR_INVALID_OPERATION; -} - -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED -ErrCode AnsManagerStub::RegisterSwingCallback(const sptr& swingCallback) -{ - ANS_LOGE("RegisterSwingCallback called!"); - return ERR_INVALID_OPERATION; -} -#endif - -ErrCode AnsManagerStub::UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) -{ - ANS_LOGE("UpdateNotificationTimerByUid called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DisableNotificationFeature(const sptr ¬ificationDisable) -{ - ANS_LOGE("DisableNotificationFeature called!"); - return ERR_INVALID_OPERATION; -} -} // namespace Notification -} // namespace OHOS 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 539872868a4a64ddec3d1a6788b3228ed9dd7188..f55a3ebfba32de6880bb73deaa3189b366cb4cc0 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,7940 +1,7254 @@ -/* - * 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 "ans_subscriber_listener.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, ""); - 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, ""); - 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, ""); - 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, ""); - 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, ""); - 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(""); - 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(""); - 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(""); - 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(""); - 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, ""); - 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, ""); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); - EXPECT_EQ(0, 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, ""); - 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, ""); - 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, ""); - 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: 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", ""); - 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", ""); - 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", ""); - 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", ""); - 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: 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, ""); - 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, ""); - 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, ""); - 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, ""); - 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); -} - -/* - * @tc.name: UpdateNotificationTimerByUid_0100 - * @tc.desc: test UpdateNotificationTimerByUid function - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, UpdateNotificationTimerByUid_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, UpdateNotificationTimerByUid_0100, TestSize.Level1"; - sptr iremoteObject = new (std::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); - int32_t uid = 20099999; - bool isPaused = true; - int32_t result = proxy->UpdateNotificationTimerByUid(uid, isPaused); - EXPECT_EQ(ERR_OK, result); -} - -/* - * @tc.name: DisableNotificationFeature_0100 - * @tc.desc: test DisableNotificationFeature - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerProxyUnitTest, DisableNotificationFeature_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, DisableNotificationFeature_0100, TestSize.Level1"; - sptr iremoteObject = new (std::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 notificationDisable = nullptr; - ErrCode res = proxy->DisableNotificationFeature(notificationDisable); - EXPECT_EQ(res, ERR_OK); -} -} // 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_inner_errors.h" +#include "ans_subscriber_listener.h" +#include "ians_manager.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 { + +const int32_t IPC_READ_ERROR = 0; + +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: 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_INVALID_VALUE, 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(IPC_READ_ERROR, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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, ""); + EXPECT_EQ(ERR_INVALID_VALUE, 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, ""); + EXPECT_EQ(IPC_READ_ERROR, 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, ""); + 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, ""); + EXPECT_EQ(DEAD_OBJECT, 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, ""); + EXPECT_EQ(IPC_READ_ERROR, 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(""); + EXPECT_EQ(ERR_INVALID_VALUE, 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(""); + 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(""); + EXPECT_EQ(DEAD_OBJECT, 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(""); + EXPECT_EQ(IPC_READ_ERROR, 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_INVALID_VALUE, 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(IPC_READ_ERROR, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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_INVALID_VALUE, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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); + EXPECT_EQ(ERR_INVALID_VALUE, 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); + EXPECT_EQ(IPC_READ_ERROR, 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); + 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); + EXPECT_EQ(DEAD_OBJECT, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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 == 0) { + reply.WriteBool(false); + } + if (slotNum == 1) { + reply.WriteBool(true); + 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_OK, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_EQ(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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, ""); + EXPECT_EQ(ERR_INVALID_VALUE, 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, ""); + EXPECT_EQ(ERR_INVALID_DATA, result); + EXPECT_EQ(0, 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, ""); + EXPECT_EQ(DEAD_OBJECT, 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, ""); + EXPECT_EQ(ERR_TRANSACTION_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, ""); + EXPECT_EQ(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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_INVALID_DATA, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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_INVALID_DATA, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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); + MockWriteInterfaceToken(true); + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + int32_t result = proxy->RemoveNotification(bundleOption, 0, "0", 0); + EXPECT_EQ(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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(IPC_READ_ERROR, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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", ""); + EXPECT_EQ(ERR_INVALID_VALUE, 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", ""); + 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", ""); + EXPECT_EQ(DEAD_OBJECT, 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", ""); + EXPECT_EQ(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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_INVALID_DATA, 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(DEAD_OBJECT, 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_INVALID_DATA, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(IPC_READ_ERROR, 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(DEAD_OBJECT, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(IPC_READ_ERROR, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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_INVALID_DATA, 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(DEAD_OBJECT, 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_INVALID_DATA, 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_INVALID_VALUE, result); + MockWriteInterfaceToken(true); +} + +/* + * @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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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_TRANSACTION_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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(IPC_READ_ERROR, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, result); +} + +/* + * @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, ""); + EXPECT_EQ(ERR_INVALID_VALUE, 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, ""); + 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, ""); + EXPECT_EQ(DEAD_OBJECT, 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, ""); + EXPECT_EQ(IPC_READ_ERROR, 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(IPC_READ_ERROR, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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_OK, result); +} + +/** + * @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_INVALID_VALUE, 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_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_INVALID_VALUE, 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_INVALID_VALUE, 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(DEAD_OBJECT, 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(IPC_READ_ERROR, 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); +} + +/* + * @tc.name: UpdateNotificationTimerByUid_0100 + * @tc.desc: test UpdateNotificationTimerByUid function + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, UpdateNotificationTimerByUid_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, UpdateNotificationTimerByUid_0100, TestSize.Level1"; + sptr iremoteObject = new (std::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); + int32_t uid = 20099999; + bool isPaused = true; + int32_t result = proxy->UpdateNotificationTimerByUid(uid, isPaused); + EXPECT_EQ(ERR_OK, result); +} + +/* + * @tc.name: DisableNotificationFeature_0100 + * @tc.desc: test DisableNotificationFeature + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerProxyUnitTest, DisableNotificationFeature_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, DisableNotificationFeature_0100, TestSize.Level1"; + sptr iremoteObject = new (std::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 notificationDisable = nullptr; + ErrCode res = proxy->DisableNotificationFeature(notificationDisable); + EXPECT_EQ(res, ERR_OK); +} + +} // namespace Notification +} // namespace OHOS diff --git a/frameworks/core/test/unittest/ans_notification_annex_test/ans_notification_annex_test.cpp b/frameworks/core/test/unittest/ans_notification_annex_test/ans_notification_annex_test.cpp index 09aacf0eb6c3bab7789be8b73360e224ca34ca21..0990171e18c4a403bba984b4e9e3ab324c12f467 100644 --- a/frameworks/core/test/unittest/ans_notification_annex_test/ans_notification_annex_test.cpp +++ b/frameworks/core/test/unittest/ans_notification_annex_test/ans_notification_annex_test.cpp @@ -1,275 +1,275 @@ -/* - * 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 - -#define private public -#define protected public -#include "ans_manager_proxy.h" -#include "ans_notification.h" -#include "ans_subscriber_proxy.h" -#undef private -#undef protected -#include "ans_inner_errors.h" -#include "ipc_types.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; - -namespace OHOS { -namespace Notification { -class AnsNotificationUnitAnnexTest : public testing::Test { -public: - AnsNotificationUnitAnnexTest() {} - - virtual ~AnsNotificationUnitAnnexTest() {} - - static void SetUpTestCase(); - - static void TearDownTestCase(); - - void SetUp(); - - void TearDown(); - std::shared_ptr ans_; - sptr ansManagerProxy_{nullptr}; -}; - -void AnsNotificationUnitAnnexTest::SetUpTestCase() {} - -void AnsNotificationUnitAnnexTest::TearDownTestCase() {} - -void AnsNotificationUnitAnnexTest::SetUp() -{ - if (!ans_) { - ans_ = DelayedSingleton::GetInstance(); - } -} - -void AnsNotificationUnitAnnexTest::TearDown() {} - -/* - * @tc.name: GetNotificationSlotNumAsBundle_0200 - * @tc.desc: test GetNotificationSlotNumAsBundle return ERR_ANS_NON_SYSTEM_APP. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, GetNotificationSlotNumAsBundle_0200, Function | MediumTest | Level1) -{ - bool res = ans_->GetAnsManagerProxy(); - EXPECT_EQ(res, true); - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - uint64_t num = 10; - ErrCode ret1 = ans_->GetNotificationSlotNumAsBundle(bundleOption, num); - EXPECT_EQ(ret1, ERR_ANS_NON_SYSTEM_APP); -} - -/* - * @tc.name: PublishNotification_0100 - * @tc.desc: test PublishNotification ErrCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, PublishNotification_0100, Function | MediumTest | Level1) -{ - std::string label = "this is label"; - NotificationRequest request; - request.SetContent(nullptr); - - ErrCode ret1 = ans_->PublishNotification(label, request); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: PublishNotificationAsBundle_0100 - * @tc.desc: test PublishNotificationAsBundle ErrCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, PublishNotificationAsBundle_0100, Function | MediumTest | Level1) -{ - std::string representativeBundle = "this is representativeBundle"; - NotificationRequest request; - request.SetContent(nullptr); - ErrCode ret5 = ans_->PublishNotificationAsBundle(representativeBundle, request); - EXPECT_EQ(ret5, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: PublishNotificationAsBundle_0200 - * @tc.desc: test PublishNotificationAsBundle ErrCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, PublishNotificationAsBundle_0200, Function | MediumTest | Level1) -{ - std::string representativeBundle = "this is representativeBundle"; - NotificationRequest request; - 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_INVALID_OPERATION); -} - -/* - * @tc.name: RemoveNotification_0100 - * @tc.desc: test RemoveNotification ErrCode ERR_ANS_NON_SYSTEM_APP. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, RemoveNotification_0100, Function | MediumTest | Level1) -{ - int32_t removeReason = 10; - 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_NON_SYSTEM_APP); -} - -/* - * @tc.name: RemoveAllNotifications_0200 - * @tc.desc: test RemoveAllNotifications ErrCode ERR_ANS_NON_SYSTEM_APP. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, RemoveAllNotifications_0200, Function | MediumTest | Level1) -{ - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - ErrCode ret3 = ans_->RemoveAllNotifications(bundleOption); - EXPECT_EQ(ret3, ERR_ANS_NON_SYSTEM_APP); -} - -/* - * @tc.name: RemoveNotificationsByBundle_0200 - * @tc.desc: test RemoveNotificationsByBundle ErrCode ERR_ANS_NON_SYSTEM_APP. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, RemoveNotificationsByBundle_0200, Function | MediumTest | Level1) -{ - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - ErrCode ret3 = ans_->RemoveNotificationsByBundle(bundleOption); - EXPECT_EQ(ret3, ERR_ANS_NON_SYSTEM_APP); -} - -/* - * @tc.name: GetNotificationSlotsForBundle_0200 - * @tc.desc: test GetNotificationSlotsForBundle ErrCode ERR_ANS_NON_SYSTEM_APP. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, GetNotificationSlotsForBundle_0200, Function | MediumTest | Level1) -{ - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - std::vector> slots; - ErrCode ret3 = ans_->GetNotificationSlotsForBundle(bundleOption, slots); - EXPECT_EQ(ret3, ERR_ANS_NON_SYSTEM_APP); -} - -/* - * @tc.name: UpdateNotificationSlots_0200 - * @tc.desc: test UpdateNotificationSlots ErrCode ERR_ANS_PERMISSION_DENIED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, UpdateNotificationSlots_0200, Function | MediumTest | Level1) -{ - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - std::vector> slots; - ErrCode ret3 = ans_->UpdateNotificationSlots(bundleOption, slots); - EXPECT_EQ(ret3, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: RemoveGroupByBundle_0100 - * @tc.desc: test RemoveGroupByBundle ErrCode ERR_ANS_INVALID_PARAM. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, RemoveGroupByBundle_0100, Function | MediumTest | Level1) -{ - std::string groupName = ""; - NotificationBundleOption bundleOption; - std::string bundleName = "this is bundleName"; - bundleOption.SetBundleName(bundleName); - ErrCode ret2 = ans_->RemoveGroupByBundle(bundleOption, groupName); - EXPECT_EQ(ret2, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: PublishContinuousTaskNotification_0100 - * @tc.desc: test PublishContinuousTaskNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, PublishContinuousTaskNotification_0100, Function | MediumTest | Level1) -{ - NotificationRequest request; - request.SetContent(nullptr); - ErrCode ret1 = ans_->PublishContinuousTaskNotification(request); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: PublishContinuousTaskNotification_0200 - * @tc.desc: test PublishContinuousTaskNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, PublishContinuousTaskNotification_0200, Function | MediumTest | Level1) -{ - 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_NOT_SYSTEM_SERVICE); -} - -/* - * @tc.name: CheckImageSizeForContent_0100 - * @tc.desc: test CheckImageSizeForContent. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitAnnexTest, CheckImageSizeForContent_0100, Function | MediumTest | Level1) -{ - NotificationRequest request; - request.SetContent(nullptr); - - ErrCode ret = request.CheckImageSizeForContent(); - EXPECT_EQ(ret, ERR_OK); -} -} // namespace Notification -} // namespace OHOS +/* + * 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 + +#define private public +#define protected public +#include "ans_manager_proxy.h" +#include "ans_notification.h" +#include "ans_subscriber_proxy.h" +#undef private +#undef protected +#include "ans_inner_errors.h" +#include "ipc_types.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; + +namespace OHOS { +namespace Notification { +class AnsNotificationUnitAnnexTest : public testing::Test { +public: + AnsNotificationUnitAnnexTest() {} + + virtual ~AnsNotificationUnitAnnexTest() {} + + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp(); + + void TearDown(); + std::shared_ptr ans_; + sptr ansManagerProxy_{nullptr}; +}; + +void AnsNotificationUnitAnnexTest::SetUpTestCase() {} + +void AnsNotificationUnitAnnexTest::TearDownTestCase() {} + +void AnsNotificationUnitAnnexTest::SetUp() +{ + if (!ans_) { + ans_ = DelayedSingleton::GetInstance(); + } +} + +void AnsNotificationUnitAnnexTest::TearDown() {} + +/* + * @tc.name: GetNotificationSlotNumAsBundle_0200 + * @tc.desc: test GetNotificationSlotNumAsBundle return ERR_ANS_NON_SYSTEM_APP. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, GetNotificationSlotNumAsBundle_0200, Function | MediumTest | Level1) +{ + bool res = ans_->GetAnsManagerProxy(); + EXPECT_EQ(res, true); + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + uint64_t num = 10; + ErrCode ret1 = ans_->GetNotificationSlotNumAsBundle(bundleOption, num); + EXPECT_EQ(ret1, ERR_ANS_NON_SYSTEM_APP); +} + +/* + * @tc.name: PublishNotification_0100 + * @tc.desc: test PublishNotification ErrCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, PublishNotification_0100, Function | MediumTest | Level1) +{ + std::string label = "this is label"; + NotificationRequest request; + request.SetContent(nullptr); + + ErrCode ret1 = ans_->PublishNotification(label, request); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: PublishNotificationAsBundle_0100 + * @tc.desc: test PublishNotificationAsBundle ErrCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, PublishNotificationAsBundle_0100, Function | MediumTest | Level1) +{ + std::string representativeBundle = "this is representativeBundle"; + NotificationRequest request; + request.SetContent(nullptr); + ErrCode ret5 = ans_->PublishNotificationAsBundle(representativeBundle, request); + EXPECT_EQ(ret5, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: PublishNotificationAsBundle_0200 + * @tc.desc: test PublishNotificationAsBundle ErrCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, PublishNotificationAsBundle_0200, Function | MediumTest | Level1) +{ + std::string representativeBundle = "this is representativeBundle"; + NotificationRequest request; + 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_INVALID_OPERATION); +} + +/* + * @tc.name: RemoveNotification_0100 + * @tc.desc: test RemoveNotification ErrCode ERR_ANS_NON_SYSTEM_APP. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, RemoveNotification_0100, Function | MediumTest | Level1) +{ + int32_t removeReason = 10; + 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_NON_SYSTEM_APP); +} + +/* + * @tc.name: RemoveAllNotifications_0200 + * @tc.desc: test RemoveAllNotifications ErrCode ERR_ANS_NON_SYSTEM_APP. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, RemoveAllNotifications_0200, Function | MediumTest | Level1) +{ + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + ErrCode ret3 = ans_->RemoveAllNotifications(bundleOption); + EXPECT_EQ(ret3, ERR_ANS_NON_SYSTEM_APP); +} + +/* + * @tc.name: RemoveNotificationsByBundle_0200 + * @tc.desc: test RemoveNotificationsByBundle ErrCode ERR_ANS_NON_SYSTEM_APP. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, RemoveNotificationsByBundle_0200, Function | MediumTest | Level1) +{ + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + ErrCode ret3 = ans_->RemoveNotificationsByBundle(bundleOption); + EXPECT_EQ(ret3, ERR_ANS_NON_SYSTEM_APP); +} + +/* + * @tc.name: GetNotificationSlotsForBundle_0200 + * @tc.desc: test GetNotificationSlotsForBundle ErrCode ERR_ANS_NON_SYSTEM_APP. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, GetNotificationSlotsForBundle_0200, Function | MediumTest | Level1) +{ + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + std::vector> slots; + ErrCode ret3 = ans_->GetNotificationSlotsForBundle(bundleOption, slots); + EXPECT_EQ(ret3, ERR_ANS_NON_SYSTEM_APP); +} + +/* + * @tc.name: UpdateNotificationSlots_0200 + * @tc.desc: test UpdateNotificationSlots ErrCode ERR_ANS_PERMISSION_DENIED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, UpdateNotificationSlots_0200, Function | MediumTest | Level1) +{ + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + std::vector> slots; + ErrCode ret3 = ans_->UpdateNotificationSlots(bundleOption, slots); + EXPECT_EQ(ret3, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: RemoveGroupByBundle_0100 + * @tc.desc: test RemoveGroupByBundle ErrCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, RemoveGroupByBundle_0100, Function | MediumTest | Level1) +{ + std::string groupName = ""; + NotificationBundleOption bundleOption; + std::string bundleName = "this is bundleName"; + bundleOption.SetBundleName(bundleName); + ErrCode ret2 = ans_->RemoveGroupByBundle(bundleOption, groupName); + EXPECT_EQ(ret2, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: PublishContinuousTaskNotification_0100 + * @tc.desc: test PublishContinuousTaskNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, PublishContinuousTaskNotification_0100, Function | MediumTest | Level1) +{ + NotificationRequest request; + request.SetContent(nullptr); + ErrCode ret1 = ans_->PublishContinuousTaskNotification(request); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: PublishContinuousTaskNotification_0200 + * @tc.desc: test PublishContinuousTaskNotification ErrCode ERR_ANS_SERVICE_NOT_CONNECTED. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, PublishContinuousTaskNotification_0200, Function | MediumTest | Level1) +{ + 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_NOT_SYSTEM_SERVICE); +} + +/* + * @tc.name: CheckImageSizeForContent_0100 + * @tc.desc: test CheckImageSizeForContent. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitAnnexTest, CheckImageSizeForContent_0100, Function | MediumTest | Level1) +{ + NotificationRequest request; + request.SetContent(nullptr); + + ErrCode ret = request.CheckImageSizeForContent(); + EXPECT_EQ(ret, ERR_OK); +} +} // namespace Notification +} // namespace OHOS diff --git a/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp b/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp index d77d2a489e2d785f08998692ede526474c7e26ce..2b1c342e048d49221be65bd7d0428c3fe4bcbbe8 100644 --- a/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp +++ b/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp @@ -1,937 +1,974 @@ -/* - * Copyright (c) 2023-2025 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_notification.h" -#include "ans_subscriber_proxy.h" -#include "ans_manager_interface.h" -#include "ans_manager_proxy.h" -#undef private -#undef protected -#include "ians_dialog_callback.h" -#include "ans_inner_errors.h" -#include "ipc_types.h" -#include "notification.h" -#include "notification_request.h" -#include "singleton.h" -#include "notification_subscriber.h" - -extern void MockGetAnsManagerProxy(OHOS::sptr mockRet); - -using namespace testing; -using namespace testing::ext; -using namespace OHOS; -using namespace OHOS::Notification; - -namespace OHOS { -namespace Notification { -class MockAnsManagerInterface : public AnsManagerInterface { -public: - MockAnsManagerInterface() = default; - virtual ~MockAnsManagerInterface() - {}; - sptr AsObject() override - { - return nullptr; - } - - ErrCode Publish(const std::string &label, const sptr ¬ification) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode PublishNotificationForIndirectProxy(const sptr ¬ification) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode Cancel(int notificationId, const std::string &label, const std::string &instanceKey) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode CancelAll(const std::string &instanceKey) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode CancelAsBundle( - int32_t notificationId, const std::string &representativeBundle, int32_t userId) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode CancelAsBundle( - const sptr &bundleOption, int32_t notificationId) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode CancelAsBundle( - const sptr &bundleOption, int32_t notificationId, int32_t userId) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode AddSlotByType(NotificationConstant::SlotType slotType) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode AddSlots(const std::vector> &slots) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RemoveAllSlots() override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetSlots(std::vector> &slots) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetActiveNotifications(std::vector> ¬ifications, - const std::string &instanceKey) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetActiveNotificationNums(uint64_t &num) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetAllActiveNotifications(std::vector> ¬ifications) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetSpecialActiveNotifications( - const std::vector &key, std::vector> ¬ifications) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode PublishAsBundle( - const sptr notification, const std::string &representativeBundle) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetNotificationBadgeNum(int num) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetBundleImportance(int &importance) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode HasNotificationPolicyAccessPermission(bool &granted) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode Delete(const std::string &key, int32_t removeReason) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RemoveNotification(const sptr &bundleOption, int notificationId, - const std::string &label, int32_t removeReason) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RemoveAllNotifications(const sptr &bundleOption) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RemoveNotifications(const std::vector &hashcodes, int32_t removeReason) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode DeleteByBundle(const sptr &bundleOption) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode DeleteAll() override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetSlotsByBundle( - const sptr &bundleOption, std::vector> &slots) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetSlotByBundle( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, - sptr &slot) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode UpdateSlots( - const sptr &bundleOption, const std::vector> &slots) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RequestEnableNotification(const std::string &deviceId, - const sptr &callback, - const sptr &callerToken) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetNotificationsEnabledForSpecialBundle( - const std::string &deviceId, const sptr &bundleOption, bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetShowBadgeEnabled(bool &enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode Subscribe(const sptr &subscriber, - const sptr &info) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SubscribeSelf(const sptr &subscriber) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetAllNotificationEnabledBundles(std::vector &bundleOption)override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetAllLiveViewEnabledBundles(std::vector &bundleOption) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetAllDistribuedEnabledBundles(const std::string& deviceType, - std::vector &bundleOption) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SubscribeLocalLiveView(const sptr &subscriber, - const sptr &info, const bool isNatives) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode Unsubscribe( - const sptr &subscriber, const sptr &info) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsAllowedNotify(bool &allowed) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsAllowedNotifySelf(bool &allowed) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode CanPopEnableNotificationDialog(const sptr &callback, - bool &canPop, std::string &bundleName) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RemoveEnableNotificationDialog() override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetDoNotDisturbDate(const sptr &date) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetDoNotDisturbDate(sptr &date) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode AddDoNotDisturbProfiles(const std::vector> &profiles) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RemoveDoNotDisturbProfiles(const std::vector> &profiles) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode CancelGroup(const std::string &groupName, const std::string &instanceKey) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RemoveGroupByBundle( - const sptr &bundleOption, const std::string &groupName) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsDistributedEnabled(bool &enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode EnableDistributed(bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode EnableDistributedByBundle(const sptr &bundleOption, bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode EnableDistributedSelf(bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode PublishContinuousTaskNotification(const sptr &request) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsSupportTemplate(const std::string &templateName, bool &support) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode DeleteAllByUser(const int32_t &userId) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr &date) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool &enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, int32_t recvUserId, - std::vector &dumpInfo) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetBadgeNumberByBundle(const sptr& bundleOption, int32_t badgeNumber) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetBadgeNumberForDhByBundle( - const sptr& bundleOption, int32_t badgeNumber) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetSlotFlagsAsBundle(const sptr& bundleOption, uint32_t &slotFlags) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetSlotFlagsAsBundle(const sptr& bundleOption, uint32_t slotFlags) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode RegisterPushCallback(const sptr &pushCallback, - const sptr ¬ificationCheckRequest) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode UnregisterPushCallback() override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetActiveNotificationByFilter(const sptr &bundleOption, - const int32_t notificationId, const std::string &label, std::vector extraInfoKeys, - sptr &request) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode TriggerLocalLiveView(const sptr &bundleOption, - const int32_t notificationId, const sptr &buttonOption) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetDistributedEnabledByBundle(const sptr &bundleOption, - const std::string &deviceType, const bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetAdditionConfig(const std::string &key, const std::string &value) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsDistributedEnabledByBundle(const sptr &bundleOption, - const std::string &deviceType, bool &enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode IsDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode CancelAsBundleWithAgent(const sptr &bundleOption, const int32_t id) - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const std::string deveiceId = std::string()) - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const uint32_t controlFlag, const std::string deveiceId = std::string()) - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetDoNotDisturbProfile(int64_t id, sptr &profile) - { - return ERR_ANS_INVALID_PARAM; - } - -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED - ErrCode RegisterSwingCallback(const sptr &swingCallback) override - { - return ERR_ANS_INVALID_PARAM; - } -#endif - - ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode DisableNotificationFeature(const sptr ¬ificationDisable) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode DistributeOperation(sptr& operationInfo, - const sptr &callback) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode ReplyDistributeOperation(const std::string& hashCode, const int32_t result) - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetNotificationRequestByHashCode( - const std::string& hashCode, sptr& notificationRequest) override - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode SetHashCodeRule(const uint32_t type) - { - return ERR_ANS_INVALID_PARAM; - } - - ErrCode GetAllNotificationsBySlotType(std::vector> ¬ifications, - const NotificationConstant::SlotType slotType) - { - return ERR_ANS_INVALID_PARAM; - } -}; - -class AnsNotificationBranchTest : public testing::Test { -public: - AnsNotificationBranchTest() {} - - virtual ~AnsNotificationBranchTest() {} - - static void SetUpTestCase(); - - static void TearDownTestCase(); - - void SetUp(); -}; - -void AnsNotificationBranchTest::SetUpTestCase() -{ - MockGetAnsManagerProxy(nullptr); -} - -void AnsNotificationBranchTest::TearDownTestCase() {} - -void AnsNotificationBranchTest::SetUp() {} - -/* - * @tc.name: RemoveNotifications_0100 - * @tc.desc: Test RemoveNotifications and hashcodes is empty - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationBranchTest, RemoveNotifications_0100, Function | MediumTest | Level1) -{ - auto ansNotification = std::make_shared(); - EXPECT_NE(ansNotification, nullptr); - std::vector hashcodes; - int32_t removeReason = 1; - ErrCode ret = ansNotification->RemoveNotifications(hashcodes, removeReason); - EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: RemoveNotifications_0200 - * @tc.desc: 1.Test RemoveNotifications and hashcodes is not empty - * 2.GetAnsManagerProxy is false - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationBranchTest, RemoveNotifications_0200, Function | MediumTest | Level1) -{ - auto ansNotification = std::make_shared(); - EXPECT_NE(ansNotification, nullptr); - std::string hashcode = "aa"; - std::vector hashcodes; - hashcodes.emplace_back(hashcode); - int32_t removeReason = 1; - ErrCode ret = ansNotification->RemoveNotifications(hashcodes, removeReason); - EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: RemoveNotifications_0300 - * @tc.desc: 1.Test RemoveNotifications and hashcodes is not empty - * 2.GetAnsManagerProxy is true - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationBranchTest, RemoveNotifications_0300, Function | MediumTest | Level1) -{ - auto ansNotification = std::make_shared(); - EXPECT_NE(ansNotification, nullptr); - std::string hashcode = "aa"; - std::vector hashcodes; - hashcodes.emplace_back(hashcode); - int32_t removeReason = 1; - ansNotification->RemoveNotifications(hashcodes, removeReason); -} - -/* - * @tc.name: RegisterPushCallback_0100 - * @tc.desc: 1.Test RegisterPushCallback - * 2.GetAnsManagerProxy is false - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationBranchTest, RegisterPushCallback_0100, Function | MediumTest | Level1) -{ - auto ansNotification = std::make_shared(); - EXPECT_NE(ansNotification, nullptr); - sptr pushCallback = nullptr; - sptr checkRequest = new (std::nothrow) NotificationCheckRequest(); - ErrCode ret = ansNotification->RegisterPushCallback(pushCallback, checkRequest); - EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: RegisterPushCallback_0200 - * @tc.desc: 1.Test RegisterPushCallback - * 2.GetAnsManagerProxy is true - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationBranchTest, RegisterPushCallback_0200, Function | MediumTest | Level1) -{ - auto ansNotification = std::make_shared(); - EXPECT_NE(ansNotification, nullptr); - sptr pushCallback = nullptr; - sptr checkRequest = new (std::nothrow) NotificationCheckRequest(); - ansNotification->RegisterPushCallback(pushCallback, checkRequest); -} - -/* - * @tc.name: UnregisterPushCallback_0100 - * @tc.desc: 1.Test UnregisterPushCallback - * 2.GetAnsManagerProxy is false - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationBranchTest, UnregisterPushCallback_0100, Function | MediumTest | Level1) -{ - auto ansNotification = std::make_shared(); - EXPECT_NE(ansNotification, nullptr); - ErrCode ret = ansNotification->UnregisterPushCallback(); - EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: UnregisterPushCallback_0200 - * @tc.desc: 1.Test UnregisterPushCallback - * 2.GetAnsManagerProxy is true - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationBranchTest, UnregisterPushCallback_0200, Function | MediumTest | Level1) -{ - auto ansNotification = std::make_shared(); - EXPECT_NE(ansNotification, nullptr); - ansNotification->UnregisterPushCallback(); -} - -/* - * @tc.name: CanPublishLiveViewContent_0100 - * @tc.desc: CanPublishLiveViewContent - * @tc.type: FUNC - * @tc.require: issule - */ -HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0100, Function | MediumTest | Level1) -{ - NotificationRequest request; - auto notification = std::make_shared(); - EXPECT_TRUE(notification->CanPublishLiveViewContent(request)); -} - -/* - * @tc.name: CanPublishLiveViewContent_0110 - * @tc.desc: CanPublishLiveViewContent - * @tc.type: FUNC - * @tc.require: issule - */ -HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0110, Function | MediumTest | Level1) -{ - NotificationRequest request; - request.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); - auto liveViewContent = std::make_shared(); - liveViewContent->SetLiveViewStatus(NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_BUTT); - auto content = std::make_shared(liveViewContent); - request.SetContent(content); - - auto notification = std::make_shared(); - EXPECT_FALSE(notification->CanPublishLiveViewContent(request)); -} - -/* - * @tc.name: CanPublishLiveViewContent_0120 - * @tc.desc: CanPublishLiveViewContent - * @tc.type: FUNC - * @tc.require: issule - */ -HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0120, Function | MediumTest | Level1) -{ - NotificationRequest request; - request.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); - auto liveViewContent = std::make_shared(); - auto content = std::make_shared(liveViewContent); - request.SetContent(content); - - auto notification = std::make_shared(); - EXPECT_TRUE(notification->CanPublishLiveViewContent(request)); -} - -/* - * @tc.name: CanPublishLiveViewContent_0130 - * @tc.desc: CanPublishLiveViewContent - * @tc.type: FUNC - * @tc.require: issule - */ -HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0130, Function | MediumTest | Level1) -{ - NotificationRequest request; - request.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); - auto liveViewContent = std::make_shared(); - liveViewContent->SetLiveViewStatus(NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_FULL_UPDATE); - auto content = std::make_shared(liveViewContent); - request.SetContent(content); - - auto notification = std::make_shared(); - EXPECT_TRUE(notification->CanPublishLiveViewContent(request)); -} - -/* - * @tc.name: CanPublishLiveViewContent_0140 - * @tc.desc: CanPublishLiveViewContent - * @tc.type: FUNC - * @tc.require: issule - */ -HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0140, Function | MediumTest | Level1) -{ - NotificationRequest request; - request.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); - auto liveViewContent = std::make_shared(); - auto content = std::make_shared(liveViewContent); - request.SetContent(content); - request.notificationContent_ = nullptr; - - auto notification = std::make_shared(); - EXPECT_FALSE(notification->CanPublishLiveViewContent(request)); -} - -/* - * @tc.name: CanPublishLiveViewContent_0150 - * @tc.desc: CanPublishLiveViewContent - * @tc.type: FUNC - * @tc.require: issule - */ -HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0150, Function | MediumTest | Level1) -{ - NotificationRequest request; - request.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); - auto liveViewContent = std::make_shared(); - auto content = std::make_shared(liveViewContent); - content->content_ = nullptr; - request.SetContent(content); - - auto notification = std::make_shared(); - EXPECT_FALSE(notification->CanPublishLiveViewContent(request)); -} - -/* - * @tc.name: SetNotificationSlotFlagsAsBundle_0001 - * @tc.desc: SetNotificationSlotFlagsAsBundle - * @tc.type: FUNC - * @tc.require: issule - */ -HWTEST_F(AnsNotificationBranchTest, SetNotificationSlotFlagsAsBundle_0001, Function | MediumTest | Level1) -{ - NotificationBundleOption bundle; - uint32_t slotFlags = 1; - auto notification = std::make_shared(); - ErrCode ret = notification->SetNotificationSlotFlagsAsBundle(bundle, slotFlags); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); - ret = notification->GetNotificationSlotFlagsAsBundle(bundle, slotFlags); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); -} - -/* - * @tc.name: PublishNotification_0001 - * @tc.desc: PublishNotification - * @tc.type: FUNC - * @tc.require: issule - */ -HWTEST_F(AnsNotificationBranchTest, PublishNotification_0001, Function | MediumTest | Level1) -{ - auto notification = std::make_shared(); - MockGetAnsManagerProxy(new (std::nothrow) MockAnsManagerInterface()); - NotificationRequest req; - std::shared_ptr mediaContent = std::make_shared(); - auto content = std::make_shared(mediaContent); - content->content_ = nullptr; - req.SetContent(content); - - auto ret = notification->PublishNotification("label", req); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); - ret = notification->PublishNotificationAsBundle("label", req); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); - - auto liveViewContent = std::make_shared(); - auto content1 = std::make_shared(liveViewContent); - content1->content_ = nullptr; - req.SetContent(content1); - req.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); - ret = notification->PublishNotification("label", req); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); - ret = notification->PublishNotificationAsBundle("label", req); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); -} - -} // namespace Notification -} // namespace OHOS +/* + * Copyright (c) 2023-2025 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_notification.h" +#include "ans_subscriber_proxy.h" +#include "ans_manager_proxy.h" +#include "ians_manager.h" +#undef private +#undef protected +#include "ians_dialog_callback.h" +#include "ans_inner_errors.h" +#include "ipc_types.h" +#include "notification.h" +#include "notification_request.h" +#include "singleton.h" +#include "notification_subscriber.h" + +extern void MockGetAnsManagerProxy(OHOS::sptr mockRet); + +using namespace testing; +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::Notification; + +namespace OHOS { +namespace Notification { +class MockAnsManagerInterface : public IAnsManager { +public: + MockAnsManagerInterface() = default; + virtual ~MockAnsManagerInterface() + {}; + sptr AsObject() override + { + return nullptr; + } + + ErrCode Publish(const std::string &label, const sptr ¬ification) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode PublishNotificationForIndirectProxy(const sptr ¬ification) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode Cancel(int notificationId, const std::string &label, const std::string &instanceKey) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode CancelAll(const std::string &instanceKey) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode CancelAsBundle( + int32_t notificationId, const std::string &representativeBundle, int32_t userId) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode CancelAsBundle( + const sptr &bundleOption, int32_t notificationId) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode CancelAsBundle( + const sptr &bundleOption, int32_t notificationId, int32_t userId) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode AddSlotByType(int32_t slotTypeInt) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode AddSlots(const std::vector> &slots) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RemoveSlotByType(int32_t slotTypeInt) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RemoveAllSlots() override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetSlotByType(int32_t slotTypeInt, sptr &slot) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetSlots(std::vector> &slots) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetActiveNotifications(std::vector> ¬ifications, + const std::string &instanceKey) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetActiveNotificationNums(uint64_t &num) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetAllActiveNotifications(std::vector> ¬ifications) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetSpecialActiveNotifications( + const std::vector &key, std::vector> ¬ifications) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode PublishAsBundle( + const sptr ¬ification, const std::string &representativeBundle) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetNotificationBadgeNum(int num) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetBundleImportance(int &importance) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode HasNotificationPolicyAccessPermission(bool &granted) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode Delete(const std::string &key, int32_t removeReason) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RemoveNotification(const sptr &bundleOption, int notificationId, + const std::string &label, int32_t removeReason) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RemoveAllNotifications(const sptr &bundleOption) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RemoveNotifications(const std::vector &hashcodes, int32_t removeReason) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode DeleteByBundle(const sptr &bundleOption) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode DeleteAll() override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetSlotsByBundle( + const sptr &bundleOption, std::vector> &slots) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetSlotByBundle( + const sptr &bundleOption, int32_t slotTypeInt, + sptr &slot) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode UpdateSlots( + const sptr &bundleOption, const std::vector> &slots) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RequestEnableNotification(const std::string &deviceId, + const sptr& ansDialogCallback) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RequestEnableNotification(const std::string &deviceId, + const sptr& ansDialogCallback, + const sptr& callerToken) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RequestEnableNotification(const std::string& bundleName, int32_t uid) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetNotificationsEnabledForSpecialBundle( + const std::string &deviceId, const sptr &bundleOption, bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetShowBadgeEnabled(bool &enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode Subscribe(const sptr& subscriber) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode Subscribe(const sptr &subscriber, + const sptr &info) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SubscribeSelf(const sptr &subscriber) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetAllNotificationEnabledBundles(std::vector &bundleOption)override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetAllLiveViewEnabledBundles(std::vector &bundleOption) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetAllDistribuedEnabledBundles(const std::string& deviceType, + std::vector &bundleOption) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SubscribeLocalLiveView(const sptr &subscriber, + bool isNatives) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SubscribeLocalLiveView(const sptr& subscriber, + const sptr& info, bool isNatives) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode Unsubscribe(const sptr& subscriber) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode Unsubscribe(const sptr& subscriber, const sptr& info) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsAllowedNotify(bool &allowed) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsAllowedNotifySelf(bool &allowed) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode CanPopEnableNotificationDialog(const sptr &callback, + bool &canPop, std::string &bundleName) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RemoveEnableNotificationDialog() override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetDoNotDisturbDate(const sptr &date) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetDoNotDisturbDate(sptr &date) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode AddDoNotDisturbProfiles(const std::vector> &profiles) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RemoveDoNotDisturbProfiles(const std::vector> &profiles) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode CancelGroup(const std::string &groupName, const std::string &instanceKey) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RemoveGroupByBundle( + const sptr &bundleOption, const std::string &groupName) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsDistributedEnabled(bool &enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode EnableDistributed(bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode EnableDistributedByBundle(const sptr &bundleOption, bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode EnableDistributedSelf(bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetDeviceRemindType(int32_t& remindTypeInt) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode PublishContinuousTaskNotification(const sptr &request) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsSupportTemplate(const std::string &templateName, bool &support) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsSpecialUserAllowedNotify(int32_t userId, bool &allowed) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetNotificationsEnabledByUser(int32_t userId, bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode DeleteAllByUser(int32_t userId) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetDoNotDisturbDate(int32_t userId, const sptr &date) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetDoNotDisturbDate(int32_t userId, sptr &date) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetEnabledForBundleSlot(const sptr &bundleOption, + int32_t slotTypeInt, bool enabled, bool isForceControl) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetEnabledForBundleSlot(const sptr &bundleOption, + int32_t slotTypeInt, bool &enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetEnabledForBundleSlotSelf(int32_t slotTypeInt, bool &enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, int32_t recvUserId, + std::vector &dumpInfo) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetBadgeNumberByBundle(const sptr& bundleOption, int32_t badgeNumber) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetBadgeNumberForDhByBundle( + const sptr& bundleOption, int32_t badgeNumber) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetSlotFlagsAsBundle(const sptr& bundleOption, uint32_t &slotFlags) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetSlotFlagsAsBundle(const sptr& bundleOption, uint32_t slotFlags) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode RegisterPushCallback(const sptr &pushCallback, + const sptr ¬ificationCheckRequest) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode UnregisterPushCallback() override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetActiveNotificationByFilter(const sptr &bundleOption, + int32_t notificationId, const std::string &label, const std::vector& extraInfoKeys, + sptr &request) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode TriggerLocalLiveView(const sptr &bundleOption, + const int32_t notificationId, const sptr &buttonOption) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetDistributedEnabledByBundle(const sptr &bundleOption, + const std::string &deviceType, const bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetAdditionConfig(const std::string &key, const std::string &value) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsDistributedEnabledByBundle(const sptr &bundleOption, + const std::string &deviceType, bool &enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetDistributedEnabledBySlot( + int32_t slotTypeInt, const std::string &deviceType, bool enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode IsDistributedEnabledBySlot( + int32_t slotTypeInt, const std::string &deviceType, bool &enabled) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode CancelAsBundleWithAgent(const sptr &bundleOption, const int32_t id) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetTargetDeviceStatus(const std::string &deviceType, uint32_t status, + const std::string& deveiceId) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetTargetDeviceStatus(const std::string &deviceType, uint32_t status, + uint32_t controlFlag, const std::string& deveiceId) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetDoNotDisturbProfile(int64_t id, sptr &profile) override + { + return ERR_ANS_INVALID_PARAM; + } + +#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED + ErrCode RegisterSwingCallback(const sptr &swingCallback) override + { + return ERR_ANS_INVALID_PARAM; + } +#endif + + ErrCode UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode DisableNotificationFeature(const sptr ¬ificationDisable) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode DistributeOperation(sptr& operationInfo, + const sptr& operationCallback) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode ReplyDistributeOperation(const std::string& hashCode, const int32_t result) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetNotificationRequestByHashCode( + const std::string& hashCode, sptr& notificationRequest) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode SetHashCodeRule(const uint32_t type) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode GetAllNotificationsBySlotType(std::vector> ¬ifications, + int32_t slotTypeInt) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode PublishWithMaxCapacity(const std::string& label, const sptr& notification) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode PublishNotificationForIndirectProxyWithMaxCapacity(const sptr& notification) override + { + return ERR_ANS_INVALID_PARAM; + } + + ErrCode PublishAsBundleWithMaxCapacity( + const sptr& notification, const std::string& representativeBundle) override + { + return ERR_ANS_INVALID_PARAM; + } +}; + +class AnsNotificationBranchTest : public testing::Test { +public: + AnsNotificationBranchTest() {} + + virtual ~AnsNotificationBranchTest() {} + + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp(); +}; + +void AnsNotificationBranchTest::SetUpTestCase() +{ + MockGetAnsManagerProxy(nullptr); +} + +void AnsNotificationBranchTest::TearDownTestCase() {} + +void AnsNotificationBranchTest::SetUp() {} + +/* + * @tc.name: RemoveNotifications_0100 + * @tc.desc: Test RemoveNotifications and hashcodes is empty + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, RemoveNotifications_0100, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + std::vector hashcodes; + int32_t removeReason = 1; + ErrCode ret = ansNotification->RemoveNotifications(hashcodes, removeReason); + EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: RemoveNotifications_0200 + * @tc.desc: 1.Test RemoveNotifications and hashcodes is not empty + * 2.GetAnsManagerProxy is false + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, RemoveNotifications_0200, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + std::string hashcode = "aa"; + std::vector hashcodes; + hashcodes.emplace_back(hashcode); + int32_t removeReason = 1; + ErrCode ret = ansNotification->RemoveNotifications(hashcodes, removeReason); + EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: RemoveNotifications_0300 + * @tc.desc: 1.Test RemoveNotifications and hashcodes is not empty + * 2.GetAnsManagerProxy is true + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, RemoveNotifications_0300, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + std::string hashcode = "aa"; + std::vector hashcodes; + hashcodes.emplace_back(hashcode); + int32_t removeReason = 1; + ansNotification->RemoveNotifications(hashcodes, removeReason); +} + +/* + * @tc.name: RegisterPushCallback_0100 + * @tc.desc: 1.Test RegisterPushCallback + * 2.GetAnsManagerProxy is false + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, RegisterPushCallback_0100, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + sptr pushCallback = nullptr; + sptr checkRequest = new (std::nothrow) NotificationCheckRequest(); + ErrCode ret = ansNotification->RegisterPushCallback(pushCallback, checkRequest); + EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: RegisterPushCallback_0200 + * @tc.desc: 1.Test RegisterPushCallback + * 2.GetAnsManagerProxy is true + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, RegisterPushCallback_0200, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + sptr pushCallback = nullptr; + sptr checkRequest = new (std::nothrow) NotificationCheckRequest(); + ansNotification->RegisterPushCallback(pushCallback, checkRequest); +} + +/* + * @tc.name: UnregisterPushCallback_0100 + * @tc.desc: 1.Test UnregisterPushCallback + * 2.GetAnsManagerProxy is false + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, UnregisterPushCallback_0100, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + ErrCode ret = ansNotification->UnregisterPushCallback(); + EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: UnregisterPushCallback_0200 + * @tc.desc: 1.Test UnregisterPushCallback + * 2.GetAnsManagerProxy is true + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, UnregisterPushCallback_0200, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + ansNotification->UnregisterPushCallback(); +} + +/* + * @tc.name: CanPublishLiveViewContent_0100 + * @tc.desc: CanPublishLiveViewContent + * @tc.type: FUNC + * @tc.require: issule + */ +HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0100, Function | MediumTest | Level1) +{ + NotificationRequest request; + auto notification = std::make_shared(); + EXPECT_TRUE(notification->CanPublishLiveViewContent(request)); +} + +/* + * @tc.name: CanPublishLiveViewContent_0110 + * @tc.desc: CanPublishLiveViewContent + * @tc.type: FUNC + * @tc.require: issule + */ +HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0110, Function | MediumTest | Level1) +{ + NotificationRequest request; + request.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + auto liveViewContent = std::make_shared(); + liveViewContent->SetLiveViewStatus(NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_BUTT); + auto content = std::make_shared(liveViewContent); + request.SetContent(content); + + auto notification = std::make_shared(); + EXPECT_FALSE(notification->CanPublishLiveViewContent(request)); +} + +/* + * @tc.name: CanPublishLiveViewContent_0120 + * @tc.desc: CanPublishLiveViewContent + * @tc.type: FUNC + * @tc.require: issule + */ +HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0120, Function | MediumTest | Level1) +{ + NotificationRequest request; + request.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + auto liveViewContent = std::make_shared(); + auto content = std::make_shared(liveViewContent); + request.SetContent(content); + + auto notification = std::make_shared(); + EXPECT_TRUE(notification->CanPublishLiveViewContent(request)); +} + +/* + * @tc.name: CanPublishLiveViewContent_0130 + * @tc.desc: CanPublishLiveViewContent + * @tc.type: FUNC + * @tc.require: issule + */ +HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0130, Function | MediumTest | Level1) +{ + NotificationRequest request; + request.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + auto liveViewContent = std::make_shared(); + liveViewContent->SetLiveViewStatus(NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_FULL_UPDATE); + auto content = std::make_shared(liveViewContent); + request.SetContent(content); + + auto notification = std::make_shared(); + EXPECT_TRUE(notification->CanPublishLiveViewContent(request)); +} + +/* + * @tc.name: CanPublishLiveViewContent_0140 + * @tc.desc: CanPublishLiveViewContent + * @tc.type: FUNC + * @tc.require: issule + */ +HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0140, Function | MediumTest | Level1) +{ + NotificationRequest request; + request.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + auto liveViewContent = std::make_shared(); + auto content = std::make_shared(liveViewContent); + request.SetContent(content); + request.notificationContent_ = nullptr; + + auto notification = std::make_shared(); + EXPECT_FALSE(notification->CanPublishLiveViewContent(request)); +} + +/* + * @tc.name: CanPublishLiveViewContent_0150 + * @tc.desc: CanPublishLiveViewContent + * @tc.type: FUNC + * @tc.require: issule + */ +HWTEST_F(AnsNotificationBranchTest, CanPublishLiveViewContent_0150, Function | MediumTest | Level1) +{ + NotificationRequest request; + request.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + auto liveViewContent = std::make_shared(); + auto content = std::make_shared(liveViewContent); + content->content_ = nullptr; + request.SetContent(content); + + auto notification = std::make_shared(); + EXPECT_FALSE(notification->CanPublishLiveViewContent(request)); +} + +/* + * @tc.name: SetNotificationSlotFlagsAsBundle_0001 + * @tc.desc: SetNotificationSlotFlagsAsBundle + * @tc.type: FUNC + * @tc.require: issule + */ +HWTEST_F(AnsNotificationBranchTest, SetNotificationSlotFlagsAsBundle_0001, Function | MediumTest | Level1) +{ + NotificationBundleOption bundle; + uint32_t slotFlags = 1; + auto notification = std::make_shared(); + ErrCode ret = notification->SetNotificationSlotFlagsAsBundle(bundle, slotFlags); + EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + ret = notification->GetNotificationSlotFlagsAsBundle(bundle, slotFlags); + EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: PublishNotification_0001 + * @tc.desc: PublishNotification + * @tc.type: FUNC + * @tc.require: issule + */ +HWTEST_F(AnsNotificationBranchTest, PublishNotification_0001, Function | MediumTest | Level1) +{ + auto notification = std::make_shared(); + MockGetAnsManagerProxy(new (std::nothrow) MockAnsManagerInterface()); + NotificationRequest req; + std::shared_ptr mediaContent = std::make_shared(); + auto content = std::make_shared(mediaContent); + content->content_ = nullptr; + req.SetContent(content); + + auto ret = notification->PublishNotification("label", req); + EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + ret = notification->PublishNotificationAsBundle("label", req); + EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + + auto liveViewContent = std::make_shared(); + auto content1 = std::make_shared(liveViewContent); + content1->content_ = nullptr; + req.SetContent(content1); + req.SetSlotType(NotificationConstant::SlotType::LIVE_VIEW); + ret = notification->PublishNotification("label", req); + EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); + ret = notification->PublishNotificationAsBundle("label", req); + EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); +} + +} // namespace Notification +} // namespace OHOS 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 106a1c9b561b64bd55d98d2644d697dae610b2f7..856f6899c5e74796add7cf273e3c423b7b796105 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,1624 +1,1624 @@ -/* - * 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 "refbase.h" -#include -#include -#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); -} - -/* - * @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: 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: SubscribeNotification_0300 - * @tc.desc: test SubscribeNotification return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SubscribeNotification_0300, 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 = std::make_shared(); - sptr info = new (std::nothrow) NotificationSubscribeInfo(); - ErrCode ret1 = ans_->SubscribeNotification(subscriber, info); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: SubscribeNotification_0400 - * @tc.desc: test SubscribeNotification return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, SubscribeNotification_0400, 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); - - ErrCode ret1 = ans_->SubscribeNotification(nullptr); - EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); -} - -/* - * @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: UnSubscribeNotification_0300 - * @tc.desc: test UnSubscribeNotification return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, UnSubscribeNotification_0300, 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 = std::make_shared(); - ErrCode ret1 = ans_->UnSubscribeNotification(subscriber); - EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: UnSubscribeNotification_0400 - * @tc.desc: test UnSubscribeNotification return false. - * @tc.type: FUNC - * @tc.require: #I62SME - */ -HWTEST_F(AnsNotificationUnitTest, UnSubscribeNotification_0400, 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 = std::make_shared(); - sptr info = new (std::nothrow) NotificationSubscribeInfo(); - 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 - */ -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); -} - -/* - * @tc.name: DisableNotificationFeature_0100 - * @tc.desc: test DisableNotificationFeature. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, DisableNotificationFeature_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 ret = ans_->GetAnsManagerProxy(); - EXPECT_FALSE(ret); - - NotificationDisable notificationDisable; - ErrCode res = ans_->DisableNotificationFeature(notificationDisable); - EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/* - * @tc.name: PublishNotificationForIndirectProxy_0100 - * @tc.desc: test PublishNotificationForIndirectProxy. - * @tc.type: FUNC - */ -HWTEST_F(AnsNotificationUnitTest, PublishNotificationForIndirectProxy_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 ret = ans_->GetAnsManagerProxy(); - EXPECT_FALSE(ret); - - NotificationRequest request; - ErrCode res = ans_->PublishNotificationForIndirectProxy(request); - EXPECT_EQ(res, ERR_ANS_INVALID_PARAM); -} -} // 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 "refbase.h" +#include +#include +#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); +} + +/* + * @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: 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: SubscribeNotification_0300 + * @tc.desc: test SubscribeNotification return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SubscribeNotification_0300, 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 = std::make_shared(); + sptr info = new (std::nothrow) NotificationSubscribeInfo(); + ErrCode ret1 = ans_->SubscribeNotification(subscriber, info); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SubscribeNotification_0400 + * @tc.desc: test SubscribeNotification return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, SubscribeNotification_0400, 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); + + ErrCode ret1 = ans_->SubscribeNotification(nullptr); + EXPECT_EQ(ret1, ERR_ANS_INVALID_PARAM); +} + +/* + * @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: UnSubscribeNotification_0300 + * @tc.desc: test UnSubscribeNotification return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, UnSubscribeNotification_0300, 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 = std::make_shared(); + ErrCode ret1 = ans_->UnSubscribeNotification(subscriber); + EXPECT_EQ(ret1, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: UnSubscribeNotification_0400 + * @tc.desc: test UnSubscribeNotification return false. + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationUnitTest, UnSubscribeNotification_0400, 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 = std::make_shared(); + sptr info = new (std::nothrow) NotificationSubscribeInfo(); + 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 + */ +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); +} + +/* + * @tc.name: DisableNotificationFeature_0100 + * @tc.desc: test DisableNotificationFeature. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, DisableNotificationFeature_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 ret = ans_->GetAnsManagerProxy(); + EXPECT_FALSE(ret); + + NotificationDisable notificationDisable; + ErrCode res = ans_->DisableNotificationFeature(notificationDisable); + EXPECT_EQ(res, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: PublishNotificationForIndirectProxy_0100 + * @tc.desc: test PublishNotificationForIndirectProxy. + * @tc.type: FUNC + */ +HWTEST_F(AnsNotificationUnitTest, PublishNotificationForIndirectProxy_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 ret = ans_->GetAnsManagerProxy(); + EXPECT_FALSE(ret); + + NotificationRequest request; + ErrCode res = ans_->PublishNotificationForIndirectProxy(request); + EXPECT_EQ(res, ERR_ANS_INVALID_PARAM); +} +} // namespace Notification +} // namespace OHOS diff --git a/frameworks/core/test/unittest/mock/mock_ans_manager_proxy.cpp b/frameworks/core/test/unittest/mock/mock_ans_manager_proxy.cpp index 83b320bd3f035e5e3760d26036a489f70ad2ed94..01ac2c8d04cda4b828357cbda162b31bf94fae22 100644 --- a/frameworks/core/test/unittest/mock/mock_ans_manager_proxy.cpp +++ b/frameworks/core/test/unittest/mock/mock_ans_manager_proxy.cpp @@ -16,17 +16,17 @@ #include "ans_notification.h" namespace { - OHOS::sptr g_mockGetAnsManagerProxy = nullptr; + OHOS::sptr g_mockGetAnsManagerProxy = nullptr; } -void MockGetAnsManagerProxy(OHOS::sptr mockRet) +void MockGetAnsManagerProxy(OHOS::sptr mockRet) { g_mockGetAnsManagerProxy = mockRet; } namespace OHOS { namespace Notification { -sptr AnsNotification::GetAnsManagerProxy() +sptr AnsNotification::GetAnsManagerProxy() { return g_mockGetAnsManagerProxy; } diff --git a/frameworks/js/napi/src/common_utils.cpp b/frameworks/js/napi/src/common_utils.cpp index 5bc276db5e0a0b42f65eb80c1e84c6cd0c928ac3..519c49fdc2d4ce411b2d1f6e97f1c9896998557a 100644 --- a/frameworks/js/napi/src/common_utils.cpp +++ b/frameworks/js/napi/src/common_utils.cpp @@ -317,6 +317,9 @@ int32_t Common::ErrorToExternal(uint32_t errCode) {ERR_ANS_PARCELABLE_FAILED, ERROR_IPC_ERROR}, {ERR_ANS_TRANSACT_FAILED, ERROR_IPC_ERROR}, {ERR_ANS_REMOTE_DEAD, ERROR_IPC_ERROR}, + {ERR_INVALID_VALUE, ERROR_IPC_ERROR}, + {ERR_INVALID_DATA, ERROR_IPC_ERROR}, + {DEAD_OBJECT, ERROR_IPC_ERROR}, {ERR_ANS_SERVICE_NOT_READY, ERROR_SERVICE_CONNECT_ERROR}, {ERR_ANS_SERVICE_NOT_CONNECTED, ERROR_SERVICE_CONNECT_ERROR}, {ERR_ANS_NOT_ALLOWED, ERROR_NOTIFICATION_CLOSED}, diff --git a/frameworks/reminder/src/reminder_request_client.cpp b/frameworks/reminder/src/reminder_request_client.cpp index 2a1ef3e92f3e84297dd73d48e5a62e54c0513090..e262a1bd62f945392ce10732e8441f790be1c8d8 100644 --- a/frameworks/reminder/src/reminder_request_client.cpp +++ b/frameworks/reminder/src/reminder_request_client.cpp @@ -34,7 +34,7 @@ constexpr int32_t REMINDER_SERVICE_LOADSA_TIMEOUT_MS = 10000; constexpr int32_t REMINDER_AGENT_SERVICE_ID = 3204; ErrCode ReminderRequestClient::AddSlotByType(const NotificationConstant::SlotType &slotType) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -44,7 +44,7 @@ ErrCode ReminderRequestClient::AddSlotByType(const NotificationConstant::SlotTyp ErrCode ReminderRequestClient::AddNotificationSlot(const NotificationSlot &slot) { - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -62,7 +62,7 @@ ErrCode ReminderRequestClient::AddNotificationSlot(const NotificationSlot &slot) ErrCode ReminderRequestClient::RemoveNotificationSlot(const NotificationConstant::SlotType &slotType) { ANS_LOGI("enter RemoveNotificationSlot,slotType:%{public}d", slotType); - sptr proxy = GetAnsManagerProxy(); + sptr proxy = GetAnsManagerProxy(); if (!proxy) { ANS_LOGE("GetAnsManagerProxy fail."); return ERR_ANS_SERVICE_NOT_CONNECTED; @@ -141,7 +141,7 @@ ErrCode ReminderRequestClient::GetExcludeDates(const int32_t reminderId, std::ve return proxy->GetExcludeDates(reminderId, dates); } -sptr ReminderRequestClient::GetAnsManagerProxy() +sptr ReminderRequestClient::GetAnsManagerProxy() { sptr systemAbilityManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); @@ -157,7 +157,7 @@ sptr ReminderRequestClient::GetAnsManagerProxy() return nullptr; } - sptr proxy = iface_cast(remoteObject); + sptr proxy = iface_cast(remoteObject); if ((!proxy) || (!proxy->AsObject())) { ANS_LOGE("Failed to get notification Manager's proxy"); return nullptr; diff --git a/interfaces/inner_api/notification_local_live_view_subscriber.h b/interfaces/inner_api/notification_local_live_view_subscriber.h index 6e611ed67146ff9a32592acab9dc61e93113b999..6e0376f43b624ec828a090da0a297bf2f60786d9 100644 --- a/interfaces/inner_api/notification_local_live_view_subscriber.h +++ b/interfaces/inner_api/notification_local_live_view_subscriber.h @@ -16,7 +16,7 @@ #ifndef BND_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_LOCAL_LIVE_VIEW_SUBSCRIBER_H #define BND_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_LOCAL_LIVE_VIEW_SUBSCRIBER_H -#include "ans_manager_interface.h" +#include "ians_manager.h" #include "ans_subscriber_stub.h" #include "ans_subscriber_local_live_view_stub.h" #include "notification_request.h" @@ -73,7 +73,7 @@ private: ErrCode OnResponse(int32_t notificationId, const sptr &buttonOption) override; - sptr GetAnsManagerProxy(); + sptr GetAnsManagerProxy(); public: NotificationLocalLiveViewSubscriber &subscriber_; diff --git a/interfaces/inner_api/notification_subscriber.h b/interfaces/inner_api/notification_subscriber.h index 1f4b43ebb041a0d3250acf226973022d3a8503b8..87949ac4c58a65ff9ec3f14871ef141d8fdda625 100644 --- a/interfaces/inner_api/notification_subscriber.h +++ b/interfaces/inner_api/notification_subscriber.h @@ -16,7 +16,7 @@ #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_SUBSCRIBER_H #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_SUBSCRIBER_H -#include "ans_manager_interface.h" +#include "ians_manager.h" #include "ans_subscriber_stub.h" #include "notification_request.h" #include "notification_sorting.h" @@ -203,7 +203,7 @@ private: ErrCode OnOperationResponse(const sptr &operationInfo, int32_t& funcResult) override; - sptr GetAnsManagerProxy(); + sptr GetAnsManagerProxy(); public: NotificationSubscriber &subscriber_; diff --git a/interfaces/inner_api/reminder_request_client.h b/interfaces/inner_api/reminder_request_client.h index f517a766b4d94926b18203eebed99835c0f9b660..1dc3a9646060695c95ef6d6781fd8214d5ee1311 100644 --- a/interfaces/inner_api/reminder_request_client.h +++ b/interfaces/inner_api/reminder_request_client.h @@ -21,7 +21,7 @@ #include "reminder_request_adaptation.h" #include "notification_slot.h" #include "notification_constant.h" -#include "ans_manager_interface.h" +#include "ians_manager.h" #include "ireminder_agent_service.h" #include "ffrt.h" @@ -126,7 +126,7 @@ private: */ ErrCode AddSlotByType(const NotificationConstant::SlotType &slotType); - sptr GetAnsManagerProxy(); + sptr GetAnsManagerProxy(); sptr GetReminderServiceProxy(); diff --git a/services/ans/BUILD.gn b/services/ans/BUILD.gn index d0071feac1a31d824cb80f70173ec71456067dde..a2510a8525a0d2a6a0860112add1aef8abe3e3fb 100644 --- a/services/ans/BUILD.gn +++ b/services/ans/BUILD.gn @@ -81,8 +81,6 @@ ohos_source_set("ans_service_sources") { "src/advanced_notification_slot_service.cpp", "src/advanced_notification_subscriber_service.cpp", "src/advanced_notification_utils.cpp", - "src/ans_manager_stub.cpp", - "src/ans_manager_stub_invalid.cpp", "src/bundle_manager_helper.cpp", "src/clone/dh_notification_clone_bundle_service.cpp", "src/clone/notification_clone_bundle_info.cpp", @@ -140,6 +138,7 @@ ohos_source_set("ans_service_sources") { deps = [ "${frameworks_module_ans_path}:ans_innerkits", + "${frameworks_module_ans_path}:ans_manager_stub", "${frameworks_module_reminder_path}:reminder_innerkits", "../ans:ans.para", "../ans:ans.para.dac", diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 32ba2af4d7e84b6fc077d71a7008a39ac895a026..a2001aef2ebc7e81b134589698fc2b6d11cf19fd 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -118,6 +118,8 @@ public: */ ErrCode Publish(const std::string &label, const sptr &request) override; + ErrCode PublishWithMaxCapacity(const std::string& label, const sptr& request) override; + /** * @brief Publishes a notification. * @note If a notification with the same ID has been published by the current application and has not been deleted, @@ -129,6 +131,8 @@ public: */ ErrCode PublishNotificationForIndirectProxy(const sptr &request) override; + ErrCode PublishNotificationForIndirectProxyWithMaxCapacity(const sptr &request) override; + /** * @brief Cancels a published notification matching the specified label and notificationId. * @@ -190,7 +194,7 @@ public: * @param slotType Indicates the notification slot type to be added. * @return Returns ERR_OK on success, others on failure. */ - ErrCode AddSlotByType(NotificationConstant::SlotType slotType) override; + ErrCode AddSlotByType(int32_t slotTypeInt) override; /** * @brief Creates multiple notification slots. @@ -207,7 +211,7 @@ public: * This parameter must be specified. * @return Returns ERR_OK on success, others on failure. */ - ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) override; + ErrCode RemoveSlotByType(int32_t slotTypeInt) override; /** * @brief Deletes all notification slots. @@ -224,7 +228,7 @@ public: * @param slot Indicates the created NotificationSlot. * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) override; + ErrCode GetSlotByType(int32_t slotTypeInt, sptr &slot) override; /** * @brief Obtains all notification slots of this application. @@ -269,7 +273,7 @@ public: * @return Returns get all active notifications */ ErrCode GetAllNotificationsBySlotType(std::vector> ¬ifications, - const NotificationConstant::SlotType slotType) override; + int32_t slotTypeInt) override; /** * @brief Obtains all active notifications in the current system. The caller must have system permissions to @@ -294,8 +298,8 @@ public: const std::vector &key, std::vector> ¬ifications) override; ErrCode GetActiveNotificationByFilter( - const sptr &bundleOption, const int32_t notificationId, const std::string &label, - const std::vector extraInfoKeys, sptr &request) override; + const sptr &bundleOption, int32_t notificationId, const std::string &label, + const std::vector &extraInfoKeys, sptr &request) override; /** * @brief Checks whether your application has permission to publish notifications by calling @@ -320,7 +324,10 @@ public: * @return Returns ERR_OK on success, others on failure. */ ErrCode PublishAsBundle( - const sptr notification, const std::string &representativeBundle) override; + const sptr& notification, const std::string &representativeBundle) override; + + ErrCode PublishAsBundleWithMaxCapacity( + const sptr& notification, const std::string &representativeBundle) override; /** * @brief Sets the number of active notifications of the current application as the number to be displayed on the @@ -430,7 +437,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ ErrCode GetSlotByBundle( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, + const sptr &bundleOption, int32_t slotTypeInt, sptr &slot) override; /** @@ -453,6 +460,9 @@ public: const sptr &callback, const sptr &callerToken) override; + ErrCode RequestEnableNotification(const std::string &deviceId, + const sptr &callback) override; + /** * @brief Allow application to publish notifications. * @@ -460,7 +470,7 @@ public: * @param uid uid. * @return Returns set notifications enabled for the bundle result. */ - ErrCode RequestEnableNotification(const std::string bundleName, const int32_t uid) override; + ErrCode RequestEnableNotification(const std::string& bundleName, int32_t uid) override; /** * @brief Set whether to allow the specified deviceId to send notifications for current bundle. @@ -526,6 +536,8 @@ public: ErrCode Subscribe(const sptr &subscriber, const sptr &info) override; + ErrCode Subscribe(const sptr &subscriber) override; + /** * @brief Subscribes notifications self. * @@ -544,6 +556,8 @@ public: ErrCode SubscribeLocalLiveView(const sptr &subscriber, const sptr &info, const bool isNative) override; + ErrCode SubscribeLocalLiveView(const sptr &subscriber, const bool isNative) override; + /** * @brief Unsubscribes notifications. * @@ -554,6 +568,8 @@ public: ErrCode Unsubscribe(const sptr &subscriber, const sptr &info) override; + ErrCode Unsubscribe(const sptr &subscriber) override; + /** * @brief Checks whether this device is allowed to publish notifications. * @@ -712,7 +728,7 @@ public: * @param remindType Reminder type for the device. * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) override; + ErrCode GetDeviceRemindType(int32_t& remindTypeInt) override; /** * @brief Publishes a continuous notification. @@ -752,7 +768,7 @@ public: * @param allowed Identifies the allowed flag. * @return Returns ERR_OK on success, others on failure. */ - ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) override; + ErrCode IsSpecialUserAllowedNotify(int32_t userId, bool &allowed) override; /** * @brief Sets whether to allow all applications to publish notifications on a specified device. The caller must @@ -765,7 +781,7 @@ public: * are not allowed. * @return Returns ERR_OK on success, others on failure. */ - ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) override; + ErrCode SetNotificationsEnabledByUser(int32_t userId, bool enabled) override; /** * @brief Delete all notifications by user. @@ -773,7 +789,7 @@ public: * @param userId Indicates the user id. * @return Returns ERR_OK on success, others on failure. */ - ErrCode DeleteAllByUser(const int32_t &userId) override; + ErrCode DeleteAllByUser(int32_t userId) override; /** * @brief Set do not disturb date by user. @@ -782,7 +798,7 @@ public: * @param date Indicates NotificationDoNotDisturbDate object. * @return Returns ERR_OK on success, others on failure. */ - ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr &date) override; + ErrCode SetDoNotDisturbDate(int32_t userId, const sptr &date) override; /** * @brief Get the do not disturb date by user. @@ -791,13 +807,15 @@ public: * @param date Indicates the NotificationDoNotDisturbDate object. * @return Returns ERR_OK on success, others on failure. */ - ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr &date) override; + ErrCode GetDoNotDisturbDate(int32_t userId, sptr &date) override; ErrCode SetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) override; + int32_t slotTypeInt, bool enabled, bool isForceControl) override; + ErrCode GetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool &enabled) override; - ErrCode GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) override; + int32_t slotTypeInt, bool &enabled) override; + + ErrCode GetEnabledForBundleSlotSelf(int32_t slotTypeInt, bool &enabled) override; // SystemEvent @@ -1053,7 +1071,7 @@ public: * @return Returns set channel switch result. */ ErrCode SetDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled) override; + int32_t slotTypeInt, const std::string &deviceType, bool enabled) override; /** * @brief Query the channel switch for collaborative reminders. @@ -1065,7 +1083,7 @@ public: * @return Returns channel switch result. */ ErrCode IsDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) override; + int32_t slotTypeInt, const std::string &deviceType, bool &enabled) override; /** * @brief Set the status of the target device. @@ -1074,8 +1092,8 @@ public: * @param status The status. * @return Returns set result. */ - ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const std::string deveiceId = std::string()) override; + ErrCode SetTargetDeviceStatus(const std::string &deviceType, uint32_t status, + const std::string &deveiceId) override; /** * @brief Set the status of the target device. @@ -1084,8 +1102,8 @@ public: * @param status The status. * @return Returns set result. */ - ErrCode SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const uint32_t controlFlag, const std::string deveiceId = std::string()) override; + ErrCode SetTargetDeviceStatus(const std::string &deviceType, uint32_t status, + uint32_t controlFlag, const std::string &deveiceId) override; /** * @brief clear notification when aggregate local switch close. @@ -1545,6 +1563,23 @@ private: const bool innerLake); void ClearSlotTypeData(const sptr &request, int32_t callingUid); + template + bool WriteParcelableVector(const std::vector> &parcelableVector, MessageParcel &data) + { + if (!data.WriteInt32(parcelableVector.size())) { + ANS_LOGE("Failed to write ParcelableVector size."); + return false; + } + + for (auto &parcelable : parcelableVector) { + if (!data.WriteStrongParcelable(parcelable)) { + ANS_LOGE("Failed to write ParcelableVector"); + return false; + } + } + return true; + } + private: static sptr instance_; static std::mutex instanceMutex_; diff --git a/services/ans/include/disturb_manager/disturb_manager.h b/services/ans/include/disturb_manager/disturb_manager.h index ae924d0e687c7a7f0da2c13697cd07e5a4be0f80..481932fe9093bedf44851b04b2c5b1e3570c90ef 100644 --- a/services/ans/include/disturb_manager/disturb_manager.h +++ b/services/ans/include/disturb_manager/disturb_manager.h @@ -19,7 +19,7 @@ #include #include -#include "ans_manager_interface.h" +#include "ians_manager.h" #include "base_manager.h" #include "distributed_notification_service_ipc_interface_code.h" #include "ians_subscriber_local_live_view.h" diff --git a/services/ans/include/slot_manager/slot_manager.h b/services/ans/include/slot_manager/slot_manager.h index 44087557434a8fe08ceb7d3df58c7febf68fd349..36e34e646dbc19bdb6324959131cc525093fca4f 100644 --- a/services/ans/include/slot_manager/slot_manager.h +++ b/services/ans/include/slot_manager/slot_manager.h @@ -19,7 +19,7 @@ #include #include -#include "ans_manager_interface.h" +#include "ians_manager.h" #include "base_manager.h" #include "distributed_notification_service_ipc_interface_code.h" #include "ians_subscriber_local_live_view.h" diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index dc555ec86a7e28896ca65f5f467e90b26f19c79f..46195854939d1d4be7f9708083307d28ebc8219f 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -104,6 +104,12 @@ ErrCode AdvancedNotificationService::SetDefaultNotificationEnabled( return result; } +ErrCode AdvancedNotificationService::PublishWithMaxCapacity( + const std::string& label, const sptr& request) +{ + return Publish(label, request); +} + ErrCode AdvancedNotificationService::Publish(const std::string &label, const sptr &request) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); @@ -295,6 +301,12 @@ ErrCode AdvancedNotificationService::CollaboratePublish(const sptr& request) +{ + return PublishNotificationForIndirectProxy(request); +} + ErrCode AdvancedNotificationService::PublishNotificationForIndirectProxy(const sptr &request) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); @@ -671,11 +683,17 @@ ErrCode AdvancedNotificationService::CancelAsBundleWithAgent( } ErrCode AdvancedNotificationService::PublishAsBundle( - const sptr notification, const std::string &representativeBundle) + const sptr& notification, const std::string &representativeBundle) { return ERR_INVALID_OPERATION; } +ErrCode AdvancedNotificationService::PublishAsBundleWithMaxCapacity( + const sptr& notification, const std::string &representativeBundle) +{ + return PublishAsBundle(notification, representativeBundle); +} + ErrCode AdvancedNotificationService::SetNotificationBadgeNum(int32_t num) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -1028,6 +1046,12 @@ ErrCode AdvancedNotificationService::GetShowBadgeEnabled(bool &enabled) return result; } +ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string &deviceId, + const sptr &callback) +{ + return RequestEnableNotification(deviceId, callback, nullptr); +} + ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string &deviceId, const sptr &callback, const sptr &callerToken) @@ -1045,7 +1069,7 @@ ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string return CommonRequestEnableNotification(deviceId, callback, callerToken, bundleOption, false); } -ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string bundleName, const int32_t uid) +ErrCode AdvancedNotificationService::RequestEnableNotification(const std::string& bundleName, int32_t uid) { ANS_LOGI("RequestEnableNotification bundleName = %{public}s uid = %{public}d", bundleName.c_str(), uid); if (!AccessTokenHelper::CheckPermission(OHOS_PERMISSION_NOTIFICATION_CONTROLLER)) { @@ -2384,7 +2408,7 @@ ErrCode AdvancedNotificationService::RemoveNotificationFromRecordList( return result; } -ErrCode AdvancedNotificationService::IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) +ErrCode AdvancedNotificationService::IsSpecialUserAllowedNotify(int32_t userId, bool &allowed) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -2412,7 +2436,7 @@ ErrCode AdvancedNotificationService::IsSpecialUserAllowedNotify(const int32_t &u return result; } -ErrCode AdvancedNotificationService::SetNotificationsEnabledByUser(const int32_t &userId, bool enabled) +ErrCode AdvancedNotificationService::SetNotificationsEnabledByUser(int32_t userId, bool enabled) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -2782,6 +2806,12 @@ ErrCode AdvancedNotificationService::SetBadgeNumberByBundle( return result; } +ErrCode AdvancedNotificationService::SubscribeLocalLiveView( + const sptr &subscriber, const bool isNative) +{ + return SubscribeLocalLiveView(subscriber, nullptr, isNative); +} + ErrCode AdvancedNotificationService::SubscribeLocalLiveView( const sptr &subscriber, const sptr &info, const bool isNative) @@ -2892,9 +2922,10 @@ ErrCode AdvancedNotificationService::IsDistributedEnabledByBundle(const sptr(slotTypeInt); HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_8, EventBranchId::BRANCH_7); bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubsystem && !AccessTokenHelper::IsSystemApp()) { @@ -2924,10 +2955,10 @@ ErrCode AdvancedNotificationService::SetDistributedEnabledBySlot( } ErrCode AdvancedNotificationService::IsDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) + int32_t slotTypeInt, const std::string &deviceType, bool &enabled) { ANS_LOGD("%{public}s", __FUNCTION__); - + NotificationConstant::SlotType slotType = static_cast(slotTypeInt); bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubsystem && !AccessTokenHelper::IsSystemApp()) { ANS_LOGD("IsSystemApp is bogus."); @@ -3099,8 +3130,8 @@ ErrCode AdvancedNotificationService::IsSmartReminderEnabled(const std::string &d return NotificationPreferences::GetInstance()->IsSmartReminderEnabled(deviceType, enabled); } -ErrCode AdvancedNotificationService::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const std::string deveiceId) +ErrCode AdvancedNotificationService::SetTargetDeviceStatus(const std::string &deviceType, uint32_t status, + const std::string &deveiceId) { ANS_LOGD("%{public}s", __FUNCTION__); uint32_t status_ = status; @@ -3119,8 +3150,8 @@ ErrCode AdvancedNotificationService::SetTargetDeviceStatus(const std::string &de return ERR_OK; } -ErrCode AdvancedNotificationService::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const uint32_t controlFlag, const std::string deveiceId) +ErrCode AdvancedNotificationService::SetTargetDeviceStatus(const std::string &deviceType, uint32_t status, + uint32_t controlFlag, const std::string &deveiceId) { ANS_LOGD("%{public}s", __FUNCTION__); if (deviceType.empty()) { diff --git a/services/ans/src/advanced_notification_reminder_service.cpp b/services/ans/src/advanced_notification_reminder_service.cpp index 1156fd627bed3cadef536550dbe5e901495887b3..6471d8cd67e64840938c4c7aa4fe2d95ab3791b9 100644 --- a/services/ans/src/advanced_notification_reminder_service.cpp +++ b/services/ans/src/advanced_notification_reminder_service.cpp @@ -83,7 +83,7 @@ NotificationConstant::RemindType AdvancedNotificationService::GetRemindType() } #endif -ErrCode AdvancedNotificationService::GetDeviceRemindType(NotificationConstant::RemindType &remindType) +ErrCode AdvancedNotificationService::GetDeviceRemindType(int32_t& remindTypeInt) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -101,7 +101,8 @@ ErrCode AdvancedNotificationService::GetDeviceRemindType(NotificationConstant::R ANS_LOGE("Serial queue is invalid."); return ERR_ANS_INVALID_PARAM; } - ffrt::task_handle handler = notificationSvrQueue_->submit_h(std::bind([&]() { remindType = GetRemindType(); })); + ffrt::task_handle handler = + notificationSvrQueue_->submit_h(std::bind([&]() { remindTypeInt = static_cast(GetRemindType()); })); notificationSvrQueue_->wait(handler); return ERR_OK; #else diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 0e9a198a490633e06416647c0b7a6b88a662931e..1d3ee8f5cfb89260d40dbee9bc3bd56eb9d98f01 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1585,10 +1585,11 @@ ErrCode AdvancedNotificationService::GetAllActiveNotifications(std::vector> ¬ifications, - const NotificationConstant::SlotType slotType) + int32_t slotTypeInt) { ANS_LOGD("%{public}s", __FUNCTION__); + NotificationConstant::SlotType slotType = static_cast(slotTypeInt); bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubsystem && !AccessTokenHelper::IsSystemApp()) { return ERR_ANS_NON_SYSTEM_APP; @@ -1936,7 +1937,7 @@ ErrCode AdvancedNotificationService::IsDistributedEnableByBundle( #endif } -ErrCode AdvancedNotificationService::SetDoNotDisturbDate(const int32_t &userId, +ErrCode AdvancedNotificationService::SetDoNotDisturbDate(int32_t userId, const sptr &date) { ANS_LOGD("%{public}s", __FUNCTION__); @@ -1958,7 +1959,7 @@ ErrCode AdvancedNotificationService::SetDoNotDisturbDate(const int32_t &userId, return SetDoNotDisturbDateByUser(userId, date); } -ErrCode AdvancedNotificationService::GetDoNotDisturbDate(const int32_t &userId, +ErrCode AdvancedNotificationService::GetDoNotDisturbDate(int32_t userId, sptr &date) { ANS_LOGD("%{public}s", __FUNCTION__); diff --git a/services/ans/src/advanced_notification_slot_service.cpp b/services/ans/src/advanced_notification_slot_service.cpp index 026b75455e0737e5ff542600664592be3fc05992..ce0d25012ed8e345c41114ce73a92adffd832ff6 100644 --- a/services/ans/src/advanced_notification_slot_service.cpp +++ b/services/ans/src/advanced_notification_slot_service.cpp @@ -165,11 +165,11 @@ ErrCode AdvancedNotificationService::GetSlotsByBundle( } ErrCode AdvancedNotificationService::GetSlotByBundle( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, + const sptr &bundleOption, int32_t slotTypeInt, sptr &slot) { ANS_LOGD("%{public}s", __FUNCTION__); - + NotificationConstant::SlotType slotType = static_cast(slotTypeInt); bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubsystem && !AccessTokenHelper::IsSystemApp()) { ANS_LOGD("IsSystemApp is false."); @@ -300,9 +300,10 @@ ErrCode AdvancedNotificationService::RemoveAllSlots() return result; } -ErrCode AdvancedNotificationService::AddSlotByType(NotificationConstant::SlotType slotType) +ErrCode AdvancedNotificationService::AddSlotByType(int32_t slotTypeInt) { ANS_LOGD("%{public}s", __FUNCTION__); + NotificationConstant::SlotType slotType = static_cast(slotTypeInt); if (!AccessTokenHelper::IsSystemApp() && slotType == NotificationConstant::SlotType::EMERGENCY_INFORMATION) { ANS_LOGE("Non system app used illegal slot type."); @@ -342,9 +343,9 @@ ErrCode AdvancedNotificationService::AddSlotByType(NotificationConstant::SlotTyp return result; } -ErrCode AdvancedNotificationService::GetEnabledForBundleSlotSelf( - const NotificationConstant::SlotType &slotType, bool &enabled) +ErrCode AdvancedNotificationService::GetEnabledForBundleSlotSelf(int32_t slotTypeInt, bool &enabled) { + NotificationConstant::SlotType slotType = static_cast(slotTypeInt); ANS_LOGD("slotType: %{public}d", slotType); sptr bundleOption = GenerateBundleOption(); @@ -651,11 +652,10 @@ void AdvancedNotificationService::SetRequestBySlotType(const sptrGetClassification().c_str()); } -ErrCode AdvancedNotificationService::GetSlotByType( - const NotificationConstant::SlotType &slotType, sptr &slot) +ErrCode AdvancedNotificationService::GetSlotByType(int32_t slotTypeInt, sptr &slot) { ANS_LOGD("%{public}s", __FUNCTION__); - + NotificationConstant::SlotType slotType = static_cast(slotTypeInt); sptr bundleOption = GenerateBundleOption(); if (bundleOption == nullptr) { ANS_LOGD("Failed to generateBundleOption."); @@ -675,10 +675,11 @@ ErrCode AdvancedNotificationService::GetSlotByType( return ERR_OK; } -ErrCode AdvancedNotificationService::RemoveSlotByType(const NotificationConstant::SlotType &slotType) +ErrCode AdvancedNotificationService::RemoveSlotByType(int32_t slotTypeInt) { ANS_LOGD("%{public}s", __FUNCTION__); + NotificationConstant::SlotType slotType = static_cast(slotTypeInt); sptr bundleOption = GenerateBundleOption(); if (bundleOption == nullptr) { return ERR_ANS_INVALID_BUNDLE; @@ -810,9 +811,10 @@ ErrCode AdvancedNotificationService::SetEnabledForBundleSlotInner( } ErrCode AdvancedNotificationService::SetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) + int32_t slotTypeInt, bool enabled, bool isForceControl) { HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__); + NotificationConstant::SlotType slotType = static_cast(slotTypeInt); ANS_LOGD("slotType: %{public}d, enabled: %{public}d, isForceControl: %{public}d", slotType, enabled, isForceControl); ErrCode result = CheckCommonParams(); @@ -843,8 +845,9 @@ ErrCode AdvancedNotificationService::SetEnabledForBundleSlot(const sptr &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled) + const sptr &bundleOption, int32_t slotTypeInt, bool &enabled) { + NotificationConstant::SlotType slotType = static_cast(slotTypeInt); ANS_LOGD("slotType: %{public}d", slotType); bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); diff --git a/services/ans/src/advanced_notification_subscriber_service.cpp b/services/ans/src/advanced_notification_subscriber_service.cpp index 7f53b43331c43a1a64845972bfb6491d163f97d1..64cf49ffa0f0766d8a2afaaad2b62ea98295cc77 100644 --- a/services/ans/src/advanced_notification_subscriber_service.cpp +++ b/services/ans/src/advanced_notification_subscriber_service.cpp @@ -41,6 +41,11 @@ namespace OHOS { namespace Notification { +ErrCode AdvancedNotificationService::Subscribe(const sptr &subscriber) +{ + return Subscribe(subscriber, nullptr); +} + ErrCode AdvancedNotificationService::Subscribe( const sptr &subscriber, const sptr &info) { @@ -132,6 +137,11 @@ ErrCode AdvancedNotificationService::SubscribeSelf(const sptr &s return errCode; } +ErrCode AdvancedNotificationService::Unsubscribe(const sptr &subscriber) +{ + return Unsubscribe(subscriber, nullptr); +} + ErrCode AdvancedNotificationService::Unsubscribe( const sptr &subscriber, const sptr &info) { diff --git a/services/ans/src/advanced_notification_utils.cpp b/services/ans/src/advanced_notification_utils.cpp index 14b20eaf1427b0cbbfdcb7f0dc1fe0e5ee3d11aa..9ff9266b4a132fc85dc613868398197abfced9a8 100644 --- a/services/ans/src/advanced_notification_utils.cpp +++ b/services/ans/src/advanced_notification_utils.cpp @@ -278,8 +278,8 @@ ErrCode AdvancedNotificationService::IsAllowedGetNotificationByFilter( } ErrCode AdvancedNotificationService::GetActiveNotificationByFilter( - const sptr &bundleOption, const int32_t notificationId, const std::string &label, - const std::vector extraInfoKeys, sptr &request) + const sptr &bundleOption, int32_t notificationId, const std::string &label, + const std::vector &extraInfoKeys, sptr &request) { ANS_LOGD("%{public}s", __FUNCTION__); ANS_LOGD("%{public}s", __FUNCTION__); @@ -1442,7 +1442,7 @@ void AdvancedNotificationService::OnUserRemoved(const int32_t &userId) DeleteAllByUserInner(userId, NotificationConstant::USER_REMOVED_REASON_DELETE, true); } -ErrCode AdvancedNotificationService::DeleteAllByUser(const int32_t &userId) +ErrCode AdvancedNotificationService::DeleteAllByUser(int32_t userId) { bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); if (!isSubsystem && !AccessTokenHelper::IsSystemApp()) { diff --git a/services/ans/src/ans_manager_stub.cpp b/services/ans/src/ans_manager_stub.cpp deleted file mode 100644 index 9465a24823b53a8e1e609f1fb23d55c40822cd25..0000000000000000000000000000000000000000 --- a/services/ans/src/ans_manager_stub.cpp +++ /dev/null @@ -1,2743 +0,0 @@ -/* - * Copyright (c) 2021-2025 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_manager_stub.h" -#include "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "disturb_manager.h" -#include "ians_subscriber_local_live_view.h" -#include "message_option.h" -#include "message_parcel.h" -#include "notification_bundle_option.h" -#include "notification_button_option.h" -#include "parcel.h" -#include "reminder_request_alarm.h" -#include "reminder_request_calendar.h" -#include "reminder_request_timer.h" -#include "slot_manager.h" - -namespace OHOS { -namespace Notification { -AnsManagerStub::AnsManagerStub() {} - -AnsManagerStub::~AnsManagerStub() {} - -int32_t AnsManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &flags) -{ - std::u16string descriptor = AnsManagerStub::GetDescriptor(); - std::u16string remoteDescriptor = data.ReadInterfaceToken(); - if (descriptor != remoteDescriptor) { - ANS_LOGE("[OnRemoteRequest] fail: invalid interface token!"); - return OBJECT_NULL; - } - ANS_LOGE("[OnRemoteRequest] called"); - ErrCode result = NO_ERROR; - switch (code) { - case static_cast(NotificationInterfaceCode::PUBLISH_NOTIFICATION): { - result = HandlePublish(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::PUBLISH_NOTIFICATION_INDIRECTPROXY): { - result = HandlePublishNotificationForIndirectProxy(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::CANCEL_NOTIFICATION): { - result = HandleCancel(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::CANCEL_ALL_NOTIFICATIONS): { - result = HandleCancelAll(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE_OPTION): { - result = HandleCancelAsBundleOption(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE_AND_USER): { - result = HandleCancelAsBundleAndUser(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE): { - result = HandleCancelAsBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::ADD_SLOT_BY_TYPE): { - result = HandleAddSlotByType(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::ADD_SLOTS): - case static_cast(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT): { - result = DelayedSingleton::GetInstance()->OnRemoteRequest(code, data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REMOVE_SLOT_BY_TYPE): { - result = HandleRemoveSlotByType(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REMOVE_ALL_SLOTS): { - result = HandleRemoveAllSlots(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SLOT_BY_TYPE): { - result = HandleGetSlotByType(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SLOTS): { - result = HandleGetSlots(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SLOT_NUM_AS_BUNDLE): { - result = HandleGetSlotNumAsBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATIONS): { - result = HandleGetActiveNotifications(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_NUMS): { - result = HandleGetActiveNotificationNums(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_ALL_ACTIVE_NOTIFICATIONS): { - result = HandleGetAllActiveNotifications(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SPECIAL_ACTIVE_NOTIFICATIONS): { - result = HandleGetSpecialActiveNotifications(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_BY_FILTER): { - result = HandleGetActiveNotificationByFilter(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::CAN_PUBLISH_AS_BUNDLE): { - result = HandleCanPublishAsBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::PUBLISH_AS_BUNDLE): { - result = HandlePublishAsBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_NOTIFICATION_BADGE_NUM): { - result = HandleSetNotificationBadgeNum(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_BUNDLE_IMPORTANCE): { - result = HandleGetBundleImportance(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::IS_NOTIFICATION_POLICY_ACCESS_GRANTED): { - result = HandleIsNotificationPolicyAccessGranted(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REMOVE_NOTIFICATION): { - result = HandleRemoveNotification(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REMOVE_ALL_NOTIFICATIONS): { - result = HandleRemoveAllNotifications(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REMOVE_NOTIFICATIONS_BY_KEYS): { - result = HandleRemoveNotifications(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::DELETE_NOTIFICATION): { - result = HandleDelete(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::DELETE_NOTIFICATION_BY_BUNDLE): { - result = HandleDeleteByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS): { - result = HandleDeleteAll(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SLOTS_BY_BUNDLE): { - result = HandleGetSlotsByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::UPDATE_SLOTS): { - result = HandleUpdateSlots(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION): { - result = HandleRequestEnableNotification(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION_BY_BUNDLE): { - result = HandleRequestEnableNotificationByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_BUNDLE): { - result = HandleSetNotificationsEnabledForBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE): { - result = HandleSetNotificationsEnabledForAllBundles(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE): { - result = HandleSetNotificationsEnabledForSpecialBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE): { - result = HandleSetShowBadgeEnabledForBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED_FOR_BUNDLE): { - result = HandleGetShowBadgeEnabledForBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED): { - result = HandleGetShowBadgeEnabled(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION): { - result = HandleSubscribe(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION): { - result = HandleUnsubscribe(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::IS_ALLOWED_NOTIFY): { - result = HandleIsAllowedNotify(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::IS_ALLOWED_NOTIFY_SELF): { - result = HandleIsAllowedNotifySelf(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::CAN_POP_ENABLE_NOTIFICATION_DIALOG): { - result = HandleCanPopEnableNotificationDialog(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REMOVE_ENABLE_NOTIFICATION_DIALOG): { - result = HandleRemoveEnableNotificationDialog(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::IS_SPECIAL_BUNDLE_ALLOWED_NOTIFY): { - result = HandleIsSpecialBundleAllowedNotify(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE): - case static_cast(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE): - case static_cast(NotificationInterfaceCode::DOES_SUPPORT_DO_NOT_DISTURB_MODE): { - result = DelayedSingleton::GetInstance()->OnRemoteRequest(code, data, reply); - break; - } - case static_cast(NotificationInterfaceCode::IS_NEED_SILENT_IN_DO_NOT_DISTURB_MODE): { - result = HandleIsNeedSilentInDoNotDisturbMode(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::CANCEL_GROUP): { - result = HandleCancelGroup(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REMOVE_GROUP_BY_BUNDLE): { - result = HandleRemoveGroupByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED): { - result = HandleIsDistributedEnabled(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::ENABLE_DISTRIBUTED): { - result = HandleEnableDistributed(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::ENABLE_DISTRIBUTED_BY_BUNDLE): { - result = HandleEnableDistributedByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::ENABLE_DISTRIBUTED_SELF): { - result = HandleEnableDistributedSelf(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED_BY_BUNDLE): { - result = HandleIsDistributedEnableByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_DEVICE_REMIND_TYPE): { - result = HandleGetDeviceRemindType(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SHELL_DUMP): { - result = HandleShellDump(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::PUBLISH_CONTINUOUS_TASK_NOTIFICATION): { - result = HandlePublishContinuousTaskNotification(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::CANCEL_CONTINUOUS_TASK_NOTIFICATION): { - result = HandleCancelContinuousTaskNotification(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::IS_SUPPORT_TEMPLATE): { - result = HandleIsSupportTemplate(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::IS_SPECIAL_USER_ALLOWED_NOTIFY): { - result = HandleIsSpecialUserAllowedNotifyByUser(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER): { - result = HandleSetNotificationsEnabledByUser(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER): { - result = HandleDeleteAllByUser(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE_BY_USER): - case static_cast(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE_BY_USER): { - result = DelayedSingleton::GetInstance()->OnRemoteRequest(code, data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT): { - result = HandleGetEnabledForBundleSlot(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT_SELF): { - result = HandleGetEnabledForBundleSlotSelf(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_DISTRIBUTED_ENABLED_BY_BUNDLE): { - result = HandleSetDistributedEnabledByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_DISTRIBUTED_ENABLED_BY_BUNDLE): { - result = HandleIsDistributedEnabledByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_SMART_REMINDER_ENABLED): { - result = HandleSetSmartReminderEnabled(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SMART_REMINDER_ENABLED): { - result = HandleIsSmartReminderEnabled(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_DISTRIBUTED_ENABLED_BY_SLOT): { - result = HandleSetDistributedEnabledBySlot(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_DISTRIBUTED_ENABLED_BY_SLOT): { - result = HandleIsDistributedEnabledBySlot(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP): { - result = HandleDistributedSetEnabledWithoutApp(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP): { - result = HandleDistributedGetEnabledWithoutApp(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_BADGE_NUMBER): { - result = HandleSetBadgeNumber(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_BADGE_NUMBER_BY_BUNDLE): { - result = HandleSetBadgeNumberByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_BADGE_NUMBER_FOR_DH_BY_BUNDLE): { - result = HandleSetBadgeNumberForDhByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_ALL_NOTIFICATION_ENABLE_STATUS): { - result = HandleGetAllNotificationEnableStatus(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_ALL_LIVEVIEW_ENABLE_STATUS): { - result = HandleGetAllLiveViewEnabledBundles(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_ALL_DISTRIBUTED_ENABLE_STATUS): { - result = HandleGetAllDistributedEnabledBundles(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REGISTER_PUSH_CALLBACK): { - result = HandleRegisterPushCallback(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::UNREGISTER_PUSH_CALLBACK): { - result = HandleUnregisterPushCallback(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SUBSCRIBE_LOCAL_LIVE_VIEW_NOTIFICATION): { - result = HandleSubscribeLocalLiveView(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_NOTIFICATION): { - result = HandleTriggerLocalLiveView(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION_SELF): { - result = HandleSubscribeSelf(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_SLOTFLAGS_BY_BUNDLE): { - result = HandleSetSlotFlagsAsBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SLOTFLAGS_BY_BUNDLE): { - result = HandleGetSlotFlagsAsBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_NOTIFICATION_AGENT_RELATIONSHIP): { - result = HandleSetAdditionConfig(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE_WITH_AGENT): { - result = HandleCancelAsBundleWithAgent(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_SLOT_BY_BUNDLE): { - result = HandleGetSlotByBundle(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::ADD_DO_NOTDISTURB_PROFILES): - case static_cast(NotificationInterfaceCode::REMOVE_DO_NOT_DISTURB_PROFILES): { - result = DelayedSingleton::GetInstance()->OnRemoteRequest(code, data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS): { - result = HandleSetTargetDeviceStatus(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS_WITH_FLAG): { - result = HandleSetDeviceStatus(data, reply); - break; - } -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED - case static_cast(NotificationInterfaceCode::REGISTER_SWING_CALLBACK): { - result = HandleRegisterSwingCallback(data, reply); - break; - } -#endif - case static_cast(NotificationInterfaceCode::GET_DONOTDISTURB_PROFILE): { - result = DelayedSingleton::GetInstance()->OnRemoteRequest(code, data, reply); - break; - } - case static_cast(NotificationInterfaceCode::UPDATE_NOTIFICATION_TIMER): { - result = HandleUpdateNotificationTimerByUid(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::ALLOW_USE_REMINDER): { - result = HandleAllowUseReminder(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::DISABLE_NOTIFICATION_FEATURE): { - result = HandleDisableNotificationFeature(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_TARGET_DEVICE_STATUS): { - result = HandleGetDeviceStatus(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_NOTIFICATION_REQUEST_BY_HASHCODE): { - result = HandleGetNotificationRequest(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::Set_HASH_CODE_RULE): { - result = HandleSetHashCodeRule(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::GET_ALL_NOTIFICATIONS_BY_SLOTTYPE): { - result = HandleGetAllNotificationsBySlotType(data, reply); - break; - } - case static_cast(NotificationInterfaceCode::REPLY_DISTRIBUTE_OPERATION): { - result = HandleReplyDistributeOperation(data, reply); - break; - } - default: { - ANS_LOGE("[OnRemoteRequest] fail: unknown code!"); - return IPCObjectStub::OnRemoteRequest(code, data, reply, flags); - } - } - if (SUCCEEDED(result)) { - return NO_ERROR; - } - - ANS_LOGE("[OnRemoteRequest] fail: Failed to call interface %{public}u, err:%{public}d", code, result); - return result; -} - -ErrCode AnsManagerStub::HandlePublish(MessageParcel &data, MessageParcel &reply) -{ - std::string label; - if (!data.ReadString(label)) { - ANS_LOGE("[HandlePublish] fail: read label failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr notification = data.ReadParcelable(); - if (!notification) { - ANS_LOGE("[HandlePublish] fail: notification ReadParcelable failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = Publish(label, notification); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandlePublish] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandlePublishNotificationForIndirectProxy(MessageParcel &data, MessageParcel &reply) -{ - sptr notification = data.ReadParcelable(); - if (!notification) { - ANS_LOGE("[HandlePublishNotificationForIndirectProxy] fail: notification ReadParcelable failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = PublishNotificationForIndirectProxy(notification); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandlePublishNotificationForIndirectProxy] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleCancel(MessageParcel &data, MessageParcel &reply) -{ - int32_t notificationId = 0; - if (!data.ReadInt32(notificationId)) { - ANS_LOGE("[HandleCancel] fail: read notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string label; - if (!data.ReadString(label)) { - ANS_LOGE("[HandleCancel] fail: read label failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string appInstanceKey; - if (!data.ReadString(appInstanceKey)) { - ANS_LOGE("[HandleCancel] fail: read InstanceKey failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = Cancel(notificationId, label, appInstanceKey); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleCancel] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleCancelAll(MessageParcel &data, MessageParcel &reply) -{ - std::string appInstanceKey; - if (!data.ReadString(appInstanceKey)) { - ANS_LOGE("[HandleCancelAll] fail: read instanceKey failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = CancelAll(appInstanceKey); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleCancelAll] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleCancelAsBundleOption(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleCancelAsBundle] fail: read BundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - int32_t notificationId = 0; - if (!data.ReadInt32(notificationId)) { - ANS_LOGE("[HandleCancelAsBundle] fail: read notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - ErrCode result = CancelAsBundle(bundleOption, notificationId); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleCancelAsBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleCancelAsBundle(MessageParcel &data, MessageParcel &reply) -{ - int32_t notificationId = 0; - if (!data.ReadInt32(notificationId)) { - ANS_LOGE("[HandleCancelAsBundle] fail: read notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string representativeBundle; - if (!data.ReadString(representativeBundle)) { - ANS_LOGE("[HandleCancelAsBundle] fail: read representativeBundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t userId = 0; - if (!data.ReadInt32(userId)) { - ANS_LOGE("[HandleCancelAsBundle] fail: read userId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = CancelAsBundle(notificationId, representativeBundle, userId); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleCancelAsBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleCancelAsBundleAndUser(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleCancelAsBundle] fail: read BundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - int32_t notificationId = 0; - if (!data.ReadInt32(notificationId)) { - ANS_LOGE("[HandleCancelAsBundle] fail: read notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t userId = 0; - if (!data.ReadInt32(userId)) { - ANS_LOGE("[HandleCancelAsBundle] fail: read userId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - ErrCode result = CancelAsBundle(bundleOption, notificationId, userId); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleCancelAsBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleAddSlotByType(MessageParcel &data, MessageParcel &reply) -{ - NotificationConstant::SlotType slotType = static_cast(data.ReadInt32()); - ErrCode result = AddSlotByType(slotType); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleAddSlotByType] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleAddSlots(MessageParcel &data, MessageParcel &reply) -{ - std::vector> slots; - if (!ReadParcelableVector(slots, data)) { - ANS_LOGE("[HandleAddSlots] fail: read slotsSize failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - ErrCode result = AddSlots(slots); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleAddSlots] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRemoveSlotByType(MessageParcel &data, MessageParcel &reply) -{ - NotificationConstant::SlotType slotType = static_cast(data.ReadInt32()); - - ErrCode result = RemoveSlotByType(slotType); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleRemoveSlotByType] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRemoveAllSlots(MessageParcel &data, MessageParcel &reply) -{ - ErrCode result = RemoveAllSlots(); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleRemoveAllSlots] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetSlots(MessageParcel &data, MessageParcel &reply) -{ - std::vector> slots; - ErrCode result = GetSlots(slots); - if (!WriteParcelableVector(slots, reply, result)) { - ANS_LOGE("[HandleGetSlots] fail: write slots failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetSlotByType(MessageParcel &data, MessageParcel &reply) -{ - NotificationConstant::SlotType slotType = static_cast(data.ReadInt32()); - - sptr slot = nullptr; - ErrCode result = GetSlotByType(slotType, slot); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetSlotByType] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteParcelable(slot)) { - ANS_LOGE("[HandleGetSlotByType] fail: write slot failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetSlotNumAsBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleGetSlotNumAsBundle] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - uint64_t num = 0; - ErrCode result = GetSlotNumAsBundle(bundleOption, num); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetSlotNumAsBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteUint64(num)) { - ANS_LOGE("[HandleGetSlotNumAsBundle] fail: write enabled failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetSlotFlagsAsBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleSetSlotFlagsAsBundle] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t slotFlags = 0; - if (!data.ReadInt32(slotFlags)) { - ANS_LOGE("[HandleSetSlotFlagsAsBundle] fail: read notification failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetSlotFlagsAsBundle(bundleOption, slotFlags); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetSlotFlagsAsBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetSlotFlagsAsBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleGetSlotFlagsAsBundle] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - uint32_t slotFlags = 0; - ErrCode result = GetSlotFlagsAsBundle(bundleOption, slotFlags); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetSlotFlagsAsBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteUint32(slotFlags)) { - ANS_LOGE("[HandleGetSlotFlagsAsBundle] fail: write enabled failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetActiveNotifications(MessageParcel &data, MessageParcel &reply) -{ - std::string appInstanceKey; - if (!data.ReadString(appInstanceKey)) { - ANS_LOGE("[HandleGetActiveNotifications] fail: read instanceKey failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - std::vector> notifications; - ErrCode result = GetActiveNotifications(notifications, appInstanceKey); - if (!WriteParcelableVector(notifications, reply, result)) { - ANS_LOGE("[HandleGetActiveNotifications] fail: write notifications failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetActiveNotificationNums(MessageParcel &data, MessageParcel &reply) -{ - uint64_t num = 0; - ErrCode result = GetActiveNotificationNums(num); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetActiveNotificationNums] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteUint64(num)) { - ANS_LOGE("[HandleGetActiveNotificationNums] fail: write num failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetAllActiveNotifications(MessageParcel &data, MessageParcel &reply) -{ - std::vector> notifications; - ErrCode result = GetAllActiveNotifications(notifications); - - if (!reply.SetMaxCapacity(NotificationConstant::NOTIFICATION_MAX_LIVE_VIEW_SIZE)) { - return ERR_ANS_PARCELABLE_FAILED; - } - if (!WriteParcelableVector(notifications, reply, result)) { - ANS_LOGE("[HandleGetAllActiveNotifications] fail: write notifications failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetSpecialActiveNotifications(MessageParcel &data, MessageParcel &reply) -{ - std::vector key; - if (!data.ReadStringVector(&key)) { - ANS_LOGE("[HandleGetSpecialActiveNotifications] fail: read key failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::vector> notifications; - ErrCode result = GetSpecialActiveNotifications(key, notifications); - if (!WriteParcelableVector(notifications, reply, result)) { - ANS_LOGE("[HandleGetSpecialActiveNotifications] fail: write notifications failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetActiveNotificationByFilter(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: read bundleOption failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t notificationId = 0; - if (!data.ReadInt32(notificationId)) { - ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: read notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string label; - if (!data.ReadString(label)) { - ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: read label failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::vector extraInfoKeys; - if (!data.ReadStringVector(&extraInfoKeys)) { - ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: read extraInfoKeys failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr request; - ErrCode result = GetActiveNotificationByFilter(bundleOption, notificationId, label, extraInfoKeys, request); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteParcelable(request)) { - ANS_LOGE("[HandleGetActiveNotificationByFilter] fail: get extra info by filter failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerStub::HandleCanPublishAsBundle(MessageParcel &data, MessageParcel &reply) -{ - std::string representativeBundle; - if (!data.ReadString(representativeBundle)) { - ANS_LOGE("[HandleCanPublishAsBundle] fail: read representativeBundle failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool canPublish = false; - ErrCode result = CanPublishAsBundle(representativeBundle, canPublish); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleCanPublishAsBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(canPublish)) { - ANS_LOGE("[HandleCanPublishAsBundle] fail: write canPublish failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandlePublishAsBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr notification = data.ReadParcelable(); - if (!notification) { - ANS_LOGE("[HandlePublishAsBundle] fail: read notification failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string representativeBundle; - if (!data.ReadString(representativeBundle)) { - ANS_LOGE("[HandlePublishAsBundle] fail: read representativeBundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = PublishAsBundle(notification, representativeBundle); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandlePublishAsBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetNotificationBadgeNum(MessageParcel &data, MessageParcel &reply) -{ - int32_t num = 0; - if (!data.ReadInt32(num)) { - ANS_LOGE("[HandleSetNotificationBadgeNum] fail: read notification failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetNotificationBadgeNum(num); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetNotificationBadgeNum] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetBundleImportance(MessageParcel &data, MessageParcel &reply) -{ - int32_t importance = 0; - ErrCode result = GetBundleImportance(importance); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetBundleImportance] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteInt32(importance)) { - ANS_LOGE("[HandleGetBundleImportance] fail: write importance failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply) -{ - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply) -{ - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleDoesSupportDoNotDisturbMode(MessageParcel &data, MessageParcel &reply) -{ - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsNeedSilentInDoNotDisturbMode(MessageParcel &data, MessageParcel &reply) -{ - std::string phoneNumber; - if (!data.ReadString(phoneNumber)) { - ANS_LOGE("[HandleIsNeedSilentInDoNotDisturbMode] fail: read phoneNumber failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t callerType = 0; - if (!data.ReadInt32(callerType)) { - ANS_LOGE("[HandleIsNeedSilentInDoNotDisturbMode] fail: read callerType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsNeedSilentInDoNotDisturbMode] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandlePublishContinuousTaskNotification(MessageParcel &data, MessageParcel &reply) -{ - sptr request = data.ReadParcelable(); - if (!request) { - ANS_LOGE("[HandlePublishContinuousTaskNotification] fail: notification ReadParcelable failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = PublishContinuousTaskNotification(request); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandlePublishContinuousTaskNotification] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleCancelContinuousTaskNotification(MessageParcel &data, MessageParcel &reply) -{ - std::string label; - if (!data.ReadString(label)) { - ANS_LOGE("[HandleCancelContinuousTaskNotification] fail: read label failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t notificationId = 0; - if (!data.ReadInt32(notificationId)) { - ANS_LOGE("[HandleCancelContinuousTaskNotification] fail: read notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = CancelContinuousTaskNotification(label, notificationId); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleCancelContinuousTaskNotification] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsNotificationPolicyAccessGranted(MessageParcel &data, MessageParcel &reply) -{ - bool granted = false; - ErrCode result = HasNotificationPolicyAccessPermission(granted); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsNotificationPolicyAccessGranted] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(granted)) { - ANS_LOGE("[HandleIsNotificationPolicyAccessGranted] fail: write granted failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleTriggerLocalLiveView(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleTriggerLocalLiveView] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t notificationId = 0; - if (!data.ReadInt32(notificationId)) { - ANS_LOGE("[HandleTriggerLocalLiveView] fail: read notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr buttonOption = data.ReadStrongParcelable(); - if (buttonOption == nullptr) { - ANS_LOGE("[HandleTriggerLocalLiveView] fail: read button failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = TriggerLocalLiveView(bundleOption, notificationId, buttonOption); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleTriggerLocalLiveView] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRemoveNotification(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleRemoveNotification] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t notificationId = 0; - if (!data.ReadInt32(notificationId)) { - ANS_LOGE("[HandleRemoveNotification] fail: read notificationId failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string label; - if (!data.ReadString(label)) { - ANS_LOGE("[HandleRemoveNotification] fail: read label failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t removeReason = 0; - if (!data.ReadInt32(removeReason)) { - ANS_LOGE("[HandleRemoveNotification] fail: read removeReason failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = RemoveNotification(bundleOption, notificationId, label, removeReason); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleRemoveNotification] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRemoveAllNotifications(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleRemoveAllNotifications] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = RemoveAllNotifications(bundleOption); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleRemoveAllNotifications] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRemoveNotifications(MessageParcel &data, MessageParcel &reply) -{ - int32_t keysSize = 0; - if (!data.ReadInt32(keysSize)) { - ANS_LOGE("read keys size failed."); - return false; - } - - std::vector keys; - if (!data.ReadStringVector(&keys)) { - ANS_LOGE("read keys failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t removeReason = 0; - if (!data.ReadInt32(removeReason)) { - ANS_LOGE("read removeReason failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = RemoveNotifications(keys, removeReason); - if (!reply.WriteInt32(result)) { - ANS_LOGE("write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - - -ErrCode AnsManagerStub::HandleDelete(MessageParcel &data, MessageParcel &reply) -{ - std::string key; - if (!data.ReadString(key)) { - ANS_LOGE("[HandleDelete] fail: read key failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t removeReason = 0; - if (!data.ReadInt32(removeReason)) { - ANS_LOGE("[HandleDelete] fail: read removeReason failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = Delete(key, removeReason); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleDelete] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleDeleteByBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleDeleteByBundle] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = DeleteByBundle(bundleOption); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleDeleteByBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleDeleteAll(MessageParcel &data, MessageParcel &reply) -{ - ErrCode result = DeleteAll(); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleDeleteAll] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetSlotsByBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleGetSlotsByBundle] fail: read bundleOption failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::vector> slots; - ErrCode result = GetSlotsByBundle(bundleOption, slots); - if (!WriteParcelableVector(slots, reply, result)) { - ANS_LOGE("[HandleGetSlotsByBundle] fail: write slots failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetSlotByBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleGetSlotByBundle] fail: read bundleOption failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - NotificationConstant::SlotType slotType = static_cast(data.ReadInt32()); - - sptr slot = nullptr; - ErrCode result = GetSlotByBundle(bundleOption, slotType, slot); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetSlotByBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteParcelable(slot)) { - ANS_LOGE("[HandleGetSlotByBundle] fail: write slot failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleUpdateSlots(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleUpdateSlots] fail: read bundleOption failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::vector> slots; - if (!ReadParcelableVector(slots, data)) { - ANS_LOGE("[HandleUpdateSlots] fail: read slots failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = UpdateSlots(bundleOption, slots); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleUpdateSlots] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRequestEnableNotification(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("enter"); - std::string deviceId; - if (!data.ReadString(deviceId)) { - ANS_LOGE("[HandleRequestEnableNotification] fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr callback = data.ReadRemoteObject(); - if (callback == nullptr) { - ANS_LOGE("[HandleRequestEnableNotification] fail: read callback failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool hasCallerToken = false; - if (!data.ReadBool(hasCallerToken)) { - ANS_LOGE("fail: read hasCallerToken failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr callerToken = nullptr; - if (hasCallerToken) { - callerToken = data.ReadRemoteObject(); - } - - ErrCode result = RequestEnableNotification(deviceId, iface_cast(callback), callerToken); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleRequestEnableNotification] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRequestEnableNotificationByBundle(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("enter"); - std::string bundleName; - if (!data.ReadString(bundleName)) { - ANS_LOGE("[HandleRequestEnableNotificationByBundle] fail: read bundleName failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t uid = 0; - if (!data.ReadInt32(uid)) { - ANS_LOGE("[HandleRequestEnableNotificationByBundle] fail: read uid failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = RequestEnableNotification(bundleName, uid); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleRequestEnableNotificationByBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetNotificationsEnabledForBundle(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceId; - if (!data.ReadString(deviceId)) { - ANS_LOGE("[HandleSetNotificationsEnabledForBundle] fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleSetNotificationsEnabledForBundle] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetNotificationsEnabledForBundle(deviceId, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetNotificationsEnabledForBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetNotificationsEnabledForAllBundles(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceId; - if (!data.ReadString(deviceId)) { - ANS_LOGE("[HandleSetNotificationsEnabledForAllBundles] fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleSetNotificationsEnabledForAllBundles] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetNotificationsEnabledForAllBundles(deviceId, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetNotificationsEnabledForAllBundles] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetNotificationsEnabledForSpecialBundle(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceId; - if (!data.ReadString(deviceId)) { - ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read bundleOption failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetNotificationsEnabledForSpecialBundle(deviceId, bundleOption, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: write result failed, ErrCode=%{public}d", - result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleSetShowBadgeEnabledForBundle] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleSetShowBadgeEnabledForBundle] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetShowBadgeEnabledForBundle(bundleOption, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetShowBadgeEnabledForBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleGetShowBadgeEnabledForBundle] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - ErrCode result = GetShowBadgeEnabledForBundle(bundleOption, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetShowBadgeEnabledForBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(enabled)) { - ANS_LOGE("[HandleGetShowBadgeEnabledForBundle] fail: write enabled failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetShowBadgeEnabled(MessageParcel &data, MessageParcel &reply) -{ - bool enabled = false; - ErrCode result = GetShowBadgeEnabled(enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetShowBadgeEnabled] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(enabled)) { - ANS_LOGE("[HandleGetShowBadgeEnabled] fail: write enabled failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSubscribe(MessageParcel &data, MessageParcel &reply) -{ - sptr subscriber = data.ReadRemoteObject(); - if (subscriber == nullptr) { - ANS_LOGE("[HandleSubscribe] fail: read subscriber failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool subcribeInfo = false; - if (!data.ReadBool(subcribeInfo)) { - ANS_LOGE("[HandleSubscribe] fail: read isSubcribeInfo failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr info = nullptr; - if (subcribeInfo) { - info = data.ReadParcelable(); - if (info == nullptr) { - ANS_LOGE("[HandleSubscribe] fail: read info failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - ErrCode result = Subscribe(iface_cast(subscriber), info); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSubscribe] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSubscribeSelf(MessageParcel &data, MessageParcel &reply) -{ - sptr subscriber = data.ReadRemoteObject(); - if (subscriber == nullptr) { - ANS_LOGE("[HandleSubscribeSelf] fail: read subscriber failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SubscribeSelf(iface_cast(subscriber)); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSubscribeSelf] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSubscribeLocalLiveView(MessageParcel &data, MessageParcel &reply) -{ - sptr subscriber = data.ReadRemoteObject(); - if (subscriber == nullptr) { - ANS_LOGE("[HandleSubscribeLocalLiveView] fail: read subscriber failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool subcribeInfo = false; - if (!data.ReadBool(subcribeInfo)) { - ANS_LOGE("[HandleSubscribeLocalLiveView] fail: read isSubcribeInfo failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr info = nullptr; - if (subcribeInfo) { - info = data.ReadParcelable(); - if (info == nullptr) { - ANS_LOGE("[HandleSubscribeLocalLiveView] fail: read info failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - bool isNative = false; - if (!data.ReadBool(isNative)) { - ANS_LOGE("[HandleSubscribeLocalLiveView] fail: read isNative failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = - SubscribeLocalLiveView(iface_cast(subscriber), info, isNative); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSubscribeLocalLiveView] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleUnsubscribe(MessageParcel &data, MessageParcel &reply) -{ - sptr subscriber = data.ReadRemoteObject(); - if (subscriber == nullptr) { - ANS_LOGE("[HandleUnsubscribe] fail: read subscriber failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool subcribeInfo = false; - if (!data.ReadBool(subcribeInfo)) { - ANS_LOGE("[HandleUnsubscribe] fail: read isSubcribeInfo failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr info = nullptr; - if (subcribeInfo) { - info = data.ReadParcelable(); - if (info == nullptr) { - ANS_LOGE("[HandleUnsubscribe] fail: read info failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - ErrCode result = Unsubscribe(iface_cast(subscriber), info); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleUnsubscribe] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsAllowedNotify(MessageParcel &data, MessageParcel &reply) -{ - bool allowed = false; - ErrCode result = IsAllowedNotify(allowed); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsAllowedNotify] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(allowed)) { - ANS_LOGE("[HandleIsAllowedNotify] fail: write allowed failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsAllowedNotifySelf(MessageParcel &data, MessageParcel &reply) -{ - bool allowed = false; - ErrCode result = IsAllowedNotifySelf(allowed); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsAllowedNotifySelf] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(allowed)) { - ANS_LOGE("[HandleIsAllowedNotifySelf] fail: write allowed failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleCanPopEnableNotificationDialog(MessageParcel &data, MessageParcel &reply) -{ - sptr callback = data.ReadRemoteObject(); - if (callback == nullptr) { - ANS_LOGE("[HandleCanPopEnableNotificationDialog] fail: read callback failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - bool canPop = false; - std::string bundleName; - ErrCode result = CanPopEnableNotificationDialog(iface_cast(callback), canPop, bundleName); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleCanPopEnableNotificationDialog] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(canPop)) { - ANS_LOGE("[HandleCanPopEnableNotificationDialog] fail: write canPop failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!reply.WriteString(bundleName)) { - ANS_LOGE("[HandleCanPopEnableNotificationDialog] fail: write bundleName failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRemoveEnableNotificationDialog(MessageParcel &data, MessageParcel &reply) -{ - ErrCode result = RemoveEnableNotificationDialog(); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleRemoveEnableNotificationDialog] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsSpecialBundleAllowedNotify(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool allowed = false; - ErrCode result = IsSpecialBundleAllowedNotify(bundleOption, allowed); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(allowed)) { - ANS_LOGE("[IsSpecialBundleAllowedNotify] fail: write allowed failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleCancelGroup(MessageParcel &data, MessageParcel &reply) -{ - std::string groupName; - if (!data.ReadString(groupName)) { - ANS_LOGE("[HandleCancelGroup] fail: read groupName failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string appInstanceKey; - if (!data.ReadString(appInstanceKey)) { - ANS_LOGE("[HandleCancelGroup] fail: read instanceKey failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = CancelGroup(groupName, appInstanceKey); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleCancelGroup] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRemoveGroupByBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleRemoveGroupByBundle] fail: read bundleOption failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string groupName; - if (!data.ReadString(groupName)) { - ANS_LOGE("[HandleRemoveGroupByBundle] fail: read groupName failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = RemoveGroupByBundle(bundleOption, groupName); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleRemoveGroupByBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsDistributedEnabled(MessageParcel &data, MessageParcel &reply) -{ - bool enabled = false; - ErrCode result = IsDistributedEnabled(enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsDistributedEnabled] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(enabled)) { - ANS_LOGE("[HandleIsDistributedEnabled] fail: write enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleEnableDistributed(MessageParcel &data, MessageParcel &reply) -{ - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleEnableDistributed] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = EnableDistributed(enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleEnableDistributed] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleEnableDistributedByBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleEnableDistributedByBundle] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleEnableDistributedByBundle] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = EnableDistributedByBundle(bundleOption, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleEnableDistributedByBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleEnableDistributedSelf(MessageParcel &data, MessageParcel &reply) -{ - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleEnableDistributedSelf] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = EnableDistributedSelf(enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleEnableDistributedSelf] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsDistributedEnableByBundle(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleIsDistributedEnableByBundle] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - ErrCode result = IsDistributedEnableByBundle(bundleOption, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsDistributedEnableByBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(enabled)) { - ANS_LOGE("[HandleIsDistributedEnableByBundle] fail: write enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetDeviceRemindType(MessageParcel &data, MessageParcel &reply) -{ - auto rType{ NotificationConstant::RemindType::NONE }; - ErrCode result = GetDeviceRemindType(rType); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetDeviceRemindType] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteInt32(static_cast(rType))) { - ANS_LOGE("[HandleGetDeviceRemindType] fail: write remind type failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleShellDump(MessageParcel &data, MessageParcel &reply) -{ - std::string cmd; - if (!data.ReadString(cmd)) { - ANS_LOGE("[HandleShellDump] fail: read cmd failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - std::string bundle; - if (!data.ReadString(bundle)) { - ANS_LOGE("[HandleShellDump] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - int32_t userId; - if (!data.ReadInt32(userId)) { - ANS_LOGE("[HandleShellDump] fail: read userId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - int32_t recvUserId; - if (!data.ReadInt32(recvUserId)) { - ANS_LOGE("[HandleShellDump] fail: read recvUserId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - std::vector notificationsInfo; - ErrCode result = ShellDump(cmd, bundle, userId, recvUserId, notificationsInfo); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetRecentNotificationsInfo] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteStringVector(notificationsInfo)) { - ANS_LOGE("[HandleGetRecentNotificationsInfo] fail: write notificationsInfo failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsSupportTemplate(MessageParcel &data, MessageParcel &reply) -{ - std::string templateName; - if (!data.ReadString(templateName)) { - ANS_LOGE("[HandleIsSupportTemplate] fail: read template name failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - bool support = false; - ErrCode result = IsSupportTemplate(templateName, support); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsSupportTemplate] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!reply.WriteBool(support)) { - ANS_LOGE("[HandleIsSupportTemplate] fail: write support failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsSpecialUserAllowedNotifyByUser(MessageParcel &data, MessageParcel &reply) -{ - int32_t userId = SUBSCRIBE_USER_INIT; - if (!data.ReadInt32(userId)) { - ANS_LOGE("[HandleIsSpecialUserAllowedNotifyByUser] fail: read userId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool allowed = false; - ErrCode result = IsSpecialUserAllowedNotify(userId, allowed); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsSpecialUserAllowedNotifyByUser] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(allowed)) { - ANS_LOGE("[HandleIsSpecialUserAllowedNotifyByUser] fail: write allowed failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetNotificationsEnabledByUser(MessageParcel &data, MessageParcel &reply) -{ - int32_t userId = SUBSCRIBE_USER_INIT; - if (!data.ReadInt32(userId)) { - ANS_LOGE("[HandleSetNotificationsEnabledByUser] fail: read userId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleSetNotificationsEnabledByUser] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetNotificationsEnabledByUser(userId, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetNotificationsEnabledByUser] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleDeleteAllByUser(MessageParcel &data, MessageParcel &reply) -{ - int32_t userId = SUBSCRIBE_USER_INIT; - if (!data.ReadInt32(userId)) { - ANS_LOGE("[HandleDeleteAllByUser] fail: read userId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = DeleteAllByUser(userId); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleDeleteAllByUser] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply) -{ - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply) -{ - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t type = 0; - if (!data.ReadInt32(type)) { - ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read slot type failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - NotificationConstant::SlotType slotType = static_cast(type); - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool isForceControl = false; - if (!data.ReadBool(isForceControl)) { - ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: read isForceControl failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetEnabledForBundleSlot(bundleOption, slotType, enabled, isForceControl); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetEnabledForBundleSlot] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetEnabledForBundleSlot(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadStrongParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: read bundle failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t type = 0; - if (!data.ReadInt32(type)) { - ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: read slot type failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - NotificationConstant::SlotType slotType = static_cast(type); - - bool enabled = false; - ErrCode result = GetEnabledForBundleSlot(bundleOption, slotType, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(enabled)) { - ANS_LOGE("[HandleGetEnabledForBundleSlot] fail: write enabled failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetEnabledForBundleSlotSelf(MessageParcel &data, MessageParcel &reply) -{ - int32_t type = 0; - if (!data.ReadInt32(type)) { - ANS_LOGE("[HandleGetEnabledForBundleSlotSelf] fail: read slot type failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - NotificationConstant::SlotType slotType = static_cast(type); - - bool enabled = false; - ErrCode result = GetEnabledForBundleSlotSelf(slotType, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetEnabledForBundleSlotSelf] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(enabled)) { - ANS_LOGE("[HandleGetEnabledForBundleSlotSelf] fail: write enabled failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleDistributedSetEnabledWithoutApp(MessageParcel &data, MessageParcel &reply) -{ - int32_t userId = SUBSCRIBE_USER_INIT; - if (!data.ReadInt32(userId)) { - ANS_LOGE("[HandleDistributedSetEnabledWithoutApp] fail: read userId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleDistributedSetEnabledWithoutApp] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetSyncNotificationEnabledWithoutApp(userId, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleDistributedSetEnabledWithoutApp] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleDistributedGetEnabledWithoutApp(MessageParcel &data, MessageParcel &reply) -{ - int32_t userId = SUBSCRIBE_USER_INIT; - if (!data.ReadInt32(userId)) { - ANS_LOGE("[HandleDistributedGetEnabledWithoutApp] fail: read userId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - ErrCode result = GetSyncNotificationEnabledWithoutApp(userId, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleDistributedGetEnabledWithoutApp] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(enabled)) { - ANS_LOGE("[HandleDistributedGetEnabledWithoutApp] fail: write enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetBadgeNumber(MessageParcel &data, MessageParcel &reply) -{ - int32_t badgeNumber = -1; - if (!data.ReadInt32(badgeNumber)) { - ANSR_LOGE("Read badge number failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string appInstanceKey; - if (!data.ReadString(appInstanceKey)) { - ANSR_LOGE("Read instance key failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetBadgeNumber(badgeNumber, appInstanceKey); - if (!reply.WriteInt32(result)) { - ANSR_LOGE("Write badge number failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerStub::HandleSetBadgeNumberByBundle(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("Called."); - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("Read bundle option failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - int32_t badgeNumber = 0; - if (!data.ReadInt32(badgeNumber)) { - ANS_LOGE("Read badge number failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetBadgeNumberByBundle(bundleOption, badgeNumber); - if (!reply.WriteInt32(result)) { - ANS_LOGE("Write result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerStub::HandleSetBadgeNumberForDhByBundle(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("Called."); - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("Read bundle option failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - int32_t badgeNumber = 0; - if (!data.ReadInt32(badgeNumber)) { - ANS_LOGE("Read badge number failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetBadgeNumberForDhByBundle(bundleOption, badgeNumber); - if (!reply.WriteInt32(result)) { - ANS_LOGE("Write result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerStub::HandleGetAllNotificationEnableStatus(MessageParcel &data, MessageParcel &reply) -{ - std::vector bundleOption; - ErrCode result = GetAllNotificationEnabledBundles(bundleOption); - int32_t vectorSize = bundleOption.size(); - if (vectorSize > MAX_STATUS_VECTOR_NUM) { - ANS_LOGE("Bundle bundleOption vector is over size."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteInt32(result)) { - ANS_LOGE("Write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteInt32(vectorSize)) { - ANS_LOGE("Write bundleOption size failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - for (const auto &item : bundleOption) { - if (!reply.WriteParcelable(&item)) { - ANS_LOGE("Write bundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRegisterPushCallback(MessageParcel &data, MessageParcel &reply) -{ - sptr pushCallBack = data.ReadRemoteObject(); - if (pushCallBack == nullptr) { - ANS_LOGE("fail: read JSPushCallBack failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr notificationCheckRequest = data.ReadParcelable(); - if (notificationCheckRequest == nullptr) { - ANS_LOGE("fail: read notificationCheckRequest failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = RegisterPushCallback(pushCallBack, notificationCheckRequest); - if (!reply.WriteInt32(result)) { - ANS_LOGE("fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerStub::HandleUnregisterPushCallback(MessageParcel &data, MessageParcel &reply) -{ - ErrCode result = UnregisterPushCallback(); - if (!reply.WriteInt32(result)) { - ANS_LOGE("fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} -ErrCode AnsManagerStub::HandleGetNotificationRequest(MessageParcel &data, MessageParcel &reply) -{ - std::string hashCode; - if (!data.ReadString(hashCode)) { - ANS_LOGE("read hashCode failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - sptr request; - ErrCode result = GetNotificationRequestByHashCode(hashCode, request); - if (!reply.WriteInt32(result)) { - ANS_LOGE("write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteParcelable(request)) { - ANS_LOGE("get request failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleAddDoNotDisturbProfiles(MessageParcel &data, MessageParcel &reply) -{ - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetDistributedEnabledByBundle(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("enter"); - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read bundleOption failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string deviceType; - if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetDistributedEnabledByBundle(bundleOption, deviceType, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetNotificationsEnabledForSpecialBundle] fail: write result failed, ErrCode=%{public}d", - result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleRemoveDoNotDisturbProfiles(MessageParcel &data, MessageParcel &reply) -{ - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetAllDistributedEnabledBundles(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceType; - if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleGetAllDistributedEnabledBundles] fail: read deviceType failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::vector bundleOption; - ErrCode result = GetAllDistribuedEnabledBundles(deviceType, bundleOption); - int32_t vectorSize = bundleOption.size(); - if (vectorSize > MAX_STATUS_VECTOR_NUM) { - ANS_LOGE("Bundle bundleOption vector is over size."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteInt32(result)) { - ANS_LOGE("Write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteInt32(vectorSize)) { - ANS_LOGE("Write bundleOption size failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - for (const auto &item : bundleOption) { - if (!reply.WriteParcelable(&item)) { - ANS_LOGE("Write bundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsDistributedEnabledByBundle(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("enter"); - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("[HandleIsDistributedEnabledByBundle] fail: read bundleOption failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string deviceType; - if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleIsDistributedEnabledByBundle] fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - ErrCode result = IsDistributedEnabledByBundle(bundleOption, deviceType, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsDistributedEnabledByBundle] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(enabled)) { - ANS_LOGE("[HandleIsDistributedEnabledByBundle] fail: write enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetAdditionConfig(MessageParcel &data, MessageParcel &reply) -{ - std::string key; - if (!data.ReadString(key)) { - ANS_LOGE("Failed to read key."); - return ERR_ANS_PARCELABLE_FAILED; - } - - std::string value; - if (!data.ReadString(value)) { - ANS_LOGE("Failed to read value."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetAdditionConfig(key, value); - if (!reply.WriteInt32(result)) { - ANS_LOGE("Failed to write result, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerStub::HandleSetSmartReminderEnabled(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("enter"); - std::string deviceType; - if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleSetSmartReminderEnabled] fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleSetSmartReminderEnabled] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetSmartReminderEnabled(deviceType, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetSmartReminderEnabled] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleCancelAsBundleWithAgent(MessageParcel &data, MessageParcel &reply) -{ - sptr bundleOption = data.ReadParcelable(); - if (bundleOption == nullptr) { - ANS_LOGE("Read bundleOption failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t id = 0; - if (!data.ReadInt32(id)) { - ANS_LOGE("Read notification id failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = CancelAsBundleWithAgent(bundleOption, id); - if (!reply.WriteInt32(result)) { - ANS_LOGE("Write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} - -ErrCode AnsManagerStub::HandleIsSmartReminderEnabled(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("enter"); - std::string deviceType; - if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleIsSmartReminderEnabled] fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - ErrCode result = IsSmartReminderEnabled(deviceType, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsSmartReminderEnabled] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(enabled)) { - ANS_LOGE("[HandleIsSmartReminderEnabled] fail: write enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetDistributedEnabledBySlot(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("enter"); - NotificationConstant::SlotType slotType = static_cast(data.ReadInt32()); - - std::string deviceType; - if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleSetDistributedEnabledBySlot] fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - if (!data.ReadBool(enabled)) { - ANS_LOGE("[HandleSetDistributedEnabledBySlot] fail: read enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetDistributedEnabledBySlot(slotType, deviceType, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetDistributedEnabledBySlot] fail: write result failed, ErrCode=%{public}d", - result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetAllLiveViewEnabledBundles(MessageParcel &data, MessageParcel &reply) -{ - std::vector bundleOption; - ErrCode result = GetAllLiveViewEnabledBundles(bundleOption); - int32_t vectorSize = bundleOption.size(); - if (vectorSize > MAX_STATUS_VECTOR_NUM) { - ANS_LOGE("Bundle bundleOption vector is over size."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteInt32(result)) { - ANS_LOGE("Write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteInt32(vectorSize)) { - ANS_LOGE("Write bundleOption size failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - for (const auto &item : bundleOption) { - if (!reply.WriteParcelable(&item)) { - ANS_LOGE("Write bundleOption failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleIsDistributedEnabledBySlot(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("enter"); - NotificationConstant::SlotType slotType = static_cast(data.ReadInt32()); - - std::string deviceType; - if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleIsDistributedEnabledBySlot] fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool enabled = false; - ErrCode result = IsDistributedEnabledBySlot(slotType, deviceType, enabled); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleIsDistributedEnabledBySlot] fail: write result failed, ErrCode=%{public}d", - result); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!reply.WriteBool(enabled)) { - ANS_LOGE("[HandleIsDistributedEnabledBySlot] fail: write enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetTargetDeviceStatus(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceType; - if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read deviceType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t status = 0; - if (!data.ReadInt32(status)) { - ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read status failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetTargetDeviceStatus(deviceType, status, std::string()); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetTargetDeviceStatus] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetDoNotDisturbProfile(MessageParcel &data, MessageParcel &reply) -{ - return ERR_OK; -} - -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED -ErrCode AnsManagerStub::HandleRegisterSwingCallback(MessageParcel &data, MessageParcel &reply) -{ - sptr swingCallBack = data.ReadRemoteObject(); - if (swingCallBack == nullptr) { - ANS_LOGE("fail: read SwingCallBack failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = RegisterSwingCallback(swingCallBack); - if (!reply.WriteInt32(result)) { - ANS_LOGE("fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return result; -} -#endif - -ErrCode AnsManagerStub::HandleUpdateNotificationTimerByUid(MessageParcel &data, MessageParcel &reply) -{ - int32_t uid = data.ReadInt32(); - bool isPaused = data.ReadBool(); - ErrCode result = UpdateNotificationTimerByUid(uid, isPaused); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleUpdateNotificationTimerByUid] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleAllowUseReminder(MessageParcel &data, MessageParcel &reply) -{ - ANS_LOGD("enter"); - std::string bundleName; - if (!data.ReadString(bundleName)) { - ANS_LOGE("fail: read deviceId failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - bool isAllowUseReminder = false; - ErrCode result = AllowUseReminder(bundleName, isAllowUseReminder); - if (!reply.WriteInt32(result)) { - ANS_LOGE("fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.WriteBool(isAllowUseReminder)) { - ANS_LOGE("fail: write enabled failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleDisableNotificationFeature(MessageParcel &data, MessageParcel &reply) -{ - sptr notificationDisable = data.ReadParcelable(); - ErrCode result = DisableNotificationFeature(notificationDisable); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleDisableNotificationFeature] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetDeviceStatus(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceType; - if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read deviceType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t status = 0; - if (!data.ReadInt32(status)) { - ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read status failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t controlFlag = 0; - if (!data.ReadInt32(controlFlag)) { - ANS_LOGE("[HandleSetTargetDeviceStatus] fail: read status failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetTargetDeviceStatus(deviceType, status, controlFlag, std::string()); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetTargetDeviceStatus] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetDeviceStatus(MessageParcel &data, MessageParcel &reply) -{ - std::string deviceType; - if (!data.ReadString(deviceType)) { - ANS_LOGE("[HandleGetDeviceStatus] fail: read deviceType failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t status = 0; - ErrCode result = GetTargetDeviceStatus(deviceType, status); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleGetDeviceStatus] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!reply.WriteInt32(status)) { - ANS_LOGE("[HandleGetDeviceStatus] fail: write slot failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleSetHashCodeRule(MessageParcel &data, MessageParcel &reply) -{ - int32_t type = 0; - if (!data.ReadInt32(type)) { - ANS_LOGE("[HandleSetHashCodeRule] fail: read type failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = SetHashCodeRule(type); - if (!reply.WriteInt32(result)) { - ANS_LOGE("[HandleSetHashCodeRule] fail: write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleDistributeOperation(MessageParcel &data, MessageParcel &reply) -{ - sptr remote = data.ReadRemoteObject(); - if (remote == nullptr) { - ANS_LOGE("remote is nullptr"); - return ERR_INVALID_DATA; - } - - sptr callback = iface_cast(remote); - if (callback.GetRefPtr() == nullptr) { - ANS_LOGE("callback is null"); - return ERR_INVALID_DATA; - } - - sptr info = nullptr; - info = data.ReadParcelable(); - if (info == nullptr) { - ANS_LOGE("[HandleSubscribe] fail: read info failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = DistributeOperation(info, callback); - if (!reply.WriteInt32(result)) { - ANS_LOGE("write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleReplyDistributeOperation(MessageParcel &data, MessageParcel &reply) -{ - std::string hashCode; - if (!data.ReadString(hashCode)) { - ANS_LOGE("read hashCode failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - int32_t resultCode = 0; - if (!data.ReadInt32(resultCode)) { - ANS_LOGE("read hashCode failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - ErrCode result = ReplyDistributeOperation(hashCode, resultCode); - if (!reply.WriteInt32(result)) { - ANS_LOGE("write result failed, ErrCode=%{public}d", result); - return ERR_ANS_PARCELABLE_FAILED; - } - - return ERR_OK; -} - -ErrCode AnsManagerStub::HandleGetAllNotificationsBySlotType(MessageParcel &data, MessageParcel &reply) -{ - NotificationConstant::SlotType slotType = static_cast(data.ReadInt32()); - std::vector> notifications; - ErrCode result = GetAllNotificationsBySlotType(notifications, slotType); - - if (!reply.SetMaxCapacity(NotificationConstant::NOTIFICATION_MAX_LIVE_VIEW_SIZE)) { - ANS_LOGE("[HandleGetAllActiveNotifications] fail:: set max capacity"); - return ERR_ANS_PARCELABLE_FAILED; - } - if (!WriteParcelableVector(notifications, reply, result)) { - ANS_LOGE("[HandleGetAllActiveNotifications] fail: write notifications failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - return ERR_OK; -} -} // namespace Notification -} // namespace OHOS diff --git a/services/ans/src/ans_manager_stub_invalid.cpp b/services/ans/src/ans_manager_stub_invalid.cpp deleted file mode 100644 index 6ca64b80007975ab3b8866ae8072ddd7086a5b03..0000000000000000000000000000000000000000 --- a/services/ans/src/ans_manager_stub_invalid.cpp +++ /dev/null @@ -1,726 +0,0 @@ -/* - * Copyright (c) 2021-2025 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_manager_stub.h" -#include "ans_const_define.h" -#include "ans_inner_errors.h" -#include "ans_log_wrapper.h" -#include "message_option.h" -#include "message_parcel.h" -#include "parcel.h" -#include "reminder_request_alarm.h" -#include "reminder_request_calendar.h" -#include "reminder_request_timer.h" - -namespace OHOS { -namespace Notification { -ErrCode AnsManagerStub::Publish(const std::string &label, const sptr ¬ification) -{ - ANS_LOGE("AnsManagerStub::Publish called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetNotificationRequestByHashCode( - const std::string& hashCode, sptr& notificationRequest) -{ - ANS_LOGE("AnsManagerStub::Publish called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::PublishNotificationForIndirectProxy(const sptr ¬ification) -{ - ANS_LOGE("AnsManagerStub::PublishNotificationForIndirectProxy called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::Cancel(int notificationId, const std::string &label, const std::string &instanceKey) -{ - ANS_LOGE("AnsManagerStub::Cancel called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAll(const std::string &instanceKey) -{ - ANS_LOGE("AnsManagerStub::CancelAll called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAsBundle(int32_t notificationId, const std::string &representativeBundle, int32_t userId) -{ - ANS_LOGE("AnsManagerStub::CancelAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAsBundle(const sptr &bundleOption, int32_t notificationId) -{ - ANS_LOGE("AnsManagerStub::CancelAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAsBundle( - const sptr &bundleOption, int32_t notificationId, int32_t userId) -{ - ANS_LOGE("AnsManagerStub::CancelAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::AddSlotByType(NotificationConstant::SlotType slotType) -{ - ANS_LOGE("AnsManagerStub::AddSlotByType called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::AddSlots(const std::vector> &slots) -{ - ANS_LOGE("AnsManagerStub::AddSlots called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveSlotByType(const NotificationConstant::SlotType &slotType) -{ - ANS_LOGE("AnsManagerStub::RemoveSlotByType called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveAllSlots() -{ - ANS_LOGE("AnsManagerStub::RemoveAllSlots called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotByType(const NotificationConstant::SlotType &slotType, sptr &slot) -{ - ANS_LOGE("AnsManagerStub::GetSlotByType called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlots(std::vector> &slots) -{ - ANS_LOGE("AnsManagerStub::GetSlots called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotNumAsBundle(const sptr &bundleOption, uint64_t &num) -{ - ANS_LOGE("AnsManagerStub::GetSlotNumAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetActiveNotifications( - std::vector> ¬ifications, const std::string &instanceKey) -{ - ANS_LOGE("AnsManagerStub::GetActiveNotifications called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetActiveNotificationNums(uint64_t &num) -{ - ANS_LOGE("AnsManagerStub::GetActiveNotificationNums called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetAllActiveNotifications(std::vector> ¬ifications) -{ - ANS_LOGE("AnsManagerStub::GetAllActiveNotifications called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSpecialActiveNotifications( - const std::vector &key, std::vector> ¬ifications) -{ - ANS_LOGE("AnsManagerStub::GetSpecialActiveNotifications called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetActiveNotificationByFilter( - const sptr &bundleOption, const int32_t notificationId, const std::string &label, - std::vector extraInfoKeys, sptr &request) -{ - ANS_LOGE("AnsManagerStub::GetActiveNotificationByFilter called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) -{ - ANS_LOGE("AnsManagerStub::CanPublishAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::PublishAsBundle( - const sptr notification, const std::string &representativeBundle) -{ - ANS_LOGE("AnsManagerStub::PublishAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetNotificationBadgeNum(int num) -{ - ANS_LOGE("AnsManagerStub::SetNotificationBadgeNum called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetBundleImportance(int &importance) -{ - ANS_LOGE("AnsManagerStub::GetBundleImportance called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotFlagsAsBundle(const sptr &bundleOption, uint32_t &slotFlags) -{ - ANS_LOGE("AnsManagerStub::GetSlotFlagsAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetSlotFlagsAsBundle(const sptr &bundleOption, uint32_t slotFlags) -{ - ANS_LOGE("AnsManagerStub::SetSlotFlagsAsBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::HasNotificationPolicyAccessPermission(bool &granted) -{ - ANS_LOGE("AnsManagerStub::HasNotificationPolicyAccessPermission called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::TriggerLocalLiveView(const sptr &bundleOption, - const int32_t notificationId, const sptr &buttonOption) -{ - ANS_LOGE("AnsManagerStub::TriggerLocalLiveView called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveNotification(const sptr &bundleOption, - int notificationId, const std::string &label, int32_t removeReason) -{ - ANS_LOGE("AnsManagerStub::RemoveNotification called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveAllNotifications(const sptr &bundleOption) -{ - ANS_LOGE("AnsManagerStub::RemoveAllNotifications called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveNotifications(const std::vector &keys, int32_t removeReason) -{ - ANS_LOGD("called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::Delete(const std::string &key, int32_t removeReason) -{ - ANS_LOGE("AnsManagerStub::Delete called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DeleteByBundle(const sptr &bundleOption) -{ - ANS_LOGE("AnsManagerStub::DeleteByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DeleteAll() -{ - ANS_LOGE("AnsManagerStub::DeleteAll called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotsByBundle( - const sptr &bundleOption, std::vector> &slots) -{ - ANS_LOGE("AnsManagerStub::GetSlotsByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSlotByBundle( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, - sptr &slot) -{ - ANS_LOGE("AnsManagerStub::GetSlotByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::UpdateSlots( - const sptr &bundleOption, const std::vector> &slots) -{ - ANS_LOGE("AnsManagerStub::UpdateSlots called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RequestEnableNotification(const std::string &deviceId, - const sptr &callback, - const sptr &callerToken) -{ - ANS_LOGE("AnsManagerStub::RequestEnableNotification called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RequestEnableNotification(const std::string bundleName, const int32_t uid) -{ - ANS_LOGE("AnsManagerStub::RequestEnableNotification called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetNotificationsEnabledForBundle(const std::string &bundle, bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetNotificationsEnabledForBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetNotificationsEnabledForAllBundles called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetNotificationsEnabledForSpecialBundle( - const std::string &deviceId, const sptr &bundleOption, bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetNotificationsEnabledForSpecialBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetShowBadgeEnabledForBundle(const sptr &bundleOption, bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetShowBadgeEnabledForBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetShowBadgeEnabledForBundle(const sptr &bundleOption, bool &enabled) -{ - ANS_LOGE("AnsManagerStub::GetShowBadgeEnabledForBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetShowBadgeEnabled(bool &enabled) -{ - ANS_LOGE("AnsManagerStub::GetShowBadgeEnabled called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::Subscribe(const sptr &subscriber, - const sptr &info) -{ - ANS_LOGE("AnsManagerStub::Subscribe called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SubscribeSelf(const sptr &subscriber) -{ - ANS_LOGE("AnsManagerStub::SubscribeSelf called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SubscribeLocalLiveView(const sptr &subscriber, - const sptr &info, const bool isNative) -{ - ANS_LOGE("AnsManagerStub::SubscribeLocalLiveView called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::Unsubscribe(const sptr &subscriber, - const sptr &info) -{ - ANS_LOGE("AnsManagerStub::Unsubscribe called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsAllowedNotify(bool &allowed) -{ - ANS_LOGE("AnsManagerStub::IsAllowedNotify called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsAllowedNotifySelf(bool &allowed) -{ - ANS_LOGE("AnsManagerStub::IsAllowedNotifySelf called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CanPopEnableNotificationDialog(const sptr &callback, - bool &canPop, std::string &bundleName) -{ - ANS_LOGE("AnsManagerStub::CanPopEnableNotificationDialog called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveEnableNotificationDialog() -{ - ANS_LOGE("AnsManagerStub::RemoveEnableNotificationDialog called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) -{ - ANS_LOGE("AnsManagerStub::IsSpecialBundleAllowedNotify called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelGroup(const std::string &groupName, const std::string &instanceKey) -{ - ANS_LOGE("AnsManagerStub::CancelGroup called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveGroupByBundle( - const sptr &bundleOption, const std::string &groupName) -{ - ANS_LOGE("AnsManagerStub::RemoveGroupByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetDoNotDisturbDate(const sptr &date) -{ - ANS_LOGE("AnsManagerStub::SetDoNotDisturbDate called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetDoNotDisturbDate(sptr &date) -{ - ANS_LOGE("AnsManagerStub::GetDoNotDisturbDate called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::AddDoNotDisturbProfiles(const std::vector> &profiles) -{ - ANS_LOGD("Called."); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RemoveDoNotDisturbProfiles(const std::vector> &profiles) -{ - ANS_LOGD("Called."); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DoesSupportDoNotDisturbMode(bool &doesSupport) -{ - ANS_LOGE("AnsManagerStub::DoesSupportDoNotDisturbMode called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) -{ - ANS_LOGE("AnsManagerStub::IsNeedSilentInDoNotDisturbMode called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsDistributedEnabled(bool &enabled) -{ - ANS_LOGE("AnsManagerStub::IsDistributedEnabled called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::EnableDistributed(bool enabled) -{ - ANS_LOGE("AnsManagerStub::EnableDistributed called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::EnableDistributedByBundle(const sptr &bundleOption, bool enabled) -{ - ANS_LOGE("AnsManagerStub::EnableDistributedByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::EnableDistributedSelf(bool enabled) -{ - ANS_LOGE("AnsManagerStub::EnableDistributedSelf called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsDistributedEnableByBundle(const sptr &bundleOption, bool &enabled) -{ - ANS_LOGE("AnsManagerStub::IsDistributedEnableByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetDeviceRemindType(NotificationConstant::RemindType &remindType) -{ - ANS_LOGE("AnsManagerStub::GetDeviceRemindType called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::PublishContinuousTaskNotification(const sptr &request) -{ - ANS_LOGE("AnsManagerStub::PublishContinuousTaskNotification called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) -{ - ANS_LOGE("AnsManagerStub::CancelContinuousTaskNotification called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsSupportTemplate(const std::string &templateName, bool &support) -{ - ANS_LOGE("AnsManagerStub::IsSupportTemplate called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) -{ - ANS_LOGE("AnsManagerStub::IsSpecialUserAllowedNotify called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetNotificationsEnabledByUser called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DeleteAllByUser(const int32_t &userId) -{ - ANS_LOGE("AnsManagerStub::DeleteAllByUser called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetDoNotDisturbDate(const int32_t &userId, const sptr &date) -{ - ANS_LOGE("AnsManagerStub::SetDoNotDisturbDate called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetDoNotDisturbDate(const int32_t &userId, sptr &date) -{ - ANS_LOGE("AnsManagerStub::GetDoNotDisturbDate called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetEnabledForBundleSlot(const sptr &bundleOption, - const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) -{ - ANS_LOGE("AnsManagerStub::SetEnabledForBundleSlot called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetEnabledForBundleSlot( - const sptr &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled) -{ - ANS_LOGE("AnsManagerStub::GetEnabledForBundleSlot called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) -{ - ANS_LOGE("AnsManagerStub::GetEnabledForBundleSlotSelf called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, - int32_t recvUserId, std::vector &dumpInfo) -{ - ANS_LOGE("AnsManagerStub::ShellDump called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) -{ - ANS_LOGE("AnsManagerStub::SetSyncNotificationEnabledWithoutApp called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) -{ - ANS_LOGE("AnsManagerStub::GetSyncNotificationEnabledWithoutApp called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetBadgeNumber(int32_t badgeNumber, const std::string &instanceKey) -{ - ANS_LOGE("AnsManagerStub::SetBadgeNumber called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetBadgeNumberByBundle(const sptr &bundleOption, int32_t badgeNumber) -{ - ANS_LOGD("Called."); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetBadgeNumberForDhByBundle( - const sptr &bundleOption, int32_t badgeNumber) -{ - ANS_LOGD("Called."); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetAllNotificationEnabledBundles(std::vector &bundleOption) -{ - ANS_LOGE("AnsManagerStub::GetAllNotificationEnabledBundles called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RegisterPushCallback( - const sptr& pushCallback, const sptr ¬ificationCheckRequest) -{ - ANS_LOGE("RegisterPushCallback called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::UnregisterPushCallback() -{ - ANS_LOGE("UnregisterPushCallback called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetDistributedEnabledByBundle(const sptr &bundleOption, - const std::string &deviceType, const bool enabled) -{ - ANS_LOGE("SetDistributedEnabledByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetTargetDeviceStatus(const std::string &deviceType, int32_t &status) -{ - ANS_LOGE("GetTargetDeviceStatus called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DistributeOperation(sptr& operationInfo, - const sptr &callback) -{ - ANS_LOGE("DistributeOperation called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::ReplyDistributeOperation(const std::string& hashCode, const int32_t result) -{ - ANS_LOGE("ReplyDistributeOperation called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetAllLiveViewEnabledBundles(std::vector &bundleOption) -{ - ANS_LOGE("AnsManagerStub::GetAllLiveViewEnabledBundles called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetAllDistribuedEnabledBundles(const std::string& deviceType, - std::vector &bundleOption) -{ - ANS_LOGE("AnsManagerStub::GetAllDistribuedEnabledBundles called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsDistributedEnabledByBundle(const sptr &bundleOption, - const std::string &deviceType, bool &enabled) -{ - ANS_LOGE("IsDistributedEnabledByBundle called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) -{ - ANS_LOGE("SetSmartReminderEnabled called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) -{ - ANS_LOGE("IsSmartReminderEnabled called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled) -{ - ANS_LOGE("SetDistributedEnabledBySlot called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::IsDistributedEnabledBySlot( - const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled) -{ - ANS_LOGE("IsDistributedEnabledBySlot called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetAdditionConfig(const std::string &key, const std::string &value) -{ - ANS_LOGE("Called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAsBundleWithAgent(const sptr &bundleOption, const int32_t id) -{ - ANS_LOGE("Called."); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const std::string deveiceId) -{ - ANS_LOGE("SetTargetDeviceStatus called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status, - const uint32_t controlFlag, const std::string deveiceId) -{ - ANS_LOGE("SetTargetDeviceStatus called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetDoNotDisturbProfile(int64_t id, sptr &profile) -{ - ANS_LOGE("GetDoNotDisturbProfile called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder) -{ - ANS_LOGE("AllowUseReminder called!"); - return ERR_INVALID_OPERATION; -} - -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED -ErrCode AnsManagerStub::RegisterSwingCallback(const sptr& swingCallback) -{ - ANS_LOGE("RegisterSwingCallback called!"); - return ERR_INVALID_OPERATION; -} -#endif - -ErrCode AnsManagerStub::UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) -{ - ANS_LOGE("UpdateNotificationTimerByUid called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::DisableNotificationFeature(const sptr ¬ificationDisable) -{ - ANS_LOGE("DisableNotificationFeature called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetHashCodeRule(const uint32_t type) -{ - ANS_LOGE("SetHashCodeRule called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetAllNotificationsBySlotType(std::vector> ¬ifications, - const NotificationConstant::SlotType slotType) -{ - ANS_LOGE("AnsManagerStub::GetAllNotificationsBySlotType called!"); - return ERR_INVALID_OPERATION; -} -} // namespace Notification -} // namespace OHOS diff --git a/services/ans/test/unittest/BUILD.gn b/services/ans/test/unittest/BUILD.gn index 98b6024e1298acfb6f78d15b1891763394cfcb54..8b958473e266ff1cce6e02730d9f78cfb989c5ab 100644 --- a/services/ans/test/unittest/BUILD.gn +++ b/services/ans/test/unittest/BUILD.gn @@ -317,7 +317,6 @@ ohos_unittest("notification_service_test") { "advanced_notification_service_test.cpp", "advanced_notification_slot_service_test.cpp", "advanced_notification_utils_test.cpp", - "ans_manager_stub_test.cpp", "clone_test/notification_clone_bundle_info_test.cpp", "mock/blob.cpp", "mock/distributed_kv_data_manager.cpp", diff --git a/services/ans/test/unittest/advanced_notification_publish_service_test.cpp b/services/ans/test/unittest/advanced_notification_publish_service_test.cpp index d54f3e5f79221ac00fe7cce2de202e4fb6e5760e..082570138604366b5896e6b19f681ae81d982bd5 100644 --- a/services/ans/test/unittest/advanced_notification_publish_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_publish_service_test.cpp @@ -1907,7 +1907,8 @@ HWTEST_F(AnsPublishServiceTest, SetTargetDeviceStatus_00001, Function | SmallTes { std::string deviceType = ""; uint32_t status = 0; - auto ret = advancedNotificationService_->SetTargetDeviceStatus(deviceType, status); + std::string deveiceId = ""; + auto ret = advancedNotificationService_->SetTargetDeviceStatus(deviceType, status, deveiceId); ASSERT_EQ(ret, ERR_ANS_INVALID_PARAM); } @@ -1927,7 +1928,8 @@ HWTEST_F(AnsPublishServiceTest, GetTargetDeviceStatus_00001, Function | SmallTes ASSERT_EQ(ret, ERR_ANS_INVALID_PARAM); uint32_t controlFlag = 0; deviceType = "testdeviceType"; - ret = advancedNotificationService_->SetTargetDeviceStatus(deviceType, inputStatus); + std::string deveiceId = ""; + ret = advancedNotificationService_->SetTargetDeviceStatus(deviceType, inputStatus, deveiceId); ASSERT_EQ(ret, ERR_OK); ret = advancedNotificationService_->GetTargetDeviceStatus(deviceType, status); ASSERT_EQ(status, inputStatus); 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 f95e50d93346afc7d88ebb71c817590d56d2cb6c..f203eef34743f4f8ada8554dbf4053aad983c002 100644 --- a/services/ans/test/unittest/advanced_notification_service_branch_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_branch_test.cpp @@ -897,7 +897,7 @@ HWTEST_F(AnsBranchTest, AnsBranchTest_265000, Function | SmallTest | Level1) MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); MockIsSystemApp(false); - NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; + int32_t remindType = -1; ASSERT_EQ(advancedNotificationService_->GetDeviceRemindType(remindType), ERR_ANS_NON_SYSTEM_APP); } @@ -912,7 +912,7 @@ HWTEST_F(AnsBranchTest, AnsBranchTest_266000, Function | SmallTest | Level1) MockGetTokenTypeFlag(ATokenTypeEnum::TOKEN_HAP); MockIsVerfyPermisson(false); - NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; + int32_t remindType = -1; ASSERT_EQ(advancedNotificationService_->GetDeviceRemindType(remindType), ERR_ANS_PERMISSION_DENIED); } @@ -1269,7 +1269,7 @@ HWTEST_F(AnsBranchTest, GetDeviceRemindType_3000, Function | SmallTest | Level1) MockIsVerfyPermisson(true); AdvancedNotificationService ans; ans.notificationSvrQueue_ = nullptr; - NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; + int32_t remindType = -1; ASSERT_EQ(ans.GetDeviceRemindType(remindType), ERR_ANS_INVALID_PARAM); } diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index 8b1dd0c808e71314f87e9784dd91f444b5fe4ad6..e33717a07480a7241e79aa1dcd72032270539252 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -298,7 +298,8 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_03000, { const std::string device = "current"; const uint32_t status = 1; - ASSERT_EQ((int)advancedNotificationService_->SetTargetDeviceStatus(device, status), + std::string deveiceId = ""; + ASSERT_EQ((int)advancedNotificationService_->SetTargetDeviceStatus(device, status, deveiceId), (int)ERR_OK); } @@ -1537,7 +1538,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_17100, ASSERT_EQ(advancedNotificationService_->IsDistributedEnableByBundle(bundleOption, enable), ERR_OK); - NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; + int32_t remindType = -1; ASSERT_EQ(advancedNotificationService_->GetDeviceRemindType(remindType), ERR_OK); int32_t userId = 1; @@ -1949,7 +1950,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19500, { GTEST_LOG_(INFO) << "GetDeviceRemindType_0100 test start"; - NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; + int32_t remindType = -1; ASSERT_EQ(advancedNotificationService_->GetDeviceRemindType(remindType), ERR_OK); GTEST_LOG_(INFO) << "GetDeviceRemindType_0100 test end"; diff --git a/services/ans/test/unittest/ans_manager_stub_test.cpp b/services/ans/test/unittest/ans_manager_stub_test.cpp deleted file mode 100644 index 05348cfbf320d98ec943c4136cc4b6453ebd6e9b..0000000000000000000000000000000000000000 --- a/services/ans/test/unittest/ans_manager_stub_test.cpp +++ /dev/null @@ -1,5054 +0,0 @@ -/* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "errors.h" -#include "ipc_types.h" -#include "iremote_object.h" -#include "notification_button_option.h" -#include "notification_check_request.h" -#include "notification_subscribe_info.h" -#include - -#define private public -#define protected public -#include "ans_manager_stub.h" -#include "ans_subscriber_stub.h" -#include "ans_dialog_host_client.h" -#include "notification_subscriber.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(NotificationInterfaceCode::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(NotificationInterfaceCode::PUBLISH_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string label = "this is a notification label"; - sptr notification = new NotificationRequest(); - notification->SetSlotType(NotificationConstant::SlotType::CONTENT_INFORMATION); - std::shared_ptr longTextContent = - std::make_shared("longtext"); - std::shared_ptr content2 = std::make_shared(longTextContent); - notification->SetContent(content2); - 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(NotificationInterfaceCode::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(NotificationInterfaceCode::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: HandleCancel01 - * @tc.desc: Test HandleCancel succeeds - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancel01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CANCEL_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t notificationId = 3; - std::string instanceKey = ""; - std::string label = "this is a notification label"; - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(notificationId); - data.WriteString(label); - data.WriteString(instanceKey); - - 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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::CANCEL_ALL_NOTIFICATIONS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string instanceKey = ""; - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(instanceKey); - - 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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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: HandleCancelAsBundle05 - * @tc.desc: Test HandlePublish succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle05, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE_OPTION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t notificationId = 3; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(notificationId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleCancelAsBundle06 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle06, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE_OPTION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - 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: HandleCancelAsBundle07 - * @tc.desc: Test if the notificationId in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle07, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE_OPTION); - 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)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCancelAsBundle08 - * @tc.desc: Test HandlePublish succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle08, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE_AND_USER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t notificationId = 3; - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(notificationId); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleCancelAsBundleWithAgent01 - * @tc.desc: Test HandleCancelAsBundleWithAgent. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundleWithAgent01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE_WITH_AGENT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - sptr bundleOption = new NotificationBundleOption(); - int32_t id = 1; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(id); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandleCancelAsBundleWithAgent02 - * @tc.desc: Test HandleCancelAsBundleWithAgent. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundleWithAgent02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE_WITH_AGENT); - 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)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCancelAsBundleWithAgent03 - * @tc.desc: Test HandleCancelAsBundleWithAgent. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundleWithAgent03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CANCEL_AS_BUNDLE_WITH_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: HandleSetTargetDeviceStatus01 - * @tc.desc: Test HandleSetTargetDeviceStatus. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetTargetDeviceStatus01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - int32_t status = 1; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString("device"); - data.WriteInt32(status); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleSetTargetDeviceStatus02 - * @tc.desc: Test HandleSetTargetDeviceStatus. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetTargetDeviceStatus02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString("device"); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetTargetDeviceStatus03 - * @tc.desc: Test HandleSetTargetDeviceStatus. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetTargetDeviceStatus03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_TARGET_DEVICE_STATUS); - 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: HandleAddSlotByType01 - * @tc.desc: Test HandleAddSlotByType succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleAddSlotByType01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATIONS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string instanceKey = ""; - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(instanceKey); - - 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(NotificationInterfaceCode::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(NotificationInterfaceCode::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: HandleGetActiveNotificationByFilter01 - * @tc.desc: Test HandleGetActiveNotificationByFilter succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetActiveNotificationByFilter01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_BY_FILTER); - 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: HandleGetActiveNotificationByFilter02 - * @tc.desc: Test HandleGetActiveNotificationByFilter succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetActiveNotificationByFilter02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_BY_FILTER); - 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_INVALID_OPERATION); -} - -/** - * @tc.name: HandleGetActiveNotificationByFilter03 - * @tc.desc: Test HandleGetActiveNotificationByFilter succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetActiveNotificationByFilter03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_ACTIVE_NOTIFICATION_BY_FILTER); - 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); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleTriggerLocalLiveView01 - * @tc.desc: Test HandleTriggerLocalLiveView succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleTriggerLocalLiveView01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_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: HandleTriggerLocalLiveView02 - * @tc.desc: Test HandleTriggerLocalLiveView succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleTriggerLocalLiveView02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t notificationId = 1; - sptr buttonOption = new NotificationButtonOption(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(notificationId); - data.WriteStrongParcelable(buttonOption); - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleTriggerLocalLiveView03 - * @tc.desc: Test HandleTriggerLocalLiveView succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleTriggerLocalLiveView03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t notificationId = 1; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(notificationId); - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleTriggerLocalLiveView04 - * @tc.desc: Test HandleTriggerLocalLiveView succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleTriggerLocalLiveView04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::TRIGGER_LOCAL_LIVE_VIEW_NOTIFICATION); - 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)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::PUBLISH_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr notification = new NotificationRequest(); - notification->SetSlotType(NotificationConstant::SlotType::CONTENT_INFORMATION); - std::shared_ptr longTextContent = - std::make_shared("longtext"); - std::shared_ptr content2 = std::make_shared(longTextContent); - notification->SetContent(content2); - 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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::PUBLISH_CONTINUOUS_TASK_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr request = new NotificationRequest(); - request->SetSlotType(NotificationConstant::SlotType::CONTENT_INFORMATION); - std::shared_ptr longTextContent = - std::make_shared("longtext"); - std::shared_ptr content2 = std::make_shared(longTextContent); - request->SetContent(content2); - 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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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: HandleRemoveNotification01 - * @tc.desc: Test HandleRemoveNotification succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveNotification01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - std::string deviceId = "this is a deviceId"; - sptr callback = new AnsDialogHostClient(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - data.WriteRemoteObject(callback->AsObject()); - data.WriteBool(false); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleRequestEnableNotification03 - * @tc.desc: Test HandleRequestEnableNotification succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRequestEnableNotification03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::REQUEST_ENABLE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - std::string deviceId = "this is a deviceId"; - const sptr callback = new AnsDialogHostClient(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - data.WriteRemoteObject(callback->AsObject()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleRequestEnableNotification04 - * @tc.desc: Test HandleRequestEnableNotification succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRequestEnableNotification04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::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_ANS_PARCELABLE_FAILED); -} - -/** - * @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(NotificationInterfaceCode::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: HandleSubscribeSelf01 - * @tc.desc: Test SubscribeSelf. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSubscribeSelf01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION_SELF); - 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: HandleSubscribeLocalLiveView01 - * @tc.desc: Test HandleSubscribeLocalLiveView. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSubscribeLocalLiveView01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_LOCAL_LIVE_VIEW_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - sptr info = new NotificationSubscribeInfo(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteBool(true); - data.WriteStrongParcelable(info); - data.WriteBool(true); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSubscribeLocalLiveView02 - * @tc.desc: Test HandleSubscribeLocalLiveView. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSubscribeLocalLiveView02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_LOCAL_LIVE_VIEW_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - sptr info = nullptr; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteBool(true); - data.WriteStrongParcelable(info); - - 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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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(NotificationInterfaceCode::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); -} - -/** - * @tc.name: HandleAddSlots01 - * @tc.desc: Test if the slots in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleAddSlots01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::ADD_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: HandleAddSlots02 - * @tc.desc: Test if the result in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleAddSlots02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::ADD_SLOTS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::vector> slots; - sptr slot = new NotificationSlot(); - slots.emplace_back(slot); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - ErrCode result = ansManagerStub_->AddSlots(slots); - ansManagerStub_->WriteParcelableVector(slots, reply, result); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetSlots01 - * @tc.desc: Test HandleGetSlots succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetSlots01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_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_OK); -} - -/** - * @tc.name: HandleGetSpecialActiveNotifications01 - * @tc.desc: Test HandleGetSpecialActiveNotifications succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetSpecialActiveNotifications01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_SPECIAL_ACTIVE_NOTIFICATIONS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::vector key; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStringVector(key); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleGetShowBadgeEnabledForBundle01 - * @tc.desc: Test HandleGetShowBadgeEnabledForBundle succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetShowBadgeEnabledForBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_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)ERR_OK); -} - -/** - * @tc.name: HandleGetShowBadgeEnabledForBundle02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetShowBadgeEnabledForBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_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: HandleGetShowBadgeEnabledForBundle03 - * @tc.desc: Test if the enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetShowBadgeEnabledForBundle03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED_FOR_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: HandleGetShowBadgeEnabled01 - * @tc.desc: Test HandleGetShowBadgeEnabled succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetShowBadgeEnabled01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_SHOW_BADGE_ENABLED); - 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_OK); -} - -/** - * @tc.name: HandleSubscribe01 - * @tc.desc: Test HandleSubscribe succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSubscribe01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); - MessageParcel parcels; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr subscriber; - bool subcribeInfo = true; - sptr info = new NotificationSubscribeInfo(); - - parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - parcels.WriteParcelable(subscriber); - parcels.WriteBool(subcribeInfo); - parcels.WriteParcelable(info); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSubscribe02 - * @tc.desc: Test if the subcribeInfo in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSubscribe02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); - MessageParcel parcels; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr subscriber; - sptr info = new NotificationSubscribeInfo(); - - parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - parcels.WriteRemoteObject(subscriber); - parcels.WriteParcelable(info); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSubscribe03 - * @tc.desc: Test if the info in parcels is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSubscribe03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); - MessageParcel parcels; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr subscriber; - bool subcribeInfo = true; - - parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - parcels.WriteParcelable(subscriber); - parcels.WriteBool(subcribeInfo); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSubscribe04 - * @tc.desc: Test if the subscriber in parcel is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSubscribe04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SUBSCRIBE_NOTIFICATION); - MessageParcel parcels; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - bool subcribeInfo = true; - sptr info = new NotificationSubscribeInfo(); - - parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - parcels.WriteBool(subcribeInfo); - parcels.WriteParcelable(info); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleUnsubscribe01 - * @tc.desc: Test HandleUnsubscribe succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleUnsubscribe01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - bool subcribeInfo = true; - sptr info = new NotificationSubscribeInfo(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(info); - data.WriteBool(subcribeInfo); - data.WriteParcelable(info); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleUnsubscribe02 - * @tc.desc: Test if the subcribeInfo in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleUnsubscribe02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr subscriber; - sptr info = new NotificationSubscribeInfo(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteRemoteObject(subscriber); - data.WriteParcelable(info); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleUnsubscribe03 - * @tc.desc: Test if the info in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleUnsubscribe03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr subscriber; - bool subcribeInfo = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(subscriber); - data.WriteBool(subcribeInfo); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleUnsubscribe04 - * @tc.desc: Test if the subscriber in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleUnsubscribe04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::UNSUBSCRIBE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - bool subcribeInfo = true; - sptr info = new NotificationSubscribeInfo(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteBool(subcribeInfo); - data.WriteParcelable(info); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCanPopEnableNotificationDialog01 - * @tc.desc: Test HandleCanPopEnableNotificationDialog. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleCanPopEnableNotificationDialog01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CAN_POP_ENABLE_NOTIFICATION_DIALOG); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(nullptr); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCanPopEnableNotificationDialog2 - * @tc.desc: Test HandleCanPopEnableNotificationDialog. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleCanPopEnableNotificationDialog02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CAN_POP_ENABLE_NOTIFICATION_DIALOG); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - sptr callback = new AnsDialogHostClient(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(callback->AsObject()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleIsAllowedNotify01 - * @tc.desc: Test HandleIsAllowedNotify succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsAllowedNotify01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_ALLOWED_NOTIFY); - 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_OK); -} - -/** - * @tc.name: HandleIsAllowedNotifySelf01 - * @tc.desc: Test HandleIsAllowedNotifySelf succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsAllowedNotifySelf01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_ALLOWED_NOTIFY_SELF); - 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_OK); -} - -/** - * @tc.name: HandleIsSpecialBundleAllowedNotify01 - * @tc.desc: Test HandleIsSpecialBundleAllowedNotify succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsSpecialBundleAllowedNotify01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_SPECIAL_BUNDLE_ALLOWED_NOTIFY); - 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_OK); -} - -/** - * @tc.name: HandleIsSpecialBundleAllowedNotify02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsSpecialBundleAllowedNotify02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_SPECIAL_BUNDLE_ALLOWED_NOTIFY); - 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: HandleCancelGroup01 - * @tc.desc: Test HandleCancelGroup succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleCancelGroup01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CANCEL_GROUP); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string groupName = "this is groupName"; - std::string instanceKey = ""; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(groupName); - data.WriteString(instanceKey); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleCancelGroup02 - * @tc.desc: Test if the groupName in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleCancelGroup02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::CANCEL_GROUP); - 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: HandleRemoveGroupByBundle01 - * @tc.desc: Test HandleRemoveGroupByBundle succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveGroupByBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::REMOVE_GROUP_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - std::string groupName = "this is groupName"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteString(groupName); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleRemoveGroupByBundle02 - * @tc.desc: Test if the groupName in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveGroupByBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::REMOVE_GROUP_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)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleRemoveGroupByBundle03 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveGroupByBundle03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::REMOVE_GROUP_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string groupName = "this is groupName"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(groupName); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleIsDistributedEnabled01 - * @tc.desc: Test HandleIsDistributedEnabled succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsDistributedEnabled01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED); - 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_OK); -} - -/** - * @tc.name: HandleEnableDistributed01 - * @tc.desc: Test HandleEnableDistributed succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleEnableDistributed01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::ENABLE_DISTRIBUTED); - 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_OK); -} - -/** - * @tc.name: HandleEnableDistributed02 - * @tc.desc: Test if the enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleEnableDistributed02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::ENABLE_DISTRIBUTED); - 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: HandleEnableDistributedByBundle01 - * @tc.desc: Test HandleEnableDistributedByBundle succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleEnableDistributedByBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::ENABLE_DISTRIBUTED_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleEnableDistributedByBundle02 - * @tc.desc: Test if the enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleEnableDistributedByBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::ENABLE_DISTRIBUTED_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)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleEnableDistributedByBundle03 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleEnableDistributedByBundle03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::ENABLE_DISTRIBUTED_BY_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: HandleEnableDistributedSelf01 - * @tc.desc: Test HandleEnableDistributedSelf succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleEnableDistributedSelf01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::ENABLE_DISTRIBUTED_SELF); - 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_OK); -} - -/** - * @tc.name: HandleEnableDistributedSelf02 - * @tc.desc: Test if the enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleEnableDistributedSelf02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::ENABLE_DISTRIBUTED_SELF); - 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: HandleIsDistributedEnableByBundle01 - * @tc.desc: Test HandleIsDistributedEnableByBundle succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsDistributedEnableByBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED_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)ERR_OK); -} - -/** - * @tc.name: HandleIsDistributedEnableByBundle02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsDistributedEnableByBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_DISTRIBUTED_ENABLED_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: HandleGetDeviceRemindType01 - * @tc.desc: Test HandleGetDeviceRemindType succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetDeviceRemindType01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_DEVICE_REMIND_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)ERR_OK); -} - -/** - * @tc.name: HandleShellDump01 - * @tc.desc: Test HandleShellDump succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleShellDump01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SHELL_DUMP); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string cmd = "this is cmd"; - std::string bundle = "this is bundle"; - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(cmd); - data.WriteString(bundle); - data.WriteInt32(userId); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleShellDump02 - * @tc.desc: Test if the userId in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleShellDump02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SHELL_DUMP); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string cmd = "this is cmd"; - std::string bundle = "this is bundle"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(cmd); - data.WriteString(bundle); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} -/** - * @tc.name: HandleShellDump03 - * @tc.desc: Test if the cmd in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleShellDump03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SHELL_DUMP); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string bundle = "this is bundle"; - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(bundle); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} -/** - * @tc.name: HandleShellDump04 - * @tc.desc: Test if the bundle in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleShellDump04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SHELL_DUMP); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string cmd = "this is cmd"; - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(cmd); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: ReadParcelableVector01 - * @tc.desc: Test ReadParcelableVector result. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, ReadParcelableVector01, Function | SmallTest | Level1) -{ - std::vector> slots; - sptr slot = new NotificationSlot(); - slots.emplace_back(slot); - MessageParcel data; - bool ret = ansManagerStub_->ReadParcelableVector(slots, data); - EXPECT_EQ(ret, false); -} - -/** - * @tc.name: ReadParcelableVector02 - * @tc.desc: Test ReadParcelableVector result. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, ReadParcelableVector02, Function | SmallTest | Level1) -{ - std::vector> slots; - sptr slot = new NotificationSlot(); - slots.emplace_back(slot); - MessageParcel data; - - int32_t infoSize = 4; - data.WriteInt32(infoSize); - data.WriteStrongParcelable(slot); - bool ret = ansManagerStub_->ReadParcelableVector(slots, data); - EXPECT_EQ(ret, false); -} - -/** - * @tc.name: HandleIsSupportTemplate01 - * @tc.desc: Test HandleIsSupportTemplate succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsSupportTemplate01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_SUPPORT_TEMPLATE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string templateName = "this is templateName"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(templateName); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleIsSupportTemplate02 - * @tc.desc: Test templateName in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsSupportTemplate02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_SUPPORT_TEMPLATE); - 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: HandleIsSpecialUserAllowedNotifyByUser01 - * @tc.desc: Test HandleIsSpecialUserAllowedNotifyByUser succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsSpecialUserAllowedNotifyByUser01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_SPECIAL_USER_ALLOWED_NOTIFY); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleIsSpecialUserAllowedNotifyByUser02 - * @tc.desc: Test userId in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleIsSpecialUserAllowedNotifyByUser02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::IS_SPECIAL_USER_ALLOWED_NOTIFY); - 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: HandleSetNotificationsEnabledByUser01 - * @tc.desc: Test HandleSetNotificationsEnabledByUser succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledByUser01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER); - MessageParcel parcels; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t userId = 4; - bool enabled = true; - - parcels.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - parcels.WriteInt32(userId); - parcels.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, parcels, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleSetNotificationsEnabledByUser02 - * @tc.desc: Test userId in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledByUser02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER); - 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: HandleSetNotificationsEnabledByUser03 - * @tc.desc: Test enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledByUser03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_NOTIFICATION_ENABLED_BY_USER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleDeleteAllByUser01 - * @tc.desc: Test HandleDeleteAllByUser succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleDeleteAllByUser01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleDeleteAllByUser02 - * @tc.desc: Test userId in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleDeleteAllByUser02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER); - 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: HandleSetDoNotDisturbDateByUser01 - * @tc.desc: Test HandleSetDoNotDisturbDateByUser succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDateByUser01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE_BY_USER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t userId = 4; - sptr date = new NotificationDoNotDisturbDate(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(userId); - data.WriteStrongParcelable(date); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleSetDoNotDisturbDateByUser02 - * @tc.desc: Test userId in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDateByUser02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE_BY_USER); - 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)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetDoNotDisturbDateByUser03 - * @tc.desc: Test date in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDateByUser03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_DO_NOT_DISTURB_DATE_BY_USER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetDoNotDisturbDateByUser01 - * @tc.desc: Test HandleGetDoNotDisturbDateByUser succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetDoNotDisturbDateByUser01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE_BY_USER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t userId = 4; - sptr date = new NotificationDoNotDisturbDate(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(date); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleGetDoNotDisturbDateByUser02 - * @tc.desc: Test userId in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetDoNotDisturbDateByUser02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_DO_NOT_DISTURB_DATE_BY_USER); - 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: HandleSetEnabledForBundleSlot01 - * @tc.desc: Test HandleSetEnabledForBundleSlot succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetEnabledForBundleSlot01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - string bundlename = "bundle1"; - bundleOption->SetBundleName(bundlename); - int32_t type = 4; - bool enabled = true; - bool isForceControl = false; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(type); - data.WriteBool(enabled); - data.WriteBool(isForceControl); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleSetEnabledForBundleSlot02 - * @tc.desc: Test bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetEnabledForBundleSlot02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t type = 4; - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(type); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetEnabledForBundleSlot03 - * @tc.desc: Test type in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetEnabledForBundleSlot03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetEnabledForBundleSlot04 - * @tc.desc: Test enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetEnabledForBundleSlot04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_ENABLED_FOR_BUNDLE_SLOT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t type = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(type); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetEnabledForBundleSlot01 - * @tc.desc: Test HandleGetEnabledForBundleSlot succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetEnabledForBundleSlot01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t type = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(type); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleGetEnabledForBundleSlot02 - * @tc.desc: Test bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetEnabledForBundleSlot02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t type = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(type); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetEnabledForBundleSlot03 - * @tc.desc: Test type in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetEnabledForBundleSlot03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT); - 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)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetEnabledForBundleSlotSelf01 - * @tc.desc: Test type in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetEnabledForBundleSlotSelf01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_ENABLED_FOR_BUNDLE_SLOT_SELF); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - int32_t type = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(type); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleSetBadgeNumber03 - * @tc.desc: HandleSetBadgeNumber. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSetBadgeNumber03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_BADGE_NUMBER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - int32_t type = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(type); - data.WriteString(""); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandleDistributedSetEnabledWithoutApp01 - * @tc.desc: Test HandleDistributedSetEnabledWithoutApp succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleDistributedSetEnabledWithoutApp01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t userId = 4; - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(userId); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleDistributedSetEnabledWithoutApp02 - * @tc.desc: Test userId in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleDistributedSetEnabledWithoutApp02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP); - 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: HandleDistributedSetEnabledWithoutApp03 - * @tc.desc: Test enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleDistributedSetEnabledWithoutApp03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleDistributedGetEnabledWithoutApp01 - * @tc.desc: Test HandleDistributedGetEnabledWithoutApp succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleDistributedGetEnabledWithoutApp01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleDistributedGetEnabledWithoutApp02 - * @tc.desc: Test userId in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleDistributedGetEnabledWithoutApp02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_SYNC_NOTIFICATION_ENABLED_WITHOUT_APP); - 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: GetSlots01 - * @tc.desc: Test GetSlots return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetSlots01, Function | SmallTest | Level1) -{ - std::vector> slots; - sptr slot = new NotificationSlot(); - slots.emplace_back(slot); - - ErrCode result = ansManagerStub_->GetSlots(slots); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetSpecialActiveNotifications01 - * @tc.desc: Test GetSpecialActiveNotifications return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetSpecialActiveNotifications01, Function | SmallTest | Level1) -{ - std::vector keys; - std::string key = "this is key"; - keys.emplace_back(key); - std::vector> notifications; - sptr notification = new Notification(); - notifications.emplace_back(notification); - - ErrCode result = ansManagerStub_->GetSpecialActiveNotifications(keys, notifications); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: PublishAsBundle01 - * @tc.desc: Test PublishAsBundle return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, PublishAsBundle01, Function | SmallTest | Level1) -{ - sptr notification = new NotificationRequest(); - std::string representativeBundle = "this is representativeBundle"; - - ErrCode result = ansManagerStub_->PublishAsBundle(notification, representativeBundle); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: SetNotificationBadgeNum01 - * @tc.desc: Test SetNotificationBadgeNum return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetNotificationBadgeNum01, Function | SmallTest | Level1) -{ - int num = 2; - ErrCode result = ansManagerStub_->SetNotificationBadgeNum(num); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetBundleImportance01 - * @tc.desc: Test GetBundleImportance return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetBundleImportance01, Function | SmallTest | Level1) -{ - int importance = 2; - ErrCode result = ansManagerStub_->GetBundleImportance(importance); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HasNotificationPolicyAccessPermission01 - * @tc.desc: Test HasNotificationPolicyAccessPermission return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HasNotificationPolicyAccessPermission01, Function | SmallTest | Level1) -{ - bool granted = true; - ErrCode result = ansManagerStub_->HasNotificationPolicyAccessPermission(granted); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: RemoveNotification01 - * @tc.desc: Test RemoveNotification return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, RemoveNotification01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - int notificationId = 4; - std::string label = "this is label"; - int32_t removeReason = 2; - ErrCode result = ansManagerStub_->RemoveNotification(bundleOption, notificationId, label, removeReason); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: RemoveAllNotifications01 - * @tc.desc: Test RemoveAllNotifications return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, RemoveAllNotifications01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - ErrCode result = ansManagerStub_->RemoveAllNotifications(bundleOption); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: Delete01 - * @tc.desc: Test Delete return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, Delete01, Function | SmallTest | Level1) -{ - std::string key = "this is key"; - int32_t removeReason = 2; - ErrCode result = ansManagerStub_->Delete(key, removeReason); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: DeleteByBundle01 - * @tc.desc: Test DeleteByBundle return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, DeleteByBundle01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - ErrCode result = ansManagerStub_->DeleteByBundle(bundleOption); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: DeleteAll01 - * @tc.desc: Test DeleteAll return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, DeleteAll01, Function | SmallTest | Level1) -{ - ErrCode result = ansManagerStub_->DeleteAll(); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetSlotsByBundle01 - * @tc.desc: Test GetSlotsByBundle return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetSlotsByBundle01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - std::vector> slots; - sptr slot = new NotificationSlot(); - slots.emplace_back(slot); - - ErrCode result = ansManagerStub_->GetSlotsByBundle(bundleOption, slots); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: UpdateSlots01 - * @tc.desc: Test UpdateSlots return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, UpdateSlots01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - std::vector> slots; - sptr slot = new NotificationSlot(); - slots.emplace_back(slot); - - ErrCode result = ansManagerStub_->UpdateSlots(bundleOption, slots); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: RequestEnableNotification01 - * @tc.desc: Test RequestEnableNotification return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, RequestEnableNotification01, Function | SmallTest | Level1) -{ - std::string deviceId = "this is deviceId"; - sptr callback = nullptr; - sptr callerToken = nullptr; - ErrCode result = ansManagerStub_->RequestEnableNotification(deviceId, callback, callerToken); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: SetNotificationsEnabledForBundle01 - * @tc.desc: Test SetNotificationsEnabledForBundle return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetNotificationsEnabledForBundle01, Function | SmallTest | Level1) -{ - std::string bundle = "this is bundle"; - bool enabled = true; - - ErrCode result = ansManagerStub_->SetNotificationsEnabledForBundle(bundle, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: SetNotificationsEnabledForAllBundles01 - * @tc.desc: Test SetNotificationsEnabledForAllBundles return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetNotificationsEnabledForAllBundles01, Function | SmallTest | Level1) -{ - std::string deviceId = "this is deviceId"; - bool enabled = true; - - ErrCode result = ansManagerStub_->SetNotificationsEnabledForAllBundles(deviceId, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: SetNotificationsEnabledForSpecialBundle01 - * @tc.desc: Test SetNotificationsEnabledForSpecialBundle return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetNotificationsEnabledForSpecialBundle01, Function | SmallTest | Level1) -{ - std::string deviceId = "this is deviceId"; - sptr bundleOption = new NotificationBundleOption(); - bool enabled = true; - - ErrCode result = ansManagerStub_->SetNotificationsEnabledForSpecialBundle(deviceId, bundleOption, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: SetShowBadgeEnabledForBundle01 - * @tc.desc: Test SetShowBadgeEnabledForBundle return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetShowBadgeEnabledForBundle01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - bool enabled = true; - - ErrCode result = ansManagerStub_->SetShowBadgeEnabledForBundle(bundleOption, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetShowBadgeEnabledForBundle01 - * @tc.desc: Test GetShowBadgeEnabledForBundle return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetShowBadgeEnabledForBundle01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - bool enabled = true; - - ErrCode result = ansManagerStub_->GetShowBadgeEnabledForBundle(bundleOption, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetShowBadgeEnabled01 - * @tc.desc: Test GetShowBadgeEnabled return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetShowBadgeEnabled01, Function | SmallTest | Level1) -{ - bool enabled = true; - - ErrCode result = ansManagerStub_->GetShowBadgeEnabled(enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: IsAllowedNotify01 - * @tc.desc: Test IsAllowedNotify return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, IsAllowedNotify01, Function | SmallTest | Level1) -{ - bool allowed = true; - - ErrCode result = ansManagerStub_->IsAllowedNotify(allowed); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: IsAllowedNotifySelf01 - * @tc.desc: Test IsAllowedNotifySelf return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, IsAllowedNotifySelf01, Function | SmallTest | Level1) -{ - bool allowed = true; - - ErrCode result = ansManagerStub_->IsAllowedNotifySelf(allowed); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: IsSpecialBundleAllowedNotify01 - * @tc.desc: Test IsSpecialBundleAllowedNotify return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, IsSpecialBundleAllowedNotify01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - bool allowed = true; - - ErrCode result = ansManagerStub_->IsSpecialBundleAllowedNotify(bundleOption, allowed); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: CancelGroup01 - * @tc.desc: Test CancelGroup return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, CancelGroup01, Function | SmallTest | Level1) -{ - std::string groupName = "this is groupName"; - - ErrCode result = ansManagerStub_->CancelGroup(groupName, ""); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: RemoveGroupByBundle01 - * @tc.desc: Test RemoveGroupByBundle return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, RemoveGroupByBundle01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - std::string groupName = "this is groupName"; - - ErrCode result = ansManagerStub_->RemoveGroupByBundle(bundleOption, groupName); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: SetDoNotDisturbDate01 - * @tc.desc: Test SetDoNotDisturbDate return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetDoNotDisturbDate01, Function | SmallTest | Level1) -{ - sptr date = new NotificationDoNotDisturbDate(); - - ErrCode result = ansManagerStub_->SetDoNotDisturbDate(date); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetDoNotDisturbDate01 - * @tc.desc: Test GetDoNotDisturbDate return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetDoNotDisturbDate01, Function | SmallTest | Level1) -{ - sptr date = new NotificationDoNotDisturbDate(); - - ErrCode result = ansManagerStub_->GetDoNotDisturbDate(date); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: DoesSupportDoNotDisturbMode01 - * @tc.desc: Test DoesSupportDoNotDisturbMode return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, DoesSupportDoNotDisturbMode01, Function | SmallTest | Level1) -{ - bool doesSupport = true; - - ErrCode result = ansManagerStub_->DoesSupportDoNotDisturbMode(doesSupport); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: IsDistributedEnabled01 - * @tc.desc: Test IsDistributedEnabled return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, IsDistributedEnabled01, Function | SmallTest | Level1) -{ - bool enabled = true; - - ErrCode result = ansManagerStub_->IsDistributedEnabled(enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: EnableDistributed01 - * @tc.desc: Test EnableDistributed return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, EnableDistributed01, Function | SmallTest | Level1) -{ - bool enabled = true; - - ErrCode result = ansManagerStub_->EnableDistributed(enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: EnableDistributedByBundle01 - * @tc.desc: Test EnableDistributedByBundle return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, EnableDistributedByBundle01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - bool enabled = true; - - ErrCode result = ansManagerStub_->EnableDistributedByBundle(bundleOption, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: EnableDistributedSelf01 - * @tc.desc: Test EnableDistributedSelf return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, EnableDistributedSelf01, Function | SmallTest | Level1) -{ - bool enabled = true; - - ErrCode result = ansManagerStub_->EnableDistributedSelf(enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: IsDistributedEnableByBundle01 - * @tc.desc: Test IsDistributedEnableByBundle return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, IsDistributedEnableByBundle01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - bool enabled = true; - - ErrCode result = ansManagerStub_->IsDistributedEnableByBundle(bundleOption, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetDeviceRemindType01 - * @tc.desc: Test GetDeviceRemindType return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetDeviceRemindType01, Function | SmallTest | Level1) -{ - NotificationConstant::RemindType remindType = NotificationConstant::RemindType::NONE; - - ErrCode result = ansManagerStub_->GetDeviceRemindType(remindType); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: PublishContinuousTaskNotification01 - * @tc.desc: Test PublishContinuousTaskNotification return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, PublishContinuousTaskNotification01, Function | SmallTest | Level1) -{ - sptr request = new NotificationRequest(); - - ErrCode result = ansManagerStub_->PublishContinuousTaskNotification(request); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: CancelContinuousTaskNotification01 - * @tc.desc: Test CancelContinuousTaskNotification return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, CancelContinuousTaskNotification01, Function | SmallTest | Level1) -{ - std::string label = "this is label"; - int32_t notificationId = 4; - - ErrCode result = ansManagerStub_->CancelContinuousTaskNotification(label, notificationId); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: IsSupportTemplate01 - * @tc.desc: Test IsSupportTemplate return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, IsSupportTemplate01, Function | SmallTest | Level1) -{ - std::string templateName = "this is templateName"; - bool support = true; - - ErrCode result = ansManagerStub_->IsSupportTemplate(templateName, support); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: IsSpecialUserAllowedNotify01 - * @tc.desc: Test IsSpecialUserAllowedNotify return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, IsSpecialUserAllowedNotify01, Function | SmallTest | Level1) -{ - int32_t userId = 2; - bool allowed = true; - - ErrCode result = ansManagerStub_->IsSpecialUserAllowedNotify(userId, allowed); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: SetNotificationsEnabledByUser01 - * @tc.desc: Test SetNotificationsEnabledByUser return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetNotificationsEnabledByUser01, Function | SmallTest | Level1) -{ - int32_t deviceId = 2; - bool enabled = true; - - ErrCode result = ansManagerStub_->SetNotificationsEnabledByUser(deviceId, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: DeleteAllByUser01 - * @tc.desc: Test DeleteAllByUser return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, DeleteAllByUser01, Function | SmallTest | Level1) -{ - int32_t userId = 2; - - ErrCode result = ansManagerStub_->DeleteAllByUser(userId); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: SetDoNotDisturbDate02 - * @tc.desc: Test SetDoNotDisturbDate return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetDoNotDisturbDate02, Function | SmallTest | Level1) -{ - int32_t userId = 2; - sptr date = new NotificationDoNotDisturbDate(); - - ErrCode result = ansManagerStub_->SetDoNotDisturbDate(userId, date); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetDoNotDisturbDate02 - * @tc.desc: Test GetDoNotDisturbDate return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetDoNotDisturbDate02, Function | SmallTest | Level1) -{ - int32_t userId = 2; - sptr date = new NotificationDoNotDisturbDate(); - - ErrCode result = ansManagerStub_->GetDoNotDisturbDate(userId, date); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: SetEnabledForBundleSlot01 - * @tc.desc: Test SetEnabledForBundleSlot return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetEnabledForBundleSlot01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER; - bool enabled = true; - - ErrCode result = ansManagerStub_->SetEnabledForBundleSlot(bundleOption, slotType, enabled, false); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetEnabledForBundleSlot01 - * @tc.desc: Test GetEnabledForBundleSlot return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetEnabledForBundleSlot01, Function | SmallTest | Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - NotificationConstant::SlotType slotType = NotificationConstant::SlotType::SERVICE_REMINDER; - bool enabled = true; - - ErrCode result = ansManagerStub_->GetEnabledForBundleSlot(bundleOption, slotType, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: ShellDump01 - * @tc.desc: Test ShellDump return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, ShellDump01, Function | SmallTest | Level1) -{ - std::string cmd = "this is cmd"; - std::string bundle = "this is bundle"; - int32_t userId = 5; - std::vector dumpInfo; - - ErrCode result = ansManagerStub_->ShellDump(cmd, bundle, userId, 0, dumpInfo); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: SetSyncNotificationEnabledWithoutApp01 - * @tc.desc: Test SetSyncNotificationEnabledWithoutApp return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetSyncNotificationEnabledWithoutApp01, Function | SmallTest | Level1) -{ - int32_t userId = 2; - bool enabled = true; - - ErrCode result = ansManagerStub_->SetSyncNotificationEnabledWithoutApp(userId, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetSyncNotificationEnabledWithoutApp01 - * @tc.desc: Test GetSyncNotificationEnabledWithoutApp return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetSyncNotificationEnabledWithoutApp01, Function | SmallTest | Level1) -{ - int32_t userId = 2; - bool enabled = true; - - ErrCode result = ansManagerStub_->GetSyncNotificationEnabledWithoutApp(userId, enabled); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: Subscribe01 - * @tc.desc: Test Subscribe return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, Subscribe01, Function | SmallTest | Level1) -{ - sptr info = new NotificationSubscribeInfo(); - - ErrCode result = ansManagerStub_->Subscribe(nullptr, info); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: Unsubscribe01 - * @tc.desc: Test Unsubscribe return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, Unsubscribe01, Function | SmallTest | Level1) -{ - sptr info = new NotificationSubscribeInfo(); - - ErrCode result = ansManagerStub_->Unsubscribe(nullptr, info); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandleSetBadgeNumber01 - * @tc.desc: Test HandleSetBadgeNumber succeed. - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerStubTest, HandleSetBadgeNumber01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t badgeNumber = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(badgeNumber); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleSetBadgeNumber02 - * @tc.desc: Test badgeNumber in data is null. - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerStubTest, HandleSetBadgeNumber02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::DELETE_ALL_NOTIFICATIONS_BY_USER); - 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: HandleSetAdditionConfig01 - * @tc.desc: Test HandleSetAdditionConfig. - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerStubTest, HandleSetAdditionConfig01, Function | SmallTest | Level1) -{ - MessageParcel data; - MessageParcel reply; - - data.WriteString("key"); - data.WriteString("value"); - - ErrCode ret = ansManagerStub_->HandleSetAdditionConfig(data, reply); - EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandleSetAdditionConfig02 - * @tc.desc: Test HandleSetAdditionConfig. - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerStubTest, HandleSetAdditionConfig02, Function | SmallTest | Level1) -{ - MessageParcel data; - MessageParcel reply; - - data.WriteString("key"); - - ErrCode ret = ansManagerStub_->HandleSetAdditionConfig(data, reply); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetAdditionConfig03 - * @tc.desc: Test HandleSetAdditionConfig. - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerStubTest, HandleSetAdditionConfig03, Function | SmallTest | Level1) -{ - MessageParcel data; - MessageParcel reply; - - ErrCode ret = ansManagerStub_->HandleSetAdditionConfig(data, reply); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleRemoveNotifications01 - * @tc.desc: Test HandleRemoveNotifications function - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveNotifications01, Function | SmallTest | Level1) -{ - MessageParcel data; - MessageParcel reply; - ErrCode ret = ansManagerStub_->HandleRemoveNotifications(data, reply); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleUnregisterPushCallback01 - * @tc.desc: Test HandleUnregisterPushCallback function - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerStubTest, HandleUnregisterPushCallback01, Function | SmallTest | Level1) -{ - MessageParcel data; - MessageParcel reply; - ErrCode ret = ansManagerStub_->HandleUnregisterPushCallback(data, reply); - EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandleRegisterPushCallback01 - * @tc.desc: Test HandleRegisterPushCallback function - * @tc.type: FUNC - * @tc.require: #I6C2X9 - */ -HWTEST_F(AnsManagerStubTest, HandleRegisterPushCallback01, Function | SmallTest | Level1) -{ - MessageParcel data; - MessageParcel reply; - ErrCode ret = ansManagerStub_->HandleRegisterPushCallback(data, reply); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleRegisterPushCallback02 - * @tc.desc: Test HandleRegisterPushCallback succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRegisterPushCallback02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::REGISTER_PUSH_CALLBACK); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - sptr callback = new AnsDialogHostClient(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(callback->AsObject()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_NE((int)ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleRegisterPushCallback03 - * @tc.desc: Test HandleRegisterPushCallback succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRegisterPushCallback03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::REGISTER_PUSH_CALLBACK); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - sptr callback = new AnsDialogHostClient(); - sptr checkRequest = nullptr; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(callback->AsObject()); - data.WriteParcelable(checkRequest); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetSlotFlagsAsBundle01 - * @tc.desc: Test HandleGetSlotFlagsAsBundle succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetSlotFlagsAsBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_SLOTFLAGS_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - uint32_t res = 305; - - sptr bundleOption = new NotificationBundleOption(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_NE((int)ret, (int)res); -} - -/** - * @tc.name: HandleGetSlotFlagsAsBundle02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetSlotFlagsAsBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_SLOTFLAGS_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - uint32_t res = 305; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_NE((int)ret, (int)res); -} - -/* - * @tc.name: SetSmartReminderEnabled_0100 - * @tc.desc: test SetSmartReminderEnabled with parameters - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, SetSmartReminderEnabled_0100, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - bool enabled = true; - data.WriteString("testDeviceType"); - data.WriteBool(enabled); - - ErrCode res = ansManagerStub_->HandleSetSmartReminderEnabled(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/** - * @tc.name: IsSmartReminderEnabled_0100 - * @tc.desc: test IsSmartReminderEnabled with parameters - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, IsSmartReminderEnabled_0100, TestSize.Level1) -{ - bool enable = true; - MessageParcel data; - MessageParcel reply; - data.WriteString("testDeviceType1111"); - data.WriteBool(enable); - ErrCode result = ansManagerStub_->HandleIsSmartReminderEnabled(data, reply); - EXPECT_EQ(result, ERR_OK); -} - -/** - * @tc.name: HandleSetSlotFlagsAsBundle01 - * @tc.desc: Test HandleSetSlotFlagsAsBundle succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetSlotFlagsAsBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_SLOTFLAGS_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - uint32_t res = 305; - - sptr bundleOption = new NotificationBundleOption(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_NE((int)ret, (int)res); -} - -/** - * @tc.name: HandleGetAllNotificationEnableStatus - * @tc.desc: Test HandleGetAllNotificationEnableStatus. - * @tc.type: FUNC - * @tc.require: issueI92VGR - */ -HWTEST_F(AnsManagerStubTest, HandleGetAllNotificationEnableStatus01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_ALL_NOTIFICATION_ENABLE_STATUS); - 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_OK); -} - -/** - * @tc.name: HandleSetSlotFlagsAsBundle02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetSlotFlagsAsBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::SET_SLOTFLAGS_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - uint32_t res = 305; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_NE((int)ret, (int)res); -} - -/* - * @tc.name: SetDistributedEnabledByBundle_0100 - * @tc.desc: test SetDistributedEnabledByBundle with parameters - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, SetDistributedEnabledByBundle_0100, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - sptr bundleOption = new NotificationBundleOption(); - bundleOption->SetBundleName("bundleName"); - bundleOption->SetUid(1); - std::string deviceType = "testDeviceType"; - bool enabled = true; - data.WriteParcelable(bundleOption); - data.WriteString(deviceType); - data.WriteBool(enabled); - - ErrCode res = ansManagerStub_->HandleSetDistributedEnabledByBundle(data, reply); - EXPECT_EQ(res, ERR_OK); -} - -/* - * @tc.name: SetDistributedEnabledByBundle_0200 - * @tc.desc: test SetDistributedEnabledByBundle - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, SetDistributedEnabledByBundle_0200, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - data.WriteParcelable(nullptr); - - ErrCode res = ansManagerStub_->HandleSetDistributedEnabledByBundle(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: IsDistributedEnabledByBundle_0100 - * @tc.desc: test IsDistributedEnabledByBundle with parameters - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, IsDistributedEnabledByBundle_0100, TestSize.Level1) -{ - sptr bundleOption = new NotificationBundleOption(); - bundleOption->SetBundleName("bundleName"); - bundleOption->SetUid(1); - std::string deviceType = "testDeviceType1111"; - bool enable = true; - - MessageParcel data; - MessageParcel reply; - data.WriteParcelable(bundleOption); - data.WriteString(deviceType); - data.WriteBool(enable); - ErrCode result = ansManagerStub_->HandleIsDistributedEnabledByBundle(data, reply); - EXPECT_EQ(result, ERR_OK); -} - -/** - * @tc.name: IsDistributedEnabledByBundle_0200 - * @tc.desc: test IsDistributedEnabledByBundle with parameters - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, IsDistributedEnabledByBundle_0200, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - - data.WriteParcelable(nullptr); - - ErrCode result = ansManagerStub_->HandleIsDistributedEnabledByBundle(data, reply); - EXPECT_EQ(result, ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetBadgeNumberByBundle01 - * @tc.desc: Test HandleSetBadgeNumberByBundle with invalid data, expect error code ERR_ANS_PARCELABLE_FAILED. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, HandleSetBadgeNumberByBundle01, Function | SmallTest | Level1) -{ - ASSERT_NE(ansManagerStub_, nullptr); - MessageParcel data; - MessageParcel reply; - - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - EXPECT_NE(bundleOption, nullptr); - data.WriteParcelable(bundleOption); - - ErrCode ret = ansManagerStub_->HandleSetBadgeNumberByBundle(data, reply); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); - - int32_t badgeNumber = 4; - data.WriteInt32(badgeNumber); - ret = ansManagerStub_->HandleSetBadgeNumberByBundle(data, reply); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetBadgeNumberByBundle02 - * @tc.desc: Test HandleSetBadgeNumberByBundle with valid data, expect error code ERR_INVALID_OPERATION. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, HandleSetBadgeNumberByBundle02, Function | SmallTest | Level1) -{ - ASSERT_NE(ansManagerStub_, nullptr); - MessageParcel data; - MessageParcel reply; - - sptr bundleOption = new (std::nothrow) NotificationBundleOption(); - EXPECT_NE(bundleOption, nullptr); - std::string bundleName = "bundleName"; - bundleOption->SetBundleName(bundleName); - data.WriteParcelable(bundleOption); - int32_t badgeNumber = 4; - data.WriteInt32(badgeNumber); - ErrCode ret = ansManagerStub_->HandleSetBadgeNumberByBundle(data, reply); - EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandleAddDoNotDisturbProfiles_0100 - * @tc.desc: test HandleAddDoNotDisturbProfiles when ReadParcelableVector return false. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, HandleAddDoNotDisturbProfiles_0100, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - ErrCode ret = ansManagerStub_->HandleAddDoNotDisturbProfiles(data, reply); - EXPECT_EQ(ret, ERR_OK); -} - -/** - * @tc.name: HandleAddDoNotDisturbProfiles_0200 - * @tc.desc: test HandleAddDoNotDisturbProfiles success. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, HandleAddDoNotDisturbProfiles_0200, TestSize.Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_SLOTS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - 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); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - ErrCode result = ansManagerStub_->AddDoNotDisturbProfiles(profiles); - ansManagerStub_->WriteParcelableVector(profiles, reply, result); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleRemoveDoNotDisturbProfiles_0200 - * @tc.desc: test HandleRemoveDoNotDisturbProfiles success. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveDoNotDisturbProfiles, TestSize.Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::GET_SLOTS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - 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); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - ErrCode result = ansManagerStub_->AddDoNotDisturbProfiles(profiles); - ansManagerStub_->WriteParcelableVector(profiles, reply, result); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED -/* - * @tc.name: RegisterSwingCallback_0100 - * @tc.desc: test RegisterSwingCallback with parameters - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, RegisterSwingCallback_0100, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - sptr swingCallback = nullptr; - data.WriteRemoteObject(swingCallback); - ErrCode res = ansManagerStub_->HandleRegisterSwingCallback(data, reply); - EXPECT_EQ(res, ERR_ANS_PARCELABLE_FAILED); -} - -/* - * @tc.name: RegisterSwingCallback_0200 - * @tc.desc: test RegisterSwingCallback with parameters - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, RegisterSwingCallback_0200, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - sptr swingCallback = nullptr; - data.WriteRemoteObject(swingCallback); - ErrCode res = ansManagerStub_->HandleRegisterSwingCallback(data, reply); - 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); -} - -/** - * @tc.name: UpdateNotificationTimerByUid_01 - * @tc.desc: Test UpdateNotificationTimerByUid return. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, UpdateNotificationTimerByUid_01, Function | SmallTest | Level1) -{ - int32_t uid = 20099999; - bool isPaused = true; - ErrCode result = ansManagerStub_->UpdateNotificationTimerByUid(uid, isPaused); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandleDisableNotificationFeature_01 - * @tc.desc: Test HandleDisableNotificationFeature. - * @tc.type: FUNC - */ -HWTEST_F(AnsManagerStubTest, HandleDisableNotificationFeature_01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(NotificationInterfaceCode::DISABLE_NOTIFICATION_FEATURE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - sptr testNotificationDisable = new (std::nothrow) NotificationDisable(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(testNotificationDisable); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, ERR_OK); -} -} -} 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 b47258818424f9290686ffb86d3401aae542d1ec..ab1f30fe5477177787b98a08b94a633bb737dac6 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,1274 +1,1273 @@ -/* - * Copyright (c) 2022-2025 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 MockQueryForgroundOsAccountId(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); -} - -#ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED -/** - * @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); - std::shared_ptr record1 = std::make_shared(); - record1->notification = new Notification(); - record1->request = new NotificationRequest(); - record1->request->SetOwnerUid(uid); - record1->request->SetReceiverUserId(0); - advancedNotificationService.notificationList_.push_back(record1); - 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_01300 - * @tc.name : AdvancedNotificationService_01300 - * @tc.desc : test DistributedNotificationDump function and recvUserId != record->notification->GetRecvUserId(). - */ -HWTEST_F(NotificationSubscriberManagerBranchTest, AdvancedNotificationService_01300, 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->request->SetReceiverUserId(2); - MockGetUserId(false); - 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); -} -#endif - -/** - * @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 = new NotificationBundleOption(); - 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); - MockQueryForgroundOsAccountId(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 = new NotificationBundleOption(); - 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); - MockQueryForgroundOsAccountId(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(); - MockQueryForgroundOsAccountId(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 = "