diff --git a/interfaces/innerkits/appexecfwk_base/include/ability_info.h b/interfaces/innerkits/appexecfwk_base/include/ability_info.h index d6e0d5e4edb64f9d24a0a8ffd9b4f01805781a29..8e3019335f171bf68c8e07f3c2c5488943800e4b 100644 --- a/interfaces/innerkits/appexecfwk_base/include/ability_info.h +++ b/interfaces/innerkits/appexecfwk_base/include/ability_info.h @@ -91,8 +91,10 @@ struct AbilityInfo : public Parcelable { bool isLauncherAbility = false; bool isNativeAbility = false; bool enabled = false; + bool supportPipMode = false; std::string readPermission; std::string writePermission; + std::vector configChanges; std::vector formEntity; int32_t minFormHeight = 0; int32_t defaultFormHeight = 0; diff --git a/interfaces/innerkits/appexecfwk_base/include/bundle_constants.h b/interfaces/innerkits/appexecfwk_base/include/bundle_constants.h index b65bf54f182b44e8941ce3eda810205ce870bd95..eeed7fd8c3d52ac5d1d0af2ef28398e80d6c9938 100755 --- a/interfaces/innerkits/appexecfwk_base/include/bundle_constants.h +++ b/interfaces/innerkits/appexecfwk_base/include/bundle_constants.h @@ -116,6 +116,8 @@ const std::string STORE_ID = "installed_bundle_datas"; // single max hap size constexpr int32_t MAX_HAP_SIZE = 50 * 1024 * 1024; +const std::string UID = "uid"; + } // namespace Constants } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/innerkits/appexecfwk_base/src/ability_info.cpp b/interfaces/innerkits/appexecfwk_base/src/ability_info.cpp index af6ac77a971962286a2c91f33a3c2afc4448f34b..54a5c3cc0d5c530378a67d2a27467efd4fc7e907 100644 --- a/interfaces/innerkits/appexecfwk_base/src/ability_info.cpp +++ b/interfaces/innerkits/appexecfwk_base/src/ability_info.cpp @@ -58,9 +58,11 @@ const std::string JSON_KEY_DEVICE_ID = "deviceId"; const std::string JSON_KEY_IS_LAUNCHER_ABILITY = "isLauncherAbility"; const std::string JSON_KEY_IS_NATIVE_ABILITY = "isNativeAbility"; const std::string JSON_KEY_ENABLED = "enabled"; +const std::string JSON_KEY_SUPPORT_PIP_MODE = "supportPipMode"; const std::string JSON_KEY_TARGET_ABILITY = "targetAbility"; const std::string JSON_KEY_READ_PERMISSION = "readPermission"; const std::string JSON_KEY_WRITE_PERMISSION = "writePermission"; +const std::string JSON_KEY_CONFIG_CHANGES = "configChanges"; const std::string JSON_KEY_FORM = "form"; const std::string JSON_KEY_FORM_ENTITY = "formEntity"; const std::string JSON_KEY_MIN_FORM_HEIGHT = "minFormHeight"; @@ -101,7 +103,12 @@ bool AbilityInfo::ReadFromParcel(Parcel &parcel) isLauncherAbility = parcel.ReadBool(); isNativeAbility = parcel.ReadBool(); enabled = parcel.ReadBool(); - + supportPipMode = parcel.ReadBool(); + int32_t configChangesSize; + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, configChangesSize); + for (int32_t i = 0; i < configChangesSize; i++) { + configChanges.emplace_back(Str16ToStr8(parcel.ReadString16())); + } int32_t formEntitySize; READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, formEntitySize); for (int32_t i = 0; i < formEntitySize; i++) { @@ -226,6 +233,11 @@ bool AbilityInfo::Marshalling(Parcel &parcel) const WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isLauncherAbility); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isNativeAbility); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, enabled); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, supportPipMode); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, configChanges.size()); + for (auto &configChange : configChanges) { + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(configChange)); + } WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, formEntity.size()); for (auto &item : formEntity) { WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(item)); @@ -354,8 +366,10 @@ void to_json(nlohmann::json &jsonObject, const AbilityInfo &abilityInfo) {JSON_KEY_IS_LAUNCHER_ABILITY, abilityInfo.isLauncherAbility}, {JSON_KEY_IS_NATIVE_ABILITY, abilityInfo.isNativeAbility}, {JSON_KEY_ENABLED, abilityInfo.enabled}, + {JSON_KEY_SUPPORT_PIP_MODE, abilityInfo.supportPipMode}, {JSON_KEY_READ_PERMISSION, abilityInfo.readPermission}, {JSON_KEY_WRITE_PERMISSION, abilityInfo.writePermission}, + {JSON_KEY_CONFIG_CHANGES, abilityInfo.configChanges}, {JSON_KEY_FORM_ENTITY, abilityInfo.formEntity}, {JSON_KEY_MIN_FORM_HEIGHT, abilityInfo.minFormHeight}, {JSON_KEY_DEFAULT_FORM_HEIGHT, abilityInfo.defaultFormHeight}, @@ -422,8 +436,10 @@ void from_json(const nlohmann::json &jsonObject, AbilityInfo &abilityInfo) abilityInfo.isLauncherAbility = jsonObject.at(JSON_KEY_IS_LAUNCHER_ABILITY).get(); abilityInfo.isNativeAbility = jsonObject.at(JSON_KEY_IS_NATIVE_ABILITY).get(); abilityInfo.enabled = jsonObject.at(JSON_KEY_ENABLED).get(); + abilityInfo.supportPipMode = jsonObject.at(JSON_KEY_SUPPORT_PIP_MODE).get(); abilityInfo.readPermission = jsonObject.at(JSON_KEY_READ_PERMISSION).get(); abilityInfo.writePermission = jsonObject.at(JSON_KEY_WRITE_PERMISSION).get(); + abilityInfo.configChanges = jsonObject.at(JSON_KEY_CONFIG_CHANGES).get>(); abilityInfo.formEntity = jsonObject.at(JSON_KEY_FORM_ENTITY).get>(); abilityInfo.minFormHeight = jsonObject.at(JSON_KEY_MIN_FORM_HEIGHT).get(); abilityInfo.defaultFormHeight = jsonObject.at(JSON_KEY_DEFAULT_FORM_HEIGHT).get(); 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 f259ac27db07c8c757978ff100f9006b337fb50e..6779e3e136057cf19b448c8a1af0f999d79f22c7 100644 --- a/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp +++ b/interfaces/innerkits/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp @@ -1104,7 +1104,7 @@ bool BundleMgrProxy::RequestPermissionFromUser( } MessageParcel reply; - if (!SendTransactCmd(IBundleMgr::Message::CAN_REQUEST_PERMISSION, data, reply)) { + if (!SendTransactCmd(IBundleMgr::Message::REQUEST_PERMISSION_FROM_USER, data, reply)) { APP_LOGE("fail to RequestPermissionsFromUser from server"); return false; } diff --git a/interfaces/innerkits/test/mock/include/test.cpp b/interfaces/innerkits/test/mock/include/test.cpp deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/kits/BUILD.gn b/kits/BUILD.gn index 6041fcf66801f8e30fc718992535404bf688c88c..a690a38ce855581e25851be045556af071f5a0ca 100755 --- a/kits/BUILD.gn +++ b/kits/BUILD.gn @@ -136,10 +136,8 @@ ohos_shared_library("appkit_native") { "//utils/native/base:utils", ] - public_deps = [ - "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr", - ] - + public_deps = + [ "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr" ] external_deps = [ "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/kits/appkit/napi/bundlemgr/bundle_mgr.cpp b/kits/appkit/napi/bundlemgr/bundle_mgr.cpp index 5ba71fc15d7536fcfd31a6cedd9802535ff3f85d..e7b314b53636284f38f9a82413e2f7cb966436a8 100644 --- a/kits/appkit/napi/bundlemgr/bundle_mgr.cpp +++ b/kits/appkit/napi/bundlemgr/bundle_mgr.cpp @@ -181,7 +181,7 @@ static void ConvertCustomizeData(napi_env env, napi_value objCustomizeData, cons HILOG_INFO("ConvertCustomizeData value=%{public}s.", customizeData.value.c_str()); napi_value nExtra; NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, customizeData.extra.c_str(), NAPI_AUTO_LENGTH, &nExtra)); - NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objCustomizeData, "value", nExtra)); + NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objCustomizeData, "extra", nExtra)); HILOG_INFO("ConvertCustomizeData extra=%{public}s.", customizeData.extra.c_str()); } diff --git a/kits/appkit/native/test/mock/include/mock_resourceManager_interface1.cpp b/kits/appkit/native/test/mock/include/mock_resourceManager_interface1.cpp index 9f1cbeb88ffe45e554744de04a89a6eeded1843b..f06f27821287435a82dbaeb55d70045c40ab50bf 100644 --- a/kits/appkit/native/test/mock/include/mock_resourceManager_interface1.cpp +++ b/kits/appkit/native/test/mock/include/mock_resourceManager_interface1.cpp @@ -1,4 +1,17 @@ - +/* + * 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 #include "gmock/gmock.h" diff --git a/ohos.build b/ohos.build index fa4f3cb8c9a6bb3fd9faa74a7f41ddfbfe730273..00cf1c043d3d6cfa43a57103a937a0e1f5041b00 100644 --- a/ohos.build +++ b/ohos.build @@ -68,6 +68,7 @@ "//foundation/appexecfwk/standard/sa_profile:appexecfwk_sa_profile", "//foundation/appexecfwk/standard/sa_profile:foundation.rc", "//foundation/appexecfwk/standard/test/resource/amssystemtestability/abilitySrc:ams_system_test_app", + "//foundation/appexecfwk/standard/test/resource/bmssystemtestability/abilitySrc:bms_system_test_app", "//foundation/appexecfwk/standard/kits/appkit/napi:napi_packages" ], "test_list": [ diff --git a/sa_profile/foundation.rc b/sa_profile/foundation.rc index 805d83e87dfe60e597ff21f83b4914e035dd0676..69909f50ff1e87952d6dec01d9bba8bd07deb03b 100755 --- a/sa_profile/foundation.rc +++ b/sa_profile/foundation.rc @@ -15,9 +15,10 @@ on init # cpuctl subsystem # set background cpuctl mkdir /dev/cpuctl/background - chown system system /dev/cpuctl/background chmod 0755 /dev/cpuctl/background chmod 0755 /dev/cpuctl/background/tasks + chown system system /dev/cpuctl/background + chown system system /dev/cpuctl/background/tasks write /dev/cpuctl/background/cpu.shares 512 # cpuset subsystem diff --git a/services/appmgr/test/unittest/ams_process_optimizer_test/ams_process_optimizer_test.cpp b/services/appmgr/test/unittest/ams_process_optimizer_test/ams_process_optimizer_test.cpp index 49686a5c44a78f27c7a14f2b7a9dda5a28aaeb88..bad957fbc5506d31b6ee9310fd0be8a2c63611c3 100644 --- a/services/appmgr/test/unittest/ams_process_optimizer_test/ams_process_optimizer_test.cpp +++ b/services/appmgr/test/unittest/ams_process_optimizer_test/ams_process_optimizer_test.cpp @@ -1,3 +1,17 @@ +/* + * 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 #define private public diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 76e7a17dcac159632704ae10ef1396cab288a8fc..3ca31d89af6d31f25096712d7a1ed7efb84e948e 100755 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -1141,6 +1141,16 @@ bool BundleDataMgr::NotifyBundleStatus(const std::string &bundleName, const std: element.SetBundleName(bundleName); element.SetAbilityName(mainAbility); want.SetElement(element); + auto iter = bundleInfos_.find(bundleName); + if (iter != bundleInfos_.end()) { + auto infoWithIdItem = iter->second.find(Constants::CURRENT_DEVICE_ID); + if (infoWithIdItem != iter->second.end()) { + for (const auto &info : iter->second) { + want.SetParam(Constants::UID, info.second.GetUid()); + APP_LOGI("want.SetParam uid %{public}d", info.second.GetUid()); + } + } + } EventFwk::CommonEventData commonData{want}; EventFwk::CommonEventManager::PublishCommonEvent(commonData); return true; @@ -1355,4 +1365,4 @@ bool BundleDataMgr::GetShortcutInfos(const std::string &bundleName, std::vector< } } // namespace AppExecFwk -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/services/bundlemgr/src/bundle_profile.cpp b/services/bundlemgr/src/bundle_profile.cpp index 27611f30615555d86795dee69f77149f77c9e24a..6ba0bd750c0bebbd91fd27d6389585815ab51dab 100644 --- a/services/bundlemgr/src/bundle_profile.cpp +++ b/services/bundlemgr/src/bundle_profile.cpp @@ -1873,8 +1873,10 @@ bool TransformToInfo( abilityInfo.applicationName = configJson.app.bundleName; abilityInfo.targetAbility = ability.targetAbility; abilityInfo.enabled = true; + abilityInfo.supportPipMode = ability.supportPipMode; abilityInfo.readPermission = ability.readPermission; abilityInfo.writePermission = ability.writePermission; + abilityInfo.configChanges = ability.configChanges; abilityInfo.formEntity = ability.form.formEntity; abilityInfo.minFormHeight = ability.form.minHeight; abilityInfo.defaultFormHeight = ability.form.defaultHeight; 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 e702d4d634b62467d9c021486c970db44062edfd..7b305013a621585dde63eb7c6656ca13d71e6076 100644 --- a/services/bundlemgr/test/mock/include/mock_ability_mgr_host.h +++ b/services/bundlemgr/test/mock/include/mock_ability_mgr_host.h @@ -190,6 +190,11 @@ public: return 0; } + int UpdateConfiguration(const GlobalConfiguration &config, std::string changeType) override + { + return 0; + } + virtual sptr GetWantSender( const WantSenderInfo &wantSenderInfo, const sptr &callerToken) override { diff --git a/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/bms_bundle_data_storage_database_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/bms_bundle_data_storage_database_test.cpp index c2a9745cb9671a682e2d37438328e635eaf89d62..43209aacff7e1ce61ff5ea3733df6bad653d6aaf 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/bms_bundle_data_storage_database_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_data_storage_test/bms_bundle_data_storage_database_test.cpp @@ -71,32 +71,34 @@ protected: "enabled": true, "readPermission": "readPermission", "writePermission": "writePermission", - "form": { - "formEntity": ["homeScreen", "searchbox"], - "minHeight": 0, - "defaultHeight": 100, - "minWidth": 0, - "defaultWidth": 200 - }, + "configChanges": [ + "locale" + ], + "formEntity": ["homeScreen", "searchbox"], + "minFormHeight": 0, + "defaultFormHeight": 100, + "minFormWidth": 0, + "defaultFormWidth": 200, "metaData": { "customizeData": [{ - ? "name" : "string", - ? "value" : "string", - ? "extra" : "$string:customizeData_description" + "name" : "string", + "value" : "string", + "extra" : "$string:customizeData_description" }], "parameters": [{ "name" : "string", - ? "type" : "Float", - ? "description" : "$string:parameters_description" + "type" : "Float", + "description" : "$string:parameters_description" }], "results": [{ - ? "name" : "string", - ? "type" : "Float", - ? "description" : "$string:results_description" + "name" : "string", + "type" : "Float", + "description" : "$string:results_description" }] }, "isLauncherAbility": true, "isNativeAbility": false, + "supportPipMode" : false, "kind": "page", "label": "Launcher", "launchMode": 0, @@ -291,6 +293,25 @@ protected: } ] }, + "shortcutInfos": { + "com.example.myapplication1com.example.myapplication.h1id": { + "bundleName": "com.example.myapplication1", + "disableMessage": "", + "hostAbility": "", + "icon": "$string:mainability_description", + "id": "id", + "intents": [ + { + "targetBundle": "com.example.myapplication1", + "targetClass": "com.example.myapplication.MainAbility" + } + ], + "isEnables": false, + "isHomeShortcut": false, + "isStatic": false, + "label": "$string:mainability_description" + } + }, "uid": 10000, "userId_": 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 7e7a0c352e3bc996e117231e713e8d7da0f52136..77119de94831687fc203e9f17b34ab6ca07607d4 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 @@ -71,6 +71,7 @@ const AbilityType ABILITY_TYPE = AbilityType::PAGE; const DisplayOrientation ORIENTATION = DisplayOrientation::PORTRAIT; const LaunchMode LAUNCH_MODE = LaunchMode::SINGLETON; const std::vector FORM_ENTITY = {"homeScreen","searchbox"}; +const std::vector CONFIG_CHANGES = {"locale"}; const int DEFAULT_FORM_HEIGHT = 100; const int DEFAULT_FORM_WIDTH = 200; const std::string META_DATA_DESCRIPTION = "description"; @@ -359,7 +360,8 @@ AbilityInfo BmsBundleKitServiceTest::MockAbilityInfo( abilityInfo.type = ABILITY_TYPE; abilityInfo.orientation = ORIENTATION; abilityInfo.launchMode = LAUNCH_MODE; - abilityInfo.formEntity = {"homeScreen","searchbox"}, + abilityInfo.configChanges = {"locale"}; + abilityInfo.formEntity = {"homeScreen","searchbox"}; abilityInfo.defaultFormHeight = DEFAULT_FORM_HEIGHT; abilityInfo.defaultFormWidth = DEFAULT_FORM_WIDTH; abilityInfo.codePath = CODE_PATH; @@ -367,6 +369,7 @@ AbilityInfo BmsBundleKitServiceTest::MockAbilityInfo( abilityInfo.libPath = LIB_PATH; abilityInfo.uri = URI; abilityInfo.enabled = true; + abilityInfo.supportPipMode = false; abilityInfo.targetAbility = TARGET_ABILITY; AppExecFwk::Parameters parameters{"description", "name", "type"}; AppExecFwk::Results results{"description", "name", "type"}; @@ -446,7 +449,9 @@ void BmsBundleKitServiceTest::CheckAbilityInfo( 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); diff --git a/services/test/mock/include/mock_ability_mgr_host.h b/services/test/mock/include/mock_ability_mgr_host.h index 31d9f786934bfb6b43f3e7f4d4ed9f32e55c72b3..a3203b312495637e5ea6f296cefea21f25decf39 100644 --- a/services/test/mock/include/mock_ability_mgr_host.h +++ b/services/test/mock/include/mock_ability_mgr_host.h @@ -184,6 +184,11 @@ public: return 0; } + int UpdateConfiguration(const GlobalConfiguration &config, std::string changeType) override + { + return 0; + } + virtual sptr GetWantSender( const WantSenderInfo &wantSenderInfo, const sptr &callerToken) override { diff --git a/test/resource/bmssystemtestability/abilitySrc/BUILD.gn b/test/resource/bmssystemtestability/abilitySrc/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ad795dfb93f114af8976c21925c71f3173dd97c0 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/BUILD.gn @@ -0,0 +1,21 @@ +# 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. + +group("bms_system_test_app") { + deps = [ + "thirdPageDemo1:page_ability_native1", + "thirdPageDemo2:page_ability_native2", + "thirdPageDemo3:page_ability_native3", + "thirdPageDemo4:page_ability_native4", + ] +} diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/BUILD.gn b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b6dbb75eec0fdf750d6cb203c0dd3b082b36f66a --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/BUILD.gn @@ -0,0 +1,58 @@ +# 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("//foundation/appexecfwk/standard/appexecfwk.gni") +SUBDEMOSYSTEM_DIR = "${appexecfwk_path}/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1" +SUBST_TOOLS_DIR = + "${appexecfwk_path}/test/resource/amssystemtestability/abilitySrc/tools" +config("third_page_demo1_config") { + visibility = [ ":*" ] + include_dirs = [ + "${SUBDEMOSYSTEM_DIR}/include", + "${kits_path}/appkit/native/app", + "${aafwk_path}/interfaces/innerkits/want/include/ohos/aafwk/content", + "${aafwk_path}/interfaces/innerkits/ability_manager/include", + "${innerkits_path}/libeventhandler/include", + "${services_path}/bundlemgr/include", + "${aafwk_path}/services/abilitymgr/include", + "${common_path}/log/include", + "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include", + "${SUBST_TOOLS_DIR}/include", + ] + defines = [ + "APP_LOG_TAG = \"thirdPageDemo1\"", + "LOG_DOMAIN = 0xD002200", + ] +} +ohos_shared_library("page_ability_native1") { + sources = [ "${SUBDEMOSYSTEM_DIR}/src/pageAbilityDemo.cpp" ] + configs = [ ":third_page_demo1_config" ] + deps = [ + "${aafwk_path}/frameworks/kits/ability/native:abilitykit_native", + "${aafwk_path}/frameworks/kits/ability/native:dummy_classes", + "${aafwk_path}/interfaces/innerkits/want:want", + "${common_path}:libappexecfwk_common", + "${innerkits_path}/appexecfwk_base:appexecfwk_base", + "${innerkits_path}/appexecfwk_core:appexecfwk_core", + "${kits_path}:appkit_native", + "${services_path}/bundlemgr:libbms", + "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", + "//utils/native/base:utilsbase", + ] + external_deps = [ + "ces_standard:cesfwk_innerkits", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + ] + subsystem_name = "bmssystemtestability" +} diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/config.json b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/config.json new file mode 100644 index 0000000000000000000000000000000000000000..9d69d4042c9e1d43baaf1d47026d19869d11eec6 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/config.json @@ -0,0 +1,52 @@ +{ + "app":{ + "bundleName": "com.third.hiworld.example1", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 3, + "target": 3 + } + }, + "deviceConfig": { + "default": { + } + }, + "module": { + "package":"com.third.hiworld.example.h1", + "name":"bmsThirdBundle1", + "deviceType": [ + "tv", + "car" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "testability", + "moduleType": "entry" + }, + "abilities": [{ + "name": "PageAbilityDemo", + "icon": "$media:snowball", + "label": "bmsThirdBundle_A1 Ability", + "launchType": "singleton", + "orientation": "unspecified", + "type": "page", + "visible": true, + "skills": [ + { + "actions": [ + "ohos.aafwk.content.Want.ACTION_HOME" + ], + "entities": [ + "ohos.aafwk.content.Want.ENTITY_HOME" + ], + "attributes": [] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/include/pageAbilityDemo.h b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/include/pageAbilityDemo.h new file mode 100644 index 0000000000000000000000000000000000000000..dad87b1f32774290063b4c66f7dee2842410b712 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/include/pageAbilityDemo.h @@ -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. + */ +#ifndef _PAGE_ABILITY_DEMO_ +#define _PAGE_ABILITY_DEMO_ +#include + +#include "ability.h" +#include "ability_loader.h" +#include "app_log_wrapper.h" +#include "stpageabilityevent.h" + +namespace OHOS { +namespace AppExecFwk { +class PageAbilityDemo : public Ability { +protected: + 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; + +public: + void CreateFile(const std::string &path) const; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif //_PAGE_ABILITY_DEMO_ \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/src/pageAbilityDemo.cpp b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/src/pageAbilityDemo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..00a3c081aefd04e4aa4c3afbfaae471d3b9ef312 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo1/src/pageAbilityDemo.cpp @@ -0,0 +1,93 @@ +/* + * 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 "pageAbilityDemo.h" +#include +#include +namespace OHOS { +namespace AppExecFwk { +const std::string BUNDLE_DATA_ROOT_PATH = "/data/accounts/account_0/appdata/"; +void PageAbilityDemo::OnStart(const Want &want) +{ + APP_LOGI("PageAbilityDemo::onStart"); + Ability::OnStart(want); + const std::string appName = "com.third.hiworld.example1"; + const std::string testCacheFileNamE1 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/name1.txt"; + const std::string testCacheFileNamE2 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/name2.txt"; + CreateFile(testCacheFileNamE1); + CreateFile(testCacheFileNamE2); +} + +void PageAbilityDemo::OnNewWant(const Want &want) +{ + APP_LOGI("PageAbilityDemo::OnNewWant"); + Ability::OnNewWant(want); +} + +void PageAbilityDemo::OnForeground(const Want &want) +{ + APP_LOGI("PageAbilityDemo::OnForeground"); + Ability::OnForeground(want); +} + +void PageAbilityDemo::OnStop() +{ + APP_LOGI("PageAbilityDemo::onStop"); + Ability::OnStop(); +} + +void PageAbilityDemo::OnActive() +{ + APP_LOGI("PageAbilityDemo::OnActive"); + Ability::OnActive(); +} + +void PageAbilityDemo::OnInactive() +{ + APP_LOGI("PageAbilityDemo::OnInactive"); + Ability::OnInactive(); +} + +void PageAbilityDemo::OnBackground() +{ + APP_LOGI("PageAbilityDemo::OnBackground"); + Ability::OnBackground(); +} + +void PageAbilityDemo::CreateFile(const std::string &path) const +{ + if (path.size() > PATH_MAX) { + APP_LOGE("CreateFile the length of path is too long"); + return; + } + + std::string realPath; + realPath.reserve(PATH_MAX); + realPath.resize(PATH_MAX - 1); + + if (realpath(path.c_str(), &(realPath[0])) == nullptr) { + APP_LOGW("CreateFile-translate:%{public}s not exist path", realPath.c_str()); + } + + std::ofstream file(path); + file.close(); + + if (access(realPath.c_str(), F_OK) != 0) { + APP_LOGE("CreateFile-checkFile:%{public}s not exist", realPath.c_str()); + } +} + +REGISTER_AA(PageAbilityDemo) +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/BUILD.gn b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1b45dd10f9c9b4da28fd2afa669aa11ce556fa3f --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/BUILD.gn @@ -0,0 +1,58 @@ +# 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("//foundation/appexecfwk/standard/appexecfwk.gni") +SUBDEMOSYSTEM_DIR = "${appexecfwk_path}/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2" +SUBST_TOOLS_DIR = + "${appexecfwk_path}/test/resource/amssystemtestability/abilitySrc/tools" +config("third_page_demo2_config") { + visibility = [ ":*" ] + include_dirs = [ + "${SUBDEMOSYSTEM_DIR}/include", + "${kits_path}/appkit/native/app", + "${aafwk_path}/interfaces/innerkits/want/include/ohos/aafwk/content", + "${aafwk_path}/interfaces/innerkits/ability_manager/include", + "${innerkits_path}/libeventhandler/include", + "${services_path}/bundlemgr/include", + "${aafwk_path}/services/abilitymgr/include", + "${common_path}/log/include", + "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include", + "${SUBST_TOOLS_DIR}/include", + ] + defines = [ + "APP_LOG_TAG = \"thirdPageDemo2\"", + "LOG_DOMAIN = 0xD002200", + ] +} +ohos_shared_library("page_ability_native2") { + sources = [ "${SUBDEMOSYSTEM_DIR}/src/pageAbilityDemo.cpp" ] + configs = [ ":third_page_demo2_config" ] + deps = [ + "${aafwk_path}/frameworks/kits/ability/native:abilitykit_native", + "${aafwk_path}/frameworks/kits/ability/native:dummy_classes", + "${aafwk_path}/interfaces/innerkits/want:want", + "${common_path}:libappexecfwk_common", + "${innerkits_path}/appexecfwk_base:appexecfwk_base", + "${innerkits_path}/appexecfwk_core:appexecfwk_core", + "${kits_path}:appkit_native", + "${services_path}/bundlemgr:libbms", + "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", + "//utils/native/base:utilsbase", + ] + external_deps = [ + "ces_standard:cesfwk_innerkits", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + ] + subsystem_name = "bmssystemtestability" +} diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/config.json b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/config.json new file mode 100644 index 0000000000000000000000000000000000000000..58ace73872728cf283fdaf394c86127d92743d22 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/config.json @@ -0,0 +1,61 @@ +{ + "app":{ + "bundleName": "com.third.hiworld.example2", + "vendor": "example", + "version": { + "code": 2, + "name": "2.0" + }, + "apiVersion": { + "compatible": 3, + "target": 3 + } + }, + "deviceConfig": { + "default": { + } + }, + "module": { + "package":"com.third.hiworld.example.h1", + "name":"bmsThirdBundle1", + "deviceType": [ + "tv", + "car" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "testability", + "moduleType": "entry" + }, + "abilities": [{ + "name": "PageAbilityDemo", + "icon": "$media:snowball", + "label": "bmsThirdBundle_A2 Ability", + "launchType": "singleton", + "orientation": "unspecified", + "type": "page", + "visible": true, + "skills": [ + { + "actions": [ + "ohos.aafwk.content.Want.ACTION_HOME" + ], + "entities": [ + "ohos.aafwk.content.Want.ENTITY_HOME" + ], + "attributes": [] + } + ] + }, + { + "name": "bmsThirdBundle_A2", + "icon": "$media:snowball", + "label": "bmsThirdBundle_A2 Ability", + "launchType": "singleton", + "orientation": "unspecified", + "type": "page", + "visible": true + } + ] + } +} \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/include/pageAbilityDemo.h b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/include/pageAbilityDemo.h new file mode 100644 index 0000000000000000000000000000000000000000..25e961d64614b9805890c5f31e43782df25c4f86 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/include/pageAbilityDemo.h @@ -0,0 +1,41 @@ +/* + * 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 _PAGE_ABILITY_DEMO_ +#define _PAGE_ABILITY_DEMO_ +#include + +#include "ability.h" +#include "ability_loader.h" +#include "app_log_wrapper.h" +#include "stpageabilityevent.h" +namespace OHOS { +namespace AppExecFwk { +class PageAbilityDemo : public Ability { +protected: + 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; + +public: + void CreateDir(const std::string &path) const; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif //_PAGE_ABILITY_DEMO_ \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/src/pageAbilityDemo.cpp b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/src/pageAbilityDemo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a7422426a98b82e173d2579836e07596d25473b7 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo2/src/pageAbilityDemo.cpp @@ -0,0 +1,78 @@ +/* + * 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 "pageAbilityDemo.h" +#include +namespace OHOS { +namespace AppExecFwk { +const std::string BUNDLE_DATA_ROOT_PATH = "/data/accounts/account_0/appdata/"; +void PageAbilityDemo::OnStart(const Want &want) +{ + APP_LOGI("PageAbilityDemo::onStart"); + Ability::OnStart(want); + const std::string appName = "com.third.hiworld.example2"; + const std::string testCacheDiR1 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/testDir1"; + const std::string testCacheDiR2 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/testDir2"; + CreateDir(testCacheDiR1); + CreateDir(testCacheDiR2); +} + +void PageAbilityDemo::OnNewWant(const Want &want) +{ + APP_LOGI("PageAbilityDemo::OnNewWant"); + Ability::OnNewWant(want); +} + +void PageAbilityDemo::OnForeground(const Want &want) +{ + APP_LOGI("PageAbilityDemo::OnForeground"); + Ability::OnForeground(want); +} + +void PageAbilityDemo::OnStop() +{ + APP_LOGI("PageAbilityDemo::onStop"); + Ability::OnStop(); +} + +void PageAbilityDemo::OnActive() +{ + APP_LOGI("PageAbilityDemo::OnActive"); + Ability::OnActive(); +} + +void PageAbilityDemo::OnInactive() +{ + APP_LOGI("PageAbilityDemo::OnInactive"); + Ability::OnInactive(); +} + +void PageAbilityDemo::OnBackground() +{ + APP_LOGI("PageAbilityDemo::OnBackground"); + Ability::OnBackground(); +} + +void PageAbilityDemo::CreateDir(const std::string &path) const +{ + if (access(path.c_str(), F_OK) != 0) { + if (mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { + APP_LOGE("CreateDir:%{public}s error", path.c_str()); + } + } +} + +REGISTER_AA(PageAbilityDemo) +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/BUILD.gn b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..779c053c67eaf329e2c7a4d671771e0ade07f93c --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/BUILD.gn @@ -0,0 +1,58 @@ +# 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("//foundation/appexecfwk/standard/appexecfwk.gni") +SUBDEMOSYSTEM_DIR = "${appexecfwk_path}/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3" +SUBST_TOOLS_DIR = + "${appexecfwk_path}/test/resource/amssystemtestability/abilitySrc/tools" +config("third_page_demo3_config") { + visibility = [ ":*" ] + include_dirs = [ + "${SUBDEMOSYSTEM_DIR}/include", + "${kits_path}/appkit/native/app", + "${aafwk_path}/interfaces/innerkits/want/include/ohos/aafwk/content", + "${aafwk_path}/interfaces/innerkits/ability_manager/include", + "${innerkits_path}/libeventhandler/include", + "${services_path}/bundlemgr/include", + "${aafwk_path}/services/abilitymgr/include", + "${common_path}/log/include", + "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include", + "${SUBST_TOOLS_DIR}/include", + ] + defines = [ + "APP_LOG_TAG = \"thirdPageDemo3\"", + "LOG_DOMAIN = 0xD002200", + ] +} +ohos_shared_library("page_ability_native3") { + sources = [ "${SUBDEMOSYSTEM_DIR}/src/pageAbilityDemo.cpp" ] + configs = [ ":third_page_demo3_config" ] + deps = [ + "${aafwk_path}/frameworks/kits/ability/native:abilitykit_native", + "${aafwk_path}/frameworks/kits/ability/native:dummy_classes", + "${aafwk_path}/interfaces/innerkits/want:want", + "${common_path}:libappexecfwk_common", + "${innerkits_path}/appexecfwk_base:appexecfwk_base", + "${innerkits_path}/appexecfwk_core:appexecfwk_core", + "${kits_path}:appkit_native", + "${services_path}/bundlemgr:libbms", + "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", + "//utils/native/base:utilsbase", + ] + external_deps = [ + "ces_standard:cesfwk_innerkits", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + ] + subsystem_name = "bmssystemtestability" +} diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/config.json b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/config.json new file mode 100644 index 0000000000000000000000000000000000000000..9d69d4042c9e1d43baaf1d47026d19869d11eec6 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/config.json @@ -0,0 +1,52 @@ +{ + "app":{ + "bundleName": "com.third.hiworld.example1", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 3, + "target": 3 + } + }, + "deviceConfig": { + "default": { + } + }, + "module": { + "package":"com.third.hiworld.example.h1", + "name":"bmsThirdBundle1", + "deviceType": [ + "tv", + "car" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "testability", + "moduleType": "entry" + }, + "abilities": [{ + "name": "PageAbilityDemo", + "icon": "$media:snowball", + "label": "bmsThirdBundle_A1 Ability", + "launchType": "singleton", + "orientation": "unspecified", + "type": "page", + "visible": true, + "skills": [ + { + "actions": [ + "ohos.aafwk.content.Want.ACTION_HOME" + ], + "entities": [ + "ohos.aafwk.content.Want.ENTITY_HOME" + ], + "attributes": [] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/include/pageAbilityDemo.h b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/include/pageAbilityDemo.h new file mode 100644 index 0000000000000000000000000000000000000000..b70fe9b2b25570d6cb7f72dabbdb18bf1b2b2284 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/include/pageAbilityDemo.h @@ -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. + */ +#ifndef _PAGE_ABILITY_DEMO_ +#define _PAGE_ABILITY_DEMO_ +#include + +#include "ability.h" +#include "ability_loader.h" +#include "app_log_wrapper.h" +#include "stpageabilityevent.h" +namespace OHOS { +namespace AppExecFwk { +class PageAbilityDemo : public Ability { +protected: + 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; + +public: + void CreateFile(const std::string &path) const; + void CreateDir(const std::string &path) const; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif //_PAGE_ABILITY_DEMO_ \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/src/pageAbilityDemo.cpp b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/src/pageAbilityDemo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..64984a03bebbd337590c56977cdaa20d1202a318 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo3/src/pageAbilityDemo.cpp @@ -0,0 +1,109 @@ +/* + * 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 "pageAbilityDemo.h" +#include +#include +#include +namespace OHOS { +namespace AppExecFwk { +const std::string BUNDLE_DATA_ROOT_PATH = "/data/accounts/account_0/appdata/"; +void PageAbilityDemo::OnStart(const Want &want) +{ + APP_LOGI("PageAbilityDemo::onStart"); + Ability::OnStart(want); + const std::string appName = "com.third.hiworld.example1"; + std::string path = BUNDLE_DATA_ROOT_PATH + appName + "/cache/"; + APP_LOGI("PageAbilityDemo::CreateDir"); + for (int i = 1; i < 7; i++) { + path += "dir" + std::to_string(i) + "/"; + APP_LOGI("PageAbilityDemo::CreateDir %{public}s", path.c_str()); + CreateDir(path); + } + const std::string testCacheFileName = + BUNDLE_DATA_ROOT_PATH + appName + "/cache/dir1/dir2/dir3/dir4/dir5/dir6/name.txt"; + CreateFile(testCacheFileName); +} + +void PageAbilityDemo::OnNewWant(const Want &want) +{ + APP_LOGI("PageAbilityDemo::OnNewWant"); + Ability::OnNewWant(want); +} + +void PageAbilityDemo::OnForeground(const Want &want) +{ + APP_LOGI("PageAbilityDemo::OnForeground"); + Ability::OnForeground(want); +} + +void PageAbilityDemo::OnStop() +{ + APP_LOGI("PageAbilityDemo::onStop"); + Ability::OnStop(); +} + +void PageAbilityDemo::OnActive() +{ + APP_LOGI("PageAbilityDemo::OnActive"); + Ability::OnActive(); +} + +void PageAbilityDemo::OnInactive() +{ + APP_LOGI("PageAbilityDemo::OnInactive"); + Ability::OnInactive(); +} + +void PageAbilityDemo::OnBackground() +{ + APP_LOGI("PageAbilityDemo::OnBackground"); + Ability::OnBackground(); +} + +void PageAbilityDemo::CreateFile(const std::string &path) const +{ + if (path.size() > PATH_MAX) { + APP_LOGE("CreateFile the length of path is too long"); + return; + } + + std::string realPath; + realPath.reserve(PATH_MAX); + realPath.resize(PATH_MAX - 1); + + if (realpath(path.c_str(), &(realPath[0])) == nullptr) { + APP_LOGW("CreateFile-translate:%{public}s not exist path", realPath.c_str()); + } + + std::ofstream file(path); + file.close(); + + if (access(realPath.c_str(), F_OK) != 0) { + APP_LOGE("CreateFile-checkFile:%{public}s not exist", realPath.c_str()); + } +} + +void PageAbilityDemo::CreateDir(const std::string &path) const +{ + if (access(path.c_str(), F_OK) != 0) { + if (mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { + APP_LOGE("CreateDir:%{public}s error", path.c_str()); + } + } +} + +REGISTER_AA(PageAbilityDemo) +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/BUILD.gn b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..76e630bb892cfdaf85786a62d404c9799ac2992f --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/BUILD.gn @@ -0,0 +1,58 @@ +# 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("//foundation/appexecfwk/standard/appexecfwk.gni") +SUBDEMOSYSTEM_DIR = "${appexecfwk_path}/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4" +SUBST_TOOLS_DIR = + "${appexecfwk_path}/test/resource/amssystemtestability/abilitySrc/tools" +config("third_page_demo4_config") { + visibility = [ ":*" ] + include_dirs = [ + "${SUBDEMOSYSTEM_DIR}/include", + "${kits_path}/appkit/native/app", + "${aafwk_path}/interfaces/innerkits/want/include/ohos/aafwk/content", + "${aafwk_path}/interfaces/innerkits/ability_manager/include", + "${innerkits_path}/libeventhandler/include", + "${services_path}/bundlemgr/include", + "${aafwk_path}/services/abilitymgr/include", + "${common_path}/log/include", + "//foundation/distributedschedule/dmsfwk/services/dtbschedmgr/include", + "${SUBST_TOOLS_DIR}/include", + ] + defines = [ + "APP_LOG_TAG = \"thirdPageDemo4\"", + "LOG_DOMAIN = 0xD002200", + ] +} +ohos_shared_library("page_ability_native4") { + sources = [ "${SUBDEMOSYSTEM_DIR}/src/pageAbilityDemo.cpp" ] + configs = [ ":third_page_demo4_config" ] + deps = [ + "${aafwk_path}/frameworks/kits/ability/native:abilitykit_native", + "${aafwk_path}/frameworks/kits/ability/native:dummy_classes", + "${aafwk_path}/interfaces/innerkits/want:want", + "${common_path}:libappexecfwk_common", + "${innerkits_path}/appexecfwk_base:appexecfwk_base", + "${innerkits_path}/appexecfwk_core:appexecfwk_core", + "${kits_path}:appkit_native", + "${services_path}/bundlemgr:libbms", + "//foundation/distributedschedule/dmsfwk/interfaces/innerkits/uri:zuri", + "//utils/native/base:utilsbase", + ] + external_deps = [ + "ces_standard:cesfwk_innerkits", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + ] + subsystem_name = "bmssystemtestability" +} diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/config.json b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/config.json new file mode 100644 index 0000000000000000000000000000000000000000..9d69d4042c9e1d43baaf1d47026d19869d11eec6 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/config.json @@ -0,0 +1,52 @@ +{ + "app":{ + "bundleName": "com.third.hiworld.example1", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 3, + "target": 3 + } + }, + "deviceConfig": { + "default": { + } + }, + "module": { + "package":"com.third.hiworld.example.h1", + "name":"bmsThirdBundle1", + "deviceType": [ + "tv", + "car" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "testability", + "moduleType": "entry" + }, + "abilities": [{ + "name": "PageAbilityDemo", + "icon": "$media:snowball", + "label": "bmsThirdBundle_A1 Ability", + "launchType": "singleton", + "orientation": "unspecified", + "type": "page", + "visible": true, + "skills": [ + { + "actions": [ + "ohos.aafwk.content.Want.ACTION_HOME" + ], + "entities": [ + "ohos.aafwk.content.Want.ENTITY_HOME" + ], + "attributes": [] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/include/pageAbilityDemo.h b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/include/pageAbilityDemo.h new file mode 100644 index 0000000000000000000000000000000000000000..b70fe9b2b25570d6cb7f72dabbdb18bf1b2b2284 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/include/pageAbilityDemo.h @@ -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. + */ +#ifndef _PAGE_ABILITY_DEMO_ +#define _PAGE_ABILITY_DEMO_ +#include + +#include "ability.h" +#include "ability_loader.h" +#include "app_log_wrapper.h" +#include "stpageabilityevent.h" +namespace OHOS { +namespace AppExecFwk { +class PageAbilityDemo : public Ability { +protected: + 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; + +public: + void CreateFile(const std::string &path) const; + void CreateDir(const std::string &path) const; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif //_PAGE_ABILITY_DEMO_ \ No newline at end of file diff --git a/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/src/pageAbilityDemo.cpp b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/src/pageAbilityDemo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..afb14de6a493348b23a0ced32baf25d6222d9e81 --- /dev/null +++ b/test/resource/bmssystemtestability/abilitySrc/thirdPageDemo4/src/pageAbilityDemo.cpp @@ -0,0 +1,107 @@ +/* + * 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 "pageAbilityDemo.h" +#include +#include +#include +namespace OHOS { +namespace AppExecFwk { +const std::string BUNDLE_DATA_ROOT_PATH = "/data/accounts/account_0/appdata/"; +void PageAbilityDemo::OnStart(const Want &want) +{ + APP_LOGI("PageAbilityDemo::onStart"); + Ability::OnStart(want); + const std::string appName = "com.third.hiworld.example1"; + const std::string testCacheDir1 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/testDir1"; + const std::string testCacheDir2 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/testDir2"; + const std::string testCacheFileNamE1 = testCacheDir1 + "/name1.txt"; + const std::string testCacheFileNamE2 = testCacheDir2 + "/name2.txt"; + CreateDir(testCacheDir1); + CreateDir(testCacheDir2); + CreateFile(testCacheFileNamE1); + CreateFile(testCacheFileNamE2); +} + +void PageAbilityDemo::OnNewWant(const Want &want) +{ + APP_LOGI("PageAbilityDemo::OnNewWant"); + Ability::OnNewWant(want); +} + +void PageAbilityDemo::OnForeground(const Want &want) +{ + APP_LOGI("PageAbilityDemo::OnForeground"); + Ability::OnForeground(want); +} + +void PageAbilityDemo::OnStop() +{ + APP_LOGI("PageAbilityDemo::onStop"); + Ability::OnStop(); +} + +void PageAbilityDemo::OnActive() +{ + APP_LOGI("PageAbilityDemo::OnActive"); + Ability::OnActive(); +} + +void PageAbilityDemo::OnInactive() +{ + APP_LOGI("PageAbilityDemo::OnInactive"); + Ability::OnInactive(); +} + +void PageAbilityDemo::OnBackground() +{ + APP_LOGI("PageAbilityDemo::OnBackground"); + Ability::OnBackground(); +} + +void PageAbilityDemo::CreateFile(const std::string &path) const +{ + if (path.size() > PATH_MAX) { + APP_LOGE("CreateFile the length of path is too long"); + return; + } + + std::string realPath; + realPath.reserve(PATH_MAX); + realPath.resize(PATH_MAX - 1); + + if (realpath(path.c_str(), &(realPath[0])) == nullptr) { + APP_LOGW("CreateFile-translate:%{public}s not exist path", realPath.c_str()); + } + + std::ofstream file(path); + file.close(); + + if (access(realPath.c_str(), F_OK) != 0) { + APP_LOGE("CreateFile-checkFile:%{public}s not exist", realPath.c_str()); + } +} + +void PageAbilityDemo::CreateDir(const std::string &path) const +{ + if (access(path.c_str(), F_OK) != 0) { + if (mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) { + APP_LOGE("CreateDir:%{public}s error", path.c_str()); + } + } +} + +REGISTER_AA(PageAbilityDemo) +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle24.hap b/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle24.hap index f5cb92e3b8e3f0aae8502ea5477529d0e11b0a54..41142715b101b06f9b6b3be03c60c319b6c05895 100644 Binary files a/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle24.hap and b/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle24.hap differ diff --git a/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle25.hap b/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle25.hap index 5c8f741ef6776ba4d31565fcf6c14f7623cce0d4..c7ec8bfd7f89debc0865b60f641c733f5765b694 100644 Binary files a/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle25.hap and b/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle25.hap differ diff --git a/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle44.hap b/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle44.hap new file mode 100644 index 0000000000000000000000000000000000000000..f0d31b0f7c15b20eb169c09f4f926a5a26d9a2b3 Binary files /dev/null and b/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle44.hap differ diff --git a/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle45.hap b/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle45.hap new file mode 100644 index 0000000000000000000000000000000000000000..3ff235b0601412ca8074fb38ab892df6f18c9da8 Binary files /dev/null and b/test/resource/bundlemgrsst/stThirdBundle/bmsThirdBundle45.hap differ 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 old mode 100755 new mode 100644 index f43c80c6324c4c79923174b4731a3a0f35b454e2..66a94ea918fce42becb13fc97b9eeb2e1c48cc9f --- 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 @@ -14,6 +14,7 @@ */ #include +#include #include #include @@ -31,6 +32,7 @@ using OHOS::AAFwk::Want; using namespace testing::ext; +using namespace std::chrono_literals; namespace { const std::string THIRD_BUNDLE_PATH = "/data/test/bms_bundle/"; @@ -404,7 +406,7 @@ void ActsBmsKitSystemTest::CheckBundleInfo(const uint32_t index, BundleInfo &bun EXPECT_EQ(iter->bundleName, BASE_BUNDLE_NAME + std::to_string(index)); EXPECT_EQ(iter->description, ""); EXPECT_EQ(iter->label, "bmsThirdBundle_A2 Ability"); - EXPECT_EQ(iter->moduleName, "bmsThirdBundle1"); + EXPECT_EQ(iter->moduleName, "testability"); std::cout << "abilityInfo-moduleName:" << iter->moduleName << std::endl; EXPECT_EQ(iter->uri, ""); EXPECT_EQ(iter->visible, true); @@ -955,7 +957,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetBundleInfos_0200, Function | MediumTest | Leve break; } } - EXPECT_EQ(count, 3); + EXPECT_GE(count, 2); if (!getInfoResult) { APP_LOGI("GetBundleInfos_0200 failed - cycle count: %{public}d", i); @@ -1055,7 +1057,6 @@ HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfo_0200, Function | MediumTest | appName, ApplicationFlag::GET_APPLICATION_INFO_WITH_PERMS, userId, appInfo); std::string permission = commonTool.VectorToStr(appInfo.permissions); EXPECT_TRUE(getInfoResult); - std::cout << permission << std::endl; resvec.clear(); Uninstall(appName, resvec); std::string uninstallResult = commonTool.VectorToStr(resvec); @@ -1159,9 +1160,6 @@ HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfo_0400, Function | MediumTest | bundleMgrProxy->GetApplicationInfo(appName, ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, appInfo); EXPECT_TRUE(getInfoResult); EXPECT_EQ(appInfo.name, appName); - std::cout << appInfo.description << std::endl; - std::cout << appInfo.iconPath << std::endl; - std::cout << appInfo.supportedModes << std::endl; resvec.clear(); Uninstall(appName, resvec); std::string uninstallResult = commonTool.VectorToStr(resvec); @@ -1415,7 +1413,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetApplicationInfos_0200, Function | MediumTest | break; } } - EXPECT_EQ(count, 3); + EXPECT_GE(count, 2); if (!getInfoResult) { APP_LOGI("GetApplicationInfos_0200 failed - cycle count: %{public}d", i); @@ -2452,10 +2450,10 @@ HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0100, Function | MediumTest | Le EXPECT_TRUE(queryResult); EXPECT_EQ(hapModuleInfo.name, "com.third.hiworld.example.h1"); - EXPECT_EQ(hapModuleInfo.moduleName, "bmsThirdBundle1"); + EXPECT_EQ(hapModuleInfo.moduleName, "testability"); EXPECT_EQ(hapModuleInfo.description, ""); EXPECT_EQ(hapModuleInfo.label, "bmsThirdBundle_A1 Ability"); - std::cout << commonTool.VectorToStr(hapModuleInfo.deviceTypes) << std::endl; + EXPECT_EQ(commonTool.VectorToStr(hapModuleInfo.deviceTypes), "tvcar"); resvec.clear(); Uninstall(appName, resvec); @@ -2509,9 +2507,9 @@ HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0200, Function | MediumTest | Le bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo); EXPECT_TRUE(queryResult); EXPECT_EQ(hapModuleInfo.name, "com.third.hiworld.example.h1"); - EXPECT_EQ(hapModuleInfo.moduleName, "bmsThirdBundle2"); + EXPECT_EQ(hapModuleInfo.moduleName, "testability"); EXPECT_EQ(hapModuleInfo.label, "bmsThirdBundle_A1 Ability"); - std::cout << commonTool.VectorToStr(hapModuleInfo.deviceTypes) << std::endl; + EXPECT_EQ(commonTool.VectorToStr(hapModuleInfo.deviceTypes), "tvcar"); bool isSubStrExist = false; for (int i = 1; i <= 2; i++) { std::string abilityName = "" + std::to_string(i); @@ -2575,8 +2573,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0300, Function | MediumTest | Le bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo); EXPECT_TRUE(queryResult); EXPECT_EQ(hapModuleInfo.name, "com.third.hiworld.example.h1"); - EXPECT_EQ(hapModuleInfo.moduleName, "bmsThirdBundle3"); - std::cout << commonTool.VectorToStr(hapModuleInfo.deviceTypes) << std::endl; + EXPECT_EQ(hapModuleInfo.moduleName, "testability"); resvec.clear(); Uninstall(appName, resvec); @@ -2674,10 +2671,10 @@ HWTEST_F(ActsBmsKitSystemTest, GetHapModuleInfo_0500, Function | MediumTest | Le bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo); EXPECT_TRUE(queryResult); EXPECT_EQ(hapModuleInfo.name, "com.ohos.settings"); - EXPECT_EQ(hapModuleInfo.moduleName, ".MyApplication"); + EXPECT_EQ(hapModuleInfo.moduleName, "entry"); EXPECT_EQ(hapModuleInfo.label, "$string:app_name"); CommonTool commonTool; - std::cout << commonTool.VectorToStr(hapModuleInfo.deviceTypes) << std::endl; + EXPECT_EQ(commonTool.VectorToStr(hapModuleInfo.deviceTypes), "phone"); if (!queryResult) { APP_LOGI("GetHapModuleInfo_0500 failed - cycle count: %{public}d", i); @@ -3361,9 +3358,15 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0100, Function | MediumTest Install(bundleFilePath, InstallFlag::NORMAL, resvec); std::string installResult = commonTool.VectorToStr(resvec); ASSERT_EQ(installResult, "Success") << "install fail!"; - - const std::string testCacheFileNamE1 = BUNDLE_DATA_ROOT_PATH + "/" + appName + "/cache/name1.txt"; - const std::string testCacheFileNamE2 = BUNDLE_DATA_ROOT_PATH + "/" + appName + "/cache/name2.txt"; + std::this_thread::sleep_for(5000ms); + system("aa start -a PageAbilityDemo -b com.third.hiworld.example1"); + std::this_thread::sleep_for(1000ms); + 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); + EXPECT_EQ(name1Exist, 0); + int name2Exist = access(testCacheFileNamE2.c_str(), F_OK); + EXPECT_EQ(name2Exist, 0); sptr bundleCleanCacheCallback = (new (std::nothrow) CleanCacheCallBackImpl()); ASSERT_NE(bundleCleanCacheCallback, nullptr); @@ -3375,9 +3378,9 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0100, Function | MediumTest bundleMgrProxy->CleanBundleCacheFiles(appName, bundleCleanCacheCallback); bool cleanCacheResult = bundleCleanCacheCallback->GetSucceededResult(); EXPECT_TRUE(cleanCacheResult); - int name1Exist = access(testCacheFileNamE1.c_str(), F_OK); + name1Exist = access(testCacheFileNamE1.c_str(), F_OK); EXPECT_NE(name1Exist, 0) << "the cache test file1 exists."; - int name2Exist = access(testCacheFileNamE2.c_str(), F_OK); + name2Exist = access(testCacheFileNamE2.c_str(), F_OK); EXPECT_NE(name2Exist, 0) << "the cache test file2 exists."; resvec.clear(); @@ -3420,10 +3423,15 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0200, Function | MediumTest Install(bundleFilePath, InstallFlag::NORMAL, resvec); std::string installResult = commonTool.VectorToStr(resvec); ASSERT_EQ(installResult, "Success") << "install fail!"; - - const std::string testCacheDiR1 = BUNDLE_DATA_ROOT_PATH + "/" + appName + "/cache/testDir1"; - const std::string testCacheDiR2 = BUNDLE_DATA_ROOT_PATH + "/" + appName + "/cache/testDir2"; - + std::this_thread::sleep_for(5000ms); + system("aa start -a PageAbilityDemo -b com.third.hiworld.example2"); + std::this_thread::sleep_for(1000ms); + 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); + EXPECT_EQ(name1Exist, 0); + int name2Exist = access(testCacheDiR2.c_str(), F_OK); + EXPECT_EQ(name2Exist, 0); sptr bundleCleanCacheCallback = (new (std::nothrow) CleanCacheCallBackImpl()); ASSERT_NE(bundleCleanCacheCallback, nullptr); sptr bundleMgrProxy = GetBundleMgrProxy(); @@ -3434,9 +3442,9 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0200, Function | MediumTest bundleMgrProxy->CleanBundleCacheFiles(appName, bundleCleanCacheCallback); bool cleanCacheResult = bundleCleanCacheCallback->GetSucceededResult(); EXPECT_TRUE(cleanCacheResult); - int name1Exist = access(testCacheDiR1.c_str(), F_OK); + name1Exist = access(testCacheDiR1.c_str(), F_OK); EXPECT_NE(name1Exist, 0) << "the cache test dir1 exists."; - int name2Exist = access(testCacheDiR2.c_str(), F_OK); + name2Exist = access(testCacheDiR2.c_str(), F_OK); EXPECT_NE(name2Exist, 0) << "the cache test dir2 exists."; resvec.clear(); @@ -3472,17 +3480,20 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0300, Function | MediumTest bool result = false; for (int i = 1; i <= stLevel_.BMSLevel; i++) { std::vector resvec; - std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle1.hap"; + std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle44.hap"; std::string appName = BASE_BUNDLE_NAME + "1"; CommonTool commonTool; Install(bundleFilePath, InstallFlag::NORMAL, resvec); std::string installResult = commonTool.VectorToStr(resvec); ASSERT_EQ(installResult, "Success") << "install fail!"; - - const std::string testCacheFileName = - BUNDLE_DATA_ROOT_PATH + "/" + appName + "/cache/dir1/dir2/dir3/dir4/dir5/dir6/name.txt"; - const std::string testCacheDir = BUNDLE_DATA_ROOT_PATH + "/" + appName + "/cache/dir1"; + std::this_thread::sleep_for(5000ms); + system("aa start -a PageAbilityDemo -b com.third.hiworld.example1"); + std::this_thread::sleep_for(1000ms); + 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); + EXPECT_EQ(isExist, 0); sptr bundleCleanCacheCallback = (new (std::nothrow) CleanCacheCallBackImpl()); ASSERT_NE(bundleCleanCacheCallback, nullptr); sptr bundleMgrProxy = GetBundleMgrProxy(); @@ -3493,7 +3504,7 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0300, Function | MediumTest bundleMgrProxy->CleanBundleCacheFiles(appName, bundleCleanCacheCallback); bool cleanCacheResult = bundleCleanCacheCallback->GetSucceededResult(); EXPECT_TRUE(cleanCacheResult); - int isExist = access(testCacheDir.c_str(), F_OK); + isExist = access(testCacheDir.c_str(), F_OK); EXPECT_NE(isExist, 0) << "the cache test dir exists."; resvec.clear(); @@ -3529,19 +3540,24 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0400, Function | MediumTest bool result = false; for (int i = 1; i <= stLevel_.BMSLevel; i++) { std::vector resvec; - std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle2.hap"; + 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); ASSERT_EQ(installResult, "Success") << "install fail!"; - - 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"; - const std::string testCacheDir2 = BUNDLE_DATA_ROOT_PATH + "/" + appName + "/cache/testDir2"; - + std::this_thread::sleep_for(5000ms); + system("aa start -a PageAbilityDemo -b com.third.hiworld.example1"); + std::this_thread::sleep_for(1000ms); + 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"; + const std::string testCacheDir2 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/testDir2"; + int name1Exist = access(testCacheDir1.c_str(), F_OK); + EXPECT_EQ(name1Exist, 0); + int name2Exist = access(testCacheDir2.c_str(), F_OK); + EXPECT_EQ(name2Exist, 0); sptr bundleCleanCacheCallback = (new (std::nothrow) CleanCacheCallBackImpl()); ASSERT_NE(bundleCleanCacheCallback, nullptr); sptr bundleMgrProxy = GetBundleMgrProxy(); @@ -3552,9 +3568,9 @@ HWTEST_F(ActsBmsKitSystemTest, CleanBundleCacheFiles_0400, Function | MediumTest bundleMgrProxy->CleanBundleCacheFiles(appName, bundleCleanCacheCallback); bool cleanCacheResult = bundleCleanCacheCallback->GetSucceededResult(); EXPECT_TRUE(cleanCacheResult); - int name1Exist = access(testCacheDir1.c_str(), F_OK); + name1Exist = access(testCacheDir1.c_str(), F_OK); EXPECT_NE(name1Exist, 0) << "the cache test dir1 exists."; - int name2Exist = access(testCacheDir2.c_str(), F_OK); + name2Exist = access(testCacheDir2.c_str(), F_OK); EXPECT_NE(name2Exist, 0) << "the cache test dir2 exists."; resvec.clear(); @@ -4050,10 +4066,10 @@ HWTEST_F(ActsBmsKitSystemTest, AbilityDump_0100, Function | MediumTest | Level0) EXPECT_TRUE(queryResult); std::string path = "/data/test/abilityInfo.txt"; - bool isSuccess = CreateFile(path); - ASSERT_TRUE(isSuccess); + std::ofstream file(path); + file.close(); int fd = open(path.c_str(), O_WRONLY | O_CLOEXEC); - ASSERT_NE(fd, -1) << "open file error"; + EXPECT_NE(fd, -1) << "open file error"; std::string prefix = "[ability]"; abilityInfo.Dump(prefix, fd); long length = lseek(fd, 0, SEEK_END); @@ -4114,10 +4130,10 @@ HWTEST_F(ActsBmsKitSystemTest, ApplicationInfoDump_0100, Function | MediumTest | EXPECT_EQ(appInfo.name, appName); std::string path = "/data/test/appInfo.txt"; - bool isSuccess = CreateFile(path); - ASSERT_TRUE(isSuccess); + std::ofstream file(path); + file.close(); int fd = open(path.c_str(), O_WRONLY | O_CLOEXEC); - ASSERT_NE(fd, -1) << "open file error"; + EXPECT_NE(fd, -1) << "open file error"; std::string prefix = "[appInfo]"; appInfo.Dump(prefix, fd); long length = lseek(fd, 0, SEEK_END); @@ -4546,10 +4562,10 @@ HWTEST_F(ActsBmsKitSystemTest, ApplicationInfo_0100, Function | MediumTest | Lev EXPECT_EQ(appInfo.name, appName); ApplicationInfo *pAppInfo = &appInfo; std::string path = "/data/test/pAppInfo_01.txt"; - bool isSuccess = CreateFile(path); - ASSERT_TRUE(isSuccess); + std::ofstream file(path); + file.close(); int fd = open(path.c_str(), O_RDWR); - ASSERT_NE(fd, -1) << "open file error"; + EXPECT_NE(fd, -1) << "open file error"; std::string prefix = "[pAppInfo]"; pAppInfo->Dump(prefix, fd); long length = lseek(fd, 0, SEEK_END); @@ -4602,10 +4618,10 @@ HWTEST_F(ActsBmsKitSystemTest, ApplicationInfo_0200, Function | MediumTest | Lev ApplicationInfo *pAppInfo = &appInfo; std::string path = "/data/test/pAppInfo_02.txt"; - bool isSuccess = CreateFile(path); - ASSERT_TRUE(isSuccess); + std::ofstream file(path); + file.close(); int fd = open(path.c_str(), O_RDWR | O_CLOEXEC); - ASSERT_NE(fd, -1) << "open file error"; + EXPECT_NE(fd, -1) << "open file error"; std::string prefix = "[pAppInfo]"; pAppInfo->Dump(prefix, fd); long length = lseek(fd, 0, SEEK_END); diff --git a/test/systemtest/common/bms/bms_install_system_test/BUILD.gn b/test/systemtest/common/bms/bms_install_system_test/BUILD.gn index a7b274ab64ff155bebe339a830fce4d33a888fd2..0aba582287f31e2a6caeb6dc1cbf27989fd2e9a6 100755 --- a/test/systemtest/common/bms/bms_install_system_test/BUILD.gn +++ b/test/systemtest/common/bms/bms_install_system_test/BUILD.gn @@ -49,5 +49,5 @@ ohos_systemtest("BmsInstallSystemTest") { group("systemtest") { testonly = true - deps = [] + deps = [ ":BmsInstallSystemTest" ] } 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 b13b31d33b4047834c02af2163b0cf5e944ffc34..a358ee49598225bb19bf4d4e4f50187ccb651394 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 @@ -14,6 +14,7 @@ */ #include +#include #include #include @@ -1233,7 +1234,7 @@ HWTEST_F(BmsSearchSystemTest, BMS_Search_3300, Function | MediumTest | Level1) EXPECT_EQ(commonTool.VectorToStr(bundleInfo.modulePublicDirs), "/data/accounts/account_0/appdata/com.third.hiworld.example1/com.third.hiworld.example.h1"); EXPECT_EQ(commonTool.VectorToStr(bundleInfo.hapModuleNames), "com.third.hiworld.example.h1"); - EXPECT_EQ(commonTool.VectorToStr(bundleInfo.moduleNames), "bmsThirdBundle1"); + EXPECT_EQ(commonTool.VectorToStr(bundleInfo.moduleNames), "testability"); std::cout << "END BMS_Search_3300" << std::endl; } @@ -1291,7 +1292,7 @@ HWTEST_F(BmsSearchSystemTest, BMS_Search_3500, Function | MediumTest | Level1) bool queryResult = bundleMgrProxy->GetHapModuleInfo(abilityInfo, hapModuleInfo); EXPECT_EQ(hapModuleInfo.name, "com.third.hiworld.example.h1"); - EXPECT_EQ(hapModuleInfo.moduleName, "bmsThirdBundle1"); + EXPECT_EQ(hapModuleInfo.moduleName, "testability"); EXPECT_TRUE(queryResult); std::cout << "END BMS_SEARCH_3500" << std::endl; } @@ -1402,19 +1403,23 @@ HWTEST_F(BmsSearchSystemTest, BMS_Search_3800, Function | MediumTest | Level1) std::string appName = BASE_BUNDLE_NAME + "1"; - const std::string testCacheFileNamE1 = BUNDLE_DATA_ROOT_PATH + "/" + appName + "/cache/name1.txt"; - const std::string testCacheFileNamE2 = BUNDLE_DATA_ROOT_PATH + "/" + appName + "/cache/name2.txt"; - bool isSuccess = CreateFile(testCacheFileNamE1); - ASSERT_TRUE(isSuccess); - isSuccess = CreateFile(testCacheFileNamE2); - ASSERT_TRUE(isSuccess); + const std::string testCacheFileNamE1 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/name1.txt"; + const std::string testCacheFileNamE2 = BUNDLE_DATA_ROOT_PATH + appName + "/cache/name2.txt"; + std::ofstream file1(testCacheFileNamE1); + std::ofstream file2(testCacheFileNamE2); + file1.close(); + file2.close(); + int name1Exist = access(testCacheFileNamE1.c_str(), F_OK); + EXPECT_EQ(name1Exist, 0); + int name2Exist = access(testCacheFileNamE2.c_str(), F_OK); + EXPECT_EQ(name2Exist, 0); sptr bundleCleanCacheCallback = (new (std::nothrow) CleanCacheCallBackImpl()); ASSERT_NE(bundleCleanCacheCallback, nullptr); bundleMgrProxy->CleanBundleCacheFiles(appName, bundleCleanCacheCallback); EXPECT_TRUE(bundleCleanCacheCallback->GetSucceededResult()); - int name1Exist = access(testCacheFileNamE1.c_str(), F_OK); + name1Exist = access(testCacheFileNamE1.c_str(), F_OK); EXPECT_NE(name1Exist, 0) << "the cache test file1 exists."; - int name2Exist = access(testCacheFileNamE2.c_str(), F_OK); + name2Exist = access(testCacheFileNamE2.c_str(), F_OK); EXPECT_NE(name2Exist, 0) << "the cache test file2 exists."; std::cout << "END BMS_SEARCH_3800" << std::endl; } @@ -1437,17 +1442,21 @@ HWTEST_F(BmsSearchSystemTest, BMS_Search_3900, Function | MediumTest | Level1) std::string appName = BASE_BUNDLE_NAME + "1"; - const std::string testCacheFileNamE1 = BUNDLE_DATA_ROOT_PATH + "/" + appName + "/files/name1.txt"; - const std::string testCacheFileNamE2 = BUNDLE_DATA_ROOT_PATH + "/" + appName + "/files/name2.txt"; - bool isSuccess = CreateFile(testCacheFileNamE1); - ASSERT_TRUE(isSuccess); - isSuccess = CreateFile(testCacheFileNamE2); - ASSERT_TRUE(isSuccess); - bundleMgrProxy->CleanBundleDataFiles(appName); + const std::string testCacheFileNamE1 = BUNDLE_DATA_ROOT_PATH + appName + "/files/name1.txt"; + const std::string testCacheFileNamE2 = BUNDLE_DATA_ROOT_PATH + appName + "/files/name2.txt"; + std::ofstream file1(testCacheFileNamE1); + std::ofstream file2(testCacheFileNamE2); + file1.close(); + file2.close(); int name1Exist = access(testCacheFileNamE1.c_str(), F_OK); - ASSERT_NE(name1Exist, 0) << "the test file1 exists."; + EXPECT_EQ(name1Exist, 0) << "the test file1 exists."; int name2Exist = access(testCacheFileNamE2.c_str(), F_OK); - ASSERT_NE(name2Exist, 0) << "the test file2 exists."; + EXPECT_EQ(name2Exist, 0) << "the test file2 exists."; + bundleMgrProxy->CleanBundleDataFiles(appName); + name1Exist = access(testCacheFileNamE1.c_str(), F_OK); + EXPECT_NE(name1Exist, 0) << "the test file1 exists."; + name2Exist = access(testCacheFileNamE2.c_str(), F_OK); + EXPECT_NE(name2Exist, 0) << "the test file2 exists."; std::cout << "END BMS_SEARCH_3900" << std::endl; }