Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
f3571449
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5992
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看板
提交
f3571449
编写于
6月 04, 2024
作者:
Anne_LXM
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增scroll-view事件自动化测试例
上级
77988399
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
102 addition
and
5 deletion
+102
-5
pages/component/scroll-view/scroll-view.test.js
pages/component/scroll-view/scroll-view.test.js
+90
-1
pages/component/scroll-view/scroll-view.uvue
pages/component/scroll-view/scroll-view.uvue
+12
-4
未找到文件。
pages/component/scroll-view/scroll-view.test.js
浏览文件 @
f3571449
...
...
@@ -5,7 +5,6 @@ describe('component-native-scroll-view', () => {
await
page
.
waitFor
(
300
);
});
it
(
'
scroll-view-screenshot
'
,
async
()
=>
{
//禁止滚动条
await
page
.
setData
({
...
...
@@ -15,4 +14,94 @@ describe('component-native-scroll-view', () => {
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
});
it
(
'
Event scroll-vertical
'
,
async
()
=>
{
// 纵向滚动
await
page
.
setData
({
scrollTop
:
100
})
await
page
.
waitFor
(
600
)
//设置top 是否触发scroll 事件
const
topScrollInfo
=
await
page
.
data
(
'
scrollTest
'
)
// const topScrollResult = {
// "scrollLeft": 0,
// "scrollTop": 100,
// "scrollHeight": 450,
// "scrollWidth": 345,
// "deltaX": 0,
// "deltaY": -100
// }
const
{
scrollLeft
,
scrollTop
,
scrollHeight
,
scrollWidth
,
deltaX
,
deltaY
}
=
topScrollInfo
.
detail
expect
(
topScrollInfo
.
type
).
toBe
(
'
scroll
'
)
expect
(
scrollLeft
).
toBe
(
0
)
expect
(
scrollTop
).
toBe
(
100
)
expect
(
scrollHeight
).
toBeGreaterThan
(
0
)
expect
(
scrollWidth
).
toBeGreaterThan
(
0
)
expect
(
deltaX
).
toBe
(
0
)
expect
(
deltaY
).
toBe
(
-
100
)
expect
(
topScrollInfo
.
currentTarget
).
not
.
toBeFalsy
();
expect
(
topScrollInfo
.
target
).
not
.
toBeFalsy
();
// expect(topScrollInfo.detail).toEqual(topScrollResult);
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
topScrollInfo
.
timeStamp
).
toBeGreaterThan
(
0
)
}
})
it
(
'
Event scroll-horizontal
'
,
async
()
=>
{
// 横向滚动
await
page
.
setData
({
scrollLeft
:
220
})
await
page
.
waitFor
(
600
)
//设置left 是否触发scroll 事件
const
leftScrollInfo
=
await
page
.
data
(
'
scrollTest
'
)
// const leftScrollResult = {
// "scrollLeft": 220,
// "scrollTop": 0,
// "scrollHeight": 150,
// "scrollWidth": 1036,
// "deltaX": -100,
// "deltaY": 0
// }
const
{
scrollLeft
,
scrollTop
,
scrollHeight
,
scrollWidth
,
deltaX
,
deltaY
}
=
leftScrollInfo
.
detail
expect
(
leftScrollInfo
.
type
).
toBe
(
'
scroll
'
)
expect
(
scrollLeft
).
toBe
(
220
)
expect
(
scrollTop
).
toBe
(
0
)
expect
(
scrollHeight
).
toBeGreaterThan
(
0
)
expect
(
scrollWidth
).
toBeGreaterThan
(
0
)
expect
(
deltaX
).
toBe
(
-
100
)
expect
(
deltaY
).
toBe
(
0
)
expect
(
leftScrollInfo
.
currentTarget
).
not
.
toBeFalsy
();
expect
(
leftScrollInfo
.
target
).
not
.
toBeFalsy
();
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
leftScrollInfo
.
timeStamp
).
toBeGreaterThan
(
0
)
}
})
it
(
'
Event scrolltolower-滚动到底部/右边
'
,
async
()
=>
{
// 滚动到底部scrollTop:300,
await
page
.
setData
({
scrollTop
:
300
})
await
page
.
waitFor
(
600
)
//设置top 是否触发scrolltolower事件
const
toLowerInfo
=
await
page
.
data
(
'
toLowerTest
'
)
expect
(
toLowerInfo
.
type
).
toBe
(
'
scrolltolower
'
)
expect
(
toLowerInfo
.
detail
.
direction
).
toBe
(
'
bottom
'
)
expect
(
toLowerInfo
.
currentTarget
).
not
.
toBeFalsy
();
expect
(
toLowerInfo
.
target
).
not
.
toBeFalsy
();
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
toLowerInfo
.
timeStamp
).
toBeGreaterThan
(
0
)
}
})
it
(
'
Event scrolltoupper-滚动到顶部/左边
'
,
async
()
=>
{
// 滚动到顶部scrollTop: 0,
// await page.setData({scrollTop: 0})
await
page
.
callMethod
(
'
goTop
'
)
await
page
.
waitFor
(
600
)
//设置top 是否触发scrolltoupper事件
const
toUpperInfo
=
await
page
.
data
(
'
toUpperTest
'
)
expect
(
toUpperInfo
.
type
).
toBe
(
'
scrolltoupper
'
)
expect
(
toUpperInfo
.
detail
.
direction
).
toBe
(
'
top
'
)
expect
(
toUpperInfo
.
currentTarget
).
not
.
toBeFalsy
();
expect
(
toUpperInfo
.
target
).
not
.
toBeFalsy
();
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
toUpperInfo
.
timeStamp
).
toBeGreaterThan
(
0
)
}
})
});
pages/component/scroll-view/scroll-view.uvue
浏览文件 @
f3571449
...
...
@@ -26,7 +26,7 @@
<text class="uni-subtitle-text">横向滚动</text>
</view>
<view>
<scroll-view class="scroll-view_H" direction="horizontal" @scroll="scroll" :scroll-left="
120
" :show-scrollbar="showScrollbar">
<scroll-view class="scroll-view_H" direction="horizontal" @scroll="scroll" :scroll-left="
scrollLeft
" :show-scrollbar="showScrollbar">
<view class="scroll-view-item_H uni-bg-red"><text class="text">A</text></view>
<view class="scroll-view-item_H uni-bg-green"><text class="text">B</text></view>
<view class="scroll-view-item_H uni-bg-blue"><text class="text">C</text></view>
...
...
@@ -68,17 +68,25 @@
return {
scrollTop: 0,
oldScrollTop: 0,
showScrollbar: true
scrollLeft:120,
showScrollbar: true,
// 自动化测试
scrollTest:null as ScrollEvent|null,
toUpperTest:null as ScrollToUpperEvent|null,
toLowerTest:null as ScrollToLowerEvent|null
}
},
methods: {
upper: function (e : ScrollToUpperEvent) {
console.log(e)
console.log('滚动到顶部/左边',e)
this.toUpperTest = e
},
lower: function (e : ScrollToLowerEvent) {
console.log(e)
console.log('滚动到底部/右边',e)
this.toLowerTest = e
},
scroll: function (e : ScrollEvent) {
this.scrollTest = e
this.oldScrollTop = e.detail.scrollTop
},
goTop: function () {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录