diff --git a/services/ans/test/unittest/BUILD.gn b/services/ans/test/unittest/BUILD.gn index de4aa72a761e0b8c56be6663307e94f5e88fad94..e52a2f7aaf5e34e16a3bff8890965c2a7446c68a 100644 --- a/services/ans/test/unittest/BUILD.gn +++ b/services/ans/test/unittest/BUILD.gn @@ -46,6 +46,7 @@ ohos_unittest("ans_unit_test") { "${services_path}/ans/src/system_event_observer.cpp", "advanced_notification_service_ability_test.cpp", "advanced_notification_service_test.cpp", + "bundle_manager_helper_test.cpp", "mock/blob.cpp", "mock/distributed_kv_data_manager.cpp", "mock/mock_access_token_helper.cpp", @@ -59,6 +60,7 @@ ohos_unittest("ans_unit_test") { "notification_slot_filter_test.cpp", "notification_subscriber_manager_test.cpp", "permission_filter_test.cpp", + "reminder_data_manager_test.cpp", ] configs = [ "//commonlibrary/c_utils/base:utils_config" ] diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index 91a54d7a47e07dac400d05928454c805d3607e0f..60b4a295f89f22f88bb5f1cbdee752f039acf396 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -1669,5 +1669,351 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12500, EXPECT_EQ(advancedNotificationService_->IsNotificationExists(key.str()), true); } + +/** + * @tc.number : AdvancedNotificationServiceTest_12600 + * @tc.name : ANS_CancelAsBundle_0100 + * @tc.desc : Test CancelAsBundle function when the result is ERR_ANS_NOTIFICATION_NOT_EXISTS + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12600, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::OTHER); + int32_t notificationId = 1; + std::string representativeBundle = "RepresentativeBundle"; + int32_t userId = 1; + int result = ERR_ANS_NOTIFICATION_NOT_EXISTS; + EXPECT_EQ(advancedNotificationService_->CancelAsBundle(notificationId, representativeBundle, userId), result); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_12700 + * @tc.name : ANS_CanPublishAsBundle_0100 + * @tc.desc : Test CanPublishAsBundle function when the result is ERR_INVALID_OPERATION + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12700, Function | SmallTest | Level1) +{ + std::string representativeBundle = "RepresentativeBundle"; + bool canPublish = true; + int result = ERR_INVALID_OPERATION; + EXPECT_EQ(advancedNotificationService_->CanPublishAsBundle(representativeBundle, canPublish), result); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_12800 + * @tc.name : ANS_PublishAsBundle_0100 + * @tc.desc : Test PublishAsBundle function when the result is ERR_INVALID_OPERATION + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12800, Function | SmallTest | Level1) +{ + sptr notification = nullptr; + std::string representativeBundle = "RepresentativeBundle"; + int result = ERR_INVALID_OPERATION; + EXPECT_EQ(advancedNotificationService_->PublishAsBundle(notification, representativeBundle), result); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_12900 + * @tc.name : ANS_HasNotificationPolicyAccessPermission_0100 + * @tc.desc : Test HasNotificationPolicyAccessPermission function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12900, Function | SmallTest | Level1) +{ + bool granted = true; + EXPECT_EQ(advancedNotificationService_->HasNotificationPolicyAccessPermission(granted), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13000 + * @tc.name : ANS_GetShowBadgeEnabled_0100 + * @tc.desc : Test GetShowBadgeEnabled function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13000, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + bool enabled = false; + EXPECT_EQ(advancedNotificationService_->GetShowBadgeEnabled(enabled), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13100 + * @tc.name : ANS_RequestEnableNotification_0100 + * @tc.desc : Test RequestEnableNotification function when the result is ERR_ANS_INVALID_PARAM + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13100, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + std::string deviceId = "DeviceId"; + EXPECT_EQ(advancedNotificationService_->RequestEnableNotification(deviceId), (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13200 + * @tc.name : ANS_PublishReminder_0100 + * @tc.desc : Test PublishReminder function + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13200, Function | SmallTest | Level1) +{ + sptr reminder = nullptr; + EXPECT_EQ(advancedNotificationService_->PublishReminder(reminder), -1); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13300 + * @tc.name : ANS_CancelReminder_0100 + * @tc.desc : Test CancelReminder function when the result is ERR_NO_INIT + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13300, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + int32_t reminderId = 1; + EXPECT_EQ(advancedNotificationService_->CancelReminder(reminderId), (int)ERR_NO_INIT); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13400 + * @tc.name : ANS_CancelAllReminders_0100 + * @tc.desc : Test CancelAllReminders function when the result is ERR_NO_INIT + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13400, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + EXPECT_EQ(advancedNotificationService_->CancelAllReminders(), (int)ERR_NO_INIT); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13500 + * @tc.name : ANS_GetValidReminders_0100 + * @tc.desc : Test GetValidReminders function when the result is ERR_NO_INIT + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13500, Function | SmallTest | Level1) +{ + std::vector> reminders; + EXPECT_EQ(advancedNotificationService_->GetValidReminders(reminders), (int)ERR_NO_INIT); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13600 + * @tc.name : ANS_ActiveNotificationDump_0100 + * @tc.desc : Test ActiveNotificationDump function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13600, Function | SmallTest | Level1) +{ + std::string bundle = "Bundle"; + int32_t userId = 2; + std::vector dumpInfo; + EXPECT_EQ(advancedNotificationService_->ActiveNotificationDump(bundle, userId, dumpInfo), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13700 + * @tc.name : ANS_RecentNotificationDump_0100 + * @tc.desc : Test RecentNotificationDump function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13700, Function | SmallTest | Level1) +{ + std::string bundle = "Bundle"; + int32_t userId = 3; + std::vector dumpInfo; + EXPECT_EQ(advancedNotificationService_->RecentNotificationDump(bundle, userId, dumpInfo), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13800 + * @tc.name : ANS_SetRecentNotificationCount_0100 + * @tc.desc : Test SetRecentNotificationCount function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13800, Function | SmallTest | Level1) +{ + std::string arg = "Arg"; + EXPECT_EQ(advancedNotificationService_->SetRecentNotificationCount(arg), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13900 + * @tc.name : ANS_RemoveAllSlots_0100 + * @tc.desc : Test RemoveAllSlots function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13900, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + EXPECT_EQ(advancedNotificationService_->RemoveAllSlots(), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14200 + * @tc.name : ANS_DoesSupportDoNotDisturbMode_0100 + * @tc.desc : Test DoesSupportDoNotDisturbMode function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14200, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + bool doesSupport = true; + EXPECT_EQ(advancedNotificationService_->DoesSupportDoNotDisturbMode(doesSupport), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14300 + * @tc.name : ANS_IsDistributedEnabled_0100 + * @tc.desc : Test IsDistributedEnabled function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14300, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + bool enabled = true; + EXPECT_EQ(advancedNotificationService_->IsDistributedEnabled(enabled), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14400 + * @tc.name : ANS_EnableDistributed_0100 + * @tc.desc : Test EnableDistributed function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14400, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + bool enabled = true; + EXPECT_EQ(advancedNotificationService_->EnableDistributed(enabled), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14600 + * @tc.name : ANS_EnableDistributedSelf_0100 + * @tc.desc : Test EnableDistributedSelf function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14600, Function | SmallTest | Level1) +{ + TestAddSlot(NotificationConstant::SlotType::SOCIAL_COMMUNICATION); + sptr req = new NotificationRequest(); + EXPECT_NE(req, nullptr); + bool enabled = true; + EXPECT_EQ(advancedNotificationService_->EnableDistributedSelf(enabled), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14800 + * @tc.name : ANS_IsSpecialUserAllowedNotify_0100 + * @tc.desc : Test IsSpecialUserAllowedNotify function when the result is ERR_ANS_INVALID_PARAM + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14800, Function | SmallTest | Level1) +{ + int32_t userId = 3; + bool allowed = true; + EXPECT_EQ(advancedNotificationService_->IsSpecialUserAllowedNotify(userId, allowed), (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14900 + * @tc.name : ANS_SetNotificationsEnabledByUser_0100 + * @tc.desc : Test SetNotificationsEnabledByUser function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14900, Function | SmallTest | Level1) +{ + int32_t userId = 3; + bool enabled = true; + EXPECT_EQ(advancedNotificationService_->SetNotificationsEnabledByUser(userId, enabled), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15000 + * @tc.name : ANS_GetDoNotDisturbDate_0100 + * @tc.desc : Test GetDoNotDisturbDate function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15000, Function | SmallTest | Level1) +{ + int32_t userId = 3; + sptr date = nullptr; + EXPECT_EQ(advancedNotificationService_->GetDoNotDisturbDate(userId, date), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15100 + * @tc.name : ANS_SetHasPoppedDialog_0100 + * @tc.desc : Test SetHasPoppedDialog function when the result is ERR_ANS_INVALID_PARAM + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15100, Function | SmallTest | Level1) +{ + sptr bundleOption = nullptr; + bool hasPopped = true; + EXPECT_EQ(advancedNotificationService_->SetHasPoppedDialog(bundleOption, hasPopped), (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15200 + * @tc.name : ANS_GetHasPoppedDialog_0100 + * @tc.desc : Test GetHasPoppedDialog function when the result is ERR_ANS_INVALID_PARAM + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15200, Function | SmallTest | Level1) +{ + sptr bundleOption = nullptr; + bool hasPopped = true; + EXPECT_EQ(advancedNotificationService_->GetHasPoppedDialog(bundleOption, hasPopped), (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15300 + * @tc.name : ANS_ShellDump_0100 + * @tc.desc : Test ShellDump function when the result is ERR_ANS_INVALID_PARAM + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15300, Function | SmallTest | Level1) +{ + std::string cmd = "CMD"; + std::string bundle = "Bundle"; + int32_t userId = 4; + std::vector dumpInfo; + EXPECT_EQ(advancedNotificationService_->ShellDump(cmd, bundle, userId, dumpInfo), (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15400 + * @tc.name : ANS_Dump_0100 + * @tc.desc : Test Dump function when the result is ERR_OK + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15400, Function | SmallTest | Level1) +{ + int fd = 1; + std::vector args; + EXPECT_EQ(advancedNotificationService_->Dump(fd, args), (int)ERR_OK); +} } // namespace Notification } // namespace OHOS \ No newline at end of file diff --git a/services/ans/test/unittest/bundle_manager_helper_test.cpp b/services/ans/test/unittest/bundle_manager_helper_test.cpp index 4cde76e92036d47a6ae466ccd74a5c9c11a8cca1..0e29e8528450a406075fa76bd90bb56c3d4098af 100644 --- a/services/ans/test/unittest/bundle_manager_helper_test.cpp +++ b/services/ans/test/unittest/bundle_manager_helper_test.cpp @@ -16,11 +16,17 @@ #include #include +#define private public +#define protected public #include "bundle_manager_helper.h" +#undef private +#undef protected + #include "if_system_ability_manager.h" #include "ipc_skeleton.h" #include "iservice_registry.h" #include "system_ability_definition.h" +#include "access_token_helper.h" using namespace testing::ext; namespace OHOS { @@ -56,5 +62,63 @@ HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00200, Function | Smal std::shared_ptr bundleManager = BundleManagerHelper::GetInstance(); EXPECT_TRUE(bundleManager->IsSystemApp(callingUid)); } + +/** + * @tc.number : BundleManagerHelperTest_00300 + * @tc.name : CheckApiCompatibility + * @tc.desc : Test CheckApiCompatibility function when the bundleOption is nullptr,return is true + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00300, Level1) +{ + sptr bundleOption = nullptr; + BundleManagerHelper bundleManagerHelper; + bool result = bundleManagerHelper.CheckApiCompatibility(bundleOption); + EXPECT_EQ(result, true); +} + +/** + * @tc.number : BundleManagerHelperTest_00400 + * @tc.name : GetBundleInfoByBundleName + * @tc.desc : get bundleinfo by bundlename when the parameeter are normal, return is true + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00400, Level1) +{ + std::string bundle = "Bundle"; + int32_t userId = 1; + AppExecFwk::BundleInfo bundleInfo; + BundleManagerHelper bundleManagerHelper; + bool result = bundleManagerHelper.GetBundleInfoByBundleName(bundle, userId, bundleInfo); + EXPECT_EQ(result, true); +} + +/** + * @tc.number : BundleManagerHelperTest_00500 + * @tc.name : GetDefaultUidByBundleName + * @tc.desc : Test GetDefaultUidByBundleName function when the parameeter are normal + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00500, Level1) +{ + std::string bundle = "Bundle"; + int32_t userId = 1; + BundleManagerHelper bundleManagerHelper; + int32_t result = bundleManagerHelper.GetDefaultUidByBundleName(bundle, userId); + EXPECT_EQ(result, 1000); +} + +/** + * @tc.number : AccessTokenHelperTest_00100 + * @tc.name : IsSystemHap + * @tc.desc : Test IsSystemHap function when the parameeter are normal + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, AccessTokenHelperTest_00100, Level1) +{ + AccessTokenHelper accessTokenHelper; + bool result = accessTokenHelper.IsSystemHap(); + EXPECT_EQ(result, false); +} } // namespace Notification } // namespace OHOS diff --git a/services/ans/test/unittest/notification_preferences_database_test.cpp b/services/ans/test/unittest/notification_preferences_database_test.cpp index 392920628a83467da1eb4f924def30fb62ee0a24..471bd29f4a9dedb22d948a6775e1bd40eaeabc01 100644 --- a/services/ans/test/unittest/notification_preferences_database_test.cpp +++ b/services/ans/test/unittest/notification_preferences_database_test.cpp @@ -439,5 +439,31 @@ HWTEST_F(NotificationPreferencesDatabaseTest, CheckBundle_00100, Function | Smal { EXPECT_EQ(true, preferncesDB_->CheckBundle(bundleName_, bundleUid_)); } + +/** + * @tc.number : PutBundlePropertyToDisturbeDB_00100 + * @tc.name : PutBundlePropertyToDisturbeDB + * @tc.desc : Test PutBundlePropertyToDisturbeDB function return is false + * @tc.require : issueI5S4VP + */ +HWTEST_F(NotificationPreferencesDatabaseTest, PutBundlePropertyToDisturbeDB_00100, Function | SmallTest | Level1) +{ + NotificationPreferencesInfo::BundleInfo bundleInfo; + bundleInfo.SetBundleName(bundleName_); + bundleInfo.SetBundleUid(bundleUid_); + EXPECT_EQ(preferncesDB_->PutBundlePropertyToDisturbeDB(bundleInfo), false); +} + +/** + * @tc.number : RemoveAllSlotsFromDisturbeDB_00100 + * @tc.name : RemoveAllSlotsFromDisturbeDB + * @tc.desc : Test RemoveAllSlotsFromDisturbeDB function return is true + * @tc.require : issueI5S4VP + */ +HWTEST_F(NotificationPreferencesDatabaseTest, RemoveAllSlotsFromDisturbeDB_00100, Function | SmallTest | Level1) +{ + std::string bundleKey = "BundleKey"; + EXPECT_EQ(preferncesDB_->RemoveAllSlotsFromDisturbeDB(bundleKey), true); +} } // namespace Notification } // namespace OHOS diff --git a/services/ans/test/unittest/reminder_data_manager_test.cpp b/services/ans/test/unittest/reminder_data_manager_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1ad03b0422258ac7524bbeccdeeb54aeeba6604b --- /dev/null +++ b/services/ans/test/unittest/reminder_data_manager_test.cpp @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2021-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 +#include + +#define private public +#define protected public +#include "reminder_data_manager.h" +#undef private +#undef protected + +using namespace testing::ext; +namespace OHOS { +namespace Notification { +class ReminderDataManagerTest : public testing::Test { +public: + static void SetUpTestCase() {}; + static void TearDownTestCase() {}; + void SetUp() {}; + void TearDown() {}; +}; + +/** + * @tc.number : ReminderDataManagerTest_00200 + * @tc.name : CheckReminderLimitExceededLocked + * @tc.desc : Test CheckReminderLimitExceededLocked function when the bundleOption is nullptr,return is false + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00200, Level1) +{ + sptr bundleOption = nullptr; + ReminderDataManager reminderDataManager; + bool result = reminderDataManager.CheckReminderLimitExceededLocked(bundleOption); + EXPECT_EQ(result, false); +} + +/** + * @tc.number : ReminderDataManagerTest_00300 + * @tc.name : FindReminderRequestLocked + * @tc.desc : Test FindReminderRequestLocked function when the result is nullptr + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00300, Level1) +{ + int32_t reminderId = 1; + ReminderDataManager reminderDataManager; + sptr result = reminderDataManager.FindReminderRequestLocked(reminderId); + EXPECT_EQ(result, nullptr); +} + +/** + * @tc.number : ReminderDataManagerTest_00400 + * @tc.name : FindReminderRequestLocked + * @tc.desc : Test FindReminderRequestLocked function when the result is nullptr + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00400, Level1) +{ + int32_t reminderId = 1; + std::string pkgName = "PkgName"; + ReminderDataManager reminderDataManager; + sptr result = reminderDataManager.FindReminderRequestLocked(reminderId, pkgName); + EXPECT_EQ(result, nullptr); +} + +/** + * @tc.number : ReminderDataManagerTest_00500 + * @tc.name : FindNotificationBundleOption + * @tc.desc : Test FindNotificationBundleOption function when the result is nullptr + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00500, Level1) +{ + int32_t reminderId = 1; + ReminderDataManager reminderDataManager; + sptr result = reminderDataManager.FindNotificationBundleOption(reminderId); + EXPECT_EQ(result, nullptr); +} + +/** + * @tc.number : ReminderDataManagerTest_00700 + * @tc.name : GetInstance + * @tc.desc : Test GetInstance function when the result is nullptr + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00700, Level1) +{ + ReminderDataManager reminderDataManager; + std::shared_ptr result = reminderDataManager.GetInstance(); + EXPECT_EQ(result, nullptr); +} + +/** + * @tc.number : ReminderDataManagerTest_00900 + * @tc.name : ShouldAlert + * @tc.desc : Test ShouldAlert function when the result is nullptr + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00900, Level1) +{ + sptr reminder = nullptr; + ReminderDataManager reminderDataManager; + bool result = reminderDataManager.ShouldAlert(reminder); + EXPECT_EQ(result, false); +} + +/** + * @tc.number : ReminderDataManagerTest_01200 + * @tc.name : GetRecentReminderLocked + * @tc.desc : Test GetRecentReminderLocked function when the result is nullptr + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_01200, Level1) +{ + ReminderDataManager reminderDataManager; + sptr result = reminderDataManager.GetRecentReminderLocked(); + EXPECT_EQ(result, nullptr); +} + +/** + * @tc.number : ReminderDataManagerTest_01400 + * @tc.name : IsAllowedNotify + * @tc.desc : Test IsAllowedNotify function when the reminder is nullptr ,the result is false + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_01400, Level1) +{ + sptr reminder = nullptr; + ReminderDataManager reminderDataManager; + bool result = reminderDataManager.IsAllowedNotify(reminder); + EXPECT_EQ(result, false); +} + +/** + * @tc.number : ReminderDataManagerTest_01500 + * @tc.name : IsReminderAgentReady + * @tc.desc : Test IsReminderAgentReady function + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_01500, Level1) +{ + ReminderDataManager reminderDataManager; + bool result = reminderDataManager.IsReminderAgentReady(); + EXPECT_EQ(result, true); +} + +/** + * @tc.number : ReminderDataManagerTest_01700 + * @tc.name : GetSoundUri + * @tc.desc : Test GetSoundUri function when the reminder is nullptr + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_01700, Level1) +{ + sptr reminder = nullptr; + ReminderDataManager reminderDataManager; + std::string result = reminderDataManager.GetSoundUri(reminder); + EXPECT_EQ(result, "//system/etc/Light.ogg"); +} + +/** + * @tc.number : ReminderDataManagerTest_01100 + * @tc.name : Dump + * @tc.desc : Test Dump function + * @tc.require : issueI5S4VP + */ +HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_01100, Level1) +{ + ReminderDataManager reminderDataManager; + std::string result = reminderDataManager.Dump(); + EXPECT_EQ(result.size(), 68); +} +} // namespace Notification +} // namespace OHOS