Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
df8ff0e0
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看板
提交
df8ff0e0
编写于
6月 11, 2024
作者:
Anne_LXM
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整测试例:因事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取
上级
af90b3cc
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
94 addition
and
43 deletion
+94
-43
pages/component/swiper/swiper.test.js
pages/component/swiper/swiper.test.js
+37
-35
pages/component/swiper/swiper.uvue
pages/component/swiper/swiper.uvue
+57
-8
未找到文件。
pages/component/swiper/swiper.test.js
浏览文件 @
df8ff0e0
...
@@ -11,6 +11,15 @@ describe('test swiper', () => {
...
@@ -11,6 +11,15 @@ describe('test swiper', () => {
}
}
let
page
;
let
page
;
const
webDetailRes
=
{
current
:
1
,
currentItemId
:
'
B
'
,
//web端多了currentItemId
source
:
'
autoplay
'
,
}
const
appDetailRes
=
{
current
:
1
,
source
:
'
autoplay
'
,
}
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/swiper/swiper
'
)
page
=
await
program
.
reLaunch
(
'
/pages/component/swiper/swiper
'
)
await
page
.
waitFor
(
600
)
await
page
.
waitFor
(
600
)
...
@@ -82,7 +91,6 @@ describe('test swiper', () => {
...
@@ -82,7 +91,6 @@ describe('test swiper', () => {
autoplaySelect
:
true
autoplaySelect
:
true
})
})
await
page
.
waitFor
(
2000
)
await
page
.
waitFor
(
2000
)
console
.
log
(
'
currentValChange
'
,
await
page
.
data
(
'
currentValChange
'
))
if
(
await
page
.
data
(
'
currentValChange
'
)
==
1
){
if
(
await
page
.
data
(
'
currentValChange
'
)
==
1
){
await
page
.
setData
({
await
page
.
setData
({
autoplaySelect
:
false
autoplaySelect
:
false
...
@@ -90,45 +98,39 @@ describe('test swiper', () => {
...
@@ -90,45 +98,39 @@ describe('test swiper', () => {
}
}
});
});
it
(
'
Event change-transitiont-animationfinish
'
,
async
()
=>
{
it
(
'
Event transitiont
'
,
async
()
=>
{
const
webResult
=
{
// android端swiper的事件event参数detail类型错误,暂时忽略测试
current
:
1
,
if
(
!
process
.
env
.
UNI_UTS_PLATFORM
.
startsWith
(
'
app-android
'
)){
currentItemId
:
'
B
'
,
//web端多了currentItemId
const
transitionDetailInfo
=
await
page
.
data
(
'
transitionDetailTest
'
)
source
:
'
autoplay
'
,
expect
(
transitionDetailInfo
.
dy
).
toBe
(
0
)
expect
(
transitionDetailInfo
.
dx
).
toBeGreaterThan
(
0
)
expect
(
await
page
.
data
(
'
isTransitionTest
'
)).
toBe
(
'
transition:Pass
'
)
}
}
const
appResult
=
{
});
current
:
1
,
source
:
'
autoplay
'
,
it
(
'
Event change
'
,
async
()
=>
{
}
if
(
!
process
.
env
.
UNI_UTS_PLATFORM
.
startsWith
(
'
app-android
'
)){
const
changeInfo
=
await
page
.
data
(
'
swiperChangeEventTest
'
)
const
changeDetailInfo
=
await
page
.
data
(
'
changeDetailTest
'
)
// console.log('change',changeInfo)
expect
(
changeInfo
.
type
).
toBe
(
'
change
'
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
changeInfo
.
detail
).
toEqual
(
webResult
)
expect
(
changeDetailInfo
).
toEqual
(
webDetailRes
)
}
else
{
}
else
{
expect
(
changeInfo
.
detail
).
toEqual
(
appResult
)
expect
(
changeDetailInfo
).
toEqual
(
appDetailRes
)
}
}
expect
(
changeInfo
.
currentTarget
).
not
.
toBeFalsy
();
expect
(
await
page
.
data
(
'
isChangeTest
'
)).
toBe
(
'
change:Pass
'
)
expect
(
changeInfo
.
target
).
not
.
toBeFalsy
();
}
});
const
transitionInfo
=
await
page
.
data
(
'
swiperTransitionTest
'
)
it
(
'
Event animationfinish
'
,
async
()
=>
{
// console.log('transitiont',transitionInfo,detail)
expect
(
transitionInfo
.
type
).
toBe
(
'
transition
'
)
expect
(
transitionInfo
.
detail
.
dy
).
toBe
(
0
)
expect
(
transitionInfo
.
detail
.
dx
).
toBeGreaterThan
(
0
)
expect
(
transitionInfo
.
currentTarget
).
not
.
toBeFalsy
();
expect
(
transitionInfo
.
target
).
not
.
toBeFalsy
();
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
1000
)
// bug:在android端第一次触发@animationfinish 得到detail中的source为空,第二次触发时正常得到source: 'autoplay'
// bug:在android端第一次触发@animationfinish 得到detail中的source为空,第二次触发时正常得到source: 'autoplay'
const
animationfinishInfo
=
await
page
.
data
(
'
swiperAnimationfinishTest
'
)
if
(
!
process
.
env
.
UNI_UTS_PLATFORM
.
startsWith
(
'
app-android
'
)){
// console.log('animationfinish',animationfinishInfo.detail)
const
animationfinishDetailInfo
=
await
page
.
data
(
'
animationfinishDetailTest
'
)
expect
(
animationfinishInfo
.
type
).
toBe
(
'
animationfinish
'
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
expect
(
animationfinishInfo
.
detail
).
toEqual
(
webResult
)
expect
(
animationfinishDetailInfo
).
toEqual
(
webDetailRes
)
}
else
if
(
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)){
}
else
{
expect
(
animationfinishInfo
.
detail
).
toEqual
(
appResult
)
expect
(
animationfinishDetailInfo
).
toEqual
(
appDetailRes
)
}
expect
(
await
page
.
data
(
'
isAnimationfinishTest
'
)).
toBe
(
'
animationfinish:Pass
'
)
}
}
expect
(
animationfinishInfo
.
currentTarget
).
not
.
toBeFalsy
();
expect
(
animationfinishInfo
.
target
).
not
.
toBeFalsy
();
});
});
});
});
pages/component/swiper/swiper.uvue
浏览文件 @
df8ff0e0
...
@@ -89,6 +89,11 @@
...
@@ -89,6 +89,11 @@
</template>
</template>
<script>
<script>
type SwiperEventTest = {
type: string;
target: UniElement | null;
currentTarget: UniElement | null;
}
export default {
export default {
data() {
data() {
return {
return {
...
@@ -112,15 +117,45 @@
...
@@ -112,15 +117,45 @@
swiperChangeSelect: false,
swiperChangeSelect: false,
currentValChange: 0,
currentValChange: 0,
// 自动化测试
// 自动化测试
swiperChangeEventTest:null as SwiperChangeEvent | null,
// 在android端以下事件event参数中detail类型报错,先条件编译处理
swiperTransitionTest:null as SwiperTransitionEvent | null,
// #ifndef APP-ANDROID
swiperAnimationfinishTest:null as SwiperAnimationFinishEvent | null
changeDetailTest:null as UniSwiperChangeDetail | null,
transitionDetailTest:null as UniSwiperTransitionDetail | null,
animationfinishDetailTest:null as UniSwiperAnimationFinishDetail | null,
// #endif
isChangeTest:'',
isTransitionTest:'',
isAnimationfinishTest:''
}
}
},
},
methods: {
methods: {
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e:SwiperEventTest, eventName:String){
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
const result = isPass ? `${eventName}:Pass` : `${eventName}:NoPass`;
switch (eventName){
case 'change':
this.isChangeTest = result
break;
case 'transition':
this.isTransitionTest = result
break;
case 'animationfinish':
this.isAnimationfinishTest = result
break;
default:
break;
}
},
swiperChange: function (e : SwiperChangeEvent) {
swiperChange: function (e : SwiperChangeEvent) {
this.swiperChangeEventTest = e
// #ifndef APP-ANDROID
this.changeDetailTest = e.detail
// #endif
this.checkEventTest({
type:e.type,
target:e.target,
currentTarget:e.currentTarget
} as SwiperEventTest,'change')
this.currentValChange = e.detail.current
this.currentValChange = e.detail.current
console.log(this.currentValChange)
console.log(this.currentValChange)
if (this.swiperChangeSelect) {
if (this.swiperChangeSelect) {
...
@@ -129,14 +164,28 @@
...
@@ -129,14 +164,28 @@
}
}
},
},
swiperTransition: function (e : SwiperTransitionEvent) {
swiperTransition: function (e : SwiperTransitionEvent) {
this.swiperTransitionTest = e
// #ifndef APP-ANDROID
this.transitionDetailTest = e.detail
// #endif
this.checkEventTest({
type:e.type,
target:e.target,
currentTarget:e.currentTarget
} as SwiperEventTest,'transition')
if (this.swiperTransitionSelect) {
if (this.swiperTransitionSelect) {
console.log("swiperTransition")
console.log("swiperTransition")
console.log(e)
console.log(e)
}
}
},
},
swiperAnimationfinish: function (e : SwiperAnimationFinishEvent) {
swiperAnimationfinish: function (e : SwiperAnimationFinishEvent) {
this.swiperAnimationfinishTest = e
// #ifndef APP-ANDROID
this.animationfinishDetailTest = e.detail
// #endif
this.checkEventTest({
type:e.type,
target:e.target,
currentTarget:e.currentTarget
} as SwiperEventTest,'animationfinish')
if (this.swiperAnimationfinishSelect) {
if (this.swiperAnimationfinishSelect) {
console.log("swiperAnimationfinish")
console.log("swiperAnimationfinish")
console.log(e)
console.log(e)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录