Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
9293e18e
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看板
提交
9293e18e
编写于
8月 10, 2022
作者:
C
chengxingzhen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
XTS测试套适配新框架
Signed-off-by:
N
chengxingzhen
<
chengxingzhen@huawei.com
>
上级
96573db5
变更
30
显示空白变更内容
内联
并排
Showing
30 changed file
with
781 addition
and
399 deletion
+781
-399
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/Test.json
...bilitymultiinstance/amsabilitymultiinstancetest/Test.json
+6
-4
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets
...ultiinstancetest/entry/src/main/ets/pages/index/index.ets
+9
-22
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets
...ultiinstancetest/entry/src/main/ets/test/Ability.test.ets
+1
-2
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/List.test.ets
...tymultiinstancetest/entry/src/main/ets/test/List.test.ets
+2
-2
ability/ability_runtime/actsabilitydelegatorcase/BUILD.gn
ability/ability_runtime/actsabilitydelegatorcase/BUILD.gn
+4
-2
ability/ability_runtime/actsabilitydelegatorcase/Test.json
ability/ability_runtime/actsabilitydelegatorcase/Test.json
+6
-4
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/config.json
...ntime/actsabilitydelegatorcase/entry/src/main/config.json
+30
-1
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/MainAbility/app.js
...abilitydelegatorcase/entry/src/main/js/MainAbility/app.js
+0
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/MainAbility/i18n/en-US.json
...legatorcase/entry/src/main/js/MainAbility/i18n/en-US.json
+0
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/MainAbility/i18n/zh-CN.json
...legatorcase/entry/src/main/js/MainAbility/i18n/zh-CN.json
+0
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/MainAbility/pages/index/index.css
...rcase/entry/src/main/js/MainAbility/pages/index/index.css
+0
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/MainAbility/pages/index/index.hml
...rcase/entry/src/main/js/MainAbility/pages/index/index.hml
+0
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/MainAbility/pages/index/index.js
...orcase/entry/src/main/js/MainAbility/pages/index/index.js
+0
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/app.js
...abilitydelegatorcase/entry/src/main/js/TestAbility/app.js
+31
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/i18n/en-US.json
...legatorcase/entry/src/main/js/TestAbility/i18n/en-US.json
+8
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/i18n/zh-CN.json
...legatorcase/entry/src/main/js/TestAbility/i18n/zh-CN.json
+8
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.css
...rcase/entry/src/main/js/TestAbility/pages/index/index.css
+50
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.hml
...rcase/entry/src/main/js/TestAbility/pages/index/index.hml
+21
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.js
...orcase/entry/src/main/js/TestAbility/pages/index/index.js
+26
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestRunner/OpenHarmonyTestRunner.js
...ase/entry/src/main/js/TestRunner/OpenHarmonyTestRunner.js
+59
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/test/ActsAbilityDelegatorCaseTest.test.js
...try/src/main/js/test/ActsAbilityDelegatorCaseTest.test.js
+333
-333
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/test/List.test.js
...sabilitydelegatorcase/entry/src/main/js/test/List.test.js
+5
-1
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/resources/base/element/string.json
...torcase/entry/src/main/resources/base/element/string.json
+8
-0
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/resources/base/media/icon.png
...elegatorcase/entry/src/main/resources/base/media/icon.png
+0
-0
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/Test.json
...untime/amsdisplayIdtest/actsamsstartabilitytest/Test.json
+6
-4
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/index/index.ets
...startabilitytest/entry/src/main/ets/pages/index/index.ets
+9
-21
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/Ability.test.ets
...startabilitytest/entry/src/main/ets/test/Ability.test.ets
+1
-1
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/List.test.ets
...amsstartabilitytest/entry/src/main/ets/test/List.test.ets
+2
-2
未找到文件。
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/Test.json
浏览文件 @
9293e18e
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"500000"
,
"package"
:
"com.example.abilitymultiinstance"
,
"shell-timeout"
:
"300000"
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"600000"
,
"bundle-name"
:
"com.example.abilitymultiinstance"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
"30000"
},
"kits"
:
[
{
...
...
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
9293e18e
/*
* 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.abilitymultiinstance.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
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets
浏览文件 @
9293e18e
...
...
@@ -12,34 +12,21 @@
* 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
@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()
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()
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
...
...
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
9293e18e
...
...
@@ -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'
let
subscriberInfoMultiInstance
=
{
...
...
@@ -100,7 +100,6 @@ export default function abilityTest(abilityContext) {
console
.
log
(
'ACTS_AbilityMultiInstance_Single_0100====<begin'
);
let
subscriber
;
let
id
;
let
result
;
let
checkEventResults
=
[
"AppA:onCreateonForegroundonAcceptWantCalledId1"
,
"AppB:onCreateonForeground"
,
"AppA:onForegroundonAcceptWantCalledId1"
];
let
checkIndex
=
0
;
...
...
ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/List.test.ets
浏览文件 @
9293e18e
...
...
@@ -15,8 +15,8 @@
import abilityTest from './Ability.test.ets'
export default function testsuite(
context
) {
export default function testsuite() {
abilityTest(
c
ontext)
abilityTest(
globalThis.abilityC
ontext)
}
\ No newline at end of file
ability/ability_runtime/actsabilitydelegatorcase/BUILD.gn
浏览文件 @
9293e18e
...
...
@@ -25,9 +25,11 @@ ohos_js_hap_suite("ActsAbilityDelegatorCaseTest") {
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
js2abc = true
hap_profile = "./entry/src/main/config.json"
source_dir = "./entry/src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/
js/
resources" ]
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
ability/ability_runtime/actsabilitydelegatorcase/Test.json
浏览文件 @
9293e18e
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"60000"
,
"package"
:
"com.amsst.actsabilitydelegatorcasetest"
,
"shell-timeout"
:
"60000"
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"300000"
,
"bundle-name"
:
"com.amsst.actsabilitydelegatorcasetest"
,
"package-name"
:
"com.amsst.actsabilitydelegatorcasetest"
,
"shell-timeout"
:
"300000"
,
"testcase-timeout"
:
"30000"
},
"kits"
:
[
{
...
...
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/config.json
浏览文件 @
9293e18e
...
...
@@ -37,12 +37,27 @@
}
],
"name"
:
"com.amsst.actsabilitydelegatorcasetest.MainAbility"
,
"srcLanguage"
:
"js"
,
"srcPath"
:
"MainAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:mainability_description"
,
"label"
:
"$string:app_name"
,
"type"
:
"page"
,
"launchType"
:
"standard"
,
"visible"
:
true
},
{
"orientation"
:
"unspecified"
,
"formsEnabled"
:
false
,
"name"
:
".TestAbility"
,
"srcLanguage"
:
"js"
,
"srcPath"
:
"TestAbility"
,
"icon"
:
"$media:icon"
,
"description"
:
"$string:TestAbility_desc"
,
"label"
:
"$string:TestAbility_label"
,
"type"
:
"page"
,
"visible"
:
true
,
"launchType"
:
"singleton"
}
],
"reqPermissions"
:
[
...
...
@@ -85,7 +100,21 @@
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
},
{
"pages"
:
[
"pages/index/index"
],
"name"
:
".TestAbility"
,
"window"
:
{
"designWidth"
:
720
,
"autoDesignWidth"
:
false
}
}
],
"testRunner"
:
{
"name"
:
"OpenHarmonyTestRunner"
,
"srcPath"
:
"TestRunner"
}
]
}
}
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
default
/app.js
→
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
MainAbility
/app.js
浏览文件 @
9293e18e
文件已移动
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
default
/i18n/en-US.json
→
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
MainAbility
/i18n/en-US.json
浏览文件 @
9293e18e
文件已移动
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
default
/i18n/zh-CN.json
→
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
MainAbility
/i18n/zh-CN.json
浏览文件 @
9293e18e
文件已移动
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
default
/pages/index/index.css
→
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
MainAbility
/pages/index/index.css
浏览文件 @
9293e18e
文件已移动
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
default
/pages/index/index.hml
→
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
MainAbility
/pages/index/index.hml
浏览文件 @
9293e18e
文件已移动
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
default
/pages/index/index.js
→
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/
MainAbility
/pages/index/index.js
浏览文件 @
9293e18e
文件已移动
ability/ability_runtime/a
bilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/second.et
s
→
ability/ability_runtime/a
ctsabilitydelegatorcase/entry/src/main/js/TestAbility/app.j
s
浏览文件 @
9293e18e
...
...
@@ -12,32 +12,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
import
{
Hypium
}
from
'
@ohos/hypium
'
import
testsuite
from
'
../test/List.test
'
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
export
default
{
onCreate
()
{
console
.
info
(
'
TestApplication onCreate
'
)
var
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
console
.
info
(
'
start run testcase!!!
'
)
Hypium
.
hypiumTest
(
abilityDelegator
,
abilityDelegatorArguments
,
testsuite
)
},
onDestroy
()
{
console
.
info
(
"
TestApplication onDestroy
"
);
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
};
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/i18n/en-US.json
0 → 100644
浏览文件 @
9293e18e
{
"strings"
:
{
"hello"
:
"Hello"
,
"world"
:
"World"
},
"Files"
:
{
}
}
\ No newline at end of file
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/i18n/zh-CN.json
0 → 100644
浏览文件 @
9293e18e
{
"strings"
:
{
"hello"
:
"您好"
,
"world"
:
"世界"
},
"Files"
:
{
}
}
\ No newline at end of file
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.css
0 → 100644
浏览文件 @
9293e18e
/*
* Copyright (c) 2021 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.
*/
.container
{
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
left
:
0px
;
top
:
0px
;
width
:
100%
;
height
:
100%
;
}
.title
{
font-size
:
60px
;
text-align
:
center
;
width
:
100%
;
height
:
40%
;
margin
:
10px
;
}
.btn
{
width
:
50%
;
height
:
100px
;
font-size
:
40px
;
}
@media
screen
and
(
device-type
:
phone
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
60px
;
}
}
@media
screen
and
(
device-type
:
tablet
)
and
(
orientation
:
landscape
)
{
.title
{
font-size
:
100px
;
}
}
\ No newline at end of file
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.hml
0 → 100644
浏览文件 @
9293e18e
<!--
Copyright (c) 2021 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.
-->
<div class="container" onswipe="touchMove">
<text class="title">
{{ $t('strings.hello') }} {{title}}
</text>
<input class="btn" type="button" value="{{ $t('strings.next') }}" onclick="onclick"></input>
</div>
ability/ability_runtime/a
bilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index.et
s
→
ability/ability_runtime/a
ctsabilitydelegatorcase/entry/src/main/js/TestAbility/pages/index/index.j
s
浏览文件 @
9293e18e
...
...
@@ -12,53 +12,15 @@
* 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"
@Entry
@Component
struct Index {
export
default
{
data
:
{
title
:
""
},
onInit
()
{
this
.
title
=
this
.
$t
(
'
strings.world
'
);
}
}
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()
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Test App')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/TestRunner/OpenHarmonyTestRunner.js
0 → 100644
浏览文件 @
9293e18e
/*
* 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
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
function
translateParamsToString
(
parameters
)
{
const
keySet
=
new
Set
([
'
-s class
'
,
'
-s notClass
'
,
'
-s suite
'
,
'
-s itName
'
,
'
-s level
'
,
'
-s testType
'
,
'
-s size
'
,
'
-s timeout
'
,
'
-s package
'
,
'
-s dryRun
'
])
let
targetParams
=
''
;
for
(
const
key
in
parameters
)
{
if
(
keySet
.
has
(
key
))
{
targetParams
+=
'
'
+
key
+
'
'
+
parameters
[
key
]
}
}
return
targetParams
.
trim
()
}
export
default
{
onPrepare
()
{
console
.
info
(
'
OpenHarmonyTestRunner OnPrepare
'
)
},
onRun
()
{
console
.
log
(
'
OpenHarmonyTestRunner onRun run
'
)
var
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
var
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
testAbilityName
=
abilityDelegatorArguments
.
parameters
[
'
-p
'
]
+
'
.TestAbility
'
var
cmd
=
'
aa start -d 0 -a
'
+
testAbilityName
+
'
-b
'
+
abilityDelegatorArguments
.
bundleName
cmd
+=
'
'
+
translateParamsToString
(
abilityDelegatorArguments
.
parameters
)
var
debug
=
abilityDelegatorArguments
.
parameters
[
"
-D
"
]
console
.
info
(
'
debug value :
'
+
debug
)
if
(
debug
==
'
true
'
)
{
cmd
+=
'
-D
'
}
console
.
info
(
'
cmd :
'
+
cmd
)
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
,
data
)
=>
{
console
.
info
(
'
executeShellCommand : err :
'
+
JSON
.
stringify
(
err
));
console
.
info
(
'
executeShellCommand : data :
'
+
data
.
stdResult
);
console
.
info
(
'
executeShellCommand : data :
'
+
data
.
exitCode
);
})
}
};
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/test/ActsAbilityDelegatorCaseTest.test.js
浏览文件 @
9293e18e
...
...
@@ -12,12 +12,15 @@
* 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
featureAbility
from
'
@ohos.ability.featureAbility
'
import
abilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
import
bundle
from
'
@ohos.bundle
'
describe
(
'
ActsStServiceAbilityTest
'
,
function
()
{
let
result
;
export
default
function
actsStServiceAbilityTest
()
{
describe
(
'
ActsStServiceAbilityTest
'
,
function
()
{
let
gSetTimeout
=
1000
beforeAll
(
async
(
done
)
=>
{
console
.
debug
(
'
= ACTS_AbeforeAll 1812 ====<begin
'
);
...
...
@@ -57,17 +60,15 @@ describe('ActsStServiceAbilityTest', function () {
console
.
log
(
'
ACTS_AExecuteShellCommand_Callback_0100====<end mySetTimeout
'
)
done
();
}
var
cmd
=
'
pwd
'
var
escresult
=
'
/system/app
'
var
cmd
=
'
echo test
'
var
AbilityDelegator
=
abilityDelegatorRegistry
.
getAbilityDelegator
()
AbilityDelegator
.
executeShellCommand
(
cmd
,
(
err
,
data
)
=>
{
clearTimeout
(
currentAlertTimeout
);
console
.
log
(
'
ACTS_AExecuteShellCommand_Callback_0100 - executeShellCommand: start
'
)
console
.
log
(
'
ACTS_AExecuteShellCommand_Callback_0100 data:
'
+
JSON
.
stringify
(
data
)
)
result
=
data
.
stdResult
.
replace
(
/
[\r\n]
/g
,
""
);
console
.
log
(
'
ACTS_AExecuteShellCommand_Callback_0100 stdResult =
'
+
data
.
stdResult
)
var
i
=
data
.
stdResult
.
indexOf
(
'
/system/app
'
);
console
.
log
(
'
ACTS_AExecuteShellCommand_Callback_0100 query string i =
'
+
i
);
expect
(
i
==
-
1
).
assertEqual
(
false
);
expect
(
result
).
assertEqual
(
'
test
'
);
console
.
log
(
'
ACTS_AExecuteShellCommand_Callback_0100 exitCode =
'
+
data
.
exitCode
)
expect
(
data
.
exitCode
).
assertEqual
(
0
);
...
...
@@ -99,16 +100,15 @@ describe('ActsStServiceAbilityTest', function () {
console
.
log
(
'
ACTS_AExecuteShellCommand_Callback_0200====<end mySetTimeout
'
)
done
();
}
var
cmd
=
'
pwd
'
var
cmd
=
'
echo test
'
var
AbilityDelegator
=
abilityDelegatorRegistry
.
getAbilityDelegator
()
AbilityDelegator
.
executeShellCommand
(
cmd
,
1
).
then
((
data
)
=>
{
clearTimeout
(
currentAlertTimeout
);
console
.
log
(
'
ACTS_AExecuteShellCommand_Promise_0100 - executeShellCommand: start
'
)
result
=
data
.
stdResult
.
replace
(
/
[\r\n]
/g
,
""
);
console
.
log
(
'
ACTS_AExecuteShellCommand_Promise_0100 stdResult =
'
+
data
.
stdResult
)
var
i
=
data
.
stdResult
.
indexOf
(
'
/system/app
'
);
console
.
log
(
'
ACTS_AExecuteShellCommand_Callback_0100 query string i =
'
+
i
);
expect
(
i
==
-
1
).
assertEqual
(
false
);
expect
(
result
).
assertEqual
(
'
test
'
);
console
.
log
(
'
ACTS_AExecuteShellCommand_Promise_0100 exitCode =
'
+
data
.
exitCode
)
expect
(
data
.
exitCode
).
assertEqual
(
0
);
...
...
@@ -379,25 +379,25 @@ describe('ActsStServiceAbilityTest', function () {
*/
it
(
'
ACTS_ATestRunner_0200
'
,
0
,
async
function
(
done
)
{
console
.
debug
(
'
ACTS_ATestRunner_0200====<begin
'
);
let
sa
=
'
-b
'
;
try
{
var
AbilityDelegatorArgs
=
abilityDelegatorRegistry
.
getArguments
()
console
.
debug
(
"
ACTS_ATestRunner_0200====>getArguments is====>
"
+
JSON
.
stringify
(
AbilityDelegatorArgs
));
console
.
debug
(
"
ACTS_ATestRunner_0200====bundleName>
"
+
JSON
.
stringify
(
AbilityDelegatorArgs
.
bundleName
));
expect
(
AbilityDelegatorArgs
.
bundleName
).
assertEqual
(
undefined
)
console
.
debug
(
"
ACTS_ATestRunner_0200====parameters>
"
+
JSON
.
stringify
(
AbilityDelegatorArgs
.
parameters
));
expect
(
AbilityDelegatorArgs
.
parameters
).
assertEqual
(
undefined
)
console
.
debug
(
"
ACTS_ATestRunner_0200====testCaseNames>
"
+
JSON
.
stringify
(
AbilityDelegatorArgs
.
testCaseNames
));
expect
(
AbilityDelegatorArgs
.
testCaseNames
).
assertEqual
(
undefined
)
console
.
debug
(
"
ACTS_ATestRunner_0200====testRunnerClassName>
"
+
JSON
.
stringify
(
AbilityDelegatorArgs
.
testRunnerClassName
));
expect
(
AbilityDelegatorArgs
.
testRunnerClassName
).
assertEqual
(
undefined
)
expect
(
AbilityDelegatorArgs
.
bundleName
).
assertEqual
(
'
com.amsst.actsabilitydelegatorcasetest
'
)
expect
(
AbilityDelegatorArgs
.
parameters
[
"
-b
"
]).
assertEqual
(
"
com.amsst.actsabilitydelegatorcasetest
"
)
expect
(
AbilityDelegatorArgs
.
parameters
[
"
-p
"
]).
assertEqual
(
"
com.amsst.actsabilitydelegatorcasetest
"
)
expect
(
AbilityDelegatorArgs
.
parameters
[
"
-s timeout
"
]).
assertEqual
(
"
30000
"
)
expect
(
AbilityDelegatorArgs
.
parameters
[
"
-s unittest
"
]).
assertEqual
(
"
OpenHarmonyTestRunner
"
)
expect
(
AbilityDelegatorArgs
.
parameters
[
"
-w
"
]).
assertEqual
(
"
300000
"
)
expect
(
AbilityDelegatorArgs
.
parameters
[
"
moduleName
"
]).
assertEqual
(
""
)
expect
(
AbilityDelegatorArgs
.
testCaseNames
).
assertEqual
(
''
)
expect
(
AbilityDelegatorArgs
.
testRunnerClassName
).
assertEqual
(
'
OpenHarmonyTestRunner
'
)
console
.
debug
(
'
ACTS_ATestRunner_0200====<end
'
);
done
();
}
catch
(
error
)
{
console
.
log
(
"
ACTS_ATestRunner_0200 : error =
"
+
error
);
console
.
debug
(
'
ACTS_ATestRunner_0200====<end catch (error)
'
);
done
();
}
})
})
\ No newline at end of file
})
}
\ No newline at end of file
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/js/test/List.test.js
浏览文件 @
9293e18e
...
...
@@ -12,4 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require
(
'
./ActsAbilityDelegatorCaseTest.test.js
'
)
\ No newline at end of file
import
actsStServiceAbilityTest
from
'
./ActsAbilityDelegatorCaseTest.test.js
'
export
default
function
testsuite
()
{
actsStServiceAbilityTest
()
}
\ No newline at end of file
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/
js/
resources/base/element/string.json
→
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/resources/base/element/string.json
浏览文件 @
9293e18e
...
...
@@ -7,6 +7,14 @@
{
"name"
:
"mainability_description"
,
"value"
:
"JS_Phone_Empty Feature Ability"
},
{
"name"
:
"TestAbility_desc"
,
"value"
:
"description"
},
{
"name"
:
"TestAbility_label"
,
"value"
:
"label"
}
]
}
\ No newline at end of file
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/
js/
resources/base/media/icon.png
→
ability/ability_runtime/actsabilitydelegatorcase/entry/src/main/resources/base/media/icon.png
浏览文件 @
9293e18e
文件已移动
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/Test.json
浏览文件 @
9293e18e
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"120000"
,
"package"
:
"com.example.actsgetdisplayidtest"
,
"shell-timeout"
:
"60000"
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"600000"
,
"bundle-name"
:
"com.example.actsgetdisplayidtest"
,
"module-name"
:
"phone"
,
"shell-timeout"
:
"600000"
,
"testcase-timeout"
:
"30000"
},
"kits"
:
[
{
...
...
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
9293e18e
/*
* 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.actsgetdisplayidtest.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
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/index/index.ets
浏览文件 @
9293e18e
...
...
@@ -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
...
...
@@ -23,23 +22,12 @@ import testsuite from "../../test/List.test.ets"
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()
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
...
...
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/Ability.test.ets
浏览文件 @
9293e18e
...
...
@@ -13,7 +13,7 @@
* 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'
...
...
ability/ability_runtime/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/List.test.ets
浏览文件 @
9293e18e
...
...
@@ -15,8 +15,8 @@
import abilityTest from './Ability.test.ets'
export default function testsuite(
context
) {
export default function testsuite() {
abilityTest(
c
ontext)
abilityTest(
globalThis.abilityC
ontext)
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录