提交 7b99ec60 编写于 作者: C chengxingzhen

xts-新增用例

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 cb65769a
......@@ -18,6 +18,6 @@ import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.info("MyAbilityStageMonitor onCreate")
globalThis.abilityStageContext = this.context
globalThis.abilityStageContext = this.context;
}
}
\ No newline at end of file
......@@ -20,42 +20,42 @@ 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("ActsShellCommandControlTest MainAbility onCreate")
console.log("ActsShellCommandControlTest MainAbility onCreate");
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
globalThis.abilityContext = this.context;
let abilityDelegator: any;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let abilityDelegatorArguments: any;
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
console.info('start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("ActsShellCommandControlTest MainAbility onDestroy")
console.log("ActsShellCommandControlTest MainAbility onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("ActsShellCommandControlTest MainAbility onWindowStageCreate")
console.log("ActsShellCommandControlTest MainAbility onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index/index", null)
console.log("ActsShellCommandControlTest MainAbility onWindowStageCreate finish")
windowStage.setUIContent(this.context, "pages/index/index", null);
console.log("ActsShellCommandControlTest MainAbility onWindowStageCreate finish");
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("ActsShellCommandControlTest MainAbility onWindowStageDestroy")
console.log("ActsShellCommandControlTest MainAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("ActsShellCommandControlTest MainAbility onForeground")
console.log("ActsShellCommandControlTest MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("ActsShellCommandControlTest MainAbility onBackground")
console.log("ActsShellCommandControlTest MainAbility onBackground");
}
};
\ No newline at end of file
......@@ -16,8 +16,8 @@
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
let abilityDelegator = undefined
let abilityDelegatorArguments = undefined
let abilityDelegator = undefined;
let abilityDelegatorArguments = undefined;
function translateParamsToString(parameters) {
const keySet = new Set([
......@@ -28,10 +28,10 @@ function translateParamsToString(parameters) {
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
targetParams = `${targetParams} ${key} ${parameters[key]}`;
}
}
return targetParams.trim()
return targetParams.trim();
}
async function onAbilityCreateCallback() {
......@@ -39,7 +39,7 @@ async function onAbilityCreateCallback() {
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
console.info("addAbilityMonitorCallback : " + JSON.stringify(err));
}
export default class OpenHarmonyTestRunner implements TestRunner {
......@@ -47,29 +47,29 @@ export default class OpenHarmonyTestRunner implements TestRunner {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
console.info("OpenHarmonyTestRunner OnPrepare ");
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
console.log('OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
let cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
let cmd = 'aa start -d 0 -a 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')
console.info('OpenHarmonyTestRunner onRun end');
}
};
\ No newline at end of file
......@@ -27,14 +27,14 @@ export default function shellCommandControlTest() {
*/
it('Acts_Ability_ShellCommandControl__0100', 0, async function (done) {
TAG = 'Acts_Ability_ShellCommandControl__0100';
console.log(`${TAG} --- start`)
console.log(`${TAG} --- start`);
let cmd = 'aa help'
globalThis.abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.log(`${TAG} stdResult = ${data.stdResult}`)
console.log(`${TAG} stdResult = ${JSON.stringify(err)}`)
console.log(`${TAG} stdResult = ${data.stdResult}`);
console.log(`${TAG} stdResult = ${JSON.stringify(err)}`);
expect(data.exitCode).assertEqual(0);
console.log(`${TAG} --- end`)
done()
console.log(`${TAG} --- end`);
done();
})
})
......@@ -46,16 +46,15 @@ export default function shellCommandControlTest() {
*/
it('Acts_Ability_ShellCommandControl__0200', 0, async function (done) {
TAG = 'Acts_Ability_ShellCommandControl__0200';
console.log(`${TAG} --- start`)
console.log(`${TAG} --- start`);
let cmd = 'ls -l';
globalThis.abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.log(`${TAG} stdResult = ${data.stdResult}`)
console.log(`${TAG} stdResult = ${JSON.stringify(err)}`)
console.log(`${TAG} stdResult = ${data.stdResult}`);
console.log(`${TAG} stdResult = ${JSON.stringify(err)}`);
expect(data.exitCode).assertEqual(-1);
console.log(`${TAG} --- end`)
done()
console.log(`${TAG} --- end`);
done();
})
})
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册