提交 b6fea1bd 编写于 作者: J jiyong_sd

Adapt to the new framework

Signed-off-by: Njiyong_sd <jiyong@huawei.com>
Change-Id: I2ab725e9d4e9ad0ebe9a0337dd41cc3e0913ded0
上级 03fe0783
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "300000",
"package": "com.example.systemcalltest",
"shell-timeout": "60000"
"bundle-name": "com.example.systemcalltest",
"module-name": "com.example.systemcalltest",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
......
......@@ -71,7 +71,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability
console.log("SystemCallTest MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
......
......@@ -12,10 +12,9 @@
* 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 testsuite from "../../test/List.test.ets"
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry
......@@ -24,22 +23,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()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 10000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(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.setUIContent(this.context, 'TestAbility/pages/index', null)
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'
])
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.systemcalltest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
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
......@@ -12,7 +12,7 @@
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
import missionManager from '@ohos.application.missionManager'
import appManager from '@ohos.application.appManager'
......@@ -129,7 +129,7 @@ function clearDepProcess(bundleNames, callback, undoneCallBack) {
}
}
export default function abilityTest(abilityContext) {
export default function abilityTest() {
describe('ActsAbilityTest', function () {
beforeEach(async (done) => {
......@@ -195,7 +195,7 @@ export default function abilityTest(abilityContext) {
subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, subscribeCallBack);
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -224,7 +224,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -280,7 +280,7 @@ export default function abilityTest(abilityContext) {
subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, subscribeCallBack);
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAMainAbilityName,
});
......@@ -310,7 +310,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAMainAbilityName,
});
......@@ -369,12 +369,12 @@ export default function abilityTest(abilityContext) {
subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, subscribeCallBack);
caller1 = await globalThis.abilityContext.startAbilityByCall({
caller1 = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAMainAbilityName,
});
caller2 = await globalThis.abilityContext.startAbilityByCall({
caller2 = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
});
......@@ -405,11 +405,11 @@ export default function abilityTest(abilityContext) {
done();
}
let caller1 = await globalThis.abilityContext.startAbilityByCall({
let caller1 = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAMainAbilityName,
});
let caller2 = await globalThis.abilityContext.startAbilityByCall({
let caller2 = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
});
......@@ -457,7 +457,7 @@ export default function abilityTest(abilityContext) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0700 releaseCallBack1' + data);
setTimeout(() => {
globalThis.abilityContext.startAbilityByCall({
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
}).then(data => {
......@@ -488,7 +488,7 @@ export default function abilityTest(abilityContext) {
subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, subscribeCallBack);
globalThis.abilityContext.startAbilityByCall({
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
}).then(data => {
......@@ -519,7 +519,7 @@ export default function abilityTest(abilityContext) {
expect(data).assertEqual('release');
console.log('ACTS_CommonComponent_Call_0800 releaseCallBack' + data);
setTimeout(() => {
globalThis.abilityContext.startAbilityByCall({
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
}).then(data => {
......@@ -543,7 +543,7 @@ export default function abilityTest(abilityContext) {
}, 100);
}
globalThis.abilityContext.startAbilityByCall({
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeASecondAbilityName,
}).then(data => {
......@@ -588,7 +588,7 @@ export default function abilityTest(abilityContext) {
subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, subscribeCallBack);
caller = await globalThis.abilityContext.startAbilityByCall({
caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: thirdAppABundleName,
abilityName: thirdAppAMainAbilityName,
});
......@@ -619,7 +619,7 @@ export default function abilityTest(abilityContext) {
done();
}
caller = await globalThis.abilityContext.startAbilityByCall({
caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: thirdAppABundleName,
abilityName: thirdAppAMainAbilityName,
});
......@@ -652,7 +652,7 @@ export default function abilityTest(abilityContext) {
var exceptionFlag = false;
try {
caller = await globalThis.abilityContext.startAbilityByCall({
caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: systemAppCalleeABundleName,
abilityName: systemAppCalleeAThirdAbilityName,
});
......@@ -712,7 +712,7 @@ export default function abilityTest(abilityContext) {
subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, subscribeCallBack);
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -768,7 +768,7 @@ export default function abilityTest(abilityContext) {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
}
let caller = await globalThis.abilityContext.startAbilityByCall(want);
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall(want);
if (typeof caller !== "object" || caller == null) {
console.log('ACTS_CommonComponent_Call_2000 startAbilityByCall fail');
expect().assertFail();
......@@ -803,7 +803,7 @@ export default function abilityTest(abilityContext) {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
}
let caller = await globalThis.abilityContext.startAbilityByCall(want);
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall(want);
if (typeof caller !== "object" || caller == null) {
console.log('ACTS_CommonComponent_Call_2300 startAbilityByCall fail');
expect().assertFail();
......@@ -849,7 +849,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -893,7 +893,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -924,7 +924,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -955,7 +955,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -986,7 +986,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -1017,7 +1017,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -1048,7 +1048,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -1217,7 +1217,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -1249,7 +1249,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -1281,7 +1281,7 @@ export default function abilityTest(abilityContext) {
done();
}
let caller = await globalThis.abilityContext.startAbilityByCall({
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
});
......@@ -1313,7 +1313,7 @@ export default function abilityTest(abilityContext) {
done();
}
globalThis.abilityContext.startAbilityByCall({
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
}).then((data) => {
......@@ -1346,7 +1346,7 @@ export default function abilityTest(abilityContext) {
done();
}
globalThis.abilityContext.startAbilityByCall({
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
}).then((data) => {
......@@ -1379,7 +1379,7 @@ export default function abilityTest(abilityContext) {
done();
}
globalThis.abilityContext.startAbilityByCall({
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
}).then((data) => {
......@@ -1479,7 +1479,7 @@ export default function abilityTest(abilityContext) {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
}
let caller = await globalThis.abilityContext.startAbilityByCall(want);
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall(want);
if (typeof caller !== "object" || caller == null) {
console.log('ACTS_CommonComponent_Call_4800 startAbilityByCall fail');
expect().assertFail();
......@@ -1534,7 +1534,7 @@ export default function abilityTest(abilityContext) {
})
}
globalThis.abilityContext.startAbilityByCall({
globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: sysABundleName,
abilityName: sysASecondAbilityName,
}).then((data) => {
......@@ -1635,7 +1635,7 @@ export default function abilityTest(abilityContext) {
let exceptionFlag = false;
try {
caller = await globalThis.abilityContext.startAbilityByCall(null);
caller = await globalThis.globalThis.abilityContext.startAbilityByCall(null);
console.log('ACTS_CommonComponent_Call_5200 startAbilityByCall' + JSON.stringify(caller))
} catch(err) {
console.log('ACTS_CommonComponent_Call_5200 exception' + err);
......@@ -1658,7 +1658,7 @@ export default function abilityTest(abilityContext) {
let exceptionFlag = false;
try {
caller = await globalThis.abilityContext.startAbilityByCall({
caller = await globalThis.globalThis.abilityContext.startAbilityByCall({
bundleName: "",
abilityName: "",
});
......@@ -1684,7 +1684,7 @@ export default function abilityTest(abilityContext) {
let exceptionFlag = false;
try {
caller = await globalThis.abilityContext.startAbilityByCall(undefined);
caller = await globalThis.globalThis.abilityContext.startAbilityByCall(undefined);
console.log('ACTS_CommonComponent_Call_5400 startAbilityByCall' + JSON.stringify(caller))
} catch(err) {
console.log('ACTS_CommonComponent_Call_5400 exception' + err);
......@@ -1710,7 +1710,7 @@ export default function abilityTest(abilityContext) {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
}
let caller = await globalThis.abilityContext.startAbilityByCall(want);
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall(want);
if (typeof caller !== "object" || caller == null) {
console.log('ACTS_CommonComponent_Call_5700 startAbilityByCall fail');
expect().assertFail();
......@@ -1757,7 +1757,7 @@ export default function abilityTest(abilityContext) {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
}
let caller = await globalThis.abilityContext.startAbilityByCall(want);
let caller = await globalThis.globalThis.abilityContext.startAbilityByCall(want);
if (typeof caller !== "object" || caller == null) {
console.log('ACTS_CommonComponent_Call_5800 startAbilityByCall fail');
expect().assertFail();
......@@ -1773,7 +1773,7 @@ export default function abilityTest(abilityContext) {
}
await sleep(1000);
await globalThis.abilityContext.startAbility(want, startAbilityCallback);
await globalThis.globalThis.abilityContext.startAbility(want, startAbilityCallback);
async function releaseCallback(data) {
console.log('ACTS_CommonComponent_Call_5800 releaseCallBack:' + data);
......
......@@ -15,8 +15,8 @@
import abilityTest from './Ability.test.ets'
export default function testsuite(context) {
export default function testsuite() {
abilityTest(context)
abilityTest()
}
\ No newline at end of file
{
"src": [
"pages/index/index",
"pages/second/second"
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "600000",
"package": "com.example.myapplication",
"shell-timeout": "600000"
"bundle-name": "com.example.myapplication",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
......
/*
* 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'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
......@@ -18,7 +41,7 @@ export default class MainAbility extends Ability {
//globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
......
......@@ -12,10 +12,7 @@
* 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 testsuite from "../../test/List.test"
import router from '@ohos.router';
@Entry
@Component
......@@ -24,22 +21,6 @@ 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();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters));
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters);
testsuite(globalThis.abilityContext);
core.execute();
}
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.myapplication.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
......@@ -12,7 +12,7 @@
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
const passStr = 'pass';
......@@ -28,7 +28,7 @@ function publishCaseExecute(caseName: string) {
});
}
export default function abilityTest(abilityContext) {
export default function abilityTest() {
describe('AccessibilityElementTest', function () {
let subScriber = undefined;
let isConnect = false;
......@@ -48,7 +48,7 @@ export default function abilityTest(abilityContext) {
}
});
await abilityContext.startAbility({
await globalThis.abilityContext.startAbility({
deviceId: '',
bundleName: 'com.example.acetest',
abilityName: 'MainAbility',
......
......@@ -14,6 +14,6 @@
*/
import abilityTest from './AccessibilityElement.test.ets'
export default function testsuite(abilityContext) {
abilityTest(abilityContext)
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"src": [
"pages/index/index"
"MainAbility/pages/index/index"
]
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccessibilityEventTest") {
hap_profile = "entry/src/main/module.json"
hap_profile = "./entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":accessibilityevent_js_assets",
......@@ -31,11 +31,11 @@ ohos_app_scope("accessibilityevent_app_profile") {
}
ohos_js_assets("accessibilityevent_js_assets") {
source_dir = "entry/src/main/ets"
source_dir = "./entry/src/main/ets"
}
ohos_resources("accessibilityevent_resources") {
sources = [ "entry/src/main/resources" ]
sources = [ "./entry/src/main/resources" ]
deps = [ ":accessibilityevent_app_profile" ]
hap_profile = "entry/src/main/module.json"
hap_profile = "./entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "180000",
"package": "com.example.myapplication",
"shell-timeout": "600000"
"bundle-name": "com.example.myapplication",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
......
/*
* 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'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
......@@ -18,7 +41,7 @@ export default class MainAbility extends Ability {
//globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
......
......@@ -12,10 +12,7 @@
* 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 testsuite from "../../test/List.test"
import router from '@ohos.router';
@Entry
@Component
......@@ -24,22 +21,6 @@ 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();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters));
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters);
testsuite(globalThis.abilityContext);
core.execute();
}
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.myapplication.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
......@@ -12,11 +12,11 @@
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import accessibility from '@ohos.accessibility'
import commonEvent from '@ohos.commonEvent'
export default function abilityTest(abilityContext) {
export default function abilityTest() {
let targetBundleName = 'com.example.myapplication';
let subScriber = undefined;
let isConnected: boolean = false;
......@@ -38,7 +38,7 @@ export default function abilityTest(abilityContext) {
});
setTimeout(async () => {
await abilityContext.startAbility({
await globalThis.abilityContext.startAbility({
deviceId: "",
bundleName: "com.example.acetest",
abilityName: "MainAbility",
......
......@@ -14,6 +14,6 @@
*/
import abilityTest from './AccessibilityEventTest.test.ets'
export default function testsuite(abilityContext) {
abilityTest(abilityContext)
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"src": [
"pages/index/index"
"MainAbility/pages/index/index"
]
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccessibilityExtensionTest") {
hap_profile = "entry/src/main/module.json"
hap_profile = "./entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":accessibilityextension_js_assets",
......@@ -31,11 +31,11 @@ ohos_app_scope("accessibilityextension_app_profile") {
}
ohos_js_assets("accessibilityextension_js_assets") {
source_dir = "entry/src/main/ets"
source_dir = "./entry/src/main/ets"
}
ohos_resources("accessibilityextension_resources") {
sources = [ "entry/src/main/resources" ]
sources = [ "./entry/src/main/resources" ]
deps = [ ":accessibilityextension_app_profile" ]
hap_profile = "entry/src/main/module.json"
hap_profile = "./entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.example.myapplication",
"shell-timeout": "60000"
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.example.myapplication",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
......
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
......@@ -18,7 +27,7 @@ export default class MainAbility extends Ability {
//globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
......
......@@ -12,10 +12,7 @@
* 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 testsuite from "../../test/List.test"
import router from '@ohos.router';
@Entry
@Component
......@@ -24,22 +21,6 @@ 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();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters));
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters);
testsuite(globalThis.abilityContext);
core.execute();
}
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.myapplication.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
......@@ -12,10 +12,10 @@
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
export default function abilityTest(abilityContext) {
export default function abilityTest() {
let isCalled: boolean = false;
let subScriber = undefined;
......@@ -57,7 +57,7 @@ export default function abilityTest(abilityContext) {
*/
it('AccessibilityExtensionTest_Connect_0100', 0, async function (done) {
console.info('AccessibilityExtensionTest_Connect_0100: start');
await abilityContext.startAbility({
await globalThis.abilityContext.startAbility({
deviceId: "",
bundleName: "com.example.acetest",
abilityName: "MainAbility",
......
......@@ -14,6 +14,6 @@
*/
import abilityTest from './AccessibilityExtension.test.ets'
export default function testsuite(abilityContext) {
abilityTest(abilityContext)
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"src": [
"pages/index/index"
"MainAbility/pages/index/index"
]
}
\ No newline at end of file
......@@ -9,12 +9,12 @@
# 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.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccessibilityExtensionContextTest") {
hap_profile = "entry/src/main/module.json"
hap_profile = "./entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":accessibilityextensioncontext_js_assets",
......@@ -31,11 +31,11 @@ ohos_app_scope("accessibilityextensioncontext_app_profile") {
}
ohos_js_assets("accessibilityextensioncontext_js_assets") {
source_dir = "entry/src/main/ets"
source_dir = "./entry/src/main/ets"
}
ohos_resources("accessibilityextensioncontext_resources") {
sources = [ "entry/src/main/resources" ]
sources = [ "./entry/src/main/resources" ]
deps = [ ":accessibilityextensioncontext_app_profile" ]
hap_profile = "entry/src/main/module.json"
hap_profile = "./entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "360000",
"package": "com.example.myapplication",
"shell-timeout": "360000"
"bundle-name": "com.example.myapplication",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
......
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
......@@ -18,7 +27,7 @@ export default class MainAbility extends Ability {
//globalThis.windowStage = windowStage
//globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
......
......@@ -14,8 +14,6 @@
*/
import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test"
@Entry
@Component
......@@ -24,22 +22,6 @@ 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();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters));
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters);
testsuite(globalThis.abilityContext);
core.execute();
}
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.myapplication.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
......@@ -12,7 +12,7 @@
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import commonEvent from '@ohos.commonEvent'
const passStr = 'pass';
......@@ -28,7 +28,7 @@ function publishCaseExecute(caseName: string) {
});
}
export default function abilityTest(abilityContext) {
export default function abilityTest() {
describe('AccessibilityExtensionContextTest', function () {
let subScriber = undefined;
let isConnect = false;
......@@ -48,7 +48,7 @@ export default function abilityTest(abilityContext) {
}
});
await abilityContext.startAbility({
await globalThis.abilityContext.startAbility({
deviceId: '',
bundleName: 'com.example.acetest',
abilityName: 'MainAbility',
......
......@@ -14,6 +14,6 @@
*/
import abilityTest from './AccessibilityExtensionContext.test.ets'
export default function testsuite(abilityContext) {
abilityTest(abilityContext)
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册