Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
85f992fe
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看板
提交
85f992fe
编写于
7月 20, 2022
作者:
Z
zhouke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify.Signed-off-by: <zhouke35@huawei.com>.
Signed-off-by:
N
zhouke
<
zhouke35@huawei.com
>
上级
56dfc4f7
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
215 addition
and
146 deletion
+215
-146
arkXtest/BUILD.gn
arkXtest/BUILD.gn
+1
-1
arkXtest/uitest/BUILD.gn
arkXtest/uitest/BUILD.gn
+3
-3
arkXtest/uitest/Test.json
arkXtest/uitest/Test.json
+21
-2
arkXtest/uitest/src/main/config.json
arkXtest/uitest/src/main/config.json
+2
-2
arkXtest/uitest/src/main/ets/MainAbility/pages/index.ets
arkXtest/uitest/src/main/ets/MainAbility/pages/index.ets
+6
-15
arkXtest/uitest/src/main/ets/MainAbility/pages/third.ets
arkXtest/uitest/src/main/ets/MainAbility/pages/third.ets
+1
-1
arkXtest/uitest/src/main/ets/TestAbility/pages/index.ets
arkXtest/uitest/src/main/ets/TestAbility/pages/index.ets
+6
-1
arkXtest/uitest/src/main/ets/TestAbility/pages/third.ets
arkXtest/uitest/src/main/ets/TestAbility/pages/third.ets
+1
-1
arkXtest/uitest/src/main/ets/test/List.test.ets
arkXtest/uitest/src/main/ets/test/List.test.ets
+1
-1
arkXtest/uitest/src/main/ets/test/uitest.test.ets
arkXtest/uitest/src/main/ets/test/uitest.test.ets
+173
-119
未找到文件。
arkXtest/BUILD.gn
浏览文件 @
85f992fe
...
@@ -16,6 +16,6 @@ import("//build/ohos_var.gni")
...
@@ -16,6 +16,6 @@ import("//build/ohos_var.gni")
group("arkXtest") {
group("arkXtest") {
testonly = true
testonly = true
if (is_standard_system) {
if (is_standard_system) {
deps = [ "uitest:uitest
_x
ts" ]
deps = [ "uitest:uitest
Ac
ts" ]
}
}
}
}
arkXtest/uitest/BUILD.gn
浏览文件 @
85f992fe
# Copyright (C) 202
1
Huawei Device Co., Ltd.
# Copyright (C) 202
2
Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# You may obtain a copy of the License at
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni")
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("uitest
_x
ts") {
ohos_js_hap_suite("uitest
Ac
ts") {
hap_profile = "./src/main/config.json"
hap_profile = "./src/main/config.json"
deps = [
deps = [
":uitest_ets_assets",
":uitest_ets_assets",
...
@@ -22,7 +22,7 @@ ohos_js_hap_suite("uitest_xts") {
...
@@ -22,7 +22,7 @@ ohos_js_hap_suite("uitest_xts") {
]
]
ets2abc = true
ets2abc = true
certificate_profile = "//test/xts/acts/arkXtest/uitest/signature/auto_ohos_default_com.uitest.test.p7b"
certificate_profile = "//test/xts/acts/arkXtest/uitest/signature/auto_ohos_default_com.uitest.test.p7b"
hap_name = "uitest
_x
ts"
hap_name = "uitest
Ac
ts"
}
}
ohos_js_assets("uitest_ets_assets") {
ohos_js_assets("uitest_ets_assets") {
source_dir = "./src/main/ets/MainAbility"
source_dir = "./src/main/ets/MainAbility"
...
...
arkXtest/uitest/Test.json
浏览文件 @
85f992fe
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
"driver"
:
{
"driver"
:
{
"type"
:
"OHJSUnitTest"
,
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"1800000"
,
"test-timeout"
:
"1800000"
,
"bundle-name"
:
"com.uitest.
test
"
,
"bundle-name"
:
"com.uitest.
acts
"
,
"package-name"
:
"com.uitest.
test
"
,
"package-name"
:
"com.uitest.
acts
"
,
"shell-timeout"
:
"60000"
"shell-timeout"
:
"60000"
},
},
"kits"
:
[
"kits"
:
[
...
@@ -14,6 +14,25 @@
...
@@ -14,6 +14,25 @@
],
],
"type"
:
"AppInstallKit"
,
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
"cleanup-apps"
:
true
},
{
"type"
:
"PushKit"
,
"push"
:
[
"resource/arkXtest/arkXtest_windowsTest.hap -> /data/local/tmp/arkXtest_windowsTest.hap"
,
"resource/arkXtest/window_manager_config.xml -> /system/etc/window/resources/window_manager_config.xml"
]
},
{
"type"
:
"ShellKit"
,
"run-command"
:
[
"power-shell wakeup"
,
"uinput -T -d 300 600 -m 300 600 300 100 -u 300 100"
,
"power-shell setmode 602"
,
"bm install -p /data/local/tmp/arkXtest_windowsTest.hap"
],
"teardown-command"
:
[
"bm uninstall -n com.example.windows"
]
}
}
]
]
}
}
\ No newline at end of file
arkXtest/uitest/src/main/config.json
浏览文件 @
85f992fe
{
{
"app"
:
{
"app"
:
{
"vendor"
:
"open"
,
"vendor"
:
"open"
,
"bundleName"
:
"com.uitest.
test
"
,
"bundleName"
:
"com.uitest.
acts
"
,
"version"
:
{
"version"
:
{
"code"
:
1000000
,
"code"
:
1000000
,
"name"
:
"1.0.0"
"name"
:
"1.0.0"
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
},
},
"deviceConfig"
:
{},
"deviceConfig"
:
{},
"module"
:
{
"module"
:
{
"package"
:
"com.uitest.
test
"
,
"package"
:
"com.uitest.
acts
"
,
"name"
:
".MyApplication"
,
"name"
:
".MyApplication"
,
"mainAbility"
:
".MainAbility"
,
"mainAbility"
:
".MainAbility"
,
"srcPath"
:
"MainAbility"
,
"srcPath"
:
"MainAbility"
,
...
...
arkXtest/uitest/src/main/ets/MainAbility/pages/index.ets
浏览文件 @
85f992fe
/**
* 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 '@system.router';
import router from '@system.router';
import prompt from '@ohos.prompt';
import prompt from '@ohos.prompt';
...
@@ -41,7 +27,12 @@ struct ScrollExample {
...
@@ -41,7 +27,12 @@ struct ScrollExample {
router.push({ uri: 'pages/fourth' })
router.push({ uri: 'pages/fourth' })
})
})
)
)
Text('Click twice')
Button() {
Text('Click twice')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({top:20})
.margin({top:20})
.gesture(
.gesture(
TapGesture({ count: 2 })
TapGesture({ count: 2 })
...
...
arkXtest/uitest/src/main/ets/MainAbility/pages/third.ets
浏览文件 @
85f992fe
...
@@ -25,7 +25,7 @@ struct Third{
...
@@ -25,7 +25,7 @@ struct Third{
.fontSize(50)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.fontWeight(FontWeight.Bold)
Button() {
Button() {
Text('
page_3
')
Text('
doubleClick
')
.fontSize(20)
.fontSize(20)
.fontWeight(FontWeight.Bold)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
}.type(ButtonType.Capsule)
...
...
arkXtest/uitest/src/main/ets/TestAbility/pages/index.ets
浏览文件 @
85f992fe
...
@@ -41,7 +41,12 @@ struct ScrollExample {
...
@@ -41,7 +41,12 @@ struct ScrollExample {
router.push({ uri: 'pages/fourth' })
router.push({ uri: 'pages/fourth' })
})
})
)
)
Text('Click twice')
Button() {
Text('Click twice')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}
.type(ButtonType.Capsule)
.margin({top:20})
.margin({top:20})
.gesture(
.gesture(
TapGesture({ count: 2 })
TapGesture({ count: 2 })
...
...
arkXtest/uitest/src/main/ets/TestAbility/pages/third.ets
浏览文件 @
85f992fe
...
@@ -25,7 +25,7 @@ struct Third{
...
@@ -25,7 +25,7 @@ struct Third{
.fontSize(50)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.fontWeight(FontWeight.Bold)
Button() {
Button() {
Text('
page_3
')
Text('
doubleClick
')
.fontSize(20)
.fontSize(20)
.fontWeight(FontWeight.Bold)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
}.type(ButtonType.Capsule)
...
...
arkXtest/uitest/src/main/ets/test/List.test.ets
浏览文件 @
85f992fe
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
import abilityTest from './
Ability
.test'
import abilityTest from './
uitest
.test'
export default function testsuite() {
export default function testsuite() {
abilityTest()
abilityTest()
...
...
arkXtest/uitest/src/main/ets/test/
Ability
.test.ets
→
arkXtest/uitest/src/main/ets/test/
uitest
.test.ets
浏览文件 @
85f992fe
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
*/
*/
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'@ohos/hypium'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'@ohos/hypium'
import
abilityDelegatorRegistry
from
'@ohos.application.abilityDelegatorRegistry'
;
import
abilityDelegatorRegistry
from
'@ohos.application.abilityDelegatorRegistry'
;
import
{
UiDriver
,
BY
,
ResizeDirection
,
MatchPattern
}
from
'@ohos.uitest'
import
{
UiDriver
,
BY
,
ResizeDirection
,
MatchPattern
,
WindowMode
}
from
'@ohos.uitest'
import
ability_featureAbility
from
'@ohos.ability.featureAbility'
;
import
ability_featureAbility
from
'@ohos.ability.featureAbility'
;
const
delegator
=
abilityDelegatorRegistry
.
getAbilityDelegator
();
const
delegator
=
abilityDelegatorRegistry
.
getAbilityDelegator
();
...
@@ -39,7 +39,7 @@ async function stopApplication(bundleName: string) {
...
@@ -39,7 +39,7 @@ async function stopApplication(bundleName: string) {
export
default
function
abilityTest
()
{
export
default
function
abilityTest
()
{
describe
(
'UiTestCase'
,
function
()
{
describe
(
'UiTestCase'
,
function
()
{
it
(
'
UiComponent.InputText
'
,
0
,
async
function
()
{
it
(
'
testInputNumber
'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
input
=
await
driver
.
findComponent
(
BY
.
type
(
'TextInput'
))
let
input
=
await
driver
.
findComponent
(
BY
.
type
(
'TextInput'
))
...
@@ -50,37 +50,54 @@ export default function abilityTest() {
...
@@ -50,37 +50,54 @@ export default function abilityTest() {
expect
(
text
==
'123'
)
.
assertTrue
()
expect
(
text
==
'123'
)
.
assertTrue
()
})
})
it
(
'
UiComponent.
ClearText'
,
0
,
async
function
()
{
it
(
'
test
ClearText'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
input
=
await
driver
.
findComponent
(
BY
.
type
(
'TextInput'
))
let
input1
=
await
driver
.
findComponent
(
BY
.
type
(
'TextInput'
))
await
input
.
clearText
()
await
input1
.
inputText
(
'abc'
)
let
input2
=
await
driver
.
findComponent
(
BY
.
type
(
'TextInput'
))
await
input2
.
clearText
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
input_new
=
await
driver
.
findComponent
(
BY
.
type
(
'TextInput'
))
let
input_new
=
await
driver
.
findComponent
(
BY
.
type
(
'TextInput'
))
let
text
=
await
input_new
.
getText
()
let
text
=
await
input_new
.
getText
()
expect
(
text
)
.
assertEqual
(
''
)
expect
(
text
)
.
assertEqual
(
''
)
})
})
it
(
'
c
heckable'
,
0
,
async
function
()
{
it
(
'
testC
heckable'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
checkable
(
true
)
.
type
(
'Checkbox'
))
let
button
=
await
driver
.
findComponent
(
BY
.
checkable
(
true
)
.
type
(
'Checkbox'
))
let
checkable
=
await
button
.
isCheckable
()
let
checkable
=
await
button
.
isCheckable
()
expect
(
typeof
(
checkable
)
==
'boolean'
)
.
assertTrue
()
expect
(
checkable
==
true
)
.
assertTrue
()
})
})
it
(
'
c
hecked'
,
0
,
async
function
()
{
it
(
'
testC
hecked'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
checked
(
false
)
.
type
(
'Checkbox'
))
let
button
=
await
driver
.
findComponent
(
BY
.
checked
(
false
)
.
type
(
'Checkbox'
))
let
checked
=
await
button
.
isChecked
()
let
checked
=
await
button
.
isChecked
()
expect
(
typeof
(
checked
)
==
'boolean'
)
.
assertTrue
()
expect
(
checked
==
false
)
.
assertTrue
()
})
it
(
'testMatchPattren'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
Button1
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
,
MatchPattern
.
EQUALS
))
expect
(
await
Button1
.
getText
()
==
'next page'
)
.
assertTrue
()
let
Button2
=
await
driver
.
findComponent
(
BY
.
text
(
'next'
,
MatchPattern
.
STARTS_WITH
))
expect
(
await
Button2
.
getText
()
==
'next page'
)
.
assertTrue
()
let
Button3
=
await
driver
.
findComponent
(
BY
.
text
(
'page'
,
MatchPattern
.
ENDS_WITH
))
expect
(
await
Button3
.
getText
()
==
'next page'
)
.
assertTrue
()
let
Button4
=
await
driver
.
findComponent
(
BY
.
text
(
'ext'
,
MatchPattern
.
CONTAINS
))
expect
(
await
Button4
.
getText
()
==
'next page'
)
.
assertTrue
()
})
})
it
(
'
UiDriver.c
lick'
,
0
,
async
function
()
{
it
(
'
testC
lick'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
click
(
350
,
90
)
let
Button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
center
=
await
Button
.
getBoundsCenter
()
await
driver
.
click
(
center
.
X
,
center
.
Y
)
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
newButton
=
await
driver
.
findComponent
(
BY
.
text
(
'back to index'
))
let
newButton
=
await
driver
.
findComponent
(
BY
.
text
(
'back to index'
))
let
text
=
await
newButton
.
getText
()
let
text
=
await
newButton
.
getText
()
...
@@ -88,10 +105,25 @@ export default function abilityTest() {
...
@@ -88,10 +105,25 @@ export default function abilityTest() {
await
newButton
.
click
()
await
newButton
.
click
()
})
})
it
(
'UiDriver.LongClick'
,
0
,
async
function
()
{
it
(
'testDoubleClick'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
Button
=
await
driver
.
findComponent
(
BY
.
text
(
'Click twice'
))
let
center
=
await
Button
.
getBoundsCenter
()
await
driver
.
doubleClick
(
center
.
X
,
center
.
Y
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'doubleClick'
))
let
text
=
await
button
.
getText
()
expect
(
text
==
'doubleClick'
)
.
assertTrue
()
await
button
.
click
()
})
it
(
'testLongClick'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
longClick
(
350
,
90
)
let
Button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
center
=
await
Button
.
getBoundsCenter
()
await
driver
.
longClick
(
center
.
X
,
center
.
Y
)
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
newButton
=
await
driver
.
findComponent
(
BY
.
text
(
'longClick'
))
let
newButton
=
await
driver
.
findComponent
(
BY
.
text
(
'longClick'
))
let
text
=
await
newButton
.
getText
()
let
text
=
await
newButton
.
getText
()
...
@@ -99,26 +131,31 @@ export default function abilityTest() {
...
@@ -99,26 +131,31 @@ export default function abilityTest() {
await
newButton
.
click
()
await
newButton
.
click
()
})
})
it
(
'
key
'
,
0
,
async
function
()
{
it
(
'
testUiComponentClick
'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
key
(
'my-key'
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
expect
(
await
button
.
getKey
()
==
'my-key'
)
.
assertTrue
()
await
button
.
click
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
newButton
=
await
driver
.
findComponent
(
BY
.
text
(
'back to index'
))
let
text
=
await
newButton
.
getText
()
expect
(
text
==
'back to index'
)
.
assertTrue
()
await
newButton
.
click
()
})
})
it
(
'
UiComponent.
Click'
,
0
,
async
function
()
{
it
(
'
testUiComponentDouble
Click'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'
next page'
,
MatchPattern
.
EQUALS
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'
Click twice'
))
await
button
.
c
lick
()
await
button
.
doubleC
lick
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
newButton
=
await
driver
.
findComponent
(
BY
.
text
(
'
back to index
'
))
let
newButton
=
await
driver
.
findComponent
(
BY
.
text
(
'
doubleClick
'
))
let
text
=
await
newButton
.
getText
()
let
text
=
await
newButton
.
getText
()
expect
(
text
==
'
back to index
'
)
.
assertTrue
()
expect
(
text
==
'
doubleClick
'
)
.
assertTrue
()
await
newButton
.
click
()
await
newButton
.
click
()
})
})
it
(
'
UiComponent.
LongClick'
,
0
,
async
function
()
{
it
(
'
testUiComponent
LongClick'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
...
@@ -130,71 +167,79 @@ export default function abilityTest() {
...
@@ -130,71 +167,79 @@ export default function abilityTest() {
await
newButton
.
click
()
await
newButton
.
click
()
})
})
it
(
'
UiComponent.getType
'
,
0
,
async
function
()
{
it
(
'
testKey
'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
text
=
await
driver
.
findComponent
(
BY
.
type
(
'Text'
))
let
button
=
await
driver
.
findComponent
(
BY
.
key
(
'my-key'
))
let
type
=
await
text
.
getType
()
expect
(
await
button
.
getKey
()
==
'my-key'
)
.
assertTrue
()
expect
(
type
==
'Text'
)
.
assertTrue
()
})
})
it
(
'
UiComponent.getText
'
,
0
,
async
function
()
{
it
(
'
testId
'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
text
=
await
button
.
getText
()
let
id
=
await
button
.
getId
()
expect
(
text
==
'next page'
)
.
assertTrue
()
let
button2
=
await
driver
.
findComponent
(
BY
.
id
(
id
))
expect
(
await
button
.
getText
()
==
'next page'
)
.
assertTrue
()
})
})
it
(
'UiComponent.isClickable'
,
0
,
async
function
()
{
it
(
'testGetType'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
text
=
await
driver
.
findComponent
(
BY
.
type
(
'Text'
))
let
type
=
await
text
.
getType
()
expect
(
type
==
'Text'
)
.
assertTrue
()
})
it
(
'testClickable'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
)
.
clickable
(
false
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
)
.
clickable
(
false
))
let
clickable
=
await
button
.
isClickable
()
let
clickable
=
await
button
.
isClickable
()
expect
(
typeof
(
clickable
)
==
'boolean'
)
.
assertTrue
()
expect
(
clickable
==
false
)
.
assertTrue
()
})
})
it
(
'
UiComponent.is
LongClickable'
,
0
,
async
function
()
{
it
(
'
test
LongClickable'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
)
.
longClickable
(
false
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
)
.
longClickable
(
false
))
let
longClickable
=
await
button
.
isLongClickable
()
let
longClickable
=
await
button
.
isLongClickable
()
expect
(
typeof
(
longClickable
)
==
'boolean'
)
.
assertTrue
()
expect
(
longClickable
==
false
)
.
assertTrue
()
})
})
it
(
'
UiComponent.is
Scrollable'
,
0
,
async
function
()
{
it
(
'
test
Scrollable'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
scrollBar
=
await
driver
.
findComponent
(
BY
.
type
(
'Scroll'
)
.
scrollable
(
false
))
let
scrollBar
=
await
driver
.
findComponent
(
BY
.
type
(
'Scroll'
)
.
scrollable
(
false
))
let
scrollable
=
await
scrollBar
.
isScrollable
()
let
scrollable
=
await
scrollBar
.
isScrollable
()
expect
(
typeof
(
scrollable
)
==
'boolean'
)
.
assertTrue
()
expect
(
scrollable
==
false
)
.
assertTrue
()
})
})
it
(
'
UiComponent.is
Enabled'
,
0
,
async
function
()
{
it
(
'
test
Enabled'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
)
.
enabled
(
true
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
)
.
enabled
(
true
))
let
enable
=
await
button
.
isEnabled
()
let
enable
=
await
button
.
isEnabled
()
expect
(
enable
)
.
assertEqual
(
true
)
expect
(
enable
==
true
)
.
assertTrue
(
)
})
})
it
(
'
UiComponent.is
Focused'
,
0
,
async
function
()
{
it
(
'
test
Focused'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
)
.
focused
(
false
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
)
.
focused
(
false
))
let
focused
=
await
button
.
isFocused
()
let
focused
=
await
button
.
isFocused
()
expect
(
typeof
(
focused
)
==
'boolean'
)
.
assertTrue
()
expect
(
focused
==
false
)
.
assertTrue
()
})
})
it
(
'
UiComponent.is
Selected'
,
0
,
async
function
()
{
it
(
'
test
Selected'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
)
.
selected
(
false
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
)
.
selected
(
false
))
let
selected
=
await
button
.
isSelected
()
let
selected
=
await
button
.
isSelected
()
expect
(
typeof
(
selected
)
==
'boolean'
)
.
assertTrue
()
expect
(
selected
==
false
)
.
assertTrue
()
})
})
it
(
'
UiComponent.s
crollToBottom'
,
0
,
async
function
()
{
it
(
'
testS
crollToBottom'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
scrollBar
=
await
driver
.
findComponent
(
BY
.
type
(
'Scroll'
))
let
scrollBar
=
await
driver
.
findComponent
(
BY
.
type
(
'Scroll'
))
...
@@ -202,28 +247,26 @@ export default function abilityTest() {
...
@@ -202,28 +247,26 @@ export default function abilityTest() {
await
scrollBar
.
scrollToBottom
()
await
scrollBar
.
scrollToBottom
()
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'bottom'
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'bottom'
))
expect
(
await
button
.
getText
()
==
'bottom'
)
.
assertTrue
()
expect
(
await
button
.
getText
()
==
'bottom'
)
.
assertTrue
()
await
scrollBar
.
scrollToTop
()
})
})
it
(
'
UiComponent.s
crollToTop'
,
0
,
async
function
()
{
it
(
'
testS
crollToTop'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
swipe
(
100
,
200
,
100
,
100
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
scrollBar
=
await
driver
.
findComponent
(
BY
.
type
(
'Scroll'
))
let
scrollBar
=
await
driver
.
findComponent
(
BY
.
type
(
'Scroll'
))
expect
(
scrollBar
!==
null
)
.
assertTrue
()
expect
(
scrollBar
!==
null
)
.
assertTrue
()
await
scrollBar
.
scrollToBottom
()
await
scrollBar
.
scrollToTop
()
await
scrollBar
.
scrollToTop
()
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
expect
(
await
button
.
getText
()
==
'next page'
)
.
assertTrue
()
expect
(
await
button
.
getText
()
==
'next page'
)
.
assertTrue
()
})
})
it
(
'
UiDriver.a
ssertComponentExist'
,
0
,
async
function
()
{
it
(
'
testA
ssertComponentExist'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
assertComponentExist
(
BY
.
text
(
'next page'
))
await
driver
.
assertComponentExist
(
BY
.
text
(
'next page'
))
})
})
it
(
'
UiDriver.p
ressBack'
,
0
,
async
function
()
{
it
(
'
testP
ressBack'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
...
@@ -235,81 +278,98 @@ export default function abilityTest() {
...
@@ -235,81 +278,98 @@ export default function abilityTest() {
expect
(
await
button_ori
.
getText
()
==
'next page'
)
.
assertTrue
()
expect
(
await
button_ori
.
getText
()
==
'next page'
)
.
assertTrue
()
})
})
it
(
'
UiDriver.f
indComponents'
,
0
,
async
function
()
{
it
(
'
testF
indComponents'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
buttons
=
await
driver
.
findComponents
(
BY
.
type
(
'Button'
))
let
buttons
=
await
driver
.
findComponents
(
BY
.
type
(
'Button'
))
expect
(
await
buttons
[
0
]
.
getText
()
!=
null
)
.
assertTrue
()
expect
(
await
buttons
[
0
]
.
getText
()
!=
null
)
.
assertTrue
()
})
})
it
(
'
UiDriver.t
riggerKey'
,
0
,
async
function
()
{
it
(
'
testT
riggerKey'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
await
button
.
click
()
await
button
.
click
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
triggerKey
(
2
)
let
keyBack
=
2
await
driver
.
triggerKey
(
keyBack
)
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button_ori
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
button_ori
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
expect
(
await
button_ori
.
getText
()
==
'next page'
)
.
assertTrue
()
expect
(
await
button_ori
.
getText
()
==
'next page'
)
.
assertTrue
()
})
})
it
(
'
g
etUiComponentBounds'
,
0
,
async
function
()
{
it
(
'
testG
etUiComponentBounds'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
text
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
text
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
expect
(
text
!==
null
)
.
assertTrue
()
expect
(
text
!==
null
)
.
assertTrue
()
let
bounds
=
await
text
.
getBounds
();
let
bounds
=
await
text
.
getBounds
();
console
.
info
(
`UiTestCase, bounds=${bounds}, type=${typeof (bounds)}`
)
console
.
info
(
bounds
.
rightX
.
toString
())
console
.
info
(
bounds
.
leftX
.
toString
())
console
.
info
(
bounds
.
topY
.
toString
())
console
.
info
(
bounds
.
bottomY
.
toString
())
expect
(
bounds
!==
null
)
.
assertTrue
()
expect
(
bounds
!==
null
)
.
assertTrue
()
expect
(
bounds
.
rightX
)
.
assertLarger
(
bounds
.
leftX
)
expect
(
bounds
.
rightX
)
.
assertLarger
(
bounds
.
leftX
)
expect
(
bounds
.
bottomY
)
.
assertLarger
(
bounds
.
topY
)
expect
(
bounds
.
bottomY
)
.
assertLarger
(
bounds
.
topY
)
})
})
it
(
'
g
etUiComponentBoundsCenter'
,
0
,
async
function
()
{
it
(
'
testG
etUiComponentBoundsCenter'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'next page'
))
let
point
=
await
button
.
getBoundsCenter
()
let
point
=
await
button
.
getBoundsCenter
()
let
bounds
=
await
button
.
getBounds
()
expect
(
point
!==
null
)
.
assertTrue
()
expect
(
point
!==
null
)
.
assertTrue
()
expect
(
point
.
Y
==
(
bounds
.
bottomY
+
bounds
.
topY
)
/
2
)
.
assertTrue
()
expect
(
point
.
X
==
(
bounds
.
rightX
+
bounds
.
leftX
)
/
2
)
.
assertTrue
()
})
})
it
(
'
UiDriver.w
aitForComponent'
,
0
,
async
function
()
{
it
(
'
testW
aitForComponent'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
waitForComponent
(
BY
.
text
(
'next page'
),
waitUiReadyMs
)
let
button
=
await
driver
.
waitForComponent
(
BY
.
text
(
'next page'
),
waitUiReadyMs
)
expect
(
button
!==
null
)
.
assertTrue
()
expect
(
button
!==
null
)
.
assertTrue
()
})
})
it
(
'UiDriver.screenCap'
,
0
,
async
function
()
{
it
(
'testScreenCap'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
savePath
=
'/data/local/tmp/1.png'
let
success
=
await
driver
.
screenCap
(
savePath
)
expect
(
success
==
true
)
.
assertTrue
()
})
it
(
'testIsBefore'
,
0
,
async
function
()
{
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
path
=
'/data/local/tmp/1.png'
let
button
=
await
driver
.
findComponent
(
BY
.
isBefore
(
BY
.
text
(
'Click twice'
))
.
type
(
'Button'
))
let
success
=
await
driver
.
screenCap
(
path
)
expect
(
await
button
.
getType
()
==
'Button'
)
.
assertTrue
()
expect
(
typeof
(
success
)
==
'boolean'
)
.
assertTrue
()
})
})
it
(
'By.isBefore'
,
0
,
async
function
()
{
it
(
'testIsAfter'
,
0
,
async
function
()
{
await
startAbility
(
'com.ohos.settings'
,
'com.ohos.settings.MainAbility'
)
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
is
Before
(
BY
.
text
(
'显示与亮度'
))
.
text
(
'移动数据
'
))
let
button
=
await
driver
.
findComponent
(
BY
.
is
After
(
BY
.
text
(
'next page'
))
.
type
(
'Text
'
))
expect
(
await
button
.
getText
()
==
'
移动数据
'
)
.
assertTrue
()
expect
(
await
button
.
getText
()
==
'
Click twice
'
)
.
assertTrue
()
})
})
it
(
'By.isAfter'
,
0
,
async
function
()
{
it
(
'testScrollSearch'
,
0
,
async
function
()
{
await
startAbility
(
'com.ohos.settings'
,
'com.ohos.settings.MainAbility'
)
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
isAfter
(
BY
.
text
(
'显示与亮度'
))
.
text
(
'声音'
))
let
scrollBar
=
await
driver
.
findComponent
(
BY
.
type
(
'Scroll'
))
expect
(
await
button
.
getText
()
==
'声音'
)
.
assertTrue
()
let
text
=
await
scrollBar
.
scrollSearch
(
BY
.
text
(
'4'
))
await
driver
.
delayMs
(
waitUiReadyMs
)
expect
(
text
!=
null
)
.
assertTrue
()
await
scrollBar
.
scrollToTop
()
})
})
it
(
'window.resize'
,
0
,
async
function
()
{
it
(
'testGetWindowMode'
,
0
,
async
function
()
{
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
mode
=
await
window
.
getWindowMode
()
expect
(
mode
==
WindowMode
.
FULLSCREEN
)
.
assertTrue
()
await
stopApplication
(
'com.example.windows'
)
})
it
(
'testWindowMoveTo'
,
0
,
async
function
()
{
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
...
@@ -317,87 +377,81 @@ export default function abilityTest() {
...
@@ -317,87 +377,81 @@ export default function abilityTest() {
await
window
.
resume
()
await
window
.
resume
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window1
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
window1
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
bounds1
=
await
window1
.
getBounds
()
await
window1
.
moveTo
(
100
,
100
)
await
window1
.
moveTo
(
100
,
100
)
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window2
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
window2
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
await
window2
.
resize
(
600
,
600
,
7
)
let
bounds2
=
await
window2
.
getBounds
()
expect
(
bounds1
!=
bounds2
)
.
assertTrue
()
await
stopApplication
(
'com.example.windows'
)
await
stopApplication
(
'com.example.windows'
)
})
})
it
(
'
window.maxim
ize'
,
0
,
async
function
()
{
it
(
'
testWindowRes
ize'
,
0
,
async
function
()
{
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
window
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
await
window
.
resume
()
await
window
.
resume
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window1
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
bounds1
=
await
window1
.
getBounds
()
await
window1
.
resize
(
400
,
400
,
ResizeDirection
.
RIGHT_DOWN
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window2
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
window2
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
await
window2
.
maximize
()
let
bounds2
=
await
window2
.
getBounds
()
expect
(
bounds1
!=
bounds2
)
.
assertTrue
()
await
stopApplication
(
'com.example.windows'
)
await
stopApplication
(
'com.example.windows'
)
})
})
it
(
'
window.minimize
'
,
0
,
async
function
()
{
it
(
'
testWindowFocus
'
,
0
,
async
function
()
{
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
window
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
await
window
.
minimize
()
await
window
.
focus
()
let
IsActive
=
await
window
.
focus
()
expect
(
IsActive
==
true
)
.
assertTrue
()
await
stopApplication
(
'com.example.windows'
)
await
stopApplication
(
'com.example.windows'
)
})
})
it
(
'
window.clos
e'
,
0
,
async
function
()
{
it
(
'
testWindowMaximiz
e'
,
0
,
async
function
()
{
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
window
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
await
window
.
close
()
await
window
.
resume
()
let
window2
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
await
window2
.
maximize
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window3
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
mode
=
await
window3
.
getWindowMode
()
expect
(
mode
==
WindowMode
.
FULLSCREEN
)
.
assertTrue
()
await
stopApplication
(
'com.example.windows'
)
})
})
it
(
'
window.split
'
,
0
,
async
function
()
{
it
(
'
testWindowMinimize
'
,
0
,
async
function
()
{
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
let
window
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
await
window
.
split
()
await
window
.
minimize
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'Clock'
))
expect
(
button
!=
null
)
.
assertTrue
()
await
stopApplication
(
'com.example.windows'
)
await
stopApplication
(
'com.example.windows'
)
})
})
it
(
'testWindowClose'
,
0
,
async
function
()
{
await
startAbility
(
'com.example.windows'
,
'MainAbility'
)
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
window
=
await
driver
.
findWindow
({
bundleName
:
'com.example.windows'
})
await
window
.
close
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponent
(
BY
.
text
(
'Clock'
))
expect
(
button
!=
null
)
.
assertTrue
()
})
})
})
}
afterAll
(
function
()
{
\ No newline at end of file
console
.
info
(
`uitestApiStatistic::Start runnig afterAll`
)
try
{
let
mod
=
globalThis
.
requireInternal
(
'uitest'
)
// collect all functions
let
objects
=
{
'By'
:
mod
.
By
,
'UiDriver'
:
mod
.
UiDriver
,
'UiComponent'
:
mod
.
UiComponent
}
let
allApis
=
[]
for
(
let
name
in
objects
)
{
let
object
=
objects
[
name
]
Object
.
getOwnPropertyNames
(
object
)
.
forEach
(
pn
=>
{
if
(
pn
!=
'constructor'
&&
typeof
(
object
[
pn
])
==
'function'
)
{
allApis
.
push
(
name
+
'.'
+
pn
)
}
})
Object
.
getOwnPropertyNames
(
object
.
prototype
)
.
forEach
(
pn
=>
{
if
(
pn
!=
'constructor'
&&
typeof
(
object
.
prototype
[
pn
])
==
'function'
)
{
allApis
.
push
(
name
+
'.'
+
pn
)
}
})
}
let
calledApis
:
Array
<
string
>
=
mod
.
getCalledJsApis
()
calledApis
.
forEach
(
name
=>
console
.
info
(
`uitestApiStatistic::CoveredApi: ${name}`
))
let
missedApis
=
allApis
.
filter
(
value
=>!
calledApis
.
includes
(
value
))
console
.
info
(
`uitestApiStatistic::Total ${allApis.length}, coverd ${calledApis.length}, missed ${missedApis.length}`
)
missedApis
.
forEach
(
name
=>
console
.
warn
(
`uitestApiStatistic::NotCoveredApi: ${name}`
))
}
catch
(
e
)
{
console
.
error
(
`uitestApiStatistic::Runnig afterAll failed: ${e}`
)
}
finally
{
console
.
info
(
`uitestApiStatistic::End runnig afterAll`
)
}
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录