Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7b99ec60
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7b99ec60
编写于
1月 12, 2023
作者:
C
chengxingzhen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xts-新增用例
Signed-off-by:
N
chengxingzhen
<
chengxingzhen@huawei.com
>
上级
cb65769a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
43 deletion
+42
-43
ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/ets/Application/MyAbilityStage.ts
...troltest/entry/src/main/ets/Application/MyAbilityStage.ts
+1
-1
ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/ets/MainAbility/MainAbility.ts
...controltest/entry/src/main/ets/MainAbility/MainAbility.ts
+15
-15
ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+16
-16
ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/ets/test/ShellCommandControl.test.ets
...test/entry/src/main/ets/test/ShellCommandControl.test.ets
+10
-11
未找到文件。
ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/ets/Application/MyAbilityStage.ts
浏览文件 @
7b99ec60
...
...
@@ -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
ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/ets/MainAbility/MainAbility.ts
浏览文件 @
7b99ec60
...
...
@@ -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
ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
浏览文件 @
7b99ec60
...
...
@@ -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
ability/ability_runtime/actsshellcommandfunctionalitytest/actsshellcommandcontroltest/entry/src/main/ets/test/ShellCommandControl.test.ets
浏览文件 @
7b99ec60
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录