diff --git a/ability/BUILD.gn b/ability/BUILD.gn index 2054416da9563de6b712c835f5d8fa3786de36f5..140c0479ca397fcde1b088c38d8a0cbd3c79d3ab 100644 --- a/ability/BUILD.gn +++ b/ability/BUILD.gn @@ -18,8 +18,8 @@ group("ability") { if (is_standard_system) { deps = [ "ability_runtime:ability_runtime", + "crossplatform:ability_crossplatform", "dmsfwk:dmsfwk", - "crossplatform:ability_crossplatform" ] } } diff --git a/ability/crossplatform/BUILD.gn b/ability/crossplatform/BUILD.gn index 91f03387ad228867a81b36411d82e09e06747f56..2bb825978c46925ebac7ad2c75c9fff6cac16561 100644 --- a/ability/crossplatform/BUILD.gn +++ b/ability/crossplatform/BUILD.gn @@ -16,8 +16,6 @@ import("//build/ohos_var.gni") group("ability_crossplatform") { testonly = true if (is_standard_system) { - deps = [ - "ability_runtime:ability_crossplatform_runtime", - ] + deps = [ "ability_runtime:ability_crossplatform_runtime" ] } } diff --git a/ability/crossplatform/ability_runtime/ActsLifeCycleEtsFeatureTest/BUILD.gn b/ability/crossplatform/ability_runtime/ActsLifeCycleEtsFeatureTest/BUILD.gn index 859c86ddf5d8dd1a40e3457fb59f7972a2578491..f15217a4614b72033af7708d6ea48809c9f07a5b 100644 --- a/ability/crossplatform/ability_runtime/ActsLifeCycleEtsFeatureTest/BUILD.gn +++ b/ability/crossplatform/ability_runtime/ActsLifeCycleEtsFeatureTest/BUILD.gn @@ -21,6 +21,7 @@ ohos_hap_assist_suite("ActsLifeCycleEtsFeatureTest") { ] ets2abc = true certificate_profile = "./signature/openharmony_sx.p7b" + # hap_name: HAP的名字,可选,默认为目标名 hap_name = "ActsLifeCycleEtsFeatureTest" subsystem_name = "ability" @@ -29,6 +30,7 @@ ohos_hap_assist_suite("ActsLifeCycleEtsFeatureTest") { ohos_app_scope("windowStage_app_profile") { # app_profile: HAP的AppScope中的app.json,只在Stage模型下使用 app_profile = "AppScope/app.json" + # sources: 资源文件路径 sources = [ "AppScope/resources" ] } @@ -39,8 +41,10 @@ ohos_js_assets("windowStage_js_assets") { ohos_resources("windowStage_resources") { # sources: 资源文件路径 sources = [ "src/main/resources" ] + # deps: 当前目标的依赖 deps = [ ":windowStage_app_profile" ] + # hap_profile: HAP的config.json,Stage模型对应module.json hap_profile = "src/main/module.json" -} \ No newline at end of file +} diff --git a/ability/crossplatform/ability_runtime/ActsLifeCycleEtsTest/BUILD.gn b/ability/crossplatform/ability_runtime/ActsLifeCycleEtsTest/BUILD.gn index 4d8ade1712e9f46ee3a64c33d9dd22914f978b90..fd7f83d5d7ea3426b8669cc956d0f7bc63b07e19 100644 --- a/ability/crossplatform/ability_runtime/ActsLifeCycleEtsTest/BUILD.gn +++ b/ability/crossplatform/ability_runtime/ActsLifeCycleEtsTest/BUILD.gn @@ -21,6 +21,7 @@ ohos_js_hap_suite("ActsLifeCycleEtsTest") { ] ets2abc = true certificate_profile = "./signature/openharmony_sx.p7b" + # hap_name: HAP的名字,可选,默认为目标名 hap_name = "ActsLifeCycleEtsTest" subsystem_name = "ability" @@ -29,6 +30,7 @@ ohos_js_hap_suite("ActsLifeCycleEtsTest") { ohos_app_scope("windowStage_app_profile") { # app_profile: HAP的AppScope中的app.json,只在Stage模型下使用 app_profile = "AppScope/app.json" + # sources: 资源文件路径 sources = [ "AppScope/resources" ] } @@ -39,8 +41,10 @@ ohos_js_assets("windowStage_js_assets") { ohos_resources("windowStage_resources") { # sources: 资源文件路径 sources = [ "src/main/resources" ] + # deps: 当前目标的依赖 deps = [ ":windowStage_app_profile" ] + # hap_profile: HAP的config.json,Stage模型对应module.json hap_profile = "src/main/module.json" -} \ No newline at end of file +} diff --git a/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/BUILD.gn b/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/BUILD.gn index 694eeee57957c633fed19c62baefa42c518cb7db..30ce8a7597b440149109c95566ba54849eb568c6 100644 --- a/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/BUILD.gn +++ b/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/BUILD.gn @@ -21,6 +21,7 @@ ohos_js_hap_suite("ActsUiAbilityEtsTest") { ] ets2abc = true certificate_profile = "./signature/openharmony_sx.p7b" + # hap_name: HAP的名字,可选,默认为目标名 hap_name = "ActsUiAbilityEtsTest" subsystem_name = "ability" @@ -29,6 +30,7 @@ ohos_js_hap_suite("ActsUiAbilityEtsTest") { ohos_app_scope("windowStage_app_profile") { # app_profile: HAP的AppScope中的app.json,只在Stage模型下使用 app_profile = "AppScope/app.json" + # sources: 资源文件路径 sources = [ "AppScope/resources" ] } @@ -39,8 +41,10 @@ ohos_js_assets("windowStage_js_assets") { ohos_resources("windowStage_resources") { # sources: 资源文件路径 sources = [ "src/main/resources" ] + # deps: 当前目标的依赖 deps = [ ":windowStage_app_profile" ] + # hap_profile: HAP的config.json,Stage模型对应module.json hap_profile = "src/main/module.json" -} \ No newline at end of file +} diff --git a/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/src/main/ets/MainAbility1/MainAbility1.ts b/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/src/main/ets/MainAbility1/MainAbility1.ts index 271aff7dfcf633644da8347a24a63fef22135cd1..d5e3a7b9e9078ef6ad2181a48ff1b6df7db35fde 100644 --- a/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/src/main/ets/MainAbility1/MainAbility1.ts +++ b/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/src/main/ets/MainAbility1/MainAbility1.ts @@ -28,6 +28,7 @@ export default class MainAbility1 extends Ability { onCreate(want, launchParam) { console.log("[Demo] MainAbility1 onCreate") + globalThis.launchParam1 = launchParam; abilityName = want.abilityName globalThis.list1 = []; recordLife(globalThis.list1, abilityName, 'onCreate'); diff --git a/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/src/main/ets/test/abilityLifeCycle.test.ets b/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/src/main/ets/test/abilityLifeCycle.test.ets index bf873f77338420eab8b841ce376ee16d952c8bd3..dd2a011ef93d1ab6185d0662de484379e39051f1 100644 --- a/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/src/main/ets/test/abilityLifeCycle.test.ets +++ b/ability/crossplatform/ability_runtime/ActsUiAbilityEtsTest/src/main/ets/test/abilityLifeCycle.test.ets @@ -14,6 +14,7 @@ */ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; +import aConstant from '@ohos.app.ability.AbilityConstant' function sleep(time) { return new Promise((resolve) => setTimeout(resolve, time)); @@ -481,5 +482,42 @@ export default function abilityTest() { // await sleep(500); // done(); // }) + + /** + *@tc.number : UIAbilityConstantTest0100 + *@tc.name : UIAbilityConstantTest0100 + *@tc.desc : start mainability1, check ability constant. + *@tc.size : MediumTest + *@tc.type : Function + *@tc.level : Level 1 + */ + it("UIAbilityConstantTest0100", 0, async (done) => { + console.log("------------UIAbilityConstantTest0100 START-------------"); + TAG = "UIAbilityConstantTest0100"; + + var want = { + bundleName: "com.example.uiabilitylifecycle", + abilityName: "MainAbility1", + moduleName: moduleName, + }; + globalThis.abilityContext + .startAbility(want) + .then((data) => { + console.info(TAG + " start successful. Data: " + data); + }) + .catch((error) => { + console.error(TAG + " start failed. Cause: " + JSON.stringify(error)); + }); + + await sleep(1000); + + console.log('UIAbilityConstantTest0100:' + globalThis.launchParam1.lastExitReason) + expect(globalThis.launchParam1.launchReason == 1).assertTrue(); + expect(globalThis.launchParam1.lastExitReason == 2).assertTrue(); + expect(aConstant.LaunchReason.UNKNOWN == 0).assertTrue(); + expect(aConstant.LastExitReason.UNKNOWN == 0).assertTrue(); + done(); + }); + }); } diff --git a/ability/crossplatform/ability_runtime/BUILD.gn b/ability/crossplatform/ability_runtime/BUILD.gn index 49e88915d8e730dc45c270563c4ac00a0e515174..483e8d4dc7c3f9b72474de662f6c63ce6fb67b1d 100644 --- a/ability/crossplatform/ability_runtime/BUILD.gn +++ b/ability/crossplatform/ability_runtime/BUILD.gn @@ -20,7 +20,7 @@ group("ability_crossplatform_runtime") { "ActsLifeCycleEtsFeatureTest:ActsLifeCycleEtsFeatureTest", "ActsLifeCycleEtsTest:ActsLifeCycleEtsTest", "ActsUiAbilityEtsTest:ActsUiAbilityEtsTest", - "commonTestAbilityApp:commonTestAbilityApp" + "commonTestAbilityApp:commonTestAbilityApp", ] } } diff --git a/ability/crossplatform/ability_runtime/commonTestAbilityApp/BUILD.gn b/ability/crossplatform/ability_runtime/commonTestAbilityApp/BUILD.gn index ca39145d82df6ed5b6d0385327d40e9f3d0e17eb..ea005f55dfce0f39a6f9734d61bf78748866b3d7 100644 --- a/ability/crossplatform/ability_runtime/commonTestAbilityApp/BUILD.gn +++ b/ability/crossplatform/ability_runtime/commonTestAbilityApp/BUILD.gn @@ -21,6 +21,7 @@ ohos_hap_assist_suite("commonTestAbilityApp") { ] ets2abc = true certificate_profile = "./signature/openharmony_sx.p7b" + # hap_name: HAP的名字,可选,默认为目标名 hap_name = "commonTestAbilityApp" subsystem_name = "ability" @@ -29,6 +30,7 @@ ohos_hap_assist_suite("commonTestAbilityApp") { ohos_app_scope("windowStage_app_profile") { # app_profile: HAP的AppScope中的app.json,只在Stage模型下使用 app_profile = "AppScope/app.json" + # sources: 资源文件路径 sources = [ "AppScope/resources" ] } @@ -39,8 +41,10 @@ ohos_js_assets("windowStage_js_assets") { ohos_resources("windowStage_resources") { # sources: 资源文件路径 sources = [ "src/main/resources" ] + # deps: 当前目标的依赖 deps = [ ":windowStage_app_profile" ] + # hap_profile: HAP的config.json,Stage模型对应module.json hap_profile = "src/main/module.json" -} \ No newline at end of file +}