diff --git a/frameworks/ans/test/unittest/notification_helper_test.cpp b/frameworks/ans/test/unittest/notification_helper_test.cpp index 7b9017750c46dfc1b71dd338a69cf4591a9be4f2..61ca7f2ad7598094969029a2411b0576bd0e1187 100644 --- a/frameworks/ans/test/unittest/notification_helper_test.cpp +++ b/frameworks/ans/test/unittest/notification_helper_test.cpp @@ -1244,6 +1244,36 @@ HWTEST_F(NotificationHelperTest, SetDistributedEnabledByBundle_0200, TestSize.Le EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); } +/** + * @tc.name: SetAdditionConfig_0100 + * @tc.desc: test SetAdditionConfig with parameters, expect errorCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + */ +HWTEST_F(NotificationHelperTest, SetAdditionConfig_0100, TestSize.Level1) +{ + std::string key = ""; + std::string value = ""; + NotificationHelper notificationHelper; + ErrCode ret = notificationHelper.SetAdditionConfig(key, value); + EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); +} + +/** + * @tc.name: CancelAsBundleWithAgent_0100 + * @tc.desc: test CancelAsBundleWithAgent with parameters, expect errorCode ERR_ANS_INVALID_PARAM. + * @tc.type: FUNC + */ +HWTEST_F(NotificationHelperTest, CancelAsBundleWithAgent_0100, TestSize.Level1) +{ + NotificationBundleOption bundleOption; + NotificationHelper notificationHelper; + bundleOption.SetBundleName(""); + bundleOption.SetUid(1); + int32_t id = 1; + ErrCode ret = notificationHelper.CancelAsBundleWithAgent(bundleOption, id); + EXPECT_EQ(ret, ERR_ANS_NO_AGENT_SETTING); +} + /** * @tc.name: IsDistributedEnabledByBundle_0100 * @tc.desc: test IsDistributedEnabledByBundle with parameters diff --git a/frameworks/ans/test/unittest/notification_request_test.cpp b/frameworks/ans/test/unittest/notification_request_test.cpp index 17d786491b67928f6a872f209dc5b25fea0abe12..a774df4f0bf0118629dce4e10da3058f1057bcf8 100644 --- a/frameworks/ans/test/unittest/notification_request_test.cpp +++ b/frameworks/ans/test/unittest/notification_request_test.cpp @@ -456,9 +456,11 @@ HWTEST_F(NotificationRequestTest, SetDevicesSupportDisplay_0100, Level1) bool result1 = notificationRequest.ConvertJsonToNotificationContent(nullptr, jsonObject); bool result2 = notificationRequest.ConvertJsonToNotificationActionButton(nullptr, jsonObject); bool result3 = notificationRequest.ConvertJsonToNotificationFlags(nullptr, jsonObject); + bool result4 = notificationRequest.ConvertJsonToNotificationBundleOption(nullptr, jsonObject); EXPECT_EQ(result1, false); EXPECT_EQ(result2, false); EXPECT_EQ(result3, false); + EXPECT_EQ(result4, false); } /** @@ -482,9 +484,11 @@ HWTEST_F(NotificationRequestTest, ConvertJsonToString_0100, Level1) bool result1 = notificationRequest.ConvertJsonToNotificationContent(target, jsonObject); bool result2 = notificationRequest.ConvertJsonToNotificationActionButton(target, jsonObject); bool result3 = notificationRequest.ConvertJsonToNotificationFlags(target, jsonObject); + bool result4 = notificationRequest.ConvertJsonToNotificationBundleOption(target, jsonObject); EXPECT_EQ(result1, true); EXPECT_EQ(result2, true); EXPECT_EQ(result3, true); + EXPECT_EQ(result4, true); } /** @@ -983,6 +987,39 @@ inline std::shared_ptr TestMakePixelMap(int32_t width, int32_t return pixelMap; } +/** + * @tc.name: SetBundleOption_0001 + * @tc.desc: Check SetBundleOption + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(NotificationRequestTest, SetBundleOption_0001, Level1) +{ + auto content = std::make_shared(); + + int32_t myNotificationId = 10; + NotificationRequest notificationRequest(myNotificationId); + notificationRequest.SetContent(content); + auto bundleOption = nullptr; + notificationRequest.SetBundleOption(bundleOption); +} + +/** + * @tc.name: GetBundleOption_0001 + * @tc.desc: Check GetBundleOption + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(NotificationRequestTest, GetBundleOption_0001, Level1) +{ + auto content = std::make_shared(); + + int32_t myNotificationId = 10; + NotificationRequest notificationRequest(myNotificationId); + notificationRequest.SetContent(content); + notificationRequest.GetBundleOption(); +} + /** * @tc.name: CheckImageSizeForContent_0001 * @tc.desc: Check no need to check image size when request is default diff --git a/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp b/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp index 1671925cee5699e0e9ebae05f26d68151a020adf..3974fabd709ca9962b27a52954f780a73408cd07 100644 --- a/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp +++ b/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp @@ -7877,6 +7877,101 @@ HWTEST_F(AnsManagerProxyUnitTest, GetAllNotificationEnabledBundles_0400, Functio EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); } +/* + * @tc.name: CancelAsBundleWithAgent_0100 + * @tc.desc: test CancelAsBundleWithAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleWithAgent_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAsBundleWithAgent_0100, TestSize.Level1"; + MockWriteInterfaceToken(false); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + sptr bundleOption = new (std::nothrow) NotificationBundleOption(); + ASSERT_NE(nullptr, bundleOption); + std::string bundleName = "bundleName"; + bundleOption->SetBundleName(bundleName); + int32_t id = 1; + + int32_t result = proxy->CancelAsBundleWithAgent(bundleOption, id); + EXPECT_EQ(result, ERR_ANS_PARCELABLE_FAILED); +} + +/* + * @tc.name: CancelAsBundleWithAgent_0200 + * @tc.desc: test CancelAsBundleWithAgent function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, CancelAsBundleWithAgent_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, CancelAsBundleWithAgent_0200, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + sptr bundleOption = nullptr; + int32_t id = 1; + + int32_t result = proxy->CancelAsBundleWithAgent(bundleOption, id); + EXPECT_EQ(result, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: SetAdditionConfig_0100 + * @tc.desc: test SetAdditionConfig function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetAdditionConfig_0100, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetAdditionConfig_0100, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + std::string key = "key"; + std::string value = "value"; + + int32_t result = proxy->SetAdditionConfig(key, value); + EXPECT_EQ(result, ERR_ANS_PARCELABLE_FAILED); +} + +/* + * @tc.name: SetAdditionConfig_0200 + * @tc.desc: test SetAdditionConfig function + * @tc.type: FUNC + * @tc.require: #I5XO2O + */ +HWTEST_F(AnsManagerProxyUnitTest, SetAdditionConfig_0200, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) + << "AnsManagerProxyUnitTest, SetAdditionConfig_0100, TestSize.Level1"; + MockWriteInterfaceToken(true); + sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); + ASSERT_NE(nullptr, iremoteObject); + std::shared_ptr proxy = std::make_shared(iremoteObject); + ASSERT_NE(nullptr, proxy); + + std::string key = ""; + std::string value = "value"; + + int32_t result = proxy->SetAdditionConfig(key, value); + EXPECT_EQ(result, ERR_ANS_PARCELABLE_FAILED); +} + /* * @tc.name: GetActiveNotificationByFilterTest_0100 * @tc.desc: test GetActiveNotificationByFilter function diff --git a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp index 10b352f22a1b215d1ca50ddeed5eed3fb1bdc036..213f32a8c5c25022ce1ea550e3e2282e1a043970 100644 --- a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp +++ b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp @@ -4653,6 +4653,42 @@ HWTEST_F(AnsManagerStubTest, IsDistributedEnabledByBundle_0100, TestSize.Level1) EXPECT_EQ(result, ERR_OK); } +/* + * @tc.name: HandleCancelAsBundleWithAgent_0100 + * @tc.desc: test HandleCancelAsBundleWithAgent. + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerStubTest, HandleCancelAsBundleWithAgent_0100, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + sptr bundleOption = new NotificationBundleOption(); + bundleOption->SetBundleName("bundleName"); + bundleOption->SetUid(1); + data.WriteStrongParcelable(bundleOption); + int32_t id = 0; + data.WriteInt32(id); + ErrCode res = ansManagerStub_->HandleCancelAsBundleWithAgent(data, reply); + EXPECT_EQ(res, ERR_INVALID_OPERATION); +} + +/* + * @tc.name: HandleSetAdditionConfig_0100 + * @tc.desc: test HandleSetAdditionConfig + * @tc.type: FUNC + */ +HWTEST_F(AnsManagerStubTest, HandleSetAdditionConfig_0100, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + std::string key = "key"; + std::string value = "value"; + data.WriteString(key); + data.WriteString(value); + ErrCode res = ansManagerStub_->HandleSetAdditionConfig(data, reply); + EXPECT_EQ(res, ERR_INVALID_OPERATION); +} + /** * @tc.name: HandleSetBadgeNumberByBundle01 * @tc.desc: Test HandleSetBadgeNumberByBundle with invalid data, expect error code ERR_ANS_PARCELABLE_FAILED. diff --git a/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp b/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp index 05ae49a60840ae71c0bea512c20402f117d38ec7..ad50778ce33d12e162bb3aebfaab99008b318038 100644 --- a/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp +++ b/frameworks/core/test/unittest/ans_notification_branch_test/ans_notification_branch_test.cpp @@ -844,6 +844,85 @@ HWTEST_F(AnsNotificationBranchTest, SetNotificationSlotFlagsAsBundle_0001, Funct EXPECT_EQ(ret, (int)ERR_ANS_INVALID_PARAM); } +/* + * @tc.name: SetAdditionConfig_0100 + * @tc.desc: 1.Test SetAdditionConfig + * 2.GetAnsManagerProxy is false + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, SetAdditionConfig_0100, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + MockGetAnsManagerProxy(false); + std::string key = "key"; + std::string value = "value"; + ErrCode ret = ansNotification->SetAdditionConfig(key, value); + EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: SetAdditionConfig_0200 + * @tc.desc: 1.Test SetAdditionConfig + * 2.GetAnsManagerProxy is true + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, SetAdditionConfig_0200, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + MockGetAnsManagerProxy(true); + std::string key = ""; + std::string value = "value"; + ansNotification->ansManagerProxy_ = new (std::nothrow) MockAnsManagerInterface(); + ErrCode ret = ansNotification->SetAdditionConfig(key, value); + EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); +} + +/* + * @tc.name: CancelAsBundleWithAgent_0100 + * @tc.desc: 1.Test CancelAsBundleWithAgent + * 2.GetAnsManagerProxy is false + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, CancelAsBundleWithAgent_0100, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + MockGetAnsManagerProxy(false); + NotificationBundleOption bundle; + bundle.SetBundleName("test"); + bundle.SetUid(1); + int32_t id = 0; + ansNotification->ansManagerProxy_ = new (std::nothrow) MockAnsManagerInterface(); + ErrCode ret = ansNotification->CancelAsBundleWithAgent(bundle, id); + EXPECT_EQ(ret, ERR_ANS_SERVICE_NOT_CONNECTED); +} + +/* + * @tc.name: CancelAsBundleWithAgent_0200 + * @tc.desc: 1.Test CancelAsBundleWithAgent + * 2.GetAnsManagerProxy is true + * @tc.type: FUNC + * @tc.require: #I62SME + */ +HWTEST_F(AnsNotificationBranchTest, CancelAsBundleWithAgent_0200, Function | MediumTest | Level1) +{ + auto ansNotification = std::make_shared(); + EXPECT_NE(ansNotification, nullptr); + MockGetAnsManagerProxy(true); + NotificationBundleOption bundle; + bundle.SetBundleName("test"); + bundle.SetUid(1); + int32_t id = -10; + ansNotification->ansManagerProxy_ = new (std::nothrow) MockAnsManagerInterface(); + ErrCode ret = ansNotification->CancelAsBundleWithAgent(bundle, id); + EXPECT_EQ(ret, ERR_ANS_INVALID_PARAM); +} + /* * @tc.name: PublishNotification_0001 * @tc.desc: PublishNotification diff --git a/services/ans/src/advanced_notification_slot_service.cpp b/services/ans/src/advanced_notification_slot_service.cpp index 13061d2275571c2b12020ed1bc620f5fa73865c6..63206cb66cddb4aad1f57764a0816f0644eb80a2 100644 --- a/services/ans/src/advanced_notification_slot_service.cpp +++ b/services/ans/src/advanced_notification_slot_service.cpp @@ -767,7 +767,7 @@ bool AdvancedNotificationService::IsAgentRelationship(const std::string &agentBu if (notificationSvrQueue_ == nullptr) { ANS_LOGE("Serial queue is invalid."); - return ERR_ANS_INVALID_PARAM; + return false; } bool result = false; diff --git a/services/ans/test/unittest/advanced_notification_publish_service_test.cpp b/services/ans/test/unittest/advanced_notification_publish_service_test.cpp index 71292efa82f6c84c07490e43824d636b280d5a20..b433c9a27a05c21af9c51502fb522ecdb6ec926f 100644 --- a/services/ans/test/unittest/advanced_notification_publish_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_publish_service_test.cpp @@ -977,6 +977,41 @@ HWTEST_F(AnsPublishServiceTest, IsSmartReminderEnabled_0400, TestSize.Level1) EXPECT_EQ(result, ERR_ANS_PERMISSION_DENIED); } +/** + * @tc.name: CancelAsBundleWithAgent_00001 + * @tc.desc: Test CancelAsBundleWithAgent + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(AnsPublishServiceTest, CancelAsBundleWithAgent_00001, Function | SmallTest | Level1) +{ + sptr bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + int32_t id = 0; + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + auto ret = advancedNotificationService_->CancelAsBundleWithAgent(bundle, id); + EXPECT_EQ(ret, (int)ERR_ANS_NON_SYSTEM_APP); +} + +/** + * @tc.name: CancelAsBundleWithAgent_00002 + * @tc.desc: Test CancelAsBundleWithAgent + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(AnsPublishServiceTest, CancelAsBundleWithAgent_00002, Function | SmallTest | Level1) +{ + sptr bundle = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, NON_SYSTEM_APP_UID); + int32_t id = -10; + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(false); + auto ret = advancedNotificationService_->CancelAsBundleWithAgent(bundle, id); + EXPECT_EQ(ret, (int)ERR_ANS_NON_SYSTEM_APP); + MockIsSystemApp(true); + ret = advancedNotificationService_->CancelAsBundleWithAgent(bundle, id); + EXPECT_EQ(ret, (int)ERR_ANS_NO_AGENT_SETTING); +} + /** * @tc.name: PublishRemoveDuplicateEvent_00001 * @tc.desc: Test PublishRemoveDuplicateEvent diff --git a/services/ans/test/unittest/advanced_notification_slot_service_test.cpp b/services/ans/test/unittest/advanced_notification_slot_service_test.cpp index fc3b5e5a368007f8f897f0301d1eff2e5564947d..ef7afa6abab7752aeef2b770c8adc8a272f4fc21 100644 --- a/services/ans/test/unittest/advanced_notification_slot_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_slot_service_test.cpp @@ -21,6 +21,7 @@ #include "gtest/gtest.h" #define private public +#define protected public #include "advanced_notification_service.h" #include "ans_inner_errors.h" #include "ans_log_wrapper.h" @@ -28,6 +29,7 @@ #include "notification_preferences.h" #include "notification_constant.h" #include "notification_config_parse.h" +#undef protected using namespace testing::ext; using namespace OHOS::Security::AccessToken; @@ -393,6 +395,69 @@ HWTEST_F(AnsSlotServiceTest, RemoveSlotByType_00002, Function | SmallTest | Leve EXPECT_EQ(ret, (int)ERR_ANS_NON_SYSTEM_APP); } +/** + * @tc.name: SetAdditionConfig_00001 + * @tc.desc: Test SetAdditionConfig + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(AnsSlotServiceTest, SetAdditionConfig_00001, Function | SmallTest | Level1) +{ + std::string key = "key"; + std::string value = "value"; + auto ret = advancedNotificationService_->SetAdditionConfig(key, value); + MockIsVerfyPermisson(true); + EXPECT_EQ(ret, (int)ERR_OK); +} + +/** + * @tc.name: SetAdditionConfig_00002 + * @tc.desc: Test SetAdditionConfig + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(AnsSlotServiceTest, SetAdditionConfig_00002, Function | SmallTest | Level1) +{ + std::string key = "key"; + std::string value = "value"; + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsVerfyPermisson(false); + auto ret = advancedNotificationService_->SetAdditionConfig(key, value); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); +} + +/** + * @tc.name: IsAgentRelationship_00001 + * @tc.desc: Test IsAgentRelationship + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(AnsSlotServiceTest, IsAgentRelationship_00001, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + std::string agentBundleName = ""; + std::string sourceBundleName = ""; + auto ret = advancedNotificationService_->IsAgentRelationship(agentBundleName, sourceBundleName); + EXPECT_EQ(ret, false); +} + +/** + * @tc.name: IsAgentRelationship_00002 + * @tc.desc: Test IsAgentRelationship + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(AnsSlotServiceTest, IsAgentRelationship_00002, Function | SmallTest | Level1) +{ + MockGetTokenTypeFlag(Security::AccessToken::ATokenTypeEnum::TOKEN_HAP); + MockIsSystemApp(true); + std::string agentBundleName = "test"; + std::string sourceBundleName = "test"; + auto ret = advancedNotificationService_->IsAgentRelationship(agentBundleName, sourceBundleName); + EXPECT_EQ(ret, false); +} + /** * @tc.name: GetSlotNumAsBundle_00001 * @tc.desc: Test GetSlotNumAsBundle diff --git a/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp b/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp index e16ab3418808bfb0f20b845795b081ccabfdf0b1..848264345334a82413103f9b22ce993d67cad016 100755 --- a/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp +++ b/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp @@ -991,6 +991,45 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0570 EXPECT_EQ(preferncesDB_->DeleteKvFromDb(string("test")), NativeRdb::E_OK); } +/** + * @tc.name : IsAgentRelationship_00100 + * @tc.number : + * @tc.desc : Test isAgentRelationship, return is false. + */ +HWTEST_F(NotificationPreferencesDatabaseBranchTest, IsAgentRelationship_00100, Function | SmallTest | Level1) +{ + std::string agentBundleName = "com.example.myapplication"; + std::string sourceBundleName = "com.example.myapplication1"; + EXPECT_EQ(preferncesDB_->IsAgentRelationship(agentBundleName, sourceBundleName), false); +} + +/** + * @tc.name : IsAgentRelationship_00200 + * @tc.number : + * @tc.desc : Test isAgentRelationship, return is false. + */ +HWTEST_F(NotificationPreferencesDatabaseBranchTest, IsAgentRelationship_00200, Function | SmallTest | Level1) +{ + std::string agentBundleName = "com.example.myapplication"; + std::string sourceBundleName = "com.example.myapplication1"; + MockInit(true); + EXPECT_EQ(preferncesDB_->IsAgentRelationship(agentBundleName, sourceBundleName), false); +} + +/** + * @tc.name : IsAgentRelationship_00300 + * @tc.number : + * @tc.desc : Test isAgentRelationship, return is false. + */ +HWTEST_F(NotificationPreferencesDatabaseBranchTest, IsAgentRelationship_00300, Function | SmallTest | Level1) +{ + std::string agentBundleName = "com.example.myapplication"; + std::string sourceBundleName = "com.example.myapplication1"; + MockInit(true); + MockQueryData(true); + EXPECT_EQ(preferncesDB_->IsAgentRelationship(agentBundleName, sourceBundleName), false); +} + /** * @tc.name : PutSlotFlags_00100 * @tc.number : diff --git a/services/ans/test/unittest/notification_preferences_test.cpp b/services/ans/test/unittest/notification_preferences_test.cpp index cffca97fcae4612856936186ce6e08b8610f99e5..f9ade74a7426a850eec0c9225bb3dfc18f6de621 100644 --- a/services/ans/test/unittest/notification_preferences_test.cpp +++ b/services/ans/test/unittest/notification_preferences_test.cpp @@ -1367,6 +1367,20 @@ HWTEST_F(NotificationPreferencesTest, IsDistributedEnabledByBundle_0100, TestSiz EXPECT_EQ(result, ERR_OK); } +/** + * @tc.name: IsAgentRelationship_0100 + * @tc.desc: test IsAgentRelationship. + * @tc.type: FUNC + */ +HWTEST_F(NotificationPreferencesTest, IsAgentRelationship_0100, TestSize.Level1) +{ + std::string agentBundleName = "com.example.myapplication"; + std::string sourceBundleName = "com.example.myapplication1"; + + ErrCode result = NotificationPreferences::GetInstance().IsAgentRelationship(agentBundleName, sourceBundleName); + EXPECT_EQ(result, false); +} + /** * @tc.name: IsDistributedEnabledByBundle_0200 * @tc.desc: test IsDistributedEnabledByBundle with parameters, expect errorCode ERR_ANS_INVALID_PARAM.