From c66e88ff09fa6e64c8e886ead2e0e42b93b28529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E8=8F=B2=E5=A2=A8?= Date: Sat, 14 Jun 2025 15:32:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=81=A2=E5=A4=8DThirdTest=E6=96=B0=E5=A2=9EOp?= =?UTF-8?q?enLinkTest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 朱菲墨 --- test/unittest/BUILD.gn | 1 + .../BUILD.gn | 147 ++----- .../ability_manager_service_third_test.cpp | 220 ---------- test/unittest/ams_open_link_test/BUILD.gn | 237 +++++++++++ .../abilitymgr.gni | 0 .../ams_open_link_test/ams_open_link_test.cpp | 385 ++++++++++++++++++ .../mock/include/mock_free_install_manager.h | 0 .../mock/include/mock_want_utils.h | 0 .../mock/src/mock_free_install_manager.cpp | 0 .../mock/src/mock_want_utils.cpp | 0 10 files changed, 649 insertions(+), 341 deletions(-) create mode 100644 test/unittest/ams_open_link_test/BUILD.gn rename test/unittest/{ability_manager_service_third_test => ams_open_link_test}/abilitymgr.gni (100%) create mode 100644 test/unittest/ams_open_link_test/ams_open_link_test.cpp rename test/unittest/{ability_manager_service_third_test => ams_open_link_test}/mock/include/mock_free_install_manager.h (100%) rename test/unittest/{ability_manager_service_third_test => ams_open_link_test}/mock/include/mock_want_utils.h (100%) rename test/unittest/{ability_manager_service_third_test => ams_open_link_test}/mock/src/mock_free_install_manager.cpp (100%) rename test/unittest/{ability_manager_service_third_test => ams_open_link_test}/mock/src/mock_want_utils.cpp (100%) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index c6d53ceff4d..730f58b0801 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -213,6 +213,7 @@ group("unittest") { "ams_mgr_scheduler_second_test:unittest", "ams_mgr_scheduler_test:unittest", "ams_mgr_stub_test:unittest", + "ams_open_link_test:unittest", "ams_recent_app_list_test:unittest", "ams_service_load_ability_process_test:unittest", "ams_service_startup_test:unittest", diff --git a/test/unittest/ability_manager_service_third_test/BUILD.gn b/test/unittest/ability_manager_service_third_test/BUILD.gn index 927a603071c..5c632b43d34 100644 --- a/test/unittest/ability_manager_service_third_test/BUILD.gn +++ b/test/unittest/ability_manager_service_third_test/BUILD.gn @@ -13,7 +13,6 @@ import("//build/test.gni") import("//foundation/ability/ability_runtime/ability_runtime.gni") -import("//foundation/ability/ability_runtime/test/unittest/ability_manager_service_third_test/abilitymgr.gni") module_output_path = "ability_runtime/ability_runtime/abilitymgr" @@ -37,28 +36,35 @@ ohos_unittest("ability_manager_service_third_test") { "${ability_runtime_test_path}/mock/mock_sa_call", "${ability_runtime_test_path}/unittest/ability_manager_client_branch_test", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit/include", - "${ability_runtime_services_path}/appdfr/include", - "${ability_runtime_path}/interfaces/kits/native/ability/native/ui_service_extension_ability/connection", - "${ability_runtime_services_path}/abilitymgr/include/mission", - "mock/include", ] sources = [ - "ability_manager_service_third_test.cpp", - "mock/src/mock_free_install_manager.cpp", - "mock/src/mock_want_utils.cpp", "${ability_runtime_innerkits_path}/uri_permission/src/uri_permission_load_callback.cpp", + "${ability_runtime_services_path}/abilitymgr/src/ability_auto_startup_data_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/ability_auto_startup_service.cpp", + "${ability_runtime_services_path}/abilitymgr/src/ability_bundle_event_callback.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/hmsf_utils.cpp", + "${ability_runtime_services_path}/abilitymgr/src/insight_intent/insight_intent_rdb_data_mgr.cpp", + "${ability_runtime_services_path}/abilitymgr/src/insight_intent/insight_intent_rdb_storage_mgr.cpp", + "${ability_runtime_services_path}/abilitymgr/src/insight_intent/insight_intent_db_cache.cpp", + "${ability_runtime_services_path}/abilitymgr/src/insight_intent/extract_insight_intent_profile.cpp", + "${ability_runtime_services_path}/abilitymgr/src/insight_intent/insight_intent_event_mgr.cpp", + "${ability_runtime_services_path}/abilitymgr/src/ability_cache_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/ability_connect_callback_stub.cpp", + "${ability_runtime_services_path}/abilitymgr/src/auto_startup_info.cpp", + "${ability_runtime_services_path}/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp", + "${ability_runtime_services_path}/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/sub_managers_helper.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/ability_event_util.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/timeout_state_utils.cpp", + "${ability_runtime_services_path}/common/src/event_report.cpp", "${ability_runtime_services_path}/common/src/ffrt_task_handler_wrap.cpp", "${ability_runtime_services_path}/common/src/queue_task_handler_wrap.cpp", "${ability_runtime_services_path}/common/src/task_handler_wrap.cpp", - "${ability_runtime_services_path}/abilitymgr/src/ability_manager_service.cpp", + "ability_manager_service_third_test.cpp", ] - sources += abilityms_files - configs = [ - "${ability_runtime_services_path}/abilitymgr:abilityms_config", - "${ability_runtime_services_path}/abilitymgr:abilityms_exception_config", - ] + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", @@ -80,154 +86,53 @@ ohos_unittest("ability_manager_service_third_test") { "${ability_runtime_services_path}/common:record_cost_time_util", "${ability_runtime_services_path}/common:task_handler_wrap", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", - "${ability_runtime_services_path}/abilitymgr:wantagent_manager", - "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", - "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", - "${ability_runtime_innerkits_path}/ability_manager:start_window_option", - "${ability_runtime_innerkits_path}/connectionobs_manager:connection_obs_manager", - "${ability_runtime_innerkits_path}/session_handler:session_handler", - "${ability_runtime_services_path}/common:res_sched_util", ] external_deps = [ - "ability_base:base", - "ability_base:configuration", - "ability_base:extractortool", "ability_base:session_info", - "ability_base:view_data", "ability_base:want", "ability_base:zuri", "access_token:libaccesstoken_sdk", - "access_token:libtokenid_sdk", "access_token:libnativetoken", "access_token:libtoken_setproc", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "bundle_framework:libappexecfwk_common", - "c_utils:utils", "cJSON:cjson", - "common_event_service:cesfwk_core", + "c_utils:utils", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", - "dsoftbus:softbus_client", "eventhandler:libeventhandler", - "faultloggerd:libbacktrace_local", "ffrt:libffrt", "googletest:gmock_main", "googletest:gtest_main", - "hicollie:libhicollie", "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", - "icu:shared_icuuc", - "init:libbeget_proxy", "init:libbegetutil", "ipc:ipc_core", - "json:nlohmann_json_static", "kv_store:distributeddata_inner", - "os_account:os_account_innerkits", - "qos_manager:concurrent_task_client", - "relational_store:native_appdatafwk", - "relational_store:native_dataability", - "relational_store:native_rdb", "safwk:api_cache_manager", "safwk:system_ability_fwk", "samgr:samgr_proxy", "selinux_adapter:librestorecon", - "window_manager:libmodal_system_ui_extension_client", - "window_manager:libwsutils", - "window_manager:scene_session", - "window_manager:session_manager_lite", - "window_manager:sms", ] - public_external_deps = [ "background_task_mgr:bgtaskmgr_innerkits" ] - - if (background_task_mgr_continuous_task_enable) { - external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] - } - - if (resource_schedule_service_enable) { - external_deps += [ "resource_schedule_service:ressched_client" ] - } - - if (memmgr_override_enable) { - external_deps += [ "memmgr:memmgrclient" ] - } - - cflags_cc = [] - if (os_dlp_part_enabled) { - cflags_cc += [ "-DWITH_DLP" ] - external_deps += [ - "dlp_permission_service:libdlp_permission_sdk", - "dlp_permission_service:libdlpparse", - ] - } - - defines = [] - - if (ability_runtime_auto_fill) { - defines += [ "SUPPORT_AUTO_FILL" ] - } - - if (ability_runtime_child_process) { - defines += [ "SUPPORT_CHILD_PROCESS" ] - } if (ability_runtime_graphics) { - defines += [ "SUPPORT_GRAPHICS" ] external_deps += [ - "ability_base:session_info", - "i18n:intl_util", - "icu:shared_icuuc", - "image_framework:image_native", - "input:libmmi-client", - "resource_management:global_resmgr", - "screenlock_mgr:screenlock_client", "window_manager:libdm", - "window_manager:libmodal_system_ui_extension_client", - "window_manager:libwm", "window_manager:libwsutils", "window_manager:scene_session", - "window_manager:sms", - ] - } - - if (ability_runtime_upms) { - defines += [ "SUPPORT_UPMS" ] - deps += [ - "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + "window_manager:session_manager_lite", ] } - if (ability_runtime_feature_sandboxmanager) { external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ] - defines += [ - "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER", - "SUPPORT_APP_SELECTOR" - ] - } - - if (include_app_domain_verify) { - external_deps += [ - "app_domain_verify:app_domain_verify_common", - "app_domain_verify:app_domain_verify_mgr_client", - ] - defines += [ "APP_DOMAIN_VERIFY_ENABLED" ] - } - - if (ability_runtime_power) { - defines += [ "SUPPORT_POWER" ] - external_deps += [ "power_manager:powermgr_client" ] - } - - if (ability_runtime_graphics && - ability_runtime_start_window_options_with_pixelmap) { - defines += [ "START_WINDOW_OPTIONS_WITH_PIXELMAP" ] - external_deps += [ "image_framework:image_native" ] + defines = [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ] } - - if (ability_runtime_no_screen) { - defines += ["DISABLE_LAUNCHER"] + cflags_cc = [] + if (os_dlp_part_enabled) { + cflags_cc += [ "-DWITH_DLP" ] } } diff --git a/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp b/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp index 45c896f8aad..2bb0f08b731 100644 --- a/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp +++ b/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp @@ -40,8 +40,6 @@ #include "mock_ability_connect_callback.h" #include "insight_intent_db_cache.h" #include "insight_intent_execute_param.h" -#include "mock_want_utils.h" -#include "mock_free_install_manager.h" using namespace testing; using namespace testing::ext; @@ -58,15 +56,6 @@ const std::string EMPTY_DEVICE_ID = ""; const std::string SESSIONID = "sessionId"; const std::string APPID = "1003"; const int REQUESTCODE = 10; -const std::string NOT_SHORTURL = "NOT_SHORTURL"; -const std::string IS_SHORTURL = "IS_SHORTURL"; -const std::string CONVERT_FAILED = "CONVERT_FAILED"; -const std::string ATOMIC_SERVICE = "ATOMIC_SERVICE"; -const std::string APP = "APP"; -const std::string FREE_INSTALL_ERR_OK = "FREE_INSTALL_ERR_OK"; -const std::string FREE_INSTALL_FAIL = "FREE_INSTALL_FAIL"; -const std::string FREE_INSTALL_NOT_TOP_ABILITY = "FREE_INSTALL_NOT_TOP_ABILITY"; -const std::string APP_LINKING_ONLY = "appLinkingOnly"; } // namespace class AbilityManagerServiceThirdTest : public testing::Test { public: @@ -2303,215 +2292,6 @@ HWTEST_F(AbilityManagerServiceThirdTest, OpenLink_002, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest OpenLink_002 call result %{public}d", result); } -/* - * Feature: AbilityManagerService - * Function: OpenLink - * FunctionPoints: OpenLink not shortUrl - */ -HWTEST_F(AbilityManagerServiceThirdTest, OpenLink_003, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_003 start"); - auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); - sptr token = MockToken(AbilityType::PAGE); - AAFwk::Want want; - Uri uri(NOT_SHORTURL); - want.SetUri(uri); - - auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_003 call result %{public}d", result); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_003 end"); -} - -/* - * Feature: AbilityManagerService - * Function: OpenLink - * FunctionPoints: OpenLink CONVERT_FAILED - */ -HWTEST_F(AbilityManagerServiceThirdTest, OpenLink_004, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_004 start"); - auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); - sptr token = MockToken(AbilityType::PAGE); - AAFwk::Want want; - Uri uri(CONVERT_FAILED); - want.SetUri(uri); - - auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_004 call result %{public}d", result); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_004 end"); -} - -/* - * Feature: AbilityManagerService - * Function: OpenLink - * FunctionPoints: OpenLink shortUrl ATOMIC_SERVICE - */ -HWTEST_F(AbilityManagerServiceThirdTest, OpenLink_005, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_005 start"); - auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); - sptr token = MockToken(AbilityType::PAGE); - AAFwk::Want want; - Uri uri(ATOMIC_SERVICE); - want.SetUri(uri); - - auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_005 call result %{public}d", result); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_005 end"); -} - -/* - * Feature: AbilityManagerService - * Function: OpenLink - * FunctionPoints: OpenLink shortUrl APP - */ -HWTEST_F(AbilityManagerServiceThirdTest, OpenLink_006, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_006 start"); - auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); - sptr token = MockToken(AbilityType::PAGE); - AAFwk::Want want; - Uri uri(APP); - want.SetUri(uri); - - auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_006 call result %{public}d", result); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_006 end"); -} - -/* - * Feature: AbilityManagerService - * Function: OpenLink - * FunctionPoints: OpenLink shortUrl not APP or ATOMIC_SERVICE; appLinkingOnly false - */ -HWTEST_F(AbilityManagerServiceThirdTest, OpenLink_007, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_007 start"); - auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); - sptr token = MockToken(AbilityType::PAGE); - AAFwk::Want want; - Uri uri(IS_SHORTURL); - want.SetUri(uri); - want.SetParam(APP_LINKING_ONLY, false); - - auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_007 call result %{public}d", result); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_007 end"); -} - -/* - * Feature: AbilityManagerService - * Function: OpenLink - * FunctionPoints: OpenLink shortUrl not APP or ATOMIC_SERVICE; appLinkingOnly true - */ -HWTEST_F(AbilityManagerServiceThirdTest, OpenLink_008, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_008 start"); - auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); - sptr token = MockToken(AbilityType::PAGE); - AAFwk::Want want; - Uri uri(IS_SHORTURL); - want.SetUri(uri); - want.SetParam(APP_LINKING_ONLY, true); - - auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_008 call result %{public}d", result); - TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest_OpenLink_008 end"); -} - -/* - * Feature: AbilityManagerService - * Function: OpenLinkFreeInstallAtomicService - * FunctionPoints: OpenLinkFreeInstallAtomicService No freeInstallManager_ FREE_INSTALL_FAIL - */ -HWTEST_F(AbilityManagerServiceThirdTest, OpenLinkFreeInstallAtomicService_001, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_001 start"); - auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); - sptr token = MockToken(AbilityType::PAGE); - AAFwk::Want want; - AAFwk::Want convertedWant; - Uri uri(FREE_INSTALL_FAIL); - convertedWant.SetUri(uri); - auto result = abilityMs_->OpenLinkFreeInstallAtomicService(convertedWant, want, - token, USER_ID_U100, REQUESTCODE, true); - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_001 call result %{public}d", result); - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_001 end"); -} - -/* - * Feature: AbilityManagerService - * Function: OpenLinkFreeInstallAtomicService - * FunctionPoints: OpenLinkFreeInstallAtomicService FREE_INSTALL_FAIL - */ -HWTEST_F(AbilityManagerServiceThirdTest, OpenLinkFreeInstallAtomicService_002, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_002 start"); - auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); - abilityMs_->freeInstallManager_ = std::make_shared(abilityMs_); - sptr token = MockToken(AbilityType::PAGE); - AAFwk::Want want; - AAFwk::Want convertedWant; - Uri uri(FREE_INSTALL_FAIL); - convertedWant.SetUri(uri); - auto result = abilityMs_->OpenLinkFreeInstallAtomicService(convertedWant, want, - token, USER_ID_U100, REQUESTCODE, true); - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_002 call result %{public}d", result); - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_002 end"); -} - -/* - * Feature: AbilityManagerService - * Function: OpenLinkFreeInstallAtomicService - * FunctionPoints: OpenLinkFreeInstallAtomicService FREE_INSTALL_NOT_TOP_ABILITY - */ -HWTEST_F(AbilityManagerServiceThirdTest, OpenLinkFreeInstallAtomicService_003, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_003 start"); - auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); - abilityMs_->freeInstallManager_ = std::make_shared(abilityMs_); - sptr token = MockToken(AbilityType::PAGE); - AAFwk::Want want; - AAFwk::Want convertedWant; - Uri uri(FREE_INSTALL_NOT_TOP_ABILITY); - convertedWant.SetUri(uri); - auto result = abilityMs_->OpenLinkFreeInstallAtomicService(convertedWant, want, - token, USER_ID_U100, REQUESTCODE, true); - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_003 call result %{public}d", result); - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_003 end"); -} - -/* - * Feature: AbilityManagerService - * Function: OpenLinkFreeInstallAtomicService - * FunctionPoints: OpenLinkFreeInstallAtomicService FREE_INSTALL_ERR_OK - */ -HWTEST_F(AbilityManagerServiceThirdTest, OpenLinkFreeInstallAtomicService_004, TestSize.Level1) -{ - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_004 start"); - auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); - abilityMs_->freeInstallManager_ = std::make_shared(abilityMs_); - sptr token = MockToken(AbilityType::PAGE); - AAFwk::Want want; - AAFwk::Want convertedWant; - Uri uri(FREE_INSTALL_ERR_OK); - convertedWant.SetUri(uri); - auto result = abilityMs_->OpenLinkFreeInstallAtomicService(convertedWant, want, - token, USER_ID_U100, REQUESTCODE, true); - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_004 call result %{public}d", result); - TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_004 end"); -} - /* * Feature: AbilityManagerService * Function: NotifySCBToHandleAtomicServiceException diff --git a/test/unittest/ams_open_link_test/BUILD.gn b/test/unittest/ams_open_link_test/BUILD.gn new file mode 100644 index 00000000000..914d5729bed --- /dev/null +++ b/test/unittest/ams_open_link_test/BUILD.gn @@ -0,0 +1,237 @@ +# Copyright (c) 2022-2025 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. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +import("//foundation/ability/ability_runtime/test/unittest/ams_open_link_test/abilitymgr.gni") + +module_output_path = "ability_runtime/ability_runtime/abilitymgr" + +ohos_unittest("ams_open_link_test") { + module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" + + include_dirs = [ + "${ability_runtime_innerkits_path}/uri_permission/include", + "${ability_runtime_path}/interfaces/kits/native/ability/ability_runtime/", + "${ability_runtime_path}/interfaces/inner_api/ability_manager/include", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include", + "${ability_runtime_path}/services/abilitymgr/include/insight_intent", + "${ability_runtime_services_path}/common/include", + "${ability_runtime_test_path}/mock/mock_sa_call", + "${ability_runtime_test_path}/unittest/ability_manager_client_branch_test", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit/include", + "${ability_runtime_services_path}/appdfr/include", + "${ability_runtime_path}/interfaces/kits/native/ability/native/ui_service_extension_ability/connection", + "${ability_runtime_services_path}/abilitymgr/include/mission", + "mock/include", + ] + + sources = [ + "ams_open_link_test.cpp", + "mock/src/mock_free_install_manager.cpp", + "mock/src/mock_want_utils.cpp", + "${ability_runtime_innerkits_path}/uri_permission/src/uri_permission_load_callback.cpp", + "${ability_runtime_services_path}/common/src/ffrt_task_handler_wrap.cpp", + "${ability_runtime_services_path}/common/src/queue_task_handler_wrap.cpp", + "${ability_runtime_services_path}/common/src/task_handler_wrap.cpp", + "${ability_runtime_services_path}/abilitymgr/src/ability_manager_service.cpp", + ] + sources += abilityms_files + + configs = [ + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_exception_config", + ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", + "${ability_runtime_innerkits_path}/ability_manager:mission_info", + "${ability_runtime_innerkits_path}/ability_manager:process_options", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:auto_startup_callback", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/global/freeze:freeze_util", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:app_util", + "${ability_runtime_services_path}/common:event_report", + "${ability_runtime_services_path}/common:perm_verification", + "${ability_runtime_services_path}/common:record_cost_time_util", + "${ability_runtime_services_path}/common:task_handler_wrap", + "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock", + "${ability_runtime_services_path}/abilitymgr:wantagent_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_connect_callback_stub", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", + "${ability_runtime_innerkits_path}/ability_manager:start_window_option", + "${ability_runtime_innerkits_path}/connectionobs_manager:connection_obs_manager", + "${ability_runtime_innerkits_path}/session_handler:session_handler", + "${ability_runtime_services_path}/common:res_sched_util", + ] + + external_deps = [ + "ability_base:base", + "ability_base:configuration", + "ability_base:extractortool", + "ability_base:session_info", + "ability_base:view_data", + "ability_base:want", + "ability_base:zuri", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "bundle_framework:libappexecfwk_common", + "c_utils:utils", + "cJSON:cjson", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "faultloggerd:libbacktrace_local", + "ffrt:libffrt", + "googletest:gmock_main", + "googletest:gtest_main", + "hicollie:libhicollie", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "icu:shared_icuuc", + "init:libbeget_proxy", + "init:libbegetutil", + "ipc:ipc_core", + "json:nlohmann_json_static", + "kv_store:distributeddata_inner", + "os_account:os_account_innerkits", + "qos_manager:concurrent_task_client", + "relational_store:native_appdatafwk", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:api_cache_manager", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "selinux_adapter:librestorecon", + "window_manager:libmodal_system_ui_extension_client", + "window_manager:libwsutils", + "window_manager:scene_session", + "window_manager:session_manager_lite", + "window_manager:sms", + ] + public_external_deps = [ "background_task_mgr:bgtaskmgr_innerkits" ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (resource_schedule_service_enable) { + external_deps += [ "resource_schedule_service:ressched_client" ] + } + + if (memmgr_override_enable) { + external_deps += [ "memmgr:memmgrclient" ] + } + + cflags_cc = [] + if (os_dlp_part_enabled) { + cflags_cc += [ "-DWITH_DLP" ] + external_deps += [ + "dlp_permission_service:libdlp_permission_sdk", + "dlp_permission_service:libdlpparse", + ] + } + + defines = [] + + if (ability_runtime_auto_fill) { + defines += [ "SUPPORT_AUTO_FILL" ] + } + + if (ability_runtime_child_process) { + defines += [ "SUPPORT_CHILD_PROCESS" ] + } + + if (ability_runtime_graphics) { + defines += [ "SUPPORT_GRAPHICS" ] + external_deps += [ + "ability_base:session_info", + "i18n:intl_util", + "icu:shared_icuuc", + "image_framework:image_native", + "input:libmmi-client", + "resource_management:global_resmgr", + "screenlock_mgr:screenlock_client", + "window_manager:libdm", + "window_manager:libmodal_system_ui_extension_client", + "window_manager:libwm", + "window_manager:libwsutils", + "window_manager:scene_session", + "window_manager:sms", + ] + } + + if (ability_runtime_upms) { + defines += [ "SUPPORT_UPMS" ] + deps += [ + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + ] + } + + if (ability_runtime_feature_sandboxmanager) { + external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ] + defines += [ + "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER", + "SUPPORT_APP_SELECTOR" + ] + } + + if (include_app_domain_verify) { + external_deps += [ + "app_domain_verify:app_domain_verify_common", + "app_domain_verify:app_domain_verify_mgr_client", + ] + defines += [ "APP_DOMAIN_VERIFY_ENABLED" ] + } + + if (ability_runtime_power) { + defines += [ "SUPPORT_POWER" ] + external_deps += [ "power_manager:powermgr_client" ] + } + + if (ability_runtime_graphics && + ability_runtime_start_window_options_with_pixelmap) { + defines += [ "START_WINDOW_OPTIONS_WITH_PIXELMAP" ] + external_deps += [ "image_framework:image_native" ] + } + + if (ability_runtime_no_screen) { + defines += ["DISABLE_LAUNCHER"] + } +} + +group("unittest") { + testonly = true + deps = [ ":ams_open_link_test" ] +} diff --git a/test/unittest/ability_manager_service_third_test/abilitymgr.gni b/test/unittest/ams_open_link_test/abilitymgr.gni similarity index 100% rename from test/unittest/ability_manager_service_third_test/abilitymgr.gni rename to test/unittest/ams_open_link_test/abilitymgr.gni diff --git a/test/unittest/ams_open_link_test/ams_open_link_test.cpp b/test/unittest/ams_open_link_test/ams_open_link_test.cpp new file mode 100644 index 00000000000..09d6a081440 --- /dev/null +++ b/test/unittest/ams_open_link_test/ams_open_link_test.cpp @@ -0,0 +1,385 @@ +/* + * Copyright (c) 2023-2025 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 + +#define private public +#define protected public +#include "ability_manager_service.h" +#include "ability_connect_manager.h" +#include "ability_connection.h" +#include "ability_start_setting.h" +#include "recovery_param.h" +#undef private +#undef protected + +#include "ability_bundle_event_callback.h" +#include "ability_manager_errors.h" +#include "ability_manager_stub_mock_test.h" +#include "ability_info.h" +#include "connection_observer_errors.h" +#include "free_install_manager.h" +#include "hilog_tag_wrapper.h" +#include "mock_sa_call.h" +#include "session/host/include/session.h" +#include "scene_board_judgement.h" +#include "system_ability_definition.h" +#include "uri.h" +#include "mock_ability_connect_callback.h" +#include "insight_intent_db_cache.h" +#include "insight_intent_execute_param.h" +#include "mock_want_utils.h" +#include "mock_free_install_manager.h" + +using namespace testing; +using namespace testing::ext; +using namespace OHOS::AppExecFwk; +using OHOS::AppExecFwk::AbilityType; +using OHOS::AppExecFwk::ExtensionAbilityType; +namespace OHOS { +namespace AAFwk { +namespace { +const int32_t USER_ID_U100 = 100; +const int32_t APP_MEMORY_SIZE = 512; +const uint32_t TOKENID = 211; +const std::string EMPTY_DEVICE_ID = ""; +const std::string SESSIONID = "sessionId"; +const std::string APPID = "1003"; +const int REQUESTCODE = 10; +const std::string NOT_SHORTURL = "NOT_SHORTURL"; +const std::string IS_SHORTURL = "IS_SHORTURL"; +const std::string CONVERT_FAILED = "CONVERT_FAILED"; +const std::string ATOMIC_SERVICE = "ATOMIC_SERVICE"; +const std::string APP = "APP"; +const std::string FREE_INSTALL_ERR_OK = "FREE_INSTALL_ERR_OK"; +const std::string FREE_INSTALL_FAIL = "FREE_INSTALL_FAIL"; +const std::string FREE_INSTALL_NOT_TOP_ABILITY = "FREE_INSTALL_NOT_TOP_ABILITY"; +const std::string APP_LINKING_ONLY = "appLinkingOnly"; +} // namespace +class AmsOpenLinkTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + std::shared_ptr MockAbilityRecord(AbilityType); + sptr MockToken(AbilityType); + void SetUp(); + void TearDown(); + + AbilityRequest GenerateAbilityRequest(const std::string& deviceName, const std::string& abilityName, + const std::string& appName, const std::string& bundleName, const std::string& moduleName); +public: + AbilityRequest abilityRequest_{}; + Want want_{}; +}; + +AbilityRequest AmsOpenLinkTest::GenerateAbilityRequest(const std::string& deviceName, + const std::string& abilityName, const std::string& appName, const std::string& bundleName, + const std::string& moduleName) +{ + ElementName element(deviceName, bundleName, abilityName, moduleName); + want_.SetElement(element); + + AbilityInfo abilityInfo; + abilityInfo.visible = true; + abilityInfo.applicationName = appName; + abilityInfo.type = AbilityType::EXTENSION; + abilityInfo.name = abilityName; + abilityInfo.bundleName = bundleName; + abilityInfo.moduleName = moduleName; + abilityInfo.deviceId = deviceName; + ApplicationInfo appinfo; + appinfo.name = appName; + appinfo.bundleName = bundleName; + abilityInfo.applicationInfo = appinfo; + AbilityRequest abilityRequest; + abilityRequest.want = want_; + abilityRequest.abilityInfo = abilityInfo; + abilityRequest.appInfo = appinfo; + + return abilityRequest; +} + +void AmsOpenLinkTest::SetUpTestCase() {} + +void AmsOpenLinkTest::TearDownTestCase() {} + +void AmsOpenLinkTest::SetUp() {} + +void AmsOpenLinkTest::TearDown() {} + +std::shared_ptr AmsOpenLinkTest::MockAbilityRecord(AbilityType abilityType) +{ + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.test.demo"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = abilityType; + return AbilityRecord::CreateAbilityRecord(abilityRequest); +} + +sptr AmsOpenLinkTest::MockToken(AbilityType abilityType) +{ + std::shared_ptr abilityRecord = MockAbilityRecord(abilityType); + if (!abilityRecord) { + return nullptr; + } + return abilityRecord->GetToken(); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLink + * FunctionPoints: AbilityManagerService OpenLink + */ +HWTEST_F(AmsOpenLinkTest, OpenLink_001, TestSize.Level1) +{ + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + Uri uri(""); + want.SetUri(uri); + + auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest OpenLink_001 call result %{public}d", result); +} + +/* +* Feature: AbilityManagerService +* Function: OpenLink +* FunctionPoints: AbilityManagerService OpenLink +*/ +HWTEST_F(AmsOpenLinkTest, OpenLink_002, TestSize.Level1) +{ + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + Uri uri(""); + want.SetUri(uri); + + auto result = abilityMs_->OpenLinkInner(want, token, USER_ID_U100, REQUESTCODE, true); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest OpenLink_002 call result %{public}d", result); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLink + * FunctionPoints: OpenLink not shortUrl + */ +HWTEST_F(AmsOpenLinkTest, OpenLink_003, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_003 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + Uri uri(NOT_SHORTURL); + want.SetUri(uri); + + auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_003 call result %{public}d", result); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_003 end"); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLink + * FunctionPoints: OpenLink CONVERT_FAILED + */ +HWTEST_F(AmsOpenLinkTest, OpenLink_004, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_004 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + Uri uri(CONVERT_FAILED); + want.SetUri(uri); + + auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_004 call result %{public}d", result); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_004 end"); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLink + * FunctionPoints: OpenLink shortUrl ATOMIC_SERVICE + */ +HWTEST_F(AmsOpenLinkTest, OpenLink_005, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_005 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + Uri uri(ATOMIC_SERVICE); + want.SetUri(uri); + + auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_005 call result %{public}d", result); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_005 end"); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLink + * FunctionPoints: OpenLink shortUrl APP + */ +HWTEST_F(AmsOpenLinkTest, OpenLink_006, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_006 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + Uri uri(APP); + want.SetUri(uri); + + auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_006 call result %{public}d", result); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_006 end"); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLink + * FunctionPoints: OpenLink shortUrl not APP or ATOMIC_SERVICE; appLinkingOnly false + */ +HWTEST_F(AmsOpenLinkTest, OpenLink_007, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_007 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + Uri uri(IS_SHORTURL); + want.SetUri(uri); + want.SetParam(APP_LINKING_ONLY, false); + + auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_007 call result %{public}d", result); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_007 end"); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLink + * FunctionPoints: OpenLink shortUrl not APP or ATOMIC_SERVICE; appLinkingOnly true + */ +HWTEST_F(AmsOpenLinkTest, OpenLink_008, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_008 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + Uri uri(IS_SHORTURL); + want.SetUri(uri); + want.SetParam(APP_LINKING_ONLY, true); + + auto result = abilityMs_->OpenLink(want, token, USER_ID_U100, REQUESTCODE); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_008 call result %{public}d", result); + TAG_LOGI(AAFwkTag::TEST, "AmsOpenLinkTest_OpenLink_008 end"); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLinkFreeInstallAtomicService + * FunctionPoints: OpenLinkFreeInstallAtomicService No freeInstallManager_ FREE_INSTALL_FAIL + */ +HWTEST_F(AmsOpenLinkTest, OpenLinkFreeInstallAtomicService_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_001 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + AAFwk::Want convertedWant; + Uri uri(FREE_INSTALL_FAIL); + convertedWant.SetUri(uri); + auto result = abilityMs_->OpenLinkFreeInstallAtomicService(convertedWant, want, + token, USER_ID_U100, REQUESTCODE, true); + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_001 call result %{public}d", result); + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_001 end"); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLinkFreeInstallAtomicService + * FunctionPoints: OpenLinkFreeInstallAtomicService FREE_INSTALL_FAIL + */ +HWTEST_F(AmsOpenLinkTest, OpenLinkFreeInstallAtomicService_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_002 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + abilityMs_->freeInstallManager_ = std::make_shared(abilityMs_); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + AAFwk::Want convertedWant; + Uri uri(FREE_INSTALL_FAIL); + convertedWant.SetUri(uri); + auto result = abilityMs_->OpenLinkFreeInstallAtomicService(convertedWant, want, + token, USER_ID_U100, REQUESTCODE, true); + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_002 call result %{public}d", result); + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_002 end"); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLinkFreeInstallAtomicService + * FunctionPoints: OpenLinkFreeInstallAtomicService FREE_INSTALL_NOT_TOP_ABILITY + */ +HWTEST_F(AmsOpenLinkTest, OpenLinkFreeInstallAtomicService_003, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_003 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + abilityMs_->freeInstallManager_ = std::make_shared(abilityMs_); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + AAFwk::Want convertedWant; + Uri uri(FREE_INSTALL_NOT_TOP_ABILITY); + convertedWant.SetUri(uri); + auto result = abilityMs_->OpenLinkFreeInstallAtomicService(convertedWant, want, + token, USER_ID_U100, REQUESTCODE, true); + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_003 call result %{public}d", result); + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_003 end"); +} + +/* + * Feature: AbilityManagerService + * Function: OpenLinkFreeInstallAtomicService + * FunctionPoints: OpenLinkFreeInstallAtomicService FREE_INSTALL_ERR_OK + */ +HWTEST_F(AmsOpenLinkTest, OpenLinkFreeInstallAtomicService_004, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_004 start"); + auto abilityMs_ = std::make_shared(); + EXPECT_NE(abilityMs_, nullptr); + abilityMs_->freeInstallManager_ = std::make_shared(abilityMs_); + sptr token = MockToken(AbilityType::PAGE); + AAFwk::Want want; + AAFwk::Want convertedWant; + Uri uri(FREE_INSTALL_ERR_OK); + convertedWant.SetUri(uri); + auto result = abilityMs_->OpenLinkFreeInstallAtomicService(convertedWant, want, + token, USER_ID_U100, REQUESTCODE, true); + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_004 call result %{public}d", result); + TAG_LOGI(AAFwkTag::TEST, "OpenLinkFreeInstallAtomicService_004 end"); +} +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/ability_manager_service_third_test/mock/include/mock_free_install_manager.h b/test/unittest/ams_open_link_test/mock/include/mock_free_install_manager.h similarity index 100% rename from test/unittest/ability_manager_service_third_test/mock/include/mock_free_install_manager.h rename to test/unittest/ams_open_link_test/mock/include/mock_free_install_manager.h diff --git a/test/unittest/ability_manager_service_third_test/mock/include/mock_want_utils.h b/test/unittest/ams_open_link_test/mock/include/mock_want_utils.h similarity index 100% rename from test/unittest/ability_manager_service_third_test/mock/include/mock_want_utils.h rename to test/unittest/ams_open_link_test/mock/include/mock_want_utils.h diff --git a/test/unittest/ability_manager_service_third_test/mock/src/mock_free_install_manager.cpp b/test/unittest/ams_open_link_test/mock/src/mock_free_install_manager.cpp similarity index 100% rename from test/unittest/ability_manager_service_third_test/mock/src/mock_free_install_manager.cpp rename to test/unittest/ams_open_link_test/mock/src/mock_free_install_manager.cpp diff --git a/test/unittest/ability_manager_service_third_test/mock/src/mock_want_utils.cpp b/test/unittest/ams_open_link_test/mock/src/mock_want_utils.cpp similarity index 100% rename from test/unittest/ability_manager_service_third_test/mock/src/mock_want_utils.cpp rename to test/unittest/ams_open_link_test/mock/src/mock_want_utils.cpp -- Gitee