From fcac1bcdf84493082aad45e34badb609ebad5530 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 8 Sep 2025 20:23:53 +0800 Subject: [PATCH] remove unuse code Signed-off-by: unknown --- frameworks/native/ability/native/BUILD.gn | 1 - .../ability/native/ability_impl_factory.cpp | 7 +- .../native/ability_runtime/js_ui_ability.cpp | 2 - .../ability/native/new_ability_impl.cpp | 158 ------------ .../kits/native/ability/native/ability.h | 2 - .../native/ability/native/new_ability_impl.h | 75 ------ .../BUILD.gn | 47 ---- .../new_ability_impl_test.cpp | 235 ------------------ 8 files changed, 1 insertion(+), 526 deletions(-) delete mode 100644 frameworks/native/ability/native/new_ability_impl.cpp delete mode 100644 interfaces/kits/native/ability/native/new_ability_impl.h delete mode 100644 test/unittest/frameworks_kits_ability_native_test/new_ability_impl_test.cpp diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index eb610ed2216..07b861117bc 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -319,7 +319,6 @@ ohos_shared_library("abilitykit_native") { "${ability_runtime_native_path}/ability/native/js_free_install_observer.cpp", "${ability_runtime_native_path}/ability/native/js_query_erms_observer.cpp", "${ability_runtime_native_path}/ability/native/js_start_abilities_observer.cpp", - "${ability_runtime_native_path}/ability/native/new_ability_impl.cpp", "${ability_runtime_native_path}/ability/native/query_erms_observer_proxy.cpp", "${ability_runtime_native_path}/ability/native/query_erms_observer_stub.cpp", "${ability_runtime_native_path}/ability/native/service_ability_impl.cpp", diff --git a/frameworks/native/ability/native/ability_impl_factory.cpp b/frameworks/native/ability/native/ability_impl_factory.cpp index 2c5e1f651a2..5eb790cddda 100644 --- a/frameworks/native/ability/native/ability_impl_factory.cpp +++ b/frameworks/native/ability/native/ability_impl_factory.cpp @@ -16,7 +16,6 @@ #include "ability_impl_factory.h" #include "data_ability_impl.h" #include "hilog_tag_wrapper.h" -#include "new_ability_impl.h" #ifdef SUPPORT_GRAPHICS #include "page_ability_impl.h" #endif @@ -42,11 +41,7 @@ std::shared_ptr AbilityImplFactory::MakeAbilityImplObject(const std switch (info->type) { #ifdef SUPPORT_GRAPHICS case AppExecFwk::AbilityType::PAGE: - if (info->isStageBasedModel) { - abilityImpl = std::make_shared(); - } else { - abilityImpl = std::make_shared(); - } + abilityImpl = std::make_shared(); break; #endif case AppExecFwk::AbilityType::SERVICE: diff --git a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp index 5837fcd5884..edbde5e33a5 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp @@ -347,7 +347,6 @@ void JsUIAbility::CreateAndBindContext(const std::shared_ptr abilityInfo, std::shared_ptr want, const std::string &moduleName, const std::string &srcPath) { - TAG_LOGI(AAFwkTag::UIABILITY, "called"); HandleScope handleScope(jsRuntime_); auto env = jsRuntime_.GetNapiEnv(); UpdateAbilityObj(abilityInfo, moduleName, srcPath); @@ -392,7 +391,6 @@ void JsUIAbility::SetAbilityContext(std::shared_ptr abilityInfo, delete workContext; return; } - TAG_LOGI(AAFwkTag::UIABILITY, "End"); } void JsUIAbility::CreateJSContext(napi_env env, napi_value &contextObj, int32_t screenMode) diff --git a/frameworks/native/ability/native/new_ability_impl.cpp b/frameworks/native/ability/native/new_ability_impl.cpp deleted file mode 100644 index ed3cc993d68..00000000000 --- a/frameworks/native/ability/native/new_ability_impl.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "new_ability_impl.h" - -#include "freeze_util.h" -#include "hilog_tag_wrapper.h" -#include "hitrace_meter.h" -#ifdef SUPPORT_SCREEN -#include "scene_board_judgement.h" -#endif // SUPPORT_SCREEN -namespace OHOS { -using AbilityRuntime::FreezeUtil; -namespace AppExecFwk { -using AbilityManagerClient = OHOS::AAFwk::AbilityManagerClient; - -void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState, - sptr sessionInfo) -{ - HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGI(AAFwkTag::ABILITY, - "srcState:%{public}d; targetState: %{public}d; isNewWant: %{public}d, sceneFlag: %{public}d", - lifecycleState_, targetState.state, targetState.isNewWant, targetState.sceneFlag); -#ifdef SUPPORT_SCREEN - if (ability_ != nullptr) { - ability_->sceneFlag_ = targetState.sceneFlag; - } - if ((lifecycleState_ == targetState.state) && !targetState.isNewWant) { - if (ability_ != nullptr && targetState.state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) { - ability_->RequestFocus(want); - AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, targetState.state, GetRestoreData()); - } - TAG_LOGE(AAFwkTag::ABILITY, "lifeCycleStat:org=Dst"); - return; - } -#endif - SetLifeCycleStateInfo(targetState); - if (ability_ != nullptr) { - ability_->SetLaunchParam(targetState.launchParam); - if (lifecycleState_ == AAFwk::ABILITY_STATE_INITIAL) { - ability_->SetStartAbilitySetting(targetState.setting); - Start(want, sessionInfo); - CheckAndRestore(); - } - } - - bool ret = false; - ret = AbilityTransaction(want, targetState); - if (ret) { - AbilityTransactionCallback(targetState.state); - } -} - -void NewAbilityImpl::HandleShareData(const int32_t &uniqueId) -{ - WantParams wantParam; - int32_t resultCode = Share(wantParam); - TAG_LOGI(AAFwkTag::ABILITY, "begin sourceState:%{public}d, wantParam size:%{public}d", - lifecycleState_, wantParam.Size()); - AbilityManagerClient::GetInstance()->ShareDataDone(token_, resultCode, uniqueId, wantParam); -} - -void NewAbilityImpl::AbilityTransactionCallback(const AbilityLifeCycleState &state) -{ - TAG_LOGI(AAFwkTag::ABILITY, "notify ams"); - auto ret = AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, state, GetRestoreData()); - if (ret == ERR_OK && state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) { - FreezeUtil::GetInstance().DeleteLifecycleEvent(token_); - FreezeUtil::GetInstance().DeleteAppLifecycleEvent(0); - } -} - -bool NewAbilityImpl::AbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState) -{ - HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - bool ret = true; - switch (targetState.state) { - case AAFwk::ABILITY_STATE_INITIAL: { -#ifdef SUPPORT_SCREEN - if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled() && - lifecycleState_ == AAFwk::ABILITY_STATE_FOREGROUND_NEW) { - Background(); - } - -#endif - bool isAsyncCallback = false; - Stop(isAsyncCallback); - if (isAsyncCallback) { - // AMS will be notified after async callback - ret = false; - } - break; - } - case AAFwk::ABILITY_STATE_FOREGROUND_NEW: { - ret = AbilityTransactionForeground(want, targetState); - break; - } - case AAFwk::ABILITY_STATE_BACKGROUND_NEW: { - if (lifecycleState_ != ABILITY_STATE_STARTED_NEW) { - ret = false; - } -#ifdef SUPPORT_SCREEN - Background(); -#endif - break; - } - default: { - ret = false; - TAG_LOGE(AAFwkTag::ABILITY, "error"); - break; - } - } - TAG_LOGD(AAFwkTag::ABILITY, "end: ret = %{public}d", static_cast(ret)); - return ret; -} - -bool NewAbilityImpl::AbilityTransactionForeground(const Want &want, const AAFwk::LifeCycleStateInfo &targetState) -{ - bool ret = true; - if (targetState.isNewWant) { - NewWant(want); - } -#ifdef SUPPORT_SCREEN - if (lifecycleState_ == AAFwk::ABILITY_STATE_FOREGROUND_NEW) { - if (ability_) { - ability_->RequestFocus(want); - } - } else { - { - std::lock_guard lock(notifyForegroundLock_); - notifyForegroundByWindow_ = false; - } - Foreground(want); - std::lock_guard lock(notifyForegroundLock_); - ret = notifyForegroundByWindow_; - if (ret) { - notifyForegroundByWindow_ = false; - notifyForegroundByAbility_ = false; - } - } -#endif - - return ret; -} -} // namespace AppExecFwk -} // namespace OHOS diff --git a/interfaces/kits/native/ability/native/ability.h b/interfaces/kits/native/ability/native/ability.h index 379e463d888..63965475235 100644 --- a/interfaces/kits/native/ability/native/ability.h +++ b/interfaces/kits/native/ability/native/ability.h @@ -93,8 +93,6 @@ class Ability : public IAbilityEvent, public IAbilityCallback, public std::enable_shared_from_this { public: - friend class NewAbilityImpl; - static Ability* Create(const std::unique_ptr& runtime); Ability() = default; diff --git a/interfaces/kits/native/ability/native/new_ability_impl.h b/interfaces/kits/native/ability/native/new_ability_impl.h deleted file mode 100644 index 50013b54dc3..00000000000 --- a/interfaces/kits/native/ability/native/new_ability_impl.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_ABILITY_RUNTIME_NEW_ABILITY_IMPL_H -#define OHOS_ABILITY_RUNTIME_NEW_ABILITY_IMPL_H - -#include "ability_impl.h" - -namespace OHOS { -namespace AppExecFwk { -class NewAbilityImpl final : public AbilityImpl { -public: - /** - * @brief Constructor. - * - */ - NewAbilityImpl() = default; - - /** - * @brief Destructor. - * - */ - ~NewAbilityImpl() = default; - - /** - * @brief Handling the life cycle switching of NewAbility. - * - * @param want Indicates the structure containing information about the ability. - * @param targetState The life cycle state to switch to. - * @param sessionInfo Indicates the sessionInfo. - * - */ - void HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState, - sptr sessionInfo = nullptr) override; - - /** - * @brief The life cycle callback of NewAbility. - * @param state The life cycle state to switch to. - */ - void AbilityTransactionCallback(const AbilityLifeCycleState &state) override; - - /** - * @brief Handling the life cycle switching of NewAbility in switch. - * - * @param want Indicates the structure containing information about the ability. - * @param targetState The life cycle state to switch to. - * - * @return return true if the lifecycle transaction successfully, otherwise return false. - * - */ - bool AbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState); - - bool AbilityTransactionForeground(const Want &want, const AAFwk::LifeCycleStateInfo &targetState); - - /** - * @description: Provide operating system ShareData information to the observer - * @param requestCode Indicates the requestCode - */ - void HandleShareData(const int32_t &requestCode) override; -}; -} // namespace AppExecFwk -} // namespace OHOS -#endif // OHOS_ABILITY_RUNTIME_NEW_ABILITY_IMPL_H diff --git a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn index 4d8fb03781c..7b965dc47b4 100644 --- a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn @@ -2135,51 +2135,6 @@ ohos_unittest("ability_transaction_callback_info_test") { } } -ohos_unittest("new_ability_impl_test") { - module_out_path = module_output_path - if (ability_runtime_graphics) { - sources = [ - "${ability_runtime_native_path}/ability/native/new_ability_impl.cpp", - "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include/mock_replace_ability_impl.cpp", - "new_ability_impl_test.cpp", - ] - - configs = [ ":module_private_config" ] - - deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", - "${ability_runtime_innerkits_path}/runtime:runtime", - "${ability_runtime_native_path}/ability/native:abilitykit_native", - "${ability_runtime_native_path}/ability/native:abilitykit_utils", - "${ability_runtime_native_path}/appkit:app_context", - "${ability_runtime_native_path}/appkit:appkit_native", - "${ability_runtime_path}/utils/global/freeze:freeze_util", - ] - - external_deps = [ - "ability_base:extractortool", - "ability_base:want", - "bundle_framework:appexecfwk_base", - "c_utils:utils", - "common_event_service:cesfwk_innerkits", - "eventhandler:libeventhandler", - "form_fwk:fmskit_native", - "googletest:gtest_main", - "hilog:libhilog", - "hitrace:hitrace_meter", - "i18n:intl_util", - "init:libbegetutil", - "input:libmmi-client", - "ipc:ipc_core", - "napi:ace_napi", - "resource_management:global_resmgr", - "samgr:samgr_proxy", - "window_manager:libwsutils", - "window_manager:sms", - ] - } -} - ohos_unittest("reserse_continuation_scheduler_primary_stub_test") { module_out_path = module_output_path if (ability_runtime_graphics) { @@ -2223,7 +2178,6 @@ ohos_unittest("reserse_continuation_scheduler_primary_proxy_test") { sources = [ "${ability_runtime_native_path}/ability/native/continuation/distributed/reverse_continuation_scheduler_primary_proxy.cpp", "${ability_runtime_native_path}/ability/native/continuation/distributed/reverse_continuation_scheduler_primary_stub.cpp", - "${ability_runtime_native_path}/ability/native/new_ability_impl.cpp", "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include/mock_replace_ability_impl.cpp", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit/src/mock_ability_connect_callback.cpp", "reserse_continuation_scheduler_primary_proxy_test.cpp", @@ -3473,7 +3427,6 @@ group("unittest") { ":fa_ability_thread_test", ":form_extension_test", ":js_ui_extension_Callback_test", - ":new_ability_impl_test", ":reserse_continuation_scheduler_primary_proxy_test", ":reserse_continuation_scheduler_primary_stub_test", ":reverse_continuation_scheduler_replica_proxy_test", diff --git a/test/unittest/frameworks_kits_ability_native_test/new_ability_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/new_ability_impl_test.cpp deleted file mode 100644 index 97e5ac539ee..00000000000 --- a/test/unittest/frameworks_kits_ability_native_test/new_ability_impl_test.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "mock_ability_token.h" -#include "mock_new_ability.h" -#define private public -#define protected public -#include "new_ability_impl.h" -#include "ohos_application.h" -#undef protected -#undef private - -namespace OHOS { -namespace AppExecFwk { -using namespace testing::ext; -using namespace OHOS; -using namespace OHOS::AppExecFwk; -using namespace OHOS::AAFwk; - -class NewAbilityImplTest : public testing::Test { -public: - NewAbilityImplTest() : newAbilityImpl_(nullptr) - {} - ~NewAbilityImplTest() - { - newAbilityImpl_ = nullptr; - } - std::shared_ptr newAbilityImpl_; - - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; - -void NewAbilityImplTest::SetUpTestCase(void) -{} - -void NewAbilityImplTest::TearDownTestCase(void) -{} - -void NewAbilityImplTest::SetUp(void) -{ - newAbilityImpl_ = std::make_shared(); -} - -void NewAbilityImplTest::TearDown(void) -{} - -/** - * @tc.number: AaFwk_NewAbilityImpl_HandleAbilityTransaction_0100 - * @tc.name: HandleAbilityTransaction - * @tc.desc: Handle transactions in the Initial state - */ - /** - * @tc.name: AaFwk_NewAbilityImpl_HandleAbilityTransaction_0100 - * @tc.desc: Handle transactions in the foreground state and isNewWant is true. - * @tc.type: FUNC - * @tc.require: I58047 - */ -HWTEST_F(NewAbilityImplTest, AaFwk_NewAbilityImpl_HandleAbilityTransaction_0100, Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_HandleAbilityTransaction_0100 start"; - - std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityInfo = std::make_shared(); - abilityInfo->name = "newAbility"; - sptr token = sptr(new (std::nothrow) MockAbilityToken()); - auto record = std::make_shared(abilityInfo, token, nullptr, 0); - - std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); - std::shared_ptr handler = std::make_shared(eventRunner); - - std::shared_ptr ability; - MockNewAbility* newAbility = new (std::nothrow) MockNewAbility(); - EXPECT_NE(newAbility, nullptr); - if (newAbility != nullptr) { - ability.reset(newAbility); - } - - newAbilityImpl_->Init(application, record, ability, handler, token); - - Want want; - AAFwk::LifeCycleStateInfo state; - state.state = ABILITY_STATE_FOREGROUND_NEW; - state.isNewWant = true; - newAbilityImpl_->HandleAbilityTransaction(want, state); - EXPECT_EQ(newAbilityImpl_->GetCurrentState(), ABILITY_STATE_INITIAL); - EXPECT_EQ(newAbility->onNewWantCalled_, true); - EXPECT_EQ(newAbility->continueRestoreCalled_, true); - - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_HandleAbilityTransaction_0100 end"; -} - -/** - * @tc.number: AaFwk_NewAbilityImpl_HandleAbilityTransaction_0200 - * @tc.name: HandleAbilityTransaction - * @tc.desc: Verify that function HandleAbilityTransaction and the GetCurrentState is 3. - */ -HWTEST_F(NewAbilityImplTest, AaFwk_NewAbilityImpl_HandleAbilityTransaction_0200, Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_HandleAbilityTransaction_0200 start"; - Want want; - AAFwk::LifeCycleStateInfo state; - state.state = ABILITY_STATE_BACKGROUND_NEW; - newAbilityImpl_->lifecycleState_ = ABILITY_STATE_BACKGROUND; - newAbilityImpl_->HandleAbilityTransaction(want, state); - EXPECT_EQ(newAbilityImpl_->GetCurrentState(), ABILITY_STATE_BACKGROUND); - EXPECT_TRUE(newAbilityImpl_->ability_ == nullptr); - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_HandleAbilityTransaction_0200 end"; -} - -/** - * @tc.number: AaFwk_NewAbilityImpl_HandleAbilityTransaction_0300 - * @tc.name: HandleAbilityTransaction - * @tc.desc: Verify that function HandleAbilityTransaction and the GetCurrentState is 3. - */ -HWTEST_F(NewAbilityImplTest, AaFwk_NewAbilityImpl_HandleAbilityTransaction_0300, Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_HandleAbilityTransaction_0300 start"; - - std::shared_ptr application = std::make_shared(); - std::shared_ptr abilityInfo = std::make_shared(); - abilityInfo->name = "newAbility"; - sptr token = sptr(new (std::nothrow) MockAbilityToken()); - auto record = std::make_shared(abilityInfo, token, nullptr, 0); - - std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); - std::shared_ptr handler = std::make_shared(eventRunner); - - std::shared_ptr ability; - MockNewAbility* newAbility = new (std::nothrow) MockNewAbility(); - EXPECT_NE(newAbility, nullptr); - if (newAbility != nullptr) { - ability.reset(newAbility); - } - - newAbilityImpl_->Init(application, record, ability, handler, token); - - Want want; - AAFwk::LifeCycleStateInfo state; - state.state = ABILITY_STATE_BACKGROUND_NEW; - state.isNewWant = true; - newAbilityImpl_->lifecycleState_ = ABILITY_STATE_BACKGROUND; - newAbilityImpl_->HandleAbilityTransaction(want, state); - EXPECT_EQ(newAbilityImpl_->GetCurrentState(), ABILITY_STATE_BACKGROUND); - EXPECT_TRUE(newAbilityImpl_->ability_ != nullptr); - - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_HandleAbilityTransaction_0300 end"; -} - -/** - * @tc.number: AaFwk_NewAbilityImpl_AbilityTransaction_0100 - * @tc.name: AbilityTransaction - * @tc.desc: Verify that function AbilityTransaction and the result is true. - */ -HWTEST_F(NewAbilityImplTest, AaFwk_NewAbilityImpl_AbilityTransaction_0100, Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_AbilityTransaction_0100 start"; - Want want; - AAFwk::LifeCycleStateInfo targetState; - targetState.state = ABILITY_STATE_INITIAL; - auto result = newAbilityImpl_->AbilityTransaction(want, targetState); - EXPECT_EQ(newAbilityImpl_->GetCurrentState(), ABILITY_STATE_INITIAL); - EXPECT_TRUE(result); - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_AbilityTransaction_0100 end"; -} - -/** - * @tc.number: AaFwk_NewAbilityImpl_AbilityTransaction_0200 - * @tc.name: AbilityTransaction - * @tc.desc: Verify that function AbilityTransaction and the result is false. - */ -HWTEST_F(NewAbilityImplTest, AaFwk_NewAbilityImpl_AbilityTransaction_0200, Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_AbilityTransaction_0200 start"; - Want want; - AAFwk::LifeCycleStateInfo targetState; - targetState.state = ABILITY_STATE_FOREGROUND_NEW; - auto result = newAbilityImpl_->AbilityTransaction(want, targetState); - EXPECT_EQ(newAbilityImpl_->GetCurrentState(), ABILITY_STATE_INITIAL); - EXPECT_TRUE(!result); - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_AbilityTransaction_0200 end"; -} - -/** - * @tc.number: AaFwk_NewAbilityImpl_AbilityTransaction_0300 - * @tc.name: AbilityTransaction - * @tc.desc: Verify that function AbilityTransaction and the result is true. - */ -HWTEST_F(NewAbilityImplTest, AaFwk_NewAbilityImpl_AbilityTransaction_0300, Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_AbilityTransaction_0300 start"; - Want want; - AAFwk::LifeCycleStateInfo targetState; - targetState.state = ABILITY_STATE_BACKGROUND_NEW; - newAbilityImpl_->lifecycleState_ = ABILITY_STATE_STARTED_NEW; - auto result = newAbilityImpl_->AbilityTransaction(want, targetState); - EXPECT_EQ(newAbilityImpl_->GetCurrentState(), ABILITY_STATE_STARTED_NEW); - EXPECT_TRUE(result); - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_AbilityTransaction_0300 end"; -} - -/** - * @tc.number: AaFwk_NewAbilityImpl_AbilityTransaction_0400 - * @tc.name: AbilityTransaction - * @tc.desc: Verify that function AbilityTransaction and the result is false. - */ -HWTEST_F(NewAbilityImplTest, AaFwk_NewAbilityImpl_AbilityTransaction_0400, Level1) -{ - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_AbilityTransaction_0400 start"; - Want want; - AAFwk::LifeCycleStateInfo targetState; - targetState.state = ABILITY_STATE_INACTIVE; - newAbilityImpl_->lifecycleState_ = ABILITY_STATE_STARTED_NEW; - auto result = newAbilityImpl_->AbilityTransaction(want, targetState); - EXPECT_EQ(newAbilityImpl_->GetCurrentState(), ABILITY_STATE_STARTED_NEW); - EXPECT_FALSE(result); - GTEST_LOG_(INFO) << "AaFwk_NewAbilityImpl_AbilityTransaction_0400 end"; -} -} // namespace AppExecFwk -} // namespace OHOS -- Gitee