From 3b14039ff812bb0e624a143b62cd38ae6843970b Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Fri, 23 Sep 2022 15:16:23 +0800 Subject: [PATCH 1/3] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5SR8J=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: I1e83d474e5578291800d9ef659b7f7b7f6ed8671 --- ...notification_preferences_database_test.cpp | 24 ++++++ .../notification_preferences_test.cpp | 79 +++++++++++++++++++ 2 files changed, 103 insertions(+) diff --git a/services/ans/test/unittest/notification_preferences_database_test.cpp b/services/ans/test/unittest/notification_preferences_database_test.cpp index 471bd29f4..d0ac91938 100644 --- a/services/ans/test/unittest/notification_preferences_database_test.cpp +++ b/services/ans/test/unittest/notification_preferences_database_test.cpp @@ -465,5 +465,29 @@ HWTEST_F(NotificationPreferencesDatabaseTest, RemoveAllSlotsFromDisturbeDB_00100 std::string bundleKey = "BundleKey"; EXPECT_EQ(preferncesDB_->RemoveAllSlotsFromDisturbeDB(bundleKey), true); } + +/** + * @tc.number : RemoveNotificationEnable_00100 + * @tc.name : RemoveNotificationEnable + * @tc.desc : Test RemoveNotificationEnable function when parameter is normal return is true + * @tc.require : issueI5SR8J + */ +HWTEST_F(NotificationPreferencesDatabaseTest, RemoveNotificationEnable_00100, Function | SmallTest | Level1) +{ + int32_t userId = 1; + EXPECT_EQ(preferncesDB_->RemoveNotificationEnable(userId), true); +} + +/** + * @tc.number : RemoveDoNotDisturbDate_00100 + * @tc.name : RemoveDoNotDisturbDate + * @tc.desc : Test RemoveDoNotDisturbDate function when parameter is normal return is true + * @tc.require : issueI5SR8J + */ +HWTEST_F(NotificationPreferencesDatabaseTest, RemoveDoNotDisturbDate_00100, Function | SmallTest | Level1) +{ + int32_t userId = 1; + EXPECT_EQ(preferncesDB_->RemoveDoNotDisturbDate(userId), true); +} } // namespace Notification } // namespace OHOS diff --git a/services/ans/test/unittest/notification_preferences_test.cpp b/services/ans/test/unittest/notification_preferences_test.cpp index 0ffe922c4..51d95ebd4 100644 --- a/services/ans/test/unittest/notification_preferences_test.cpp +++ b/services/ans/test/unittest/notification_preferences_test.cpp @@ -798,5 +798,84 @@ HWTEST_F(NotificationPreferencesTest, GetHasPoppedDialog_00100, Function | Small EXPECT_EQ((int)NotificationPreferences::GetInstance().GetHasPoppedDialog(bundleOption_, hasPopped), (int)ERR_OK); EXPECT_TRUE(hasPopped); } + +/** + * @tc.number : AddNotificationBundleProperty_00100 + * @tc.name : AddNotificationBundleProperty + * @tc.desc : Add a notification BundleProperty into distrube DB when bundleOption is null, return is ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED. + * @tc.require : issueI5SR8J + */ +HWTEST_F(NotificationPreferencesTest, AddNotificationBundleProperty_00100, Function | SmallTest | Level1) +{ + EXPECT_EQ((int)NotificationPreferences::GetInstance().AddNotificationBundleProperty(bundleOption_), + (int)ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED); +} + +/** + * @tc.number : AddNotificationBundleProperty_00200 + * @tc.name : AddNotificationBundleProperty + * @tc.desc : Add a notification BundleProperty into distrube DB when bundlename is null, + * return is ERR_ANS_INVALID_PARAM. + * @tc.require : issueI5SR8J + */ +HWTEST_F(NotificationPreferencesTest, AddNotificationBundleProperty_00200, Function | SmallTest | Level1) +{ + EXPECT_EQ((int)NotificationPreferences::GetInstance().AddNotificationBundleProperty(bundleEmptyOption_), + (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : RemoveNotificationAllSlots_00100 + * @tc.name : RemoveNotificationAllSlots + * @tc.desc : Test RemoveNotificationAllSlots function when bundlename is null, + * return is ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST. + * @tc.require : issueI5SR8J + */ +HWTEST_F(NotificationPreferencesTest, RemoveNotificationAllSlots_00100, Function | SmallTest | Level1) +{ + EXPECT_EQ((int)NotificationPreferences::GetInstance().RemoveNotificationAllSlots(bundleOption_), + (int)ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST); +} + +/** + * @tc.number : RemoveNotificationAllSlots_00200 + * @tc.name : RemoveNotificationAllSlots + * @tc.desc : Test RemoveNotificationAllSlots function when bundleOption is null, + * return is ERR_ANS_INVALID_PARAM. + * @tc.require : issueI5SR8J + */ +HWTEST_F(NotificationPreferencesTest, RemoveNotificationAllSlots_00200, Function | SmallTest | Level1) +{ + EXPECT_EQ((int)NotificationPreferences::GetInstance().RemoveNotificationAllSlots(bundleEmptyOption_), + (int)ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.number : GetNotificationSlotsNumForBundle_00100 + * @tc.name : GetNotificationSlotsNumForBundle + * @tc.desc : Test GetNotificationSlotsNumForBundle function when bundlename is null, + * return is ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST. + * @tc.require : issueI5SR8J + */ +HWTEST_F(NotificationPreferencesTest, GetNotificationSlotsNumForBundle_00100, Function | SmallTest | Level1) +{ + uint64_t num = 1; + EXPECT_EQ((int)NotificationPreferences::GetInstance().GetNotificationSlotsNumForBundle(bundleOption_, num), + (int)ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST); +} + +/** + * @tc.number : GetNotificationSlotsNumForBundle_00200 + * @tc.name : GetNotificationSlotsNumForBundle + * @tc.desc : Test GetNotificationSlotsNumForBundle function when bundleOption is null, + * return is ERR_ANS_INVALID_PARAM. + * @tc.require : issueI5SR8J + */ +HWTEST_F(NotificationPreferencesTest, GetNotificationSlotsNumForBundle_00200, Function | SmallTest | Level1) +{ + uint64_t num = 2; + EXPECT_EQ((int)NotificationPreferences::GetInstance().GetNotificationSlotsNumForBundle(bundleEmptyOption_, num), + (int)ERR_ANS_INVALID_PARAM); +} } // namespace Notification } // namespace OHOS -- Gitee From 1dc921ba0982d664f972f99c585ca9a76e657c71 Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Fri, 23 Sep 2022 16:27:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5SR8J=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: Icf22c204a533d1331642acfa730889d92571b880 --- .../test/unittest/notification_preferences_test.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/services/ans/test/unittest/notification_preferences_test.cpp b/services/ans/test/unittest/notification_preferences_test.cpp index 51d95ebd4..194b6adc8 100644 --- a/services/ans/test/unittest/notification_preferences_test.cpp +++ b/services/ans/test/unittest/notification_preferences_test.cpp @@ -802,7 +802,8 @@ HWTEST_F(NotificationPreferencesTest, GetHasPoppedDialog_00100, Function | Small /** * @tc.number : AddNotificationBundleProperty_00100 * @tc.name : AddNotificationBundleProperty - * @tc.desc : Add a notification BundleProperty into distrube DB when bundleOption is null, return is ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED. + * @tc.desc : Add a notification BundleProperty into distrube DB when bundleOption is null, + * return is ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED. * @tc.require : issueI5SR8J */ HWTEST_F(NotificationPreferencesTest, AddNotificationBundleProperty_00100, Function | SmallTest | Level1) @@ -815,7 +816,7 @@ HWTEST_F(NotificationPreferencesTest, AddNotificationBundleProperty_00100, Funct * @tc.number : AddNotificationBundleProperty_00200 * @tc.name : AddNotificationBundleProperty * @tc.desc : Add a notification BundleProperty into distrube DB when bundlename is null, - * return is ERR_ANS_INVALID_PARAM. + * return is ERR_ANS_INVALID_PARAM. * @tc.require : issueI5SR8J */ HWTEST_F(NotificationPreferencesTest, AddNotificationBundleProperty_00200, Function | SmallTest | Level1) @@ -828,7 +829,7 @@ HWTEST_F(NotificationPreferencesTest, AddNotificationBundleProperty_00200, Funct * @tc.number : RemoveNotificationAllSlots_00100 * @tc.name : RemoveNotificationAllSlots * @tc.desc : Test RemoveNotificationAllSlots function when bundlename is null, - * return is ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST. + * return is ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST. * @tc.require : issueI5SR8J */ HWTEST_F(NotificationPreferencesTest, RemoveNotificationAllSlots_00100, Function | SmallTest | Level1) @@ -841,7 +842,7 @@ HWTEST_F(NotificationPreferencesTest, RemoveNotificationAllSlots_00100, Function * @tc.number : RemoveNotificationAllSlots_00200 * @tc.name : RemoveNotificationAllSlots * @tc.desc : Test RemoveNotificationAllSlots function when bundleOption is null, - * return is ERR_ANS_INVALID_PARAM. + * return is ERR_ANS_INVALID_PARAM. * @tc.require : issueI5SR8J */ HWTEST_F(NotificationPreferencesTest, RemoveNotificationAllSlots_00200, Function | SmallTest | Level1) @@ -854,7 +855,7 @@ HWTEST_F(NotificationPreferencesTest, RemoveNotificationAllSlots_00200, Function * @tc.number : GetNotificationSlotsNumForBundle_00100 * @tc.name : GetNotificationSlotsNumForBundle * @tc.desc : Test GetNotificationSlotsNumForBundle function when bundlename is null, - * return is ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST. + * return is ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST. * @tc.require : issueI5SR8J */ HWTEST_F(NotificationPreferencesTest, GetNotificationSlotsNumForBundle_00100, Function | SmallTest | Level1) @@ -868,7 +869,7 @@ HWTEST_F(NotificationPreferencesTest, GetNotificationSlotsNumForBundle_00100, Fu * @tc.number : GetNotificationSlotsNumForBundle_00200 * @tc.name : GetNotificationSlotsNumForBundle * @tc.desc : Test GetNotificationSlotsNumForBundle function when bundleOption is null, - * return is ERR_ANS_INVALID_PARAM. + * return is ERR_ANS_INVALID_PARAM. * @tc.require : issueI5SR8J */ HWTEST_F(NotificationPreferencesTest, GetNotificationSlotsNumForBundle_00200, Function | SmallTest | Level1) -- Gitee From 141783be5f43d1782e701c1a39cb442451d59f00 Mon Sep 17 00:00:00 2001 From: wwx1143030 Date: Fri, 23 Sep 2022 16:42:18 +0800 Subject: [PATCH 3/3] =?UTF-8?q?IssueNo:https://gitee.com/openharmony/notif?= =?UTF-8?q?ication=5Fcommon=5Fevent=5Fservice/issues/I5SR8J=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: I80a7feba70b8b857adc027b7847999db0ad20a8f --- .../ans/test/unittest/notification_preferences_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/ans/test/unittest/notification_preferences_test.cpp b/services/ans/test/unittest/notification_preferences_test.cpp index 194b6adc8..fed80303f 100644 --- a/services/ans/test/unittest/notification_preferences_test.cpp +++ b/services/ans/test/unittest/notification_preferences_test.cpp @@ -828,7 +828,7 @@ HWTEST_F(NotificationPreferencesTest, AddNotificationBundleProperty_00200, Funct /** * @tc.number : RemoveNotificationAllSlots_00100 * @tc.name : RemoveNotificationAllSlots - * @tc.desc : Test RemoveNotificationAllSlots function when bundlename is null, + * @tc.desc : Test RemoveNotificationAllSlots function when bundlename is null, * return is ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST. * @tc.require : issueI5SR8J */ @@ -841,7 +841,7 @@ HWTEST_F(NotificationPreferencesTest, RemoveNotificationAllSlots_00100, Function /** * @tc.number : RemoveNotificationAllSlots_00200 * @tc.name : RemoveNotificationAllSlots - * @tc.desc : Test RemoveNotificationAllSlots function when bundleOption is null, + * @tc.desc : Test RemoveNotificationAllSlots function when bundleOption is null, * return is ERR_ANS_INVALID_PARAM. * @tc.require : issueI5SR8J */ @@ -854,7 +854,7 @@ HWTEST_F(NotificationPreferencesTest, RemoveNotificationAllSlots_00200, Function /** * @tc.number : GetNotificationSlotsNumForBundle_00100 * @tc.name : GetNotificationSlotsNumForBundle - * @tc.desc : Test GetNotificationSlotsNumForBundle function when bundlename is null, + * @tc.desc : Test GetNotificationSlotsNumForBundle function when bundlename is null, * return is ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST. * @tc.require : issueI5SR8J */ @@ -868,7 +868,7 @@ HWTEST_F(NotificationPreferencesTest, GetNotificationSlotsNumForBundle_00100, Fu /** * @tc.number : GetNotificationSlotsNumForBundle_00200 * @tc.name : GetNotificationSlotsNumForBundle - * @tc.desc : Test GetNotificationSlotsNumForBundle function when bundleOption is null, + * @tc.desc : Test GetNotificationSlotsNumForBundle function when bundleOption is null, * return is ERR_ANS_INVALID_PARAM. * @tc.require : issueI5SR8J */ -- Gitee