提交 2e8a82a8 编写于 作者: H hu0475

'测试abilityconstant'

Signed-off-by: Nhu0475 <huyanqiang5@huawei.com>
上级 25107fb1
...@@ -28,6 +28,7 @@ export default class MainAbility1 extends Ability { ...@@ -28,6 +28,7 @@ export default class MainAbility1 extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log("[Demo] MainAbility1 onCreate") console.log("[Demo] MainAbility1 onCreate")
globalThis.launchParam1 = launchParam;
abilityName = want.abilityName abilityName = want.abilityName
globalThis.list1 = []; globalThis.list1 = [];
recordLife(globalThis.list1, abilityName, 'onCreate'); recordLife(globalThis.list1, abilityName, 'onCreate');
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium";
import aConstant from '@ohos.app.ability.AbilityConstant'
function sleep(time) { function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time)); return new Promise((resolve) => setTimeout(resolve, time));
...@@ -481,5 +482,42 @@ export default function abilityTest() { ...@@ -481,5 +482,42 @@ export default function abilityTest() {
// await sleep(500); // await sleep(500);
// done(); // 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();
});
}); });
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册