Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
ba077533
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看板
提交
ba077533
编写于
3月 08, 2023
作者:
Z
zhouke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
arkXtest测试套用例调整和补充.Signed-off-by: <zhouke35@huawei.com>.
Signed-off-by:
N
zhouke
<
zhouke35@huawei.com
>
上级
9f69927c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
157 addition
and
5 deletion
+157
-5
arkXtest/uitest/src/main/ets/test/uitest.test.ets
arkXtest/uitest/src/main/ets/test/uitest.test.ets
+136
-3
arkXtest/uitestScene/src/main/ets/MainAbility/pages/index.ets
...test/uitestScene/src/main/ets/MainAbility/pages/index.ets
+21
-2
未找到文件。
arkXtest/uitest/src/main/ets/test/uitest.test.ets
浏览文件 @
ba077533
...
@@ -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
{
UiComponent
,
UiDriver
,
BY
,
Component
,
Driver
,
UiWindow
,
ON
,
MatchPattern
,
DisplayRotation
,
ResizeDirection
,
WindowMode
,
PointerMatrix
}
from
'@ohos.UiTest'
import
{
UiComponent
,
UiDriver
,
BY
,
Component
,
Driver
,
UiWindow
,
ON
,
MatchPattern
,
DisplayRotation
,
ResizeDirection
,
UiDirection
,
MouseButton
,
WindowMode
,
PointerMatrix
}
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
();
...
@@ -38,6 +38,139 @@ async function stopApplication(bundleName: string) {
...
@@ -38,6 +38,139 @@ async function stopApplication(bundleName: string) {
}
}
export
default
function
UiTest
()
{
export
default
function
UiTest
()
{
describe
(
'UiTest_API10'
,
function
()
{
/*
* @tc.number: uiTest_10001
* @tc.name: testWithIn
* @tc.desc: find UiComponent inside of the given UiComponent.
*/
it
(
'testWithIn'
,
0
,
async
function
()
{
await
startAbility
(
'com.uitestScene.acts'
,
'com.uitestScene.acts.MainAbility'
)
let
driver
=
Driver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
scroll
=
await
driver
.
findComponent
(
ON
.
type
(
'Scroll'
))
let
btn
=
await
driver
.
findComponent
(
ON
.
within
(
ON
.
type
(
'Scroll'
))
.
text
(
'next page'
))
let
bounds1
=
await
scroll
.
getBounds
()
let
bounds2
=
await
btn
.
getBounds
()
expect
(
bounds1
.
top
<
bounds2
.
top
)
.
assertTrue
()
expect
(
bounds1
.
bottom
>
bounds2
.
bottom
)
.
assertTrue
()
expect
(
bounds1
.
left
<
bounds2
.
right
)
.
assertTrue
()
expect
(
bounds1
.
right
>
bounds2
.
right
)
.
assertTrue
()
})
/*
* @tc.number: uiTest_10002
* @tc.name: testFling
* @tc.desc: inject fling on the device display.
*/
it
(
'testFling'
,
0
,
async
function
()
{
await
startAbility
(
'com.uitestScene.acts'
,
'com.uitestScene.acts.MainAbility'
)
let
driver
=
Driver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
fling
(
UiDirection
.
DOWN
,
39000
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button
=
await
driver
.
findComponents
(
ON
.
text
(
'next page'
))
expect
(
button
)
.
assertNull
()
await
driver
.
fling
(
UiDirection
.
LEFT
,
39000
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
text
=
await
driver
.
findComponents
(
ON
.
text
(
'1'
))
expect
(
text
)
.
assertNull
()
await
driver
.
fling
(
UiDirection
.
RIGHT
,
39000
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
text2
=
await
driver
.
findComponents
(
ON
.
text
(
'2'
))
expect
(
text2
)
.
assertNull
()
await
driver
.
fling
(
UiDirection
.
UP
,
39000
)
await
driver
.
delayMs
(
2000
)
let
button2
=
await
driver
.
findComponents
(
ON
.
text
(
'next page'
))
expect
(
button2
!=
null
)
.
assertTrue
()
})
/*
* @tc.number: uiTest_10003
* @tc.name: testScreenCapture
* @tc.desc: capture the specified area of current screen.
*/
it
(
'testScreenCapture'
,
0
,
async
function
()
{
await
startAbility
(
'com.uitestScene.acts'
,
'com.uitestScene.acts.MainAbility'
)
let
driver
=
Driver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
savePath
=
'/data/storage/el2/base/cache/1.png'
let
success
=
await
driver
.
screenCapture
(
savePath
,
{
left
:
0
,
top
:
0
,
right
:
100
,
bottom
:
100
})
expect
(
success
==
true
)
.
assertTrue
()
await
stopApplication
(
'com.uitestScene.acts'
)
})
/*
* @tc.number: uiTest_10004
* @tc.name: testMouseClick
* @tc.desc: click in the specified location on the screen by mouse.
*/
it
(
'testMouseClick'
,
0
,
async
function
()
{
// await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
await
startAbility
(
'com.example.myapplication_scene'
,
'com.example.entry.MainAbility'
)
let
driver
=
Driver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
Button
=
await
driver
.
findComponent
(
ON
.
text
(
'jump'
))
let
center
=
await
Button
.
getBoundsCenter
()
await
driver
.
mouseClick
({
x
:
center
.
x
,
y
:
center
.
y
},
MouseButton
.
MOUSE_BUTTON_RIGHT
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
Button1
=
await
driver
.
findComponent
(
ON
.
text
(
'right'
))
expect
(
Button1
!=
null
)
.
assertTrue
()
await
driver
.
mouseClick
({
x
:
center
.
x
,
y
:
center
.
y
},
MouseButton
.
MOUSE_BUTTON_MIDDLE
,
2072
,
2045
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
Button2
=
await
driver
.
findComponent
(
ON
.
text
(
'middle'
))
expect
(
Button2
!=
null
)
.
assertTrue
()
await
driver
.
mouseClick
({
x
:
center
.
x
,
y
:
center
.
y
},
MouseButton
.
MOUSE_BUTTON_LEFT
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
Button3
=
await
driver
.
findComponent
(
ON
.
text
(
'jump'
))
expect
(
Button3
==
null
)
.
assertTrue
()
await
stopApplication
(
'com.uitestScene.acts'
)
})
/*
* @tc.number: uiTest_10005
* @tc.name: testMouseMoveTo
* @tc.desc: move the mouse cursor to the specified location.
*/
it
(
'testMouseMoveTo'
,
0
,
async
function
()
{
// await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
await
startAbility
(
'com.example.myapplication_scene'
,
'com.example.entry.MainAbility'
)
let
driver
=
Driver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
Button
=
await
driver
.
findComponent
(
ON
.
text
(
'jump'
))
let
center
=
await
Button
.
getBoundsCenter
()
await
driver
.
mouseMoveTo
(
center
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
newButton
=
await
driver
.
findComponent
(
ON
.
text
(
'hover'
))
expect
(
newButton
!=
null
)
.
assertTrue
()
await
stopApplication
(
'com.uitestScene.acts'
)
})
/*
* @tc.number: uiTest_10006
* @tc.name: testMouseScroll
* @tc.desc: scroll the mouse wheel at the specified location to specify the cell.
*/
it
(
'testMouseScroll'
,
0
,
async
function
()
{
// await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
await
startAbility
(
'com.example.myapplication_scene'
,
'com.example.entry.MainAbility'
)
let
driver
=
Driver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
let
Scroll
=
await
driver
.
findComponent
(
ON
.
type
(
'Scroll'
))
let
center
=
await
Scroll
.
getBoundsCenter
()
await
driver
.
mouseScroll
(
center
,
true
,
30
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button1
=
await
driver
.
findComponent
(
ON
.
text
(
'next page'
))
expect
(
button1
==
null
)
.
assertTrue
()
await
driver
.
mouseScroll
(
center
,
false
,
30
,
2072
,
2048
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
button2
=
await
driver
.
findComponent
(
ON
.
text
(
'next page'
))
expect
(
button2
!=
null
)
.
assertTrue
()
await
stopApplication
(
'com.uitestScene.acts'
)
})
})
describe
(
'UiTest_API8'
,
function
()
{
describe
(
'UiTest_API8'
,
function
()
{
/*
/*
* @tc.number: uiTest_8001
* @tc.number: uiTest_8001
...
@@ -316,7 +449,7 @@ export default function UiTest() {
...
@@ -316,7 +449,7 @@ export default function UiTest() {
await
startAbility
(
'com.uitestScene.acts'
,
'com.uitestScene.acts.MainAbility'
)
await
startAbility
(
'com.uitestScene.acts'
,
'com.uitestScene.acts.MainAbility'
)
let
driver
=
UiDriver
.
create
()
let
driver
=
UiDriver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
savePath
=
'/data/
local/tmp
/1.png'
let
savePath
=
'/data/
storage/el2/base/cache
/1.png'
let
success
=
await
driver
.
screenCap
(
savePath
)
let
success
=
await
driver
.
screenCap
(
savePath
)
expect
(
success
==
true
)
.
assertTrue
()
expect
(
success
==
true
)
.
assertTrue
()
await
stopApplication
(
'com.uitestScene.acts'
)
await
stopApplication
(
'com.uitestScene.acts'
)
...
@@ -851,7 +984,7 @@ export default function UiTest() {
...
@@ -851,7 +984,7 @@ export default function UiTest() {
await
startAbility
(
'com.uitestScene.acts'
,
'com.uitestScene.acts.MainAbility'
)
await
startAbility
(
'com.uitestScene.acts'
,
'com.uitestScene.acts.MainAbility'
)
let
driver
=
Driver
.
create
()
let
driver
=
Driver
.
create
()
await
driver
.
delayMs
(
waitUiReadyMs
)
await
driver
.
delayMs
(
waitUiReadyMs
)
let
savePath
=
'/data/
local/tmp
/1.png'
let
savePath
=
'/data/
storage/el2/base/cache
/1.png'
let
success
=
await
driver
.
screenCap
(
savePath
)
let
success
=
await
driver
.
screenCap
(
savePath
)
expect
(
success
==
true
)
.
assertTrue
()
expect
(
success
==
true
)
.
assertTrue
()
await
stopApplication
(
'com.uitestScene.acts'
)
await
stopApplication
(
'com.uitestScene.acts'
)
...
...
arkXtest/uitestScene/src/main/ets/MainAbility/pages/index.ets
浏览文件 @
ba077533
...
@@ -19,7 +19,8 @@ import prompt from '@ohos.prompt';
...
@@ -19,7 +19,8 @@ import prompt from '@ohos.prompt';
@Component
@Component
struct ScrollExample {
struct ScrollExample {
scroller: Scroller = new Scroller()
scroller: Scroller = new Scroller()
private arr: number[] = [1,2,3,4]
private arr: number[] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
@State hoverText : string = 'jump'
build() {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
...
@@ -60,12 +61,30 @@ struct ScrollExample {
...
@@ -60,12 +61,30 @@ struct ScrollExample {
})
})
)
)
Button() {
Button() {
Text(
'jump'
)
Text(
this.hoverText
)
.fontSize(25)
.fontSize(25)
.fontWeight(FontWeight.Bold)
.fontWeight(FontWeight.Bold)
}
}
.type(ButtonType.Capsule)
.type(ButtonType.Capsule)
.margin({ top: 20 })
.margin({ top: 20 })
.onHover((isHover: boolean) => {
if (isHover) {
this.hoverText = 'hover'
}
})
.onMouse((event: MouseEvent) => {
switch (event.button) {
case MouseButton.Left :
this.hoverText = 'left'
break
case MouseButton.Right :
this.hoverText = 'right'
break
case MouseButton.Middle :
this.hoverText = 'middle'
break
}
})
.onClick(() => {
.onClick(() => {
router.push({ uri: 'pages/screen' })
router.push({ uri: 'pages/screen' })
})
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录