提交 de446d08 编写于 作者: J jiyong_sd

Adapt to the new framework

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