diff --git a/frameworks/wantagent/test/unittest/pending_want_test/BUILD.gn b/frameworks/wantagent/test/unittest/pending_want_test/BUILD.gn index 39561893289f55d9dc85c5df35e90c78a1caba58..80252d5fd32de52f48041e160953f428229e36a0 100644 --- a/frameworks/wantagent/test/unittest/pending_want_test/BUILD.gn +++ b/frameworks/wantagent/test/unittest/pending_want_test/BUILD.gn @@ -20,6 +20,7 @@ module_output_path = "ans_standard/wantagent" ohos_unittest("pending_want_test") { module_out_path = module_output_path include_dirs = [ + "//aafwk/standard/frameworks/kits/appkit/native/ability_runtime/context/", "//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime", "//foundation/aafwk/standard/services/abilitymgr/include", "//foundation/distributedschedule/samgr/adapter/interfaces/innerkits/include/", diff --git a/frameworks/wantagent/test/unittest/pending_want_test/pending_want_test.cpp b/frameworks/wantagent/test/unittest/pending_want_test/pending_want_test.cpp index 4f66a28dcc39fa3bd42e63c5bab3c49a1111cfe2..ee49efd405b6375da53b297175bfcff1a190bbce 100644 --- a/frameworks/wantagent/test/unittest/pending_want_test/pending_want_test.cpp +++ b/frameworks/wantagent/test/unittest/pending_want_test/pending_want_test.cpp @@ -20,6 +20,7 @@ #include "completed_dispatcher.h" #include "context/context.h" #include "context_container.h" +#include "context_impl.h" #include "element_name.h" #include "event_handler.h" #include "iservice_registry.h" @@ -102,7 +103,8 @@ Want PendingWantTest::MakeWant(std::string deviceId, std::string abilityName, st std::shared_ptr GetAppContext() { - return OHOS::AbilityRuntime::Context::GetApplicationContext(); + std::shared_ptr context = std::make_shared(); + return context; } void PendingWantTest::SetUpTestCase(void) @@ -170,26 +172,10 @@ HWTEST_F(PendingWantTest, PendingWant_0400, Function | MediumTest | Level1) want->SetElement(element); unsigned int flags = 1; flags |= FLAG_NO_CREATE; - std::shared_ptr pendingWant = PendingWant::GetAbility(GetAppContext(), requestCode, want, flags); + std::shared_ptr pendingWant = PendingWant::GetAbility(nullptr, requestCode, want, flags); EXPECT_EQ(pendingWant, nullptr); } -/* - * @tc.number : PendingWant_0500 - * @tc.name : PendingWant GetAbility - * @tc.desc : 1.Get pendingWant (START_ABILITY) - */ -HWTEST_F(PendingWantTest, PendingWant_0500, Function | MediumTest | Level1) -{ - int requestCode = 10; - std::shared_ptr want = std::make_shared(); - ElementName element("device", "bundleName", "abilityName"); - want->SetElement(element); - unsigned int flags = 1; - flags |= FLAG_NO_CREATE; - std::shared_ptr pendingWant = PendingWant::GetAbility(GetAppContext(), requestCode, want, flags); - EXPECT_NE(pendingWant, nullptr); -} /* * @tc.number : PendingWant_0600 diff --git a/frameworks/wantagent/test/unittest/want_agent_helper_test/BUILD.gn b/frameworks/wantagent/test/unittest/want_agent_helper_test/BUILD.gn index 12ec08065e3c538ddbcb370835c2161363c75910..926b3dcf1baaa87f75af1fea2fe2730a47543cac 100644 --- a/frameworks/wantagent/test/unittest/want_agent_helper_test/BUILD.gn +++ b/frameworks/wantagent/test/unittest/want_agent_helper_test/BUILD.gn @@ -20,6 +20,7 @@ module_output_path = "ans_standard/wantagent" ohos_unittest("want_agent_helper_test") { module_out_path = module_output_path include_dirs = [ + "//aafwk/standard/frameworks/kits/appkit/native/ability_runtime/context/", "//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime", "//foundation/aafwk/standard/services/abilitymgr/include", ] diff --git a/frameworks/wantagent/test/unittest/want_agent_helper_test/want_agent_helper_test.cpp b/frameworks/wantagent/test/unittest/want_agent_helper_test/want_agent_helper_test.cpp index f555062ad2331e5fbdb0fca08149d222827aa6ca..622c8c8b48270d52b7c03085ed1f352015fe02a6 100644 --- a/frameworks/wantagent/test/unittest/want_agent_helper_test/want_agent_helper_test.cpp +++ b/frameworks/wantagent/test/unittest/want_agent_helper_test/want_agent_helper_test.cpp @@ -17,6 +17,7 @@ #include "ability_context.h" #include "completed_callback.h" #include "context_container.h" +#include "context_impl.h" #include "context/context.h" #include "element_name.h" #include "event_handler.h" @@ -249,7 +250,7 @@ HWTEST_F(WantAgentHelperTest, WantAgentHelper_1100, Function | MediumTest | Leve HWTEST_F(WantAgentHelperTest, WantAgentHelper_1200, Function | MediumTest | Level1) { std::shared_ptr wantAgentHelper = std::make_shared(); - std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); + std::shared_ptr context = std::make_shared(); std::shared_ptr want = std::make_shared(); ElementName element("device", "bundleName", "abilityName"); want->SetElement(element); @@ -273,7 +274,7 @@ HWTEST_F(WantAgentHelperTest, WantAgentHelper_1200, Function | MediumTest | Leve HWTEST_F(WantAgentHelperTest, WantAgentHelper_1300, Function | MediumTest | Level1) { std::shared_ptr wantAgentHelper = std::make_shared(); - std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); + std::shared_ptr context = std::make_shared(); std::shared_ptr want = std::make_shared(); ElementName element("device", "bundleName", "abilityName"); want->SetElement(element); @@ -297,7 +298,7 @@ HWTEST_F(WantAgentHelperTest, WantAgentHelper_1300, Function | MediumTest | Leve HWTEST_F(WantAgentHelperTest, WantAgentHelper_1400, Function | MediumTest | Level1) { std::shared_ptr wantAgentHelper = std::make_shared(); - std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); + std::shared_ptr context = std::make_shared(); std::shared_ptr want = std::make_shared(); ElementName element("device", "bundleName", "abilityName"); want->SetElement(element); @@ -321,7 +322,7 @@ HWTEST_F(WantAgentHelperTest, WantAgentHelper_1400, Function | MediumTest | Leve HWTEST_F(WantAgentHelperTest, WantAgentHelper_1500, Function | MediumTest | Level1) { std::shared_ptr wantAgentHelper = std::make_shared(); - std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); + std::shared_ptr context = std::make_shared(); std::shared_ptr want = std::make_shared(); ElementName element("device", "bundleName", "abilityName"); want->SetElement(element); @@ -345,7 +346,7 @@ HWTEST_F(WantAgentHelperTest, WantAgentHelper_1500, Function | MediumTest | Leve HWTEST_F(WantAgentHelperTest, WantAgentHelper_1600, Function | MediumTest | Level1) { std::shared_ptr wantAgentHelper = std::make_shared(); - std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); + std::shared_ptr context = std::make_shared(); std::shared_ptr want = std::make_shared(); ElementName element("device", "bundleName", "abilityName"); want->SetElement(element); diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index ec56db5b775408e4b0ccf63be0b6e74fe203a41f..d6dfc6c6cd2b57071a65e15b8e26a9fcb2e5352c 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1295,16 +1295,11 @@ ErrCode AdvancedNotificationService::GetAllActiveNotifications(std::vectorPostSyncTask(std::bind([&]() { notifications.clear(); for (auto record : notificationList_) { - if (record->notification != nullptr && record->notification->GetUserId() == userId) { + if (record->notification != nullptr) { notifications.push_back(record->notification); } } diff --git a/services/ans/test/unittest/notification_preferences_test.cpp b/services/ans/test/unittest/notification_preferences_test.cpp index fa283597a239345c1958a3fe7dcfee947ba9ad70..df7a67ff103817ec129c5211759121d4dca50a52 100644 --- a/services/ans/test/unittest/notification_preferences_test.cpp +++ b/services/ans/test/unittest/notification_preferences_test.cpp @@ -1089,7 +1089,8 @@ HWTEST_F(NotificationPreferencesTest, GetNotificationsEnabled_00200, Function | EXPECT_TRUE(enable); enable = false; - EXPECT_EQ((int)NotificationPreferences::GetInstance().GetNotificationsEnabled(101, enable), (int)ERR_OK); + EXPECT_EQ( + (int)NotificationPreferences::GetInstance().GetNotificationsEnabled(101, enable), (int)ERR_ANS_INVALID_PARAM); EXPECT_FALSE(enable); }