未验证 提交 fc028cf2 编写于 作者: O openharmony_ci 提交者: Gitee

!4736 Adapt to the new framework

Merge pull request !4736 from jiyong/local-20220801-0003
{ {
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "180000", "test-timeout": "180000",
"package": "com.example.lifecycletest", "bundle-name": "com.example.lifecycletest",
"shell-timeout": "600000" "module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
}, },
"kits": [ "kits": [
{ {
......
...@@ -28,7 +28,7 @@ export default class MainAbility extends Ability { ...@@ -28,7 +28,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate") console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context; globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "pages/MainAbility_pages", null) windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility_pages", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import file from '@system.file'; import router from '@ohos.router';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import list from '../test/ListTest' import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry @Entry
@Component @Component
...@@ -24,23 +25,12 @@ struct Index { ...@@ -24,23 +25,12 @@ struct Index {
aboutToAppear() { aboutToAppear() {
console.info("start run testcase!!!!") console.info("start run testcase!!!!")
const core = Core.getInstance() var abilityDelegator: any
const expectExtend = new ExpectExtend({ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
'id': 'extend' var abilityDelegatorArguments: any
}) abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
core.addService('expect', expectExtend) console.info('start run testcase!!!')
const reportExtend = new ReportExtend(file) Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
core.addService('report', reportExtend)
core.init()
globalThis.abilityWant.parameters.timeout = 20000;
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
configService.setConfig(globalThis.abilityWant.parameters)
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
list(globalThis.abilityContext)
core.execute()
} }
build() { build() {
......
...@@ -101,7 +101,7 @@ export default class MainAbility1 extends Ability { ...@@ -101,7 +101,7 @@ export default class MainAbility1 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility1 onWindowStageCreate") console.log("[Demo] MainAbility1 onWindowStageCreate")
globalThis.ability2Context = this.context; globalThis.ability2Context = this.context;
windowStage.setUIContent(this.context, "pages/MainAbility1_pages", null) windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility1_pages", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -87,7 +87,7 @@ export default class MainAbility2 extends Ability { ...@@ -87,7 +87,7 @@ export default class MainAbility2 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility2 onWindowStageCreate") console.log("[Demo] MainAbility2 onWindowStageCreate")
globalThis.ability3Context = this.context; globalThis.ability3Context = this.context;
windowStage.setUIContent(this.context, "pages/MainAbility2_pages", null) windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility2_pages", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -115,7 +115,7 @@ export default class MainAbility3 extends Ability { ...@@ -115,7 +115,7 @@ export default class MainAbility3 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility3 onWindowStageCreate") console.log("[Demo] MainAbility3 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/MainAbility3_pages", null) windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility3_pages", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -87,7 +87,7 @@ export default class MainAbility4 extends Ability { ...@@ -87,7 +87,7 @@ export default class MainAbility4 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility4 onWindowStageCreate") console.log("[Demo] MainAbility4 onWindowStageCreate")
globalThis.ability4context = this.context; globalThis.ability4context = this.context;
windowStage.setUIContent(this.context, "pages/MainAbility4_pages", null) windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility4_pages", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -93,7 +93,7 @@ export default class MainAbility5 extends Ability { ...@@ -93,7 +93,7 @@ export default class MainAbility5 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility5 onWindowStageCreate") console.log("[Demo] MainAbility5 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/MainAbility5_pages", null) windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility5_pages", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -87,7 +87,7 @@ export default class MainAbility6 extends Ability { ...@@ -87,7 +87,7 @@ export default class MainAbility6 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility6 onWindowStageCreate") console.log("[Demo] MainAbility6 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/MainAbility6_pages", null) windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility6_pages", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -14,7 +14,7 @@ export default class MainAbility7 extends Ability { ...@@ -14,7 +14,7 @@ export default class MainAbility7 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility7 onWindowStageCreate") console.log("[Demo] MainAbility7 onWindowStageCreate")
globalThis.ability7context = this.context; globalThis.ability7context = this.context;
windowStage.setUIContent(this.context, "pages/MainAbility7_pages", null) windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility7_pages", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
/*
* Copyright (c) 2022 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 Ability from '@ohos.application.Ability'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 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 router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.lifecycletest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
...@@ -13,9 +13,8 @@ ...@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
export default function abilityTest() {
export default function abilityTest(abilityContext) {
describe('AbilityTest', function () { describe('AbilityTest', function () {
...@@ -68,7 +67,7 @@ export default function abilityTest(abilityContext) { ...@@ -68,7 +67,7 @@ export default function abilityTest(abilityContext) {
TAG = "Multihap_WindowStageLifecycleTest_001"; TAG = "Multihap_WindowStageLifecycleTest_001";
listKeyTemp = []; listKeyTemp = [];
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4" abilityName: "MainAbility4"
}, (error, data) => { }, (error, data) => {
...@@ -78,7 +77,7 @@ export default function abilityTest(abilityContext) { ...@@ -78,7 +77,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000); await sleep(1000);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility3" abilityName: "Hap2MainAbility3"
}, (error, data) => { }, (error, data) => {
...@@ -120,7 +119,7 @@ export default function abilityTest(abilityContext) { ...@@ -120,7 +119,7 @@ export default function abilityTest(abilityContext) {
TAG = "Multihap_WindowStageLifecycleTest_002"; TAG = "Multihap_WindowStageLifecycleTest_002";
listKeyTemp = []; listKeyTemp = [];
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4" abilityName: "MainAbility4"
}, (error, data) => { }, (error, data) => {
...@@ -130,7 +129,7 @@ export default function abilityTest(abilityContext) { ...@@ -130,7 +129,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000); await sleep(1000);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility4" abilityName: "Hap2MainAbility4"
}, (error, data) => { }, (error, data) => {
...@@ -140,7 +139,7 @@ export default function abilityTest(abilityContext) { ...@@ -140,7 +139,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000); await sleep(1000);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility4" abilityName: "Hap2MainAbility4"
}, (error, data) => { }, (error, data) => {
...@@ -182,7 +181,7 @@ export default function abilityTest(abilityContext) { ...@@ -182,7 +181,7 @@ export default function abilityTest(abilityContext) {
TAG = "Multihap_WindowStageLifecycleTest_003"; TAG = "Multihap_WindowStageLifecycleTest_003";
listKeyTemp = []; listKeyTemp = [];
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4" abilityName: "MainAbility4"
}, (error, data) => { }, (error, data) => {
...@@ -192,7 +191,7 @@ export default function abilityTest(abilityContext) { ...@@ -192,7 +191,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000); await sleep(1000);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility5" abilityName: "Hap2MainAbility5"
}, (error, data) => { }, (error, data) => {
...@@ -202,7 +201,7 @@ export default function abilityTest(abilityContext) { ...@@ -202,7 +201,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000); await sleep(1000);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility5" abilityName: "Hap2MainAbility5"
}, (error, data) => { }, (error, data) => {
...@@ -249,7 +248,7 @@ export default function abilityTest(abilityContext) { ...@@ -249,7 +248,7 @@ export default function abilityTest(abilityContext) {
listKeyTemp = []; listKeyTemp = [];
listKeyTemp1 = []; listKeyTemp1 = [];
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4" abilityName: "MainAbility4"
}, (error, data) => { }, (error, data) => {
...@@ -259,7 +258,7 @@ export default function abilityTest(abilityContext) { ...@@ -259,7 +258,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000); await sleep(1000);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility6" abilityName: "Hap2MainAbility6"
}, (error, data) => { }, (error, data) => {
...@@ -269,7 +268,7 @@ export default function abilityTest(abilityContext) { ...@@ -269,7 +268,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000); await sleep(1000);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap3MainAbility2" abilityName: "Hap3MainAbility2"
}, (error, data) => { }, (error, data) => {
...@@ -320,7 +319,7 @@ export default function abilityTest(abilityContext) { ...@@ -320,7 +319,7 @@ export default function abilityTest(abilityContext) {
listKeyTemp = []; listKeyTemp = [];
listKeyTemp1 = []; listKeyTemp1 = [];
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4" abilityName: "MainAbility4"
}, (error, data) => { }, (error, data) => {
...@@ -330,7 +329,7 @@ export default function abilityTest(abilityContext) { ...@@ -330,7 +329,7 @@ export default function abilityTest(abilityContext) {
await sleep(500); await sleep(500);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility6" abilityName: "Hap2MainAbility6"
}, (error, data) => { }, (error, data) => {
...@@ -340,7 +339,7 @@ export default function abilityTest(abilityContext) { ...@@ -340,7 +339,7 @@ export default function abilityTest(abilityContext) {
await sleep(500); await sleep(500);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility7" abilityName: "Hap2MainAbility7"
}, (error, data) => { }, (error, data) => {
...@@ -394,7 +393,7 @@ export default function abilityTest(abilityContext) { ...@@ -394,7 +393,7 @@ export default function abilityTest(abilityContext) {
var firstCallbackId; var firstCallbackId;
var secondCallbackId; var secondCallbackId;
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility7" abilityName: "MainAbility7"
}, (error, data) => { }, (error, data) => {
...@@ -404,7 +403,7 @@ export default function abilityTest(abilityContext) { ...@@ -404,7 +403,7 @@ export default function abilityTest(abilityContext) {
await sleep(500); await sleep(500);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility8" abilityName: "Hap2MainAbility8"
}, (error, data) => { }, (error, data) => {
...@@ -419,7 +418,7 @@ export default function abilityTest(abilityContext) { ...@@ -419,7 +418,7 @@ export default function abilityTest(abilityContext) {
await sleep(500); await sleep(500);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility7" abilityName: "MainAbility7"
}, (error, data) => { }, (error, data) => {
...@@ -429,7 +428,7 @@ export default function abilityTest(abilityContext) { ...@@ -429,7 +428,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000); await sleep(1000);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility8" abilityName: "Hap2MainAbility8"
}, (error, data) => { }, (error, data) => {
...@@ -476,7 +475,7 @@ export default function abilityTest(abilityContext) { ...@@ -476,7 +475,7 @@ export default function abilityTest(abilityContext) {
var callBackId2; var callBackId2;
var flag; var flag;
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility6" abilityName: "MainAbility6"
}, (error, data) => { }, (error, data) => {
...@@ -485,7 +484,7 @@ export default function abilityTest(abilityContext) { ...@@ -485,7 +484,7 @@ export default function abilityTest(abilityContext) {
}); });
setTimeout(function () { setTimeout(function () {
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility9" abilityName: "Hap2MainAbility9"
}, (error, data) => { }, (error, data) => {
...@@ -523,7 +522,7 @@ export default function abilityTest(abilityContext) { ...@@ -523,7 +522,7 @@ export default function abilityTest(abilityContext) {
setTimeout(function () { setTimeout(function () {
if (flag == 0) { if (flag == 0) {
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility6" abilityName: "MainAbility6"
}, (error, data) => { }, (error, data) => {
...@@ -532,7 +531,7 @@ export default function abilityTest(abilityContext) { ...@@ -532,7 +531,7 @@ export default function abilityTest(abilityContext) {
}); });
setTimeout(function () { setTimeout(function () {
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility9" abilityName: "Hap2MainAbility9"
}, (error, data) => { }, (error, data) => {
...@@ -584,7 +583,7 @@ export default function abilityTest(abilityContext) { ...@@ -584,7 +583,7 @@ export default function abilityTest(abilityContext) {
TAG = "Multihap_WindowStageLifecycleTest_008"; TAG = "Multihap_WindowStageLifecycleTest_008";
listKeyTemp = []; listKeyTemp = [];
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4" abilityName: "MainAbility4"
}, (error, data) => { }, (error, data) => {
...@@ -594,7 +593,7 @@ export default function abilityTest(abilityContext) { ...@@ -594,7 +593,7 @@ export default function abilityTest(abilityContext) {
await sleep(500); await sleep(500);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility6" abilityName: "Hap2MainAbility6"
}, (error, data) => { }, (error, data) => {
...@@ -644,7 +643,7 @@ export default function abilityTest(abilityContext) { ...@@ -644,7 +643,7 @@ export default function abilityTest(abilityContext) {
listKeyTemp = []; listKeyTemp = [];
listKeyTemp1 = []; listKeyTemp1 = [];
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4", abilityName: "MainAbility4",
}, (error, data) => { }, (error, data) => {
...@@ -653,7 +652,7 @@ export default function abilityTest(abilityContext) { ...@@ -653,7 +652,7 @@ export default function abilityTest(abilityContext) {
}) })
await sleep(1000) await sleep(1000)
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility10", abilityName: "Hap2MainAbility10",
}, (error, data) => { }, (error, data) => {
...@@ -662,7 +661,7 @@ export default function abilityTest(abilityContext) { ...@@ -662,7 +661,7 @@ export default function abilityTest(abilityContext) {
}) })
await sleep(1000) await sleep(1000)
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap3MainAbility3", abilityName: "Hap3MainAbility3",
}, (error, data) => { }, (error, data) => {
...@@ -671,7 +670,7 @@ export default function abilityTest(abilityContext) { ...@@ -671,7 +670,7 @@ export default function abilityTest(abilityContext) {
}) })
await sleep(1000) await sleep(1000)
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility10", abilityName: "Hap2MainAbility10",
}, (error, data) => { }, (error, data) => {
...@@ -680,7 +679,7 @@ export default function abilityTest(abilityContext) { ...@@ -680,7 +679,7 @@ export default function abilityTest(abilityContext) {
}) })
await sleep(1000) await sleep(1000)
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap3MainAbility3", abilityName: "Hap3MainAbility3",
}, (error, data) => { }, (error, data) => {
...@@ -690,7 +689,7 @@ export default function abilityTest(abilityContext) { ...@@ -690,7 +689,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000) await sleep(1000)
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility10", abilityName: "Hap2MainAbility10",
}, (error, data) => { }, (error, data) => {
...@@ -699,7 +698,7 @@ export default function abilityTest(abilityContext) { ...@@ -699,7 +698,7 @@ export default function abilityTest(abilityContext) {
}) })
await sleep(1000) await sleep(1000)
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap3MainAbility3", abilityName: "Hap3MainAbility3",
}, (error, data) => { }, (error, data) => {
...@@ -758,7 +757,7 @@ export default function abilityTest(abilityContext) { ...@@ -758,7 +757,7 @@ export default function abilityTest(abilityContext) {
TAG = "Multihap_WindowStageLifecycleTest_010"; TAG = "Multihap_WindowStageLifecycleTest_010";
listKeyTemp = []; listKeyTemp = [];
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "MainAbility2", abilityName: "MainAbility2",
}, (error, data) => { }, (error, data) => {
...@@ -768,7 +767,7 @@ export default function abilityTest(abilityContext) { ...@@ -768,7 +767,7 @@ export default function abilityTest(abilityContext) {
await sleep(500); await sleep(500);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest", bundleName: "com.example.lifecycletest",
abilityName: "Hap4MainAbility1", abilityName: "Hap4MainAbility1",
}, (error, data) => { }, (error, data) => {
......
...@@ -14,6 +14,6 @@ ...@@ -14,6 +14,6 @@
*/ */
import lifecycleTest from './LifecycleTest' import lifecycleTest from './LifecycleTest'
export default function List(context) { export default function List() {
lifecycleTest(context) lifecycleTest()
} }
\ No newline at end of file
{ {
"src": [ "src": [
"pages/MainAbility_pages", "MainAbility/pages/MainAbility_pages",
"pages/MainAbility1_pages", "MainAbility/pages/MainAbility1_pages",
"pages/MainAbility2_pages", "MainAbility/pages/MainAbility2_pages",
"pages/MainAbility3_pages", "MainAbility/pages/MainAbility3_pages",
"pages/MainAbility4_pages", "MainAbility/pages/MainAbility4_pages",
"pages/MainAbility5_pages", "MainAbility/pages/MainAbility5_pages",
"pages/MainAbility6_pages" "MainAbility/pages/MainAbility6_pages"
] ]
} }
\ No newline at end of file
{ {
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "180000", "test-timeout": "180000",
"package": "com.example.windowstagelifecycle_xts", "bundle-name": "com.example.windowstagelifecycle_xts",
"shell-timeout": "600000" "module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
}, },
"kits": [ "kits": [
{ {
......
...@@ -35,7 +35,7 @@ export default class Hap1MainAbility1 extends Ability { ...@@ -35,7 +35,7 @@ export default class Hap1MainAbility1 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] Hap1MainAbility1 onWindowStageCreate") console.log("[Demo] Hap1MainAbility1 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/indexh1a1", null) windowStage.setUIContent(this.context, "MainAbility/pages/indexh1a1", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -36,7 +36,7 @@ export default class Hap1MainAbility2 extends Ability { ...@@ -36,7 +36,7 @@ export default class Hap1MainAbility2 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] Hap1MainAbility2 onWindowStageCreate") console.log("[Demo] Hap1MainAbility2 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/indexh1a2", null) windowStage.setUIContent(this.context, "MainAbility/pages/indexh1a2", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -28,7 +28,7 @@ export default class MainAbility extends Ability { ...@@ -28,7 +28,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate") console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context; globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "pages/index", null) windowStage.setUIContent(this.context, "MainAbility/pages/index", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -13,29 +13,22 @@ ...@@ -13,29 +13,22 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import file from '@system.file'; import router from '@ohos.router';
import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import List from '../test/ListTest' import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry @Entry
@Component @Component
struct Index { struct Index {
aboutToAppear() { aboutToAppear() {
console.info("start run testcase!!!!") console.info("start run testcase!!!!")
const core = Core.getInstance() var abilityDelegator: any
const expectExtend = new ExpectExtend({ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
'id': 'extend' var abilityDelegatorArguments: any
}) abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
core.addService('expect', expectExtend) console.info('start run testcase!!!')
const reportExtend = new ReportExtend(file) Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
core.addService('report', reportExtend)
core.init()
globalThis.abilityWant.parameters.timeout = 10000;
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
configService.setConfig(globalThis.abilityWant.parameters);
List(globalThis.abilityContext)
core.execute()
} }
build() { build() {
......
...@@ -100,7 +100,7 @@ export default class MainAbility1 extends Ability { ...@@ -100,7 +100,7 @@ export default class MainAbility1 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility1 onWindowStageCreate") console.log("[Demo] MainAbility1 onWindowStageCreate")
globalThis.ability1context = this.context; globalThis.ability1context = this.context;
windowStage.setUIContent(this.context, "pages/index1", null) windowStage.setUIContent(this.context, "MainAbility/pages/index1", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -99,7 +99,7 @@ export default class MainAbility10 extends Ability { ...@@ -99,7 +99,7 @@ export default class MainAbility10 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility10 onWindowStageCreate") console.log("[Demo] MainAbility10 onWindowStageCreate")
globalThis.ability10 = this.context; globalThis.ability10 = this.context;
windowStage.setUIContent(this.context, "pages/index10", null) windowStage.setUIContent(this.context, "MainAbility/pages/index10", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -100,7 +100,7 @@ export default class MainAbility11 extends Ability { ...@@ -100,7 +100,7 @@ export default class MainAbility11 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility11 onWindowStageCreate") console.log("[Demo] MainAbility11 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index11", null) windowStage.setUIContent(this.context, "MainAbility/pages/index11", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -99,7 +99,7 @@ export default class MainAbility12 extends Ability { ...@@ -99,7 +99,7 @@ export default class MainAbility12 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility12 onWindowStageCreate") console.log("[Demo] MainAbility12 onWindowStageCreate")
globalThis.ability12 = this.context; globalThis.ability12 = this.context;
windowStage.setUIContent(this.context, "pages/index12", null) windowStage.setUIContent(this.context, "MainAbility/pages/index12", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -28,7 +28,7 @@ export default class MainAbility2 extends Ability { ...@@ -28,7 +28,7 @@ export default class MainAbility2 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility2 onWindowStageCreate") console.log("[Demo] MainAbility2 onWindowStageCreate")
globalThis.ability2 = this.context; globalThis.ability2 = this.context;
windowStage.setUIContent(this.context, "pages/index2", null) windowStage.setUIContent(this.context, "MainAbility/pages/index2", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -101,7 +101,7 @@ export default class MainAbility3 extends Ability { ...@@ -101,7 +101,7 @@ export default class MainAbility3 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility3 onWindowStageCreate") console.log("[Demo] MainAbility3 onWindowStageCreate")
globalThis.ability3 = this.context globalThis.ability3 = this.context
windowStage.setUIContent(this.context, "pages/index3", null) windowStage.setUIContent(this.context, "MainAbility/pages/index3", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -101,7 +101,7 @@ export default class MainAbility4 extends Ability { ...@@ -101,7 +101,7 @@ export default class MainAbility4 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility4 onWindowStageCreate") console.log("[Demo] MainAbility4 onWindowStageCreate")
globalThis.ability4 = this.context; globalThis.ability4 = this.context;
windowStage.setUIContent(this.context, "pages/index4", null) windowStage.setUIContent(this.context, "MainAbility/pages/index4", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -28,7 +28,7 @@ export default class MainAbility5 extends Ability { ...@@ -28,7 +28,7 @@ export default class MainAbility5 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility5 onWindowStageCreate") console.log("[Demo] MainAbility5 onWindowStageCreate")
globalThis.ability5 = this.context; globalThis.ability5 = this.context;
windowStage.setUIContent(this.context, "pages/index5", null) windowStage.setUIContent(this.context, "MainAbility/pages/index5", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -28,7 +28,7 @@ export default class MainAbility6 extends Ability { ...@@ -28,7 +28,7 @@ export default class MainAbility6 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility6 onWindowStageCreate") console.log("[Demo] MainAbility6 onWindowStageCreate")
globalThis.ability6 = this.context; globalThis.ability6 = this.context;
windowStage.setUIContent(this.context, "pages/index6", null) windowStage.setUIContent(this.context, "MainAbility/pages/index6", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -28,7 +28,7 @@ export default class MainAbility7 extends Ability { ...@@ -28,7 +28,7 @@ export default class MainAbility7 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility7 onWindowStageCreate") console.log("[Demo] MainAbility7 onWindowStageCreate")
globalThis.ability7 = this.context; globalThis.ability7 = this.context;
windowStage.setUIContent(this.context, "pages/index7", null) windowStage.setUIContent(this.context, "MainAbility/pages/index7", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -28,7 +28,7 @@ export default class MainAbility8 extends Ability { ...@@ -28,7 +28,7 @@ export default class MainAbility8 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility8 onWindowStageCreate") console.log("[Demo] MainAbility8 onWindowStageCreate")
globalThis.ability8 = this.context; globalThis.ability8 = this.context;
windowStage.setUIContent(this.context, "pages/index8", null) windowStage.setUIContent(this.context, "MainAbility/pages/index8", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -28,7 +28,7 @@ export default class MainAbility9 extends Ability { ...@@ -28,7 +28,7 @@ export default class MainAbility9 extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility9 onWindowStageCreate") console.log("[Demo] MainAbility9 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index9", null) windowStage.setUIContent(this.context, "MainAbility/pages/index9", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
/*
* Copyright (c) 2022 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 Ability from '@ohos.application.Ability'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 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 router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.windowstagelifecycle_xts.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
...@@ -13,9 +13,8 @@ ...@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
export default function lifecycleTest() {
export default function lifecycleTest(abilityContext) {
describe('LifeCycleTest', function () { describe('LifeCycleTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
...@@ -84,7 +83,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -84,7 +83,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -137,7 +136,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -137,7 +136,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility1", "abilityName": "MainAbility1",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -148,7 +147,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -148,7 +147,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -206,7 +205,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -206,7 +205,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility1", "abilityName": "MainAbility1",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -217,7 +216,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -217,7 +216,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -286,7 +285,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -286,7 +285,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility3", "abilityName": "MainAbility3",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start3 successful. Data: ' + data); console.info(TAG + ' start3 successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -297,7 +296,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -297,7 +296,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start2 successful. Data: ' + data); console.info(TAG + ' start2 successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -370,7 +369,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -370,7 +369,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility1", "abilityName": "MainAbility1",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start1 successful. Data: ' + data); console.info(TAG + ' start1 successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -381,7 +380,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -381,7 +380,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility5", "abilityName": "MainAbility5",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start5 successful. Data: ' + data); console.info(TAG + ' start5 successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -393,7 +392,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -393,7 +392,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str2) globalThis.globalThis.abilityContext.startAbility(str2)
.then((data) => { .then((data) => {
console.info(TAG + ' start2 successful. Data: ' + data); console.info(TAG + ' start2 successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -445,7 +444,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -445,7 +444,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility1", "abilityName": "MainAbility1",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -456,7 +455,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -456,7 +455,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -468,7 +467,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -468,7 +467,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -481,7 +480,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -481,7 +480,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -547,7 +546,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -547,7 +546,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility1", "abilityName": "MainAbility1",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -558,7 +557,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -558,7 +557,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -570,7 +569,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -570,7 +569,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -633,7 +632,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -633,7 +632,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility6", "abilityName": "MainAbility6",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -648,7 +647,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -648,7 +647,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -681,7 +680,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -681,7 +680,7 @@ export default function lifecycleTest(abilityContext) {
console.log("------------Singlehap_WindowStageLifeCycleTest_0900 start-------------"); console.log("------------Singlehap_WindowStageLifeCycleTest_0900 start-------------");
TAG = "Singlehap_WindowStageLifeCycleTest_0900"; TAG = "Singlehap_WindowStageLifeCycleTest_0900";
listKeyTemp = []; listKeyTemp = [];
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.windowstagelifecycle_xts", bundleName: "com.example.windowstagelifecycle_xts",
abilityName: "MainAbility9" abilityName: "MainAbility9"
}, (error, data) => { }, (error, data) => {
...@@ -689,7 +688,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -689,7 +688,7 @@ export default function lifecycleTest(abilityContext) {
",data: " + JSON.stringify(data)); ",data: " + JSON.stringify(data));
}); });
await sleep(500); await sleep(500);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.windowstagelifecycle_xts", bundleName: "com.example.windowstagelifecycle_xts",
abilityName: "Hap1MainAbility1" abilityName: "Hap1MainAbility1"
}, (error, data) => { }, (error, data) => {
...@@ -697,7 +696,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -697,7 +696,7 @@ export default function lifecycleTest(abilityContext) {
",data: " + JSON.stringify(data)); ",data: " + JSON.stringify(data));
}); });
await sleep(500); await sleep(500);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.windowstagelifecycle_xts", bundleName: "com.example.windowstagelifecycle_xts",
abilityName: "Hap1MainAbility1" abilityName: "Hap1MainAbility1"
}, (error, data) => { }, (error, data) => {
...@@ -737,7 +736,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -737,7 +736,7 @@ export default function lifecycleTest(abilityContext) {
console.log("------------Singlehap_WindowStageLifeCycleTest_1000 start-------------"); console.log("------------Singlehap_WindowStageLifeCycleTest_1000 start-------------");
TAG = "Singlehap_WindowStageLifeCycleTest_1000"; TAG = "Singlehap_WindowStageLifeCycleTest_1000";
listKeyTemp = []; listKeyTemp = [];
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.windowstagelifecycle_xts", bundleName: "com.example.windowstagelifecycle_xts",
abilityName: "MainAbility9" abilityName: "MainAbility9"
}, (error, data) => { }, (error, data) => {
...@@ -745,7 +744,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -745,7 +744,7 @@ export default function lifecycleTest(abilityContext) {
",data: " + JSON.stringify(data)); ",data: " + JSON.stringify(data));
}); });
await sleep(500); await sleep(500);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.windowstagelifecycle_xts", bundleName: "com.example.windowstagelifecycle_xts",
abilityName: "Hap1MainAbility2" abilityName: "Hap1MainAbility2"
}, (error, data) => { }, (error, data) => {
...@@ -753,7 +752,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -753,7 +752,7 @@ export default function lifecycleTest(abilityContext) {
",data: " + JSON.stringify(data)); ",data: " + JSON.stringify(data));
}); });
await sleep(500); await sleep(500);
abilityContext.startAbility({ globalThis.abilityContext.startAbility({
bundleName: "com.example.windowstagelifecycle_xts", bundleName: "com.example.windowstagelifecycle_xts",
abilityName: "Hap1MainAbility2" abilityName: "Hap1MainAbility2"
}, (error, data) => { }, (error, data) => {
...@@ -801,7 +800,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -801,7 +800,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility11", "abilityName": "MainAbility11",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -812,7 +811,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -812,7 +811,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -828,7 +827,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -828,7 +827,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility11", "abilityName": "MainAbility11",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -839,7 +838,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -839,7 +838,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -892,7 +891,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -892,7 +891,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility12", "abilityName": "MainAbility12",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -903,7 +902,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -903,7 +902,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -935,7 +934,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -935,7 +934,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility12", "abilityName": "MainAbility12",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -946,7 +945,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -946,7 +945,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -1002,7 +1001,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -1002,7 +1001,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility1", "abilityName": "MainAbility1",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -1013,7 +1012,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -1013,7 +1012,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility12", "abilityName": "MainAbility12",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -1024,7 +1023,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -1024,7 +1023,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str2) globalThis.globalThis.abilityContext.startAbility(str2)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -1077,7 +1076,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -1077,7 +1076,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility1", "abilityName": "MainAbility1",
} }
globalThis.abilityContext.startAbility(str) globalThis.globalThis.abilityContext.startAbility(str)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -1088,7 +1087,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -1088,7 +1087,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility12", "abilityName": "MainAbility12",
} }
globalThis.abilityContext.startAbility(str1) globalThis.globalThis.abilityContext.startAbility(str1)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
...@@ -1099,7 +1098,7 @@ export default function lifecycleTest(abilityContext) { ...@@ -1099,7 +1098,7 @@ export default function lifecycleTest(abilityContext) {
"bundleName": "com.example.windowstagelifecycle_xts", "bundleName": "com.example.windowstagelifecycle_xts",
"abilityName": "MainAbility2", "abilityName": "MainAbility2",
} }
globalThis.abilityContext.startAbility(str2) globalThis.globalThis.abilityContext.startAbility(str2)
.then((data) => { .then((data) => {
console.info(TAG + ' start successful. Data: ' + data); console.info(TAG + ' start successful. Data: ' + data);
}).catch((error) => { }).catch((error) => {
......
...@@ -14,6 +14,6 @@ ...@@ -14,6 +14,6 @@
*/ */
import LifeCycleTest from './LifeCycleTest' import LifeCycleTest from './LifeCycleTest'
export default function List(context) { export default function List() {
LifeCycleTest(context) LifeCycleTest()
} }
\ No newline at end of file
{ {
"src": [ "src": [
"pages/index", "MainAbility/pages/index",
"pages/index1", "MainAbility/pages/index1",
"pages/index2", "MainAbility/pages/index2",
"pages/index3", "MainAbility/pages/index3",
"pages/index4", "MainAbility/pages/index4",
"pages/index5", "MainAbility/pages/index5",
"pages/index6", "MainAbility/pages/index6",
"pages/index7", "MainAbility/pages/index7",
"pages/index8", "MainAbility/pages/index8",
"pages/index9", "MainAbility/pages/index9",
"pages/index10", "MainAbility/pages/index10",
"pages/index11", "MainAbility/pages/index11",
"pages/index12", "MainAbility/pages/index12",
"pages/indexh1a1", "MainAbility/pages/indexh1a1",
"pages/indexh1a2" "MainAbility/pages/indexh1a2"
] ]
} }
...@@ -22,7 +22,7 @@ ohos_js_hap_suite("WorkerContextTest") { ...@@ -22,7 +22,7 @@ ohos_js_hap_suite("WorkerContextTest") {
] ]
ets2abc = true ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b" certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "WorkerContextTest" hap_name = "ActsWorkerContextTest"
} }
ohos_app_scope("workercontexttest_app_profile") { ohos_app_scope("workercontexttest_app_profile") {
......
{ {
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "180000", "test-timeout": "180000",
"package": "com.example.workercontexttest", "bundle-name": "com.example.workercontexttest",
"shell-timeout": "600000" "module-name": "entry",
"shell-timeout": "600000",
"testcase-timeout": 70000
}, },
"kits": [ "kits": [
{ {
"test-file-name": [ "test-file-name": [
"WorkerContextTest.hap" "ActsWorkerContextTest.hap"
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
......
...@@ -32,7 +32,7 @@ export default class MainAbility extends Ability { ...@@ -32,7 +32,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.info(printLog1 + 'onWindowStageCreate') console.info(printLog1 + 'onWindowStageCreate')
windowStage.loadContent("pages/index", (err, data) => { windowStage.loadContent("MainAbility/pages/index", (err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err)); console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return; return;
......
...@@ -12,9 +12,10 @@ ...@@ -12,9 +12,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import file from '@system.file'; import router from '@ohos.router';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import list from '../test/ListTest' import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry @Entry
@Component @Component
...@@ -23,23 +24,12 @@ struct Index { ...@@ -23,23 +24,12 @@ struct Index {
aboutToAppear() { aboutToAppear() {
console.info("start run testcase!!!!") console.info("start run testcase!!!!")
const core = Core.getInstance() var abilityDelegator: any
const expectExtend = new ExpectExtend({ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
'id': 'extend' var abilityDelegatorArguments: any
}) abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
core.addService('expect', expectExtend) console.info('start run testcase!!!')
const reportExtend = new ReportExtend(file) Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
core.addService('report', reportExtend)
core.init()
globalThis.abilityWant.parameters.timeout = 20000;
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
configService.setConfig(globalThis.abilityWant.parameters)
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
list(globalThis.abilityContext)
core.execute()
} }
build() { build() {
......
/*
* Copyright (c) 2022 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 Ability from '@ohos.application.Ability'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 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 router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.workercontexttest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import workerTransmitTest from './WorkerTransmitTest.test' import workerTransmitTest from './WorkerTransmitTest.test'
export default function List(context) { export default function List() {
workerTransmitTest() workerTransmitTest()
} }
\ No newline at end of file
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
import worker from '@ohos.worker'
import worker from '@ohos.worker'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
var TAG = '' var TAG = ''
export default function WorkerTransmitTest() { export default function WorkerTransmitTest() {
describe('WorkerTransmitTest', function () { describe('WorkerTransmitTest', function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册