From 8aef9bb4764eade1fdb8362668c2b505252041da Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Tue, 20 Sep 2022 18:56:00 +0800 Subject: [PATCH 1/9] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5S4VP=20Description:?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96=E7=8E=87?= =?UTF-8?q?=20Sig:SIG=5FApplicationFramework=20Feature=20or=20Bugfix:Bugfi?= =?UTF-8?q?x=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwx1143030 Change-Id: Icaadb2cc2b54192f36e03d42ef3ff41c91a4c713 --- services/ans/test/unittest/BUILD.gn | 1 + .../unittest/bundle_manager_helper_test.cpp | 216 ++++++++++++++++++ 2 files changed, 217 insertions(+) diff --git a/services/ans/test/unittest/BUILD.gn b/services/ans/test/unittest/BUILD.gn index de4aa72a7..3802fa014 100644 --- a/services/ans/test/unittest/BUILD.gn +++ b/services/ans/test/unittest/BUILD.gn @@ -50,6 +50,7 @@ ohos_unittest("ans_unit_test") { "mock/distributed_kv_data_manager.cpp", "mock/mock_access_token_helper.cpp", "mock/mock_bundle_manager_helper.cpp", + "bundle_manager_helper_test.cpp", "mock/mock_event_handler.cpp", "mock/mock_ipc.cpp", "mock/mock_single_kv_store.cpp", diff --git a/services/ans/test/unittest/bundle_manager_helper_test.cpp b/services/ans/test/unittest/bundle_manager_helper_test.cpp index 4cde76e92..e274a9752 100644 --- a/services/ans/test/unittest/bundle_manager_helper_test.cpp +++ b/services/ans/test/unittest/bundle_manager_helper_test.cpp @@ -16,11 +16,18 @@ #include #include +#define private public +#define protected public #include "bundle_manager_helper.h" +#include "reminder_data_manager.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 +63,214 @@ 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 + * @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 : Test GetBundleInfoByBundleName function + * @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 + * @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 : ReminderDataManagerTest_00200 + * @tc.name : CheckReminderLimitExceededLocked + * @tc.desc : Test CheckReminderLimitExceededLocked function + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, 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(BundleManagerHelperTest, 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, 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(BundleManagerHelperTest, ReminderDataManagerTest_01100, Level1) +{ + ReminderDataManager reminderDataManager; + std::string result = reminderDataManager.Dump(); + EXPECT_EQ(result.size(), 68); +} + +/** + * @tc.number : AccessTokenHelperTest_00100 + * @tc.name : IsSystemHap + * @tc.desc : Test IsSystemHap function + * @tc.require : issueI5S4VP + */ +HWTEST_F(BundleManagerHelperTest, AccessTokenHelperTest_00100, Level1) +{ + AccessTokenHelper accessTokenHelper; + bool result = accessTokenHelper.IsSystemHap(); + EXPECT_EQ(result, false); +} } // namespace Notification } // namespace OHOS -- Gitee From 8193738cbdbb749528db32fc9986e0a84293e64e Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Tue, 20 Sep 2022 20:01:56 +0800 Subject: [PATCH 2/9] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5S4VP=20Description:?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96=E7=8E=87?= =?UTF-8?q?=20Sig:SIG=5FApplicationFramework=20Feature=20or=20Bugfix:Bugfi?= =?UTF-8?q?x=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwx1143030 Change-Id: I37e9d86cfdf6655643233f86e01fe3fb172cfb62 --- services/ans/test/unittest/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ans/test/unittest/BUILD.gn b/services/ans/test/unittest/BUILD.gn index 3802fa014..aadf21953 100644 --- a/services/ans/test/unittest/BUILD.gn +++ b/services/ans/test/unittest/BUILD.gn @@ -46,11 +46,11 @@ 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", "mock/mock_bundle_manager_helper.cpp", - "bundle_manager_helper_test.cpp", "mock/mock_event_handler.cpp", "mock/mock_ipc.cpp", "mock/mock_single_kv_store.cpp", -- Gitee From fc3cd71c0dc38d98a3498b424208a4756393dcfd Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Wed, 21 Sep 2022 17:15:45 +0800 Subject: [PATCH 3/9] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5S4VP=20Description:?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96=E7=8E=87?= =?UTF-8?q?=20Sig:SIG=5FApplicationFramework=20Feature=20or=20Bugfix:Bugfi?= =?UTF-8?q?x=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwx1143030 Change-Id: I63fd022f0b07ae233b9fe6d7f103e4179cb56c33 --- services/ans/test/unittest/BUILD.gn | 1 + .../advanced_notification_service_test.cpp | 316 ++++++++++++++++++ .../unittest/bundle_manager_helper_test.cpp | 152 --------- .../unittest/reminder_data_manager_test.cpp | 187 +++++++++++ 4 files changed, 504 insertions(+), 152 deletions(-) create mode 100644 services/ans/test/unittest/reminder_data_manager_test.cpp diff --git a/services/ans/test/unittest/BUILD.gn b/services/ans/test/unittest/BUILD.gn index aadf21953..e52a2f7aa 100644 --- a/services/ans/test/unittest/BUILD.gn +++ b/services/ans/test/unittest/BUILD.gn @@ -60,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 91a54d7a4..6587227ca 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -1669,5 +1669,321 @@ 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 + * @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; + EXPECT_EQ(advancedNotificationService_->CancelAsBundle(notificationId, representativeBundle, userId), 67108880); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_12700 + * @tc.name : ANS_CanPublishAsBundle_0100 + * @tc.desc : Test CanPublishAsBundle function + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12700, Function | SmallTest | Level1) +{ + std::string representativeBundle = "RepresentativeBundle"; + bool canPublish = true; + EXPECT_EQ(advancedNotificationService_->CanPublishAsBundle(representativeBundle, canPublish), 38); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_12800 + * @tc.name : ANS_PublishAsBundle_0100 + * @tc.desc : Test PublishAsBundle function + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12800, Function | SmallTest | Level1) +{ + sptr notification = nullptr; + std::string representativeBundle = "RepresentativeBundle"; + EXPECT_EQ(advancedNotificationService_->PublishAsBundle(notification, representativeBundle), 38); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_12900 + * @tc.name : ANS_HasNotificationPolicyAccessPermission_0100 + * @tc.desc : Test HasNotificationPolicyAccessPermission function + * @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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13000, Function | SmallTest | Level1) +{ + 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13100, Function | SmallTest | Level1) +{ + std::string deviceId = "DeviceId"; + EXPECT_EQ(advancedNotificationService_->RequestEnableNotification(deviceId), 67108867); +} + +/** + * @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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13300, Function | SmallTest | Level1) +{ + int32_t reminderId = 1; + EXPECT_EQ(advancedNotificationService_->CancelReminder(reminderId), 19); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13400 + * @tc.name : ANS_CancelAllReminders_0100 + * @tc.desc : Test CancelAllReminders function + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13400, Function | SmallTest | Level1) +{ + EXPECT_EQ(advancedNotificationService_->CancelAllReminders(), 19); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13500 + * @tc.name : ANS_GetValidReminders_0100 + * @tc.desc : Test GetValidReminders function + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13500, Function | SmallTest | Level1) +{ + std::vector> reminders; + EXPECT_EQ(advancedNotificationService_->GetValidReminders(reminders), 19); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_13600 + * @tc.name : ANS_ActiveNotificationDump_0100 + * @tc.desc : Test ActiveNotificationDump function + * @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 + * @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 + * @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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13900, Function | SmallTest | Level1) +{ + EXPECT_EQ(advancedNotificationService_->RemoveAllSlots(), (int)ERR_OK); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14200 + * @tc.name : ANS_DoesSupportDoNotDisturbMode_0100 + * @tc.desc : Test DoesSupportDoNotDisturbMode function + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14200, Function | SmallTest | Level1) +{ + 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14300, Function | SmallTest | Level1) +{ + 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14400, Function | SmallTest | Level1) +{ + 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14600, Function | SmallTest | Level1) +{ + 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14800, Function | SmallTest | Level1) +{ + int32_t userId = 3; + bool allowed = true; + EXPECT_EQ(advancedNotificationService_->IsSpecialUserAllowedNotify(userId, allowed), 67108867); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_14900 + * @tc.name : ANS_SetNotificationsEnabledByUser_0100 + * @tc.desc : Test SetNotificationsEnabledByUser function + * @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 + * @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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15100, Function | SmallTest | Level1) +{ + sptr bundleOption = nullptr; + bool hasPopped = true; + EXPECT_EQ(advancedNotificationService_->SetHasPoppedDialog(bundleOption, hasPopped), 67108867); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15200 + * @tc.name : ANS_GetHasPoppedDialog_0100 + * @tc.desc : Test GetHasPoppedDialog function + * @tc.require : issueI5S4VP + */ +HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15200, Function | SmallTest | Level1) +{ + sptr bundleOption = nullptr; + bool hasPopped = true; + EXPECT_EQ(advancedNotificationService_->GetHasPoppedDialog(bundleOption, hasPopped), 67108867); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15300 + * @tc.name : ANS_ShellDump_0100 + * @tc.desc : Test ShellDump function + * @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), 67108867); +} + +/** + * @tc.number : AdvancedNotificationServiceTest_15400 + * @tc.name : ANS_Dump_0100 + * @tc.desc : Test Dump function + * @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 e274a9752..a7be57df0 100644 --- a/services/ans/test/unittest/bundle_manager_helper_test.cpp +++ b/services/ans/test/unittest/bundle_manager_helper_test.cpp @@ -19,7 +19,6 @@ #define private public #define protected public #include "bundle_manager_helper.h" -#include "reminder_data_manager.h" #undef private #undef protected @@ -109,157 +108,6 @@ HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00500, Level1) EXPECT_EQ(result, 1000); } -/** - * @tc.number : ReminderDataManagerTest_00200 - * @tc.name : CheckReminderLimitExceededLocked - * @tc.desc : Test CheckReminderLimitExceededLocked function - * @tc.require : issueI5S4VP - */ -HWTEST_F(BundleManagerHelperTest, 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 - * @tc.require : issueI5S4VP - */ -HWTEST_F(BundleManagerHelperTest, 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 - * @tc.require : issueI5S4VP - */ -HWTEST_F(BundleManagerHelperTest, 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 - * @tc.require : issueI5S4VP - */ -HWTEST_F(BundleManagerHelperTest, 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 - * @tc.require : issueI5S4VP - */ -HWTEST_F(BundleManagerHelperTest, 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 - * @tc.require : issueI5S4VP - */ -HWTEST_F(BundleManagerHelperTest, 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 - * @tc.require : issueI5S4VP - */ -HWTEST_F(BundleManagerHelperTest, 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 - * @tc.require : issueI5S4VP - */ -HWTEST_F(BundleManagerHelperTest, 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(BundleManagerHelperTest, 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 - * @tc.require : issueI5S4VP - */ -HWTEST_F(BundleManagerHelperTest, 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(BundleManagerHelperTest, ReminderDataManagerTest_01100, Level1) -{ - ReminderDataManager reminderDataManager; - std::string result = reminderDataManager.Dump(); - EXPECT_EQ(result.size(), 68); -} - /** * @tc.number : AccessTokenHelperTest_00100 * @tc.name : IsSystemHap 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 000000000..6b51045ea --- /dev/null +++ b/services/ans/test/unittest/reminder_data_manager_test.cpp @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2021 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 + * @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 + * @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 + * @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 + * @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 + * @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 + * @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 + * @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 + * @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 + * @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 -- Gitee From ddf58d1b2fc89e52adfd09f91c27f37cd47cbc86 Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Wed, 21 Sep 2022 17:38:27 +0800 Subject: [PATCH 4/9] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5S4VP=20Description:?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96=E7=8E=87?= =?UTF-8?q?=20Sig:SIG=5FApplicationFramework=20Feature=20or=20Bugfix:Bugfi?= =?UTF-8?q?x=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwx1143030 Change-Id: If5a025843d56faa2fbf924605b700630e3f965ce --- services/ans/test/unittest/reminder_data_manager_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/ans/test/unittest/reminder_data_manager_test.cpp b/services/ans/test/unittest/reminder_data_manager_test.cpp index 6b51045ea..c93ef2d29 100644 --- a/services/ans/test/unittest/reminder_data_manager_test.cpp +++ b/services/ans/test/unittest/reminder_data_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 -- Gitee From 644e23fdb9198af958eb9ae914490c1cfe74dd46 Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Thu, 22 Sep 2022 16:30:49 +0800 Subject: [PATCH 5/9] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5S4VP=20Description:?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96=E7=8E=87?= =?UTF-8?q?=20Sig:SIG=5FApplicationFramework=20Feature=20or=20Bugfix:Bugfi?= =?UTF-8?q?x=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwx1143030 Change-Id: I6a5818705339c6c2453adfae0dec70b73769b5cf --- .../unittest/bundle_manager_helper_test.cpp | 8 +++--- ...notification_preferences_database_test.cpp | 26 +++++++++++++++++++ .../unittest/reminder_data_manager_test.cpp | 20 +++++++------- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/services/ans/test/unittest/bundle_manager_helper_test.cpp b/services/ans/test/unittest/bundle_manager_helper_test.cpp index a7be57df0..0e29e8528 100644 --- a/services/ans/test/unittest/bundle_manager_helper_test.cpp +++ b/services/ans/test/unittest/bundle_manager_helper_test.cpp @@ -66,7 +66,7 @@ HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00200, Function | Smal /** * @tc.number : BundleManagerHelperTest_00300 * @tc.name : CheckApiCompatibility - * @tc.desc : Test CheckApiCompatibility function + * @tc.desc : Test CheckApiCompatibility function when the bundleOption is nullptr,return is true * @tc.require : issueI5S4VP */ HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00300, Level1) @@ -80,7 +80,7 @@ HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00300, Level1) /** * @tc.number : BundleManagerHelperTest_00400 * @tc.name : GetBundleInfoByBundleName - * @tc.desc : Test GetBundleInfoByBundleName function + * @tc.desc : get bundleinfo by bundlename when the parameeter are normal, return is true * @tc.require : issueI5S4VP */ HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00400, Level1) @@ -96,7 +96,7 @@ HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00400, Level1) /** * @tc.number : BundleManagerHelperTest_00500 * @tc.name : GetDefaultUidByBundleName - * @tc.desc : Test GetDefaultUidByBundleName function + * @tc.desc : Test GetDefaultUidByBundleName function when the parameeter are normal * @tc.require : issueI5S4VP */ HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00500, Level1) @@ -111,7 +111,7 @@ HWTEST_F(BundleManagerHelperTest, BundleManagerHelperTest_00500, Level1) /** * @tc.number : AccessTokenHelperTest_00100 * @tc.name : IsSystemHap - * @tc.desc : Test IsSystemHap function + * @tc.desc : Test IsSystemHap function when the parameeter are normal * @tc.require : issueI5S4VP */ HWTEST_F(BundleManagerHelperTest, AccessTokenHelperTest_00100, Level1) diff --git a/services/ans/test/unittest/notification_preferences_database_test.cpp b/services/ans/test/unittest/notification_preferences_database_test.cpp index 392920628..add5ee776 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 + * @tc.require : issueI5S4VP + */ +HWTEST_F(NotificationPreferencesDatabaseTest, PutBundlePropertyToDisturbeDB_00100, Function | SmallTest | Level1) +{ + NotificationPreferencesInfo::BundleInfo bundleInfo; + bundleInfo.SetBundleName(bundleName_); + bundleInfo.SetBundleUid(bundleUid_); + EXPECT_EQ(false, preferncesDB_->PutBundlePropertyToDisturbeDB(bundleInfo)); +} + +/** + * @tc.number : RemoveAllSlotsFromDisturbeDB_00100 + * @tc.name : RemoveAllSlotsFromDisturbeDB + * @tc.desc : Test RemoveAllSlotsFromDisturbeDB function + * @tc.require : issueI5S4VP + */ +HWTEST_F(NotificationPreferencesDatabaseTest, RemoveAllSlotsFromDisturbeDB_00100, Function | SmallTest | Level1) +{ + std::string bundleKey = "BundleKey"; + EXPECT_EQ(true, preferncesDB_->RemoveAllSlotsFromDisturbeDB(bundleKey)); +} } // 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 index c93ef2d29..1ad03b042 100644 --- a/services/ans/test/unittest/reminder_data_manager_test.cpp +++ b/services/ans/test/unittest/reminder_data_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * 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 @@ -36,7 +36,7 @@ public: /** * @tc.number : ReminderDataManagerTest_00200 * @tc.name : CheckReminderLimitExceededLocked - * @tc.desc : Test CheckReminderLimitExceededLocked function + * @tc.desc : Test CheckReminderLimitExceededLocked function when the bundleOption is nullptr,return is false * @tc.require : issueI5S4VP */ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00200, Level1) @@ -50,7 +50,7 @@ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00200, Level1) /** * @tc.number : ReminderDataManagerTest_00300 * @tc.name : FindReminderRequestLocked - * @tc.desc : Test FindReminderRequestLocked function + * @tc.desc : Test FindReminderRequestLocked function when the result is nullptr * @tc.require : issueI5S4VP */ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00300, Level1) @@ -64,7 +64,7 @@ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00300, Level1) /** * @tc.number : ReminderDataManagerTest_00400 * @tc.name : FindReminderRequestLocked - * @tc.desc : Test FindReminderRequestLocked function + * @tc.desc : Test FindReminderRequestLocked function when the result is nullptr * @tc.require : issueI5S4VP */ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00400, Level1) @@ -79,7 +79,7 @@ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00400, Level1) /** * @tc.number : ReminderDataManagerTest_00500 * @tc.name : FindNotificationBundleOption - * @tc.desc : Test FindNotificationBundleOption function + * @tc.desc : Test FindNotificationBundleOption function when the result is nullptr * @tc.require : issueI5S4VP */ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00500, Level1) @@ -93,7 +93,7 @@ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00500, Level1) /** * @tc.number : ReminderDataManagerTest_00700 * @tc.name : GetInstance - * @tc.desc : Test GetInstance function + * @tc.desc : Test GetInstance function when the result is nullptr * @tc.require : issueI5S4VP */ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00700, Level1) @@ -106,7 +106,7 @@ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00700, Level1) /** * @tc.number : ReminderDataManagerTest_00900 * @tc.name : ShouldAlert - * @tc.desc : Test ShouldAlert function + * @tc.desc : Test ShouldAlert function when the result is nullptr * @tc.require : issueI5S4VP */ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00900, Level1) @@ -120,7 +120,7 @@ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_00900, Level1) /** * @tc.number : ReminderDataManagerTest_01200 * @tc.name : GetRecentReminderLocked - * @tc.desc : Test GetRecentReminderLocked function + * @tc.desc : Test GetRecentReminderLocked function when the result is nullptr * @tc.require : issueI5S4VP */ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_01200, Level1) @@ -133,7 +133,7 @@ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_01200, Level1) /** * @tc.number : ReminderDataManagerTest_01400 * @tc.name : IsAllowedNotify - * @tc.desc : Test IsAllowedNotify function + * @tc.desc : Test IsAllowedNotify function when the reminder is nullptr ,the result is false * @tc.require : issueI5S4VP */ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_01400, Level1) @@ -160,7 +160,7 @@ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_01500, Level1) /** * @tc.number : ReminderDataManagerTest_01700 * @tc.name : GetSoundUri - * @tc.desc : Test GetSoundUri function + * @tc.desc : Test GetSoundUri function when the reminder is nullptr * @tc.require : issueI5S4VP */ HWTEST_F(ReminderDataManagerTest, ReminderDataManagerTest_01700, Level1) -- Gitee From 4d2b970b1ab11d10fdc4b50a33ccccf2d40ec0a2 Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Thu, 22 Sep 2022 16:34:56 +0800 Subject: [PATCH 6/9] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5S4VP=20Description:?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96=E7=8E=87?= =?UTF-8?q?=20Sig:SIG=5FApplicationFramework=20Feature=20or=20Bugfix:Bugfi?= =?UTF-8?q?x=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwx1143030 Change-Id: Ia6a684ad73e1ffd62c93a4dc053075bb38f079f1 --- .../advanced_notification_service_test.cpp | 76 ++++++++++--------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index 6587227ca..e22a1f1e3 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -1673,7 +1673,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12500, /** * @tc.number : AdvancedNotificationServiceTest_12600 * @tc.name : ANS_CancelAsBundle_0100 - * @tc.desc : Test CancelAsBundle function + * @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) @@ -1682,39 +1682,39 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12600, int32_t notificationId = 1; std::string representativeBundle = "RepresentativeBundle"; int32_t userId = 1; - EXPECT_EQ(advancedNotificationService_->CancelAsBundle(notificationId, representativeBundle, userId), 67108880); + EXPECT_EQ(advancedNotificationService_->CancelAsBundle(notificationId, representativeBundle, userId), (int)ERR_ANS_NOTIFICATION_NOT_EXISTS); } /** * @tc.number : AdvancedNotificationServiceTest_12700 * @tc.name : ANS_CanPublishAsBundle_0100 - * @tc.desc : Test CanPublishAsBundle function + * @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; - EXPECT_EQ(advancedNotificationService_->CanPublishAsBundle(representativeBundle, canPublish), 38); + EXPECT_EQ(advancedNotificationService_->CanPublishAsBundle(representativeBundle, canPublish), (int)ERR_INVALID_OPERATION); } /** * @tc.number : AdvancedNotificationServiceTest_12800 * @tc.name : ANS_PublishAsBundle_0100 - * @tc.desc : Test PublishAsBundle function + * @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"; - EXPECT_EQ(advancedNotificationService_->PublishAsBundle(notification, representativeBundle), 38); + EXPECT_EQ(advancedNotificationService_->PublishAsBundle(notification, representativeBundle), (int)ERR_INVALID_OPERATION); } /** * @tc.number : AdvancedNotificationServiceTest_12900 * @tc.name : ANS_HasNotificationPolicyAccessPermission_0100 - * @tc.desc : Test HasNotificationPolicyAccessPermission function + * @tc.desc : Test HasNotificationPolicyAccessPermission function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12900, Function | SmallTest | Level1) @@ -1726,7 +1726,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12900, /** * @tc.number : AdvancedNotificationServiceTest_13000 * @tc.name : ANS_GetShowBadgeEnabled_0100 - * @tc.desc : Test GetShowBadgeEnabled function + * @tc.desc : Test GetShowBadgeEnabled function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13000, Function | SmallTest | Level1) @@ -1738,13 +1738,13 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13000, /** * @tc.number : AdvancedNotificationServiceTest_13100 * @tc.name : ANS_RequestEnableNotification_0100 - * @tc.desc : Test RequestEnableNotification function + * @tc.desc : Test RequestEnableNotification function when the result is ERR_ANS_INVALID_PARAM * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13100, Function | SmallTest | Level1) { std::string deviceId = "DeviceId"; - EXPECT_EQ(advancedNotificationService_->RequestEnableNotification(deviceId), 67108867); + EXPECT_EQ(advancedNotificationService_->RequestEnableNotification(deviceId), (int)ERR_ANS_INVALID_PARAM); } /** @@ -1762,42 +1762,45 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13200, /** * @tc.number : AdvancedNotificationServiceTest_13300 * @tc.name : ANS_CancelReminder_0100 - * @tc.desc : Test CancelReminder function + * @tc.desc : Test CancelReminder function when the result is ERR_NO_INIT * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13300, Function | SmallTest | Level1) { int32_t reminderId = 1; - EXPECT_EQ(advancedNotificationService_->CancelReminder(reminderId), 19); + EXPECT_EQ(advancedNotificationService_->CancelReminder(reminderId), (int)ERR_NO_INIT); } /** * @tc.number : AdvancedNotificationServiceTest_13400 * @tc.name : ANS_CancelAllReminders_0100 - * @tc.desc : Test CancelAllReminders function + * @tc.desc : Test CancelAllReminders function when the result is ERR_NO_INIT * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13400, Function | SmallTest | Level1) { - EXPECT_EQ(advancedNotificationService_->CancelAllReminders(), 19); + 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 + * @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), 19); + EXPECT_EQ(advancedNotificationService_->GetValidReminders(reminders), (int)ERR_NO_INIT); } /** * @tc.number : AdvancedNotificationServiceTest_13600 * @tc.name : ANS_ActiveNotificationDump_0100 - * @tc.desc : Test ActiveNotificationDump function + * @tc.desc : Test ActiveNotificationDump function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13600, Function | SmallTest | Level1) @@ -1811,7 +1814,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13600, /** * @tc.number : AdvancedNotificationServiceTest_13700 * @tc.name : ANS_RecentNotificationDump_0100 - * @tc.desc : Test RecentNotificationDump function + * @tc.desc : Test RecentNotificationDump function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13700, Function | SmallTest | Level1) @@ -1825,7 +1828,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13700, /** * @tc.number : AdvancedNotificationServiceTest_13800 * @tc.name : ANS_SetRecentNotificationCount_0100 - * @tc.desc : Test SetRecentNotificationCount function + * @tc.desc : Test SetRecentNotificationCount function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13800, Function | SmallTest | Level1) @@ -1837,18 +1840,21 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13800, /** * @tc.number : AdvancedNotificationServiceTest_13900 * @tc.name : ANS_RemoveAllSlots_0100 - * @tc.desc : Test RemoveAllSlots function + * @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 + * @tc.desc : Test DoesSupportDoNotDisturbMode function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14200, Function | SmallTest | Level1) @@ -1860,7 +1866,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14200, /** * @tc.number : AdvancedNotificationServiceTest_14300 * @tc.name : ANS_IsDistributedEnabled_0100 - * @tc.desc : Test IsDistributedEnabled function + * @tc.desc : Test IsDistributedEnabled function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14300, Function | SmallTest | Level1) @@ -1872,7 +1878,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14300, /** * @tc.number : AdvancedNotificationServiceTest_14400 * @tc.name : ANS_EnableDistributed_0100 - * @tc.desc : Test EnableDistributed function + * @tc.desc : Test EnableDistributed function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14400, Function | SmallTest | Level1) @@ -1884,7 +1890,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14400, /** * @tc.number : AdvancedNotificationServiceTest_14600 * @tc.name : ANS_EnableDistributedSelf_0100 - * @tc.desc : Test EnableDistributedSelf function + * @tc.desc : Test EnableDistributedSelf function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14600, Function | SmallTest | Level1) @@ -1896,20 +1902,20 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14600, /** * @tc.number : AdvancedNotificationServiceTest_14800 * @tc.name : ANS_IsSpecialUserAllowedNotify_0100 - * @tc.desc : Test IsSpecialUserAllowedNotify function + * @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), 67108867); + 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 + * @tc.desc : Test SetNotificationsEnabledByUser function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14900, Function | SmallTest | Level1) @@ -1922,7 +1928,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14900, /** * @tc.number : AdvancedNotificationServiceTest_15000 * @tc.name : ANS_GetDoNotDisturbDate_0100 - * @tc.desc : Test GetDoNotDisturbDate function + * @tc.desc : Test GetDoNotDisturbDate function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15000, Function | SmallTest | Level1) @@ -1935,33 +1941,33 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15000, /** * @tc.number : AdvancedNotificationServiceTest_15100 * @tc.name : ANS_SetHasPoppedDialog_0100 - * @tc.desc : Test SetHasPoppedDialog function + * @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), 67108867); + 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 + * @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), 67108867); + 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 + * @tc.desc : Test ShellDump function when the result is ERR_ANS_INVALID_PARAM * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15300, Function | SmallTest | Level1) @@ -1970,13 +1976,13 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15300, std::string bundle = "Bundle"; int32_t userId = 4; std::vector dumpInfo; - EXPECT_EQ(advancedNotificationService_->ShellDump(cmd, bundle, userId, dumpInfo), 67108867); + 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 + * @tc.desc : Test Dump function when the result is ERR_OK * @tc.require : issueI5S4VP */ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_15400, Function | SmallTest | Level1) -- Gitee From 01ff02df77efc8b7a396681ed805e5633b878181 Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Thu, 22 Sep 2022 16:49:34 +0800 Subject: [PATCH 7/9] Signed-off-by: wwx1143030 Change-Id: I784d9c984632e59ab1df2119011e5f2b90dab574 --- .../advanced_notification_service_test.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index e22a1f1e3..a70625e3d 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -1731,6 +1731,9 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12900, */ 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); } @@ -1743,6 +1746,9 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13000, */ 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); } @@ -1767,6 +1773,9 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13200, */ 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); } @@ -1859,6 +1868,9 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_13900, */ 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); } @@ -1871,6 +1883,9 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14200, */ 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); } @@ -1883,6 +1898,9 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14300, */ 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); } @@ -1895,6 +1913,9 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_14400, */ 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); } -- Gitee From d3661e67c8ba66d654411fca18d51d2df410501a Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Thu, 22 Sep 2022 16:50:01 +0800 Subject: [PATCH 8/9] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5S4VP=20Description:?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96=E7=8E=87?= =?UTF-8?q?=20Sig:SIG=5FApplicationFramework=20Feature=20or=20Bugfix:Bugfi?= =?UTF-8?q?x=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwx1143030 Change-Id: Idc51194a8bb7bd64f10688e31f683bbe12716911 --- .../unittest/notification_preferences_database_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/ans/test/unittest/notification_preferences_database_test.cpp b/services/ans/test/unittest/notification_preferences_database_test.cpp index add5ee776..471bd29f4 100644 --- a/services/ans/test/unittest/notification_preferences_database_test.cpp +++ b/services/ans/test/unittest/notification_preferences_database_test.cpp @@ -443,7 +443,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, CheckBundle_00100, Function | Smal /** * @tc.number : PutBundlePropertyToDisturbeDB_00100 * @tc.name : PutBundlePropertyToDisturbeDB - * @tc.desc : Test PutBundlePropertyToDisturbeDB function + * @tc.desc : Test PutBundlePropertyToDisturbeDB function return is false * @tc.require : issueI5S4VP */ HWTEST_F(NotificationPreferencesDatabaseTest, PutBundlePropertyToDisturbeDB_00100, Function | SmallTest | Level1) @@ -451,19 +451,19 @@ HWTEST_F(NotificationPreferencesDatabaseTest, PutBundlePropertyToDisturbeDB_0010 NotificationPreferencesInfo::BundleInfo bundleInfo; bundleInfo.SetBundleName(bundleName_); bundleInfo.SetBundleUid(bundleUid_); - EXPECT_EQ(false, preferncesDB_->PutBundlePropertyToDisturbeDB(bundleInfo)); + EXPECT_EQ(preferncesDB_->PutBundlePropertyToDisturbeDB(bundleInfo), false); } /** * @tc.number : RemoveAllSlotsFromDisturbeDB_00100 * @tc.name : RemoveAllSlotsFromDisturbeDB - * @tc.desc : Test RemoveAllSlotsFromDisturbeDB function + * @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(true, preferncesDB_->RemoveAllSlotsFromDisturbeDB(bundleKey)); + EXPECT_EQ(preferncesDB_->RemoveAllSlotsFromDisturbeDB(bundleKey), true); } } // namespace Notification } // namespace OHOS -- Gitee From ca326e7fedb1b4c649084243e01f3351e83183cf Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Thu, 22 Sep 2022 17:33:12 +0800 Subject: [PATCH 9/9] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5S4VP=20Description:?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=88=86=E6=94=AF=E8=A6=86=E7=9B=96=E7=8E=87?= =?UTF-8?q?=20Sig:SIG=5FApplicationFramework=20Feature=20or=20Bugfix:Bugfi?= =?UTF-8?q?x=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wwx1143030 Change-Id: I56fc3fd5a9a9ae9cc69f6b6e7f312d41cc1f3786 --- .../test/unittest/advanced_notification_service_test.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index a70625e3d..60b4a295f 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -1682,7 +1682,8 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12600, int32_t notificationId = 1; std::string representativeBundle = "RepresentativeBundle"; int32_t userId = 1; - EXPECT_EQ(advancedNotificationService_->CancelAsBundle(notificationId, representativeBundle, userId), (int)ERR_ANS_NOTIFICATION_NOT_EXISTS); + int result = ERR_ANS_NOTIFICATION_NOT_EXISTS; + EXPECT_EQ(advancedNotificationService_->CancelAsBundle(notificationId, representativeBundle, userId), result); } /** @@ -1695,7 +1696,8 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12700, { std::string representativeBundle = "RepresentativeBundle"; bool canPublish = true; - EXPECT_EQ(advancedNotificationService_->CanPublishAsBundle(representativeBundle, canPublish), (int)ERR_INVALID_OPERATION); + int result = ERR_INVALID_OPERATION; + EXPECT_EQ(advancedNotificationService_->CanPublishAsBundle(representativeBundle, canPublish), result); } /** @@ -1708,7 +1710,8 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_12800, { sptr notification = nullptr; std::string representativeBundle = "RepresentativeBundle"; - EXPECT_EQ(advancedNotificationService_->PublishAsBundle(notification, representativeBundle), (int)ERR_INVALID_OPERATION); + int result = ERR_INVALID_OPERATION; + EXPECT_EQ(advancedNotificationService_->PublishAsBundle(notification, representativeBundle), result); } /** -- Gitee