Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
9c3952cd
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9c3952cd
编写于
9月 12, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(global-events): 调整 program.tap 坐标
上级
2f486a92
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
327 addition
and
349 deletion
+327
-349
pages/API/get-current-pages/get-current-pages.uvue
pages/API/get-current-pages/get-current-pages.uvue
+1
-1
pages/component/global-events/global-events.test.js
pages/component/global-events/global-events.test.js
+326
-348
未找到文件。
pages/API/get-current-pages/get-current-pages.uvue
浏览文件 @
9c3952cd
...
@@ -201,7 +201,7 @@
...
@@ -201,7 +201,7 @@
let res = element != null
let res = element != null
// #ifndef APP-ANDROID
// #ifndef APP-ANDROID
if(res){
if(res){
const elPage = element.getPage()
const elPage = element
!
.getPage()
console.log('elPage', elPage)
console.log('elPage', elPage)
res = elPage === page
res = elPage === page
}
}
...
...
pages/component/global-events/global-events.test.js
浏览文件 @
9c3952cd
const
PAGE_PATH
=
'
/pages/component/global-events/global-events
'
const
PAGE_PATH
=
'
/pages/component/global-events/global-events
'
describe
(
'
event trigger
'
,
()
=>
{
describe
(
'
event trigger
'
,
()
=>
{
if
(
process
.
env
.
UNI_TEST_DEVICES_DIRECTION
==
'
landscape
'
)
{
if
(
process
.
env
.
UNI_TEST_DEVICES_DIRECTION
==
'
landscape
'
)
{
it
(
'
跳过横屏模式
'
,
()
=>
{
it
(
'
跳过横屏模式
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
expect
(
1
).
toBe
(
1
)
})
})
return
return
}
}
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
let
page
let
page
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
await
page
.
waitFor
(
'
view
'
)
})
})
it
(
'
touch
'
,
async
()
=>
{
it
(
'
touch
'
,
async
()
=>
{
if
(
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
if
(
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
const
el
=
await
page
.
$
(
'
#touch-target
'
)
const
el
=
await
page
.
$
(
'
#touch-target
'
)
await
el
.
touchstart
({
await
el
.
touchstart
({
touches
:
[{
touches
:
[{
identifier
:
1
,
identifier
:
1
,
pageX
:
101
,
pageX
:
101
,
pageY
:
101
,
pageY
:
101
,
clientX
:
101
,
clientX
:
101
,
clientY
:
101
,
clientY
:
101
,
screenX
:
101
,
screenX
:
101
,
screenY
:
101
screenY
:
101
},],
},
],
changedTouches
:
[{
changedTouches
:
[{
identifier
:
1
,
identifier
:
1
,
pageX
:
101
,
pageX
:
101
,
pageY
:
101
,
pageY
:
101
,
clientX
:
101
,
clientX
:
101
,
clientY
:
101
,
clientY
:
101
,
screenX
:
101
,
screenX
:
101
,
screenY
:
101
screenY
:
101
},],
},
],
})
})
const
touchStartTouchTargetIdentifier
=
isAndroid
?
'
1.0
'
:
'
1
'
const
touchStartTouchTargetIdentifier
=
isAndroid
?
'
1.0
'
:
'
1
'
const
touchStartTouchTargetValue
=
isAndroid
?
'
101.0
'
:
'
101
'
const
touchStartTouchTargetValue
=
isAndroid
?
'
101.0
'
:
'
101
'
const
touchStartTouchIdentifier
=
await
page
.
$
(
'
#touch-start-touch-identifier
'
)
const
touchStartTouchIdentifier
=
await
page
.
$
(
'
#touch-start-touch-identifier
'
)
expect
(
await
touchStartTouchIdentifier
.
text
()).
toBe
(
touchStartTouchTargetIdentifier
)
expect
(
await
touchStartTouchIdentifier
.
text
()).
toBe
(
touchStartTouchTargetIdentifier
)
const
touchStartTouchPageX
=
await
page
.
$
(
'
#touch-start-touch-page-x
'
)
const
touchStartTouchPageX
=
await
page
.
$
(
'
#touch-start-touch-page-x
'
)
expect
(
await
touchStartTouchPageX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartTouchPageX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartTouchPageY
=
await
page
.
$
(
'
#touch-start-touch-page-y
'
)
const
touchStartTouchPageY
=
await
page
.
$
(
'
#touch-start-touch-page-y
'
)
expect
(
await
touchStartTouchPageY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartTouchPageY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartTouchClientX
=
await
page
.
$
(
'
#touch-start-touch-client-x
'
)
const
touchStartTouchClientX
=
await
page
.
$
(
'
#touch-start-touch-client-x
'
)
expect
(
await
touchStartTouchClientX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartTouchClientX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartTouchClientY
=
await
page
.
$
(
'
#touch-start-touch-client-y
'
)
const
touchStartTouchClientY
=
await
page
.
$
(
'
#touch-start-touch-client-y
'
)
expect
(
await
touchStartTouchClientY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartTouchClientY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartTouchScreenX
=
await
page
.
$
(
'
#touch-start-touch-screen-x
'
)
const
touchStartTouchScreenX
=
await
page
.
$
(
'
#touch-start-touch-screen-x
'
)
expect
(
await
touchStartTouchScreenX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartTouchScreenX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartTouchScreenY
=
await
page
.
$
(
'
#touch-start-touch-screen-y
'
)
const
touchStartTouchScreenY
=
await
page
.
$
(
'
#touch-start-touch-screen-y
'
)
expect
(
await
touchStartTouchScreenY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartTouchScreenY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartChangedTouchIdentifier
=
await
page
.
$
(
'
#touch-start-changed-touch-identifier
'
)
const
touchStartChangedTouchIdentifier
=
await
page
.
$
(
'
#touch-start-changed-touch-identifier
'
)
expect
(
await
touchStartChangedTouchIdentifier
.
text
()).
toBe
(
touchStartTouchTargetIdentifier
)
expect
(
await
touchStartChangedTouchIdentifier
.
text
()).
toBe
(
touchStartTouchTargetIdentifier
)
const
touchStartChangedTouchPageX
=
await
page
.
$
(
'
#touch-start-changed-touch-page-x
'
)
const
touchStartChangedTouchPageX
=
await
page
.
$
(
'
#touch-start-changed-touch-page-x
'
)
expect
(
await
touchStartChangedTouchPageX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartChangedTouchPageX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartChangedTouchPageY
=
await
page
.
$
(
'
#touch-start-changed-touch-page-y
'
)
const
touchStartChangedTouchPageY
=
await
page
.
$
(
'
#touch-start-changed-touch-page-y
'
)
expect
(
await
touchStartChangedTouchPageY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartChangedTouchPageY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartChangedTouchClientX
=
await
page
.
$
(
'
#touch-start-changed-touch-client-x
'
)
const
touchStartChangedTouchClientX
=
await
page
.
$
(
'
#touch-start-changed-touch-client-x
'
)
expect
(
await
touchStartChangedTouchClientX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartChangedTouchClientX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartChangedTouchClientY
=
await
page
.
$
(
'
#touch-start-changed-touch-client-y
'
)
const
touchStartChangedTouchClientY
=
await
page
.
$
(
'
#touch-start-changed-touch-client-y
'
)
expect
(
await
touchStartChangedTouchClientY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartChangedTouchClientY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartChangedTouchScreenX
=
await
page
.
$
(
'
#touch-start-changed-touch-screen-x
'
)
const
touchStartChangedTouchScreenX
=
await
page
.
$
(
'
#touch-start-changed-touch-screen-x
'
)
expect
(
await
touchStartChangedTouchScreenX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartChangedTouchScreenX
.
text
()).
toBe
(
touchStartTouchTargetValue
)
const
touchStartChangedTouchScreenY
=
await
page
.
$
(
'
#touch-start-changed-touch-screen-y
'
)
const
touchStartChangedTouchScreenY
=
await
page
.
$
(
'
#touch-start-changed-touch-screen-y
'
)
expect
(
await
touchStartChangedTouchScreenY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
expect
(
await
touchStartChangedTouchScreenY
.
text
()).
toBe
(
touchStartTouchTargetValue
)
await
el
.
touchmove
({
await
el
.
touchmove
({
touches
:
[{
touches
:
[{
identifier
:
1
,
identifier
:
1
,
pageX
:
102
,
pageX
:
102
,
pageY
:
102
,
pageY
:
102
,
clientX
:
102
,
clientX
:
102
,
clientY
:
102
,
clientY
:
102
,
screenX
:
102
,
screenX
:
102
,
screenY
:
102
screenY
:
102
}],
}],
changedTouches
:
[{
changedTouches
:
[{
identifier
:
1
,
identifier
:
1
,
pageX
:
102
,
pageX
:
102
,
pageY
:
102
,
pageY
:
102
,
clientX
:
102
,
clientX
:
102
,
clientY
:
102
,
clientY
:
102
,
screenX
:
102
,
screenX
:
102
,
screenY
:
102
screenY
:
102
},],
},
],
})
})
const
touchMoveTouchTargetIdentifier
=
isAndroid
?
'
1.0
'
:
'
1
'
const
touchMoveTouchTargetIdentifier
=
isAndroid
?
'
1.0
'
:
'
1
'
const
touchMoveTouchTargetValue
=
isAndroid
?
'
102.0
'
:
'
102
'
const
touchMoveTouchTargetValue
=
isAndroid
?
'
102.0
'
:
'
102
'
const
touchMoveTouchIdentifier
=
await
page
.
$
(
'
#touch-move-touch-identifier
'
)
const
touchMoveTouchIdentifier
=
await
page
.
$
(
'
#touch-move-touch-identifier
'
)
expect
(
await
touchMoveTouchIdentifier
.
text
()).
toBe
(
touchMoveTouchTargetIdentifier
)
expect
(
await
touchMoveTouchIdentifier
.
text
()).
toBe
(
touchMoveTouchTargetIdentifier
)
const
touchMoveTouchPageX
=
await
page
.
$
(
'
#touch-move-touch-page-x
'
)
const
touchMoveTouchPageX
=
await
page
.
$
(
'
#touch-move-touch-page-x
'
)
expect
(
await
touchMoveTouchPageX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveTouchPageX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveTouchPageY
=
await
page
.
$
(
'
#touch-move-touch-page-y
'
)
const
touchMoveTouchPageY
=
await
page
.
$
(
'
#touch-move-touch-page-y
'
)
expect
(
await
touchMoveTouchPageY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveTouchPageY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveTouchClientX
=
await
page
.
$
(
'
#touch-move-touch-client-x
'
)
const
touchMoveTouchClientX
=
await
page
.
$
(
'
#touch-move-touch-client-x
'
)
expect
(
await
touchMoveTouchClientX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveTouchClientX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveTouchClientY
=
await
page
.
$
(
'
#touch-move-touch-client-y
'
)
const
touchMoveTouchClientY
=
await
page
.
$
(
'
#touch-move-touch-client-y
'
)
expect
(
await
touchMoveTouchClientY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveTouchClientY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveTouchScreenX
=
await
page
.
$
(
'
#touch-move-touch-screen-x
'
)
const
touchMoveTouchScreenX
=
await
page
.
$
(
'
#touch-move-touch-screen-x
'
)
expect
(
await
touchMoveTouchScreenX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveTouchScreenX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveTouchScreenY
=
await
page
.
$
(
'
#touch-move-touch-screen-y
'
)
const
touchMoveTouchScreenY
=
await
page
.
$
(
'
#touch-move-touch-screen-y
'
)
expect
(
await
touchMoveTouchScreenY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveTouchScreenY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveChangedTouchIdentifier
=
await
page
.
$
(
'
#touch-move-changed-touch-identifier
'
)
const
touchMoveChangedTouchIdentifier
=
await
page
.
$
(
'
#touch-move-changed-touch-identifier
'
)
expect
(
await
touchMoveChangedTouchIdentifier
.
text
()).
toBe
(
touchMoveTouchTargetIdentifier
)
expect
(
await
touchMoveChangedTouchIdentifier
.
text
()).
toBe
(
touchMoveTouchTargetIdentifier
)
const
touchMoveChangedTouchPageX
=
await
page
.
$
(
'
#touch-move-changed-touch-page-x
'
)
const
touchMoveChangedTouchPageX
=
await
page
.
$
(
'
#touch-move-changed-touch-page-x
'
)
expect
(
await
touchMoveChangedTouchPageX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveChangedTouchPageX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveChangedTouchPageY
=
await
page
.
$
(
'
#touch-move-changed-touch-page-y
'
)
const
touchMoveChangedTouchPageY
=
await
page
.
$
(
'
#touch-move-changed-touch-page-y
'
)
expect
(
await
touchMoveChangedTouchPageY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveChangedTouchPageY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveChangedTouchClientX
=
await
page
.
$
(
'
#touch-move-changed-touch-client-x
'
)
const
touchMoveChangedTouchClientX
=
await
page
.
$
(
'
#touch-move-changed-touch-client-x
'
)
expect
(
await
touchMoveChangedTouchClientX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveChangedTouchClientX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveChangedTouchClientY
=
await
page
.
$
(
'
#touch-move-changed-touch-client-y
'
)
const
touchMoveChangedTouchClientY
=
await
page
.
$
(
'
#touch-move-changed-touch-client-y
'
)
expect
(
await
touchMoveChangedTouchClientY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveChangedTouchClientY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveChangedTouchScreenX
=
await
page
.
$
(
'
#touch-move-changed-touch-screen-x
'
)
const
touchMoveChangedTouchScreenX
=
await
page
.
$
(
'
#touch-move-changed-touch-screen-x
'
)
expect
(
await
touchMoveChangedTouchScreenX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveChangedTouchScreenX
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
const
touchMoveChangedTouchScreenY
=
await
page
.
$
(
'
#touch-move-changed-touch-screen-y
'
)
const
touchMoveChangedTouchScreenY
=
await
page
.
$
(
'
#touch-move-changed-touch-screen-y
'
)
expect
(
await
touchMoveChangedTouchScreenY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
expect
(
await
touchMoveChangedTouchScreenY
.
text
()).
toBe
(
touchMoveTouchTargetValue
)
await
el
.
touchend
({
await
el
.
touchend
({
touches
:
[{
touches
:
[{
identifier
:
1
,
identifier
:
1
,
pageX
:
103
,
pageX
:
103
,
pageY
:
103
,
pageY
:
103
,
clientX
:
103
,
clientX
:
103
,
clientY
:
103
,
clientY
:
103
,
screenX
:
103
,
screenX
:
103
,
screenY
:
103
screenY
:
103
}],
}],
changedTouches
:
[{
changedTouches
:
[{
identifier
:
1
,
identifier
:
1
,
pageX
:
103
,
pageX
:
103
,
pageY
:
103
,
pageY
:
103
,
clientX
:
103
,
clientX
:
103
,
clientY
:
103
,
clientY
:
103
,
screenX
:
103
,
screenX
:
103
,
screenY
:
103
screenY
:
103
},],
},
],
})
})
const
touchEndTouchTargetIdentifier
=
isAndroid
?
'
1.0
'
:
'
1
'
const
touchEndTouchTargetIdentifier
=
isAndroid
?
'
1.0
'
:
'
1
'
const
touchEndTouchTargetValue
=
isAndroid
?
'
103.0
'
:
'
103
'
const
touchEndTouchTargetValue
=
isAndroid
?
'
103.0
'
:
'
103
'
const
touchEndTouchIdentifier
=
await
page
.
$
(
'
#touch-end-touch-identifier
'
)
const
touchEndTouchIdentifier
=
await
page
.
$
(
'
#touch-end-touch-identifier
'
)
expect
(
await
touchEndTouchIdentifier
.
text
()).
toBe
(
touchEndTouchTargetIdentifier
)
expect
(
await
touchEndTouchIdentifier
.
text
()).
toBe
(
touchEndTouchTargetIdentifier
)
const
touchEndTouchPageX
=
await
page
.
$
(
'
#touch-end-touch-page-x
'
)
const
touchEndTouchPageX
=
await
page
.
$
(
'
#touch-end-touch-page-x
'
)
expect
(
await
touchEndTouchPageX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndTouchPageX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndTouchPageY
=
await
page
.
$
(
'
#touch-end-touch-page-y
'
)
const
touchEndTouchPageY
=
await
page
.
$
(
'
#touch-end-touch-page-y
'
)
expect
(
await
touchEndTouchPageY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndTouchPageY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndTouchClientX
=
await
page
.
$
(
'
#touch-end-touch-client-x
'
)
const
touchEndTouchClientX
=
await
page
.
$
(
'
#touch-end-touch-client-x
'
)
expect
(
await
touchEndTouchClientX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndTouchClientX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndTouchClientY
=
await
page
.
$
(
'
#touch-end-touch-client-y
'
)
const
touchEndTouchClientY
=
await
page
.
$
(
'
#touch-end-touch-client-y
'
)
expect
(
await
touchEndTouchClientY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndTouchClientY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndTouchScreenX
=
await
page
.
$
(
'
#touch-end-touch-screen-x
'
)
const
touchEndTouchScreenX
=
await
page
.
$
(
'
#touch-end-touch-screen-x
'
)
expect
(
await
touchEndTouchScreenX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndTouchScreenX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndTouchScreenY
=
await
page
.
$
(
'
#touch-end-touch-screen-y
'
)
const
touchEndTouchScreenY
=
await
page
.
$
(
'
#touch-end-touch-screen-y
'
)
expect
(
await
touchEndTouchScreenY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndTouchScreenY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndChangedTouchIdentifier
=
await
page
.
$
(
'
#touch-end-changed-touch-identifier
'
)
const
touchEndChangedTouchIdentifier
=
await
page
.
$
(
'
#touch-end-changed-touch-identifier
'
)
expect
(
await
touchEndChangedTouchIdentifier
.
text
()).
toBe
(
touchEndTouchTargetIdentifier
)
expect
(
await
touchEndChangedTouchIdentifier
.
text
()).
toBe
(
touchEndTouchTargetIdentifier
)
const
touchEndChangedTouchPageX
=
await
page
.
$
(
'
#touch-end-changed-touch-page-x
'
)
const
touchEndChangedTouchPageX
=
await
page
.
$
(
'
#touch-end-changed-touch-page-x
'
)
expect
(
await
touchEndChangedTouchPageX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndChangedTouchPageX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndChangedTouchPageY
=
await
page
.
$
(
'
#touch-end-changed-touch-page-y
'
)
const
touchEndChangedTouchPageY
=
await
page
.
$
(
'
#touch-end-changed-touch-page-y
'
)
expect
(
await
touchEndChangedTouchPageY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndChangedTouchPageY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndChangedTouchClientX
=
await
page
.
$
(
'
#touch-end-changed-touch-client-x
'
)
const
touchEndChangedTouchClientX
=
await
page
.
$
(
'
#touch-end-changed-touch-client-x
'
)
expect
(
await
touchEndChangedTouchClientX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndChangedTouchClientX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndChangedTouchClientY
=
await
page
.
$
(
'
#touch-end-changed-touch-client-y
'
)
const
touchEndChangedTouchClientY
=
await
page
.
$
(
'
#touch-end-changed-touch-client-y
'
)
expect
(
await
touchEndChangedTouchClientY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndChangedTouchClientY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndChangedTouchScreenX
=
await
page
.
$
(
'
#touch-end-changed-touch-screen-x
'
)
const
touchEndChangedTouchScreenX
=
await
page
.
$
(
'
#touch-end-changed-touch-screen-x
'
)
expect
(
await
touchEndChangedTouchScreenX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndChangedTouchScreenX
.
text
()).
toBe
(
touchEndTouchTargetValue
)
const
touchEndChangedTouchScreenY
=
await
page
.
$
(
'
#touch-end-changed-touch-screen-y
'
)
const
touchEndChangedTouchScreenY
=
await
page
.
$
(
'
#touch-end-changed-touch-screen-y
'
)
expect
(
await
touchEndChangedTouchScreenY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
expect
(
await
touchEndChangedTouchScreenY
.
text
()).
toBe
(
touchEndTouchTargetValue
)
}
}
})
})
it
(
'
click
'
,
async
()
=>
{
it
(
'
click
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
#longpress-target
'
)
const
el
=
await
page
.
$
(
'
#longpress-target
'
)
await
el
.
tap
()
await
el
.
tap
()
const
targetX
=
isAndroid
?
'
0.0
'
:
'
0
'
const
targetX
=
isAndroid
?
'
0.0
'
:
'
0
'
const
targetY
=
isAndroid
?
'
0.0
'
:
'
0
'
const
targetY
=
isAndroid
?
'
0.0
'
:
'
0
'
const
tapEventX
=
await
page
.
$
(
'
#tap-event-x
'
)
const
tapEventX
=
await
page
.
$
(
'
#tap-event-x
'
)
expect
(
await
tapEventX
.
text
()).
toBe
(
targetX
)
expect
(
await
tapEventX
.
text
()).
toBe
(
targetX
)
const
tapEventY
=
await
page
.
$
(
'
#tap-event-y
'
)
const
tapEventY
=
await
page
.
$
(
'
#tap-event-y
'
)
expect
(
await
tapEventY
.
text
()).
toBe
(
targetY
)
expect
(
await
tapEventY
.
text
()).
toBe
(
targetY
)
const
clickEventX
=
await
page
.
$
(
'
#click-event-x
'
)
const
clickEventX
=
await
page
.
$
(
'
#click-event-x
'
)
expect
(
await
clickEventX
.
text
()).
toBe
(
targetX
)
expect
(
await
clickEventX
.
text
()).
toBe
(
targetX
)
const
clickEventY
=
await
page
.
$
(
'
#click-event-y
'
)
const
clickEventY
=
await
page
.
$
(
'
#click-event-y
'
)
expect
(
await
clickEventY
.
text
()).
toBe
(
targetY
)
expect
(
await
clickEventY
.
text
()).
toBe
(
targetY
)
})
})
it
(
'
longPress
'
,
async
()
=>
{
it
(
'
longPress
'
,
async
()
=>
{
if
(
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
if
(
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
const
el
=
await
page
.
$
(
'
#longpress-target
'
)
const
el
=
await
page
.
$
(
'
#longpress-target
'
)
await
el
.
longpress
()
await
el
.
longpress
()
const
longPressTouchTargetIdentifier
=
isAndroid
?
'
1.0
'
:
'
1
'
const
longPressTouchTargetIdentifier
=
isAndroid
?
'
1.0
'
:
'
1
'
const
longPressTouchTargetValue
=
isAndroid
?
'
0.0
'
:
'
0
'
const
longPressTouchTargetValue
=
isAndroid
?
'
0.0
'
:
'
0
'
const
longPressTouchIdentifier
=
await
page
.
$
(
'
#long-press-touch-identifier
'
)
const
longPressTouchIdentifier
=
await
page
.
$
(
'
#long-press-touch-identifier
'
)
expect
(
await
longPressTouchIdentifier
.
text
()).
toBe
(
longPressTouchTargetIdentifier
)
expect
(
await
longPressTouchIdentifier
.
text
()).
toBe
(
longPressTouchTargetIdentifier
)
const
longPressTouchPageX
=
await
page
.
$
(
'
#long-press-touch-page-x
'
)
const
longPressTouchPageX
=
await
page
.
$
(
'
#long-press-touch-page-x
'
)
expect
(
await
longPressTouchPageX
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressTouchPageX
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressTouchPageY
=
await
page
.
$
(
'
#long-press-touch-page-y
'
)
const
longPressTouchPageY
=
await
page
.
$
(
'
#long-press-touch-page-y
'
)
expect
(
await
longPressTouchPageY
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressTouchPageY
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressTouchClientX
=
await
page
.
$
(
'
#long-press-touch-client-x
'
)
const
longPressTouchClientX
=
await
page
.
$
(
'
#long-press-touch-client-x
'
)
expect
(
await
longPressTouchClientX
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressTouchClientX
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressTouchClientY
=
await
page
.
$
(
'
#long-press-touch-client-y
'
)
const
longPressTouchClientY
=
await
page
.
$
(
'
#long-press-touch-client-y
'
)
expect
(
await
longPressTouchClientY
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressTouchClientY
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressTouchScreenX
=
await
page
.
$
(
'
#long-press-touch-screen-x
'
)
const
longPressTouchScreenX
=
await
page
.
$
(
'
#long-press-touch-screen-x
'
)
expect
(
await
longPressTouchScreenX
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressTouchScreenX
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressTouchScreenY
=
await
page
.
$
(
'
#long-press-touch-screen-y
'
)
const
longPressTouchScreenY
=
await
page
.
$
(
'
#long-press-touch-screen-y
'
)
expect
(
await
longPressTouchScreenY
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressTouchScreenY
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchIdentifier
=
await
page
.
$
(
'
#long-press-changed-touch-identifier
'
)
const
longPressChangedTouchIdentifier
=
await
page
.
$
(
'
#long-press-changed-touch-identifier
'
)
expect
(
await
longPressChangedTouchIdentifier
.
text
()).
toBe
(
longPressTouchTargetIdentifier
)
expect
(
await
longPressChangedTouchIdentifier
.
text
()).
toBe
(
longPressTouchTargetIdentifier
)
const
longPressChangedTouchPageX
=
await
page
.
$
(
'
#long-press-changed-touch-page-x
'
)
const
longPressChangedTouchPageX
=
await
page
.
$
(
'
#long-press-changed-touch-page-x
'
)
expect
(
await
longPressChangedTouchPageX
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressChangedTouchPageX
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchPageY
=
await
page
.
$
(
'
#long-press-changed-touch-page-y
'
)
const
longPressChangedTouchPageY
=
await
page
.
$
(
'
#long-press-changed-touch-page-y
'
)
expect
(
await
longPressChangedTouchPageY
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressChangedTouchPageY
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchClientX
=
await
page
.
$
(
'
#long-press-changed-touch-client-x
'
)
const
longPressChangedTouchClientX
=
await
page
.
$
(
'
#long-press-changed-touch-client-x
'
)
expect
(
await
longPressChangedTouchClientX
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressChangedTouchClientX
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchClientY
=
await
page
.
$
(
'
#long-press-changed-touch-client-y
'
)
const
longPressChangedTouchClientY
=
await
page
.
$
(
'
#long-press-changed-touch-client-y
'
)
expect
(
await
longPressChangedTouchClientY
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressChangedTouchClientY
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchScreenX
=
await
page
.
$
(
'
#long-press-changed-touch-screen-x
'
)
const
longPressChangedTouchScreenX
=
await
page
.
$
(
'
#long-press-changed-touch-screen-x
'
)
expect
(
await
longPressChangedTouchScreenX
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressChangedTouchScreenX
.
text
()).
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchScreenY
=
await
page
.
$
(
'
#long-press-changed-touch-screen-y
'
)
const
longPressChangedTouchScreenY
=
await
page
.
$
(
'
#long-press-changed-touch-screen-y
'
)
expect
(
await
longPressChangedTouchScreenY
.
text
()).
toBe
(
longPressTouchTargetValue
)
expect
(
await
longPressChangedTouchScreenY
.
text
()).
toBe
(
longPressTouchTargetValue
)
if
(
isAndroid
||
isIos
)
{
if
(
isAndroid
||
isIos
)
{
if
(
isAndroid
)
{
if
(
isIos
)
{
if
(
platformInfo
.
indexOf
(
'
6
'
)
!=
-
1
&&
platformInfo
.
indexOf
(
'
x86
'
)
==
-
1
)
{
// 规避系统授权弹框
await
program
.
tap
({
await
program
.
tap
({
x
:
200
,
x
:
100
,
y
:
700
,
y
:
500
,
duration
:
1000
})
})
}
}
else
if
(
platformInfo
.
indexOf
(
'
12
'
)
!=
-
1
)
{
await
program
.
tap
({
await
program
.
tap
({
x
:
200
,
x
:
300
,
y
:
400
,
y
:
1100
,
duration
:
1000
duration
:
1000
})
})
const
longPressTouchIdentifierText
=
await
longPressTouchIdentifier
.
text
()
}
else
{
expect
(
longPressTouchIdentifierText
).
not
.
toBe
(
longPressTouchTargetIdentifier
)
await
program
.
tap
({
expect
(
longPressTouchIdentifierText
).
toBeTruthy
()
x
:
200
,
const
longPressTouchPageXText
=
await
longPressTouchPageX
.
text
()
y
:
1000
,
expect
(
longPressTouchPageXText
).
not
.
toBe
(
longPressTouchTargetValue
)
duration
:
1000
expect
(
longPressTouchPageXText
).
toBeTruthy
()
})
const
longPressTouchPageYText
=
await
longPressTouchPageY
.
text
()
}
expect
(
longPressTouchPageYText
).
not
.
toBe
(
longPressTouchTargetValue
)
}
else
if
(
isIos
)
{
expect
(
longPressTouchPageYText
).
toBeTruthy
()
// 规避系统授权弹框
const
longPressTouchClientXText
=
await
longPressTouchClientX
.
text
()
await
program
.
tap
({
expect
(
longPressTouchClientXText
).
not
.
toBe
(
longPressTouchTargetValue
)
x
:
100
,
expect
(
longPressTouchClientXText
).
toBeTruthy
()
y
:
500
,
const
longPressTouchClientYText
=
await
longPressTouchClientY
.
text
()
})
expect
(
longPressTouchClientYText
).
not
.
toBe
(
longPressTouchTargetValue
)
await
program
.
tap
({
expect
(
longPressTouchClientYText
).
toBeTruthy
()
x
:
200
,
const
longPressTouchScreenXText
=
await
longPressTouchScreenX
.
text
()
y
:
400
,
expect
(
longPressTouchScreenXText
).
not
.
toBe
(
longPressTouchTargetValue
)
duration
:
1000
expect
(
longPressTouchScreenXText
).
toBeTruthy
()
})
const
longPressTouchScreenYText
=
await
longPressTouchScreenY
.
text
()
}
expect
(
longPressTouchScreenYText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressTouchIdentifierText
=
await
longPressTouchIdentifier
.
text
()
expect
(
longPressTouchScreenYText
).
toBeTruthy
()
expect
(
longPressTouchIdentifierText
).
not
.
toBe
(
longPressTouchTargetIdentifier
)
const
longPressChangedTouchIdentifierText
=
await
longPressChangedTouchIdentifier
.
text
()
expect
(
longPressTouchIdentifierText
).
toBeTruthy
()
expect
(
longPressChangedTouchIdentifierText
).
not
.
toBe
(
longPressTouchTargetIdentifier
)
const
longPressTouchPageXText
=
await
longPressTouchPageX
.
text
()
expect
(
longPressChangedTouchIdentifierText
).
toBeTruthy
()
expect
(
longPressTouchPageXText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchPageXText
=
await
longPressChangedTouchPageX
.
text
()
expect
(
longPressTouchPageXText
).
toBeTruthy
()
expect
(
longPressChangedTouchPageXText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressTouchPageYText
=
await
longPressTouchPageY
.
text
()
expect
(
longPressChangedTouchPageXText
).
toBeTruthy
()
expect
(
longPressTouchPageYText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchPageYText
=
await
longPressChangedTouchPageY
.
text
()
expect
(
longPressTouchPageYText
).
toBeTruthy
()
expect
(
longPressChangedTouchPageYText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressTouchClientXText
=
await
longPressTouchClientX
.
text
()
expect
(
longPressChangedTouchPageYText
).
toBeTruthy
()
expect
(
longPressTouchClientXText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchClientXText
=
await
longPressChangedTouchClientX
.
text
()
expect
(
longPressTouchClientXText
).
toBeTruthy
()
expect
(
longPressChangedTouchClientXText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressTouchClientYText
=
await
longPressTouchClientY
.
text
()
expect
(
longPressChangedTouchClientXText
).
toBeTruthy
()
expect
(
longPressTouchClientYText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchClientYText
=
await
longPressChangedTouchClientY
.
text
()
expect
(
longPressTouchClientYText
).
toBeTruthy
()
expect
(
longPressChangedTouchClientYText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressTouchScreenXText
=
await
longPressTouchScreenX
.
text
()
expect
(
longPressChangedTouchClientYText
).
toBeTruthy
()
expect
(
longPressTouchScreenXText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchScreenXText
=
await
longPressChangedTouchScreenX
.
text
()
expect
(
longPressTouchScreenXText
).
toBeTruthy
()
expect
(
longPressChangedTouchScreenXText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressTouchScreenYText
=
await
longPressTouchScreenY
.
text
()
expect
(
longPressChangedTouchScreenXText
).
toBeTruthy
()
expect
(
longPressTouchScreenYText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchScreenYText
=
await
longPressChangedTouchScreenY
.
text
()
expect
(
longPressTouchScreenYText
).
toBeTruthy
()
expect
(
longPressChangedTouchScreenYText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
longPressChangedTouchIdentifierText
=
await
longPressChangedTouchIdentifier
.
text
()
expect
(
longPressChangedTouchScreenYText
).
toBeTruthy
()
expect
(
longPressChangedTouchIdentifierText
).
not
.
toBe
(
longPressTouchTargetIdentifier
)
}
expect
(
longPressChangedTouchIdentifierText
).
toBeTruthy
()
}
const
longPressChangedTouchPageXText
=
await
longPressChangedTouchPageX
.
text
()
})
expect
(
longPressChangedTouchPageXText
).
not
.
toBe
(
longPressTouchTargetValue
)
expect
(
longPressChangedTouchPageXText
).
toBeTruthy
()
it
(
'
mock tap event
'
,
async
()
=>
{
const
longPressChangedTouchPageYText
=
await
longPressChangedTouchPageY
.
text
()
expect
(
longPressChangedTouchPageYText
).
not
.
toBe
(
longPressTouchTargetValue
)
// ios only 坐标换算准确
expect
(
longPressChangedTouchPageYText
).
toBeTruthy
()
if
(
isIos
)
{
const
longPressChangedTouchClientXText
=
await
longPressChangedTouchClientX
.
text
()
expect
(
longPressChangedTouchClientXText
).
not
.
toBe
(
longPressTouchTargetValue
)
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
expect
(
longPressChangedTouchClientXText
).
toBeTruthy
()
await
page
.
waitFor
(
'
view
'
)
const
longPressChangedTouchClientYText
=
await
longPressChangedTouchClientY
.
text
()
const
el
=
await
page
.
$
(
'
#longpress-target
'
)
expect
(
longPressChangedTouchClientYText
).
not
.
toBe
(
longPressTouchTargetValue
)
expect
(
longPressChangedTouchClientYText
).
toBeTruthy
()
const
size
=
await
el
.
size
()
const
longPressChangedTouchScreenXText
=
await
longPressChangedTouchScreenX
.
text
()
const
position
=
await
el
.
offset
()
expect
(
longPressChangedTouchScreenXText
).
not
.
toBe
(
longPressTouchTargetValue
)
// console.log('position', position)
expect
(
longPressChangedTouchScreenXText
).
toBeTruthy
()
// console.log('size', size);
const
longPressChangedTouchScreenYText
=
await
longPressChangedTouchScreenY
.
text
()
const
x
=
position
.
left
+
size
.
width
/
2.0
expect
(
longPressChangedTouchScreenYText
).
not
.
toBe
(
longPressTouchTargetValue
)
const
y
=
position
.
top
+
size
.
height
/
2.0
expect
(
longPressChangedTouchScreenYText
).
toBeTruthy
()
const
res
=
await
uni
.
getWindowInfo
();
}
// console.log('res', res.statusBarHeight);
}
const
baseStatusTextHeight
=
44
})
const
baseTop
=
res
.
statusBarHeight
??
0
it
(
'
mock tap event
'
,
async
()
=>
{
await
program
.
tap
({
x
:
x
,
// ios only 坐标换算准确
y
:
y
+
baseTop
+
baseStatusTextHeight
,
if
(
isIos
)
{
duration
:
100
})
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
await
page
.
waitFor
(
'
view
'
)
const
el
=
await
page
.
$
(
'
#longpress-target
'
)
const
clickEventX
=
await
page
.
$
(
'
#click-event-x
'
)
const
StringX
=
await
clickEventX
.
text
()
const
size
=
await
el
.
size
()
const
position
=
await
el
.
offset
()
expect
(
Number
(
StringX
)).
toBeGreaterThan
(
0
)
// console.log('position', position)
const
clickEventY
=
await
page
.
$
(
'
#click-event-y
'
)
// console.log('size', size);
const
StringY
=
await
clickEventY
.
text
()
const
x
=
position
.
left
+
size
.
width
/
2.0
expect
(
Number
(
StringY
)).
toBeGreaterThan
(
0
)
const
y
=
position
.
top
+
size
.
height
/
2.0
}
else
{
const
res
=
await
uni
.
getWindowInfo
();
expect
(
1
).
toBe
(
1
)
// console.log('res', res.statusBarHeight);
}
const
baseStatusTextHeight
=
44
})
const
baseTop
=
res
.
statusBarHeight
??
0
await
program
.
tap
({
x
:
x
,
y
:
y
+
baseTop
+
baseStatusTextHeight
,
duration
:
100
})
await
page
.
waitFor
(
500
)
const
clickEventX
=
await
page
.
$
(
'
#click-event-x
'
)
const
StringX
=
await
clickEventX
.
text
()
expect
(
Number
(
StringX
)).
toBeGreaterThan
(
0
)
const
clickEventY
=
await
page
.
$
(
'
#click-event-y
'
)
const
StringY
=
await
clickEventY
.
text
()
expect
(
Number
(
StringY
)).
toBeGreaterThan
(
0
)
}
else
{
expect
(
1
).
toBe
(
1
)
}
})
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录