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(); + }); + }); }