提交 4ee8c884 编写于 作者: J jiyong_sd

Adapt to the new framework

Signed-off-by: Njiyong_sd <jiyong@huawei.com>
Change-Id: I0a3b8d5df45128d0032562993a8f4838a42adff4
上级 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() {
......
......@@ -107,7 +107,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() {
......
......@@ -93,7 +93,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() {
......
......@@ -121,7 +121,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() {
......
......@@ -86,7 +86,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() {
......
......@@ -92,7 +92,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() {
......
......@@ -86,7 +86,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_LifecycleTest_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) => {
......@@ -123,7 +122,7 @@ export default function abilityTest(abilityContext) {
TAG = "Multihap_LifecycleTest_002";
listKeyTemp = [];
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4"
}, (error, data) => {
......@@ -133,7 +132,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility4"
}, (error, data) => {
......@@ -143,7 +142,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility4"
}, (error, data) => {
......@@ -187,7 +186,7 @@ export default function abilityTest(abilityContext) {
TAG = "Multihap_LifecycleTest_003";
listKeyTemp = [];
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4"
}, (error, data) => {
......@@ -197,7 +196,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility5"
}, (error, data) => {
......@@ -207,7 +206,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility5"
}, (error, data) => {
......@@ -259,7 +258,7 @@ export default function abilityTest(abilityContext) {
listKeyTemp = [];
listKeyTemp1 = [];
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4"
}, (error, data) => {
......@@ -269,7 +268,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility6"
}, (error, data) => {
......@@ -279,7 +278,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap3MainAbility2"
}, (error, data) => {
......@@ -336,7 +335,7 @@ export default function abilityTest(abilityContext) {
listKeyTemp = [];
listKeyTemp1 = [];
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4"
}, (error, data) => {
......@@ -346,7 +345,7 @@ export default function abilityTest(abilityContext) {
await sleep(500);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility6"
}, (error, data) => {
......@@ -356,7 +355,7 @@ export default function abilityTest(abilityContext) {
await sleep(500);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility7"
}, (error, data) => {
......@@ -416,7 +415,7 @@ export default function abilityTest(abilityContext) {
var firstCallbackId;
var secondCallbackId;
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility7"
}, (error, data) => {
......@@ -426,7 +425,7 @@ export default function abilityTest(abilityContext) {
await sleep(500);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility8"
}, (error, data) => {
......@@ -441,7 +440,7 @@ export default function abilityTest(abilityContext) {
await sleep(500);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility7"
}, (error, data) => {
......@@ -451,7 +450,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility8"
}, (error, data) => {
......@@ -498,7 +497,7 @@ export default function abilityTest(abilityContext) {
var callBackId2;
var flag;
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility6"
}, (error, data) => {
......@@ -507,7 +506,7 @@ export default function abilityTest(abilityContext) {
});
setTimeout(function () {
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility9"
}, (error, data) => {
......@@ -548,7 +547,7 @@ export default function abilityTest(abilityContext) {
setTimeout(function () {
if (flag == 0) {
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility6"
}, (error, data) => {
......@@ -557,7 +556,7 @@ export default function abilityTest(abilityContext) {
});
setTimeout(function () {
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility9"
}, (error, data) => {
......@@ -612,7 +611,7 @@ export default function abilityTest(abilityContext) {
TAG = "Multihap_LifecycleTest_008";
listKeyTemp = [];
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4"
}, (error, data) => {
......@@ -622,7 +621,7 @@ export default function abilityTest(abilityContext) {
await sleep(500);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility6"
}, (error, data) => {
......@@ -675,7 +674,7 @@ export default function abilityTest(abilityContext) {
listKeyTemp = [];
listKeyTemp1 = [];
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility4",
}, (error, data) => {
......@@ -684,7 +683,7 @@ export default function abilityTest(abilityContext) {
})
await sleep(1000)
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility10",
}, (error, data) => {
......@@ -693,7 +692,7 @@ export default function abilityTest(abilityContext) {
})
await sleep(1000)
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap3MainAbility3",
}, (error, data) => {
......@@ -702,7 +701,7 @@ export default function abilityTest(abilityContext) {
})
await sleep(1000)
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility10",
}, (error, data) => {
......@@ -711,7 +710,7 @@ export default function abilityTest(abilityContext) {
})
await sleep(1000)
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap3MainAbility3",
}, (error, data) => {
......@@ -721,7 +720,7 @@ export default function abilityTest(abilityContext) {
await sleep(1000)
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap2MainAbility10",
}, (error, data) => {
......@@ -730,7 +729,7 @@ export default function abilityTest(abilityContext) {
})
await sleep(1000)
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap3MainAbility3",
}, (error, data) => {
......@@ -791,7 +790,7 @@ export default function abilityTest(abilityContext) {
TAG = "Multihap_LifecycleTest_011";
listKeyTemp = [];
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "MainAbility2",
}, (error, data) => {
......@@ -801,7 +800,7 @@ export default function abilityTest(abilityContext) {
await sleep(500);
abilityContext.startAbility({
globalThis.abilityContext.startAbility({
bundleName: "com.example.lifecycletest",
abilityName: "Hap4MainAbility1",
}, (error, data) => {
......
......@@ -14,8 +14,8 @@
*/
import lifecycleTest from './LifecycleTest'
export default function List(context) {
export default function List() {
lifecycleTest(context)
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.lifecycle_xts",
"shell-timeout": "600000"
"bundle-name": "com.example.lifecycle_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() {
......
......@@ -118,7 +118,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() {
......
......@@ -103,7 +103,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() {
......
......@@ -97,7 +97,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() {
......
......@@ -96,7 +96,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() {
......
......@@ -119,7 +119,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() {
......
......@@ -119,7 +119,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.lifecycle_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
......@@ -15,7 +15,7 @@
import LifeCycleTest from './LifeCycleTest'
import Test from './Test'
export default function List(context) {
LifeCycleTest(context)
export default function List() {
LifeCycleTest()
// Test(context)
}
\ 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"
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册