From 6a1cadbc9c1a05d5f8e13e0433ac22b4a7c1de56 Mon Sep 17 00:00:00 2001 From: zhaoyuan17 Date: Wed, 27 Oct 2021 10:07:16 +0800 Subject: [PATCH] Test codex Signed-off-by: zhaoyuan17 --- .../include/bundle_constants.h | 3 +- .../appexecfwk_base/include/form_info.h | 7 + .../include/appmgr/ams_mgr_interface.h | 3 + .../include/appmgr/ams_mgr_proxy.h | 2 + .../include/appmgr/ams_mgr_stub.h | 1 + .../include/appmgr/app_mgr_client.h | 2 + .../include/bundlemgr/bundle_mgr_host.h | 7 + .../include/bundlemgr/bundle_mgr_interface.h | 10 +- .../include/bundlemgr/bundle_mgr_proxy.h | 7 + .../src/appmgr/ams_mgr_proxy.cpp | 23 ++ .../src/appmgr/ams_mgr_stub.cpp | 9 + .../src/appmgr/app_mgr_client.cpp | 13 + .../src/bundlemgr/bundle_mgr_host.cpp | 26 ++ .../src/bundlemgr/bundle_mgr_proxy.cpp | 19 + kits/appkit/napi/bundlemgr/bundle_mgr.cpp | 118 +++--- services/appmgr/include/ams_mgr_scheduler.h | 2 + .../appmgr/include/app_mgr_service_inner.h | 2 + services/appmgr/include/app_running_manager.h | 2 + services/appmgr/src/ams_mgr_scheduler.cpp | 11 + services/appmgr/src/app_mgr_service_inner.cpp | 10 + services/appmgr/src/app_running_manager.cpp | 20 + services/appmgr/src/lmks/lmks_utils.cpp | 3 +- .../mock/include/mock_ams_mgr_scheduler.h | 1 + .../test/mock/include/mock_bundle_manager.h | 8 + services/bundlemgr/include/bundle_data_mgr.h | 7 + .../bundlemgr/include/bundle_mgr_host_impl.h | 7 + services/bundlemgr/include/bundle_util.h | 2 +- services/bundlemgr/include/common_profile.h | 1 + .../bundlemgr/include/inner_bundle_info.h | 14 +- services/bundlemgr/src/bundle_data_mgr.cpp | 46 +++ .../bundlemgr/src/bundle_mgr_host_impl.cpp | 10 + services/bundlemgr/src/bundle_profile.cpp | 113 +++--- services/bundlemgr/src/bundle_util.cpp | 7 +- services/bundlemgr/src/inner_bundle_info.cpp | 21 + .../test/mock/include/mock_ability_mgr_host.h | 2 +- .../bms_bundle_kit_service_test.cpp | 200 +++++++++- .../bms_bundle_parser_test.cpp | 5 + services/formmgr/src/form_refresh_limiter.cpp | 2 +- .../formmgr/src/form_sys_event_receiver.cpp | 2 +- services/formmgr/test/BUILD.gn | 16 + .../test/mock/include/mock_ability_manager.h | 2 +- .../test/mock/include/mock_bundle_manager.h | 4 + .../test/mock/include/mock_ability_mgr_host.h | 2 +- .../bms_bundle_installer_module_test.cpp | 5 + .../amssystemtestability/abilitySrc/BUILD.gn | 3 + .../amsAbilityAppendTestA/config.json | 1 + .../amsAbilityVisibleTestPageA/config.json | 3 + .../amsAbilityVisibleTestServiceB/config.json | 4 + .../amsConfigurationUpdatedTest/config.json | 5 + .../abilitySrc/amsDataSystemTestA/config.json | 1 + .../src/ams_st_data_ability_data_a.cpp | 4 + .../abilitySrc/amsDataSystemTestB/config.json | 1 + .../abilitySrc/amsDataSystemTestC/config.json | 1 + .../abilitySrc/amsKitSystemTest/config.json | 5 + .../abilitySrc/amsKitSystemTestA/config.json | 1 + .../amsKitSystemTestDataA/config.json | 4 + .../amsKitSystemTestDataB/config.json | 2 + .../amsKitSystemTestPageA/config.json | 4 + .../amsKitSystemTestService/config.json | 5 + .../amsMissionStackTest/config.json | 2 + .../amsMissionStackTestSubsidiary/config.json | 2 + .../abilitySrc/amsSystemTestA/config.json | 1 + .../abilitySrc/amsSystemTestC/config.json | 2 + .../abilitySrc/amsSystemTestD/config.json | 1 + .../abilitySrc/amsSystemTestDFX/config.json | 1 + .../abilitySrc/amsSystemTestF/config.json | 2 + .../abilitySrc/amsSystemTestG/config.json | 1 + .../abilitySrc/amsSystemTestI/config.json | 3 + .../abilitySrc/amsSystemTestN/config.json | 3 + .../abilitySrc/amsSystemTestQ/config.json | 3 + .../abilitySrc/amsSystemTestR/config.json | 3 + .../amsSystemTestServiceB/config.json | 1 + .../abilitySrc/fwkAbilityState/BUILD.gn | 64 +++ .../abilitySrc/fwkAbilityState/config.json | 50 +++ .../include/ability_state_main.h | 81 ++++ .../include/ability_state_second.h | 79 ++++ .../fwkAbilityState/include/test_utils.h | 30 ++ .../src/ability_state_main.cpp | 154 ++++++++ .../src/ability_state_second.cpp | 133 +++++++ .../fwkAbilityState/src/test_utils.cpp | 42 ++ .../taskDispatcherTestA/config.json | 1 + .../taskDispatcherTestB/config.json | 1 + .../stThirdBundle/bmsThirdBundle41.hap | Bin 94208 -> 94238 bytes .../stThirdBundle/bmsThirdBundle43.hap | Bin 54948083 -> 54942354 bytes .../fmsSystemTestHostCommonA/BUILD.gn | 2 +- .../fmsSystemTestHostCommonB/BUILD.gn | 2 +- .../fmsSystemTestHostNormal/BUILD.gn | 2 +- .../fmsSystemTestHostNormalB/BUILD.gn | 2 +- .../fmsSystemTestHostNormalC/BUILD.gn | 2 +- test/systemtest/BUILD.gn | 1 - test/systemtest/common/ams/BUILD.gn | 1 + .../ams/ams_ability_state_test/BUILD.gn | 82 ++++ .../ams_ability_state_test.cpp | 290 ++++++++++++++ .../acts_bms_kit_system_test.cpp | 167 +++----- .../bms_compatible_system_test.cpp | 10 +- .../bms_install_system_test.cpp | 5 +- .../bms_launcher_service_system_test.cpp | 366 +++++++----------- .../bms_search_system_test.cpp | 3 - .../bms_uninstall_system_test.cpp | 2 - .../common/fms/fms_acquire_form_test/BUILD.gn | 2 +- .../fms/fms_acquire_form_test_max/BUILD.gn | 2 +- .../common/fms/fms_delete_form_test/BUILD.gn | 2 +- .../common/fms/fms_release_form_test/BUILD.gn | 2 +- .../fms/fms_self_starting_test/BUILD.gn | 2 +- tools/fm/src/fms_command.cpp | 2 +- tools/test/mock/mock_bundle_mgr_host.h | 1 + 106 files changed, 1930 insertions(+), 501 deletions(-) create mode 100644 test/resource/amssystemtestability/abilitySrc/fwkAbilityState/BUILD.gn create mode 100644 test/resource/amssystemtestability/abilitySrc/fwkAbilityState/config.json create mode 100644 test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/ability_state_main.h create mode 100644 test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/ability_state_second.h create mode 100644 test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/test_utils.h create mode 100644 test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/ability_state_main.cpp create mode 100644 test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/ability_state_second.cpp create mode 100644 test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/test_utils.cpp create mode 100755 test/systemtest/common/ams/ams_ability_state_test/BUILD.gn create mode 100644 test/systemtest/common/ams/ams_ability_state_test/ams_ability_state_test.cpp mode change 100755 => 100644 test/systemtest/common/bms/bms_install_system_test/bms_install_system_test.cpp diff --git a/interfaces/innerkits/appexecfwk_base/include/bundle_constants.h b/interfaces/innerkits/appexecfwk_base/include/bundle_constants.h index 0a5a4207d8..e0a7298c6d 100755 --- a/interfaces/innerkits/appexecfwk_base/include/bundle_constants.h +++ b/interfaces/innerkits/appexecfwk_base/include/bundle_constants.h @@ -115,7 +115,8 @@ const std::string STORE_ID = "installed_bundle_datas"; const std::string ABILITY_USAGE_STORE_ID = "ability_usage_datas"; // single max hap size -constexpr int32_t MAX_HAP_SIZE = 50 * 1024 * 1024; +constexpr int64_t ONE_GB = 1024 * 1024 * 1024; +constexpr int64_t MAX_HAP_SIZE = ONE_GB * 4; // 4GB const std::string UID = "uid"; const int32_t MAX_LIMIT_SIZE = 4; diff --git a/interfaces/innerkits/appexecfwk_base/include/form_info.h b/interfaces/innerkits/appexecfwk_base/include/form_info.h index 6048620d7f..88948bc5e5 100644 --- a/interfaces/innerkits/appexecfwk_base/include/form_info.h +++ b/interfaces/innerkits/appexecfwk_base/include/form_info.h @@ -37,6 +37,11 @@ struct FormCustomizeData { std::string value; }; +struct FormWindow { + int32_t designWidth; + bool autoDesignWidth; +}; + struct FormInfo : public Parcelable { std::string package; std::string bundleName; @@ -50,6 +55,8 @@ struct FormInfo : public Parcelable { std::string deepLink; std::string formConfigAbility; std::string scheduledUpateTime = "0:0"; + std::string layout; + FormWindow window; int32_t descriptionId = 0; int32_t updateDuration = 0; int32_t defaultDimension = 0; diff --git a/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_interface.h b/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_interface.h index 5572cac4e0..547e06d125 100644 --- a/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_interface.h +++ b/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_interface.h @@ -107,6 +107,8 @@ public: virtual void AbilityAttachTimeOut(const sptr &token) = 0; + virtual void PrepareTerminate(const sptr &token) = 0; + /** * Checks whether a specified permission has been granted to the process identified by pid and uid * @@ -130,6 +132,7 @@ public: AMS_KILL_APPLICATION, AMS_ABILITY_ATTACH_TIMEOUT, AMS_COMPEL_VERIFY_PERMISSION, + AMS_PREPARE_TERMINATE_ABILITY, }; }; } // namespace AppExecFwk diff --git a/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_proxy.h b/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_proxy.h index 086a8ad5c1..36d1552cbb 100644 --- a/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_proxy.h +++ b/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_proxy.h @@ -104,6 +104,8 @@ public: virtual void AbilityAttachTimeOut(const sptr &token) override; + virtual void PrepareTerminate(const sptr &token) override; + /** * Checks whether a specified permission has been granted to the process identified by pid and uid * diff --git a/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_stub.h b/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_stub.h index a5e9874ad8..990c7d2180 100644 --- a/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_stub.h +++ b/interfaces/innerkits/appexecfwk_core/include/appmgr/ams_mgr_stub.h @@ -44,6 +44,7 @@ private: int32_t HandleKillApplication(MessageParcel &data, MessageParcel &reply); int32_t HandleAbilityAttachTimeOut(MessageParcel &data, MessageParcel &reply); int32_t HandleCompelVerifyPermission(MessageParcel &data, MessageParcel &reply); + int32_t HandlePrepareTerminate(MessageParcel &data, MessageParcel &reply); using AmsMgrFunc = int32_t (AmsMgrStub::*)(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; diff --git a/interfaces/innerkits/appexecfwk_core/include/appmgr/app_mgr_client.h b/interfaces/innerkits/appexecfwk_core/include/appmgr/app_mgr_client.h index 55bf0be769..130cbedde7 100644 --- a/interfaces/innerkits/appexecfwk_core/include/appmgr/app_mgr_client.h +++ b/interfaces/innerkits/appexecfwk_core/include/appmgr/app_mgr_client.h @@ -153,6 +153,8 @@ public: virtual AppMgrResultCode GetAppFreezingTime(int &time); virtual void AbilityAttachTimeOut(const sptr &token); + virtual void PrepareTerminate(const sptr &token); + /** * Checks whether a specified permission has been granted to the process identified by pid and uid * diff --git a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h index ecf6aff158..08a7fd9811 100644 --- a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h +++ b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h @@ -125,6 +125,13 @@ private: * @return Returns ERR_OK if called successfully; returns error code otherwise. */ ErrCode HandleQueryAbilityInfos(Parcel &data, Parcel &reply); + /** + * @brief Handles the QueryAbilityInfosForClone function called from a IBundleMgr proxy object. + * @param data Indicates the data to be read. + * @param reply Indicates the reply to be sent; + * @return Returns ERR_OK if called successfully; returns error code otherwise. + */ + ErrCode HandleQueryAbilityInfosForClone(Parcel &data, Parcel &reply); /** * @brief Handles the QueryAbilityInfoByUri function called from a IBundleMgr proxy object. * @param data Indicates the data to be read. diff --git a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h index ea34e91cfa..cb73253c3f 100644 --- a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h +++ b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h @@ -148,13 +148,20 @@ public: * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. */ virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) = 0; - /** + /** * @brief Query the AbilityInfo of list by the given Want. * @param want Indicates the information of the ability. * @param abilityInfos Indicates the obtained AbilityInfos object. * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. */ virtual bool QueryAbilityInfos(const Want &want, std::vector &abilityInfos) = 0; + /** + * @brief Query the AbilityInfo of list for clone by the given Want. + * @param want Indicates the information of the ability. + * @param abilityInfos Indicates the obtained AbilityInfos object. + * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. + */ + virtual bool QueryAbilityInfosForClone(const Want &want, std::vector &abilityInfos) = 0; /** * @brief Query the AbilityInfo by ability.uri in config.json. * @param abilityUri Indicates the uri of the ability. @@ -437,6 +444,7 @@ public: GET_BUNDLE_INFOS_BY_METADATA, QUERY_ABILITY_INFO, QUERY_ABILITY_INFOS, + QUERY_ABILITY_INFOS_FOR_CLONE, QUERY_ABILITY_INFO_BY_URI, QUERY_KEEPALIVE_BUNDLE_INFOS, GET_ABILITY_LABEL, diff --git a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h index bd268e69f4..a4eef7f344 100644 --- a/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h +++ b/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h @@ -143,6 +143,13 @@ public: * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. */ virtual bool QueryAbilityInfos(const Want &want, std::vector &abilityInfos) override; + /** + * @brief Query the AbilityInfo of list for clone by the given Want. + * @param want Indicates the information of the ability. + * @param abilityInfos Indicates the obtained AbilityInfos object. + * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. + */ + virtual bool QueryAbilityInfosForClone(const Want &want, std::vector &abilityInfos) override; /** * @brief Query the AbilityInfo by ability.uri in config.json through the proxy object. * @param abilityUri Indicates the uri of the ability. diff --git a/interfaces/innerkits/appexecfwk_core/src/appmgr/ams_mgr_proxy.cpp b/interfaces/innerkits/appexecfwk_core/src/appmgr/ams_mgr_proxy.cpp index 5a309cb691..de43ffe9ec 100644 --- a/interfaces/innerkits/appexecfwk_core/src/appmgr/ams_mgr_proxy.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/appmgr/ams_mgr_proxy.cpp @@ -263,6 +263,29 @@ void AmsMgrProxy::AbilityAttachTimeOut(const sptr &token) APP_LOGD("end"); } +void AmsMgrProxy::PrepareTerminate(const sptr &token) +{ + APP_LOGD("start"); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!WriteInterfaceToken(data)) { + return; + } + data.WriteParcelable(token.GetRefPtr()); + sptr remote = Remote(); + if (remote == nullptr) { + APP_LOGE("Remote() is NULL"); + return; + } + int32_t ret = + remote->SendRequest(static_cast(IAmsMgr::Message::AMS_PREPARE_TERMINATE_ABILITY), data, reply, option); + if (ret != NO_ERROR) { + APP_LOGW("SendRequest is failed, error code: %{public}d", ret); + } + APP_LOGD("end"); +} + int AmsMgrProxy::CompelVerifyPermission(const std::string &permission, int pid, int uid, std::string &message) { APP_LOGD("start"); diff --git a/interfaces/innerkits/appexecfwk_core/src/appmgr/ams_mgr_stub.cpp b/interfaces/innerkits/appexecfwk_core/src/appmgr/ams_mgr_stub.cpp index 177edf1602..20e21997a1 100644 --- a/interfaces/innerkits/appexecfwk_core/src/appmgr/ams_mgr_stub.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/appmgr/ams_mgr_stub.cpp @@ -47,6 +47,8 @@ AmsMgrStub::AmsMgrStub() &AmsMgrStub::HandleAbilityAttachTimeOut; memberFuncMap_[static_cast(IAmsMgr::Message::AMS_COMPEL_VERIFY_PERMISSION)] = &AmsMgrStub::HandleCompelVerifyPermission; + memberFuncMap_[static_cast(IAmsMgr::Message::AMS_PREPARE_TERMINATE_ABILITY)] = + &AmsMgrStub::HandlePrepareTerminate; } AmsMgrStub::~AmsMgrStub() @@ -169,5 +171,12 @@ int32_t AmsMgrStub::HandleCompelVerifyPermission(MessageParcel &data, MessagePar reply.WriteInt32(result); return NO_ERROR; } + +int32_t AmsMgrStub::HandlePrepareTerminate(MessageParcel &data, MessageParcel &reply) +{ + sptr token = data.ReadParcelable(); + PrepareTerminate(token); + return NO_ERROR; +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/interfaces/innerkits/appexecfwk_core/src/appmgr/app_mgr_client.cpp b/interfaces/innerkits/appexecfwk_core/src/appmgr/app_mgr_client.cpp index 29d7f18009..d5bce6d733 100644 --- a/interfaces/innerkits/appexecfwk_core/src/appmgr/app_mgr_client.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/appmgr/app_mgr_client.cpp @@ -224,6 +224,19 @@ void AppMgrClient::AbilityAttachTimeOut(const sptr &token) amsService->AbilityAttachTimeOut(token); } +void AppMgrClient::PrepareTerminate(const sptr &token) +{ + sptr service = iface_cast(remote_); + if (service == nullptr) { + return; + } + sptr amsService = service->GetAmsMgr(); + if (amsService == nullptr) { + return; + } + amsService->PrepareTerminate(token); +} + int AppMgrClient::CompelVerifyPermission(const std::string &permission, int pid, int uid, std::string &message) { sptr service = iface_cast(remote_); diff --git a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp index 6cc4585316..155d93a3c7 100755 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp @@ -89,6 +89,9 @@ int BundleMgrHost::OnRemoteRequest(uint32_t code, MessageParcel &data, MessagePa case static_cast(IBundleMgr::Message::QUERY_ABILITY_INFOS): errCode = HandleQueryAbilityInfos(data, reply); break; + case static_cast(IBundleMgr::Message::QUERY_ABILITY_INFOS_FOR_CLONE): + errCode = HandleQueryAbilityInfosForClone(data, reply); + break; case static_cast(IBundleMgr::Message::QUERY_ABILITY_INFO_BY_URI): errCode = HandleQueryAbilityInfoByUri(data, reply); break; @@ -464,6 +467,29 @@ ErrCode BundleMgrHost::HandleQueryAbilityInfos(Parcel &data, Parcel &reply) return ERR_OK; } +ErrCode BundleMgrHost::HandleQueryAbilityInfosForClone(Parcel &data, Parcel &reply) +{ + std::unique_ptr want(data.ReadParcelable()); + if (!want) { + APP_LOGE("ReadParcelable failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + std::vector abilityInfos; + bool ret = QueryAbilityInfosForClone(*want, abilityInfos); + if (!reply.WriteBool(ret)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + if (ret) { + if (!WriteParcelableVector(abilityInfos, reply)) { + APP_LOGE("write failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + } + return ERR_OK; +} + ErrCode BundleMgrHost::HandleQueryAbilityInfoByUri(Parcel &data, Parcel &reply) { std::string abilityUri = data.ReadString(); diff --git a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp index 0550b9335f..9437c31035 100644 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp @@ -386,6 +386,25 @@ bool BundleMgrProxy::QueryAbilityInfos(const Want &want, std::vector &abilityInfos) +{ + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + APP_LOGE("fail to QueryAbilityInfo due to write MessageParcel fail"); + return false; + } + if (!data.WriteParcelable(&want)) { + APP_LOGE("fail to QueryAbilityInfo due to write want fail"); + return false; + } + + if (!GetParcelableInfos(IBundleMgr::Message::QUERY_ABILITY_INFOS_FOR_CLONE, data, abilityInfos)) { + APP_LOGE("fail to QueryAbilityInfos from server"); + return false; + } + return true; +} + bool BundleMgrProxy::QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) { MessageParcel data; diff --git a/kits/appkit/napi/bundlemgr/bundle_mgr.cpp b/kits/appkit/napi/bundlemgr/bundle_mgr.cpp index b6137e9c57..8362621002 100644 --- a/kits/appkit/napi/bundlemgr/bundle_mgr.cpp +++ b/kits/appkit/napi/bundlemgr/bundle_mgr.cpp @@ -724,6 +724,16 @@ static void ConvertFormCustomizeData(napi_env env, napi_value objformInfo, const NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objformInfo, "value", nValue)); } +static void ConvertFormWindow(napi_env env, napi_value objWindowInfo, const FormWindow &formWindow) +{ + napi_value nDesignWidth; + NAPI_CALL_RETURN_VOID(env, napi_create_uint32(env, formWindow.designWidth, &nDesignWidth)); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objWindowInfo, "designWidth", nDesignWidth)); + napi_value nAutoDesignWidth; + NAPI_CALL_RETURN_VOID(env, napi_get_boolean(env, formWindow.autoDesignWidth, &nAutoDesignWidth)); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objWindowInfo, "autoDesignWidth", nAutoDesignWidth)); +} + static void ConvertFormInfo(napi_env env, napi_value objformInfo, const FormInfo &formInfo) { napi_value nName; @@ -812,6 +822,18 @@ static void ConvertFormInfo(napi_env env, napi_value objformInfo, const FormInfo NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nCustomizeDatas, idx, nCustomizeData)); } NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objformInfo, "customizeDatas", nCustomizeDatas)); + + napi_value nLayout; + NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, formInfo.layout.c_str(), NAPI_AUTO_LENGTH, &nLayout)); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objformInfo, "layout", nLayout)); + HILOG_INFO("ConvertFormInfo layout=%{public}s.", formInfo.layout.c_str()); + + napi_value nWindow; + NAPI_CALL_RETURN_VOID(env, napi_create_object(env, &nWindow)); + ConvertFormWindow(env, nWindow, formInfo.window); + HILOG_INFO("ConvertFormInfo window.designWidth=%{public}d.", formInfo.window.designWidth); + HILOG_INFO("ConvertFormInfo window.autoDesignWidth=%{public}d.", formInfo.window.autoDesignWidth); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objformInfo, "window", nWindow)); } static void ConvertShortcutIntent(napi_env env, napi_value objShortcutInfo, const ShortcutIntent &shortcutIntent) @@ -1051,10 +1073,10 @@ napi_value GetApplicationInfos(napi_env env, napi_callback_info info) } AsyncApplicationInfosCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncApplicationInfosCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, - .applicationFlag = applicationFlag, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .applicationFlag = applicationFlag, .userId = userId }; if (asyncCallbackInfo == nullptr) { @@ -1246,9 +1268,9 @@ napi_value QueryAbilityInfos(napi_env env, napi_callback_info info) ParseInt(env, userId, argv[PARAM2]); AsyncAbilityInfoCallbackInfo *asyncCallbackInfo = new AsyncAbilityInfoCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, .want = want }; if (asyncCallbackInfo == nullptr) { @@ -1573,9 +1595,9 @@ napi_value GetBundleInfos(napi_env env, napi_callback_info info) bundleFlag = BundleFlag::GET_BUNDLE_DEFAULT; } AsyncBundleInfosCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncBundleInfosCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, .bundleFlag = bundleFlag }; if (asyncCallbackInfo == nullptr) { @@ -1711,10 +1733,10 @@ napi_value GetBundleInfo(napi_env env, napi_callback_info info) bundleFlag = BundleFlag::GET_BUNDLE_DEFAULT; } AsyncBundleInfoCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncBundleInfoCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, - .param = bundleName, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .param = bundleName, .bundleFlag = bundleFlag }; if (asyncCallbackInfo == nullptr) { @@ -1851,10 +1873,10 @@ napi_value GetBundleArchiveInfo(napi_env env, napi_callback_info info) bundleFlag = BundleFlag::GET_BUNDLE_DEFAULT; } AsyncBundleInfoCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncBundleInfoCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, - .param = hapFilePath, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .param = hapFilePath, .bundleFlag = bundleFlag }; if (asyncCallbackInfo == nullptr) { @@ -2043,9 +2065,9 @@ napi_value GetPermissionDef(napi_env env, napi_callback_info info) std::string permissionName; ParseString(env, permissionName, argv[PARAM0]); AsyncPermissionDefCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncPermissionDefCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, .permissionName = permissionName }; if (asyncCallbackInfo == nullptr) { @@ -2190,8 +2212,8 @@ napi_value GetBundleInstaller(napi_env env, napi_callback_info info) AsyncGetBundleInstallerCallbackInfo *asyncCallbackInfo = new AsyncGetBundleInstallerCallbackInfo { - .env = env, - .asyncWork = nullptr, + .env = env, + .asyncWork = nullptr, .deferred = nullptr }; if (asyncCallbackInfo == nullptr) { @@ -2800,8 +2822,8 @@ napi_value GetAllFormsInfo(napi_env env, napi_callback_info info) HILOG_INFO("ARGCSIZE is =%{public}zu.", argc); AsyncFormInfosCallbackInfo *asyncCallbackInfo = new AsyncFormInfosCallbackInfo { - .env = env, - .asyncWork = nullptr, + .env = env, + .asyncWork = nullptr, .deferred = nullptr }; if (asyncCallbackInfo == nullptr) { @@ -2930,10 +2952,10 @@ napi_value GetFormsInfoByModule(napi_env env, napi_callback_info info) ParseString(env, moduleName, argv[PARAM1]); AsyncFormInfosByModuleCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncFormInfosByModuleCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, - .bundleName = bundleName, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .bundleName = bundleName, .moduleName = moduleName }; if (asyncCallbackInfo == nullptr) { @@ -3061,9 +3083,9 @@ napi_value GetFormsInfoByApp(napi_env env, napi_callback_info info) ParseString(env, bundleName, argv[PARAM0]); AsyncFormInfosByAppCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncFormInfosByAppCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, .bundleName = bundleName }; if (asyncCallbackInfo == nullptr) { @@ -3209,9 +3231,9 @@ napi_value GetShortcutInfos(napi_env env, napi_callback_info info) std::string bundleName; ParseString(env, bundleName, argv[PARAM0]); AsyncShortcutInfosCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncShortcutInfosCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, .bundleName = bundleName }; if (asyncCallbackInfo == nullptr) { @@ -3357,9 +3379,9 @@ napi_value GetModuleUsageRecords(napi_env env, napi_callback_info info) int number; ParseInt(env, number, argv[PARAM0]); AsyncModuleUsageRecordsCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncModuleUsageRecordsCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, .number = number }; if (asyncCallbackInfo == nullptr) { @@ -3535,7 +3557,7 @@ static bool InnerRegisterPermissionsChanged(napi_env env, const std::vector uids; ParseInt32Array(env, uids, argv[ARGS_SIZE_ONE]); AsyncRegisterPermissions *asyncCallbackInfo = new (std::nothrow) AsyncRegisterPermissions { - .env = env, - .asyncWork = nullptr, + .env = env, + .asyncWork = nullptr, .uids = uids }; if (asyncCallbackInfo == nullptr) { @@ -3610,7 +3632,7 @@ napi_value RegisterAllPermissionsChanged(napi_env env, napi_callback_info info) return result; } else if (permissionEvent == ANY_PERMISSION_CHANGE && argc == ARGS_SIZE_TWO) { AsyncRegisterAllPermissions *asyncCallbackInfo = new (std::nothrow) AsyncRegisterAllPermissions { - .env = env, + .env = env, .asyncWork = nullptr }; if (asyncCallbackInfo == nullptr) { @@ -3795,8 +3817,8 @@ napi_value UnregisterPermissionsChanged(napi_env env, napi_callback_info info) std::vector uids; ParseInt32Array(env, uids, argv[ARGS_SIZE_ONE]); AsyncUnregisterPermissions *asyncCallbackInfo = new AsyncUnregisterPermissions { - .env = env, - .asyncWork = nullptr, + .env = env, + .asyncWork = nullptr, .uids = uids }; if (asyncCallbackInfo == nullptr) { @@ -3884,10 +3906,10 @@ napi_value CheckPermission(napi_env env, napi_callback_info info) ParseString(env, permission, argv[PARAM1]); AsyncPermissionCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncPermissionCallbackInfo { - .env = env, - .asyncWork = nullptr, - .deferred = nullptr, - .bundleName = bundleName, + .env = env, + .asyncWork = nullptr, + .deferred = nullptr, + .bundleName = bundleName, .permission = permission }; if (asyncCallbackInfo == nullptr) { diff --git a/services/appmgr/include/ams_mgr_scheduler.h b/services/appmgr/include/ams_mgr_scheduler.h index a384d99f36..ff5b5998cb 100644 --- a/services/appmgr/include/ams_mgr_scheduler.h +++ b/services/appmgr/include/ams_mgr_scheduler.h @@ -116,6 +116,8 @@ public: virtual void AbilityAttachTimeOut(const sptr &token) override; + virtual void PrepareTerminate(const sptr &token) override; + /** * Checks whether a specified permission has been granted to the process identified by pid and uid * diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 9bda97a256..9cdce9a6e2 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -437,6 +437,8 @@ public: void HandleAbilityAttachTimeOut(const sptr &token); + void PrepareTerminate(const sptr &token); + /** * Checks whether a specified permission has been granted to the process identified by pid and uid * diff --git a/services/appmgr/include/app_running_manager.h b/services/appmgr/include/app_running_manager.h index 4299d82896..2fa13a8463 100644 --- a/services/appmgr/include/app_running_manager.h +++ b/services/appmgr/include/app_running_manager.h @@ -123,6 +123,8 @@ public: void TerminateAbility(const sptr &token); bool GetPidsByBundleName(const std::string &bundleName, std::list &pids); + void PrepareTerminate(const sptr &token); + std::shared_ptr GetTerminatingAppRunningRecord(const sptr &abilityToken); private: diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index 2dba594b61..c9133e8cea 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -142,6 +142,17 @@ void AmsMgrScheduler::AbilityAttachTimeOut(const sptr &token) APP_LOGI("AmsMgrScheduler AttachTimeOut end"); } +void AmsMgrScheduler::PrepareTerminate(const sptr &token) +{ + APP_LOGI("AmsMgrScheduler PrepareTerminate begin"); + if (!IsReady()) { + return; + } + auto task = [=]() { amsMgrServiceInner_->PrepareTerminate(token); }; + amsHandler_->PostTask(task); + APP_LOGI("AmsMgrScheduler PrepareTerminate end"); +} + int32_t AmsMgrScheduler::KillApplication(const std::string &bundleName) { if (!IsReady()) { diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index caeb2756c7..573b8ecba3 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1106,6 +1106,16 @@ void AppMgrServiceInner::HandleAbilityAttachTimeOut(const sptr &t appRunningManager_->HandleAbilityAttachTimeOut(token); } +void AppMgrServiceInner::PrepareTerminate(const sptr &token) +{ + APP_LOGI("%{public}s called", __func__); + if (!appRunningManager_) { + APP_LOGE("appRunningManager_ is nullptr"); + return; + } + appRunningManager_->PrepareTerminate(token); +} + void AppMgrServiceInner::HandleTerminateApplicationTimeOut(const int64_t eventId) { APP_LOGI("%{public}s called", __func__); diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index 74c987f3a6..a5def2ce81 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -261,6 +261,26 @@ void AppRunningManager::HandleAbilityAttachTimeOut(const sptr &to appRecord->TerminateAbility(token, true); } + +void AppRunningManager::PrepareTerminate(const sptr &token) +{ + APP_LOGI("%{public}s, called", __func__); + if (token == nullptr) { + APP_LOGE("%{public}s, token is nullptr", __func__); + return; + } + + auto appRecord = GetAppRunningRecordByAbilityToken(token); + if (!appRecord) { + APP_LOGE("%{public}s, appRecord is nullptr", __func__); + return; + } + + if (appRecord->IsLastAbilityRecord(token)) { + appRecord->SetTerminating(); + } +} + void AppRunningManager::TerminateAbility(const sptr &token) { APP_LOGI("%{public}s, called", __func__); diff --git a/services/appmgr/src/lmks/lmks_utils.cpp b/services/appmgr/src/lmks/lmks_utils.cpp index 93c5042b5f..f275a2af5b 100644 --- a/services/appmgr/src/lmks/lmks_utils.cpp +++ b/services/appmgr/src/lmks/lmks_utils.cpp @@ -159,8 +159,7 @@ int LmksUtils::GetProcSize(pid_t pid) return -1; } - if ((strlen(line) + 1 <= PROC_LINE_MAX && strlen(line) != 0 && line[strlen(line)] == '\0') && - (sscanf_s(line, "%d %d ", &total, &rss) > 0)) { + if ((strlen(line) + 1 <= PROC_LINE_MAX && strlen(line) != 0) && (sscanf_s(line, "%d %d ", &total, &rss) > 0)) { HiLog::Info(LABEL, "pid %{public}d total %{public}d rss %{public}d", pid, total, rss); } else { HiLog::Error(LABEL, "strlen or sscanf_s err %{public}s", strerror(errno)); diff --git a/services/appmgr/test/mock/include/mock_ams_mgr_scheduler.h b/services/appmgr/test/mock/include/mock_ams_mgr_scheduler.h index 2b5aaeeb47..efc8412e86 100644 --- a/services/appmgr/test/mock/include/mock_ams_mgr_scheduler.h +++ b/services/appmgr/test/mock/include/mock_ams_mgr_scheduler.h @@ -36,6 +36,7 @@ public: MOCK_METHOD1(KillApplication, int32_t(const std::string &bundleName)); MOCK_METHOD0(IsReady, bool()); MOCK_METHOD1(AbilityAttachTimeOut, void(const sptr &token)); + MOCK_METHOD1(PrepareTerminate, void(const sptr &token)); MOCK_METHOD4(CompelVerifyPermission, int(const std::string &permission, int pid, int uid, std::string &message)); MockAmsMgrScheduler() : AmsMgrStub(){}; virtual ~MockAmsMgrScheduler(){}; diff --git a/services/appmgr/test/mock/include/mock_bundle_manager.h b/services/appmgr/test/mock/include/mock_bundle_manager.h index abe52439ea..f027e7bf10 100644 --- a/services/appmgr/test/mock/include/mock_bundle_manager.h +++ b/services/appmgr/test/mock/include/mock_bundle_manager.h @@ -61,6 +61,10 @@ public: { return true; }; + virtual bool QueryAbilityInfosForClone(const Want &want, std::vector &abilityInfos) override + { + return true; + }; virtual bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo) override { return true; @@ -226,6 +230,10 @@ public: { return true; }; + virtual bool QueryAbilityInfosForClone(const Want &want, std::vector &abilityInfos) override + { + return true; + }; virtual bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo) override; virtual bool GetBundleInfos(const BundleFlag flag, std::vector &bundleInfos) override { diff --git a/services/bundlemgr/include/bundle_data_mgr.h b/services/bundlemgr/include/bundle_data_mgr.h index 7f78b68d15..01af48fb4d 100755 --- a/services/bundlemgr/include/bundle_data_mgr.h +++ b/services/bundlemgr/include/bundle_data_mgr.h @@ -131,6 +131,13 @@ public: * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. */ bool QueryAbilityInfos(const Want &want, std::vector &abilityInfo) const; + /** + * @brief Query a AbilityInfo of list for clone by the given Want. + * @param want Indicates the information of the ability. + * @param abilityInfo Indicates the obtained AbilityInfo of list. + * @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise. + */ + bool QueryAbilityInfosForClone(const Want &want, std::vector &abilityInfo) const; /** * @brief Query the AbilityInfo by ability.uri in config.json. * @param abilityUri Indicates the uri of the ability. diff --git a/services/bundlemgr/include/bundle_mgr_host_impl.h b/services/bundlemgr/include/bundle_mgr_host_impl.h index 8c2b84b3af..393bcfd0a5 100644 --- a/services/bundlemgr/include/bundle_mgr_host_impl.h +++ b/services/bundlemgr/include/bundle_mgr_host_impl.h @@ -115,6 +115,13 @@ public: * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. */ virtual bool QueryAbilityInfos(const Want &want, std::vector &abilityInfos) override; + /** + * @brief Query the AbilityInfo of list for clone by the given Want. + * @param want Indicates the information of the ability. + * @param abilityInfos Indicates the obtained AbilityInfos object. + * @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise. + */ + virtual bool QueryAbilityInfosForClone(const Want &want, std::vector &abilityInfos) override; /** * @brief Query the AbilityInfo by ability.uri in config.json. * @param abilityUri Indicates the uri of the ability. diff --git a/services/bundlemgr/include/bundle_util.h b/services/bundlemgr/include/bundle_util.h index a1996661f4..5189a28b18 100644 --- a/services/bundlemgr/include/bundle_util.h +++ b/services/bundlemgr/include/bundle_util.h @@ -49,7 +49,7 @@ public: * @param fileName Indicates the file path. * @return Returns true if the file size checked successfully; returns false otherwise. */ - static bool CheckFileSize(const std::string &bundlePath, const int32_t fileSize); + static bool CheckFileSize(const std::string &bundlePath, const int64_t fileSize); }; } // namespace AppExecFwk diff --git a/services/bundlemgr/include/common_profile.h b/services/bundlemgr/include/common_profile.h index a5a659e0c8..1f6adc16f1 100644 --- a/services/bundlemgr/include/common_profile.h +++ b/services/bundlemgr/include/common_profile.h @@ -196,6 +196,7 @@ const std::string BUNDLE_MODULE_PROFILE_FORMS_JS_COMPONENT_NAME = "jsComponentNa const std::string BUNDLE_MODULE_PROFILE_FORMS_VALUE = "value"; const std::string BUNDLE_MODULE_PROFILE_FORMS_FORM_CONFIG_ABILITY = "formConfigAbility"; const std::string BUNDLE_MODULE_PROFILE_FORMS_FORM_VISIBLE_NOTIFY = "formEnabled"; +const std::string BUNDLE_MODULE_PROFILE_FORMS_LAYOUT = "layout"; // sub BUNDLE_MODULE_PROFILE_KEY_JS const std::string BUNDLE_MODULE_PROFILE_KEY_PAGES = "pages"; const std::string BUNDLE_MODULE_PROFILE_KEY_WINDOW = "window"; diff --git a/services/bundlemgr/include/inner_bundle_info.h b/services/bundlemgr/include/inner_bundle_info.h index de34790d82..eaa5e972e1 100644 --- a/services/bundlemgr/include/inner_bundle_info.h +++ b/services/bundlemgr/include/inner_bundle_info.h @@ -114,7 +114,7 @@ enum class ArrayType { NOT_ARRAY, }; -template +template void CheckArrayType( const nlohmann::json &jsonObject, const std::string &key, dataType &data, ArrayType arrayType, int32_t &parseResult) { @@ -167,7 +167,7 @@ void CheckArrayType( } } -template +template void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail::iter_impl &end, const std::string &key, dataType &data, JsonType jsonType, bool isNecessary, int32_t &parseResult, ArrayType arrayType) @@ -297,11 +297,19 @@ public: */ std::optional FindAbilityInfo(const std::string &bundleName, const std::string &abilityName) const; /** - * @brief Find abilityInfo of list by bundle name. + * @brief Find abilityInfo of list by bundle name. * @param bundleName Indicates the bundle name. * @return Returns the AbilityInfo of list if find it; returns null otherwise. */ std::optional> FindAbilityInfos(const std::string &bundleName) const; + /** + * @brief Find abilityInfo of list for clone by bundle name and ability name. + * @param bundleName Indicates the bundle name. + * @param abilityName Indicates the ability name + * @return Returns the AbilityInfo of list if find it; returns null otherwise. + */ + std::optional> FindAbilityInfosForClone( + const std::string &bundleName, const std::string &abilityName) const; /** * @brief Transform the InnerBundleInfo object to string. * @return Returns the string object diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 9c080158d9..9e916e69a9 100755 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -353,6 +353,49 @@ bool BundleDataMgr::QueryAbilityInfos(const Want &want, std::vector return true; } +bool BundleDataMgr::QueryAbilityInfosForClone(const Want &want, std::vector &abilityInfo) const +{ + ElementName element = want.GetElement(); + std::string abilityName = element.GetAbilityName(); + std::string bundleName = element.GetBundleName(); + APP_LOGI("bundle name:%{public}s, ability name:%{public}s", bundleName.c_str(), abilityName.c_str()); + + std::string keyName = bundleName + abilityName; + APP_LOGI("ability, name:%{public}s", keyName.c_str()); + std::lock_guard lock(bundleInfoMutex_); + if (bundleInfos_.empty()) { + APP_LOGI("bundleInfos_ is empty"); + return false; + } + auto item = bundleInfos_.find(bundleName); + if (item == bundleInfos_.end()) { + APP_LOGI("bundle:%{public}s not find", bundleName.c_str()); + return false; + } + + auto infoWithIdItem = item->second.find(Constants::CURRENT_DEVICE_ID); + if (infoWithIdItem == item->second.end()) { + APP_LOGI("bundle:%{public}s device id not find", bundleName.c_str()); + return false; + } + if (infoWithIdItem->second.IsDisabled()) { + APP_LOGI("app %{public}s is disabled", infoWithIdItem->second.GetBundleName().c_str()); + return false; + } + auto ability = infoWithIdItem->second.FindAbilityInfosForClone(bundleName, abilityName); + if (!ability) { + APP_LOGE("ability:%{public}s not find", keyName.c_str()); + return false; + } + abilityInfo = (*ability); + for (auto &ability : abilityInfo) { + infoWithIdItem->second.GetApplicationInfo( + ApplicationFlag::GET_APPLICATION_INFO_WITH_PERMS, 0, ability.applicationInfo); + } + + return true; +} + bool BundleDataMgr::QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) const { APP_LOGI("abilityUri is %{public}s", abilityUri.c_str()); @@ -1420,6 +1463,9 @@ bool BundleDataMgr::GetFormsInfoByModule( return false; } innerBundleInfo->second.GetFormsInfoByModule(moduleName, formInfos); + if (formInfos.empty()) { + return false; + } APP_LOGE("module forminfo find success"); return true; } diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 03c8fed2c3..c19a9ecea9 100755 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -150,6 +150,16 @@ bool BundleMgrHostImpl::QueryAbilityInfos(const Want &want, std::vectorQueryAbilityInfos(want, abilityInfos); } +bool BundleMgrHostImpl::QueryAbilityInfosForClone(const Want &want, std::vector &abilityInfos) +{ + auto dataMgr = GetDataMgrFromService(); + if (dataMgr == nullptr) { + APP_LOGE("DataMgr is nullptr"); + return false; + } + return dataMgr->QueryAbilityInfosForClone(want, abilityInfos); +} + bool BundleMgrHostImpl::QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) { auto dataMgr = GetDataMgrFromService(); diff --git a/services/bundlemgr/src/bundle_profile.cpp b/services/bundlemgr/src/bundle_profile.cpp index 472576be4b..ba06e00128 100644 --- a/services/bundlemgr/src/bundle_profile.cpp +++ b/services/bundlemgr/src/bundle_profile.cpp @@ -153,12 +153,19 @@ struct FormsMetaData { std::vector customizeData; }; +struct Window { + int32_t designWidth = 750; + bool autoDesignWidth = false; +}; + struct Forms { std::string name; std::string description; int32_t descriptionId = 0; bool isDefault = false; std::string type; + std::string layout; + Window window; std::string colorMode = "auto"; std::vector supportDimensions; std::string defaultDimension; @@ -242,11 +249,6 @@ struct Ability { std::vector formses; }; -struct Window { - int32_t designWidth = 750; - bool autoDesignWidth = false; -}; - struct Js { std::string name = "default"; std::vector pages; @@ -876,6 +878,28 @@ void from_json(const nlohmann::json &jsonObject, FormsMetaData &formsMetaData) ArrayType::OBJECT); } +void from_json(const nlohmann::json &jsonObject, Window &window) +{ + // these are not required fields. + const auto &jsonObjectEnd = jsonObject.end(); + GetValueIfFindKey(jsonObject, + jsonObjectEnd, + BUNDLE_MODULE_PROFILE_KEY_DESIGN_WIDTH, + window.designWidth, + JsonType::NUMBER, + false, + parseResult, + ArrayType::NOT_ARRAY); + GetValueIfFindKey(jsonObject, + jsonObjectEnd, + BUNDLE_MODULE_PROFILE_KEY_AUTO_DESIGN_WIDTH, + window.autoDesignWidth, + JsonType::BOOLEAN, + false, + parseResult, + ArrayType::NOT_ARRAY); +} + void from_json(const nlohmann::json &jsonObject, Forms &forms) { // these are required fields. @@ -904,6 +928,22 @@ void from_json(const nlohmann::json &jsonObject, Forms &forms) true, parseResult, ArrayType::NOT_ARRAY); + GetValueIfFindKey(jsonObject, + jsonObjectEnd, + BUNDLE_MODULE_PROFILE_FORMS_LAYOUT, + forms.layout, + JsonType::STRING, + false, + parseResult, + ArrayType::NOT_ARRAY); + GetValueIfFindKey(jsonObject, + jsonObjectEnd, + BUNDLE_MODULE_PROFILE_KEY_WINDOW, + forms.window, + JsonType::OBJECT, + false, + parseResult, + ArrayType::NOT_ARRAY); GetValueIfFindKey>(jsonObject, jsonObjectEnd, BUNDLE_MODULE_PROFILE_FORMS_SUPPORT_DIMENSIONS, @@ -1344,28 +1384,6 @@ void from_json(const nlohmann::json &jsonObject, Ability &ability) ArrayType::OBJECT); } -void from_json(const nlohmann::json &jsonObject, Window &window) -{ - // these are not required fields. - const auto &jsonObjectEnd = jsonObject.end(); - GetValueIfFindKey(jsonObject, - jsonObjectEnd, - BUNDLE_MODULE_PROFILE_KEY_DESIGN_WIDTH, - window.designWidth, - JsonType::NUMBER, - false, - parseResult, - ArrayType::NOT_ARRAY); - GetValueIfFindKey(jsonObject, - jsonObjectEnd, - BUNDLE_MODULE_PROFILE_KEY_AUTO_DESIGN_WIDTH, - window.autoDesignWidth, - JsonType::BOOLEAN, - false, - parseResult, - ArrayType::NOT_ARRAY); -} - void from_json(const nlohmann::json &jsonObject, Js &js) { // these are required fields. @@ -1775,53 +1793,56 @@ uint32_t GetFormEntity(const std::vector &formEntity) return formEntityInBinary; } -bool ConvertFormInfo(FormInfo &forminfos, const ProfileReader::Forms &form) +bool ConvertFormInfo(FormInfo &formInfo, const ProfileReader::Forms &form) { - forminfos.name = form.name; - forminfos.description = form.description; - forminfos.descriptionId = form.descriptionId; - forminfos.formConfigAbility = form.formConfigAbility; - forminfos.formVisibleNotify = form.formVisibleNotify; - forminfos.deepLink = form.deepLink; - forminfos.defaultFlag = form.isDefault; + formInfo.name = form.name; + formInfo.description = form.description; + formInfo.descriptionId = form.descriptionId; + formInfo.formConfigAbility = form.formConfigAbility; + formInfo.formVisibleNotify = form.formVisibleNotify; + formInfo.deepLink = form.deepLink; + formInfo.defaultFlag = form.isDefault; auto type = std::find_if(std::begin(ProfileReader::formTypeMap), std::end(ProfileReader::formTypeMap), [&form](const auto &item) { return item.first == form.type; }); if (type != ProfileReader::formTypeMap.end()) { - forminfos.type = type->second; + formInfo.type = type->second; } auto colorMode = std::find_if(std::begin(ProfileReader::formColorModeMap), std::end(ProfileReader::formColorModeMap), [&form](const auto &item) { return item.first == form.colorMode; }); if (colorMode != ProfileReader::formColorModeMap.end()) { - forminfos.colorMode = colorMode->second; + formInfo.colorMode = colorMode->second; } - forminfos.updateEnabled = form.updateEnabled; - forminfos.scheduledUpateTime = form.scheduledUpateTime; - forminfos.updateDuration = form.updateDuration; - forminfos.jsComponentName = form.jsComponentName; + formInfo.updateEnabled = form.updateEnabled; + formInfo.scheduledUpateTime = form.scheduledUpateTime; + formInfo.updateDuration = form.updateDuration; + formInfo.jsComponentName = form.jsComponentName; for (auto &data : form.metaData.customizeData) { FormCustomizeData customizeData; customizeData.name = data.name; customizeData.value = data.value; - forminfos.customizeDatas.emplace_back(customizeData); + formInfo.customizeDatas.emplace_back(customizeData); } for (const auto &dimensions : form.supportDimensions) { auto dimension = std::find_if(std::begin(ProfileReader::dimensionMap), std::end(ProfileReader::dimensionMap), [&dimensions](const auto &item) { return item.first == dimensions; }); if (dimension != ProfileReader::dimensionMap.end()) { - forminfos.supportDimensions.emplace_back(dimension->second); + formInfo.supportDimensions.emplace_back(dimension->second); } } auto dimension = std::find_if(std::begin(ProfileReader::dimensionMap), std::end(ProfileReader::dimensionMap), [&form](const auto &item) { return item.first == form.defaultDimension; }); if (dimension != ProfileReader::dimensionMap.end()) { - forminfos.defaultDimension = dimension->second; + formInfo.defaultDimension = dimension->second; } - forminfos.landscapeLayouts = form.landscapeLayouts; - forminfos.portraitLayouts = form.portraitLayouts; + formInfo.landscapeLayouts = form.landscapeLayouts; + formInfo.portraitLayouts = form.portraitLayouts; + formInfo.layout = form.layout; + formInfo.window.autoDesignWidth = form.window.autoDesignWidth; + formInfo.window.designWidth = form.window.designWidth; return true; } diff --git a/services/bundlemgr/src/bundle_util.cpp b/services/bundlemgr/src/bundle_util.cpp index e9e2476ed1..ef7610ae15 100644 --- a/services/bundlemgr/src/bundle_util.cpp +++ b/services/bundlemgr/src/bundle_util.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "string_ex.h" #include "directory_ex.h" @@ -45,7 +46,7 @@ ErrCode BundleUtil::CheckFilePath(const std::string &bundlePath, std::string &re return ERR_APPEXECFWK_INSTALL_INVALID_BUNDLE_FILE; } if (!CheckFileSize(realPath, Constants::MAX_HAP_SIZE)) { - APP_LOGE("file size is larger than max size Max size is: %{public}d", Constants::MAX_HAP_SIZE); + APP_LOGE("file size is larger than max hap size Max size is: %{public}" PRId64, Constants::MAX_HAP_SIZE); return ERR_APPEXECFWK_INSTALL_INVALID_HAP_SIZE; } return ERR_OK; @@ -81,9 +82,9 @@ bool BundleUtil::CheckFileName(const std::string &fileName) return true; } -bool BundleUtil::CheckFileSize(const std::string &bundlePath, const int32_t fileSize) +bool BundleUtil::CheckFileSize(const std::string &bundlePath, const int64_t fileSize) { - struct stat fileInfo = { 0 }; + struct stat fileInfo = {0}; if (stat(bundlePath.c_str(), &fileInfo) != 0) { APP_LOGE("call stat error"); return false; diff --git a/services/bundlemgr/src/inner_bundle_info.cpp b/services/bundlemgr/src/inner_bundle_info.cpp index 787ac25d6e..765a43e602 100644 --- a/services/bundlemgr/src/inner_bundle_info.cpp +++ b/services/bundlemgr/src/inner_bundle_info.cpp @@ -800,6 +800,27 @@ std::optional> InnerBundleInfo::FindAbilityInfos(const return std::nullopt; } +std::optional> InnerBundleInfo::FindAbilityInfosForClone( + const std::string &bundleName, const std::string &abilityName) const +{ + std::vector abilitys; + + if (bundleName.empty()) { + return std::nullopt; + } + + for (const auto &ability : baseAbilityInfos_) { + if ((ability.second.bundleName == bundleName && (ability.second.name == abilityName))) { + abilitys.emplace_back(ability.second); + } + } + if (!abilitys.empty()) { + return abilitys; + } + + return std::nullopt; +} + bool InnerBundleInfo::AddModuleInfo(const InnerBundleInfo &newInfo) { if (newInfo.currentPackage_.empty()) { diff --git a/services/bundlemgr/test/mock/include/mock_ability_mgr_host.h b/services/bundlemgr/test/mock/include/mock_ability_mgr_host.h index df955fb472..221c07b239 100644 --- a/services/bundlemgr/test/mock/include/mock_ability_mgr_host.h +++ b/services/bundlemgr/test/mock/include/mock_ability_mgr_host.h @@ -248,7 +248,7 @@ public: { return 0; } - int MoveMissionToSplitScreenStack(const MissionOption &missionOption) override + int MoveMissionToSplitScreenStack(const MissionOption &primary, const MissionOption &secondary) override { return 0; } diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp index 967887d6b1..9f7f808360 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_kit_service_test.cpp @@ -124,6 +124,8 @@ const std::string FORM_PORTRAIT_LAYOUTS1 = "port1"; const std::string FORM_PORTRAIT_LAYOUTS2 = "port2"; const std::string FORM_LANDSCAPE_LAYOUTS1 = "land1"; const std::string FORM_LANDSCAPE_LAYOUTS2 = "land2"; +const std::string FORM_LAYOUT = "page/card/index"; +constexpr int32_t FORM_JS_WINDOW_DESIGNWIDTH = 720; const std::string SHORTCUT_TEST_ID = "shortcutTestId"; const std::string SHORTCUT_DEMO_ID = "shortcutDemoId"; const std::string SHORTCUT_HOST_ABILITY = "hostAbility"; @@ -163,6 +165,8 @@ public: const std::string &bundleName, const uint32_t permissionSize, const ApplicationInfo &appInfo) const; void CheckAbilityInfo( const std::string &bundleName, const std::string &abilityName, const AbilityInfo &appInfo) const; + void CheckAbilityInfos( + const std::string &bundleName, const std::string &abilityName, const std::vector &appInfo) const; void CheckCompatibleApplicationInfo( const std::string &bundleName, const uint32_t permissionSize, const CompatibleApplicationInfo &appInfo) const; void CheckCompatibleAbilityInfo( @@ -247,23 +251,23 @@ void BmsBundleKitServiceTest::MockInstallBundle( moduleInfo.colorMode = COLOR_MODE; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; moduleInfo.metaData = metaData; @@ -279,12 +283,12 @@ void BmsBundleKitServiceTest::MockInstallBundle( // for launch ability if (bundleName == BUNDLE_NAME_TEST) { AppExecFwk::SkillUri uri { - URI_SCHEME, + URI_SCHEME, URI_HOST }; Skill skill { - {ACTION}, - {ENTITY}, + {ACTION}, + {ENTITY}, {uri} }; std::vector skills; @@ -340,6 +344,9 @@ FormInfo BmsBundleKitServiceTest::MockFormInfo( formInfo.scheduledUpateTime = FORM_SCHEDULED_UPDATE_TIME; formInfo.updateEnabled = true; formInfo.jsComponentName = FORM_JS_COMPONENT_NAME; + formInfo.layout = FORM_LAYOUT; + formInfo.window.autoDesignWidth = true; + formInfo.window.designWidth = FORM_JS_WINDOW_DESIGNWIDTH; for (auto &info : formInfo.customizeDatas) { info.name = FORM_CUSTOMIZE_DATAS_NAME; info.value = FORM_CUSTOMIZE_DATAS_VALUE; @@ -408,23 +415,23 @@ AbilityInfo BmsBundleKitServiceTest::MockAbilityInfo( abilityInfo.supportPipMode = false; abilityInfo.targetAbility = TARGET_ABILITY; AppExecFwk::Parameters parameters { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::Results results { - "description", - "name", + "description", + "name", "type" }; AppExecFwk::CustomizeData customizeData { - "name", - "value", + "name", + "value", "extra" }; MetaData metaData { - {parameters}, - {results}, + {parameters}, + {results}, {customizeData} }; abilityInfo.metaData = metaData; @@ -543,6 +550,46 @@ void BmsBundleKitServiceTest::CheckAbilityInfo( } } +void BmsBundleKitServiceTest::CheckAbilityInfos( + const std::string &bundleName, const std::string &abilityName, const std::vector &abilityInfos) const +{ + for (auto abilityInfo : abilityInfos) + { + EXPECT_EQ(abilityName, abilityInfo.name); + EXPECT_EQ(bundleName, abilityInfo.bundleName); + EXPECT_EQ(LABEL, abilityInfo.label); + EXPECT_EQ(DESCRIPTION, abilityInfo.description); + EXPECT_EQ(DEVICE_ID, abilityInfo.deviceId); + EXPECT_EQ(THEME, abilityInfo.theme); + EXPECT_EQ(ICON_PATH, abilityInfo.iconPath); + EXPECT_EQ(CODE_PATH, abilityInfo.codePath); + EXPECT_EQ(ORIENTATION, abilityInfo.orientation); + EXPECT_EQ(LAUNCH_MODE, abilityInfo.launchMode); + EXPECT_EQ(URI, abilityInfo.uri); + EXPECT_EQ(false, abilityInfo.supportPipMode); + EXPECT_EQ(TARGET_ABILITY, abilityInfo.targetAbility); + EXPECT_EQ(CONFIG_CHANGES, abilityInfo.configChanges); + EXPECT_EQ(FORM_ENTITY, abilityInfo.formEntity); + EXPECT_EQ(DEFAULT_FORM_HEIGHT, abilityInfo.defaultFormHeight); + EXPECT_EQ(DEFAULT_FORM_WIDTH, abilityInfo.defaultFormWidth); + for (auto &info : abilityInfo.metaData.customizeData) { + EXPECT_EQ(info.name, META_DATA_NAME); + EXPECT_EQ(info.value, META_DATA_VALUE); + EXPECT_EQ(info.extra, META_DATA_EXTRA); + } + for (auto &info : abilityInfo.metaData.parameters) { + EXPECT_EQ(info.description, META_DATA_DESCRIPTION); + EXPECT_EQ(info.name, META_DATA_NAME); + EXPECT_EQ(info.type, META_DATA_TYPE); + } + for (auto &info : abilityInfo.metaData.results) { + EXPECT_EQ(info.description, META_DATA_DESCRIPTION); + EXPECT_EQ(info.name, META_DATA_NAME); + EXPECT_EQ(info.type, META_DATA_TYPE); + } + } +} + void BmsBundleKitServiceTest::CheckCompatibleAbilityInfo( const std::string &bundleName, const std::string &abilityName, const CompatibleAbilityInfo &abilityInfo) const { @@ -719,6 +766,9 @@ void BmsBundleKitServiceTest::CheckFormInfoTest(const std::vector &for EXPECT_EQ(info.name, FORM_CUSTOMIZE_DATAS_NAME); EXPECT_EQ(info.value, FORM_CUSTOMIZE_DATAS_VALUE); } + EXPECT_EQ(formInfo.layout, FORM_LAYOUT); + EXPECT_EQ(formInfo.window.designWidth, FORM_JS_WINDOW_DESIGNWIDTH); + EXPECT_EQ(formInfo.window.autoDesignWidth, true); } } @@ -745,6 +795,8 @@ void BmsBundleKitServiceTest::CheckFormInfoDemo(const std::vector &for EXPECT_EQ(formInfo.scheduledUpateTime, FORM_SCHEDULED_UPDATE_TIME); EXPECT_EQ(formInfo.jsComponentName, FORM_JS_COMPONENT_NAME); EXPECT_EQ(formInfo.updateEnabled, true); + EXPECT_EQ(formInfo.layout, FORM_LAYOUT); + EXPECT_EQ(formInfo.window.designWidth, FORM_JS_WINDOW_DESIGNWIDTH); for (auto &info : formInfo.customizeDatas) { EXPECT_EQ(info.name, FORM_CUSTOMIZE_DATAS_NAME); EXPECT_EQ(info.value, FORM_CUSTOMIZE_DATAS_VALUE); @@ -1219,6 +1271,116 @@ HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfo_0300, Function | SmallTest | EXPECT_EQ(false, testRet); } +/** + * @tc.number: QueryAbilityInfos_0100 + * @tc.name: test can get the ability info of list by want + * @tc.desc: 1.system run normally + * 2.get ability info successfully + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfos_0100, Function | SmallTest | Level1) +{ + MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); + Want want; + want.SetElementName(BUNDLE_NAME_TEST, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfos(want, result); + EXPECT_EQ(true, testRet); + CheckAbilityInfos(BUNDLE_NAME_TEST, ABILITY_NAME_TEST, result); + + MockUninstallBundle(BUNDLE_NAME_TEST); +} + +/** + * @tc.number: QueryAbilityInfos_0200 + * @tc.name: test can not get the ability info by want in which bundle name is wrong + * @tc.desc: 1.system run normally + * 2.get ability info failed + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfos_0200, Function | SmallTest | Level1) +{ + MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); + + Want want; + want.SetElementName(BUNDLE_NAME_DEMO, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfos(want, result); + EXPECT_EQ(false, testRet); + + MockUninstallBundle(BUNDLE_NAME_TEST); +} + +/** + * @tc.number: QueryAbilityInfos_0300 + * @tc.name: test can not get the ability info by want which bundle doesn't exist + * @tc.desc: 1.system run normally + * 2.get ability info failed + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfos_0300, Function | SmallTest | Level1) +{ + Want want; + want.SetElementName(BUNDLE_NAME_TEST, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfos(want, result); + EXPECT_EQ(false, testRet); +} + +/** + * @tc.number: QueryAbilityInfosForClone_0100 + * @tc.name: test can get the ability info of list by want + * @tc.desc: 1.system run normally + * 2.get ability info successfully + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfosForClone_0100, Function | SmallTest | Level1) +{ + MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); + Want want; + want.SetElementName(BUNDLE_NAME_TEST, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfosForClone(want, result); + EXPECT_EQ(true, testRet); + CheckAbilityInfos(BUNDLE_NAME_TEST, ABILITY_NAME_TEST, result); + + MockUninstallBundle(BUNDLE_NAME_TEST); +} + +/** + * @tc.number: QueryAbilityInfosForClone_0200 + * @tc.name: test can not get the ability info by want in which element name is wrong + * @tc.desc: 1.system run normally + * 2.get ability info failed + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfosForClone_0200, Function | SmallTest | Level1) +{ + MockInstallBundle(BUNDLE_NAME_TEST, MODULE_NAME_TEST, ABILITY_NAME_TEST); + + Want want; + want.SetElementName(BUNDLE_NAME_DEMO, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfosForClone(want, result); + EXPECT_EQ(false, testRet); + + want.SetElementName(BUNDLE_NAME_TEST, ABILITY_NAME_DEMO); + testRet = GetBundleDataMgr()->QueryAbilityInfosForClone(want, result); + EXPECT_EQ(false, testRet); + + MockUninstallBundle(BUNDLE_NAME_TEST); +} + +/** + * @tc.number: QueryAbilityInfosForClone_0300 + * @tc.name: test can not get the ability info by want which bundle doesn't exist + * @tc.desc: 1.system run normally + * 2.get ability info failed + */ +HWTEST_F(BmsBundleKitServiceTest, QueryAbilityInfosForClone_0300, Function | SmallTest | Level1) +{ + Want want; + want.SetElementName(BUNDLE_NAME_TEST, ABILITY_NAME_TEST); + std::vector result; + bool testRet = GetBundleDataMgr()->QueryAbilityInfosForClone(want, result); + EXPECT_EQ(false, testRet); +} + /** * @tc.number: GetLaunchWantForBundle_0100 * @tc.name: test can get the launch want of a bundle diff --git a/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp index f00af36b41..29bb58494c 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp @@ -118,6 +118,11 @@ const nlohmann::json CONFIG_JSON = R"( "portraitLayouts": [ "$layout:ability_form" ], + "layout": "pages/card/index", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, "formVisibleNotify": true, "deepLink": "ability://com.example.myapplication.fa/.MainAbility", "formConfigAbility": "ability://com.example.myapplication.fa/.MainAbility", diff --git a/services/formmgr/src/form_refresh_limiter.cpp b/services/formmgr/src/form_refresh_limiter.cpp index 4b5fb29285..0cca52ee9e 100644 --- a/services/formmgr/src/form_refresh_limiter.cpp +++ b/services/formmgr/src/form_refresh_limiter.cpp @@ -194,4 +194,4 @@ int FormRefreshLimiter::GetItemCount() const return limiterMap_.size(); } } // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/formmgr/src/form_sys_event_receiver.cpp b/services/formmgr/src/form_sys_event_receiver.cpp index 0311b31535..c969bf47e9 100644 --- a/services/formmgr/src/form_sys_event_receiver.cpp +++ b/services/formmgr/src/form_sys_event_receiver.cpp @@ -482,4 +482,4 @@ void FormSysEventReceiver::HandleTimerUpdate(const int64_t formId, FormTimerMgr::GetInstance().UpdateFormTimer(formId, type, timerCfg); } } // namespace AppExecFwk -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/formmgr/test/BUILD.gn b/services/formmgr/test/BUILD.gn index 8087cc0fd0..5ab060b450 100644 --- a/services/formmgr/test/BUILD.gn +++ b/services/formmgr/test/BUILD.gn @@ -43,8 +43,24 @@ group("unittest") { deps = [ "unittest/fms_form_cache_mgr_test:unittest", + "unittest/fms_form_data_mgr_test:unittest", "unittest/fms_form_db_record_test:unittest", "unittest/fms_form_host_record_test:unittest", + "unittest/fms_form_mgr_add_form_test:unittest", + "unittest/fms_form_mgr_cast_temp_form_test:unittest", + "unittest/fms_form_mgr_death_callback_test:unittest", + "unittest/fms_form_mgr_delete_form_test:unittest", + "unittest/fms_form_mgr_lifecycle_update_test:unittest", + "unittest/fms_form_mgr_message_event_test:unittest", + "unittest/fms_form_mgr_notify_invisible_forms_test:unittest", + "unittest/fms_form_mgr_notify_visible_forms_test:unittest", + "unittest/fms_form_mgr_release_form_test:unittest", + "unittest/fms_form_mgr_request_form_test:unittest", + "unittest/fms_form_mgr_update_form_test:unittest", "unittest/fms_form_provider_data_test:unittest", + "unittest/fms_form_provider_mgr_test:unittest", + "unittest/fms_form_set_next_refresh_test:unittest", + "unittest/fms_form_sys_event_receiver_test:unittest", + "unittest/fms_form_timer_mgr_test:unittest", ] } diff --git a/services/formmgr/test/mock/include/mock_ability_manager.h b/services/formmgr/test/mock/include/mock_ability_manager.h index a64fbb6ae1..dfafea69b6 100644 --- a/services/formmgr/test/mock/include/mock_ability_manager.h +++ b/services/formmgr/test/mock/include/mock_ability_manager.h @@ -487,7 +487,7 @@ public: { return 0; } - int MoveMissionToSplitScreenStack(const MissionOption &missionOption) + int MoveMissionToSplitScreenStack(const MissionOption &primary, const MissionOption &secondary) { return 0; } diff --git a/services/formmgr/test/mock/include/mock_bundle_manager.h b/services/formmgr/test/mock/include/mock_bundle_manager.h index e64a1dbfc2..0871787142 100644 --- a/services/formmgr/test/mock/include/mock_bundle_manager.h +++ b/services/formmgr/test/mock/include/mock_bundle_manager.h @@ -400,6 +400,10 @@ public: { return true; }; + virtual bool QueryAbilityInfosForClone(const Want &want, std::vector &abilityInfos) override + { + return true; + }; virtual bool GetModuleUsageRecords( const int32_t number, std::vector &moduleUsageRecords) override { diff --git a/services/test/mock/include/mock_ability_mgr_host.h b/services/test/mock/include/mock_ability_mgr_host.h index 1a0080a53e..8f76106278 100644 --- a/services/test/mock/include/mock_ability_mgr_host.h +++ b/services/test/mock/include/mock_ability_mgr_host.h @@ -244,7 +244,7 @@ public: { return 0; } - int MoveMissionToSplitScreenStack(const MissionOption &missionOption) override + int MoveMissionToSplitScreenStack(const MissionOption &primary, const MissionOption &secondary) override { return 0; } diff --git a/services/test/moduletest/common/bms/bundle_installer_test/bms_bundle_installer_module_test.cpp b/services/test/moduletest/common/bms/bundle_installer_test/bms_bundle_installer_module_test.cpp index db27d0673b..75e60f3c37 100644 --- a/services/test/moduletest/common/bms/bundle_installer_test/bms_bundle_installer_module_test.cpp +++ b/services/test/moduletest/common/bms/bundle_installer_test/bms_bundle_installer_module_test.cpp @@ -393,6 +393,11 @@ protected: "supportDimensions": [ 1 ], + "layout": "pages/card/index", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, "landscapeLayouts": [], "portraitLayouts": [], "customizeData": [ diff --git a/test/resource/amssystemtestability/abilitySrc/BUILD.gn b/test/resource/amssystemtestability/abilitySrc/BUILD.gn index b541b54ea0..a34cd6814f 100644 --- a/test/resource/amssystemtestability/abilitySrc/BUILD.gn +++ b/test/resource/amssystemtestability/abilitySrc/BUILD.gn @@ -59,8 +59,11 @@ group("ams_system_test_app") { "amsSystemTestServiceF:amsSystemTestServiceF", "amsSystemTestServiceG:amsSystemTestServiceG", "amsSystemTestServiceH:amsSystemTestServiceH", + "fwkAbilityState:fwkAbilityState", "serviceAbilityA:serviceAbilityA", "taskDispatcherTestA:taskDispatcherTestA", "taskDispatcherTestB:taskDispatcherTestB", + + # "launcherAbility:launcher_ability_native", ] } diff --git a/test/resource/amssystemtestability/abilitySrc/amsAbilityAppendTestA/config.json b/test/resource/amssystemtestability/abilitySrc/amsAbilityAppendTestA/config.json index daa8d0e0a8..c1db086c95 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsAbilityAppendTestA/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsAbilityAppendTestA/config.json @@ -42,6 +42,7 @@ { "name": "SecondAbility", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Second Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsAbilityVisibleTestPageA/config.json b/test/resource/amssystemtestability/abilitySrc/amsAbilityVisibleTestPageA/config.json index 73169cd439..1f0cae84de 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsAbilityVisibleTestPageA/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsAbilityVisibleTestPageA/config.json @@ -40,6 +40,7 @@ { "name": "AmsAbilityVisibleTestPageA2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AmsAbilityVisibleTestPageA2 Ability", "launchType": "standard", "orientation": "unspecified", @@ -49,6 +50,7 @@ { "name": "AmsAbilityVisibleTestPageA3", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AmsAbilityVisibleTestPageA3 Ability", "launchType": "singleton", "orientation": "unspecified", @@ -58,6 +60,7 @@ { "name": "AmsAbilityVisibleTestPageA4", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AmsAbilityVisibleTestPageA4 Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsAbilityVisibleTestServiceB/config.json b/test/resource/amssystemtestability/abilitySrc/amsAbilityVisibleTestServiceB/config.json index 6779fe76ee..97e89f8659 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsAbilityVisibleTestServiceB/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsAbilityVisibleTestServiceB/config.json @@ -40,6 +40,7 @@ { "name": "AmsAbilityVisibleTestPageB2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AmsAbilityVisibleTestPageB2 Ability", "launchType": "standard", "orientation": "unspecified", @@ -49,6 +50,7 @@ { "name": "AmsAbilityVisibleTestData", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AmsAbilityVisibleTestData Ability", "launchType": "singleton", "orientation": "unspecified", @@ -59,6 +61,7 @@ { "name": "AmsAbilityVisibleTestService", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AmsAbilityVisibleTestService Ability", "launchType": "standard", "orientation": "unspecified", @@ -68,6 +71,7 @@ { "name": "AmsAbilityVisibleTestServiceA1", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AmsAbilityVisibleTestServiceA1 Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsConfigurationUpdatedTest/config.json b/test/resource/amssystemtestability/abilitySrc/amsConfigurationUpdatedTest/config.json index a9fd4fb144..52bff73c89 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsConfigurationUpdatedTest/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsConfigurationUpdatedTest/config.json @@ -43,6 +43,7 @@ { "name": "SecondAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "SecondAbility label", "launchType": "standard", "configChanges": ["orientation","locale"], @@ -53,6 +54,7 @@ { "name": "ThirdAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "ThirdAbility label", "launchType": "standard", "configChanges": ["orientation","locale","layout"], @@ -63,6 +65,7 @@ { "name": "FourthAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "FourthAbility label", "launchType": "standard", "configChanges": ["orientation","locale","layout","fontSize"], @@ -73,6 +76,7 @@ { "name": "FifthAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "FifthAbility label", "launchType": "standard", "configChanges": ["orientation","locale","layout","fontSize","density"], @@ -83,6 +87,7 @@ { "name": "SixthAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "SixthAbility label", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestA/config.json b/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestA/config.json index fb04d7dfe3..b93f1bcbe6 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestA/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestA/config.json @@ -40,6 +40,7 @@ { "name": "AmsStDataAbilityDataA", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "DataA Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestA/src/ams_st_data_ability_data_a.cpp b/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestA/src/ams_st_data_ability_data_a.cpp index 45f840465d..c6c252b3b6 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestA/src/ams_st_data_ability_data_a.cpp +++ b/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestA/src/ams_st_data_ability_data_a.cpp @@ -175,6 +175,10 @@ int AmsStDataAbilityDataA::OpenFile(const Uri &uri, const std::string &mode) fd = fileno(fd1); APP_LOGI("--------------------------------AmsStDataAbilityDataA fd: %{public}d", fd); PublishEvent(abilityEventName, ABILITY_DATA_A_CODE, "OpenFile"); + int result = fclose(fd1); + if (result != 0) { + APP_LOGI("--------------------------------AmsStDataAbilityDataA: close file failure"); + } return fd; } diff --git a/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestB/config.json b/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestB/config.json index ddf9342a97..3b94f8634a 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestB/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestB/config.json @@ -40,6 +40,7 @@ { "name": "AmsStDataAbilityDataB", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "DataB Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestC/config.json b/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestC/config.json index be0fd6ab7d..b62f442b2f 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestC/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsDataSystemTestC/config.json @@ -41,6 +41,7 @@ { "name": "AmsStDataAbilityDataC2", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "DataB Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTest/config.json b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTest/config.json index c782e31695..ec89671618 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTest/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTest/config.json @@ -60,6 +60,7 @@ { "name": "ThirdAbility", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Third Ability", "launchType": "singletop", "orientation": "unspecified", @@ -69,6 +70,7 @@ { "name": "FourthAbility", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Fourth Ability", "launchType": "singletop", "orientation": "unspecified", @@ -78,6 +80,7 @@ { "name": "SixthAbility", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Sixth Ability", "launchType": "singletop", "orientation": "unspecified", @@ -87,6 +90,7 @@ { "name": "KitTestAbilityManager", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Kittest Ability", "launchType": "singletop", "orientation": "unspecified", @@ -96,6 +100,7 @@ { "name": "FifthAbility", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Fifth Ability", "launchType": "singletop", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestA/config.json b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestA/config.json index 5e52602563..b6f44b3fba 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestA/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestA/config.json @@ -42,6 +42,7 @@ { "name": "SecondAbility", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Second Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestDataA/config.json b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestDataA/config.json index 0723970936..3628b23967 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestDataA/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestDataA/config.json @@ -41,6 +41,7 @@ { "name": "AmsStKitDataAbilityServiceA", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "ServiceA Ability", "launchType": "standard", "orientation": "unspecified", @@ -50,6 +51,7 @@ { "name": "AmsStKitDataAbilityDataA1", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "DataA1 Ability", "launchType": "standard", "orientation": "unspecified", @@ -60,6 +62,7 @@ { "name": "AmsStKitDataAbilityDataA2", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "DataA2 Ability", "launchType": "standard", "orientation": "unspecified", @@ -70,6 +73,7 @@ { "name": "AmsStKitDataAbilityDataA3", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "DataA3 Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestDataB/config.json b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestDataB/config.json index 19877d22e4..f6083e0bd7 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestDataB/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestDataB/config.json @@ -41,6 +41,7 @@ { "name": "AmsStKitDataAbilityServiceB", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "ServiceB Ability", "launchType": "standard", "orientation": "unspecified", @@ -50,6 +51,7 @@ { "name": "AmsStKitDataAbilityDataB", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "DataB Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestPageA/config.json b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestPageA/config.json index d41eda064a..e140e853fe 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestPageA/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestPageA/config.json @@ -41,6 +41,7 @@ { "name": "AbilityContextAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityContextAbility Ability", "launchType": "standard", "orientation": "unspecified", @@ -50,6 +51,7 @@ { "name": "AbilityAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityAbility Ability", "launchType": "standard", "orientation": "unspecified", @@ -59,6 +61,7 @@ { "name": "AbilityLifeCycleAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "Lifecycle Callbacks Ability", "launchType": "standard", "orientation": "unspecified", @@ -68,6 +71,7 @@ { "name": "LifeCycleObserverAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "Lifecycle Callbacks Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestService/config.json b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestService/config.json index ccaf21ff68..3dd4f317b5 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestService/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsKitSystemTestService/config.json @@ -41,6 +41,7 @@ { "name": "AbilityContextAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "Lifecycle Callbacks Ability", "launchType": "standard", "orientation": "unspecified", @@ -50,6 +51,7 @@ { "name": "AbilityAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "Lifecycle Callbacks Ability", "launchType": "standard", "orientation": "unspecified", @@ -59,6 +61,7 @@ { "name": "AbilityLifeCycleAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "Lifecycle Callbacks Ability", "launchType": "standard", "orientation": "unspecified", @@ -68,6 +71,7 @@ { "name": "LifeCycleObserverAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "Lifecycle Callbacks Ability", "launchType": "standard", "orientation": "unspecified", @@ -77,6 +81,7 @@ { "name": "AbilityConnectionAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "Lifecycle Callbacks Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsMissionStackTest/config.json b/test/resource/amssystemtestability/abilitySrc/amsMissionStackTest/config.json index a42dcaab6e..3967c8b6b8 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsMissionStackTest/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsMissionStackTest/config.json @@ -42,6 +42,7 @@ { "name": "SecondAbility", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Second Ability", "launchType": "standard", "orientation": "unspecified", @@ -51,6 +52,7 @@ { "name": "ThirdAbility", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Third Ability", "launchType": "singleton", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsMissionStackTestSubsidiary/config.json b/test/resource/amssystemtestability/abilitySrc/amsMissionStackTestSubsidiary/config.json index 95664c491d..727170594a 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsMissionStackTestSubsidiary/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsMissionStackTestSubsidiary/config.json @@ -42,6 +42,7 @@ { "name": "SecondAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "SecondAbility label", "launchType": "standard", "orientation": "unspecified", @@ -51,6 +52,7 @@ { "name": "ThirdAbility", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "ThirdAbility label", "launchType": "singleton", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestA/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestA/config.json index 8cba64cb4d..98a5a7b945 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestA/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestA/config.json @@ -40,6 +40,7 @@ { "name": "AmsStAbilityA2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityA2 Ability", "launchType": "singletop", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestC/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestC/config.json index a59eedb5e0..f41686d598 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestC/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestC/config.json @@ -40,6 +40,7 @@ { "name": "AmsStAbilityC2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityC2 Ability", "launchType": "singletop", "orientation": "unspecified", @@ -49,6 +50,7 @@ { "name": "AmsStAbilityC3", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityC3 Ability", "launchType": "singletop", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestD/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestD/config.json index 4e2104cae5..d6779121b3 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestD/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestD/config.json @@ -40,6 +40,7 @@ { "name": "AmsStAbilityD2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityD2 Ability", "launchType": "singleton", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestDFX/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestDFX/config.json index 9521129d32..dfac5dc9cb 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestDFX/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestDFX/config.json @@ -40,6 +40,7 @@ { "name": "AmsDfxStServiceAbilityA2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AmsDfxStServiceAbilityA1 Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestF/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestF/config.json index ec0c430307..d54b30c7dd 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestF/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestF/config.json @@ -40,6 +40,7 @@ { "name": "AmsStAbilityF2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityF2 Ability", "launchType": "standard", "orientation": "unspecified", @@ -49,6 +50,7 @@ { "name": "AmsStAbilityF3", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityF3 Ability", "launchType": "singleton", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestG/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestG/config.json index 4400b3f555..7a69271b4e 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestG/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestG/config.json @@ -40,6 +40,7 @@ { "name": "AmsStAbilityG2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityG2 Ability", "launchType": "singletop", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestI/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestI/config.json index f94fc01079..a3795b6316 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestI/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestI/config.json @@ -40,6 +40,7 @@ { "name": "AmsStAbilityI2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityI2 Ability", "launchType": "singletop", "orientation": "unspecified", @@ -49,6 +50,7 @@ { "name": "AmsStAbilityI3", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityC3 Ability", "launchType": "singleton", "orientation": "unspecified", @@ -58,6 +60,7 @@ { "name": "AmsStAbilityI4", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityC3 Ability", "launchType": "singletop", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestN/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestN/config.json index acff51b1ab..15e9c3f600 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestN/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestN/config.json @@ -40,6 +40,7 @@ { "name": "AmsStAbilityN2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityI2 Ability", "launchType": "standard", "orientation": "unspecified", @@ -49,6 +50,7 @@ { "name": "AmsStAbilityN3", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityC3 Ability", "launchType": "singleton", "orientation": "unspecified", @@ -58,6 +60,7 @@ { "name": "AmsStAbilityN4", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityC3 Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestQ/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestQ/config.json index 3c63fff766..5e93dd7d86 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestQ/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestQ/config.json @@ -40,6 +40,7 @@ { "name": "AmsStAbilityQ2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityQ2 Ability", "launchType": "standard", "orientation": "unspecified", @@ -49,6 +50,7 @@ { "name": "AmsStAbilityQ3", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityQ3 Ability", "launchType": "singleton", "orientation": "unspecified", @@ -58,6 +60,7 @@ { "name": "AmsStAbilityQ4", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityQ4 Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestR/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestR/config.json index f304197a66..1edef7bee1 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestR/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestR/config.json @@ -40,6 +40,7 @@ { "name": "AmsStAbilityR2", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityR2 Ability", "launchType": "standard", "orientation": "unspecified", @@ -49,6 +50,7 @@ { "name": "AmsStAbilityR3", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityR3 Ability", "launchType": "singleton", "orientation": "unspecified", @@ -58,6 +60,7 @@ { "name": "AmsStAbilityR4", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AbilityR4 Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/amsSystemTestServiceB/config.json b/test/resource/amssystemtestability/abilitySrc/amsSystemTestServiceB/config.json index 69e1f41e6d..9d48184059 100644 --- a/test/resource/amssystemtestability/abilitySrc/amsSystemTestServiceB/config.json +++ b/test/resource/amssystemtestability/abilitySrc/amsSystemTestServiceB/config.json @@ -41,6 +41,7 @@ { "name": "AmsStServiceAbilityB3", "icon": "$media:snowball", + "srcLanguage": "c++", "label": "AmsStServiceAbilityB3 Ability", "launchType": "standard", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/BUILD.gn b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/BUILD.gn new file mode 100644 index 0000000000..be3a1d21d4 --- /dev/null +++ b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/BUILD.gn @@ -0,0 +1,64 @@ +# 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. +import("//build/ohos.gni") +APP_DIR = "//foundation/appexecfwk/standard/test/resource/amssystemtestability/abilitySrc/fwkAbilityState" +TOOLS_DIR = "//foundation/appexecfwk/standard/test/resource/amssystemtestability/abilitySrc/tools" +config("amsSystemTestAConfig") { + visibility = [ ":*" ] + include_dirs = [ + "${APP_DIR}/include", + "//foundation/appexecfwk/standard/kits/appkit/native/app", + "//foundation/aafwk/standard/interfaces/innerkits/want/include/ohos/aafwk/content", + "//foundation/aafwk/standard/interfaces/innerkits/ability_manager/include", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include", + "//foundation/appexecfwk/standard/services/bundlemgr/include", + "//foundation/aafwk/standard/services/abilitymgr/include", + "//foundation/appexecfwk/standard/common/log/include", + "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include", + "${TOOLS_DIR}/include", + ] + defines = [ + "APP_LOG_TAG = \"fwkAbilityState\"", + "LOG_DOMAIN = 0xD002200", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } +} +ohos_shared_library("fwkAbilityState") { + sources = [ + "${APP_DIR}/src/ability_state_main.cpp", + "${APP_DIR}/src/ability_state_second.cpp", + "${APP_DIR}/src/test_utils.cpp", + "${TOOLS_DIR}/src/stpageabilityevent.cpp", + ] + configs = [ ":amsSystemTestAConfig" ] + deps = [ + "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", + "//foundation/aafwk/standard/interfaces/innerkits/want:want", + "//foundation/appexecfwk/standard/common:libappexecfwk_common", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core:appexecfwk_core", + "//foundation/appexecfwk/standard/kits:appkit_native", + "//foundation/appexecfwk/standard/services/bundlemgr:libbms", + "//utils/native/base:utilsbase", + ] + external_deps = [ + "ces_standard:cesfwk_core", + "ces_standard:cesfwk_innerkits", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + ] + subsystem_name = "amssystemtestability" +} diff --git a/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/config.json b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/config.json new file mode 100644 index 0000000000..1ad8afb829 --- /dev/null +++ b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/config.json @@ -0,0 +1,50 @@ +{ + "app":{ + "bundleName": "com.ohos.amsst.fwkAbilityState", + "vendor": "ix", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 3, + "target": 3 + } + }, + "deviceConfig": { + "default": { + } + }, + "module": { + "package":"com.ohos.fwkAbilityState.src", + "name":"fwkAbilityState", + "deviceType": [ + "tv", + "car" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "testability", + "moduleType": "entry" + }, + "abilities": [{ + "name": "FwkAbilityStateMain", + "icon": "$media:snowball", + "srcLanguage": "c++", + "label": "FwkAbilityStateMain", + "launchType": "standard", + "orientation": "unspecified", + "type": "page", + "visible": true + }, + { + "name": "FwkAbilityStateSecond", + "icon": "$media:snowball", + "label": "FwkAbilityStateSecond", + "launchType": "standard", + "orientation": "unspecified", + "type": "page", + "visible": true + }] + } +} \ No newline at end of file diff --git a/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/ability_state_main.h b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/ability_state_main.h new file mode 100644 index 0000000000..fdffa3e207 --- /dev/null +++ b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/ability_state_main.h @@ -0,0 +1,81 @@ +/* + * 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 FWK_ABILITY_STATE_ABILITY_A_H +#define FWK_ABILITY_STATE_ABILITY_A_H +#include +#include "ability.h" +#include "ability_loader.h" +#include "app_log_wrapper.h" +#include "common_event.h" +#include "common_event_manager.h" +#include "pac_map.h" +#include "stpageabilityevent.h" + +namespace OHOS { +namespace AppExecFwk { +class FwkAbilityStateSecondSubscriber; +class FwkAbilityStateMain : public Ability { +public: + FwkAbilityStateMain() + { + mapAction_["StartNextAbility"] = [this](int code) { StartNextAbility(code); }; + } + ~FwkAbilityStateMain(); + virtual void OnStart(const Want &want) override; + virtual void OnStop() override; + virtual void OnActive() override; + virtual void OnInactive() override; + virtual void OnBackground() override; + virtual void OnForeground(const Want &want) override; + virtual void OnNewWant(const Want &want) override; + virtual void OnSaveAbilityState(PacMap &outState) override; + virtual void OnRestoreAbilityState(const PacMap &inState) override; + + void Action(std::string action, int code); + void StartNextAbility(int code); + +private: + std::shared_ptr subscriber_; + std::string callback_seq; + std::unordered_map> mapAction_; + void SubscribeEvent(); +}; + +class FwkAbilityStateSecondSubscriber : public EventFwk::CommonEventSubscriber { +public: + explicit FwkAbilityStateSecondSubscriber(const EventFwk::CommonEventSubscribeInfo &sp) + : CommonEventSubscriber(sp) + { + mapAction_ = { + {"StartNextAbility", [this](std::string action, int code) { Action(action, code); }}, + }; + mainAbility = nullptr; + } + + void Action(std::string action, int code) + { + mainAbility->Action(action, code); + } + + virtual void OnReceiveEvent(const EventFwk::CommonEventData &data); + + FwkAbilityStateMain *mainAbility; + std::unordered_map> mapAction_; + ~FwkAbilityStateSecondSubscriber() = default; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // _FWK_ABILITY_STATE_ABILITY_A_H \ No newline at end of file diff --git a/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/ability_state_second.h b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/ability_state_second.h new file mode 100644 index 0000000000..cfbc84ee51 --- /dev/null +++ b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/ability_state_second.h @@ -0,0 +1,79 @@ +/* + * 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 FWK_ABILITY_STATE_ABILITY_B_H +#define FWK_ABILITY_STATE_ABILITY_B_H +#include +#include "ability_loader.h" +#include "app_log_wrapper.h" +#include "common_event.h" +#include "common_event_manager.h" +#include "pac_map.h" +#include "stpageabilityevent.h" + +namespace OHOS { +namespace AppExecFwk { +class FwkAbilityStateMainSubscriber; +class FwkAbilityStateSecond : public Ability { +public: + FwkAbilityStateSecond() + { + mapAction_["Terminate"] = [this](int code) { TerminateThis(code); }; + } + ~FwkAbilityStateSecond(); + virtual void OnStart(const Want &want) override; + virtual void OnStop() override; + virtual void OnActive() override; + virtual void OnInactive() override; + virtual void OnBackground() override; + virtual void OnForeground(const Want &want) override; + virtual void OnNewWant(const Want &want) override; + virtual void OnSaveAbilityState(PacMap &outState) override; + virtual void OnRestoreAbilityState(const PacMap &inState) override; + + void Action(std::string action, int code); + void TerminateThis(int code); + +private: + std::shared_ptr subscriber_; + std::unordered_map> mapAction_; + void SubscribeEvent(); +}; + +class FwkAbilityStateMainSubscriber : public EventFwk::CommonEventSubscriber { +public: + explicit FwkAbilityStateMainSubscriber(const EventFwk::CommonEventSubscribeInfo &sp) + : CommonEventSubscriber(sp) + { + mapAction_ = { + {"Terminate", [this](std::string action, int code) { Action(action, code); }}, + }; + mainAbility = nullptr; + } + + void Action(std::string action, int code) + { + mainAbility->Action(action, code); + } + + virtual void OnReceiveEvent(const EventFwk::CommonEventData &data); + + FwkAbilityStateSecond *mainAbility; + std::unordered_map> mapAction_; + ~FwkAbilityStateMainSubscriber() = default; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // _FWK_ABILITY_STATE_ABILITY_B_H \ No newline at end of file diff --git a/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/test_utils.h b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/test_utils.h new file mode 100644 index 0000000000..8969a915e6 --- /dev/null +++ b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/include/test_utils.h @@ -0,0 +1,30 @@ +/* + * 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 _TEST_UTILS_H_ +#define _TEST_UTILS_H_ +#include "want.h" + +namespace OHOS { +namespace AppExecFwk { +class TestUtils { +public: + TestUtils() = default; + virtual ~TestUtils() = default; + static bool PublishEvent(const std::string &eventName, const int &code, const std::string &data); + static std::vector split(const std::string &in, const std::string &delim); +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // _TEST_UTILS_H_ \ No newline at end of file diff --git a/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/ability_state_main.cpp b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/ability_state_main.cpp new file mode 100644 index 0000000000..e4ac03e1e5 --- /dev/null +++ b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/ability_state_main.cpp @@ -0,0 +1,154 @@ +/* + * 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. + */ + +#include "ability_state_main.h" +#include +#include "test_utils.h" + +namespace OHOS { +namespace AppExecFwk { +using namespace OHOS::EventFwk; +namespace { +std::string FwkAbilityState_Event_Resp_A = "resp_com_ohos_amsst_FwkAbilityStateA"; +std::string FwkAbilityState_Event_Requ_A = "requ_com_ohos_amsst_FwkAbilityStateA"; +int OnStopCode = 3; +int OnActiveCode = 1; +int OnBackgroundCode = 2; +} + +FwkAbilityStateMain::~FwkAbilityStateMain() +{ + CommonEventManager::UnSubscribeCommonEvent(subscriber_); +} + +void FwkAbilityStateMain::OnStart(const Want &want) +{ + APP_LOGI("FwkAbilityStateMain::onStart"); + SubscribeEvent(); + Ability::OnStart(want); + callback_seq += "OnStart"; +} + +void FwkAbilityStateMain::OnNewWant(const Want &want) +{ + APP_LOGI("FwkAbilityStateMain::OnNewWant"); + Ability::OnNewWant(want); + callback_seq += "OnNewWant"; +} + +void FwkAbilityStateMain::OnForeground(const Want &want) +{ + APP_LOGI("FwkAbilityStateMain::OnForeground"); + Ability::OnForeground(want); + callback_seq += "OnForeground"; +} + +void FwkAbilityStateMain::OnStop() +{ + APP_LOGI("FwkAbilityStateMain::onStop"); + Ability::OnStop(); + CommonEventManager::UnSubscribeCommonEvent(subscriber_); + callback_seq += "OnStop"; + TestUtils::PublishEvent(FwkAbilityState_Event_Resp_A, OnStopCode, callback_seq); + callback_seq = ""; +} + +void FwkAbilityStateMain::OnActive() +{ + APP_LOGI("FwkAbilityStateMain::OnActive"); + Ability::OnActive(); + callback_seq += "OnActive"; + TestUtils::PublishEvent(FwkAbilityState_Event_Resp_A, OnActiveCode, callback_seq); + callback_seq = ""; +} + +void FwkAbilityStateMain::OnInactive() +{ + APP_LOGI("FwkAbilityStateMain::OnInactive"); + Ability::OnInactive(); + callback_seq += "OnInactive"; +} + +void FwkAbilityStateMain::OnBackground() +{ + APP_LOGI("FwkAbilityStateMain::OnBackground"); + Ability::OnBackground(); + callback_seq += "OnBackground"; + TestUtils::PublishEvent(FwkAbilityState_Event_Resp_A, OnBackgroundCode, callback_seq); + callback_seq = ""; +} + +void FwkAbilityStateMain::OnSaveAbilityState(PacMap &outState) +{ + APP_LOGI("FwkAbilityStateMain::OnSaveAbilityState"); + Ability::OnSaveAbilityState(outState); + callback_seq += "OnSaveAbilityState"; +} + +void FwkAbilityStateMain::OnRestoreAbilityState(const PacMap &inState) +{ + APP_LOGI("FwkAbilityStateMain::OnRestoreAbilityState"); + Ability::OnRestoreAbilityState(inState); + callback_seq += "OnRestoreAbilityState"; +} + +void FwkAbilityStateMain::SubscribeEvent() +{ + std::vector eventList = { + FwkAbilityState_Event_Requ_A, + }; + MatchingSkills matchingSkills; + for (const auto &e : eventList) { + matchingSkills.AddEvent(e); + } + CommonEventSubscribeInfo subscribeInfo(matchingSkills); + subscribeInfo.SetPriority(1); + subscriber_ = std::make_shared(subscribeInfo); + subscriber_->mainAbility = this; + CommonEventManager::SubscribeCommonEvent(subscriber_); +} + +void FwkAbilityStateSecondSubscriber::OnReceiveEvent(const CommonEventData &data) +{ + auto eventName = data.GetWant().GetAction(); + if (strcmp(eventName.c_str(), FwkAbilityState_Event_Requ_A.c_str()) == 0) { + auto target = data.GetData(); + if (mapAction_.find(target) != mapAction_.end()) { + mapAction_[target](target, data.GetCode()); + } else { + APP_LOGI("OnReceiveEvent: CommonEventData error(%{public}s)", target.c_str()); + } + } +} + +void FwkAbilityStateMain::Action(std::string action, int code) +{ + if (mapAction_.find(action) != mapAction_.end()) { + mapAction_[action](code); + } +} + +void FwkAbilityStateMain::StartNextAbility(int code) +{ + std::string targetBundle = "com.ohos.amsst.fwkAbilityState"; + std::string targetAbility = "FwkAbilityStateAbilityB"; + Want want; + want.SetElementName(targetBundle, targetAbility); + StartAbility(want); +} + +REGISTER_AA(FwkAbilityStateMain); +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/ability_state_second.cpp b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/ability_state_second.cpp new file mode 100644 index 0000000000..9fdc118a13 --- /dev/null +++ b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/ability_state_second.cpp @@ -0,0 +1,133 @@ +/* + * 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. + */ + +#include "ability_state_second.h" +#include +#include "test_utils.h" + +namespace OHOS { +namespace AppExecFwk { +using namespace OHOS::EventFwk; +std::string FwkAbilityState_Event_Requ_B = "requ_com_ohos_amsst_FwkAbilityStateB"; + +FwkAbilityStateSecond::~FwkAbilityStateSecond() +{ + CommonEventManager::UnSubscribeCommonEvent(subscriber_); +} + +void FwkAbilityStateSecond::OnStart(const Want &want) +{ + SubscribeEvent(); + APP_LOGI("FwkAbilityStateSecond::onStart"); + Ability::OnStart(want); +} + +void FwkAbilityStateSecond::OnForeground(const Want &want) +{ + APP_LOGI("FwkAbilityStateSecond::OnForeground"); + Ability::OnForeground(want); +} + +void FwkAbilityStateSecond::OnNewWant(const Want &want) +{ + APP_LOGI("FwkAbilityStateSecond::OnNewWant"); + Ability::OnNewWant(want); +} + +void FwkAbilityStateSecond::OnStop() +{ + APP_LOGI("FwkAbilityStateSecond::onStop"); + Ability::OnStop(); +} + +void FwkAbilityStateSecond::OnActive() +{ + APP_LOGI("FwkAbilityStateSecond::OnActive"); + Ability::OnActive(); +} + +void FwkAbilityStateSecond::OnInactive() +{ + APP_LOGI("FwkAbilityStateSecond::OnInactive"); + Ability::OnInactive(); +} + +void FwkAbilityStateSecond::OnBackground() +{ + APP_LOGI("FwkAbilityStateSecond::OnBackground"); + Ability::OnBackground(); +} + +void FwkAbilityStateSecond::OnSaveAbilityState(PacMap &outState) +{ + APP_LOGI("FwkAbilityStateSecond::OnSaveAbilityState"); + Ability::OnSaveAbilityState(outState); +} + +void FwkAbilityStateSecond::OnRestoreAbilityState(const PacMap &inState) +{ + APP_LOGI("FwkAbilityStateSecond::OnRestoreAbilityState"); + Ability::OnRestoreAbilityState(inState); +} + + +void FwkAbilityStateSecond::SubscribeEvent() +{ + std::vector eventList = { + FwkAbilityState_Event_Requ_B, + }; + MatchingSkills matchingSkills; + for (const auto &e : eventList) { + matchingSkills.AddEvent(e); + } + CommonEventSubscribeInfo subscribeInfo(matchingSkills); + subscribeInfo.SetPriority(1); + subscriber_ = std::make_shared(subscribeInfo); + subscriber_->mainAbility = this; + CommonEventManager::SubscribeCommonEvent(subscriber_); +} + +void FwkAbilityStateMainSubscriber::OnReceiveEvent(const CommonEventData &data) +{ + auto eventName = data.GetWant().GetAction(); + if (strcmp(eventName.c_str(), FwkAbilityState_Event_Requ_B.c_str()) == 0) { + auto target = data.GetData(); + if (mapAction_.find(target) != mapAction_.end()) { + mapAction_[target](target, data.GetCode()); + } else { + APP_LOGI("OnReceiveEvent: CommonEventData error(%{public}s)", target.c_str()); + } + } +} + +void FwkAbilityStateSecond::Action(std::string action, int code) +{ + if (mapAction_.find(action) != mapAction_.end()) { + mapAction_[action](code); + } +} + +void FwkAbilityStateSecond::TerminateThis(int code) +{ + std::string targetBundle = "com.ohos.amsst.fwkAbilityState"; + std::string targetAbility = "FwkAbilityStateSecond"; + Want want; + want.SetElementName(targetBundle, targetAbility); + StartAbility(want); +} + +REGISTER_AA(FwkAbilityStateSecond); +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/test_utils.cpp b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/test_utils.cpp new file mode 100644 index 0000000000..0b28e93d48 --- /dev/null +++ b/test/resource/amssystemtestability/abilitySrc/fwkAbilityState/src/test_utils.cpp @@ -0,0 +1,42 @@ +/* + * 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. + */ +#include "test_utils.h" +#include "common_event_data.h" +#include "common_event_manager.h" +#include + +namespace OHOS { +namespace AppExecFwk { +using namespace OHOS::EventFwk; +bool TestUtils::PublishEvent(const std::string &eventName, const int &code, const std::string &data) +{ + Want want; + want.SetAction(eventName); + CommonEventData commonData; + commonData.SetWant(want); + commonData.SetCode(code); + commonData.SetData(data); + return CommonEventManager::PublishCommonEvent(commonData); +} + +std::vector TestUtils::split(const std::string &in, const std::string &delim) +{ + std::regex reg(delim); + std::vector res = { + std::sregex_token_iterator(in.begin(), in.end(), reg, -1), std::sregex_token_iterator()}; + return res; +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/resource/amssystemtestability/abilitySrc/taskDispatcherTestA/config.json b/test/resource/amssystemtestability/abilitySrc/taskDispatcherTestA/config.json index e81fa5739c..bc23c52d72 100644 --- a/test/resource/amssystemtestability/abilitySrc/taskDispatcherTestA/config.json +++ b/test/resource/amssystemtestability/abilitySrc/taskDispatcherTestA/config.json @@ -42,6 +42,7 @@ { "name": "SecondAbility", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Second Ability", "launchType": "singletop", "orientation": "unspecified", diff --git a/test/resource/amssystemtestability/abilitySrc/taskDispatcherTestB/config.json b/test/resource/amssystemtestability/abilitySrc/taskDispatcherTestB/config.json index 323a49d473..551bf938a9 100644 --- a/test/resource/amssystemtestability/abilitySrc/taskDispatcherTestB/config.json +++ b/test/resource/amssystemtestability/abilitySrc/taskDispatcherTestB/config.json @@ -42,6 +42,7 @@ { "name": "SecondAbility", "icon": "$media:snowflakes", + "srcLanguage": "c++", "label": "Second Ability", "launchType": "singletop", "orientation": "unspecified", diff --git a/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle41.hap b/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle41.hap index 05035ff2a8d5b96887346b15f6473e2f8e197b3f..6939058dc68e2c0bd987a944d293c410e6acae60 100644 GIT binary patch delta 709 zcmV;$0y_PG;02!G1&}U(RL@VsFcdzIg#Upw9?cZEaYMa$@q~IX#&qk0z1X!&+ku4e zzuRsD*Rr9wa2W6V`hI-hTX)03$UcM?1)1&YKUE+p1>^8Ub0D)3No5|J3>Awr+(^Y) z3|}-aIE=}4>(Ckmlgb@v-~d$`rLb_TP=%zDxiaJHATFBn8JZDcno3#Fd}hLQ7h5<442uxnyNkx_z>s=_g&; zXuqOy=4)DOK$2W99R05HW#UolRu|jCm3s>`G;0#dno`x0^W95@+9=s!5d)6a!0juV z>``b#IkzmMN(i%m*MlE6$AIM~$kA*`H?!%RfG}#?ZL{^cN`au=gu9+K@iqFGk54LM zS}h8>%7G!BX(2a>n@bW*vEpECwU8$j+DYwV)}53>7m(r- zft^rIlZ;VAPry>)0c-S~-P}}LWfhMZVx}$92juc zgh^QG5+lx=G3hho5<@OD#WTig>b|^A&To1~9YRLEDo(>1(H|v@{;|u^U$u)a5H32Z zR=6AR1U;))>$YmH+2O$cz5!562MG5$KHk&;006#&@Bz2*0RabPATK}Q#I~v8Z-a3< z<<$nnNJ)=t^5x<4^vKlvE!IFU{I?fp0iOpuIWaXcF)}bTGg>e&1_>&LNQU# zA_O49_S{zFpn_A=7i--O|B8p%%W^@c)XrMy*u6qu7CHBq@ooVVL?Bt6T*GTJ0juBP z0DAG8KJ1~!QjO(ajq>7kIUr_5Ub6xr0KS)n*CV_ZS5cxe(7@8w3MbxqrA_5hkY!&1 r&08uAU6)920Wb;oIX>Rh0RRBLmw|5qP681Em(gzlDF%jb0RR917C==t delta 693 zcmV;m0!sa!;01u-1&}U(ls#|4Fc604An_lN)e%JnHa6O+ODEJ0RaH6hK~8n-$abIz z@!xAF0b-L-Xv7fiUf;)a7w?CIk$ng)3Nqi(B-Slgb@v+<{kVl)}1Oi7HPjnM*Sn2X@hkjK` zE~vqTyAU%kG%-}I!8rTLe5l`!!3l#6rtmDq3fF#Y>sry08{Zn9&m}9X)a{c6O~2{d zTKkE{na{LlK$2W9o&2eq%hZ$9r7m}cOZO2lG#e6PO{r?({PaShHcEDkhyh1Cz}-8V z>_uopIkzgKN(iHW*Nq=H$AHx)$kFUbx3a05fG}#;J!U)SDg=Ud9qxP9#Ao!im|SGU zv|1GMkOM{1b_W-;Tq6boga$icP<}aR6 z2gsY9vWxBj7oDgT?#8{z2Y)p% zH!(3XH!?U{FfRrPDuzgg_YDCF1Ti86Am(`EI|f4)znC}d;W7`-taPkl?l;p=V?svk z12i)X)-VhP2r7n1&OHPJ0tEmBM=(VKAppi~6n_r2`Ha7gT8OTIpL2>m5`a$uNN$HD zS3ij1#$f^=JqPiOI9KJ|eb&RFYZK2BcfnwVYzwgW`GbO)$Q3Z?GM8p=0Wb->hfF@U b0RRAQm!EF|P6G1*m+x-@DF$e70RR91ayK*i diff --git a/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle43.hap b/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle43.hap index 2d9d0ce3db258be2e38744ddf5b2806a296b6bb6..12d6093e841f947394093fd63a41f2087fe603d0 100644 GIT binary patch delta 2800 zcmZwEck~GK_s8+i>-F}rXJlt&Wh7MqgMAfJk=SB6X z5jCS$oFBF0f~XT0#zj##>P7u%5DlYIG>#_GG@3>8Xb~;r;!Mfmj_adO^o@RTL-dauV?Ydy zK`}Un#7!|YhQ;u>IYz|D7!{*qOxzN;#%(b+ZjU=+T-+IV#rT*IcgH<(Z$#V|6Jt_L zjwx|}ObudMJP_04!I%*uc||^vUlb4pMIljG6cJ~MqN12MTND>1L`hLflon+~S#gdiC(4ToqM|rg zR1%d%6;V}G6X%KQqK2p`YKikjZE=C9BQ6vdiMpbms4p6bhN6*ZESiX>qM2weT8Nh7 zVsVLRC0dI%qOHghmx^|xy|_$t5FN$k;tJ78WQ!|BXVFDmCAx~MMK{r1^bkG8HR4)v zo#-Wci|a)n(O2{nH;De?MlnDP6obTIF+|)XhKgZgxVTx25F^DXFOcM`?>Eb~#L(CMj#BA}9m?P$j zhs8WGUpyin6_1I>#R9QVED}$MC&gm1L_8&yil@ah;#u*WSSFT>=fw-+Me&k&S*#GR zh?QcMcvY+xYs72fb+J~wA=ZiY;!W|E*dR8Fx5Xy0S!@wo#Wt~Byd!pqonn`GSG*_Q z7rVs=;zRL~_*m=_pNPF;pZHXKCiaWZ#TVjBaX@?}4vMeEH{x6Io%miH5{JbP;z#k5 z_*ongN5wDVm^dy@h+oBT;&<_f_*48PPKs0FZ}E>ft;t5lCYc;2)8sU{Om36Mlj=9iWWa^rFroL%l8k$C?v1wwOnr5cCX<=HLi_Imbm1%9-n6@U% zTx!~x_U1Cv!E`j2n=4EwlWndvolO^WmFa4(Hr-5j)5G*M*O+U~b*7i;ZLT+cOkdN_ z++g~f8_fVS&)To;NR;7tKrNWwXM(Vpf_}=2f%WtTC^d z*UehWo{W`o&i-Zq=eX0yd?HQUT~^N!hJcA8!0UGtuK-|RLYm=DcI=3}$R zd}8*Redbg1nb~hXH(!`9%>nb3IcUB%-LuzY8YCJf8YLPhnk1SgnkAYiS|nN~E>2vMXq9N4 zXp?B0)@G%5v&Uy-D;{2 z#yW-f&-kOzLz}v{ZIi#<{=7x=b;(SvwoZ9rTb?beZmL%0*}uMcsc6Gp-InLywg31X zw;uU<-1t{VOv+xewf3pecP}f>#-__B{MexK+^&5)d|0dcFO};LXg@J??*m827sy?8 z<(3WQmlvDVC~wUAFVpQ@>8{&*P2cF=U%yP&HX)htX_KC zzAHw~IqYTA3murczU{~j3*Rc+Ye}QNMb@-F+-}IQ)+aWfyzJ$D?K}0ZG5_@L4Q;#a z$Umn_|0b)8H?Pp6f5CG9?4I`Z*a>fUF0}mE$li4e4IQ;BP zy+*HT)q;WVH0)FBo6i<4d%n+!aRZyxo|ZXj=YvlU-B#mR&xYzVrfHeu89!Ao%#ovO z*Hx`M{jT2*wJLIa*p*vbXXZb&EBDy#*H+6{c4?`jUAOOSQE$b#&QsT}ZO|{fSlMM= z9yz!;YtJ*+>{vImXUWXQ<%)db!6nkXku_JeYcTNCut^m=&YJuF=>03FuRcj#Jn zo1$e$1wUPB6^S_*voI7{k%iKHP{pOqGvGsF( z&K;TSGhRqo6w!)@cuF0qEA^zlG?0ekC5@!9cuNy$D$S(1w2+q4N?J=B@sYcvt+bQ& z(m{NsqxeZD=`43k7x9;_a*uSA?$Sd7q^I-}Rdf<4K@uz>5-PnVOu{8X?v*~$SNchR z86bKwNTfuGQKBVAVkJ)EWuOcalO#x@BuTQQ$Y4p8G#Mg8C0#NkQ|^;tGFJsV^>Ju6e8WOw+jR=hi-h?KEri5mM=7bi6mV{P>)`T_$AHrRP zwuE+s_Jj@uUqVNMAE6VWGvRJR7lJ>bE8!kOH$rzp4?+N;C!rTXCFlr&gdjpNA%qZ0 z=uHSCgcBkN_Y(RL`V#sP`V$5a^aKMTk`P5O5~2w)gjhlxA)YXhFo<9xBoGn_NrYrV z3SlrIm5@dlLKsR&Cu9&Z3HK3(5rz})CyXGBBxDh?2|0vZf|-y<$R`vK3JFDoQ3MO2 zm|!K?2qlEkgi=Bo!A>YAj3GD(6@*Gc6=5vl0m3-Kg9ImGJmDciHQ`}`5FQ~+AWS4o zB1|SsAxtHJFpV&sFoW>=zW zd_veq_>}M&;d8=%!U4h;goA`bgf9t)2}cM=3C9S>2`30&5xypzB%C6gCVWFUL->~P z9pQVz4}`OX9|`9O=LtU%E)XsfE)gyht`M#gekNQa{6hGZCNYS?427X(crZK}br^LS z^%(UT4Hyj>UW`VJ#td&p6Gl@;Ge&bp3r0&uD@JQZ8-@?#E=F5MJ4Sm(2Zk@BBg2o; ziP4#HH=_%~pV5_Z52G8SJEI39fYFoDi=i@fj6g;ZBbX7w2xatUgfYSy5sZ5oeHeWi z{TTfj0~mUSff31wVi+0Gj2K2NBaRWz7|0mJFfkGsiHsyhG9!gCn32jzV+>&oWu!AQ z7@3Uw7{eID8TT_rFh(-67}<;*MlQq5$YbO)3K)fqBE~3&g;C6~GHi?z#%M+1;z@-O2#V2i;UHbml$gpYZ>bp>lrUIHZV3aHZfjdyvlfu@j7EOV+-RA#+!_{ z7+V={Gu~mm%h<+vkFlNcKH~$%4#tO!os3|=b&_>A#6V?W~n z;|sv()S;miybByzh zpBNVy7a5lrml;M5wNpn-yh3cM6F zQqWj|w}K`Lnks0fpt*t;3R)^?rJ%KfHVS+c+@+wcf_4hpE9juWS3ySwehNA%=&ayw z1zi;QE9k1=9tGVLbXU+rL4bmu3VJC}73dTMDhN^#tRO@|sDj=K!W4unh){5^f<6lR zD(I)6zk&e@^a>0LA{9g_Fe5si^^=)^1*Kw9aFtu zZ*`@y{(Sn534MDU-*;i})}D{dIv9D6aaNZLtJiey{Q1gymoHAY_^;31c4_36%BrAq zdG?K)_kXl?<9dsuwbQf4vOe{PiM`(#b61x^gT-flkD{N|gzXF8o^o*KrFI2{!;Zh@ zZ(C8_<8&V%lk-T%^p1W&o0m7VS+#7(funVy`EInfI&>mWg}MJw9vdudn&p-`TN!&B8-n zR!wWadd=BhGau}a<3kN?297&bJm})Q%GMFH4s_f2)aRFH#V%;Pa|N8S)druDzc!A% zwtU>-_$J*qwk-YWrL%iJ*7{l}*N@z_Z|>lO4ece@uFNUi`LMQnM!WVsSHzv(ef8j& znN8kV-Sx~;n*6}m>o0fB@efZt+jQ^q$G`f{5Hw{&=H6v_eNM;gYb@cr!WJhK>bAva zej8Bti%#!(gbd0KT{WovnU4}*Z8z~zPv?y8d#2rYRl7>x!S=!7P76+L+Isn$>aC+k zC5|oHl|6NTw{7K@`rcpk)z}U-l^s@lJnm?_-Quz9traW3KXA1A!z9DWYn(K&PTh!C zR?J&X8qH>{M#CD7?{F`TrnM`xuFH2pU5%#PHCC&=GCb>bn-DwUq8HWSnrg3jwc6DIksGvS=YlatE40#x3J7!T9{pKci&*IEOFmpD;rU0wVU%xv)op{9!|gV^1@u# zM2H&LJ3Bnw91xP{dJ7H>$qfh(QNseV!p*8KC^#?AtP690QI@4Jx6oec7cth)YO@Dq zoAYd??yn5hg$D(P2kOFmT(@WC+0CUcv&-09b(_ca@Vgm8so7%ADl@wtmR)Xj=32}F zh1NWq`+>RUF=mUc#9SJ1JtSL!t?ZV`6G~MjBI6 z5{_m%hT3b<@jv z%Pl$G;K+`#6lJ8Rlw=16=O?R1M{Ge(f~m;pFcs-5T|uPARV1dGDu%kO2~ndeOhu-O zTec#D&6Hf`h)lj7WQ@@fAC+2UOfwncZUk0f8Z^xMyU;3PQl0wr8!IhKH5$VmnL|V3 zGScJi*?}P;anUK3jG=19z$kt34IfkLFl(&(J1=9jBPXV!BqK0d&2sHVTy(r8+qL4H zz%<9uRDG%;Kj-HD#u?muJ;wn-Cl_MokaW z$7WUN0*jIixyC44S#(NVrp}yRT#=YjH8^INHQr&$D~l~iOAA+xVU{>GH9aHKnoyi? z(v{i9lxLfhN9$8g2S&ZYZU-sG4ZTX9eKQS4b(S!OpE zmlwJ`-1L%X&a#)g&%U2~cEpX@5w00O*I9QR;^M+GH&vCnPj;! zUCu7YayMJ}m5eI9PEV!QEQ{Z`nrhE))oSjeR@0Umg^5|)ds*>jwV`KS7mM!ft5p;i zQ|9OzsP#ORG_7Ydj!e)sSDU&A^_w+FEHPVSvr3C?)=FI)wUyi2pqck=R^L=}ma|yb zN$u#KQ=0kQKBq4!vAEgAwF2Krz1qH&SD;P}R0DN^uFsInR$js3y1*da&7oTIFQaf; zE8Srf>r}PpjVS#8DvG31TVA2X?3;3fKh+GinP;8r8^LsQM--}~7&O|UyZD<;OV=FL zkKWv3`(s__t&Hydu-BXpbaG|4w{hr;BkfJgd;g?-eD+-{JG-a$@37^)n&g@FT5f$j zc&B2W`flrai&E4iwSz03cAd1X)t2L%ADFPgujMBV77W~Q@b0mj&U%bn7!ad2ayv98 z`cnD@g%MtqQaf!*p+?PPoyNIh`l@=> z*_EqeJ2x?$dDOhAz;jL0`QDD`e%H<{oU`GmVMgv3c|RRlcK*mT&(M*-JU`!cPtAm) zsxN+o0EOR?GPzXOskSQqBJ4N2~CruzRE z${5w#(|HR)9^D_(YW$RJjn));uyW=ouZN%h-YfpyU%J}9%h4AP9J?u?!P8@2Kb?`W z`@W|Z4yeBJ@}3NB%v4j%oRV3FB`a#qZyIqmb!o#!2XiLP_$;Q$qDQWCIs zyL6aZdeHZtcFAQKaS!&c6Z69&gE~NM>;_9Sa=Ostp(-vA)rJ#!-Ug>u5#9@4X!F1c zP2!5(bNtuL$#gXO@Ky$|Cs4`PsJW~?a-~JS<&dx7%o@g7sqEnre=8LDDuYnrhzcT7_x$#8F z;xY4|KCjLmoj9{{-?CPFyD!}t(|Ur33rtxqFrBywruODH`qmER&JyVS10xmd{vDV? zf&y>Hl6&|MxY5Nwe@%}6kQ?1N`V$y+eCE4t^IvQgvU1A%i${EYN`JS%_L$GJ=l0ki zj$F0e^TNvS{e3>z=X~7jm5sd@KUk7JdE0|`m8==F^yM8X>d-8)=5z5U4aD*YLy$M zK%<&jE&k&Eu!rZ`zjv;_6j3nZxox4(9NX-@ZC|rvy$?mfMs z#mA@jHF2@lyLD}j=ORiMq-^LCaCLq9ig#ws@_x(Wy!T+s>bBP=9ZHy1dSZIkv62k? zwEXvjpS^c~PhB+`TuAHZ>JQXW{~(qBDwEDyW$tEyt=)^%6soOn^&<5YU4vVLI;6I} zHK^yIYka*(1_y@dbh@CR@JzMWZ?jsRpVl|;+ZJ0M*}rl4)dP!znhnW{x^Uci*~c?< z<;j@oM+U9mGJCpO|5j~hZL}K2zV(tu&+zYiU+mDX#h;9*zp7P~ZC*uAqT2JtA(@|k zH>vVC`+D|oygXw;n(umpuHP!p$sZiP+HC8@Lcbq3RUYwbS+h1;t*$%&RvhlWtL}7{ zX^LxGU2T`M_FC1*-#n=%R2%GS<}|LpPSe%>>F(@YpMwt1vv{2yYPrj!e)@$Gr;_)6 z_g3S%FC}+a|Kc-i-_CdRbLp1jE}95(C2zw`nkYEDWykMm;)ZT<{#)Vl56|Xpy2aIt z>27BT_fU2IKa`ul(<{#Fg5|)-!;c!C+%)d<)@=`kZ!uofjCtwPf?XcFm4$C6cbtF! z{g#BB;0gXpht(CSgAZzdObIrPY4h~wH9_}v-Tc)dLrt@PuUDKm1k2UYt4^9ndnc`) zT{3#!)K~X=C8zt;&ex5DuhTr0`O*2%W#iv_^@^p(wt;oSyie$VnmwSRPl5i4_u5Uh zeEDN#-!-$=HsSue%Sx79eP95q?YfWuJb%fMUMF|dGwylgYs_{hH6)lTXMyDhkE6|mMc!po#~bTTCO;6c2T;2s8{|~k*ihX)LJld{w90> zkzV<)<%;tUy7uq&N-d!M2Xe)EhkE62<%-c&@$`2lSDfy)>5pysKdWx6y-ZJyfn^cg7~MqGJhP2m%o^8;@y z5$vJS#;8X2^_br$?$AM#?^++j?w8-UKL6Fu^~Cu4P{}GLFWV3O@6Vla)U7%~Te{v{SFAqCcW`08ufbx=8RZ)s z=$?C4pAoIJ-||pOw6d_yz~-9fn!0sezcOn&M%?~GwEM4x->&UR(aLRqG$al5@N`e! R?Rx!GN257e5Upr5{{!V0c4Pnm diff --git a/test/resource/formsystemtestability/fmsSystemTestHostCommonA/BUILD.gn b/test/resource/formsystemtestability/fmsSystemTestHostCommonA/BUILD.gn index 7cd4bdc2bb..d68dd6133b 100644 --- a/test/resource/formsystemtestability/fmsSystemTestHostCommonA/BUILD.gn +++ b/test/resource/formsystemtestability/fmsSystemTestHostCommonA/BUILD.gn @@ -74,7 +74,7 @@ ohos_shared_library("fmsSystemTestHostCommonA") { "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "samgr_L2:samgr_proxy", ] subsystem_name = "formsystemtestability" } diff --git a/test/resource/formsystemtestability/fmsSystemTestHostCommonB/BUILD.gn b/test/resource/formsystemtestability/fmsSystemTestHostCommonB/BUILD.gn index d6fb1e579a..2d93b79c14 100644 --- a/test/resource/formsystemtestability/fmsSystemTestHostCommonB/BUILD.gn +++ b/test/resource/formsystemtestability/fmsSystemTestHostCommonB/BUILD.gn @@ -74,7 +74,7 @@ ohos_shared_library("fmsSystemTestHostCommonB") { "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "samgr_L2:samgr_proxy", ] subsystem_name = "formsystemtestability" } diff --git a/test/resource/formsystemtestability/fmsSystemTestHostNormal/BUILD.gn b/test/resource/formsystemtestability/fmsSystemTestHostNormal/BUILD.gn index 97d3331b98..97f7b4d475 100755 --- a/test/resource/formsystemtestability/fmsSystemTestHostNormal/BUILD.gn +++ b/test/resource/formsystemtestability/fmsSystemTestHostNormal/BUILD.gn @@ -76,7 +76,7 @@ ohos_shared_library("fmsSystemTestHostNormal") { "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "samgr_L2:samgr_proxy", ] subsystem_name = "formsystemtestability" } diff --git a/test/resource/formsystemtestability/fmsSystemTestHostNormalB/BUILD.gn b/test/resource/formsystemtestability/fmsSystemTestHostNormalB/BUILD.gn index d4b35c6b31..30e6a8c55b 100755 --- a/test/resource/formsystemtestability/fmsSystemTestHostNormalB/BUILD.gn +++ b/test/resource/formsystemtestability/fmsSystemTestHostNormalB/BUILD.gn @@ -74,7 +74,7 @@ ohos_shared_library("fmsSystemTestHostNormalB") { "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "samgr_L2:samgr_proxy", ] subsystem_name = "formsystemtestability" } diff --git a/test/resource/formsystemtestability/fmsSystemTestHostNormalC/BUILD.gn b/test/resource/formsystemtestability/fmsSystemTestHostNormalC/BUILD.gn index beac2d5327..5630620e87 100755 --- a/test/resource/formsystemtestability/fmsSystemTestHostNormalC/BUILD.gn +++ b/test/resource/formsystemtestability/fmsSystemTestHostNormalC/BUILD.gn @@ -74,7 +74,7 @@ ohos_shared_library("fmsSystemTestHostNormalC") { "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "samgr_L2:samgr_proxy", ] subsystem_name = "formsystemtestability" } diff --git a/test/systemtest/BUILD.gn b/test/systemtest/BUILD.gn index ad06723297..9865e4bf44 100755 --- a/test/systemtest/BUILD.gn +++ b/test/systemtest/BUILD.gn @@ -26,7 +26,6 @@ group("systemtest") { "common/ams:systemtest", "common/bms:systemtest_bms", "common/ems:systemtest_ems", - "common/fms:systemtest", "common/task_dispatcher:systemtest_task", ] } diff --git a/test/systemtest/common/ams/BUILD.gn b/test/systemtest/common/ams/BUILD.gn index 97e7c287b5..1e2cca024f 100755 --- a/test/systemtest/common/ams/BUILD.gn +++ b/test/systemtest/common/ams/BUILD.gn @@ -32,6 +32,7 @@ group("systemtest") { deps = [ "ams_aa_command_test:systemtest", "ams_ability_append_test:systemtest", + "ams_ability_state_test:systemtest", "ams_ability_visible_test:systemtest", "ams_app_process_manage_test:systemtest", "ams_configuration_updated_test:systemtest", diff --git a/test/systemtest/common/ams/ams_ability_state_test/BUILD.gn b/test/systemtest/common/ams/ams_ability_state_test/BUILD.gn new file mode 100755 index 0000000000..1e86e4f161 --- /dev/null +++ b/test/systemtest/common/ams/ams_ability_state_test/BUILD.gn @@ -0,0 +1,82 @@ +# 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. + +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/appexecfwk/standard/appexecfwk.gni") +module_output_path = "appexecfwk_standard/ams/" + +config("system_test_ams_ability_state_test_config") { + include_dirs = + [ "//foundation/appexecfwk/standard/kits/appkit/native/app/include" ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } +} + +ohos_systemtest("ams_ability_state_test") { + module_out_path = module_output_path + + include_dirs = [ + "//foundation/distributedschedule/safwk/services/safwk/include", + "//foundation/appexecfwk/standard/test/systemtest/common/ams/tool/include", + "//base/notification/ces_standard/test/systemtest/common/resource", + ] + + sources = [ + "//foundation/appexecfwk/standard/test/systemtest/common/ams/tool/src/event.cpp", + "//foundation/appexecfwk/standard/test/systemtest/common/ams/tool/src/module_test_dump_util.cpp", + "//foundation/appexecfwk/standard/test/systemtest/common/ams/tool/src/st_ability_util.cpp", + "//foundation/appexecfwk/standard/test/systemtest/common/ams/tool/src/stoperator.cpp", + "ams_ability_state_test.cpp", + ] + + configs = [ + "${aafwk_path}/services/abilitymgr:abilityms_config", + "${appexecfwk_path}/services/appmgr:appmgr_config", + "//foundation/appexecfwk/standard/kits:appkit_config", + + ":system_test_ams_ability_state_test_config", + "//foundation/appexecfwk/standard/test/systemtest/common/ams/tool/:system_test_ability_util_config", + "//foundation/appexecfwk/standard/libs/libeventhandler:libeventhandler_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${aafwk_path}/interfaces/innerkits/want:want", + "${aafwk_path}/services/abilitymgr:abilityms", + "${appexecfwk_path}/interfaces/innerkits/appexecfwk_base:appexecfwk_base", + "${appexecfwk_path}/interfaces/innerkits/appexecfwk_core:appexecfwk_core", + "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", + "//foundation/appexecfwk/standard/kits:appkit_native", + "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "//third_party/googletest:gtest_main", + "//utils/native/base:utils", + ] + + external_deps = [ + "ces_standard:cesfwk_innerkits", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + ] +} + +group("systemtest") { + testonly = true + + deps = [ ":ams_ability_state_test" ] +} diff --git a/test/systemtest/common/ams/ams_ability_state_test/ams_ability_state_test.cpp b/test/systemtest/common/ams/ams_ability_state_test/ams_ability_state_test.cpp new file mode 100644 index 0000000000..523052c668 --- /dev/null +++ b/test/systemtest/common/ams/ams_ability_state_test/ams_ability_state_test.cpp @@ -0,0 +1,290 @@ +/* + * 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. + */ +#include +#include "ability_lifecycle_executor.h" +#include "common_event_manager.h" +#include "st_ability_util.h" +#include "testConfigParser.h" + +namespace { +using namespace OHOS; +using namespace OHOS::AppExecFwk; +using namespace OHOS::AAFwk; +using namespace OHOS::EventFwk; +using namespace OHOS::STtools; +using namespace testing::ext; +using namespace STABUtil; +namespace { +const std::string bundleName = "com.ohos.amsst.fwkAbilityState"; +const std::string firstAbilityName = "FwkAbilityStateMain"; +const std::string secondAbilityname = "FwkAbilityStateSecond"; +std::string FwkAbilityState_Event_Resp_A = "resp_com_ohos_amsst_FwkAbilityStateA"; +std::string FwkAbilityState_Event_Requ_A = "requ_com_ohos_amsst_FwkAbilityStateA"; +std::string FwkAbilityState_Event_Requ_B = "requ_com_ohos_amsst_FwkAbilityStateB"; +constexpr int onActive = 1; +constexpr int onBackground = 2; +constexpr int onStop = 3; +constexpr int WAIT_TIME = 100; +constexpr int DELAY = 10; +} +class AmsAbilityStateTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + + static bool SubscribeEvent(); + class AppEventSubscriber : public OHOS::EventFwk::CommonEventSubscriber { + public: + explicit AppEventSubscriber(const OHOS::EventFwk::CommonEventSubscribeInfo &sp) : CommonEventSubscriber(sp) {}; + virtual void OnReceiveEvent(const OHOS::EventFwk::CommonEventData &data) override; + ~AppEventSubscriber() = default; + }; + + void StartAbility(const std::string &abilityName, const std::string &bundleName); + static OHOS::sptr abilityMs; + static OHOS::STtools::Event event; + static OHOS::StressTestLevel stLevel_; + static std::shared_ptr subscriber_; +}; + +Event AmsAbilityStateTest::event = OHOS::STtools::Event(); +sptr AmsAbilityStateTest::abilityMs = nullptr; +StressTestLevel AmsAbilityStateTest::stLevel_ {}; +std::shared_ptr AmsAbilityStateTest::subscriber_ = nullptr; + +void AmsAbilityStateTest::SetUpTestCase(void) +{ + if (!SubscribeEvent()) { + GTEST_LOG_(INFO) << "SubscribeEvent error"; + } + TestConfigParser tcp; + tcp.ParseFromFile4StressTest(STRESS_TEST_CONFIG_FILE_PATH, stLevel_); + std::cout << "stress test level : " + << "AMS : " << stLevel_.AMSLevel << " " + << "BMS : " << stLevel_.BMSLevel << " " + << "CES : " << stLevel_.CESLevel << std::endl; + stLevel_.AMSLevel = 1; +} +void AmsAbilityStateTest::TearDownTestCase(void) +{ + CommonEventManager::UnSubscribeCommonEvent(subscriber_); +} + +void AmsAbilityStateTest::SetUp() +{ + std::vector hapNameList = {"fwkAbilityState"}; + STAbilityUtil::InstallHaps(hapNameList); +} + +void AmsAbilityStateTest::TearDown() +{ + std::vector bundleNameList = { + bundleName, + }; + STAbilityUtil::UninstallBundle(bundleNameList); + STAbilityUtil::CleanMsg(event); +} + +void AmsAbilityStateTest::AppEventSubscriber::OnReceiveEvent(const CommonEventData &data) +{ + GTEST_LOG_(INFO) << "OnReceiveEvent: event=" << data.GetWant().GetAction(); + GTEST_LOG_(INFO) << "OnReceiveEvent: data=" << data.GetData(); + GTEST_LOG_(INFO) << "OnReceiveEvent: code=" << data.GetCode(); + STAbilityUtil::Completed(event, data.GetWant().GetAction(), data.GetCode(), data.GetData()); +} + +bool AmsAbilityStateTest::SubscribeEvent() +{ + std::vector eventList = { + FwkAbilityState_Event_Resp_A, + }; + MatchingSkills matchingSkills; + for (const auto &e : eventList) { + matchingSkills.AddEvent(e); + } + CommonEventSubscribeInfo subscribeInfo(matchingSkills); + subscribeInfo.SetPriority(1); + auto subscriber = std::make_shared(subscribeInfo); + return CommonEventManager::SubscribeCommonEvent(subscriber); +} + +void AmsAbilityStateTest::StartAbility(const std::string &abilityName, const std::string &bundleName) +{ + std::map params; + Want want = STAbilityUtil::MakeWant("device", abilityName, bundleName, params); + ErrCode result = STAbilityUtil::StartAbility(want, abilityMs, WAIT_TIME); + GTEST_LOG_(INFO) << "AmsAbilityStateTest::StartAbility : " << result; + EXPECT_EQ(0, STAbilityUtil::WaitCompleted(event, bundleName, 0, DELAY)); +} + +/** + * @tc.number : FWK_SaveAbilityState_0100 + * @tc.name : onSaveAbilityState called when home event + * @tc.desc : onSaveAbilityState called when home event + */ +HWTEST_F(AmsAbilityStateTest, FWK_SaveAbilityState_0100, Function | MediumTest | Level1) +{ + std::string data; + Want wantEntity; + wantEntity.AddEntity(Want::FLAG_HOME_INTENT_FROM_SYSTEM); + bool result = false; + for (int i = 0; i < stLevel_.AMSLevel; i++) { + // start ability + StartAbility(firstAbilityName, bundleName); + // home + STAbilityUtil::StartAbility(wantEntity, abilityMs); + // ability state BACKGROUND + EXPECT_EQ(0, STAbilityUtil::WaitCompleted(event, FwkAbilityState_Event_Resp_A, onBackground, DELAY)); + data = STAbilityUtil::GetData(event, FwkAbilityState_Event_Resp_A, onBackground); + result = data.compare("OnInactiveOnSaveAbilityStateOnBackground") == 0; + EXPECT_TRUE(result); + if (!result && i > 0) { + GTEST_LOG_(INFO) << "FWK_SaveAbilityState_0100 : " << i; + break; + } + } +} + +/** + * @tc.number : FWK_SaveAbilityState_0200 + * @tc.name : onSaveAbilityState called when system property changes + * @tc.desc : onSaveAbilityState called when system property changes + */ +HWTEST_F(AmsAbilityStateTest, FWK_SaveAbilityState_0200, Function | MediumTest | Level1) +{ + StartAbility(firstAbilityName, bundleName); + std::string data; + DummyConfiguration configuration {"orientation#"}; + bool result = false; + for (int i = 0; i < stLevel_.AMSLevel; i++) { + abilityMs->UpdateConfiguration(configuration); + EXPECT_EQ(0, STAbilityUtil::WaitCompleted(event, FwkAbilityState_Event_Resp_A, onStop, DELAY)); + data = STAbilityUtil::GetData(event, FwkAbilityState_Event_Resp_A, onStop); + result = data.compare("OnInactiveOnSaveAbilityStateOnBackgroundOnStop") == 0; + EXPECT_TRUE(result); + if (!result && i > 0) { + GTEST_LOG_(INFO) << "FWK_SaveAbilityState_0200 : " << i; + break; + } + } +} + +/** + * @tc.number : FWK_SaveAbilityState_0300 + * @tc.name : onSaveAbilityState called when start another ability + * @tc.desc : onSaveAbilityState called when start another ability + */ +HWTEST_F(AmsAbilityStateTest, FWK_SaveAbilityState_0300, Function | MediumTest | Level1) +{ + std::string eventData = "StartNextAbility"; + std::string resultData; + bool result = false; + for (int i = 0; i < stLevel_.AMSLevel; i++) { + StartAbility(firstAbilityName, bundleName); + STAbilityUtil::PublishEvent(FwkAbilityState_Event_Requ_A, onActive, eventData); + EXPECT_EQ(0, STAbilityUtil::WaitCompleted(event, FwkAbilityState_Event_Resp_A, onBackground, DELAY)); + resultData = STAbilityUtil::GetData(event, FwkAbilityState_Event_Resp_A, onBackground); + result = resultData.compare("OnInactiveOnSaveAbilityStateOnBackground") == 0; + EXPECT_TRUE(result); + if (!result && i > 0) { + GTEST_LOG_(INFO) << "FWK_SaveAbilityState_0300 : " << i; + break; + } + } +} + +/** + * @tc.number : FWK_RestoreAbilityState_0100 + * @tc.name : onRestoreAbilityState called when restart after home event + * @tc.desc : onRestoreAbilityState called when restart after home event + */ +HWTEST_F(AmsAbilityStateTest, FWK_RestoreAbilityState_0100, Function | MediumTest | Level1) +{ + StartAbility(firstAbilityName, bundleName); + std::string data; + Want wantEntity; + wantEntity.AddEntity(Want::FLAG_HOME_INTENT_FROM_SYSTEM); + bool result = false; + for (int i = 0; i < stLevel_.AMSLevel; i++) { + // home + STAbilityUtil::StartAbility(wantEntity, abilityMs); + // ability state BACKGROUND + EXPECT_EQ(0, STAbilityUtil::WaitCompleted(event, FwkAbilityState_Event_Resp_A, onBackground, DELAY)); + // restart ability + StartAbility(firstAbilityName, bundleName); + EXPECT_EQ(0, STAbilityUtil::WaitCompleted(event, FwkAbilityState_Event_Resp_A, onActive, DELAY)); + data = STAbilityUtil::GetData(event, FwkAbilityState_Event_Resp_A, onActive); + result = data.compare("OnForegroundOnRestoreAbilityStateOnActive") == 0; + EXPECT_TRUE(result); + if (!result && i > 0) { + GTEST_LOG_(INFO) << "FWK_RestoreAbilityState_0100 : " << i; + break; + } + } +} + +/** + * @tc.number : FWK_RestoreAbilityState_0200 + * @tc.name : onRestoreAbilityState called when system property changes + * @tc.desc : onRestoreAbilityState called when system property changes + */ +HWTEST_F(AmsAbilityStateTest, FWK_RestoreAbilityState_0200, Function | MediumTest | Level1) +{ + StartAbility(firstAbilityName, bundleName); + std::string data; + DummyConfiguration configuration {"orientation#"}; + bool result = false; + for (int i = 0; i < stLevel_.AMSLevel; i++) { + abilityMs->UpdateConfiguration(configuration); + EXPECT_EQ(0, STAbilityUtil::WaitCompleted(event, FwkAbilityState_Event_Resp_A, onActive, DELAY)); + data = STAbilityUtil::GetData(event, FwkAbilityState_Event_Resp_A, onActive); + result = data.compare("OnStartOnRestoreAbilityStateOnActive") == 0; + EXPECT_TRUE(result); + if (!result && i > 0) { + GTEST_LOG_(INFO) << "FWK_RestoreAbilityState_0200 : " << i; + break; + } + } +} + +/** + * @tc.number : FWK_RestoreAbilityState_0300 + * @tc.name : onRestoreAbilityState called when back event after start another ability + * @tc.desc : onRestoreAbilityState called when back event after start another ability + */ +HWTEST_F(AmsAbilityStateTest, FWK_RestoreAbilityState_0300, Function | MediumTest | Level1) +{ + StartAbility(firstAbilityName, bundleName); + std::string eventData; + std::string resultData; + bool result = false; + for (int i = 0; i < stLevel_.AMSLevel; i++) { + eventData = "StartNextAbility"; + STAbilityUtil::PublishEvent(FwkAbilityState_Event_Requ_A, onActive, eventData); + EXPECT_EQ(0, STAbilityUtil::WaitCompleted(event, FwkAbilityState_Event_Resp_A, onBackground, DELAY)); + eventData = "TerminateSecond"; + STAbilityUtil::PublishEvent(FwkAbilityState_Event_Requ_B, onStop, eventData); + resultData = STAbilityUtil::GetData(event, FwkAbilityState_Event_Resp_A, onActive); + result = resultData.compare("OnForegroundOnRestoreAbilityStateOnActive") == 0; + EXPECT_TRUE(result); + if (!result && i > 0) { + GTEST_LOG_(INFO) << "FWK_RestoreAbilityState_0300 : " << i; + break; + } + } +} +} // namespace \ No newline at end of file diff --git a/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp b/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp index cf25fff20f..b0b9009f58 100644 --- a/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp +++ b/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp @@ -53,7 +53,6 @@ const int TARGETVERSION = 3; namespace OHOS { namespace AppExecFwk { - class BundleStatusCallbackImpl : public BundleStatusCallbackHost { public: BundleStatusCallbackImpl(); @@ -194,7 +193,6 @@ public: void CheckFileNonExist(const std::string &bundleName, const std::string &modulePackage) const; static StressTestLevel stLevel_; }; - StressTestLevel ActsBmsKitSystemTest::stLevel_{}; void ActsBmsKitSystemTest::SetUpTestCase() @@ -2429,11 +2427,8 @@ HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0200, Function | MediumTest | Le std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle2.hap"; std::string appName = BASE_BUNDLE_NAME + "1"; Install(bundleFilePath, InstallFlag::NORMAL, resvec); - CommonTool commonTool; - std::string installResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(installResult, "Success") << "install fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; AbilityInfo abilityInfo; abilityInfo.bundleName = appName; abilityInfo.package = BASE_BUNDLE_NAME + ".h1"; @@ -2462,8 +2457,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0200, Function | MediumTest | Le } resvec.clear(); Uninstall(appName, resvec); - std::string uninstallResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!"; if (!queryResult) { APP_LOGI("GetHapModuleInfo_0200 failed - cycle count: %{public}d", i); @@ -2471,7 +2465,6 @@ HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0200, Function | MediumTest | Le } result = true; } - if (result && stLevel_.BMSLevel > 1) { APP_LOGI("GetHapModuleInfo_0200 success - cycle count: %{public}d", stLevel_.BMSLevel); } @@ -3080,7 +3073,6 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0700, Function | MediumTest | Level1) std::string firstAppName = BASE_BUNDLE_NAME + "1"; std::string secondFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap"; std::string secondAppName = BASE_BUNDLE_NAME + "2"; - CommonTool commonTool; sptr firstBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl()); EXPECT_NE(firstBundleStatusCallback, nullptr); @@ -3092,37 +3084,28 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0700, Function | MediumTest | Level1) } bundleMgrProxy->RegisterBundleStatusCallback(firstBundleStatusCallback); Install(firstFilePath, InstallFlag::NORMAL, resvec); - std::string firstinstallResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(firstinstallResult, "Success") << "install fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; resvec.clear(); sptr secondBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl()); EXPECT_NE(secondBundleStatusCallback, nullptr); secondBundleStatusCallback->SetBundleName(secondAppName); bundleMgrProxy->RegisterBundleStatusCallback(secondBundleStatusCallback); Install(secondFilePath, InstallFlag::NORMAL, resvec); - std::string secondinstallResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(secondinstallResult, "Success") << "install fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; bool clearResult = bundleMgrProxy->ClearBundleStatusCallback(firstBundleStatusCallback); EXPECT_TRUE(clearResult); - std::vector resvec2; Uninstall(firstAppName, resvec2); - std::string uninstallResult = commonTool.VectorToStr(resvec2); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; + EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!"; resvec2.clear(); Uninstall(secondAppName, resvec2); - uninstallResult = commonTool.VectorToStr(resvec2); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!"; if (!clearResult) { APP_LOGI("Callback_0700 failed - cycle count: %{public}d", i); break; } result = true; } - if (result && stLevel_.BMSLevel > 1) { APP_LOGI("Callback_0700 success - cycle count: %{public}d", stLevel_.BMSLevel); } @@ -3151,7 +3134,6 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0800, Function | MediumTest | Level1) std::string firstAppName = BASE_BUNDLE_NAME + "1"; std::string secondFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap"; std::string secondAppName = BASE_BUNDLE_NAME + "2"; - CommonTool commonTool; sptr firstBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl()); EXPECT_NE(firstBundleStatusCallback, nullptr); @@ -3165,7 +3147,6 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0800, Function | MediumTest | Level1) Install(firstFilePath, InstallFlag::NORMAL, resvec); std::string firstinstallResult = commonTool.VectorToStr(resvec); EXPECT_EQ(firstinstallResult, "Success") << "install fail!"; - resvec.clear(); sptr secondBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl()); EXPECT_NE(secondBundleStatusCallback, nullptr); @@ -3174,26 +3155,20 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0800, Function | MediumTest | Level1) Install(secondFilePath, InstallFlag::NORMAL, resvec); std::string secondinstallResult = commonTool.VectorToStr(resvec); EXPECT_EQ(secondinstallResult, "Success") << "install fail!"; - bool clearResult = bundleMgrProxy->ClearBundleStatusCallback(secondBundleStatusCallback); EXPECT_TRUE(clearResult); - std::vector resvec2; Uninstall(firstAppName, resvec2); - std::string uninstallResult = commonTool.VectorToStr(resvec2); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; + EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!"; resvec2.clear(); Uninstall(secondAppName, resvec2); - uninstallResult = commonTool.VectorToStr(resvec2); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!"; if (!clearResult) { APP_LOGI("Callback_0800 failed - cycle count: %{public}d", i); break; } result = true; } - if (result && stLevel_.BMSLevel > 1) { APP_LOGI("Callback_0800 success - cycle count: %{public}d", stLevel_.BMSLevel); } @@ -3223,7 +3198,6 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0900, Function | MediumTest | Level1) std::string firstAppName = BASE_BUNDLE_NAME + "1"; std::string secondFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap"; std::string secondAppName = BASE_BUNDLE_NAME + "2"; - CommonTool commonTool; sptr firstBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl()); EXPECT_NE(firstBundleStatusCallback, nullptr); @@ -3235,39 +3209,30 @@ HWTEST_F(ActsBmsKitSystemTest, Callback_0900, Function | MediumTest | Level1) } bundleMgrProxy->RegisterBundleStatusCallback(firstBundleStatusCallback); Install(firstFilePath, InstallFlag::NORMAL, resvec); - std::string firstinstallResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(firstinstallResult, "Success") << "install fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; resvec.clear(); sptr secondBundleStatusCallback = (new (std::nothrow) BundleStatusCallbackImpl()); EXPECT_NE(secondBundleStatusCallback, nullptr); secondBundleStatusCallback->SetBundleName(secondAppName); bundleMgrProxy->RegisterBundleStatusCallback(secondBundleStatusCallback); Install(secondFilePath, InstallFlag::NORMAL, resvec); - std::string secondinstallResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(secondinstallResult, "Success") << "install fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; bool clearResult1 = bundleMgrProxy->ClearBundleStatusCallback(firstBundleStatusCallback); EXPECT_TRUE(clearResult1); bool clearResult2 = bundleMgrProxy->ClearBundleStatusCallback(secondBundleStatusCallback); EXPECT_TRUE(clearResult2); - std::vector resvec2; Uninstall(firstAppName, resvec2); - std::string uninstallResult = commonTool.VectorToStr(resvec2); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; + EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!"; resvec2.clear(); Uninstall(secondAppName, resvec2); - uninstallResult = commonTool.VectorToStr(resvec2); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!"; if (!clearResult1 && !clearResult2) { APP_LOGI("Callback_0900 failed - cycle count: %{public}d", i); break; } result = true; } - if (result && stLevel_.BMSLevel > 1) { APP_LOGI("Callback_0900 success - cycle count: %{public}d", stLevel_.BMSLevel); } @@ -3296,9 +3261,9 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0100, Function | MediumTest Install(bundleFilePath, InstallFlag::NORMAL, resvec); std::string installResult = commonTool.VectorToStr(resvec); EXPECT_EQ(installResult, "Success") << "install fail!"; - std::this_thread::sleep_for(5000ms); + std::this_thread::sleep_for(3000ms); system("aa start -a PageAbilityDemo -b com.third.hiworld.example1"); - std::this_thread::sleep_for(1000ms); + std::this_thread::sleep_for(3000ms); const std::string testCacheFileNamE1 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/name1.txt"; const std::string testCacheFileNamE2 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/name2.txt"; int name1Exist = access(testCacheFileNamE1.c_str(), F_OK); @@ -3361,9 +3326,9 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0200, Function | MediumTest Install(bundleFilePath, InstallFlag::NORMAL, resvec); std::string installResult = commonTool.VectorToStr(resvec); EXPECT_EQ(installResult, "Success") << "install fail!"; - std::this_thread::sleep_for(5000ms); + std::this_thread::sleep_for(3000ms); system("aa start -a PageAbilityDemo -b com.third.hiworld.example2"); - std::this_thread::sleep_for(1000ms); + std::this_thread::sleep_for(3000ms); const std::string testCacheDiR1 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/testDir1"; const std::string testCacheDiR2 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/testDir2"; int name1Exist = access(testCacheDiR1.c_str(), F_OK); @@ -3425,9 +3390,9 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0300, Function | MediumTest Install(bundleFilePath, InstallFlag::NORMAL, resvec); std::string installResult = commonTool.VectorToStr(resvec); EXPECT_EQ(installResult, "Success") << "install fail!"; - std::this_thread::sleep_for(5000ms); + std::this_thread::sleep_for(3000ms); system("aa start -a PageAbilityDemo -b com.third.hiworld.example1"); - std::this_thread::sleep_for(1000ms); + std::this_thread::sleep_for(3000ms); const std::string testCacheFileName = BUNDLE_DATA_ROOT_PATH + appName + "/cache/dir1/dir2/dir3/dir4/dir5/dir6"; const std::string testCacheDir = BUNDLE_DATA_ROOT_PATH + appName + "/cache/dir1"; int isExist = access(testCacheDir.c_str(), F_OK); @@ -3480,14 +3445,13 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0400, Function | MediumTest std::vector resvec; std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle45.hap"; std::string appName = BASE_BUNDLE_NAME + "1"; - CommonTool commonTool; Install(bundleFilePath, InstallFlag::NORMAL, resvec); std::string installResult = commonTool.VectorToStr(resvec); EXPECT_EQ(installResult, "Success") << "install fail!"; - std::this_thread::sleep_for(5000ms); + std::this_thread::sleep_for(3000ms); system("aa start -a PageAbilityDemo -b com.third.hiworld.example1"); - std::this_thread::sleep_for(1000ms); + std::this_thread::sleep_for(3000ms); const std::string testCacheFileNamE1 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/testDir1/name1.txt"; const std::string testCacheDir1 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/testDir1"; const std::string testCacheFileNamE2 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/testDir2/name2.txt"; @@ -3510,19 +3474,15 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0400, Function | MediumTest EXPECT_NE(name1Exist, 0) << "the cache test dir1 exists."; name2Exist = access(testCacheDir2.c_str(), F_OK); EXPECT_NE(name2Exist, 0) << "the cache test dir2 exists."; - resvec.clear(); Uninstall(appName, resvec); - std::string uninstallResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!"; if (!cleanCacheResult) { APP_LOGI("CleanBundleCacheFiles_0400 failed - cycle count: %{public}d", i); break; } result = true; } - if (result && stLevel_.BMSLevel > 1) { APP_LOGI("CleanBundleCacheFiles_0400 success - cycle count: %{public}d", stLevel_.BMSLevel); } @@ -3982,11 +3942,8 @@ HWTEST_F(ActsBmsKitSystemTest, AbilityDump_0100, Function | MediumTest | Level0) std::string appName = BASE_BUNDLE_NAME + "1"; std::string abilityName = "bmsThirdBundle_A1"; Install(bundleFilePath, InstallFlag::NORMAL, resvec); - CommonTool commonTool; - std::string installResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(installResult, "Success") << "install fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; Want want; ElementName name; name.SetAbilityName(abilityName); @@ -4002,7 +3959,6 @@ HWTEST_F(ActsBmsKitSystemTest, AbilityDump_0100, Function | MediumTest | Level0) bool queryResult = bundleMgrProxy->QueryAbilityInfo(want, abilityInfo); EXPECT_EQ(abilityInfo.name, abilityName); EXPECT_TRUE(queryResult); - std::string path = "/data/test/abilityInfo.txt"; std::ofstream file(path); file.close(); @@ -4013,19 +3969,15 @@ HWTEST_F(ActsBmsKitSystemTest, AbilityDump_0100, Function | MediumTest | Level0) long length = lseek(fd, 0, SEEK_END); EXPECT_GT(length, 0); close(fd); - resvec.clear(); Uninstall(appName, resvec); - std::string uninstallResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!"; if (!queryResult) { APP_LOGI("AbilityDump_0100 failed - cycle count: %{public}d", i); break; } result = true; } - if (result && stLevel_.BMSLevel > 1) { APP_LOGI("AbilityDump_0100 success - cycle count: %{public}d", stLevel_.BMSLevel); } @@ -4479,14 +4431,10 @@ HWTEST_F(ActsBmsKitSystemTest, ApplicationInfo_0100, Function | MediumTest | Lev bool result = false; for (int i = 1; i <= stLevel_.BMSLevel; i++) { std::vector resvec; - std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap"; std::string appName = BASE_BUNDLE_NAME + "1"; - Install(bundleFilePath, InstallFlag::NORMAL, resvec); - + Install(THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap", InstallFlag::NORMAL, resvec); CommonTool commonTool; - std::string installResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(installResult, "Success") << "install fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; ApplicationInfo appInfo; int userId = Constants::DEFAULT_USERID; sptr bundleMgrProxy = GetBundleMgrProxy(); @@ -4504,8 +4452,7 @@ HWTEST_F(ActsBmsKitSystemTest, ApplicationInfo_0100, Function | MediumTest | Lev file.close(); int fd = open(path.c_str(), O_RDWR); EXPECT_NE(fd, -1) << "open file error"; - std::string prefix = "[pAppInfo]"; - pAppInfo->Dump(prefix, fd); + pAppInfo->Dump("[pAppInfo]", fd); long length = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); std::string strAppInfo; @@ -4516,19 +4463,15 @@ HWTEST_F(ActsBmsKitSystemTest, ApplicationInfo_0100, Function | MediumTest | Lev std::string cacheDir = BUNDLE_DATA_ROOT_PATH + appName + "/cache"; EXPECT_TRUE(IsSubStr(strAppInfo, cacheDir)); close(fd); - resvec.clear(); Uninstall(appName, resvec); - std::string uninstallResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; - + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!"; if (retVal <= 0) { APP_LOGI("ApplicationInfo_0100 failed - cycle count: %{public}d", i); break; } result = true; } - if (result && stLevel_.BMSLevel > 1) { APP_LOGI("ApplicationInfo_0100 success - cycle count: %{public}d", stLevel_.BMSLevel); } @@ -4851,24 +4794,20 @@ HWTEST_F(ActsBmsKitSystemTest, GetBundlesForUid_0100, Function | MediumTest | Le APP_LOGE("bundle mgr proxy is nullptr."); EXPECT_EQ(bundleMgrProxy, nullptr); } - std::string installResult; CommonTool commonTool; for (int i = 6; i <= 8; i++) { std::vector resvec; std::string hapFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle" + std::to_string(i) + ".hap"; - std::cout << "begin install" << hapFilePath << std::endl; Install(hapFilePath, InstallFlag::NORMAL, resvec); - installResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(installResult, "Success") << "install fail!"; + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; } bool ret; for (int i = 1; i <= 3; i++) { std::string appName = BASE_BUNDLE_NAME + std::to_string(i); BundleInfo bundleInfo; bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo); - int uid = bundleInfo.uid; std::vector bundleNames; - ret = bundleMgrProxy->GetBundlesForUid(uid, bundleNames); + ret = bundleMgrProxy->GetBundlesForUid(bundleInfo.uid, bundleNames); EXPECT_TRUE(ret); for (auto bundleName : bundleNames) { EXPECT_EQ(bundleName, appName); @@ -4878,8 +4817,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetBundlesForUid_0100, Function | MediumTest | Le std::vector resvec; std::string appName = BASE_BUNDLE_NAME + std::to_string(i); Uninstall(appName, resvec); - std::string uninstallResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!"; } if (!ret) { APP_LOGI("GetBundlesForUid_0100 failed - cycle count: %{public}d", i); @@ -4984,55 +4922,39 @@ HWTEST_F(ActsBmsKitSystemTest, GetNameForUid_0100, Function | MediumTest | Level bool result = false; for (int i = 1; i <= stLevel_.BMSLevel; i++) { CommonTool commonTool; - std::string installResult; std::vector resvec; - std::string bundleFilePath1 = THIRD_BUNDLE_PATH + "bmsThirdBundle6.hap"; - std::string bundleFilePath2 = THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap"; - std::string appName1 = BASE_BUNDLE_NAME + '1'; - std::string appName2 = BASE_BUNDLE_NAME + '2'; - std::string name1; - std::string name2; - Install(bundleFilePath1, InstallFlag::NORMAL, resvec); - installResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(installResult, "Success") << "install fail!"; + std::string name1, name2; + Install(THIRD_BUNDLE_PATH + "bmsThirdBundle6.hap", InstallFlag::NORMAL, resvec); + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; resvec.clear(); sptr bundleMgrProxy = GetBundleMgrProxy(); if (!bundleMgrProxy) { APP_LOGE("bundle mgr proxy is nullptr."); EXPECT_EQ(bundleMgrProxy, nullptr); } - BundleInfo bundleInfo1; - bundleMgrProxy->GetBundleInfo(appName1, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo1); - int uid1 = bundleInfo1.uid; - bool ret = bundleMgrProxy->GetNameForUid(uid1, name1); + bundleMgrProxy->GetBundleInfo(BASE_BUNDLE_NAME + '1', BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo1); + bool ret = bundleMgrProxy->GetNameForUid(bundleInfo1.uid, name1); EXPECT_TRUE(ret); - - Uninstall(appName1, resvec); + Uninstall(BASE_BUNDLE_NAME + '1', resvec); EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "uninstall fail!"; resvec.clear(); - Install(bundleFilePath2, InstallFlag::NORMAL, resvec); - installResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(installResult, "Success") << "install fail!"; + Install(THIRD_BUNDLE_PATH + "bmsThirdBundle7.hap", InstallFlag::NORMAL, resvec); + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; resvec.clear(); - - Install(bundleFilePath1, InstallFlag::NORMAL, resvec); - installResult = commonTool.VectorToStr(resvec); - EXPECT_EQ(installResult, "Success") << "install fail!"; - + Install(THIRD_BUNDLE_PATH + "bmsThirdBundle6.hap", InstallFlag::NORMAL, resvec); + EXPECT_EQ(commonTool.VectorToStr(resvec), "Success") << "install fail!"; BundleInfo bundleInfo2; - bundleMgrProxy->GetBundleInfo(appName1, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo2); - int uid2 = bundleInfo2.uid; - ret = bundleMgrProxy->GetNameForUid(uid2, name2); + bundleMgrProxy->GetBundleInfo(BASE_BUNDLE_NAME + '1', BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo2); + ret = bundleMgrProxy->GetNameForUid(bundleInfo2.uid, name2); EXPECT_TRUE(ret); - EXPECT_NE(uid1, uid2); + EXPECT_NE(bundleInfo1.uid, bundleInfo2.uid); EXPECT_EQ(name1, name2); for (int i = 1; i <= 2; i++) { std::string appName = BASE_BUNDLE_NAME + std::to_string(i); std::vector resvec2; Uninstall(appName, resvec2); - std::string uninstallResult = commonTool.VectorToStr(resvec2); - EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!"; + EXPECT_EQ(commonTool.VectorToStr(resvec2), "Success") << "uninstall fail!"; } if (!ret) { APP_LOGI("GetNameForUid_0100 failed - cycle count: %{public}d", i); @@ -5040,7 +4962,6 @@ HWTEST_F(ActsBmsKitSystemTest, GetNameForUid_0100, Function | MediumTest | Level } result = true; } - if (result && stLevel_.BMSLevel > 1) { APP_LOGI("GetNameForUid_0100 success - cycle count: %{public}d", stLevel_.BMSLevel); } diff --git a/test/systemtest/common/bms/bms_compatible_system_test/bms_compatible_system_test.cpp b/test/systemtest/common/bms/bms_compatible_system_test/bms_compatible_system_test.cpp index b17f871fe2..097a2f34b9 100644 --- a/test/systemtest/common/bms/bms_compatible_system_test/bms_compatible_system_test.cpp +++ b/test/systemtest/common/bms/bms_compatible_system_test/bms_compatible_system_test.cpp @@ -49,7 +49,6 @@ const int MIN_WIDTH = 100; const int DEFAULT_HEIGHT = 100; const int DEFAULT_WIDTH = 200; const int FORM_NUM = 3; - } // namespace using OHOS::AAFwk::Want; using namespace testing::ext; @@ -228,9 +227,11 @@ static void CheckCompatibleApplicationInfo( EXPECT_EQ(compatibleApplicationInfo.name, bundleName); EXPECT_EQ(compatibleApplicationInfo.label, "$string:app_name"); EXPECT_EQ(compatibleApplicationInfo.description, "$string:mainability_description"); - EXPECT_EQ(compatibleApplicationInfo.moduleInfos[0].moduleName, "entry"); - EXPECT_EQ(compatibleApplicationInfo.moduleInfos[0].moduleSourceDir, - "/data/accounts/account_0/applications/com.example.third1/com.example.third1"); + if (!compatibleApplicationInfo.moduleInfos.empty()) { + EXPECT_EQ(compatibleApplicationInfo.moduleInfos[0].moduleName, "entry"); + EXPECT_EQ(compatibleApplicationInfo.moduleInfos[0].moduleSourceDir, + "/data/accounts/account_0/applications/com.example.third1/com.example.third1"); + } EXPECT_TRUE(compatibleApplicationInfo.enabled); } /** @@ -725,6 +726,5 @@ HWTEST_F(BmsCompatibleSystemTest, BMS_QueryAbilityInfoByUri_0300, Function | Med EXPECT_EQ(abilityInfo.uri, ""); GTEST_LOG_(INFO) << "END BMS_QueryAbilityInfoByUri_0300"; } - } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/common/bms/bms_install_system_test/bms_install_system_test.cpp b/test/systemtest/common/bms/bms_install_system_test/bms_install_system_test.cpp old mode 100755 new mode 100644 index 3d0b62e0a7..721ac1d847 --- a/test/systemtest/common/bms/bms_install_system_test/bms_install_system_test.cpp +++ b/test/systemtest/common/bms/bms_install_system_test/bms_install_system_test.cpp @@ -31,7 +31,6 @@ using namespace testing::ext; using namespace std::chrono_literals; namespace { - const std::string THIRD_BUNDLE_PATH = "/data/test/bms_bundle/"; const std::string CODE_ROOT_PATH = "/data/accounts/account_0/applications/"; const std::string DATA_ROOT_PATH = "/data/accounts/account_0/appdata/"; @@ -41,6 +40,7 @@ const std::string SYSTEM_BASE_BUNDLE_NAME = "com.system.hiworld.example"; const std::string MSG_SUCCESS = "[SUCCESS]"; const std::string OPERATION_FAILURE = "Failure"; const std::string OPERATION_SUCCESS = "Success"; +const int TIMEOUT = 10; } // namespace namespace OHOS { @@ -87,7 +87,7 @@ void StatusReceiverImpl::OnFinished(const int32_t resultCode, const std::string std::string StatusReceiverImpl::GetResultMsg() const { auto future = resultMsgSignal_.get_future(); - std::chrono::seconds timeout(10); + std::chrono::seconds timeout(TIMEOUT); if (future.wait_for(timeout) == std::future_status::timeout) { return OPERATION_FAILURE + " timeout"; } @@ -2446,6 +2446,5 @@ HWTEST_F(BmsInstallSystemTest, BMS_DFX_0400, Function | MediumTest | Level2) EXPECT_FALSE(getInfoResult); std::cout << "END BMS_DFX_0400" << std::endl; } - } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/common/bms/bms_launcher_service_system_test/bms_launcher_service_system_test.cpp b/test/systemtest/common/bms/bms_launcher_service_system_test/bms_launcher_service_system_test.cpp index 3fa58800fc..faafa769fd 100644 --- a/test/systemtest/common/bms/bms_launcher_service_system_test/bms_launcher_service_system_test.cpp +++ b/test/systemtest/common/bms/bms_launcher_service_system_test/bms_launcher_service_system_test.cpp @@ -44,7 +44,7 @@ const std::string BUNDLE_ADD = "Bundle Add Success"; const std::string BUNDLE_UPDATE = "Bundle Update Success"; const std::string BUNDLE_REMOVE = "Bundle Remove Success"; constexpr uint32_t WAIT_SECONDS = 5; - +const unsigned int LIST_SIZE = 2; } // namespace using OHOS::AAFwk::Want; using namespace testing::ext; @@ -173,7 +173,7 @@ void BmsLauncherServiceSystemTest::Install( InstallParam installParam; installParam.installFlag = installFlag; installParam.userId = Constants::DEFAULT_USERID; - sptr statusReceiver = (new (std::nothrow) StatusReceiverImpl()); + sptr statusReceiver = new (std::nothrow) StatusReceiverImpl(); EXPECT_NE(statusReceiver, nullptr); installerProxy->Install(bundleFilePath, installParam, statusReceiver); installMessage = statusReceiver->GetResultMsg(); @@ -194,7 +194,7 @@ void BmsLauncherServiceSystemTest::Uninstall(const std::string &bundleName, std: } else { InstallParam installParam; installParam.userId = Constants::DEFAULT_USERID; - sptr statusReceiver = (new (std::nothrow) StatusReceiverImpl()); + sptr statusReceiver = new (std::nothrow) StatusReceiverImpl(); EXPECT_NE(statusReceiver, nullptr); installerProxy->Uninstall(bundleName, installParam, statusReceiver); uninstallMessage = statusReceiver->GetResultMsg(); @@ -294,13 +294,13 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_Register_0100, Function | MediumTest std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap"; std::string bundleName = "com.example.third1"; std::string message; - std::shared_ptr launcherservice = std::make_shared(); + LauncherService launcherservice; sptr callback = new TestBundleStatusCallback(); - launcherservice->RegisterCallback(callback); + launcherservice.RegisterCallback(callback); Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; EXPECT_TRUE(Wait(BUNDLE_ADD)); - launcherservice->UnRegisterCallback(); + launcherservice.UnRegisterCallback(); Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; GTEST_LOG_(INFO) << "END BMS_Register_0100"; @@ -316,15 +316,15 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_Register_0200, Function | MediumTest std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap"; std::string bundleName = "com.example.third1"; std::string message; - std::shared_ptr launcherservice = std::make_shared(); + LauncherService launcherservice; sptr callback = new TestBundleStatusCallback(); - launcherservice->RegisterCallback(callback); + launcherservice.RegisterCallback(callback); Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; Uninstall(bundleName, message); EXPECT_TRUE(Wait(BUNDLE_REMOVE)); EXPECT_EQ(message, "Success") << "uninstall fail!"; - launcherservice->UnRegisterCallback(); + launcherservice.UnRegisterCallback(); GTEST_LOG_(INFO) << "END BMS_Register_0200"; } /** @@ -339,16 +339,16 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_Register_0300, Function | MediumTest std::string bundleFilePath1 = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap"; std::string bundleFilePath2 = THIRD_BUNDLE_PATH + "bmsThirdBundle4.hap"; std::string message; - std::shared_ptr launcherservice = std::make_shared(); + LauncherService launcherservice; sptr callback = new TestBundleStatusCallback(); - launcherservice->RegisterCallback(callback); + launcherservice.RegisterCallback(callback); Install(bundleFilePath1, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; EXPECT_TRUE(Wait(BUNDLE_ADD)); Install(bundleFilePath2, InstallFlag::REPLACE_EXISTING, message); EXPECT_EQ(message, "Success") << "install fail!"; EXPECT_TRUE(Wait(BUNDLE_UPDATE)); - launcherservice->UnRegisterCallback(); + launcherservice.UnRegisterCallback(); Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; GTEST_LOG_(INFO) << "END BMS_Register_0300"; @@ -364,10 +364,10 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_Register_0400, Function | MediumTest std::string bundleName = THIRD_BASE_BUNDLE_NAME + "2"; std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle2.hap"; std::string message; - std::shared_ptr launcherservice = std::make_shared(); + LauncherService launcherservice; sptr callback = new TestBundleStatusCallback(); - launcherservice->RegisterCallback(callback); - launcherservice->UnRegisterCallback(); + launcherservice.RegisterCallback(callback); + launcherservice.UnRegisterCallback(); Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; EXPECT_FALSE(Wait(BUNDLE_ADD)); @@ -392,17 +392,14 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityList_0100, Function | Mediu Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; - std::shared_ptr launcherservice = std::make_shared(); + LauncherService launcherservice; std::vector launcherAbilityInfos; - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetAbilityList(bundleName, userId, launcherAbilityInfos); + bool result = launcherservice.GetAbilityList(bundleName, userId, launcherAbilityInfos); EXPECT_TRUE(result) << "Get ability list failed"; EXPECT_FALSE(launcherAbilityInfos.empty()) << "Launcher ability infos is empty"; - EXPECT_EQ(launcherAbilityInfos[0].name, abilityName); - + if (!launcherAbilityInfos.empty()) { + EXPECT_EQ(launcherAbilityInfos[0].name, abilityName); + } Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; GTEST_LOG_(INFO) << "END BMS_GetAbilityList_0100"; @@ -429,17 +426,14 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityList_0200, Function | Mediu Install(bundleFilePath2, InstallFlag::REPLACE_EXISTING, message); EXPECT_EQ(message, "Success") << "install fail!"; - std::shared_ptr launcherservice = std::make_shared(); + LauncherService launcherservice; std::vector launcherAbilityInfos; - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetAbilityList(bundleName, userId, launcherAbilityInfos); + bool result = launcherservice.GetAbilityList(bundleName, userId, launcherAbilityInfos); EXPECT_TRUE(result) << "Get ability list failed"; EXPECT_FALSE(launcherAbilityInfos.empty()) << "Launcher ability infos is empty"; - EXPECT_EQ(launcherAbilityInfos[0].name, abilityName); - + if (!launcherAbilityInfos.empty()) { + EXPECT_EQ(launcherAbilityInfos[0].name, abilityName); + } Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; GTEST_LOG_(INFO) << "END BMS_GetAbilityList_0200"; @@ -462,17 +456,17 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityList_0300, Function | Mediu Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; std::vector launcherAbilityInfos; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetAbilityList(bundleName, userId, launcherAbilityInfos); + LauncherService launcherservice; + + bool result = launcherservice.GetAbilityList(bundleName, userId, launcherAbilityInfos); EXPECT_TRUE(result) << "Get ability list failed"; EXPECT_FALSE(launcherAbilityInfos.empty()) << "Launcher ability infos is empty"; - EXPECT_GE(launcherAbilityInfos.size(), 1); - EXPECT_EQ(launcherAbilityInfos[0].name, abilityName1); - EXPECT_EQ(launcherAbilityInfos[1].name, abilityName2); + EXPECT_EQ(launcherAbilityInfos.size(), LIST_SIZE); + if (!launcherAbilityInfos.empty()) { + + EXPECT_EQ(launcherAbilityInfos[0].name, abilityName1); + EXPECT_EQ(launcherAbilityInfos[1].name, abilityName2); + } Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; GTEST_LOG_(INFO) << "END BMS_GetAbilityList_0300"; @@ -500,17 +494,17 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityList_0400, Function | Mediu Install(bundleFilePath2, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; std::vector launcherAbilityInfos; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetAbilityList(bundleName, userId, launcherAbilityInfos); + LauncherService launcherservice; + + bool result = launcherservice.GetAbilityList(bundleName, userId, launcherAbilityInfos); EXPECT_TRUE(result) << "Get ability list failed"; EXPECT_FALSE(launcherAbilityInfos.empty()) << "Launcher ability infos is empty"; - EXPECT_GE(launcherAbilityInfos.size(), 1); - EXPECT_EQ(launcherAbilityInfos[0].name, abilityName1); - EXPECT_EQ(launcherAbilityInfos[1].name, abilityName2); + EXPECT_EQ(launcherAbilityInfos.size(), LIST_SIZE); + if (!launcherAbilityInfos.empty()) { + EXPECT_EQ(launcherAbilityInfos[0].name, abilityName1); + EXPECT_EQ(launcherAbilityInfos[1].name, abilityName2); + } + Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; GTEST_LOG_(INFO) << "END BMS_GetAbilityList_0400"; @@ -527,12 +521,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityList_0500, Function | Mediu int userId = Constants::DEFAULT_USERID; std::vector launcherAbilityInfos; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetAbilityList(bundleName, userId, launcherAbilityInfos); + LauncherService launcherservice; + + bool result = launcherservice.GetAbilityList(bundleName, userId, launcherAbilityInfos); EXPECT_FALSE(result); GTEST_LOG_(INFO) << "END BMS_GetAbilityList_0500"; } @@ -554,21 +545,20 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityList_0600, Function | Mediu Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; - std::shared_ptr launcherservice = std::make_shared(); + LauncherService launcherservice; std::vector launcherAbilityInfos; - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result1 = launcherservice->GetAbilityList(bundleName, userId, launcherAbilityInfos); + + bool result1 = launcherservice.GetAbilityList(bundleName, userId, launcherAbilityInfos); EXPECT_TRUE(result1) << "Get ability list failed"; EXPECT_FALSE(launcherAbilityInfos.empty()) << "Launcher ability infos is empty"; - EXPECT_EQ(launcherAbilityInfos[0].name, abilityName); + if (!launcherAbilityInfos.empty()) { + EXPECT_EQ(launcherAbilityInfos[0].name, abilityName); + } Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; - bool result2 = launcherservice->GetAbilityList(bundleName, userId, launcherAbilityInfos); + bool result2 = launcherservice.GetAbilityList(bundleName, userId, launcherAbilityInfos); EXPECT_FALSE(result2); GTEST_LOG_(INFO) << "END BMS_GetAbilityList_0600"; } @@ -585,16 +575,14 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityList_0700, Function | Mediu int userId = Constants::DEFAULT_USERID; std::vector launcherAbilityInfos; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetAbilityList(bundleName, userId, launcherAbilityInfos); + LauncherService launcherservice; + + bool result = launcherservice.GetAbilityList(bundleName, userId, launcherAbilityInfos); EXPECT_TRUE(result); EXPECT_FALSE(launcherAbilityInfos.empty()) << "Launcher ability infos is empty"; - EXPECT_EQ(launcherAbilityInfos[0].name, abilityName); - + if (!launcherAbilityInfos.empty()) { + EXPECT_EQ(launcherAbilityInfos[0].name, abilityName); + } GTEST_LOG_(INFO) << "END BMS_GetAbilityList_0700"; } /** @@ -622,12 +610,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityInfo_0100, Function | Mediu want.SetElement(name); LauncherAbilityInfo launcherAbilityInfo; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool Result = launcherservice->GetAbilityInfo(want, userId, launcherAbilityInfo); + LauncherService launcherservice; + + bool Result = launcherservice.GetAbilityInfo(want, userId, launcherAbilityInfo); EXPECT_TRUE(Result); EXPECT_EQ(launcherAbilityInfo.name, abilityName); @@ -658,12 +643,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityInfo_0200, Function | Mediu want.SetElement(name); LauncherAbilityInfo launcherAbilityInfos; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetAbilityInfo(want, userId, launcherAbilityInfos); + LauncherService launcherservice; + + bool result = launcherservice.GetAbilityInfo(want, userId, launcherAbilityInfos); EXPECT_TRUE(result) << "Get ability list failed"; EXPECT_EQ(launcherAbilityInfos.name, abilityName); Uninstall(bundleName, message); @@ -697,12 +679,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityInfo_0300, Function | Mediu name.SetBundleName(bundleName); want.SetElement(name); LauncherAbilityInfo launcherAbilityInfo; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetAbilityInfo(want, userId, launcherAbilityInfo); + LauncherService launcherservice; + + bool result = launcherservice.GetAbilityInfo(want, userId, launcherAbilityInfo); EXPECT_FALSE(result); GTEST_LOG_(INFO) << "END GetAbilityInfo_0300"; } @@ -724,12 +703,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityInfo_0400, Function | Mediu want.SetElement(name); LauncherAbilityInfo launcherAbilityInfo; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool Result = launcherservice->GetAbilityInfo(want, userId, launcherAbilityInfo); + LauncherService launcherservice; + + bool Result = launcherservice.GetAbilityInfo(want, userId, launcherAbilityInfo); EXPECT_TRUE(Result); EXPECT_EQ(launcherAbilityInfo.name, abilityName); @@ -764,12 +740,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetAbilityInfo_0500, Function | Mediu want.SetElement(name); LauncherAbilityInfo launcherAbilityInfos; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetAbilityInfo(want, userId, launcherAbilityInfos); + LauncherService launcherservice; + + bool result = launcherservice.GetAbilityInfo(want, userId, launcherAbilityInfos); EXPECT_TRUE(result); EXPECT_EQ(launcherAbilityInfos.name, abilityName); Uninstall(bundleName, message); @@ -790,14 +763,11 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetApplicationInfo_0100, Function | M int userId = Constants::DEFAULT_USERID; Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } + LauncherService launcherservice; + ApplicationInfo appInfo; ApplicationFlag flag = ApplicationFlag::GET_BASIC_APPLICATION_INFO; - bool result = launcherservice->GetApplicationInfo(bundleName, flag, userId, appInfo); + bool result = launcherservice.GetApplicationInfo(bundleName, flag, userId, appInfo); EXPECT_TRUE(result); EXPECT_EQ(appInfo.name, bundleName); Uninstall(bundleName, message); @@ -820,13 +790,10 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetApplicationInfo_0200, Function | M Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } + LauncherService launcherservice; + ApplicationInfo applicationInfo; - bool Result = launcherservice->GetApplicationInfo( + bool Result = launcherservice.GetApplicationInfo( bundleName, ApplicationFlag::GET_APPLICATION_INFO_WITH_PERMS, userId, applicationInfo); EXPECT_TRUE(Result); @@ -849,13 +816,10 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetApplicationInfo_0300, Function | M std::string bundleName = SYSTEM_BASE_BUNDLE_NAME + "1"; int userId = Constants::DEFAULT_USERID; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } + LauncherService launcherservice; + ApplicationInfo applicationInfo; - bool Result = launcherservice->GetApplicationInfo( + bool Result = launcherservice.GetApplicationInfo( bundleName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, applicationInfo); EXPECT_TRUE(Result); EXPECT_EQ(applicationInfo.name, bundleName); @@ -882,13 +846,10 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetApplicationInfo_0400, Function | M Install(bundleFilePath2, InstallFlag::REPLACE_EXISTING, message); EXPECT_EQ(message, "Success") << "install fail!"; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } + LauncherService launcherservice; + ApplicationInfo applicationInfo; - bool Result = launcherservice->GetApplicationInfo( + bool Result = launcherservice.GetApplicationInfo( bundleName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, applicationInfo); EXPECT_TRUE(Result); EXPECT_EQ(applicationInfo.name, bundleName); @@ -913,14 +874,11 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetApplicationInfo_0500, Function | M Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } + LauncherService launcherservice; + ApplicationInfo appInfo; bool result = - launcherservice->GetApplicationInfo(bundleName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, appInfo); + launcherservice.GetApplicationInfo(bundleName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, appInfo); EXPECT_FALSE(result); GTEST_LOG_(INFO) << "END BMS_GetApplicationInfo_0500"; } @@ -936,14 +894,11 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetApplicationInfo_0600, Function | M std::string bundleName = ""; int userId = Constants::DEFAULT_USERID; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } + LauncherService launcherservice; + ApplicationInfo appInfo; bool result = - launcherservice->GetApplicationInfo(bundleName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, appInfo); + launcherservice.GetApplicationInfo(bundleName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, appInfo); EXPECT_FALSE(result); GTEST_LOG_(INFO) << "END BMS_GetApplicationInfo_0600"; } @@ -964,12 +919,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_IsAbilityEnabled_0100, Function | Med AbilityInfo abilityInfo; abilityInfo.bundleName = bundleName; abilityInfo.name = abilityName; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->IsAbilityEnabled(abilityInfo); + LauncherService launcherservice; + + bool result = launcherservice.IsAbilityEnabled(abilityInfo); EXPECT_TRUE(result); Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; @@ -993,12 +945,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_IsAbilityEnabled_0200, Function | Med APP_LOGE("bundle mgr proxy is nullptr."); EXPECT_EQ(bundleMgrProxy, nullptr); } - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->IsAbilityEnabled(abilityInfo); + LauncherService launcherservice; + + bool result = launcherservice.IsAbilityEnabled(abilityInfo); EXPECT_TRUE(result); GTEST_LOG_(INFO) << "END BMS_IsAbilityEnabled_0200"; } @@ -1015,12 +964,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_IsAbilityEnabled_0300, Function | Med AbilityInfo abilityInfo; abilityInfo.bundleName = bundleName; abilityInfo.name = abilityName; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->IsAbilityEnabled(abilityInfo); + LauncherService launcherservice; + + bool result = launcherservice.IsAbilityEnabled(abilityInfo); EXPECT_FALSE(result); GTEST_LOG_(INFO) << "END BMS_IsAbilityEnabled_0300"; } @@ -1049,12 +995,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_IsAbilityEnabled_0400, Function | Med } bool ret = bundleMgrProxy->SetAbilityEnabled(abilityInfo, true); EXPECT_TRUE(ret); - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->IsAbilityEnabled(abilityInfo); + LauncherService launcherservice; + + bool result = launcherservice.IsAbilityEnabled(abilityInfo); EXPECT_TRUE(result); Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; @@ -1073,12 +1016,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_IsBundleEnabled_0100, Function | Medi std::string bundleName = THIRD_BASE_BUNDLE_NAME + "1"; Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->IsBundleEnabled(bundleName); + LauncherService launcherservice; + + bool result = launcherservice.IsBundleEnabled(bundleName); EXPECT_TRUE(result); Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; @@ -1098,15 +1038,12 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_IsBundleEnabled_0200, Function | Medi std::string bundleName = THIRD_BASE_BUNDLE_NAME + "1"; Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; - std::shared_ptr launcherservice = std::make_shared(); + LauncherService launcherservice; sptr bundleMgrProxy = GetBundleMgrProxy(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } + bool ret = bundleMgrProxy->SetApplicationEnabled(bundleName, false); EXPECT_TRUE(ret); - bool result = launcherservice->IsBundleEnabled(bundleName); + bool result = launcherservice.IsBundleEnabled(bundleName); EXPECT_FALSE(result); Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; @@ -1121,12 +1058,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_IsBundleEnabled_0300, Function | Medi { GTEST_LOG_(INFO) << "START BMS_IsBundleEnabled_0300"; std::string bundleName = SYSTEM_BASE_BUNDLE_NAME + "1"; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->IsBundleEnabled(bundleName); + LauncherService launcherservice; + + bool result = launcherservice.IsBundleEnabled(bundleName); EXPECT_TRUE(result); GTEST_LOG_(INFO) << "END BMS_IsBundleEnabled_0300"; } @@ -1139,12 +1073,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_IsBundleEnabled_0400, Function | Medi { GTEST_LOG_(INFO) << "START BMS_IsBundleEnabled_0400"; std::string bundleName = ""; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcherservice is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->IsBundleEnabled(bundleName); + LauncherService launcherservice; + + bool result = launcherservice.IsBundleEnabled(bundleName); EXPECT_FALSE(result); GTEST_LOG_(INFO) << "END BMS_IsBundleEnabled_0400"; } @@ -1160,20 +1091,17 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetShortcutInfos_0100, Function | Med std::string bundleName = "com.example.third1"; std::string shortcutId = "id.third1"; std::string message; - Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; std::vector launcherShortcutInfo; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetShortcutInfos(bundleName, launcherShortcutInfo); + LauncherService launcherservice; + bool result = launcherservice.GetShortcutInfos(bundleName, launcherShortcutInfo); EXPECT_TRUE(result) << "Get shortcut info failed"; EXPECT_FALSE(launcherShortcutInfo.empty()) << "Launcher shortcut infos is empty"; - EXPECT_EQ(launcherShortcutInfo[0].bundleName, bundleName); - EXPECT_EQ(launcherShortcutInfo[0].shortcutid, shortcutId); + if (!launcherShortcutInfo.empty()) { + EXPECT_EQ(launcherShortcutInfo[0].bundleName, bundleName); + EXPECT_EQ(launcherShortcutInfo[0].shortcutid, shortcutId); + } Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; GTEST_LOG_(INFO) << "END BMS_GetShortcutInfos_0100"; @@ -1200,17 +1128,16 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetShortcutInfos_0200, Function | Med Install(bundleFilePath2, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; std::vector launcherShortcutInfo; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetShortcutInfos(bundleName, launcherShortcutInfo); + LauncherService launcherservice; + + bool result = launcherservice.GetShortcutInfos(bundleName, launcherShortcutInfo); EXPECT_TRUE(result) << "Get shortcut info failed"; EXPECT_FALSE(launcherShortcutInfo.empty()) << "Launcher shortcut infos is empty"; - EXPECT_GE(launcherShortcutInfo.size(), 1); - EXPECT_EQ(launcherShortcutInfo[0].shortcutid, shortcutId1); - EXPECT_EQ(launcherShortcutInfo[1].shortcutid, shortcutId2); + EXPECT_EQ(launcherShortcutInfo.size(), LIST_SIZE); + if (!launcherShortcutInfo.empty()) { + EXPECT_EQ(launcherShortcutInfo[0].shortcutid, shortcutId1); + EXPECT_EQ(launcherShortcutInfo[1].shortcutid, shortcutId2); + } Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; GTEST_LOG_(INFO) << "END BMS_GetShortcutInfos_0200"; @@ -1230,12 +1157,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetShortcutInfos_0300, Function | Med Install(bundleFilePath, InstallFlag::NORMAL, message); EXPECT_EQ(message, "Success") << "install fail!"; std::vector launcherShortcutInfo; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetShortcutInfos(bundleName, launcherShortcutInfo); + LauncherService launcherservice; + + bool result = launcherservice.GetShortcutInfos(bundleName, launcherShortcutInfo); EXPECT_FALSE(result); EXPECT_TRUE(launcherShortcutInfo.empty()); Uninstall(bundleName, message); @@ -1252,12 +1176,9 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetShortcutInfos_0400, Function | Med GTEST_LOG_(INFO) << "START BMS_GetShortcutInfos_0400"; std::string bundleName = ""; std::vector launcherShortcutInfo; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetShortcutInfos(bundleName, launcherShortcutInfo); + LauncherService launcherservice; + + bool result = launcherservice.GetShortcutInfos(bundleName, launcherShortcutInfo); EXPECT_FALSE(result); GTEST_LOG_(INFO) << "END BMS_GetShortcutInfos_0400"; } @@ -1281,18 +1202,15 @@ HWTEST_F(BmsLauncherServiceSystemTest, BMS_GetShortcutInfos_0500, Function | Med EXPECT_EQ(message, "Success") << "install fail!"; Install(bundleFilePath2, InstallFlag::REPLACE_EXISTING, message); EXPECT_EQ(message, "Success") << "install fail!"; - std::vector launcherShortcutInfo; - std::shared_ptr launcherservice = std::make_shared(); - if (!launcherservice) { - APP_LOGE("launcher service is nullptr."); - EXPECT_EQ(launcherservice, nullptr); - } - bool result = launcherservice->GetShortcutInfos(bundleName, launcherShortcutInfo); + LauncherService launcherservice; + bool result = launcherservice.GetShortcutInfos(bundleName, launcherShortcutInfo); EXPECT_TRUE(result); EXPECT_FALSE(launcherShortcutInfo.empty()) << "Launcher shortcut info is empty"; - EXPECT_EQ(launcherShortcutInfo[0].bundleName, bundleName); - EXPECT_EQ(launcherShortcutInfo[0].shortcutid, shortcutId); + if (!launcherShortcutInfo.empty()) { + EXPECT_EQ(launcherShortcutInfo[0].bundleName, bundleName); + EXPECT_EQ(launcherShortcutInfo[0].shortcutid, shortcutId); + } Uninstall(bundleName, message); EXPECT_EQ(message, "Success") << "uninstall fail!"; GTEST_LOG_(INFO) << "END BMS_GetShortcutInfos_0500"; diff --git a/test/systemtest/common/bms/bms_search_system_test/bms_search_system_test.cpp b/test/systemtest/common/bms/bms_search_system_test/bms_search_system_test.cpp index 3ed774b217..838bb73cd9 100644 --- a/test/systemtest/common/bms/bms_search_system_test/bms_search_system_test.cpp +++ b/test/systemtest/common/bms/bms_search_system_test/bms_search_system_test.cpp @@ -45,7 +45,6 @@ const std::string OPERATION_SUCCESS = "Success"; namespace OHOS { namespace AppExecFwk { - class BundleStatusCallbackImpl : public BundleStatusCallbackHost { public: BundleStatusCallbackImpl(); @@ -1197,7 +1196,6 @@ HWTEST_F(BmsSearchSystemTest, BMS_Search_3300, Function | MediumTest | Level1) bool getInfoResult = bundleMgrProxy->GetBundleInfo(appName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo); EXPECT_TRUE(getInfoResult); EXPECT_EQ(bundleInfo.name, appName); - EXPECT_EQ(bundleInfo.appId, ""); EXPECT_EQ(bundleInfo.label, "bmsThirdBundle_A1 Ability"); EXPECT_EQ(commonTool.VectorToStr(bundleInfo.modulePublicDirs), "/data/accounts/account_0/appdata/com.third.hiworld.example1/com.third.hiworld.example.h1"); @@ -1427,6 +1425,5 @@ HWTEST_F(BmsSearchSystemTest, BMS_Search_3900, Function | MediumTest | Level1) EXPECT_NE(name2Exist, 0) << "the test file2 exists."; std::cout << "END BMS_SEARCH_3900" << std::endl; } - } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/common/bms/bms_uninstall_system_test/bms_uninstall_system_test.cpp b/test/systemtest/common/bms/bms_uninstall_system_test/bms_uninstall_system_test.cpp index aff2267f59..e74303550a 100755 --- a/test/systemtest/common/bms/bms_uninstall_system_test/bms_uninstall_system_test.cpp +++ b/test/systemtest/common/bms/bms_uninstall_system_test/bms_uninstall_system_test.cpp @@ -47,7 +47,6 @@ const int32_t MAX_BUNDLE_NAME = 6; namespace OHOS { namespace AppExecFwk { - class StatusReceiverImpl : public StatusReceiverHost { public: StatusReceiverImpl(); @@ -1369,6 +1368,5 @@ HWTEST_F(BmsUninstallSystemTest, BMS_DFX_0500, Function | MediumTest | Level2) EXPECT_EQ(uninstallMsg, "Success") << "uninstall fail!"; std::cout << "END BMS_DFX_0500" << std::endl; } - } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/test/systemtest/common/fms/fms_acquire_form_test/BUILD.gn b/test/systemtest/common/fms/fms_acquire_form_test/BUILD.gn index 3437550f9f..3fa5bababd 100644 --- a/test/systemtest/common/fms/fms_acquire_form_test/BUILD.gn +++ b/test/systemtest/common/fms/fms_acquire_form_test/BUILD.gn @@ -63,7 +63,7 @@ ohos_systemtest("FmsAcquireFormTest") { "ipc:ipc_core", "multimodalinput_base:libmmi-client", "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "samgr_L2:samgr_proxy", ] } diff --git a/test/systemtest/common/fms/fms_acquire_form_test_max/BUILD.gn b/test/systemtest/common/fms/fms_acquire_form_test_max/BUILD.gn index f5e9c19a5d..2a567af5bd 100644 --- a/test/systemtest/common/fms/fms_acquire_form_test_max/BUILD.gn +++ b/test/systemtest/common/fms/fms_acquire_form_test_max/BUILD.gn @@ -63,7 +63,7 @@ ohos_systemtest("FmsAcquireFormTestMax") { "ipc:ipc_core", "multimodalinput_base:libmmi-client", "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "samgr_L2:samgr_proxy", ] } diff --git a/test/systemtest/common/fms/fms_delete_form_test/BUILD.gn b/test/systemtest/common/fms/fms_delete_form_test/BUILD.gn index fad13d501f..1cbfbc5b1a 100644 --- a/test/systemtest/common/fms/fms_delete_form_test/BUILD.gn +++ b/test/systemtest/common/fms/fms_delete_form_test/BUILD.gn @@ -63,7 +63,7 @@ ohos_systemtest("FormDeleteFormTest") { "ipc:ipc_core", "multimodalinput_base:libmmi-client", "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "samgr_L2:samgr_proxy", ] } diff --git a/test/systemtest/common/fms/fms_release_form_test/BUILD.gn b/test/systemtest/common/fms/fms_release_form_test/BUILD.gn index 559a78c1c9..3212f211b0 100644 --- a/test/systemtest/common/fms/fms_release_form_test/BUILD.gn +++ b/test/systemtest/common/fms/fms_release_form_test/BUILD.gn @@ -63,7 +63,7 @@ ohos_systemtest("FormReleaseFormTest") { "ipc:ipc_core", "multimodalinput_base:libmmi-client", "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "samgr_L2:samgr_proxy", ] } diff --git a/test/systemtest/common/fms/fms_self_starting_test/BUILD.gn b/test/systemtest/common/fms/fms_self_starting_test/BUILD.gn index 8ea23e2e33..0b98eeb563 100644 --- a/test/systemtest/common/fms/fms_self_starting_test/BUILD.gn +++ b/test/systemtest/common/fms/fms_self_starting_test/BUILD.gn @@ -63,7 +63,7 @@ ohos_systemtest("FmsSelfStartingTest") { "ipc:ipc_core", "multimodalinput_base:libmmi-client", "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", + "samgr_L2:samgr_proxy", ] } diff --git a/tools/fm/src/fms_command.cpp b/tools/fm/src/fms_command.cpp index bcc3b184ed..462165df9a 100755 --- a/tools/fm/src/fms_command.cpp +++ b/tools/fm/src/fms_command.cpp @@ -445,7 +445,7 @@ int FormMgrShellCommand::GetStringInfo(IFormMgr::Message code, MessageParcel &da std::vector stringInfoList; if (!reply.ReadStringVector(&stringInfoList)) { APP_LOGE("%{public}s, failed to read string vector from reply", __func__); - return ERR_APPEXECFWK_PARCEL_ERROR; + return false; } if (stringInfoList.empty()) { APP_LOGI("%{public}s, No string info", __func__); diff --git a/tools/test/mock/mock_bundle_mgr_host.h b/tools/test/mock/mock_bundle_mgr_host.h index a2482006cf..89e75035dc 100644 --- a/tools/test/mock/mock_bundle_mgr_host.h +++ b/tools/test/mock/mock_bundle_mgr_host.h @@ -40,6 +40,7 @@ public: MOCK_METHOD2(GetBundleInfosByMetaData, bool(const std::string &metaData, std::vector &bundleInfos)); MOCK_METHOD2(QueryAbilityInfo, bool(const Want &want, AbilityInfo &abilityInfo)); MOCK_METHOD2(QueryAbilityInfos, bool(const Want &want, std::vector &abilityInfos)); + MOCK_METHOD2(QueryAbilityInfosForClone, bool(const Want &want, std::vector &abilityInfos)); MOCK_METHOD2(QueryAbilityInfoByUri, bool(const std::string &abilityUri, AbilityInfo &abilityInfo)); MOCK_METHOD1(QueryKeepAliveBundleInfos, bool(std::vector &bundleInfos)); MOCK_METHOD2(GetAbilityLabel, std::string(const std::string &bundleName, const std::string &className)); -- Gitee