From e44a7b25fee3959f897fdcd8013cd209f80a0e0b Mon Sep 17 00:00:00 2001 From: fangjinliang1 Date: Thu, 20 Jan 2022 15:50:40 +0800 Subject: [PATCH] global ability Signed-off-by: fangjinliang1 Change-Id: Ifca6bb1dde85d4a8d6be105ebd98dfa7f5d3635d Signed-off-by: fangjinliang1 --- interfaces/innerkits/ability_manager/BUILD.gn | 1 + .../panding_want_manager_test/BUILD.gn | 2 ++ .../panding_want_manager_test.cpp | 25 ++++++++++--------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/interfaces/innerkits/ability_manager/BUILD.gn b/interfaces/innerkits/ability_manager/BUILD.gn index 1295ec5cdb7..17865d3150e 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 3c5a4f76b1e..b984e47b347 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 b4732de8c88..fc671e41fbe 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, -- Gitee