Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
4047b74b
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
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看板
提交
4047b74b
编写于
9月 12, 2024
作者:
DCloud_iOS_XHY
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增 touch-events-bubbles.test.js 自动化测试例测试 touch 事件冒泡
上级
9c3952cd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
199 addition
and
1 deletion
+199
-1
pages/component/global-events/touch-events-bubbles.test.js
pages/component/global-events/touch-events-bubbles.test.js
+65
-0
pages/component/global-events/touch-events-bubbles.uvue
pages/component/global-events/touch-events-bubbles.uvue
+132
-0
pages/component/global-events/touch-events.uvue
pages/component/global-events/touch-events.uvue
+1
-1
testSequencer.js
testSequencer.js
+1
-0
未找到文件。
pages/component/global-events/touch-events-bubbles.test.js
0 → 100644
浏览文件 @
4047b74b
const
PAGE_PATH
=
'
/pages/component/global-events/touch-events-bubbles
'
describe
(
'
touch-events-test
'
,
()
=>
{
// 先屏蔽 android 及 web 平台
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
it
(
'
other platform
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
if
(
process
.
env
.
UNI_TEST_DEVICES_DIRECTION
==
'
landscape
'
)
{
it
(
'
跳过横屏模式
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
);
})
it
(
'
touch-event-bubbles-test1
'
,
async
()
=>
{
let
iconRect
=
await
page
.
data
(
'
iconRect
'
)
let
x
=
iconRect
.
x
+
iconRect
.
width
/
2.0
let
y
=
iconRect
.
y
+
5
// 滑动事件
await
program
.
swipe
({
startPoint
:
{
x
:
x
,
y
:
y
},
endPoint
:
{
x
:
x
,
y
:
y
+
35
},
duration
:
200
})
await
page
.
waitFor
(
1500
);
await
page
.
callMethod
(
'
isPassTest1
'
)
const
ret
=
await
page
.
data
(
'
ret1
'
)
expect
(
ret
).
toBe
(
true
)
})
it
(
'
touch-event-bubbles-test2
'
,
async
()
=>
{
let
viewEleRect
=
await
page
.
data
(
'
viewEleRect
'
)
let
x
=
viewEleRect
.
x
+
viewEleRect
.
width
/
2.0
let
y
=
viewEleRect
.
y
+
5
// 滑动事件
await
program
.
swipe
({
startPoint
:
{
x
:
x
,
y
:
y
},
endPoint
:
{
x
:
x
,
y
:
y
+
35
},
duration
:
200
})
await
page
.
waitFor
(
1500
);
await
page
.
callMethod
(
'
isPassTest2
'
)
const
ret
=
await
page
.
data
(
'
ret2
'
)
expect
(
ret
).
toBe
(
true
)
})
})
pages/component/global-events/touch-events-bubbles.uvue
0 → 100644
浏览文件 @
4047b74b
<template>
<scroll-view style="flex: 1">
<page-head title="事件冒泡测试"></page-head>
<view class="container">
<view class="view-box" id="view1" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd">
<view class="mid-view" id="view1-2" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd">
<image class="icon" id="view1-3" src="../image/logo.png" @touchstart="onTouchStart" @touchmove="onTouchMove"
@touchend="onTouchEnd"></image>
</view>
</view>
<view class="view-box" id="view2" @touchstart="onTouchStart" @touchmove="onTouchMove" @touchend="onTouchEnd">
<view class="mid-view" id="view2-2" @touchend="onTouchEnd">
<view style="background-color: beige;" class="icon" id="view2-3" @touchstart="onTouchStart" @touchend="onTouchEnd"></view>
</view>
</view>
</view>
</scroll-view>
</template>
<script>
export default {
data() {
return {
iconRect: null as DOMRect | null,
viewEleRect: null as DOMRect | null,
touchstartValue: [],
touchmoveValue: [],
touchendValue: [],
ret1: false,
ret2: false
}
},
onReady() {
// #ifdef APP-IOS
let iconEle = uni.getElementById("view1-3")
this.iconRect = iconEle?.getBoundingClientRect()
// 加上导航栏及状态栏高度
this.iconRect.y += uni.getSystemInfoSync().safeArea.top + 44
let viewEle = uni.getElementById("view2-3")
this.viewEleRect = viewEle?.getBoundingClientRect()
// 加上导航栏及状态栏高度
this.viewEleRect.y += uni.getSystemInfoSync().safeArea.top + 44
// #endif
},
methods: {
clearValue() {
this.touchstartValue = []
this.touchmoveValue = []
this.touchendValue = []
},
isPassTest1() {
let result = this.touchstartValue.join("") == "view1-3view1-2view1" &&
this.touchmoveValue.join("") == "view1-3view1-2view1" &&
this.touchendValue.join("") == "view1-3view1-2view1"
console.log('isPassTest1', result)
this.ret1 = result
this.clearValue()
},
isPassTest2() {
let result = this.touchstartValue.join("") == "view2-3view2" &&
this.touchmoveValue.join("") == "view2" &&
this.touchendValue.join("") == "view2-3view2-2view2"
console.log('isPassTest2', result)
this.ret2 = result
this.clearValue()
},
onTouchStart(e : TouchEvent) {
let _id = e.currentTarget!.attributes.get("id")
if (!this.touchstartValue.includes(_id)) {
this.touchstartValue.push(_id)
}
console.log('onTouchStart', e.currentTarget!.attributes.get("id"))
},
onTouchMove(e : TouchEvent) {
let _id = e.currentTarget!.attributes.get("id")
if (!this.touchmoveValue.includes(_id)) {
this.touchmoveValue.push(_id)
}
console.log('onTouchMove', e.currentTarget!.attributes.get("id"))
},
onTouchEnd(e : TouchEvent) {
let _id = e.currentTarget!.attributes.get("id")
if (!this.touchendValue.includes(_id)) {
this.touchendValue.push(_id)
}
}
}
}
</script>
<style>
.container {
width: 100%;
height: 80%;
flex-direction: column;
align-items: center;
justify-content: space-between;
}
.view-box {
width: 200px;
height: 200px;
align-items: center;
justify-content: center;
border-style: solid;
}
.mid-view {
width: 150px;
height: 150px;
align-items: center;
justify-content: center;
background-color: aqua;
}
.icon {
width: 100px;
height: 100px;
}
</style>
pages/component/global-events/touch-events.uvue
浏览文件 @
4047b74b
...
...
@@ -49,7 +49,7 @@
onViewTouchStart(e : TouchEvent) {
this.touchTargets += e.target!.tagName + e.currentTarget!.tagName
this.touchTargetsCount++
console.log(this.touchTargets, this.touchTargetsCount)
//
console.log(this.touchTargets, this.touchTargetsCount)
},
onTouchStart(e : TouchEvent) {
this.touchTargetsCount++
...
...
testSequencer.js
浏览文件 @
4047b74b
...
...
@@ -6,6 +6,7 @@ const sortTestFilePaths = [
"
pages/component/list-view/list-view-refresh.test.js
"
,
"
pages/component/scroll-view/scroll-view-refresher.test.js
"
,
"
pages/component/global-events/touch-events.test.js
"
,
"
pages/component/global-events/touch-events-bubbles.test.js
"
,
"
pages/component/swiper/swiper2.test.js
"
,
"
pages/component/rich-text/rich-text-complex.test.js
"
]
...
...
DCloud_iOS_XHY
@u011616665
mentioned in commit
530e17ab
·
9月 12, 2024
mentioned in commit
530e17ab
mentioned in commit 530e17ab730090b841ebd30ed3a2a8ce37647fc0
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录