From 7cdb31db6f0a9b1f8474178758a65ba3ad967d24 Mon Sep 17 00:00:00 2001 From: xuchenghua09 Date: Fri, 8 Jul 2022 13:09:18 +0800 Subject: [PATCH] mt modify Signed-off-by: xuchenghua09 --- .../include/ability_manager_errors.h | 6 +----- .../mock/src/ui_service_mgr_client_mock.cpp | 7 +++++++ .../start_ability_implicit_module_test.cpp | 14 ++++++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index 278a6b76a8..e5a07a097a 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -250,11 +250,7 @@ enum { */ ERR_AAFWK_PARCEL_FAIL, /** - * Result(2097199) for type is empty. - */ - ERR_WANT_NO_TYPE, - /** - * Result(2097200) for implicit start ability is failed. + * Result(2097199) for for implicit start ability is failed. */ ERR_IMPLICIT_START_ABILITY_FAIL, }; diff --git a/test/moduletest/mock/src/ui_service_mgr_client_mock.cpp b/test/moduletest/mock/src/ui_service_mgr_client_mock.cpp index 884346ec4a..9745d0ceb8 100644 --- a/test/moduletest/mock/src/ui_service_mgr_client_mock.cpp +++ b/test/moduletest/mock/src/ui_service_mgr_client_mock.cpp @@ -36,6 +36,7 @@ namespace { const std::string EVENT_CLOSE_CODE = "EVENT_CLOSE"; const std::string EVENT_MULT_APP_CHOOSE = "EVENT_MULT_APP_CHOOSE"; const std::string EVENT_MULT_APP_CLOSE = "EVENT_MULT_APP_CLOSE"; + const std::string EVENT_TIPS_APP = "EVENT_TIPS_APP"; } std::shared_ptr UIServiceMgrClient::GetInstance() @@ -103,6 +104,12 @@ ErrCode UIServiceMgrClient::ShowDialog(const std::string& name, const std::strin return ERR_OK; } + if (code_ == EVENT_TIPS_APP) { + params_ = params; + callback(0, EVENT_CLOSE_CODE, ""); + return ERR_OK; + } + return 0; } diff --git a/test/moduletest/start_ability_implicit_module_test/start_ability_implicit_module_test.cpp b/test/moduletest/start_ability_implicit_module_test/start_ability_implicit_module_test.cpp index 01460b1aab..9bba265d96 100644 --- a/test/moduletest/start_ability_implicit_module_test/start_ability_implicit_module_test.cpp +++ b/test/moduletest/start_ability_implicit_module_test/start_ability_implicit_module_test.cpp @@ -36,6 +36,7 @@ using namespace OHOS::AppExecFwk; namespace { const std::string EVENT_MULT_APP_CHOOSE = "EVENT_MULT_APP_CHOOSE"; const std::string EVENT_MULT_APP_CLOSE = "EVENT_MULT_APP_CLOSE"; + const std::string EVENT_TIPS_APP = "EVENT_TIPS_APP"; const std::string ACTION_VIEW = "ohos.want.action.viewData"; const std::string WANT_TYPE = "image/png"; const int32_t MOCK_MAIN_USER_ID = 100; @@ -107,6 +108,11 @@ void StartAbilityImplicitModuleTest::OnStartAms() abilityMs_->iBundleManager_ = new BundleMgrService(); EXPECT_TRUE(abilityMs_->iBundleManager_); + abilityMs_->implicitStartProcessor_ = std::make_shared(); + EXPECT_TRUE(abilityMs_->implicitStartProcessor_); + abilityMs_->implicitStartProcessor_->iBundleManager_ = new BundleMgrService(); + EXPECT_TRUE(abilityMs_->implicitStartProcessor_->iBundleManager_); + DelayedSingleton::GetInstance()->SetDeviceType("phone"); abilityMs_->InitMissionListManager(userId, true); abilityMs_->SwitchManagers(0, false); @@ -250,13 +256,13 @@ HWTEST_F(StartAbilityImplicitModuleTest, StartAbility_004, TestSize.Level1) want.SetType(WANT_TYPE); want.SetParam("numMock", 0); - Ace::UIServiceMgrClient::GetInstance()->SetDialogCheckState(EVENT_MULT_APP_CHOOSE); + Ace::UIServiceMgrClient::GetInstance()->SetDialogCheckState(EVENT_TIPS_APP); abilityMs_->StartAbility(want, MOCK_MAIN_USER_ID); auto params = Ace::UIServiceMgrClient::GetInstance()->GetParams(); auto isCallBack = Ace::UIServiceMgrClient::GetInstance()->IsCallBack(); - EXPECT_TRUE(params.empty()); - EXPECT_TRUE(!isCallBack); + EXPECT_TRUE(!params.empty()); + EXPECT_TRUE(isCallBack); auto abilityRecord = abilityMs_->currentMissionListManager_->GetCurrentTopAbilityLocked(); EXPECT_TRUE(abilityRecord == nullptr); @@ -281,7 +287,7 @@ HWTEST_F(StartAbilityImplicitModuleTest, StartAbility_005, TestSize.Level1) Ace::UIServiceMgrClient::GetInstance()->SetDialogCheckState(EVENT_MULT_APP_CHOOSE); auto ret = abilityMs_->StartAbility(want, MOCK_MAIN_USER_ID); - EXPECT_EQ(ret, ERR_WANT_NO_TYPE); + EXPECT_EQ(ret, ERR_OK); } } } \ No newline at end of file