diff --git a/test/mock/mock_sa_call/mock_sa_call.h b/test/mock/mock_sa_call/mock_sa_call.h new file mode 100644 index 0000000000..572f0dc029 --- /dev/null +++ b/test/mock/mock_sa_call/mock_sa_call.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2023 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 UNITTEST_OHOS_ABILITY_RUNTIME_IS_SA_CALL_TEST_H +#define UNITTEST_OHOS_ABILITY_RUNTIME_IS_SA_CALL_TEST_H + +#include "accesstoken_kit.h" +#include "nativetoken_kit.h" +#include "token_setproc.h" + +namespace OHOS::AAFwk { +class IsMockSaCall { +public: + static void IsMockSaCallWithPermission() + { + uint64_t tokenId; + const char* perms[] = { + perms[0] = "ohos.permission.ACCESS_DLP_FILE", + perms[1] = "ohos.permission.CLEAN_APPLICATION_DATA", + perms[2] = "ohos.permission.CLEAN_BACKGROUND_PROCESSES", + perms[3] = "ohos.permission.GET_RUNNING_INFO", + perms[4] = "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", + perms[5] = "ohos.permission.MANAGE_MISSIONS", + perms[6] = "ohos.permission.RUNNING_STATE_OBSERVER", + perms[7] = "ohos.permission.SET_ABILITY_CONTROLLER", + perms[8] = "ohos.permission.UPDATE_CONFIGURATION", + perms[9] = "ohos.permission.INSTALL_BUNDLE", + perms[10] = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + perms[11] = "ohos.permission.START_INVISIBLE_ABILITY", + perms[12] = "ohos.permission.START_ABILITIES_FROM_BACKGROUND", + perms[13] = "ohos.permission.START_ABILIIES_FROM_BACKGROUND", + perms[14] = "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION", + perms[15] = "ohos.permission.MANAGER_ABILITY_FROM_GATEWAY", + perms[16] = "ohos.permission.PROXY_AUTHORIZATION_URI", + perms[17] = "ohos.permission.EXEMPT_AS_CALLER", + perms[18] = "ohos.permission.EXEMPT_AS_TARGET", + perms[19] = "ohos.permission.PREPARE_APP_TERMINATE", + perms[20] = "ohos.permission.START_ABILITY_WITH_ANIMATION", + perms[21] = "ohos.permission.MANAGE_APP_BOOT_INTERNAL", + perms[22] = "ohos.permission.CONNECT_UI_EXTENSION_ABILITY", + perms[23] = "ohos.permission.START_RECENT_ABILITY" + }; + + NativeTokenInfoParams infoInstance = { + .dcapsNum = 0, + .permsNum = static_cast(sizeof(perms)/sizeof(perms[0])), + .aclsNum = 0, + .dcaps = nullptr, + .perms = perms, + .acls = nullptr, + .aplStr = "system_core", + }; + infoInstance.processName = "distributedsched"; + tokenId = GetAccessTokenId(&infoInstance); + SetSelfTokenID(tokenId); + Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); + } +}; +} // namespace OHOS::AAFwk +#endif // UNITTEST_OHOS_ABILITY_RUNTIME_IS_SA_CALL_TEST_H \ No newline at end of file diff --git a/test/moduletest/app_mgr_client_test/BUILD.gn b/test/moduletest/app_mgr_client_test/BUILD.gn index dc62f69fea..731f0da694 100644 --- a/test/moduletest/app_mgr_client_test/BUILD.gn +++ b/test/moduletest/app_mgr_client_test/BUILD.gn @@ -21,6 +21,7 @@ ohos_moduletest("app_mgr_client_test") { include_dirs = [ "${ability_runtime_test_path}/mock/common/include", + "${ability_runtime_test_path}/mock/mock_sa_call", "${ability_runtime_test_path}/moduletest/mock/include", ] @@ -33,6 +34,7 @@ ohos_moduletest("app_mgr_client_test") { deps = [ "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:perm_verification", "//third_party/googletest:gtest_main", ] @@ -41,6 +43,7 @@ ohos_moduletest("app_mgr_client_test") { "ability_base:want", "ability_runtime:ability_manager", "ability_runtime:app_manager", + "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", "bundle_framework:appexecfwk_base", diff --git a/test/moduletest/app_mgr_client_test/app_mgr_client_test.cpp b/test/moduletest/app_mgr_client_test/app_mgr_client_test.cpp index 7c4c997f70..1b330425c8 100644 --- a/test/moduletest/app_mgr_client_test/app_mgr_client_test.cpp +++ b/test/moduletest/app_mgr_client_test/app_mgr_client_test.cpp @@ -20,6 +20,7 @@ #include "hilog_wrapper.h" #include "mock_configuration_observer.h" #include "mock_native_token.h" +#include "mock_sa_call.h" using namespace testing; using namespace testing::ext; @@ -63,6 +64,7 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_GetProcessRunningInfosByUserId_0100, Tes { HILOG_INFO("AppMgrClient_GetProcessRunningInfosByUserId_0100 start"); + AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); auto appMgrClient = std::make_unique(); EXPECT_NE(appMgrClient, nullptr); diff --git a/test/unittest/ability_manager_service_first_test/BUILD.gn b/test/unittest/ability_manager_service_first_test/BUILD.gn index b775f3686c..663669b3ad 100644 --- a/test/unittest/ability_manager_service_first_test/BUILD.gn +++ b/test/unittest/ability_manager_service_first_test/BUILD.gn @@ -25,6 +25,7 @@ ohos_unittest("ability_manager_service_first_test") { "${ability_runtime_path}/interfaces/inner_api/ability_manager/include", "${ability_runtime_test_path}/mock/ability_manager_collaborator", "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_test_path}/mock/mock_sa_call", "${ability_runtime_test_path}/mock/prepare_terminate_callback", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit/include", "${ability_runtime_test_path}/unittest/app_debug_listener_stub_test", @@ -58,6 +59,9 @@ ohos_unittest("ability_manager_service_first_test") { "ability_base:want", "ability_base:zuri", "ability_runtime:ability_manager", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "c_utils:utils", diff --git a/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp b/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp index 4377d8a39e..7d0cce28be 100644 --- a/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp +++ b/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp @@ -26,7 +26,6 @@ #include "recovery_param.h" #undef private #undef protected - #include "ability_manager_errors.h" #include "connection_observer_errors.h" #include "mock_ability_connect_callback.h" @@ -36,6 +35,7 @@ #include "session/host/include/session.h" #include "mock_ability_manager_collaborator.h" #include "mock_prepare_terminate_callback.h" +#include "mock_sa_call.h" #include "scene_board_judgement.h" using namespace testing; @@ -591,6 +591,7 @@ HWTEST_F(AbilityManagerServiceFirstTest, GetMissionIdByToken_001, TestSize.Level { HILOG_INFO("AbilityManagerServiceFirstTest GetMissionIdByToken_001 start"); auto abilityMs_ = std::make_shared(); + AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); EXPECT_EQ(abilityMs_->GetMissionIdByToken(nullptr), -1); EXPECT_EQ(abilityMs_->GetMissionIdByToken(MockToken(AbilityType::PAGE)), -1); HILOG_INFO("AbilityManagerServiceFirstTest GetMissionIdByToken_001 end"); diff --git a/test/unittest/ams_mgr_kill_process_test/BUILD.gn b/test/unittest/ams_mgr_kill_process_test/BUILD.gn index f423b98978..8119999794 100644 --- a/test/unittest/ams_mgr_kill_process_test/BUILD.gn +++ b/test/unittest/ams_mgr_kill_process_test/BUILD.gn @@ -24,6 +24,7 @@ ohos_unittest("AmsMgrKillProcessTest") { include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", "${ability_runtime_test_path}/mock/common/include", + "${ability_runtime_test_path}/mock/mock_sa_call", "${ability_runtime_test_path}/mock/services_appmgr_test/include", ] @@ -48,6 +49,7 @@ ohos_unittest("AmsMgrKillProcessTest") { "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", @@ -55,6 +57,7 @@ ohos_unittest("AmsMgrKillProcessTest") { external_deps = [ "ability_base:want", + "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", "bundle_framework:appexecfwk_base", diff --git a/test/unittest/ams_mgr_kill_process_test/ams_mgr_kill_process_test.cpp b/test/unittest/ams_mgr_kill_process_test/ams_mgr_kill_process_test.cpp index 542b19674d..f1c3eeb1e4 100644 --- a/test/unittest/ams_mgr_kill_process_test/ams_mgr_kill_process_test.cpp +++ b/test/unittest/ams_mgr_kill_process_test/ams_mgr_kill_process_test.cpp @@ -22,6 +22,7 @@ #include "hilog_wrapper.h" #include "mock_bundle_manager.h" #include "mock_native_token.h" +#include "mock_sa_call.h" #include "system_ability_definition.h" #include "sys_mgr_client.h" @@ -96,6 +97,7 @@ HWTEST_F(AmsMgrKillProcessTest, KillProcess_0100, TestSize.Level0) { HILOG_INFO("AmsMgrKillProcessTest_KillProcess_0100"); + AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); auto appMgrServiceInner = GetAppMgrServiceInner(); EXPECT_NE(appMgrServiceInner, nullptr); @@ -115,6 +117,7 @@ HWTEST_F(AmsMgrKillProcessTest, KillProcess_0200, TestSize.Level0) { HILOG_INFO("AmsMgrKillProcessTest_KillProcess_0200"); + AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); auto proxy = GetAppMgrProxy(); EXPECT_NE(proxy, nullptr); diff --git a/test/unittest/app_mgr_service_dump_test/BUILD.gn b/test/unittest/app_mgr_service_dump_test/BUILD.gn index 66888f6a82..fa6b425d21 100644 --- a/test/unittest/app_mgr_service_dump_test/BUILD.gn +++ b/test/unittest/app_mgr_service_dump_test/BUILD.gn @@ -19,7 +19,10 @@ module_output_path = "ability_runtime/abilitymgr" ohos_unittest("app_mgr_service_dump_test") { module_out_path = module_output_path - include_dirs = [ "${ability_runtime_test_path}/mock/common/include" ] + include_dirs = [ + "${ability_runtime_test_path}/mock/common/include", + "${ability_runtime_test_path}/mock/mock_sa_call", + ] sources = [ "${ability_runtime_test_path}/mock/common/src/mock_native_token.cpp", @@ -30,6 +33,7 @@ ohos_unittest("app_mgr_service_dump_test") { deps = [ "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "//third_party/googletest:gtest_main", ] @@ -37,6 +41,7 @@ ohos_unittest("app_mgr_service_dump_test") { external_deps = [ "ability_base:want", "ability_runtime:app_manager", + "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", "bundle_framework:appexecfwk_base", diff --git a/test/unittest/app_mgr_service_dump_test/app_mgr_service_dump_test.cpp b/test/unittest/app_mgr_service_dump_test/app_mgr_service_dump_test.cpp index b6a950d945..211558a673 100644 --- a/test/unittest/app_mgr_service_dump_test/app_mgr_service_dump_test.cpp +++ b/test/unittest/app_mgr_service_dump_test/app_mgr_service_dump_test.cpp @@ -20,6 +20,7 @@ #undef private #include "hilog_wrapper.h" #include "mock_native_token.h" +#include "mock_sa_call.h" using namespace testing; using namespace testing::ext; @@ -62,6 +63,7 @@ HWTEST_F(AppMgrServiceDumpTest, AppMgrServiceDump_GetProcessRunningInfosByUserId { HILOG_INFO("AppMgrServiceDump_GetProcessRunningInfosByUserId_0100 start"); + AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); auto appMgrServiceInner = std::make_shared(); EXPECT_NE(appMgrServiceInner, nullptr); @@ -82,6 +84,7 @@ HWTEST_F(AppMgrServiceDumpTest, AppMgrServiceDump_GetProcessRunningInfosByUserId { HILOG_INFO("AppMgrServiceDump_GetProcessRunningInfosByUserId_0200 start"); + AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); auto appMgrService = std::make_shared(); EXPECT_NE(appMgrService, nullptr); diff --git a/test/unittest/app_mgr_service_inner_test/BUILD.gn b/test/unittest/app_mgr_service_inner_test/BUILD.gn index 224485d723..bfd57c968a 100644 --- a/test/unittest/app_mgr_service_inner_test/BUILD.gn +++ b/test/unittest/app_mgr_service_inner_test/BUILD.gn @@ -22,6 +22,7 @@ ohos_unittest("AppMgrServiceInnerTest") { include_dirs = [ "${ability_runtime_test_path}/mock/common/include", "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_test_path}/mock/mock_sa_call", "${ability_runtime_test_path}/mock/services_appmgr_test/include", "${ability_runtime_services_path}/abilitymgr/include", "${ability_runtime_test_path}/moduletest/mock/include", @@ -36,6 +37,7 @@ ohos_unittest("AppMgrServiceInnerTest") { deps = [ "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", "${ability_runtime_services_path}/common:task_handler_wrap", "//third_party/googletest:gmock_main", "//third_party/googletest:gtest_main", @@ -45,6 +47,7 @@ ohos_unittest("AppMgrServiceInnerTest") { "ability_base:configuration", "ability_base:want", "ability_runtime:app_manager", + "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", "bundle_framework:appexecfwk_base", diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 66c92b39a9..00db90d429 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -31,6 +31,7 @@ #include "mock_iapp_state_callback.h" #include "mock_native_token.h" #include "mock_render_scheduler.h" +#include "mock_sa_call.h" #include "parameters.h" #include "window_manager.h" @@ -837,6 +838,7 @@ HWTEST_F(AppMgrServiceInnerTest, KillApplicationSelf_001, TestSize.Level0) HWTEST_F(AppMgrServiceInnerTest, KillApplicationByUserId_001, TestSize.Level0) { HILOG_INFO("KillApplicationByUserId_001 start"); + AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); auto appMgrServiceInner = std::make_shared(); EXPECT_NE(appMgrServiceInner, nullptr); diff --git a/test/unittest/app_scheduler_test/BUILD.gn b/test/unittest/app_scheduler_test/BUILD.gn index 6e3445224a..fa44ddf53e 100644 --- a/test/unittest/app_scheduler_test/BUILD.gn +++ b/test/unittest/app_scheduler_test/BUILD.gn @@ -23,6 +23,7 @@ ohos_unittest("app_scheduler_test") { include_dirs = [ "${ability_runtime_services_path}/abilitymgr/include", + "${ability_runtime_test_path}/mock/mock_sa_call", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/system_ability_mock", "${ability_runtime_test_path}/unittest/app_debug_listener_proxy_test", "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", @@ -54,6 +55,8 @@ ohos_unittest("app_scheduler_test") { "ability_base:want", "ability_base:zuri", "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", "c_utils:utils", "common_event_service:cesfwk_innerkits", "ffrt:libffrt", diff --git a/test/unittest/app_scheduler_test/app_scheduler_test.cpp b/test/unittest/app_scheduler_test/app_scheduler_test.cpp index 3d08ecf70d..c35f276ca4 100644 --- a/test/unittest/app_scheduler_test/app_scheduler_test.cpp +++ b/test/unittest/app_scheduler_test/app_scheduler_test.cpp @@ -27,6 +27,7 @@ #include "app_process_data.h" #include "app_state_call_back_mock.h" #include "element_name.h" +#include "mock_sa_call.h" using namespace testing; using namespace testing::ext; @@ -1181,6 +1182,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_RegisterAppDebugListener_001, TestSize.L */ HWTEST_F(AppSchedulerTest, AppScheduler_RegisterAppDebugListener_002, TestSize.Level1) { + AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); auto listener = new AppDebugListenerStubMock(); int res = DelayedSingleton::GetInstance()->RegisterAppDebugListener(listener); EXPECT_EQ(res, ERR_OK); @@ -1205,6 +1207,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_UnregisterAppDebugListener_001, TestSize */ HWTEST_F(AppSchedulerTest, AppScheduler_UnregisterAppDebugListener_002, TestSize.Level1) { + AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); auto listener = new AppDebugListenerStubMock(); int res = DelayedSingleton::GetInstance()->UnregisterAppDebugListener(listener); EXPECT_EQ(res, ERR_OK); diff --git a/test/unittest/frameworks_kits_ability_native_test/ui_ability_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ui_ability_impl_test.cpp index cfaf3a0f4f..769145f13f 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ui_ability_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ui_ability_impl_test.cpp @@ -24,7 +24,9 @@ #include "context_deal.h" #include "hilog_wrapper.h" #include "locale_config.h" +#include "mock_ability_impl.h" #include "mock_ability_token.h" +#include "mock_page_ability.h" #include "mock_ui_ability.h" #include "mock_ui_ability_impl.h" #include "ohos_application.h" @@ -341,7 +343,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_Stop_001, TestSize.Level1) HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_001, TestSize.Level1) { GTEST_LOG_(INFO) << "AbilityRuntime_New_Foreground_001 start"; - std::shared_ptr mockUIAbilityimpl = std::make_shared(); + std::shared_ptr mockAbilityimpl = std::make_shared(); std::shared_ptr application = std::make_shared(); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "uiAbility"; @@ -353,8 +355,8 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_001, TestSize.Level1) std::shared_ptr record = std::make_shared(abilityInfo, token); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); - std::shared_ptr uiability = nullptr; - MockUIAbility *pMocKUIAbility = new (std::nothrow) MockUIAbility(); + std::shared_ptr uiability = nullptr; + MockPageAbility *pMocKUIAbility = new (std::nothrow) MockPageAbility(); EXPECT_NE(pMocKUIAbility, nullptr); if (pMocKUIAbility != nullptr) { uiability.reset(pMocKUIAbility); @@ -364,11 +366,11 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_001, TestSize.Level1) contextDeal->SetAbilityInfo(abilityInfo); pMocKUIAbility->AttachBaseContext(contextDeal); application->AttachBaseContext(contextDeal); - mockUIAbilityimpl->Init(application, record, uiability, handler, token); + mockAbilityimpl->Init(application, record, uiability, handler, token); Want want; - mockUIAbilityimpl->ImplForeground(want); - EXPECT_EQ(MockUIAbility::Event::ON_FOREGROUND, pMocKUIAbility->state_); - EXPECT_EQ(AAFwk::ABILITY_STATE_FOREGROUND_NEW, mockUIAbilityimpl->GetCurrentState()); + mockAbilityimpl->ImplForeground(want); + EXPECT_EQ(MockPageAbility::Event::ON_FOREGROUND, pMocKUIAbility->state_); + EXPECT_EQ(AAFwk::ABILITY_STATE_FOREGROUND_NEW, mockAbilityimpl->GetCurrentState()); } } GTEST_LOG_(INFO) << "AbilityRuntime_New_Foreground_001 end"; @@ -385,7 +387,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_001, TestSize.Level1) HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_002, TestSize.Level1) { GTEST_LOG_(INFO) << "AbilityRuntime_New_Foreground_002 start"; - std::shared_ptr mockUIAbilityimpl = std::make_shared(); + std::shared_ptr mockAbilityimpl = std::make_shared(); std::shared_ptr application = std::make_shared(); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "uiAbility"; @@ -397,8 +399,8 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_002, TestSize.Level1) std::shared_ptr record = std::make_shared(abilityInfo, token); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); - std::shared_ptr uiability = nullptr; - MockUIAbility *pMocKUIAbility = new (std::nothrow) MockUIAbility(); + std::shared_ptr uiability = nullptr; + MockPageAbility *pMocKUIAbility = new (std::nothrow) MockPageAbility(); EXPECT_NE(pMocKUIAbility, nullptr); if (pMocKUIAbility != nullptr) { uiability.reset(pMocKUIAbility); @@ -408,13 +410,11 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_002, TestSize.Level1) contextDeal->SetAbilityInfo(abilityInfo); pMocKUIAbility->AttachBaseContext(contextDeal); application->AttachBaseContext(contextDeal); - mockUIAbilityimpl->Init(application, record, uiability, handler, token); + mockAbilityimpl->Init(application, record, uiability, handler, token); Want want; - mockUIAbilityimpl->ImplForeground(want); - mockUIAbilityimpl->ImplForeground(want); - mockUIAbilityimpl->ImplForeground(want); - EXPECT_EQ(MockUIAbility::Event::ON_FOREGROUND, pMocKUIAbility->state_); - EXPECT_EQ(AAFwk::ABILITY_STATE_FOREGROUND_NEW, mockUIAbilityimpl->GetCurrentState()); + mockAbilityimpl->ImplForeground(want); + EXPECT_EQ(MockPageAbility::Event::ON_FOREGROUND, pMocKUIAbility->state_); + EXPECT_EQ(AAFwk::ABILITY_STATE_FOREGROUND_NEW, mockAbilityimpl->GetCurrentState()); } } GTEST_LOG_(INFO) << "AbilityRuntime_New_Foreground_002 end"; @@ -562,7 +562,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_001, TestSi HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_002, TestSize.Level1) { GTEST_LOG_(INFO) << "AbilityRuntime_New_Foreground_Background_002 start"; - std::shared_ptr mockUIAbilityimpl = std::make_shared(); + std::shared_ptr mockAbilityimpl = std::make_shared(); std::shared_ptr application = std::make_shared(); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "uiAbility"; @@ -574,8 +574,8 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_002, TestSi std::shared_ptr record = std::make_shared(abilityInfo, token); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); - std::shared_ptr uiability = nullptr; - MockUIAbility *pMocKUIAbility = new (std::nothrow) MockUIAbility(); + std::shared_ptr uiability = nullptr; + MockPageAbility *pMocKUIAbility = new (std::nothrow) MockPageAbility(); EXPECT_NE(pMocKUIAbility, nullptr); if (pMocKUIAbility != nullptr) { uiability.reset(pMocKUIAbility); @@ -585,13 +585,13 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_002, TestSi contextDeal->SetAbilityInfo(abilityInfo); pMocKUIAbility->AttachBaseContext(contextDeal); application->AttachBaseContext(contextDeal); - mockUIAbilityimpl->Init(application, record, uiability, handler, token); + mockAbilityimpl->Init(application, record, uiability, handler, token); Want want; - mockUIAbilityimpl->ImplForeground(want); - mockUIAbilityimpl->ImplBackground(); - mockUIAbilityimpl->ImplForeground(want); - EXPECT_EQ(MockUIAbility::Event::ON_FOREGROUND, pMocKUIAbility->state_); - EXPECT_EQ(AAFwk::ABILITY_STATE_FOREGROUND_NEW, mockUIAbilityimpl->GetCurrentState()); + mockAbilityimpl->ImplForeground(want); + mockAbilityimpl->ImplBackground(); + mockAbilityimpl->ImplForeground(want); + EXPECT_EQ(MockPageAbility::Event::ON_FOREGROUND, pMocKUIAbility->state_); + EXPECT_EQ(AAFwk::ABILITY_STATE_FOREGROUND_NEW, mockAbilityimpl->GetCurrentState()); } } GTEST_LOG_(INFO) << "AbilityRuntime_New_Foreground_Background_002 end"; @@ -608,7 +608,7 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_002, TestSi HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_003, TestSize.Level1) { GTEST_LOG_(INFO) << "AbilityRuntime_New_Foreground_Background_002 start"; - std::shared_ptr mockUIAbilityimpl = std::make_shared(); + std::shared_ptr mockAbilityimpl = std::make_shared(); std::shared_ptr application = std::make_shared(); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "uiAbility"; @@ -620,8 +620,8 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_003, TestSi std::shared_ptr record = std::make_shared(abilityInfo, token); std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); - std::shared_ptr uiability = nullptr; - MockUIAbility *pMocKUIAbility = new (std::nothrow) MockUIAbility(); + std::shared_ptr uiability = nullptr; + MockPageAbility *pMocKUIAbility = new (std::nothrow) MockPageAbility(); EXPECT_NE(pMocKUIAbility, nullptr); if (pMocKUIAbility != nullptr) { uiability.reset(pMocKUIAbility); @@ -631,12 +631,12 @@ HWTEST_F(UIAbilityImplTest, AbilityRuntime_New_Foreground_Background_003, TestSi contextDeal->SetAbilityInfo(abilityInfo); pMocKUIAbility->AttachBaseContext(contextDeal); application->AttachBaseContext(contextDeal); - mockUIAbilityimpl->Init(application, record, uiability, handler, token); + mockAbilityimpl->Init(application, record, uiability, handler, token); Want want; - mockUIAbilityimpl->ImplBackground(); - mockUIAbilityimpl->ImplForeground(want); - EXPECT_EQ(MockUIAbility::Event::ON_FOREGROUND, pMocKUIAbility->state_); - EXPECT_EQ(AAFwk::ABILITY_STATE_FOREGROUND_NEW, mockUIAbilityimpl->GetCurrentState()); + mockAbilityimpl->ImplBackground(); + mockAbilityimpl->ImplForeground(want); + EXPECT_EQ(MockPageAbility::Event::ON_FOREGROUND, pMocKUIAbility->state_); + EXPECT_EQ(AAFwk::ABILITY_STATE_FOREGROUND_NEW, mockAbilityimpl->GetCurrentState()); } } GTEST_LOG_(INFO) << "AbilityRuntime_New_Foreground_Background_003 end"; diff --git a/test/unittest/mission_info_mgr_test/mission_info_mgr_test.cpp b/test/unittest/mission_info_mgr_test/mission_info_mgr_test.cpp index 42164e5885..a63db8aa9f 100755 --- a/test/unittest/mission_info_mgr_test/mission_info_mgr_test.cpp +++ b/test/unittest/mission_info_mgr_test/mission_info_mgr_test.cpp @@ -447,7 +447,7 @@ HWTEST_F(MissionInfoMgrTest, FindReusedMissionInfo_001, TestSize.Level1) missionInfo.missionName = "test"; missionInfo.launchMode = static_cast(AppExecFwk::LaunchMode::STANDARD); missionInfoMgr->missionInfoList_.push_back(missionInfo); - EXPECT_TRUE(missionInfoMgr->FindReusedMissionInfo("test", "", false, missionInfo)); + EXPECT_TRUE(missionInfoMgr->FindReusedMissionInfo("test", "", true, missionInfo)); } /*