diff --git a/interfaces/innerkits/ability_manager/BUILD.gn b/interfaces/innerkits/ability_manager/BUILD.gn index 1295ec5cdb758a2410c0fc6a7eddfd742fb5edc0..17865d3150ec9e87e8cb85c14d4364cd084109e2 100644 --- a/interfaces/innerkits/ability_manager/BUILD.gn +++ b/interfaces/innerkits/ability_manager/BUILD.gn @@ -75,6 +75,7 @@ ohos_shared_library("ability_manager") { "${services_path}/abilitymgr/src/stop_user_callback_proxy.cpp", "${services_path}/abilitymgr/src/stop_user_callback_stub.cpp", "${services_path}/abilitymgr/src/want_sender_info.cpp", + "${services_path}/abilitymgr/src/want_sender_stub.cpp", "${services_path}/abilitymgr/src/wants_info.cpp", "//foundation/aafwk/standard/frameworks/kits/ability/native/src/data_ability_operation.cpp", "//foundation/aafwk/standard/frameworks/kits/ability/native/src/data_ability_operation_builder.cpp", diff --git a/services/test/moduletest/panding_want_manager_test/BUILD.gn b/services/test/moduletest/panding_want_manager_test/BUILD.gn index 3c5a4f76b1eb954bcd10100ec5dd2b42b702fbaa..b984e47b347fb15c011e214df880a5d6c3b0bc32 100755 --- a/services/test/moduletest/panding_want_manager_test/BUILD.gn +++ b/services/test/moduletest/panding_want_manager_test/BUILD.gn @@ -21,6 +21,7 @@ ohos_moduletest("PandingWantMgrTest") { module_out_path = module_output_path include_dirs = [ + "//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime", "//foundation/aafwk/standard/services/test/mock/include", "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/appmg", "//foundation/aafwk/standard/frameworks/kits/appkit/native/app/include", @@ -53,6 +54,7 @@ ohos_moduletest("PandingWantMgrTest") { "//base/notification/ans_standard/frameworks/wantagent:wantagent_innerkits", "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", "//foundation/aafwk/standard/frameworks/kits/ability/native:dummy_classes", + "//foundation/aafwk/standard/frameworks/kits/appkit:app_context", "//foundation/aafwk/standard/interfaces/innerkits/app_manager:app_manager", "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base", "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core:appexecfwk_core", diff --git a/services/test/moduletest/panding_want_manager_test/panding_want_manager_test.cpp b/services/test/moduletest/panding_want_manager_test/panding_want_manager_test.cpp index b4732de8c8850fae73e3f6a6e938280e71ae4391..fc671e41fbe81eaa500bd668dc804146dce42a2a 100644 --- a/services/test/moduletest/panding_want_manager_test/panding_want_manager_test.cpp +++ b/services/test/moduletest/panding_want_manager_test/panding_want_manager_test.cpp @@ -26,6 +26,7 @@ #undef private #undef protected +#include "context/context.h" #include "system_ability_definition.h" #include "mock_ability_scheduler.h" #include "mock_app_mgr_client.h" @@ -268,7 +269,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_001, TestSize.Level1) wants.push_back(abilityWant); WantAgentInfo info = MakeWantAgentInfo(type, requsetCode, flags, wants); - std::shared_ptr context = std::make_shared(); + std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); // proxy start auto amsProxyGetWantSenderReturn = [&](const WantSenderInfo &wantSenderInfo, @@ -301,7 +302,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_001, TestSize.Level1) TriggerInfo paramsInfo("", nullptr, abilityWant, 11); EXPECT_CALL(*call, OnSendFinished(_, _, _, _)).Times(1); - WantAgentHelper::TriggerWantAgent(context, wantAgent, callback, paramsInfo); + WantAgentHelper::TriggerWantAgent(wantAgent, callback, paramsInfo); // An ability should be activated auto stackMgr = ams->GetStackManager(); @@ -340,7 +341,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_002, TestSize.Level1) wants.push_back(abilityWant1); WantAgentInfo info = MakeWantAgentInfo(type, requsetCode, flags, wants); - std::shared_ptr context = std::make_shared(); + std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); // proxy start auto amsProxyGetWantSenderReturn = [&](const WantSenderInfo &wantSenderInfo, @@ -377,7 +378,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_002, TestSize.Level1) EXPECT_NE(topAbility, nullptr); topAbility->SetAbilityState(OHOS::AAFwk::AbilityState::ACTIVE); - WantAgentHelper::TriggerWantAgent(context, wantAgent, callback, paramsInfo); + WantAgentHelper::TriggerWantAgent(wantAgent, callback, paramsInfo); } /* @@ -401,7 +402,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_003, TestSize.Level1) wants.push_back(abilityWant); WantAgentInfo info = MakeWantAgentInfo(type, requsetCode, flags, wants); - std::shared_ptr context = std::make_shared(); + std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); // proxy start auto amsProxyGetWantSenderReturn = [&](const WantSenderInfo &wantSenderInfo, @@ -434,7 +435,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_003, TestSize.Level1) TriggerInfo paramsInfo("", nullptr, abilityWant, 11); EXPECT_CALL(*call, OnSendFinished(_, _, _, _)).Times(1); - WantAgentHelper::TriggerWantAgent(context, wantAgent, callback, paramsInfo); + WantAgentHelper::TriggerWantAgent(wantAgent, callback, paramsInfo); // An ability should be activated auto serviceRecord = ams->connectManager_->GetServiceRecordByElementName(abilityWant->GetElement().GetURI()); @@ -467,7 +468,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_004, TestSize.Level1) wants.push_back(abilityWant); WantAgentInfo info = MakeWantAgentInfo(type, requsetCode, flags, wants); - std::shared_ptr context = std::make_shared(); + std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); // proxy start auto amsProxyGetWantSenderReturn = [&](const WantSenderInfo &wantSenderInfo, @@ -500,7 +501,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_004, TestSize.Level1) TriggerInfo paramsInfo("", nullptr, abilityWant, 11); EXPECT_CALL(*call, OnSendFinished(_, _, _, _)).Times(1); - WantAgentHelper::TriggerWantAgent(context, wantAgent, callback, paramsInfo); + WantAgentHelper::TriggerWantAgent(wantAgent, callback, paramsInfo); // An ability should be activated auto serviceRecord = ams->connectManager_->GetServiceRecordByElementName(abilityWant->GetElement().GetURI()); @@ -532,7 +533,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_005, TestSize.Level1) wants.push_back(abilityWant); WantAgentInfo info = MakeWantAgentInfo(type, requsetCode, flags, wants); - std::shared_ptr context = std::make_shared(); + std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); // proxy start auto amsProxyGetWantSenderReturn = [&](const WantSenderInfo &wantSenderInfo, @@ -562,7 +563,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_005, TestSize.Level1) TriggerInfo paramsInfo("", nullptr, abilityWant, 11); EXPECT_CALL(*call, OnSendFinished(_, _, _, _)).Times(1); - WantAgentHelper::TriggerWantAgent(context, wantAgent, callback, paramsInfo); + WantAgentHelper::TriggerWantAgent(wantAgent, callback, paramsInfo); } /* @@ -586,7 +587,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_006, TestSize.Level1) wants.push_back(abilityWant); WantAgentInfo info = MakeWantAgentInfo(type, requsetCode, flags, wants); - std::shared_ptr context = std::make_shared(); + std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); // proxy start auto amsProxyGetWantSenderReturn = [&](const WantSenderInfo &wantSenderInfo, @@ -653,7 +654,7 @@ HWTEST_F(PandingWantManagerTest, pending_want_mgr_test_007, TestSize.Level1) wants.push_back(abilityWant); WantAgentInfo info = MakeWantAgentInfo(type, requsetCode, flags, wants); - std::shared_ptr context = std::make_shared(); + std::shared_ptr context = OHOS::AbilityRuntime::Context::GetApplicationContext(); // proxy start auto amsProxyGetWantSenderReturn = [&](const WantSenderInfo &wantSenderInfo,