diff --git a/frameworks/core/include/ans_manager_stub.h b/frameworks/core/include/ans_manager_stub.h index 256fc2be882c1daef9b00674d5faf30b1df605f5..0434a0498ac8ca23d9f956fc0f194139041cacfd 100644 --- a/frameworks/core/include/ans_manager_stub.h +++ b/frameworks/core/include/ans_manager_stub.h @@ -41,668 +41,6 @@ public: 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 on a specified remote device. - * @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. - * @param deviceId Indicates the ID of the remote device. If this parameter is null or an empty string, - * the notification will be published on the local device. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode PublishToDevice( - const sptr ¬ification, const std::string &deviceId) 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. - * @return Returns cancel notification result. - */ - virtual ErrCode Cancel(int32_t notificationId, const std::string &label) override; - - /** - * @brief Cancels all the published notifications. - * - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CancelAll() 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 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) 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; - - /** - * @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; - - /** - * @brief Allows another application to act as an agent to publish notifications in the name of your application - * bundle. - * - * @param agent Indicates the name of the application bundle that can publish notifications for your application. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetNotificationAgent(const std::string &agent) override; - - /** - * @brief Obtains the name of the application bundle that can publish notifications in the name of your application. - * - * @param agent Indicates the name of the application bundle that can publish notifications for your application if - * any; returns null otherwise. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetNotificationAgent(std::string &agent) 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 Set whether to allow private notifications. - * - * @param allow Indicates the flag that allows private notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetPrivateNotificationsAllowed(bool allow) override; - - /** - * @brief Get whether to allow private notifications. - * - * @param allow Indicates the flag that allows private notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetPrivateNotificationsAllowed(bool &allow) 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; - - /** - * @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 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) 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 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 Obtains whether notifications are suspended. - * - * @param suspended Indicates the suspended status. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode AreNotificationsSuspended(bool &suspended) 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 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 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 Cancel notifications according to group. - * - * @param groupName Indicates the group name. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CancelGroup(const std::string &groupName) 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 Publishes a reminder notification. - * - * @param reminder Identifies the reminder notification request that needs to be published. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode PublishReminder(sptr &reminder) override; - - /** - * @brief Cancel a reminder notifications. - * - * @param reminderId Identifies the reminders id that needs to be canceled. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CancelReminder(const int32_t reminderId) override; - - /** - * @brief Get all valid reminder notifications. - * - * @param reminders Identifies the list of all valid notifications. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetValidReminders(std::vector> &reminders) override; - - /** - * @brief Cancel all reminder notifications. - * - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode CancelAllReminders() 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) override; - virtual ErrCode GetEnabledForBundleSlot(const sptr &bundleOption, - 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, - 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) override; - private: static const std::map> interfaces_; diff --git a/frameworks/core/src/ans_manager_stub.cpp b/frameworks/core/src/ans_manager_stub.cpp index 545cc24ec4c3e686c871dc5e630d9ad27d6a9f20..065a4acc97c848d5f129ad7f2803bbdb5686e52f 100644 --- a/frameworks/core/src/ans_manager_stub.cpp +++ b/frameworks/core/src/ans_manager_stub.cpp @@ -1795,462 +1795,5 @@ ErrCode AnsManagerStub::HandleSetBadgeNumber(MessageParcel &data, MessageParcel } return result; } - -ErrCode AnsManagerStub::Publish(const std::string &label, const sptr ¬ification) -{ - ANS_LOGE("AnsManagerStub::Publish called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::PublishToDevice(const sptr ¬ification, const std::string &deviceId) -{ - ANS_LOGE("AnsManagerStub::PublishToDevice called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::Cancel(int notificationId, const std::string &label) -{ - ANS_LOGE("AnsManagerStub::Cancel called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAll() -{ - 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::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) -{ - 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::SetNotificationAgent(const std::string &agent) -{ - ANS_LOGE("AnsManagerStub::SetNotificationAgent called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetNotificationAgent(std::string &agent) -{ - ANS_LOGE("AnsManagerStub::GetNotificationAgent 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::HasNotificationPolicyAccessPermission(bool &granted) -{ - ANS_LOGE("AnsManagerStub::HasNotificationPolicyAccessPermission called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::SetPrivateNotificationsAllowed(bool allow) -{ - ANS_LOGE("AnsManagerStub::SetPrivateNotificationsAllowed called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetPrivateNotificationsAllowed(bool &allow) -{ - ANS_LOGE("AnsManagerStub::GetPrivateNotificationsAllowed 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::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::UpdateSlots( - const sptr &bundleOption, const std::vector> &slots) -{ - ANS_LOGE("AnsManagerStub::UpdateSlots called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::RequestEnableNotification(const std::string &deviceId) -{ - 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::Unsubscribe(const sptr &subscriber, - const sptr &info) -{ - ANS_LOGE("AnsManagerStub::Unsubscribe called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::AreNotificationsSuspended(bool &suspended) -{ - ANS_LOGE("AnsManagerStub::AreNotificationsSuspended 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::IsSpecialBundleAllowedNotify(const sptr &bundleOption, bool &allowed) -{ - ANS_LOGE("AnsManagerStub::IsSpecialBundleAllowedNotify called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelGroup(const std::string &groupName) -{ - 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::DoesSupportDoNotDisturbMode(bool &doesSupport) -{ - ANS_LOGE("AnsManagerStub::DoesSupportDoNotDisturbMode 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::PublishReminder(sptr &reminder) -{ - ANS_LOGE("AnsManagerStub::PublishReminder called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelReminder(const int32_t reminderId) -{ - ANS_LOGE("AnsManagerStub::CancelReminder called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetValidReminders(std::vector> &reminders) -{ - ANS_LOGE("AnsManagerStub::getValidReminders called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::CancelAllReminders() -{ - ANS_LOGE("AnsManagerStub::cancelAllReminders 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) -{ - 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::ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, - 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) -{ - ANS_LOGE("AnsManagerStub::SetBadgeNumber called!"); - return ERR_INVALID_OPERATION; -} } // namespace Notification } // namespace OHOS diff --git a/frameworks/core/test/unittest/BUILD.gn b/frameworks/core/test/unittest/BUILD.gn index c088cd31fbacb303aadd1147128c7ac528e69da2..eefa6d4cb97ba612bee5f4809425aef495e7f661 100644 --- a/frameworks/core/test/unittest/BUILD.gn +++ b/frameworks/core/test/unittest/BUILD.gn @@ -19,7 +19,6 @@ group("unittest") { "ans_image_util_test:unittest", "ans_manager_death_recipient_test:unittest", "ans_manager_proxy_test:unittest", - "ans_manager_stub_test:unittest", "ans_notification_annex_test:unittest", "ans_notification_test:unittest", "ans_subscriber_proxy_test:unittest", diff --git a/frameworks/core/test/unittest/ans_manager_stub_test/BUILD.gn b/frameworks/core/test/unittest/ans_manager_stub_test/BUILD.gn deleted file mode 100644 index f0b1edc232e5dc511c8f6b1f54becbfff141d3d8..0000000000000000000000000000000000000000 --- a/frameworks/core/test/unittest/ans_manager_stub_test/BUILD.gn +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/ohos.gni") -import("//build/test.gni") - -module_output_path = "${component_name}/unittest" - -ohos_unittest("ans_manager_stub_test") { - module_out_path = module_output_path - include_dirs = [ - "${core_path}/include", - "//commonlibrary/c_utils/base/include", - ] - - sources = [ "ans_manager_stub_test.cpp" ] - - deps = [ "${core_path}:ans_core" ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "ability_runtime:wantagent_innerkits", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_framework:image_native", - "relational_store:native_rdb", - ] - - subsystem_name = "${subsystem_name}" - part_name = "${component_name}" -} - -group("unittest") { - testonly = true - deps = [] - - deps += [ ":ans_manager_stub_test" ] -} diff --git a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp deleted file mode 100644 index ab12c0e3ed93b6abd1edd07a64d80e86e5782d73..0000000000000000000000000000000000000000 --- a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp +++ /dev/null @@ -1,4400 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#define private public -#define protected public -#include "ans_manager_stub.h" -#include "ans_subscriber_stub.h" -#include "reminder_request_alarm.h" -#include "reminder_request_timer.h" -#include "reminder_request_calendar.h" -#undef private -#undef protected - -#include "ans_inner_errors.h" - -using namespace testing::ext; -namespace OHOS { -namespace Notification { -class AnsManagerStubTest : public testing::Test { -public: - static void SetUpTestCase() {} - static void TearDownTestCase() {} - void SetUp() - { - ansManagerStub_ = new AnsManagerStub(); - } - void TearDown() {} - sptr ansManagerStub_; -}; - -/** - * @tc.name: OnRemoteRequest01 - * @tc.desc: Test if get the wrong descriptor. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, OnRemoteRequest0001, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(u"error.GetDescriptor"); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)OBJECT_NULL); -} - -/** - * @tc.name: OnRemoteRequest02 - * @tc.desc: Test if get the wrong code. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, OnRemoteRequest0002, Function | SmallTest | Level1) -{ - uint32_t code = 267; - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)IPC_STUB_UNKNOW_TRANS_ERR); -} - -/** - * @tc.name: HandlePublish01 - * @tc.desc: Test HandlePublish succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublish01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string label = "this is a notification label"; - sptr notification = new NotificationRequest(); - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(label); - data.WriteParcelable(notification); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandlePublish02 - * @tc.desc: Test if the label is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublish02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr notification = new NotificationRequest(); - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(notification); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandlePublish03 - * @tc.desc: Test if the notification is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublish03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string label = "this is a notification label"; - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(label); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandlePublishToDevice01 - * @tc.desc: Test HandlePublishToDevice succeeds; - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublishToDevice01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION_TO_DEVICE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string deviceId = "this is a deviceId"; - sptr notification = new NotificationRequest(); - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(notification); - data.WriteString(deviceId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandlePublishToDevice02 - * @tc.desc: Test if the notification is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublishToDevice02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION_TO_DEVICE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string deviceId = "this is a deviceId"; - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandlePublishToDevice03 - * @tc.desc: Test if the deviceId in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublishToDevice03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_NOTIFICATION_TO_DEVICE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr notification = new NotificationRequest(); - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(notification); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCancel01 - * @tc.desc: Test HandleCancel succeeds - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancel01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t notificationId = 3; - std::string label = "this is a notification label"; - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(notificationId); - data.WriteString(label); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleCancel02 - * @tc.desc: Test if the notificationId in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancel02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string label = "this is a notification label"; - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(label); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCancel03 - * @tc.desc: Test if the label in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancel03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t notificationId = 3; - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(notificationId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCancelAll01 - * @tc.desc: Test HandleCancelAll succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAll01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_ALL_NOTIFICATIONS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleCancelAsBundle01 - * @tc.desc: Test HandlePublish succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t notificationId = 3; - std::string representativeBundle = "this is a representativeBundle"; - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(notificationId); - data.WriteString(representativeBundle); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleCancelAsBundle02 - * @tc.desc: Test if the notificationId in data is null.. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string representativeBundle = "this is a representativeBundle"; - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(representativeBundle); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCancelAsBundle03 - * @tc.desc: Test if the representativeBundle in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t notificationId = 3; - int32_t userId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(notificationId); - data.WriteInt32(userId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCancelAsBundle04 - * @tc.desc: Test if the userId in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAsBundle04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t notificationId = 3; - std::string representativeBundle = "this is a representativeBundle"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(notificationId); - data.WriteString(representativeBundle); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleAddSlotByType01 - * @tc.desc: Test HandleAddSlotByType succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleAddSlotByType01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::ADD_SLOT_BY_TYPE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleRemoveSlotByType01 - * @tc.desc: Test HandleRemoveSlotByType succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveSlotByType01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_SLOT_BY_TYPE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleRemoveAllSlots01 - * @tc.desc: Test HandleRemoveAllSlots succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveAllSlots01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_ALL_SLOTS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleGetSlotByType01 - * @tc.desc: Test HandleGetSlotByType succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetSlotByType01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_SLOT_BY_TYPE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleGetSlotNumAsBundle01 - * @tc.desc: Test HandleGetSlotNumAsBundle succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetSlotNumAsBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_SLOT_NUM_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleGetSlotNumAsBundle02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetSlotNumAsBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_SLOT_NUM_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetActiveNotifications01 - * @tc.desc: Test HandleGetActiveNotifications succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetActiveNotifications01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_ACTIVE_NOTIFICATIONS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleGetActiveNotificationNums01 - * @tc.desc: Test HandleGetActiveNotificationNums succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetActiveNotificationNums01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_ACTIVE_NOTIFICATION_NUMS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleGetAllActiveNotifications01 - * @tc.desc: Test HandleGetAllActiveNotifications succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetAllActiveNotifications01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_ALL_ACTIVE_NOTIFICATIONS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleSetNotificationAgent01 - * @tc.desc: Test HandleSetNotificationAgent succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationAgent01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_AGENT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string agent = "this is a agent"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(agent); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleSetNotificationAgent02 - * @tc.desc: Test if the agent in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationAgent02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_AGENT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetNotificationAgent01 - * @tc.desc: Test HandleGetNotificationAgent succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetNotificationAgent01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_NOTIFICATION_AGENT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleCanPublishAsBundle01 - * @tc.desc: Test HandleCanPublishAsBundle succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCanPublishAsBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CAN_PUBLISH_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string representativeBundle = "this is a representativeBundle"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(representativeBundle); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleCanPublishAsBundle02 - * @tc.desc: Test if the representativeBundle in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCanPublishAsBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CAN_PUBLISH_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandlePublishAsBundle01 - * @tc.desc: Test HandlePublishAsBundle succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublishAsBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr notification = new NotificationRequest(); - - std::string representativeBundle = "this is a representativeBundle"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(notification); - data.WriteString(representativeBundle); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandlePublishAsBundle02 - * @tc.desc: Test if the notification in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublishAsBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string representativeBundle = "this is a representativeBundle"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(representativeBundle); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandlePublishAsBundle03 - * @tc.desc: Test if the representativeBundle in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublishAsBundle03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_AS_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr notification = new NotificationRequest(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(notification); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetNotificationBadgeNum01 - * @tc.desc: Test HandleSetNotificationBadgeNum succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationBadgeNum01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_BADGE_NUM); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t num = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(num); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleSetNotificationBadgeNum02 - * @tc.desc: Test if the num in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationBadgeNum02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_BADGE_NUM); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetBundleImportance01 - * @tc.desc: Test HandleGetBundleImportance succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetBundleImportance01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_BUNDLE_IMPORTANCE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleSetDoNotDisturbDate01 - * @tc.desc: Test HandleSetDoNotDisturbDate succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDate01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_DO_NOT_DISTURB_DATE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr date = new NotificationDoNotDisturbDate(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(date); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleSetDoNotDisturbDate02 - * @tc.desc: Test if the date in data is null.. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetDoNotDisturbDate02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_DO_NOT_DISTURB_DATE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetDoNotDisturbDate01 - * @tc.desc: Test HandleGetDoNotDisturbDate succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetDoNotDisturbDate01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_DO_NOT_DISTURB_DATE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleDoesSupportDoNotDisturbMode01 - * @tc.desc: Test HandleDoesSupportDoNotDisturbMode01 succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleDoesSupportDoNotDisturbMode01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::DOES_SUPPORT_DO_NOT_DISTURB_MODE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandlePublishContinuousTaskNotification01 - * @tc.desc: Test HandlePublishContinuousTaskNotification succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublishContinuousTaskNotification01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_CONTINUOUS_TASK_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr request = new NotificationRequest(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(request); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandlePublishContinuousTaskNotification02 - * @tc.desc: Test if the request in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandlePublishContinuousTaskNotification02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_CONTINUOUS_TASK_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCancelContinuousTaskNotification01 - * @tc.desc: Test HandleCancelContinuousTaskNotification succeeds. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelContinuousTaskNotification01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_CONTINUOUS_TASK_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string label = "this is a label"; - int32_t notificationId = 3; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(label); - data.WriteInt32(notificationId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleCancelContinuousTaskNotification02 - * @tc.desc: Test if the label in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelContinuousTaskNotification02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_CONTINUOUS_TASK_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t notificationId = 3; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(notificationId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCancelContinuousTaskNotification03 - * @tc.desc: Test if the notificationId in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleCancelContinuousTaskNotification03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_CONTINUOUS_TASK_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string label = "this is a label"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(label); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleIsNotificationPolicyAccessGranted01 - * @tc.desc: Test HandleIsNotificationPolicyAccessGranted succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleIsNotificationPolicyAccessGranted01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::IS_NOTIFICATION_POLICY_ACCESS_GRANTED); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleSetPrivateNotificationsAllowed02 - * @tc.desc: Test if the allow in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetPrivateNotificationsAllowed02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_PRIVATIVE_NOTIFICATIONS_ALLOWED); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetPrivateNotificationsAllowed01 - * @tc.desc: Test HandleGetPrivateNotificationsAllowed succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetPrivateNotificationsAllowed01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_PRIVATIVE_NOTIFICATIONS_ALLOWED); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleRemoveNotification01 - * @tc.desc: Test HandleRemoveNotification succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveNotification01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t notificationId = 1; - std::string label = "this is a label"; - int32_t removeReason = 2; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(notificationId); - data.WriteString(label); - data.WriteInt32(removeReason); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleRemoveNotification02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveNotification02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t notificationId = 1; - std::string label = "this is a label"; - int32_t removeReason = 2; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(notificationId); - data.WriteString(label); - data.WriteInt32(removeReason); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleRemoveNotification03 - * @tc.desc: Test if the notificationId in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveNotification03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - std::string label = "this is a label"; - int32_t removeReason = 2; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteString(label); - data.WriteInt32(removeReason); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleRemoveNotification04 - * @tc.desc: Test if the label in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveNotification04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t notificationId = 1; - int32_t removeReason = 2; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(notificationId); - data.WriteInt32(removeReason); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleRemoveNotification05 - * @tc.desc: Test if the removeReason in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveNotification05, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t notificationId = 1; - std::string label = "this is a label"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(notificationId); - data.WriteString(label); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleRemoveAllNotifications01 - * @tc.desc: Test HandleRemoveAllNotifications succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveAllNotifications01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_ALL_NOTIFICATIONS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleRemoveAllNotifications02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRemoveAllNotifications02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REMOVE_ALL_NOTIFICATIONS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleDelete01 - * @tc.desc: Test HandleDelete succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleDelete01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string key = "this is a key"; - int32_t removeReason = 2; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(key); - data.WriteInt32(removeReason); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleDelete02 - * @tc.desc: Test if the key in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleDelete02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t removeReason = 2; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(removeReason); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleDelete03 - * @tc.desc: Test if the removeReason in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleDelete03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string key = "this is a key"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(key); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleDeleteByBundle01 - * @tc.desc: Test HandleDeleteByBundle succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleDeleteByBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_NOTIFICATION_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleDeleteByBundle02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleDeleteByBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_NOTIFICATION_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleDeleteAll01 - * @tc.desc: Test HandleDeleteAll succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleDeleteAll01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::DELETE_ALL_NOTIFICATIONS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleGetSlotsByBundle01 - * @tc.desc: Test HandleGetSlotsByBundle succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetSlotsByBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_SLOTS_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(bundleOption); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleGetSlotsByBundle02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetSlotsByBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_SLOTS_BY_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleUpdateSlots01 - * @tc.desc: Test HandleUpdateSlots succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleUpdateSlots01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::UPDATE_SLOTS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t infoSize = 3; - sptr slot1 = new NotificationSlot(); - sptr slot2 = new NotificationSlot(); - sptr slot3 = new NotificationSlot(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(infoSize); - data.WriteStrongParcelable(slot1); - data.WriteStrongParcelable(slot2); - data.WriteStrongParcelable(slot3); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleUpdateSlots02 - * @tc.desc: Test if the StrongParcelable:info in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleUpdateSlots02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::UPDATE_SLOTS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t infoSize = 3; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(infoSize); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleUpdateSlots03 - * @tc.desc: Test if the StrongParcelable:info in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleUpdateSlots03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::UPDATE_SLOTS); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleRequestEnableNotification01 - * @tc.desc: Test HandleRequestEnableNotification succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRequestEnableNotification01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REQUEST_ENABLE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string deviceId = "this is a deviceId"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @tc.name: HandleRequestEnableNotification02 - * @tc.desc: Test if the deviceId in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleRequestEnableNotification02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::REQUEST_ENABLE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetNotificationsEnabledForBundle01 - * @tc.desc: Test HandleSetNotificationsEnabledForBundle succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string deviceId = "this is a deviceId"; - bool enabled = false; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleSetNotificationsEnabledForBundle02 - * @tc.desc: Test if the deviceId in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - bool enabled = false; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetNotificationsEnabledForBundle03 - * @tc.desc: Test if the enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForBundle03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string deviceId = "this is a deviceId"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetNotificationsEnabledForAllBundles01 - * @tc.desc: Test HandleSetNotificationsEnabledForAllBundles succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForAllBundles01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string deviceId = "this is a deviceId"; - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleSetNotificationsEnabledForAllBundles02 - * @tc.desc: Test if the deviceId in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForAllBundles02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetNotificationsEnabledForAllBundles03 - * @tc.desc: Test if the enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForAllBundles03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string deviceId = "this is a deviceId"; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetNotificationsEnabledForSpecialBundle01 - * @tc.desc: Test HandleSetNotificationsEnabledForSpecialBundle succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string deviceId = "this is a deviceId"; - sptr bundleOption = new NotificationBundleOption(); - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - data.WriteParcelable(bundleOption); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleSetNotificationsEnabledForSpecialBundle02 - * @tc.desc: Test if the deviceId in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(bundleOption); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetNotificationsEnabledForSpecialBundle03 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string deviceId = "this is a deviceId"; - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetNotificationsEnabledForSpecialBundle04 - * @tc.desc: Test if the enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetNotificationsEnabledForSpecialBundle04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - std::string deviceId = "this is a deviceId"; - sptr bundleOption = new NotificationBundleOption(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteString(deviceId); - data.WriteParcelable(bundleOption); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetShowBadgeEnabledForBundle01 - * @tc.desc: Test HandleSetShowBadgeEnabledForBundle succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetShowBadgeEnabledForBundle01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(bundleOption); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - -/** - * @tc.name: HandleSetShowBadgeEnabledForBundle02 - * @tc.desc: Test if the bundleOption in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetShowBadgeEnabledForBundle02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteBool(enabled); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleSetShowBadgeEnabledForBundle03 - * @tc.desc: Test if the enabled in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetShowBadgeEnabledForBundle03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_SHOW_BADGE_ENABLED_FOR_BUNDLE); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(bundleOption); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::SUBSCRIBE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr subscriber; - bool subcribeInfo = true; - sptr info = new NotificationSubscribeInfo(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(subscriber); - data.WriteBool(subcribeInfo); - data.WriteParcelable(info); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, 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(AnsManagerInterface::TransactId::SUBSCRIBE_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: HandleSubscribe03 - * @tc.desc: Test if the info in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSubscribe03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SUBSCRIBE_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: HandleSubscribe04 - * @tc.desc: Test if the subscriber in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleSubscribe04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SUBSCRIBE_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: HandleUnsubscribe01 - * @tc.desc: Test HandleUnsubscribe succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleUnsubscribe01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::UNSUBSCRIBE_NOTIFICATION); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr subscriber; - bool subcribeInfo = true; - sptr info = new NotificationSubscribeInfo(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteParcelable(subscriber); - 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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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: HandleAreNotificationsSuspended01 - * @tc.desc: Test HandleAreNotificationsSuspended succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleAreNotificationsSuspended01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::ARE_NOTIFICATION_SUSPENDED); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - bool suspended = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteBool(suspended); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_OK); -} - -/** - * @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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::CANCEL_GROUP); - 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_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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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); - - 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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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: HandlePublishReminder01 - * @tc.desc: Test Reminder type ALARM. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandlePublishReminder01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_REMINDER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - uint8_t typeInfo = static_cast(ReminderRequest::ReminderType::ALARM); - sptr reminder = new ReminderRequest(); - sptr reminderRequestAlarm = new ReminderRequestAlarm(); - - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteUint8(typeInfo); - data.WriteStrongParcelable(reminder); - data.WriteParcelable(reminderRequestAlarm); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandlePublishReminder02 - * @tc.desc: Test Reminder type invalid. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandlePublishReminder02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_REMINDER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - uint8_t typeInfo = static_cast(ReminderRequest::ReminderType::INVALID); - sptr reminder = new ReminderRequest(); - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteUint8(typeInfo); - data.WriteParcelable(reminder); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.name: HandlePublishReminder03 - * @tc.desc: Test reminder in date is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandlePublishReminder03, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_REMINDER); - 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: HandlePublishReminder04 - * @tc.desc: Test Reminder type TIMER. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandlePublishReminder04, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_REMINDER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - uint8_t typeInfo = static_cast(ReminderRequest::ReminderType::TIMER); - sptr reminder = new ReminderRequest(); - sptr reminderRequestTimer = new ReminderRequestTimer(); - - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteUint8(typeInfo); - data.WriteStrongParcelable(reminder); - data.WriteParcelable(reminderRequestTimer); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandlePublishReminder05 - * @tc.desc: Test Reminder type CALENDAR. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandlePublishReminder05, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_REMINDER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - uint8_t typeInfo = static_cast(ReminderRequest::ReminderType::CALENDAR); - sptr reminder = new ReminderRequest(); - sptr reminderRequestCalendar = new ReminderRequestCalendar(); - - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteUint8(typeInfo); - data.WriteStrongParcelable(reminder); - data.WriteParcelable(reminderRequestCalendar); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandlePublishReminder06 - * @tc.desc: Test typeInfo in date is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandlePublishReminder06, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::PUBLISH_REMINDER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr reminder = new ReminderRequest(); - sptr reminderRequestCalendar = new ReminderRequestCalendar(); - - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(reminder); - data.WriteParcelable(reminderRequestCalendar); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleCancelReminder01 - * @tc.desc: Test HandleCancelReminder ERR_INVALID_OPERATION. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleCancelReminder01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_REMINDER); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - int32_t reminderId = 4; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteInt32(reminderId); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: HandleCancelReminder02 - * @tc.desc: Test reminderId in data is null. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleCancelReminder02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_REMINDER); - 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: HandleCancelAllReminders01 - * @tc.desc: Test HandleCancelAllReminders result ERR_INVALID_OPERATION. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleCancelAllReminders01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::CANCEL_ALL_REMINDERS); - 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_INVALID_OPERATION); -} - -/** - * @tc.name: HandleGetValidReminders01 - * @tc.desc: Test HandleGetValidReminders result ERR_INVALID_OPERATION. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleGetValidReminders01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_ALL_VALID_REMINDERS); - 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_INVALID_OPERATION); -} - -/** - * @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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::SET_NOTIFICATION_ENABLED_BY_USER); - 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: 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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::SET_ENABLED_FOR_BUNDLE_SLOT); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - sptr bundleOption = new NotificationBundleOption(); - int32_t type = 4; - bool enabled = true; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - data.WriteStrongParcelable(bundleOption); - data.WriteInt32(type); - data.WriteBool(enabled); - - 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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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: HandleDistributedSetEnabledWithoutApp01 - * @tc.desc: Test HandleDistributedSetEnabledWithoutApp succeed. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, HandleDistributedSetEnabledWithoutApp01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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: SetPrivateNotificationsAllowed01 - * @tc.desc: Test SetPrivateNotificationsAllowed return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetPrivateNotificationsAllowed01, Function | SmallTest | Level1) -{ - bool allow = true; - ErrCode result = ansManagerStub_->SetPrivateNotificationsAllowed(allow); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetPrivateNotificationsAllowed01 - * @tc.desc: Test GetPrivateNotificationsAllowed return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetPrivateNotificationsAllowed01, Function | SmallTest | Level1) -{ - bool allow = true; - ErrCode result = ansManagerStub_->GetPrivateNotificationsAllowed(allow); - 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"; - ErrCode result = ansManagerStub_->RequestEnableNotification(deviceId); - 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: AreNotificationsSuspended01 - * @tc.desc: Test AreNotificationsSuspended return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, AreNotificationsSuspended01, Function | SmallTest | Level1) -{ - bool suspended = true; - - ErrCode result = ansManagerStub_->AreNotificationsSuspended(suspended); - 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: PublishReminder01 - * @tc.desc: Test PublishReminder return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, PublishReminder01, Function | SmallTest | Level1) -{ - sptr reminder = new ReminderRequest(); - - ErrCode result = ansManagerStub_->PublishReminder(reminder); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: CancelReminder01 - * @tc.desc: Test CancelReminder return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, CancelReminder01, Function | SmallTest | Level1) -{ - int32_t reminderId = 5; - - ErrCode result = ansManagerStub_->CancelReminder(reminderId); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetValidReminders01 - * @tc.desc: Test GetValidReminders return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetValidReminders01, Function | SmallTest | Level1) -{ - std::vector> reminders; - sptr reminder = new ReminderRequest(); - reminders.emplace_back(reminder); - - ErrCode result = ansManagerStub_->GetValidReminders(reminders); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: CancelAllReminders01 - * @tc.desc: Test CancelAllReminders return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, CancelAllReminders01, Function | SmallTest | Level1) -{ - ErrCode result = ansManagerStub_->CancelAllReminders(); - 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); - 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, 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(AnsManagerInterface::TransactId::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(AnsManagerInterface::TransactId::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); -} -} -} \ No newline at end of file diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index bc084aa91502b4a4b084839272ea4a6268d9f7c1..10f88880e2fbe7e039266a5f20ade5a8a37ce0e1 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -50,8 +50,6 @@ public: */ static sptr GetInstance(); - // AnsManagerStub - /** * @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, diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 4f5b2f36cff5893e5a4d87aa2175f27b68ff6b60..caa42aa42d00bafb0f6bebd973829f86f901dea0 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -18,10 +18,6 @@ group("fuzztest") { "addnotificationslot_fuzzer:AddNotificationSlotFuzzTest", "addnotificationslots_fuzzer:AddNotificationSlotsFuzzTest", "addslotbytype_fuzzer:AddSlotByTypeFuzzTest", - "ansmanagerstub_fuzzer:AnsManagerStubFuzzTest", - "ansmanagerstubannex_fuzzer:AnsManagerStubAnnexFuzzTest", - "ansmanagerstubannexthree_fuzzer:AnsManagerStubAnnexThreeFuzzTest", - "ansmanagerstubannextwo_fuzzer:AnsManagerStubAnnexTwoFuzzTest", "anssubscriberproxy_fuzzer:AnsSubscriberProxyFuzzTest", "anssubscriberstub_fuzzer:AnsSubscriberStubFuzzTest", "cancelasbundle_fuzzer:CancelAsBundleFuzzTest", diff --git a/test/fuzztest/ansmanagerstub_fuzzer/BUILD.gn b/test/fuzztest/ansmanagerstub_fuzzer/BUILD.gn deleted file mode 100644 index a4671ff43964c744d67ab139e30aef5a2e407d6b..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstub_fuzzer/BUILD.gn +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "${component_name}/fuzztest" - -##############################fuzztest########################################## -ohos_fuzztest("AnsManagerStubFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = "${component_path}/test/fuzztest/ansmanagerstub_fuzzer" - - include_dirs = [ "${component_path}/test/fuzztest/fuzz_common_base" ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "ansmanagerstub_fuzzer.cpp" ] - - deps = [ - "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", - "${core_path}:ans_core", - "${frameworks_module_ans_path}:ans_innerkits", - ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_framework:image_native", - "relational_store:native_rdb", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":AnsManagerStubFuzzTest" ] -} -############################################################################### diff --git a/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp b/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp deleted file mode 100644 index 75cf95b1f3f3a184e2ec840c91afe44ce71f585a..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define private public -#define protected public -#include "ans_manager_stub.h" -#undef private -#undef protected -#include "ansmanagerstub_fuzzer.h" -#include "notification_request.h" - -constexpr uint8_t SLOT_TYPE_NUM = 5; - -namespace OHOS { - bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) - { - std::string stringData(data); - Notification::AnsManagerStub ansManagerStub; - uint32_t code = GetU32Data(data); - MessageParcel datas; - MessageParcel reply; - MessageOption flags; - ansManagerStub.OnRemoteRequest(code, datas, reply, flags); - ansManagerStub.HandlePublish(datas, reply); - ansManagerStub.HandlePublishToDevice(datas, reply); - ansManagerStub.HandleCancel(datas, reply); - ansManagerStub.HandleCancelAll(datas, reply); - ansManagerStub.HandleCancelAsBundle(datas, reply); - ansManagerStub.HandleAddSlotByType(datas, reply); - ansManagerStub.HandleAddSlots(datas, reply); - ansManagerStub.HandleRemoveSlotByType(datas, reply); - ansManagerStub.HandleRemoveAllSlots(datas, reply); - ansManagerStub.HandleGetSlots(datas, reply); - ansManagerStub.HandleGetSlotByType(datas, reply); - ansManagerStub.HandleGetSlotNumAsBundle(datas, reply); - ansManagerStub.HandleGetActiveNotifications(datas, reply); - ansManagerStub.HandleGetActiveNotificationNums(datas, reply); - ansManagerStub.HandleGetAllActiveNotifications(datas, reply); - ansManagerStub.HandleGetSpecialActiveNotifications(datas, reply); - ansManagerStub.HandleSetNotificationAgent(datas, reply); - ansManagerStub.HandleGetNotificationAgent(datas, reply); - ansManagerStub.HandleCanPublishAsBundle(datas, reply); - ansManagerStub.HandlePublishAsBundle(datas, reply); - ansManagerStub.HandleSetNotificationBadgeNum(datas, reply); - ansManagerStub.HandleGetBundleImportance(datas, reply); - ansManagerStub.HandleSetDoNotDisturbDate(datas, reply); - ansManagerStub.HandleGetDoNotDisturbDate(datas, reply); - ansManagerStub.HandleDoesSupportDoNotDisturbMode(datas, reply); - ansManagerStub.HandlePublishContinuousTaskNotification(datas, reply); - ansManagerStub.HandleCancelContinuousTaskNotification(datas, reply); - ansManagerStub.HandleIsNotificationPolicyAccessGranted(datas, reply); - ansManagerStub.HandleSetPrivateNotificationsAllowed(datas, reply); - ansManagerStub.HandleGetPrivateNotificationsAllowed(datas, reply); - ansManagerStub.HandleRemoveNotification(datas, reply); - ansManagerStub.HandleRemoveAllNotifications(datas, reply); - ansManagerStub.HandleDelete(datas, reply); - ansManagerStub.HandleDeleteByBundle(datas, reply); - ansManagerStub.HandleDeleteAll(datas, reply); - ansManagerStub.HandleGetSlotsByBundle(datas, reply); - ansManagerStub.HandleUpdateSlots(datas, reply); - ansManagerStub.HandleRequestEnableNotification(datas, reply); - ansManagerStub.HandleSetNotificationsEnabledForBundle(datas, reply); - ansManagerStub.HandleSetNotificationsEnabledForAllBundles(datas, reply); - ansManagerStub.HandleSetNotificationsEnabledForSpecialBundle(datas, reply); - ansManagerStub.HandleSetShowBadgeEnabledForBundle(datas, reply); - ansManagerStub.HandleGetShowBadgeEnabledForBundle(datas, reply); - ansManagerStub.HandleGetShowBadgeEnabled(datas, reply); - ansManagerStub.HandleSubscribe(datas, reply); - ansManagerStub.HandleUnsubscribe(datas, reply); - ansManagerStub.HandleAreNotificationsSuspended(datas, reply); - ansManagerStub.HandleIsAllowedNotify(datas, reply); - ansManagerStub.HandleIsAllowedNotifySelf(datas, reply); - ansManagerStub.HandleIsSpecialBundleAllowedNotify(datas, reply); - ansManagerStub.HandleCancelGroup(datas, reply); - ansManagerStub.HandleRemoveGroupByBundle(datas, reply); - ansManagerStub.HandleIsDistributedEnabled(datas, reply); - ansManagerStub.HandleEnableDistributed(datas, reply); - ansManagerStub.HandleEnableDistributedByBundle(datas, reply); - ansManagerStub.HandleEnableDistributedSelf(datas, reply); - ansManagerStub.HandleIsDistributedEnableByBundle(datas, reply); - ansManagerStub.HandleGetDeviceRemindType(datas, reply); - ansManagerStub.HandleShellDump(datas, reply); - ansManagerStub.HandlePublishReminder(datas, reply); - ansManagerStub.HandleCancelReminder(datas, reply); - ansManagerStub.HandleCancelAllReminders(datas, reply); - ansManagerStub.HandleGetValidReminders(datas, reply); - ansManagerStub.HandleIsSupportTemplate(datas, reply); - ansManagerStub.HandleIsSpecialUserAllowedNotifyByUser(datas, reply); - ansManagerStub.HandleSetNotificationsEnabledByUser(datas, reply); - ansManagerStub.HandleDeleteAllByUser(datas, reply); - ansManagerStub.HandleSetDoNotDisturbDateByUser(datas, reply); - ansManagerStub.HandleGetDoNotDisturbDateByUser(datas, reply); - ansManagerStub.HandleSetEnabledForBundleSlot(datas, reply); - ansManagerStub.HandleGetEnabledForBundleSlot(datas, reply); - ansManagerStub.HandleDistributedSetEnabledWithoutApp(datas, reply); - ansManagerStub.HandleDistributedGetEnabledWithoutApp(datas, reply); - sptr notification = new Notification::NotificationRequest(); - const std::string label = "this is a notification label"; - ansManagerStub.Publish(label, notification); - const std::string deviceId = "this is a notification deviceId"; - ansManagerStub.PublishToDevice(notification, deviceId); - int notificationId = 1; - ansManagerStub.Cancel(notificationId, label); - ansManagerStub.CancelAll(); - const std::string representativeBundle = "this is a notification representativeBundle"; - int32_t userId = 1; - ansManagerStub.CancelAsBundle(notificationId, representativeBundle, userId); - uint8_t type = *data % SLOT_TYPE_NUM; - Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType(type); - ansManagerStub.AddSlotByType(slotType); - std::vector> slots; - ansManagerStub.AddSlots(slots); - ansManagerStub.RemoveSlotByType(slotType); - ansManagerStub.RemoveAllSlots(); - sptr slot = new Notification::NotificationSlot(); - ansManagerStub.GetSlotByType(slotType, slot); - ansManagerStub.GetSlots(slots); - sptr bundleOption = new Notification::NotificationBundleOption(); - uint64_t num = 1; - ansManagerStub.GetSlotNumAsBundle(bundleOption, num); - std::vector> notifications; - ansManagerStub.GetActiveNotifications(notifications); - ansManagerStub.GetActiveNotificationNums(num); - std::vector> notificationss; - ansManagerStub.GetAllActiveNotifications(notificationss); - std::vector key; - ansManagerStub.GetSpecialActiveNotifications(key, notificationss); - std::string agent = "this is a notification agent"; - ansManagerStub.SetNotificationAgent(agent); - ansManagerStub.GetNotificationAgent(agent); - bool canPublish = true; - ansManagerStub.CanPublishAsBundle(representativeBundle, canPublish); - ansManagerStub.PublishAsBundle(notification, representativeBundle); - ansManagerStub.SetNotificationBadgeNum(num); - int importance = 1; - ansManagerStub.GetBundleImportance(importance); - bool granted = true; - ansManagerStub.HasNotificationPolicyAccessPermission(granted); - bool allow = true; - ansManagerStub.SetPrivateNotificationsAllowed(allow); - int32_t removeReason = 1; - ansManagerStub.RemoveNotification(bundleOption, notificationId, label, removeReason); - ansManagerStub.RemoveAllNotifications(bundleOption); - const std::string keys = "this is a notification keys"; - ansManagerStub.Delete(keys, removeReason); - ansManagerStub.DeleteByBundle(bundleOption); - ansManagerStub.DeleteAll(); - ansManagerStub.GetSlotsByBundle(bundleOption, slots); - ansManagerStub.UpdateSlots(bundleOption, slots); - ansManagerStub.RequestEnableNotification(deviceId); - const std::string bundle = "this is a notification bundle"; - bool enabled = true; - ansManagerStub.SetNotificationsEnabledForBundle(bundle, enabled); - ansManagerStub.SetNotificationsEnabledForSpecialBundle(deviceId, bundleOption, enabled); - ansManagerStub.SetShowBadgeEnabledForBundle(bundleOption, enabled); - ansManagerStub.GetShowBadgeEnabledForBundle(bundleOption, enabled); - ansManagerStub.GetShowBadgeEnabled(enabled); - bool suspended = true; - ansManagerStub.AreNotificationsSuspended(suspended); - bool allowed = true; - ansManagerStub.IsAllowedNotify(allowed); - ansManagerStub.IsSpecialBundleAllowedNotify(bundleOption, allowed); - const std::string groupName = "this is a notification groupName"; - ansManagerStub.CancelGroup(groupName); - ansManagerStub.RemoveGroupByBundle(bundleOption, groupName); - sptr date = new Notification::NotificationDoNotDisturbDate(); - ansManagerStub.SetDoNotDisturbDate(date); - ansManagerStub.GetDoNotDisturbDate(date); - bool doesSupport = true; - ansManagerStub.DoesSupportDoNotDisturbMode(doesSupport); - ansManagerStub.IsDistributedEnabled(enabled); - ansManagerStub.EnableDistributedByBundle(bundleOption, enabled); - ansManagerStub.EnableDistributedSelf(enabled); - ansManagerStub.IsDistributedEnableByBundle(bundleOption, enabled); - Notification::NotificationConstant::RemindType remindType; - ansManagerStub.GetDeviceRemindType(remindType); - sptr request = new Notification::NotificationRequest(); - ansManagerStub.PublishContinuousTaskNotification(request); - ansManagerStub.CancelContinuousTaskNotification(label, notificationId); - sptr reminder = new Notification::ReminderRequest(); - ansManagerStub.PublishReminder(reminder); - const int32_t reminderId = 1; - ansManagerStub.CancelReminder(reminderId); - std::vector> reminders; - ansManagerStub.GetValidReminders(reminders); - ansManagerStub.CancelAllReminders(); - const std::string templateName = "this is a notification templateName"; - bool support = true; - ansManagerStub.IsSupportTemplate(templateName, support); - ansManagerStub.IsSpecialUserAllowedNotify(userId, allowed); - const int32_t deviceIds = 1; - ansManagerStub.SetNotificationsEnabledByUser(deviceIds, enabled); - ansManagerStub.DeleteAllByUser(userId); - ansManagerStub.SetDoNotDisturbDate(date); - ansManagerStub.GetDoNotDisturbDate(date); - ansManagerStub.SetEnabledForBundleSlot(bundleOption, slotType, enabled); - ansManagerStub.GetEnabledForBundleSlot(bundleOption, slotType, enabled); - const std::string cmd = "this is a notification cmd"; - std::vector dumpInfo; - ansManagerStub.ShellDump(cmd, bundle, userId, dumpInfo); - ansManagerStub.SetSyncNotificationEnabledWithoutApp(userId, enabled); - ansManagerStub.GetSyncNotificationEnabledWithoutApp(userId, enabled); - return true; - } -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - char *ch = ParseData(data, size); - if (ch != nullptr && size >= GetU32Size()) { - OHOS::DoSomethingInterestingWithMyAPI(ch, size); - free(ch); - ch = nullptr; - } - return 0; -} diff --git a/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.h b/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.h deleted file mode 100644 index a6a9b4924d33ab16ac6696df91297b1ab0b8ea58..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_FUZZTEST_ANSMANAGERSTUB_FUZZER_ANSMANAGERSTUB_FUZZER_H -#define TEST_FUZZTEST_ANSMANAGERSTUB_FUZZER_ANSMANAGERSTUB_FUZZER_H - -#include "fuzz_common_base.h" - -#define FUZZ_PROJECT_NAME "ansmanagerstub_fuzzer" - -#endif // TEST_FUZZTEST_ANSMANAGERSTUB_FUZZER_ANSMANAGERSTUB_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/ansmanagerstub_fuzzer/corpus/init b/test/fuzztest/ansmanagerstub_fuzzer/corpus/init deleted file mode 100644 index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstub_fuzzer/corpus/init +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -FUZZ \ No newline at end of file diff --git a/test/fuzztest/ansmanagerstub_fuzzer/project.xml b/test/fuzztest/ansmanagerstub_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstub_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/ansmanagerstubannex_fuzzer/BUILD.gn b/test/fuzztest/ansmanagerstubannex_fuzzer/BUILD.gn deleted file mode 100644 index 7f8a8e82fb439c6c0022197da77641d215742e0a..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannex_fuzzer/BUILD.gn +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "${component_name}/fuzztest" - -##############################fuzztest########################################## -ohos_fuzztest("AnsManagerStubAnnexFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "${component_path}/test/fuzztest/ansmanagerstubannex_fuzzer" - - include_dirs = [ "${component_path}/test/fuzztest/fuzz_common_base" ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "ansmanagerstubannex_fuzzer.cpp" ] - - deps = [ - "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", - "${core_path}:ans_core", - "${frameworks_module_ans_path}:ans_innerkits", - ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_framework:image_native", - "relational_store:native_rdb", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":AnsManagerStubAnnexFuzzTest" ] -} -############################################################################### diff --git a/test/fuzztest/ansmanagerstubannex_fuzzer/ansmanagerstubannex_fuzzer.cpp b/test/fuzztest/ansmanagerstubannex_fuzzer/ansmanagerstubannex_fuzzer.cpp deleted file mode 100644 index 6f38a8ff510265c5acab6177b70786f385954e49..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannex_fuzzer/ansmanagerstubannex_fuzzer.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define private public -#define protected public -#include "ans_manager_stub.h" -#undef private -#undef protected -#include "ansmanagerstubannex_fuzzer.h" - -namespace OHOS { - bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) - { - Notification::AnsManagerStub ansManagerStub; - MessageParcel datas; - MessageParcel reply; - ansManagerStub.HandleDelete(datas, reply); - ansManagerStub.HandleDeleteByBundle(datas, reply); - ansManagerStub.HandleDeleteAll(datas, reply); - ansManagerStub.HandleGetSlotsByBundle(datas, reply); - ansManagerStub.HandleUpdateSlots(datas, reply); - ansManagerStub.HandleRequestEnableNotification(datas, reply); - ansManagerStub.HandleSetNotificationsEnabledForBundle(datas, reply); - ansManagerStub.HandleSetNotificationsEnabledForAllBundles(datas, reply); - ansManagerStub.HandleSetNotificationsEnabledForSpecialBundle(datas, reply); - ansManagerStub.HandleSetShowBadgeEnabledForBundle(datas, reply); - ansManagerStub.HandleGetShowBadgeEnabledForBundle(datas, reply); - ansManagerStub.HandleGetShowBadgeEnabled(datas, reply); - ansManagerStub.HandleSubscribe(datas, reply); - ansManagerStub.HandleUnsubscribe(datas, reply); - ansManagerStub.HandleAreNotificationsSuspended(datas, reply); - ansManagerStub.HandleIsAllowedNotify(datas, reply); - ansManagerStub.HandleIsAllowedNotifySelf(datas, reply); - ansManagerStub.HandleIsSpecialBundleAllowedNotify(datas, reply); - ansManagerStub.HandleCancelGroup(datas, reply); - ansManagerStub.HandleRemoveGroupByBundle(datas, reply); - ansManagerStub.HandleIsDistributedEnabled(datas, reply); - ansManagerStub.HandleEnableDistributed(datas, reply); - ansManagerStub.HandleEnableDistributedByBundle(datas, reply); - ansManagerStub.HandleEnableDistributedSelf(datas, reply); - ansManagerStub.HandleIsDistributedEnableByBundle(datas, reply); - ansManagerStub.HandleGetDeviceRemindType(datas, reply); - ansManagerStub.HandleShellDump(datas, reply); - ansManagerStub.HandlePublishReminder(datas, reply); - ansManagerStub.HandleCancelReminder(datas, reply); - ansManagerStub.HandleCancelAllReminders(datas, reply); - ansManagerStub.HandleGetValidReminders(datas, reply); - ansManagerStub.HandleIsSupportTemplate(datas, reply); - ansManagerStub.HandleIsSpecialUserAllowedNotifyByUser(datas, reply); - ansManagerStub.HandleSetNotificationsEnabledByUser(datas, reply); - ansManagerStub.HandleDeleteAllByUser(datas, reply); - ansManagerStub.HandleSetDoNotDisturbDateByUser(datas, reply); - ansManagerStub.HandleGetDoNotDisturbDateByUser(datas, reply); - return ansManagerStub.HandleSetEnabledForBundleSlot(datas, reply); - } -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - char *ch = ParseData(data, size); - if (ch != nullptr && size >= GetU32Size()) { - OHOS::DoSomethingInterestingWithMyAPI(ch, size); - free(ch); - ch = nullptr; - } - return 0; -} diff --git a/test/fuzztest/ansmanagerstubannex_fuzzer/ansmanagerstubannex_fuzzer.h b/test/fuzztest/ansmanagerstubannex_fuzzer/ansmanagerstubannex_fuzzer.h deleted file mode 100644 index 330d8b85b4bec8f4d53cf290532384071b96e162..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannex_fuzzer/ansmanagerstubannex_fuzzer.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_FUZZTEST_ANSMANAGERSTUBANNEX_FUZZER_ANSMANAGERSTUBANNEX_FUZZER_H -#define TEST_FUZZTEST_ANSMANAGERSTUBANNEX_FUZZER_ANSMANAGERSTUBANNEX_FUZZER_H - -#include "fuzz_common_base.h" - -#define FUZZ_PROJECT_NAME "ansmanagerstubannex_fuzzer" - -#endif // TEST_FUZZTEST_ANSMANAGERSTUBANNEX_FUZZER_ANSMANAGERSTUBANNEX_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/ansmanagerstubannex_fuzzer/corpus/init b/test/fuzztest/ansmanagerstubannex_fuzzer/corpus/init deleted file mode 100644 index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannex_fuzzer/corpus/init +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -FUZZ \ No newline at end of file diff --git a/test/fuzztest/ansmanagerstubannex_fuzzer/project.xml b/test/fuzztest/ansmanagerstubannex_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannex_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/ansmanagerstubannexthree_fuzzer/BUILD.gn b/test/fuzztest/ansmanagerstubannexthree_fuzzer/BUILD.gn deleted file mode 100644 index 69d0849c61e8b011eb7cb012d3f28d33a0757269..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannexthree_fuzzer/BUILD.gn +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "${component_name}/fuzztest" - -##############################fuzztest########################################## -ohos_fuzztest("AnsManagerStubAnnexThreeFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "${component_path}/test/fuzztest/ansmanagerstubannexthree_fuzzer" - - include_dirs = [ "${component_path}/test/fuzztest/fuzz_common_base" ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "ansmanagerstubannexthree_fuzzer.cpp" ] - - deps = [ - "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", - "${core_path}:ans_core", - "${frameworks_module_ans_path}:ans_innerkits", - ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_framework:image_native", - "relational_store:native_rdb", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":AnsManagerStubAnnexThreeFuzzTest" ] -} -############################################################################### diff --git a/test/fuzztest/ansmanagerstubannexthree_fuzzer/ansmanagerstubannexthree_fuzzer.cpp b/test/fuzztest/ansmanagerstubannexthree_fuzzer/ansmanagerstubannexthree_fuzzer.cpp deleted file mode 100644 index ef99f9d9d647efbc3b7a1a487297fafd051e958a..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannexthree_fuzzer/ansmanagerstubannexthree_fuzzer.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define private public -#define protected public -#include "ans_manager_stub.h" -#undef private -#undef protected -#include "ansmanagerstubannexthree_fuzzer.h" - -namespace OHOS { - namespace { - constexpr uint8_t ENABLE = 2; - constexpr uint8_t SLOT_TYPE_NUM = 5; - } - bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) - { - Notification::AnsManagerStub ansManagerStub; - bool allow = *data % ENABLE; - ansManagerStub.GetPrivateNotificationsAllowed(allow); - sptr bundleOption = new Notification::NotificationBundleOption(); - int notificationId = 1; - std::string stringData(data); - int32_t removeReason = static_cast(GetU32Data(data)); - ansManagerStub.RemoveNotification(bundleOption, notificationId, stringData, removeReason); - ansManagerStub.RemoveAllNotifications(bundleOption); - ansManagerStub.Delete(stringData, removeReason); - ansManagerStub.DeleteByBundle(bundleOption); - ansManagerStub.DeleteAll(); - sptr slot = new Notification::NotificationSlot(); - std::vector> slots; - slots.emplace_back(slot); - ansManagerStub.GetSlotsByBundle(bundleOption, slots); - ansManagerStub.SetNotificationsEnabledForSpecialBundle(stringData, bundleOption, allow); - ansManagerStub.SetShowBadgeEnabledForBundle(bundleOption, allow); - ansManagerStub.GetShowBadgeEnabledForBundle(bundleOption, allow); - ansManagerStub.GetShowBadgeEnabled(allow); - ansManagerStub.AreNotificationsSuspended(allow); - ansManagerStub.IsAllowedNotify(allow); - ansManagerStub.IsAllowedNotifySelf(allow); - ansManagerStub.IsSpecialBundleAllowedNotify(bundleOption, allow); - ansManagerStub.CancelGroup(stringData); - ansManagerStub.RemoveGroupByBundle(bundleOption, stringData); - ansManagerStub.DoesSupportDoNotDisturbMode(allow); - ansManagerStub.IsDistributedEnabled(allow); - ansManagerStub.EnableDistributed(allow); - ansManagerStub.EnableDistributedByBundle(bundleOption, allow); - ansManagerStub.EnableDistributedSelf(allow); - ansManagerStub.IsDistributedEnableByBundle(bundleOption, allow); - int32_t remindType = static_cast(*data % SLOT_TYPE_NUM); - Notification::NotificationConstant::RemindType remind = - Notification::NotificationConstant::RemindType(remindType); - ansManagerStub.GetDeviceRemindType(remind); - sptr request = new Notification::NotificationRequest(); - ansManagerStub.PublishContinuousTaskNotification(request); - ansManagerStub.CancelContinuousTaskNotification(stringData, removeReason); - ansManagerStub.CancelReminder(removeReason); - return ansManagerStub.CancelAllReminders(); - } -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - char *ch = ParseData(data, size); - if (ch != nullptr && size >= GetU32Size()) { - OHOS::DoSomethingInterestingWithMyAPI(ch, size); - free(ch); - ch = nullptr; - } - return 0; -} diff --git a/test/fuzztest/ansmanagerstubannexthree_fuzzer/ansmanagerstubannexthree_fuzzer.h b/test/fuzztest/ansmanagerstubannexthree_fuzzer/ansmanagerstubannexthree_fuzzer.h deleted file mode 100644 index ec514818a31fc21b568147d7d47d9d07f86c6942..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannexthree_fuzzer/ansmanagerstubannexthree_fuzzer.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_FUZZTEST_ANSMANAGERSTUBANNEXTHREE_FUZZER_ANSMANAGERSTUBANNEXTHREE_FUZZER_H -#define TEST_FUZZTEST_ANSMANAGERSTUBANNEXTHREE_FUZZER_ANSMANAGERSTUBANNEXTHREE_FUZZER_H - -#include "fuzz_common_base.h" - -#define FUZZ_PROJECT_NAME "ansmanagerstubannexthree_fuzzer" - -#endif // TEST_FUZZTEST_ANSMANAGERSTUBANNEXTHREE_FUZZER_ANSMANAGERSTUBANNEXTHREE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/ansmanagerstubannexthree_fuzzer/corpus/init b/test/fuzztest/ansmanagerstubannexthree_fuzzer/corpus/init deleted file mode 100644 index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannexthree_fuzzer/corpus/init +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -FUZZ \ No newline at end of file diff --git a/test/fuzztest/ansmanagerstubannexthree_fuzzer/project.xml b/test/fuzztest/ansmanagerstubannexthree_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannexthree_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/ansmanagerstubannextwo_fuzzer/BUILD.gn b/test/fuzztest/ansmanagerstubannextwo_fuzzer/BUILD.gn deleted file mode 100644 index ab0e817f3dc5b515cf81afa584cafe4a8e938a8e..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannextwo_fuzzer/BUILD.gn +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#####################hydra-fuzz################### -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/config/features.gni") -import("//build/test.gni") -module_output_path = "${component_name}/fuzztest" - -##############################fuzztest########################################## -ohos_fuzztest("AnsManagerStubAnnexTwoFuzzTest") { - module_out_path = module_output_path - fuzz_config_file = - "${component_path}/test/fuzztest/ansmanagerstubannextwo_fuzzer" - - include_dirs = [ "${component_path}/test/fuzztest/fuzz_common_base" ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "ansmanagerstubannextwo_fuzzer.cpp" ] - - deps = [ - "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", - "${core_path}:ans_core", - "${frameworks_module_ans_path}:ans_innerkits", - ] - - external_deps = [ - "ability_base:want", - "ability_base:zuri", - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "multimedia_image_framework:image_native", - "relational_store:native_rdb", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":AnsManagerStubAnnexTwoFuzzTest" ] -} -############################################################################### diff --git a/test/fuzztest/ansmanagerstubannextwo_fuzzer/ansmanagerstubannextwo_fuzzer.cpp b/test/fuzztest/ansmanagerstubannextwo_fuzzer/ansmanagerstubannextwo_fuzzer.cpp deleted file mode 100644 index e310e1843609586b6d13a5445319ca08e1b9eb57..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannextwo_fuzzer/ansmanagerstubannextwo_fuzzer.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define private public -#define protected public -#include "ans_manager_stub.h" -#undef private -#undef protected -#include "ansmanagerstubannextwo_fuzzer.h" - -namespace OHOS { - namespace { - constexpr uint8_t ENABLE = 2; - constexpr uint8_t SLOT_TYPE_NUM = 5; - } - bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) - { - Notification::AnsManagerStub ansManagerStub; - MessageParcel datas; - MessageParcel reply; - ansManagerStub.HandleGetEnabledForBundleSlot(datas, reply); - ansManagerStub.HandleDistributedSetEnabledWithoutApp(datas, reply); - ansManagerStub.HandleDistributedGetEnabledWithoutApp(datas, reply); - std::string stringData(data); - sptr notification = new Notification::NotificationRequest(); - ansManagerStub.Publish(stringData, notification); - ansManagerStub.PublishToDevice(notification, stringData); - int notificationId = 1; - ansManagerStub.Cancel(notificationId, stringData); - ansManagerStub.CancelAll(); - int32_t notificationIds = static_cast(GetU32Data(data)); - int32_t userId = static_cast(GetU32Data(data)); - ansManagerStub.CancelAsBundle(notificationIds, stringData, userId); - uint8_t type = *data % SLOT_TYPE_NUM; - Notification::NotificationConstant::SlotType slotType = Notification::NotificationConstant::SlotType(type); - ansManagerStub.AddSlotByType(slotType); - sptr slot = new Notification::NotificationSlot(); - std::vector> slots; - slots.emplace_back(slot); - ansManagerStub.AddSlots(slots); - ansManagerStub.RemoveSlotByType(slotType); - ansManagerStub.RemoveAllSlots(); - ansManagerStub.GetSlotByType(slotType, slot); - ansManagerStub.GetSlots(slots); - sptr bundleOption = new Notification::NotificationBundleOption(); - uint64_t num = 1; - ansManagerStub.GetSlotNumAsBundle(bundleOption, num); - sptr notificationer = new Notification::NotificationRequest(); - std::vector> notifications; - notifications.emplace_back(notificationer); - ansManagerStub.GetActiveNotifications(notifications); - ansManagerStub.GetActiveNotificationNums(num); - sptr notificatione = new Notification::Notification(); - std::vector> notificationes; - notificationes.emplace_back(notificatione); - ansManagerStub.GetAllActiveNotifications(notificationes); - std::vector key; - key.emplace_back(stringData); - ansManagerStub.GetSpecialActiveNotifications(key, notificationes); - ansManagerStub.SetNotificationAgent(stringData); - ansManagerStub.GetNotificationAgent(stringData); - bool canPublish = *data % ENABLE; - ansManagerStub.CanPublishAsBundle(stringData, canPublish); - ansManagerStub.PublishAsBundle(notificationer, stringData); - ansManagerStub.SetNotificationBadgeNum(notificationId); - ansManagerStub.GetBundleImportance(notificationId); - ansManagerStub.HasNotificationPolicyAccessPermission(canPublish); - return ansManagerStub.SetPrivateNotificationsAllowed(canPublish); - } -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - char *ch = ParseData(data, size); - if (ch != nullptr && size >= GetU32Size()) { - OHOS::DoSomethingInterestingWithMyAPI(ch, size); - free(ch); - ch = nullptr; - } - return 0; -} diff --git a/test/fuzztest/ansmanagerstubannextwo_fuzzer/ansmanagerstubannextwo_fuzzer.h b/test/fuzztest/ansmanagerstubannextwo_fuzzer/ansmanagerstubannextwo_fuzzer.h deleted file mode 100644 index 5302226367564e411522410e9d289ab37cdab0ac..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannextwo_fuzzer/ansmanagerstubannextwo_fuzzer.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_FUZZTEST_ANSMANAGERSTUBANNEXTWO_FUZZER_ANSMANAGERSTUBANNEXTWO_FUZZER_H -#define TEST_FUZZTEST_ANSMANAGERSTUBANNEXTWO_FUZZER_ANSMANAGERSTUBANNEXTWO_FUZZER_H - -#include "fuzz_common_base.h" - -#define FUZZ_PROJECT_NAME "ansmanagerstubannextwo_fuzzer" - -#endif // TEST_FUZZTEST_ANSMANAGERSTUBANNEXTWO_FUZZER_ANSMANAGERSTUBANNEXTWO_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/ansmanagerstubannextwo_fuzzer/corpus/init b/test/fuzztest/ansmanagerstubannextwo_fuzzer/corpus/init deleted file mode 100644 index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannextwo_fuzzer/corpus/init +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -FUZZ \ No newline at end of file diff --git a/test/fuzztest/ansmanagerstubannextwo_fuzzer/project.xml b/test/fuzztest/ansmanagerstubannextwo_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/test/fuzztest/ansmanagerstubannextwo_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/tools/test/BUILD.gn b/tools/test/BUILD.gn index fd45480139651ca4c1d6a65e8534c1b9269245ba..63fd3d17adef5e93d9a39ecc1a3e8c78480b1f4c 100644 --- a/tools/test/BUILD.gn +++ b/tools/test/BUILD.gn @@ -15,6 +15,4 @@ import("//build/test.gni") group("unittest") { testonly = true - - deps = [ "unittest/dump:unittest" ] } diff --git a/tools/test/mock/mock_ans_manager_stub.cpp b/tools/test/mock/mock_ans_manager_stub.cpp deleted file mode 100644 index 0e060f19baa71065ecdd724c698e345cb53ea033..0000000000000000000000000000000000000000 --- a/tools/test/mock/mock_ans_manager_stub.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mock_ans_manager_stub.h" - -#include "ans_inner_errors.h" - -namespace OHOS { -namespace Notification { -std::string MockAnsManagerStub::GetCmd() -{ - return cmd_; -} - -std::string MockAnsManagerStub::GetBundle() -{ - return bundle_; -} - -int32_t MockAnsManagerStub::GetUserId() -{ - return userId_; -} - -ErrCode MockAnsManagerStub::ShellDump(const std::string &cmd, const std::string &bundle, int32_t userId, - std::vector &dumpInfo) -{ - ANS_LOGE("enter"); - ErrCode result = ERR_ANS_NOT_ALLOWED; - cmd_ = cmd; - bundle_ = bundle; - userId_ = userId; - return result; -} -} // namespace Notification -} // namespace OHOSc diff --git a/tools/test/mock/mock_ans_manager_stub.h b/tools/test/mock/mock_ans_manager_stub.h deleted file mode 100644 index 3d0ad8d9daa5b6e962c97dc1db1686f75165ec33..0000000000000000000000000000000000000000 --- a/tools/test/mock/mock_ans_manager_stub.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_TOOLS_MOCK_ANS_MANAGER_STUB_H -#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_TOOLS_MOCK_ANS_MANAGER_STUB_H - -#include "gmock/gmock.h" - -#include "ans_log_wrapper.h" -#include "ans_manager_stub.h" - -namespace OHOS { -namespace Notification { -class MockAnsManagerStub : public AnsManagerStub { -public: - - std::string GetCmd(); - std::string GetBundle(); - int32_t GetUserId(); - - /** - * @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, - std::vector &dumpInfo) override; - -private: - std::string cmd_; - std::string bundle_; - int32_t userId_; -}; -} // namespace EventFwk -} // namespace OHOS - -#endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_TOOLS_MOCK_ANS_MANAGER_STUB_H diff --git a/tools/test/unittest/dump/BUILD.gn b/tools/test/unittest/dump/BUILD.gn deleted file mode 100644 index dab5f124614f9ca4cd7d4a574dd371b1ad2e73f3..0000000000000000000000000000000000000000 --- a/tools/test/unittest/dump/BUILD.gn +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//base/notification/distributed_notification_service/notification.gni") -import("//build/test.gni") - -module_output_path = "distributed_notification_service/tools" - -config("tools_dump_config_mock") { - include_dirs = [ - "//third_party/googletest/googlemock/include", - "${tools_path}/test/mock", - "${component_path}/services/ans/include", - ] -} - -tools_dump_mock_sources = - [ "${tools_path}/test/mock/mock_ans_manager_stub.cpp" ] - -ohos_unittest("notification_shell_command_dump_test") { - module_out_path = module_output_path - - include_dirs = [] - - sources = [ - "${tools_path}/dump/src/notification_shell_command.cpp", - "${tools_path}/dump/src/shell_command.cpp", - "${tools_path}/test/mock/mock_ans_notification.cpp", - "notification_shell_command_dump_test.cpp", - ] - sources += tools_dump_mock_sources - - configs = [ - "${tools_path}/dump:tools_dump_config", - ":tools_dump_config_mock", - ] - - cflags = [] - if (target_cpu == "arm") { - cflags += [ "-DBINDER_IPC_32BIT" ] - } - - deps = [ - "${core_path}:ans_core", - "${frameworks_module_ans_path}:ans_innerkits", - "//third_party/googletest:gmock_main", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "ability_base:base", - "ability_base:want", - "ability_base:zuri", - "access_token:libnativetoken", - "access_token:libtoken_setproc", - "c_utils:utils", - "common_event_service:cesfwk_innerkits", - "eventhandler:libeventhandler", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "relational_store:native_rdb", - ] -} - -group("unittest") { - testonly = true - - deps = [ ":notification_shell_command_dump_test" ] -} diff --git a/tools/test/unittest/dump/notification_shell_command_dump_test.cpp b/tools/test/unittest/dump/notification_shell_command_dump_test.cpp deleted file mode 100644 index bd6e386fcbdc86ffeed5310c138a8614bea48841..0000000000000000000000000000000000000000 --- a/tools/test/unittest/dump/notification_shell_command_dump_test.cpp +++ /dev/null @@ -1,709 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#define private public -#include "notification_shell_command.h" -#undef private -#include "ans_inner_errors.h" -#include "ans_manager_interface.h" -#include "mock_ans_manager_stub.h" -#include "singleton.h" - -using namespace testing::ext; -using namespace OHOS; -using namespace OHOS::Notification; - -namespace { -static char g_dumpHelpMsg[] = -"request a option 'A' or 'R' or 'D'\n" -"usage: anm dump []\n" -"options list:\n" -" --help, -h help menu\n" -" --active, -A list all active notifications\n" -" --recent, -R list recent notifications\n" -" --bundle, -b dump the info filter by the specified bundle name\n" -" --user-id, -u dump the info filter by the specified userId\n"; - -static char g_dumpActiveBound[] = -"error: option 'b' requires a value.\n" -"usage: anm dump []\noptions list:\n" -" --help, -h help menu\n" -" --active, -A list all active notifications\n" -" --recent, -R list recent notifications\n" -" --bundle, -b dump the info filter by the specified bundle name\n" -" --user-id, -u dump the info filter by the specified userId\n"; - -static char g_dumpActiveUser[] = -"error: option 'u' requires a value.\n" -"usage: anm dump []\n" -"options list:\n" -" --help, -h help menu\n" -" --active, -A list all active notifications\n" -" --recent, -R list recent notifications\n" -" --bundle, -b dump the info filter by the specified bundle name\n" -" --user-id, -u dump the info filter by the specified userId\n"; - -static char g_enableErrorInformation[] = -"error: option 'e' requires a value.\nusage: anm setting []\noptions list:\n" -" --help, -h help menu\n" -" --recent-count -c set the max count of recent notifications keeping in memory\n --enable-notification" -" -e set notification enabled for the bundle, eg: -e com.example:10100:1\n"; - -static char g_enableBundleNameNull[] = -"error: setting information error\n" -"usage: anm setting []\n" -"options list:\n --help, -h help menu\n" -" --recent-count -c set the max count of recent notifications keeping in memory\n --enable-notification" -" -e set notification enabled for the bundle, eg: -e com.example:10100:1\n"; - -static char g_enableObjectNull[] = -"error: object is null\n" -"error: object is null\n" -"usage: anm setting []\n" -"options list:\n --help, -h help menu\n" -" --recent-count -c set the max count of recent notifications keeping in memory\n --enable-notification" -" -e set notification enabled for the bundle, eg: -e com.example:10100:1\n"; - -static char g_unknownOption[] = -"error: unknown option.\n" -"usage: anm dump []\n" -"options list:\n" -" --help, -h help menu\n" -" --active, -A list all active notifications\n" -" --recent, -R list recent notifications\n" -" --bundle, -b dump the info filter by the specified bundle name\n" -" --user-id, -u dump the info filter by the specified userId\n"; - -static char g_dumpActiveCount[] = -"error: option 'c' requires a value.\n" -"usage: anm setting []\n" -"options list:\n" -" --help, -h help menu\n" -" --recent-count -c set the max count of recent notifications keeping in memory\n --enable-notification" -" -e set notification enabled for the bundle, eg: -e com.example:10100:1\n"; - -static char g_helpMsg[] = -"error: unknown option.\n" -"usage: anm dump []\n" -"options list:\n" -" --help, -h help menu\n" -" --active, -A list all active notifications\n" -" --recent, -R list recent notifications\n" -" --bundle, -b dump the info filter by the specified bundle name\n" -" --user-id, -u dump the info filter by the specified userId\n" -"usage: anm dump []\n" -"options list:\n" -" --help, -h help menu\n" -" --active, -A list all active notifications\n" -" --recent, -R list recent notifications\n" -" --bundle, -b dump the info filter by the specified bundle name\n" -" --user-id, -u dump the info filter by the specified userId\n"; - -static char g_bundleName[] = "example"; -static char g_commandActive[] = "active"; -static char g_commandRecent[] = "recent"; - -class AnmManagerDumpTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp() override; - void TearDown() override; - - void MakeMockObjects(); - - std::string cmd_ = "dump"; - std::string enable_ = "setting"; - std::string toolName_ = "anm"; - sptr proxyPtr_; - sptr stubPtr_; -}; - -void AnmManagerDumpTest::SetUpTestCase() -{} - -void AnmManagerDumpTest::TearDownTestCase() -{} - -void AnmManagerDumpTest::SetUp() -{ - // reset optind to 0 - optind = 0; - - // make mock objects - MakeMockObjects(); -} - -void AnmManagerDumpTest::TearDown() -{} - -void AnmManagerDumpTest::MakeMockObjects() -{ - // mock a stub - stubPtr_ = new (std::nothrow) MockAnsManagerStub(); - - // mock a proxy - proxyPtr_ = iface_cast(stubPtr_); - - // set the mock proxy - auto ansNotificationPtr = DelayedSingleton::GetInstance(); - ansNotificationPtr->ansManagerProxy_ = proxyPtr_; -} - -/** - * @tc.number: Anm_Command_Dump_0100 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -h" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0100, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-h", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), g_dumpHelpMsg); -} - -/** - * @tc.number: Anm_Command_Dump_0200 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -A" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0200, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-A", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - cmd.ExecCommand(); - - EXPECT_EQ(stubPtr_->GetCmd(), g_commandActive); -} - -/** - * @tc.number: Anm_Command_Dump_0300 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -R" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0300, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-R", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - cmd.ExecCommand(); - - EXPECT_EQ(stubPtr_->GetCmd(), g_commandRecent); -} - -/** - * @tc.number: Anm_Command_Dump_0400 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -R -b" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0400, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-R", - (char *)"-b", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), g_dumpActiveBound); -} - -/** - * @tc.number: Anm_Command_Dump_0500 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -A -b example" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0500, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-A", - (char *)"-b", - (char *)"example", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - cmd.ExecCommand(); - - EXPECT_EQ(stubPtr_->GetCmd(), g_commandActive); - EXPECT_EQ(stubPtr_->GetBundle(), g_bundleName); -} - -/** - * @tc.number: Anm_Command_Dump_0600 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -A -b" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0600, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-A", - (char *)"-b", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), g_dumpActiveBound); -} - -/** - * @tc.number: Anm_Command_Dump_0700 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -R -b example" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0700, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-R", - (char *)"-b", - (char *)"example", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - cmd.ExecCommand(); - - EXPECT_EQ(stubPtr_->GetCmd(), g_commandRecent); - EXPECT_EQ(stubPtr_->GetBundle(), g_bundleName); -} - -/** - * @tc.number: Anm_Command_Dump_0800 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -R -u" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0800, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-R", - (char *)"-u", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), g_dumpActiveUser); -} - -/** - * @tc.number: Anm_Command_Dump_0900 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -A -u" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0900, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-A", - (char *)"-u", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), g_dumpActiveUser); -} - -/** - * @tc.number: Anm_Command_Dump_1000 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -A -u 33" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1000, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-A", - (char *)"-u", - (char *)"33", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - cmd.ExecCommand(); - - EXPECT_EQ(stubPtr_->GetCmd(), g_commandActive); - EXPECT_EQ(stubPtr_->GetUserId(), 33); -} - -/** - * @tc.number: Anm_Command_Dump_1100 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -R -u 33" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1100, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-R", - (char *)"-u", - (char *)"33", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - cmd.ExecCommand(); - - EXPECT_EQ(stubPtr_->GetCmd(), g_commandRecent); - EXPECT_EQ(stubPtr_->GetUserId(), 33); -} - -/** - * @tc.number: Anm_Command_Dump_1200 - * @tc.name: RunAsSettingCommand - * @tc.desc: test RunAsSettingCommand function - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1200, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-h", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.RunAsSettingCommand(), ERR_INVALID_VALUE); -} - -/** - * @tc.number: Anm_Command_Dump_1300 - * @tc.name: RunSetEnableCmd - * @tc.desc: test RunSetEnableCmd function - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1300, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-h", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.RunSetEnableCmd(), ERR_ANS_SERVICE_NOT_CONNECTED); -} - -/** - * @tc.number: Anm_Command_Dump_1400 - * @tc.name: GetCommandErrorMsg - * @tc.desc: test GetCommandErrorMsg function - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1400, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-h", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.GetCommandErrorMsg(), "anm_dump: 'dump' is not a valid anm_dump command. See 'anm_dump help'.\n"); -} - -/** - * @tc.number: Anm_Command_Dump_1500 - * @tc.name: GetUnknownOptionMsg - * @tc.desc: test GetUnknownOptionMsg function - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1500, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-h", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - std::string unknownOption = "aa"; - - EXPECT_EQ(cmd.GetUnknownOptionMsg(unknownOption), "error: unknown option.\n"); -} - -/** - * @tc.number: Anm_Command_Dump_1600 - * @tc.name: GetMessageFromCode - * @tc.desc: test GetMessageFromCode function - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1600, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-h", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - int32_t code = 11; - - EXPECT_EQ(cmd.GetMessageFromCode(code), ""); -} - -/** - * @tc.number: Anm_Command_Dump_1700 - * @tc.name: RunAsSettingCommand - * @tc.desc: Verify the "anm setting -e bundleName:uid:enable" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1700, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)enable_.c_str(), - (char *)"-e", - (char *)"dd:ss:aa", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), "set notification enabled failed\n"); -} - -/** - * @tc.number: Anm_Command_Dump_1800 - * @tc.name: RunAsSettingCommand - * @tc.desc: Verify the "anm setting -e" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1800, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)enable_.c_str(), - (char *)"-e", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), g_enableErrorInformation); -} - -/** - * @tc.number: Anm_Command_Dump_1900 - * @tc.name: RunAsSettingCommand - * @tc.desc: Verify the "anm setting -e bundleName:uid" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_1900, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)enable_.c_str(), - (char *)"-e", - (char *)"dd:ss", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), g_enableBundleNameNull); -} - -/** - * @tc.number: Anm_Command_Dump_2000 - * @tc.name: RunAsSettingCommand - * @tc.desc: Verify the "anm setting -e bundleName:uid:enable" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_2000, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)enable_.c_str(), - (char *)"-e", - (char *)"22", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.RunSetEnableCmd(), cmd.RunAsSettingCommand()); - EXPECT_EQ(cmd.ExecCommand(), g_enableObjectNull); -} - -/** - * @tc.number: Anm_Command_Dump_2100 - * @tc.name: RunAsSettingCommand - * @tc.desc: Verify the "anm setting -e bundleName:uid:enable" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_2100, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)enable_.c_str(), - (char *)"-e", - (char *)"gg:ss:aa", - (char *)"22", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), "set notification enabled success\n"); -} - -/** - * @tc.number: Anm_Command_Dump_2200 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -A -s" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_2200, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-A", - (char *)"-s", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), g_unknownOption); -} - -/** - * @tc.number: Anm_Command_Dump_2300 - * @tc.name: RunAsSettingCommand - * @tc.desc: Verify the "anm setting -e" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_2300, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)enable_.c_str(), - (char *)"-c", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - EXPECT_EQ(cmd.ExecCommand(), g_dumpActiveCount); -} - -/** - * @tc.number: Anm_Command_Dump_2400 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -D" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0240, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-D", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - cmd.ExecCommand(); - - EXPECT_EQ(cmd.ExecCommand(), g_helpMsg); -} - -/** - * @tc.number: Anm_Command_Dump_2500 - * @tc.name: ExecCommand - * @tc.desc: Verify the "anm dump -D" command. - */ -HWTEST_F(AnmManagerDumpTest, Anm_Notification_Shell_Dump_0250, Function | MediumTest | Level1) -{ - char *argv[] = { - (char *)toolName_.c_str(), - (char *)cmd_.c_str(), - (char *)"-p", - (char *)"", - }; - int argc = sizeof(argv) / sizeof(argv[0]) - 1; - - NotificationShellCommand cmd(argc, argv); - - cmd.ExecCommand(); - - EXPECT_EQ(cmd.ExecCommand(), g_helpMsg); -} -} // namespace \ No newline at end of file