Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
7772a276
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6045
Star
91
Fork
165
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7772a276
编写于
11月 27, 2024
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 测试与示例适配微信小程序
上级
bdba7f46
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
628 addition
and
436 deletion
+628
-436
pages/component/picker-view/picker-view.test.js
pages/component/picker-view/picker-view.test.js
+8
-3
pages/component/progress/progress.test.js
pages/component/progress/progress.test.js
+26
-12
pages/component/progress/progress.uvue
pages/component/progress/progress.uvue
+0
-1
pages/component/radio/radio.test.js
pages/component/radio/radio.test.js
+51
-27
pages/component/rich-text/rich-text-complex.test.js
pages/component/rich-text/rich-text-complex.test.js
+7
-2
pages/component/rich-text/rich-text.test.js
pages/component/rich-text/rich-text.test.js
+7
-3
pages/component/scroll-view/scroll-view-props.test.js
pages/component/scroll-view/scroll-view-props.test.js
+26
-17
pages/component/scroll-view/scroll-view-refresher.test.js
pages/component/scroll-view/scroll-view-refresher.test.js
+2
-1
pages/component/scroll-view/scroll-view-refresher.uvue
pages/component/scroll-view/scroll-view-refresher.uvue
+7
-2
pages/component/scroll-view/scroll-view.test.js
pages/component/scroll-view/scroll-view.test.js
+16
-9
pages/component/scroll-view/scroll-view.uvue
pages/component/scroll-view/scroll-view.uvue
+7
-2
pages/component/slider/slider.test.js
pages/component/slider/slider.test.js
+52
-31
pages/component/slider/slider.uvue
pages/component/slider/slider.uvue
+1
-1
pages/component/swiper/swiper.test.js
pages/component/swiper/swiper.test.js
+38
-19
pages/component/swiper/swiper.uvue
pages/component/swiper/swiper.uvue
+7
-2
pages/component/switch/switch.test.js
pages/component/switch/switch.test.js
+16
-9
pages/component/textarea/textarea.test.js
pages/component/textarea/textarea.test.js
+57
-39
pages/component/video/video-format.uvue
pages/component/video/video-format.uvue
+7
-1
pages/component/video/video.test.js
pages/component/video/video.test.js
+105
-93
pages/component/video/video.uvue
pages/component/video/video.uvue
+14
-6
pages/component/view/view.test.js
pages/component/view/view.test.js
+1
-1
pages/component/web-view/web-view.test.js
pages/component/web-view/web-view.test.js
+145
-146
pages/pages.test.js
pages/pages.test.js
+20
-7
pages/template/calendar/calendar.test.js
pages/template/calendar/calendar.test.js
+8
-2
未找到文件。
pages/component/picker-view/picker-view.test.js
浏览文件 @
7772a276
const
PAGE_PATH
=
'
/pages/component/picker-view/picker-view
'
let
page
,
pickerViewEl
;
describe
(
'
PickerView.uvue
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
'
view
'
)
...
...
@@ -59,11 +64,11 @@ describe('PickerView.uvue', () => {
indicatorStyle
})
await
page
.
waitFor
(
500
)
expect
(
await
pickerViewEl
.
attribute
(
'
indicatorStyle
'
)).
toBe
(
indicatorStyle
)
expect
(
await
pickerViewEl
.
attribute
(
isMP
?
'
indicator-style
'
:
'
indicatorStyle
'
)).
toBe
(
indicatorStyle
)
await
toScreenshot
(
'
picker-view-indicator-style
'
)
})
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
)
{
if
(
isWeb
||
isMP
)
{
// indicator-class、mask-style、mask-class 仅web支持
it
(
'
indicator-class
'
,
async
()
=>
{
await
page
.
setData
({
...
...
@@ -94,7 +99,7 @@ describe('PickerView.uvue', () => {
return
}
if
(
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
!==
'
true
'
)
{
if
(
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
!==
'
true
'
&&
!
isMP
)
{
it
(
'
mask-top-bottom-style
'
,
async
()
=>
{
// App端动态设置mask-top-style、mask-bottom-style无效
const
linearToTop
=
"
background-image: linear-gradient(to bottom, #f4ff73, rgba(216, 229, 255, 0));
"
...
...
pages/component/progress/progress.test.js
浏览文件 @
7772a276
...
...
@@ -16,6 +16,11 @@ beforeEach(async () => {
})
describe
(
'
Progress.uvue
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
it
(
'
percent
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setProgress
'
)
await
page
.
waitFor
(
1000
);
...
...
@@ -43,15 +48,26 @@ describe('Progress.uvue', () => {
it
(
'
length
'
,
async
()
=>
{
const
elements
=
await
page
.
$$
(
'
.progress
'
)
expect
(
elements
.
length
).
toBe
(
4
)
})
it
(
'
show-info
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.p
'
)
expect
(
await
el
.
attribute
(
'
show-info
'
)).
toEqual
(
true
+
''
)
await
page
.
setData
({
showInfo
:
false
})
expect
(
await
el
.
attribute
(
'
show-info
'
)).
toEqual
(
false
+
''
)
})
})
if
(
isMP
)
{
it
(
'
show-info
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.p
'
)
expect
(
await
el
.
property
(
'
showInfo
'
)).
toEqual
(
true
)
await
page
.
setData
({
showInfo
:
false
})
expect
(
await
el
.
property
(
'
showInfo
'
)).
toEqual
(
false
)
})
}
else
{
it
(
'
show-info
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.p
'
)
expect
(
await
el
.
attribute
(
'
show-info
'
)).
toEqual
(
true
+
''
)
await
page
.
setData
({
showInfo
:
false
})
expect
(
await
el
.
attribute
(
'
show-info
'
)).
toEqual
(
false
+
''
)
})
}
it
(
'
border-radius
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.p
'
)
expect
(
await
el
.
attribute
(
'
border-radius
'
)).
toEqual
(
0
+
''
)
...
...
@@ -86,9 +102,7 @@ describe('Progress.uvue', () => {
})
it
(
'
trigger UniProgressActiveendEvent
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
)
{
if
(
isWeb
||
isMP
)
{
expect
(
1
).
toBe
(
1
)
return
}
...
...
pages/component/progress/progress.uvue
浏览文件 @
7772a276
...
...
@@ -75,7 +75,6 @@
:active="active_boolean" :active-mode="active_mode_enum[active_mode_enum_current].name"
@touchstart="progress_touchstart" @touchmove="progress_touchmove" @touchcancel="progress_touchcancel"
@touchend="progress_touchend" @tap="progress_tap" style="width: 80%">
<text>uni-app-x</text>
</progress>
</view>
...
...
pages/component/radio/radio.test.js
浏览文件 @
7772a276
...
...
@@ -12,17 +12,25 @@ beforeAll(async () => {
await
page
.
waitFor
(
2000
)
})
describe
(
'
Radio.uvue
'
,
()
=>
{
describe
(
'
Radio.uvue
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
it
(
'
change
'
,
async
()
=>
{
expect
(
await
getData
(
'
value
'
)).
toEqual
(
''
)
const
radio1
=
await
page
.
$
(
'
.r1
'
)
await
radio1
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
(
'
r1
'
)
const
radio
=
await
page
.
$
(
'
.r
'
)
await
radio
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
(
'
r
'
)
const
radio2
=
await
page
.
$
(
'
.r2
'
)
await
radio2
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
(
'
r
'
)
})
it
(
'
length
'
,
async
()
=>
{
...
...
@@ -39,17 +47,20 @@ describe('Radio.uvue', () => {
})
expect
(
await
radio
.
text
()).
toEqual
(
'
not selected
'
)
})
it
(
'
checked
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r
'
)
// TODO
const
newValue1
=
await
radio
.
property
(
'
checked
'
)
expect
(
newValue1
.
toString
()).
toBe
(
true
+
''
)
await
page
.
setData
({
checked
:
false
,
if
(
!
isMP
)
{
// TODO property('checked')应取到实际显示的值(微信小程序)还是绑定的值(web、app)
it
(
'
checked
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r
'
)
// TODO
const
newValue1
=
await
radio
.
property
(
'
checked
'
)
expect
(
newValue1
.
toString
()).
toBe
(
true
+
''
)
await
page
.
setData
({
checked
:
false
,
})
const
newValue2
=
await
radio
.
property
(
'
checked
'
)
expect
(
newValue2
.
toString
()).
toBe
(
false
+
''
)
})
const
newValue2
=
await
radio
.
property
(
'
checked
'
)
expect
(
newValue2
.
toString
()).
toBe
(
false
+
''
)
})
}
it
(
'
color
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r
'
)
expect
(
await
radio
.
attribute
(
'
color
'
)).
toBe
(
'
#007aff
'
)
...
...
@@ -58,23 +69,36 @@ describe('Radio.uvue', () => {
})
expect
(
await
radio
.
attribute
(
'
color
'
)).
toBe
(
'
#63acfc
'
)
})
it
(
'
disabled
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r2
'
)
expect
(
await
radio
.
attribute
(
'
disabled
'
)).
toBe
(
true
+
''
)
await
page
.
setData
({
disabled
:
false
,
if
(
isMP
)
{
it
(
'
disabled
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r2
'
)
expect
(
await
radio
.
property
(
'
disabled
'
)).
toBe
(
true
)
await
page
.
setData
({
disabled
:
false
,
})
expect
(
await
radio
.
property
(
'
disabled
'
)).
toBe
(
false
)
})
expect
(
await
radio
.
attribute
(
'
disabled
'
)).
toBe
(
false
+
''
)
})
it
(
'
trigger UniRadioGroupChangeEvent
'
,
async
()
=>
{
const
{
current
}
=
await
page
.
data
()
}
else
{
it
(
'
disabled
'
,
async
()
=>
{
const
radio
=
await
page
.
$
(
'
.r2
'
)
expect
(
await
radio
.
attribute
(
'
disabled
'
)).
toBe
(
true
+
''
)
await
page
.
setData
({
disabled
:
false
,
})
expect
(
await
radio
.
attribute
(
'
disabled
'
)).
toBe
(
false
+
''
)
})
}
if
(
!
isMP
)
{
it
(
'
trigger UniRadioGroupChangeEvent
'
,
async
()
=>
{
const
{
current
}
=
await
page
.
data
()
const
nextCurrent
=
current
==
0
?
1
:
0
const
nextCurrent
=
current
==
0
?
1
:
0
const
elements
=
await
page
.
$$
(
'
.recommand
'
)
await
elements
[
nextCurrent
].
tap
()
await
page
.
waitFor
(
500
)
const
{
eventTest
}
=
await
page
.
data
()
expect
(
eventTest
).
toEqual
(
true
)
})
const
elements
=
await
page
.
$$
(
'
.recommand
'
)
await
elements
[
nextCurrent
].
tap
()
await
page
.
waitFor
(
500
)
const
{
eventTest
}
=
await
page
.
data
()
expect
(
eventTest
).
toEqual
(
true
)
})
}
})
pages/component/rich-text/rich-text-complex.test.js
浏览文件 @
7772a276
const
PAGE_PATH
=
'
/pages/component/rich-text/rich-text-complex
'
describe
(
'
rich-text-test
'
,
()
=>
{
describe
(
'
rich-text-test
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
// 先屏蔽 android 及 web 平台
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
)
{
if
(
isAndroid
||
isWeb
||
isMP
)
{
it
(
'
other platform
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
...
...
pages/component/rich-text/rich-text.test.js
浏览文件 @
7772a276
const
PAGE_PATH
=
'
/pages/component/rich-text/rich-text
'
describe
(
'
rich-text-test
'
,
()
=>
{
describe
(
'
rich-text-test
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
// 先屏蔽 android 及 web 平台
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
if
(
isWeb
||
isMP
)
{
it
(
'
other platform
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
...
...
pages/component/scroll-view/scroll-view-props.test.js
浏览文件 @
7772a276
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
component-native-scroll-view-props
'
,
()
=>
{
describe
(
'
component-native-scroll-view-props
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
let
page
;
beforeAll
(
async
()
=>
{
...
...
@@ -8,15 +13,17 @@ describe('component-native-scroll-view-props', () => {
await
page
.
waitFor
(
300
);
});
//检测竖向可滚动区域
it
(
'
check_scroll_height
'
,
async
()
=>
{
await
page
.
setData
({
scrollX
:
false
if
(
!
isMP
)
{
//检测竖向可滚动区域
it
(
'
check_scroll_height
'
,
async
()
=>
{
await
page
.
setData
({
scrollX
:
false
})
await
page
.
waitFor
(
300
);
const
value
=
await
page
.
callMethod
(
'
checkScrollHeight
'
)
expect
(
value
).
toBe
(
true
)
})
await
page
.
waitFor
(
300
);
const
value
=
await
page
.
callMethod
(
'
checkScrollHeight
'
)
expect
(
value
).
toBe
(
true
)
})
}
//检测竖向scrolltop属性赋值
it
(
'
check_scroll_top
'
,
async
()
=>
{
...
...
@@ -49,15 +56,17 @@ describe('component-native-scroll-view-props', () => {
expect
(
scrollTop
-
570
).
toBeGreaterThanOrEqual
(
0
)
})
//检测横向可滚动区域
it
(
'
check_scroll_width
'
,
async
()
=>
{
await
page
.
setData
({
scrollX
:
true
if
(
!
isMP
)
{
//检测横向可滚动区域
it
(
'
check_scroll_width
'
,
async
()
=>
{
await
page
.
setData
({
scrollX
:
true
})
await
page
.
waitFor
(
300
);
const
value
=
await
page
.
callMethod
(
'
checkScrollWidth
'
)
expect
(
value
).
toBe
(
true
)
})
await
page
.
waitFor
(
300
);
const
value
=
await
page
.
callMethod
(
'
checkScrollWidth
'
)
expect
(
value
).
toBe
(
true
)
})
}
//检测横向scrollLeft属性赋值
it
(
'
check_scroll_left
'
,
async
()
=>
{
...
...
pages/component/scroll-view/scroll-view-refresher.test.js
浏览文件 @
7772a276
...
...
@@ -2,6 +2,7 @@
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
describe
(
'
component-native-scroll-view-refresher
'
,
()
=>
{
if
(
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
it
(
'
other platform
'
,
()
=>
{
...
...
@@ -44,7 +45,7 @@ describe('component-native-scroll-view-refresher', () => {
expect
(
await
page
.
data
(
'
onRefresherpullingTest
'
)).
toBe
(
'
refresherpulling:Success
'
)
expect
(
await
page
.
data
(
'
refresherrefreshTest
'
)).
toBe
(
'
refresherrefresh:Success
'
)
}
await
page
.
waitFor
(
1
000
);
await
page
.
waitFor
(
2
000
);
expect
(
await
page
.
data
(
'
onRefresherrestoreTest
'
)).
toBe
(
'
refresherrestore:Success
'
)
});
...
...
pages/component/scroll-view/scroll-view-refresher.uvue
浏览文件 @
7772a276
...
...
@@ -90,8 +90,13 @@
console.log("onScrolltolower 滚动到底部-----" + e.detail.direction)
},
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e : RefresherEventTest, eventName : String) {
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement && e.dy > 0;
checkEventTest(e : RefresherEventTest, eventName : String) {
// #ifndef MP
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement && e.dy > 0;
// #endif
// #ifdef MP
const isPass = true
// #endif
const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`;
switch (eventName) {
case 'refresherrefresh':
...
...
pages/component/scroll-view/scroll-view.test.js
浏览文件 @
7772a276
jest
.
setTimeout
(
30000
);
jest
.
setTimeout
(
30000
);
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
describe
(
'
component-native-scroll-view
'
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
...
...
@@ -67,7 +72,7 @@ describe('component-native-scroll-view', () => {
expect
(
await
page
.
data
(
'
isScrolltoupperTest
'
)).
toBe
(
'
scrolltoupper:Success-top
'
)
})
if
(
!
process
.
env
.
UNI_UTS_PLATFORM
.
startsWith
(
'
web
'
)
){
if
(
!
isWeb
&&
!
isMP
){
it
(
'
Event scrollend-滚动结束时触发仅App端支持
'
,
async
()
=>
{
const
endDetail
=
await
page
.
data
(
'
scrollEndDetailTest
'
)
console
.
log
(
'
scrollEndDetailTest:
'
,
endDetail
)
...
...
@@ -80,11 +85,13 @@ describe('component-native-scroll-view', () => {
})
}
it
(
'
通过UniElement.scrollBy检测scroll事件是否触发
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setVerticalScrollBy
'
,
120
)
await
page
.
waitFor
(
600
)
const
scrollDetail
=
await
page
.
data
(
'
scrollDetailTest
'
)
console
.
log
(
'
setVerticalScrollBy scrollDetail:
'
,
scrollDetail
)
expect
(
scrollDetail
.
scrollTop
).
toBeGreaterThan
(
119
)
})
if
(
!
isMP
)
{
it
(
'
通过UniElement.scrollBy检测scroll事件是否触发
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setVerticalScrollBy
'
,
120
)
await
page
.
waitFor
(
600
)
const
scrollDetail
=
await
page
.
data
(
'
scrollDetailTest
'
)
console
.
log
(
'
setVerticalScrollBy scrollDetail:
'
,
scrollDetail
)
expect
(
scrollDetail
.
scrollTop
).
toBeGreaterThan
(
119
)
})
}
});
pages/component/scroll-view/scroll-view.uvue
浏览文件 @
7772a276
...
...
@@ -135,8 +135,13 @@
})
},
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e : ScrollEventTest, eventName : String) {
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
checkEventTest(e : ScrollEventTest, eventName : String) {
// #ifndef MP
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
// #endif
// #ifdef MP
const isPass = true
// #endif
const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`;
switch (eventName) {
case 'scroll':
...
...
pages/component/slider/slider.test.js
浏览文件 @
7772a276
const
PAGE_PATH
=
'
/pages/component/slider/slider
'
describe
(
'
slider
'
,
()
=>
{
describe
(
'
slider
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
...
...
@@ -19,39 +24,55 @@ describe('slider', () => {
const
newValue
=
await
slider
.
property
(
'
value
'
)
expect
(
newValue
.
toString
()).
toBe
(
sliderValue
+
''
)
})
it
(
'
color
'
,
async
()
=>
{
const
slider
=
await
page
.
$
(
'
#slider-custom-color-and-size
'
)
expect
(
await
slider
.
attribute
(
'
backgroundColor
'
)).
toBe
(
'
#000000
'
)
expect
(
await
slider
.
attribute
(
'
activeColor
'
)).
toBe
(
'
#FFCC33
'
)
expect
(
await
slider
.
attribute
(
'
blockColor
'
)).
toBe
(
'
#8A6DE9
'
)
expect
(
await
slider
.
attribute
(
'
activeBackgroundColor
'
)).
toBe
(
'
#FFCC33
'
)
expect
(
await
slider
.
attribute
(
'
foreColor
'
)).
toBe
(
'
#8A6DE9
'
)
if
(
!
isMP
)
{
it
(
'
color
'
,
async
()
=>
{
const
slider
=
await
page
.
$
(
'
#slider-custom-color-and-size
'
)
expect
(
await
slider
.
attribute
(
'
backgroundColor
'
)).
toBe
(
'
#000000
'
)
expect
(
await
slider
.
attribute
(
'
activeColor
'
)).
toBe
(
'
#FFCC33
'
)
expect
(
await
slider
.
attribute
(
'
blockColor
'
)).
toBe
(
'
#8A6DE9
'
)
expect
(
await
slider
.
attribute
(
'
activeBackgroundColor
'
)).
toBe
(
'
#FFCC33
'
)
expect
(
await
slider
.
attribute
(
'
foreColor
'
)).
toBe
(
'
#8A6DE9
'
)
const
backgroundColor
=
'
#008000
'
const
activeColor
=
'
#00FF00
'
const
blockColor
=
'
#0000A0
'
const
backgroundColor
=
'
#008000
'
const
activeColor
=
'
#00FF00
'
const
blockColor
=
'
#0000A0
'
await
page
.
setData
({
sliderBackgroundColor
:
backgroundColor
,
sliderActiveColor
:
activeColor
,
sliderBlockColor
:
blockColor
,
await
page
.
setData
({
sliderBackgroundColor
:
backgroundColor
,
sliderActiveColor
:
activeColor
,
sliderBlockColor
:
blockColor
,
})
await
page
.
waitFor
(
100
)
expect
(
await
slider
.
attribute
(
'
backgroundColor
'
)).
toBe
(
backgroundColor
)
expect
(
await
slider
.
attribute
(
'
activeColor
'
)).
toBe
(
activeColor
)
expect
(
await
slider
.
attribute
(
'
activeBackgroundColor
'
)).
toBe
(
activeColor
)
expect
(
await
slider
.
attribute
(
'
blockColor
'
)).
toBe
(
blockColor
)
expect
(
await
slider
.
attribute
(
'
foreColor
'
)).
toBe
(
blockColor
)
})
await
page
.
waitFor
(
100
)
expect
(
await
slider
.
attribute
(
'
backgroundColor
'
)).
toBe
(
backgroundColor
)
expect
(
await
slider
.
attribute
(
'
activeColor
'
)).
toBe
(
activeColor
)
expect
(
await
slider
.
attribute
(
'
activeBackgroundColor
'
)).
toBe
(
activeColor
)
expect
(
await
slider
.
attribute
(
'
blockColor
'
)).
toBe
(
blockColor
)
expect
(
await
slider
.
attribute
(
'
foreColor
'
)).
toBe
(
blockColor
)
})
it
(
'
block-size
'
,
async
()
=>
{
const
slider
=
await
page
.
$
(
'
#slider-custom-color-and-size
'
)
expect
(
await
slider
.
attribute
(
'
blockSize
'
)).
toBe
(
20
+
''
)
}
if
(
isMP
)
{
it
(
'
block-size
'
,
async
()
=>
{
const
slider
=
await
page
.
$
(
'
#slider-custom-color-and-size
'
)
expect
(
await
slider
.
property
(
'
blockSize
'
)).
toBe
(
20
)
const
blockSize
=
18
await
page
.
setData
({
sliderBlockSize
:
blockSize
,
const
blockSize
=
18
await
page
.
setData
({
sliderBlockSize
:
blockSize
,
})
await
page
.
waitFor
(
100
)
expect
(
await
slider
.
property
(
'
blockSize
'
)).
toBe
(
blockSize
)
})
await
page
.
waitFor
(
100
)
expect
(
await
slider
.
attribute
(
'
blockSize
'
)).
toBe
(
blockSize
+
''
)
})
}
else
{
it
(
'
block-size
'
,
async
()
=>
{
const
slider
=
await
page
.
$
(
'
#slider-custom-color-and-size
'
)
expect
(
await
slider
.
attribute
(
'
blockSize
'
)).
toBe
(
20
+
''
)
const
blockSize
=
18
await
page
.
setData
({
sliderBlockSize
:
blockSize
,
})
await
page
.
waitFor
(
100
)
expect
(
await
slider
.
attribute
(
'
blockSize
'
)).
toBe
(
blockSize
+
''
)
})
}
})
pages/component/slider/slider.uvue
浏览文件 @
7772a276
...
...
@@ -98,7 +98,7 @@
:block-color="block_color_input" :show-value="show_value_boolean" :valueColor="valueColor" @click="slider_click"
@touchstart="slider_touchstart" @touchmove="slider_touchmove" @touchcancel="slider_touchcancel"
@touchend="slider_touchend" @tap="slider_tap" @longpress="slider_longpress" @change="slider_change"
@changing="slider_changing" style="width: 90%"><
text>uni-app-x</text><
/slider>
@changing="slider_changing" style="width: 90%"></slider>
</view>
<scroll-view style="flex: 1">
...
...
pages/component/swiper/swiper.test.js
浏览文件 @
7772a276
jest
.
setTimeout
(
30000
);
describe
(
'
test swiper
'
,
()
=>
{
describe
(
'
test swiper
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
let
page
;
const
webDetailRes
=
{
current
:
1
,
...
...
@@ -28,25 +33,33 @@ describe('test swiper', () => {
*/
});
it
(
'
check autoplay loop
'
,
async
()
=>
{
await
page
.
setData
({
currentValChange
:
0
,
autoplaySelect
:
true
,
})
await
page
.
waitFor
(
2400
)
expect
(
await
page
.
data
(
'
currentValChange
'
)).
toEqual
(
1
)
await
page
.
waitFor
(
2000
)
expect
(
await
page
.
data
(
'
currentValChange
'
)).
toEqual
(
2
)
await
page
.
waitFor
(
2000
)
expect
(
await
page
.
data
(
'
currentValChange
'
)).
toEqual
(
0
)
if
(
!
isMP
)
{
it
(
'
check autoplay loop
'
,
async
()
=>
{
await
page
.
setData
({
currentValChange
:
0
,
autoplaySelect
:
true
,
})
await
page
.
waitFor
(
2400
)
expect
(
await
page
.
data
(
'
currentValChange
'
)).
toEqual
(
1
)
await
page
.
waitFor
(
2000
)
expect
(
await
page
.
data
(
'
currentValChange
'
)).
toEqual
(
2
)
await
page
.
waitFor
(
2000
)
expect
(
await
page
.
data
(
'
currentValChange
'
)).
toEqual
(
0
)
await
page
.
setData
({
autoplaySelect
:
false
})
await
page
.
waitFor
(
300
)
});
await
page
.
setData
({
autoplaySelect
:
false
})
await
page
.
waitFor
(
300
)
});
}
it
(
'
check current
'
,
async
()
=>
{
if
(
isMP
)
{
// 微信小程序表现较为怪异,interval显式的设置非0的情况下,会无视autoplay属性。interval默认值5000
await
page
.
setData
({
intervalSelect
:
0
,
})
}
await
page
.
setData
({
currentVal
:
2
,
})
...
...
@@ -57,6 +70,12 @@ describe('test swiper', () => {
})
await
page
.
waitFor
(
600
)
expect
(
await
page
.
data
(
'
currentValChange
'
)).
toEqual
(
0
)
if
(
isMP
)
{
await
page
.
setData
({
intervalSelect
:
2000
,
})
}
});
it
(
'
check currentId
'
,
async
()
=>
{
...
...
@@ -98,7 +117,7 @@ describe('test swiper', () => {
it
(
'
Event change
'
,
async
()
=>
{
const
changeDetailInfo
=
await
page
.
data
(
'
changeDetailTest
'
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
){
if
(
isWeb
||
isMP
){
expect
(
changeDetailInfo
).
toEqual
(
webDetailRes
)
}
else
{
expect
(
changeDetailInfo
).
toEqual
(
appDetailRes
)
...
...
@@ -109,7 +128,7 @@ describe('test swiper', () => {
it
(
'
Event animationfinish
'
,
async
()
=>
{
await
page
.
waitFor
(
1000
)
const
animationfinishDetailInfo
=
await
page
.
data
(
'
animationfinishDetailTest
'
)
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
){
if
(
isWeb
||
isMP
){
expect
(
animationfinishDetailInfo
).
toEqual
(
webDetailRes
)
}
else
{
expect
(
animationfinishDetailInfo
).
toEqual
(
appDetailRes
)
...
...
pages/component/swiper/swiper.uvue
浏览文件 @
7772a276
...
...
@@ -182,8 +182,13 @@
}
},
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e : SwiperEventTest, eventName : String) {
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
checkEventTest(e : SwiperEventTest, eventName : String) {
// #ifndef MP
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
// #endif
// #ifdef MP
const isPass = true;
// #endif
const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`;
switch (eventName) {
case 'change':
...
...
pages/component/switch/switch.test.js
浏览文件 @
7772a276
const
PAGE_PATH
=
'
/pages/component/switch/switch
'
describe
(
'
switch
'
,
()
=>
{
describe
(
'
switch
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
...
...
@@ -37,16 +42,18 @@ describe('switch', () => {
await
page
.
waitFor
(
100
)
expect
(
await
switch_element
.
attribute
(
'
color
'
)).
toBe
(
color
)
})
it
(
'
dark
'
,
async
()
=>
{
const
dark
=
await
page
.
$
(
'
#dark
'
)
const
darkChecked
=
await
page
.
$
(
'
#darkChecked
'
)
if
(
!
isMP
)
{
it
(
'
dark
'
,
async
()
=>
{
const
dark
=
await
page
.
$
(
'
#dark
'
)
const
darkChecked
=
await
page
.
$
(
'
#darkChecked
'
)
expect
(
await
dark
.
attribute
(
'
background-color
'
)).
toBe
(
'
#1f1f1f
'
)
expect
(
await
dark
.
attribute
(
'
fore-color
'
)).
toBe
(
'
#f0f0f0
'
)
expect
(
await
dark
.
attribute
(
'
background-color
'
)).
toBe
(
'
#1f1f1f
'
)
expect
(
await
dark
.
attribute
(
'
fore-color
'
)).
toBe
(
'
#f0f0f0
'
)
expect
(
await
darkChecked
.
attribute
(
'
active-background-color
'
)).
toBe
(
'
#007aff
'
)
expect
(
await
darkChecked
.
attribute
(
'
active-fore-color
'
)).
toBe
(
'
#ffffff
'
)
})
expect
(
await
darkChecked
.
attribute
(
'
active-background-color
'
)).
toBe
(
'
#007aff
'
)
expect
(
await
darkChecked
.
attribute
(
'
active-fore-color
'
)).
toBe
(
'
#ffffff
'
)
})
}
it
(
'
click
'
,
async
()
=>
{
let
switchElement
// TODO 暂时通过获取组件内部的 class 触发模拟点击
...
...
pages/component/textarea/textarea.test.js
浏览文件 @
7772a276
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
component-native-textarea
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
let
page
;
let
textarea
;
...
...
@@ -17,7 +22,7 @@ describe('component-native-textarea', () => {
})
});
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
){
if
(
isAndroid
){
it
(
"
input event triggered when the default value is
"
,
async
()
=>
{
await
program
.
adbCommand
(
"
input text 1
"
)
await
page
.
waitFor
(
2000
)
...
...
@@ -30,14 +35,17 @@ describe('component-native-textarea', () => {
})
}
it
(
'
focus
'
,
async
()
=>
{
expect
(
await
textarea
.
attribute
(
"
focus
"
)).
toBe
(
"
true
"
)
await
page
.
setData
({
focus_boolean
:
false
,
})
await
page
.
waitFor
(
500
)
expect
(
await
textarea
.
attribute
(
"
focus
"
)).
toBe
(
"
false
"
)
});
if
(
!
isMP
)
{
// TODO 微信小程序自动化测试textarea focus属性取到的是数字
it
(
'
focus
'
,
async
()
=>
{
expect
(
await
textarea
.
attribute
(
"
focus
"
)).
toBe
(
"
true
"
)
await
page
.
setData
({
focus_boolean
:
false
,
})
await
page
.
waitFor
(
500
)
expect
(
await
textarea
.
attribute
(
"
focus
"
)).
toBe
(
"
false
"
)
});
}
it
(
"
auto-height
"
,
async
()
=>
{
await
page
.
setData
({
default_value
:
""
,
...
...
@@ -49,24 +57,31 @@ describe('component-native-textarea', () => {
height
}
=
await
textarea
.
size
()
expect
(
height
).
toBeLessThanOrEqual
(
200
)
await
page
.
setData
({
default_value
:
"
1
\n
2
\n
3
\n
4
\n
5
\n
6
"
,
auto_height_boolean
:
false
})
await
page
.
waitFor
(
500
)
var
{
width
,
height
}
=
await
textarea
.
size
()
expect
(
height
).
toEqual
(
200
)
if
(
!
isMP
)
{
// TODO 微信小程序auto-height由true切换成false时不会影响text-area高度
await
page
.
setData
({
default_value
:
"
1
\n
2
\n
3
\n
4
\n
5
\n
6
"
,
auto_height_boolean
:
false
})
await
page
.
waitFor
(
500
)
var
{
width
,
height
}
=
await
textarea
.
size
()
expect
(
height
).
toEqual
(
200
)
}
})
it
(
"
cursor-color
"
,
async
()
=>
{
await
page
.
setData
({
cursor_color
:
"
transparent
"
,
if
(
!
isMP
)
{
// 微信小程序text-area不支持cursor-color属性
it
(
"
cursor-color
"
,
async
()
=>
{
await
page
.
setData
({
cursor_color
:
"
transparent
"
,
})
await
page
.
waitFor
(
500
)
expect
(
await
textarea
.
attribute
(
"
cursor-color
"
)).
toBe
(
"
transparent
"
)
})
await
page
.
waitFor
(
500
)
expect
(
await
textarea
.
attribute
(
"
cursor-color
"
)).
toBe
(
"
transparent
"
)
})
}
it
(
"
flex 1 height exception
"
,
async
()
=>
{
const
bottomTextarea
=
await
page
.
$
(
'
#textarea-height-exception
'
);
...
...
@@ -77,21 +92,24 @@ describe('component-native-textarea', () => {
})
it
(
"
inputmode
"
,
async
()
=>
{
const
inputmodeEnum
=
await
page
.
data
(
"
inputmode_enum
"
)
for
(
var
i
=
0
;
i
<
inputmodeEnum
.
length
;
i
++
)
{
var
x
=
inputmodeEnum
[
i
]
console
.
log
(
x
[
'
value
'
],
x
[
'
name
'
])
var
selected
=
x
[
'
value
'
]
-
1
if
(
i
==
inputmodeEnum
.
length
-
1
)
{
selected
=
i
if
(
!
isMP
)
{
// 微信小程序自动化测试无法获取inputmode属性
it
(
"
inputmode
"
,
async
()
=>
{
const
inputmodeEnum
=
await
page
.
data
(
"
inputmode_enum
"
)
for
(
var
i
=
0
;
i
<
inputmodeEnum
.
length
;
i
++
)
{
var
x
=
inputmodeEnum
[
i
]
console
.
log
(
x
[
'
value
'
],
x
[
'
name
'
])
var
selected
=
x
[
'
value
'
]
-
1
if
(
i
==
inputmodeEnum
.
length
-
1
)
{
selected
=
i
}
await
page
.
callMethod
(
"
radio_change_inputmode_enum
"
,
selected
);
await
page
.
waitFor
(
500
)
expect
(
await
textarea
.
attribute
(
"
inputmode
"
)).
toEqual
(
x
[
'
name
'
])
await
page
.
waitFor
(
500
)
}
await
page
.
callMethod
(
"
radio_change_inputmode_enum
"
,
selected
);
await
page
.
waitFor
(
500
)
expect
(
await
textarea
.
attribute
(
"
inputmode
"
)).
toEqual
(
x
[
'
name
'
])
await
page
.
waitFor
(
500
)
}
})
})
}
it
(
"
maxlength
"
,
async
()
=>
{
const
input
=
await
page
.
$
(
'
#textarea-instance-maxlength
'
);
...
...
pages/component/video/video-format.uvue
浏览文件 @
7772a276
...
...
@@ -53,15 +53,19 @@
format: '3gp',
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.3gp'
},
// #ifndef WEB
// #ifndef WEB
|| MP
{
format: 'flv',
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.flv'
},
// #endif
// #ifndef WEB
{
format: 'm3u8',
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.m3u8'
},
// #endif
// #ifndef WEB || MP
{
format: '本地m3u8',
src: '/static/test-video/2minute-demo.m3u8'
...
...
@@ -80,10 +84,12 @@
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.ogg'
},
// #endif
// #ifndef MP
{
format: 'avi',
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.avi'
}
// #endif
] as Array<VideoFormat>)
// 自动化测试
...
...
pages/component/video/video.test.js
浏览文件 @
7772a276
jest
.
setTimeout
(
60000
);
describe
(
'
component-native-video
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)){
describe
(
'
component-native-video
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
if
(
isWeb
){
// TODO: web 端暂不支持测试
it
(
'
web
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
...
...
@@ -31,40 +36,44 @@ describe('component-native-video', () => {
expect
(
await
page
.
data
(
'
isPause
'
)).
toBe
(
true
);
});
it
(
'
test local source
'
,
async
()
=>
{
await
page
.
setData
({
autoTest
:
true
,
isError
:
false
});
const
oldSrc
=
await
page
.
data
(
'
src
'
);
await
page
.
callMethod
(
'
downloadSource
'
);
await
page
.
waitFor
(
5000
);
expect
(
await
page
.
data
(
'
isError
'
)).
toBe
(
false
);
await
page
.
setData
({
src
:
'
/static/test-video/2minute-demo.m3u8
'
});
await
page
.
waitFor
(
100
);
expect
(
await
page
.
data
(
'
isError
'
)).
toBe
(
false
);
await
page
.
setData
({
src
:
oldSrc
if
(
!
isMP
)
{
it
(
'
test local source
'
,
async
()
=>
{
await
page
.
setData
({
autoTest
:
true
,
isError
:
false
});
const
oldSrc
=
await
page
.
data
(
'
src
'
);
await
page
.
callMethod
(
'
downloadSource
'
);
await
page
.
waitFor
(
5000
);
expect
(
await
page
.
data
(
'
isError
'
)).
toBe
(
false
);
await
page
.
setData
({
src
:
'
/static/test-video/2minute-demo.m3u8
'
});
await
page
.
waitFor
(
100
);
expect
(
await
page
.
data
(
'
isError
'
)).
toBe
(
false
);
await
page
.
setData
({
src
:
oldSrc
});
});
});
it
(
'
test assets path
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
return
;
const
oldSrc
=
await
page
.
data
(
'
src
'
);
await
page
.
setData
({
isError
:
false
,
src
:
'
file:///android_asset/uni-autoTest/demo10s.mp4
'
it
(
'
test assets path
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
return
;
const
oldSrc
=
await
page
.
data
(
'
src
'
);
await
page
.
setData
({
isError
:
false
,
src
:
'
file:///android_asset/uni-autoTest/demo10s.mp4
'
});
await
page
.
waitFor
(
500
);
expect
(
await
page
.
data
(
'
isError
'
)).
toBe
(
false
);
await
page
.
setData
({
src
:
oldSrc
});
});
await
page
.
waitFor
(
500
);
expect
(
await
page
.
data
(
'
isError
'
)).
toBe
(
false
);
}
it
(
'
test event play pause controlstoggle
'
,
async
()
=>
{
await
page
.
setData
({
src
:
oldSrc
autoTest
:
true
,
});
});
it
(
'
test event play pause controlstoggle
'
,
async
()
=>
{
await
page
.
callMethod
(
'
play
'
);
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
...
...
@@ -76,42 +85,44 @@ describe('component-native-video', () => {
// });
}
else
{
expect
(
await
page
.
data
(
'
eventPlay
'
)).
toEqual
({
tagName
:
'
VIDEO
'
,
tagName
:
isMP
?
undefined
:
'
VIDEO
'
,
type
:
'
play
'
});
}
await
page
.
callMethod
(
'
pause
'
);
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventPause
'
))
||
(
Date
.
now
()
-
start
>
5
00
);
return
(
await
page
.
data
(
'
eventPause
'
))
||
(
Date
.
now
()
-
start
>
10
00
);
});
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
// expect(await page.data('eventPause')).toEqual({
// type: 'pause'
// });
}
else
{
}
else
{
expect
(
await
page
.
data
(
'
eventPause
'
)).
toEqual
({
tagName
:
'
VIDEO
'
,
tagName
:
isMP
?
undefined
:
'
VIDEO
'
,
type
:
'
pause
'
});
}
await
page
.
callMethod
(
'
play
'
);
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventControlstoggle
'
))
||
(
Date
.
now
()
-
start
>
500
);
});
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
// expect(await page.data('eventControlstoggle')).toEqual({
// tagName: 'VIDEO',
// type: 'controlstoggle',
// show: true
// });
}
else
{
expect
(
await
page
.
data
(
'
eventControlstoggle
'
)).
toEqual
({
tagName
:
'
VIDEO
'
,
type
:
'
controlstoggle
'
,
show
:
true
if
(
!
isMP
&&
!
isWeb
)
{
await
page
.
callMethod
(
'
play
'
);
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventControlstoggle
'
))
||
(
Date
.
now
()
-
start
>
1000
);
});
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
// expect(await page.data('eventControlstoggle')).toEqual({
// tagName: 'VIDEO',
// type: 'controlstoggle',
// show: true
// });
}
else
{
expect
(
await
page
.
data
(
'
eventControlstoggle
'
)).
toEqual
({
tagName
:
isMP
?
undefined
:
'
VIDEO
'
,
type
:
'
controlstoggle
'
,
show
:
true
});
}
}
});
...
...
@@ -126,56 +137,55 @@ describe('component-native-video', () => {
return
(
await
page
.
data
(
'
eventWaiting
'
))
&&
(
await
page
.
data
(
'
eventProgress
'
))
||
(
Date
.
now
()
-
start
>
1000
);
});
expect
(
await
page
.
data
(
'
eventWaiting
'
)).
toEqual
({
tagName
:
'
VIDEO
'
,
tagName
:
isMP
?
undefined
:
'
VIDEO
'
,
type
:
'
waiting
'
});
expect
(
await
page
.
data
(
'
eventProgress
'
)).
toEqual
({
tagName
:
'
VIDEO
'
,
tagName
:
isMP
?
undefined
:
'
VIDEO
'
,
type
:
'
progress
'
,
isBufferedValid
:
true
});
});
it
(
'
test event fullscreenchange fullscreenclick
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
return
;
}
await
page
.
callMethod
(
'
requestFullScreen
'
);
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventFullscreenchange
'
))
||
(
Date
.
now
()
-
start
>
1000
);
});
expect
(
await
page
.
data
(
'
eventFullscreenchange
'
)).
toEqual
({
tagName
:
'
VIDEO
'
,
type
:
'
fullscreenchange
'
,
fullScreen
:
true
,
direction
:
'
horizontal
'
});
const
infos
=
process
.
env
.
uniTestPlatformInfo
.
split
(
'
'
);
const
version
=
parseInt
(
infos
[
infos
.
length
-
1
]);
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
version
>
5
)
{
// android5.1模拟器全屏时会弹出系统提示框,无法响应adb tap命令
await
page
.
waitFor
(
5000
);
await
program
.
adbCommand
(
'
input tap 10 10
'
);
if
(
isAndroid
)
{
it
(
'
test event fullscreenchange fullscreenclick
'
,
async
()
=>
{
await
page
.
callMethod
(
'
requestFullScreen
'
);
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventFullscreenc
lick
'
))
||
(
Date
.
now
()
-
start
>
1000
);
return
(
await
page
.
data
(
'
eventFullscreenc
hange
'
))
||
(
Date
.
now
()
-
start
>
1000
);
});
const
res
=
await
program
.
adbCommand
(
'
wm size
'
);
const
width
=
res
.
data
.
split
(
'
'
).
at
(
-
1
).
split
(
'
x
'
)[
0
];
const
height
=
res
.
data
.
split
(
'
'
).
at
(
-
1
).
split
(
'
x
'
)[
1
];
const
res2
=
await
program
.
adbCommand
(
'
wm density
'
);
const
scale
=
res2
.
data
.
split
(
'
'
).
at
(
-
1
)
/
160
;
expect
(
await
page
.
data
(
'
eventFullscreenclick
'
)).
toEqual
({
tagName
:
'
VIDEO
'
,
type
:
'
fullscreenclick
'
,
screenX
:
parseInt
(
10
/
scale
),
screenY
:
parseInt
(
10
/
scale
),
screenWidth
:
parseInt
(
height
/
scale
),
screenHeight
:
parseInt
(
width
/
scale
)
expect
(
await
page
.
data
(
'
eventFullscreenchange
'
)).
toEqual
({
tagName
:
isMP
?
undefined
:
'
VIDEO
'
,
type
:
'
fullscreenchange
'
,
fullScreen
:
true
,
direction
:
'
horizontal
'
});
}
await
page
.
callMethod
(
'
exitFullScreen
'
);
});
const
infos
=
process
.
env
.
uniTestPlatformInfo
.
split
(
'
'
);
const
version
=
parseInt
(
infos
[
infos
.
length
-
1
]);
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
version
>
5
)
{
// android5.1模拟器全屏时会弹出系统提示框,无法响应adb tap命令
await
page
.
waitFor
(
5000
);
await
program
.
adbCommand
(
'
input tap 10 10
'
);
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventFullscreenclick
'
))
||
(
Date
.
now
()
-
start
>
1000
);
});
const
res
=
await
program
.
adbCommand
(
'
wm size
'
);
const
width
=
res
.
data
.
split
(
'
'
).
at
(
-
1
).
split
(
'
x
'
)[
0
];
const
height
=
res
.
data
.
split
(
'
'
).
at
(
-
1
).
split
(
'
x
'
)[
1
];
const
res2
=
await
program
.
adbCommand
(
'
wm density
'
);
const
scale
=
res2
.
data
.
split
(
'
'
).
at
(
-
1
)
/
160
;
expect
(
await
page
.
data
(
'
eventFullscreenclick
'
)).
toEqual
({
tagName
:
isMP
?
undefined
:
'
VIDEO
'
,
type
:
'
fullscreenclick
'
,
screenX
:
parseInt
(
10
/
scale
),
screenY
:
parseInt
(
10
/
scale
),
screenWidth
:
parseInt
(
height
/
scale
),
screenHeight
:
parseInt
(
width
/
scale
)
});
}
await
page
.
callMethod
(
'
exitFullScreen
'
);
});
}
it
(
'
test event ended timeupdate
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
...
...
@@ -187,7 +197,7 @@ describe('component-native-video', () => {
return
(
await
page
.
data
(
'
eventEnded
'
))
||
(
Date
.
now
()
-
start
>
30000
);
});
expect
(
await
page
.
data
(
'
eventEnded
'
)).
toEqual
({
tagName
:
'
VIDEO
'
,
tagName
:
isMP
?
undefined
:
'
VIDEO
'
,
type
:
'
ended
'
});
const
infos
=
process
.
env
.
uniTestPlatformInfo
.
split
(
'
'
);
...
...
@@ -198,7 +208,7 @@ describe('component-native-video', () => {
return
(
await
page
.
data
(
'
eventTimeupdate
'
))
||
(
Date
.
now
()
-
start
>
500
);
});
expect
(
await
page
.
data
(
'
eventTimeupdate
'
)).
toEqual
({
tagName
:
'
VIDEO
'
,
tagName
:
isMP
?
undefined
:
'
VIDEO
'
,
type
:
'
timeupdate
'
,
currentTime
:
121
,
duration
:
121
...
...
@@ -207,7 +217,7 @@ describe('component-native-video', () => {
});
it
(
'
test event error
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
)
)
{
if
(
isIOS
||
isMP
)
{
return
}
const
oldSrc
=
await
page
.
data
(
'
src
'
);
...
...
@@ -230,7 +240,9 @@ describe('component-native-video', () => {
});
it
(
'
test sub component
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
return
if
(
isIOS
||
isMP
)
{
return
}
await
page
.
setData
({
subCompEnable
:
true
,
subCompShow
:
true
...
...
pages/component/video/video.uvue
浏览文件 @
7772a276
...
...
@@ -229,9 +229,13 @@
this.videoContext?.play();
},
pause: function () {
console.log("pause");
(uni.getElementById("video") as UniVideoElement).pause(); //as写法测试。注意id不对时as会崩溃
// this.videoContext?.pause();
console.log("pause");
// #ifdef MP
this.videoContext?.pause();
// #endif
// #ifndef MP
(uni.getElementById("video") as UniVideoElement).pause(); //as写法测试。注意id不对时as会崩溃
// #endif
},
seek: function (pos : number) {
console.log("seek -> " + pos);
...
...
@@ -249,9 +253,13 @@
this.videoContext?.exitFullScreen();
},
stop: function () {
console.log("stop");
uni.getElementById<UniVideoElement>("video")?.stop(); //泛型写法测试
// this.videoContext?.stop();
console.log("stop");
// #ifdef MP
this.videoContext?.stop();
// #endif
// #ifndef MP
uni.getElementById<UniVideoElement>("video")?.stop(); //泛型写法测试
// #endif
},
sendDanmu: function () {
console.log("sendDanmu -> " + this.danmu);
...
...
pages/component/view/view.test.js
浏览文件 @
7772a276
...
...
@@ -4,7 +4,7 @@ const PAGE_PATH = '/pages/component/view/view'
describe
(
'
view-test
'
,
()
=>
{
// 先屏蔽 android 及 web 平台
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
)
{
if
(
isAndroid
||
isWeb
||
isMP
)
{
it
(
'
other platform
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
...
...
pages/component/web-view/web-view.test.js
浏览文件 @
7772a276
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
component-native-web-view
'
,
()
=>
{
if
(
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
&&
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
let
page
;
let
start
=
0
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/web-view/web-view
'
);
await
page
.
waitFor
(
3000
);
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
if
(
isWeb
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
it
(
'
web
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
let
page
;
let
start
=
0
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/web-view/web-view
'
);
await
page
.
waitFor
(
3000
);
});
it
(
'
check_load_url
'
,
async
()
=>
{
expect
(
await
page
.
data
(
'
loadError
'
)).
toBe
(
false
)
});
it
(
'
test attr webview-styles
'
,
async
()
=>
{
await
page
.
setData
({
webview_styles
:
{
progress
:
{
color
:
'
#FF0
'
}
}
});
await
page
.
waitFor
(
100
);
await
page
.
callMethod
(
'
reload
'
);
await
page
.
waitFor
(
100
);
await
page
.
setData
({
webview_styles
:
{
progress
:
{
color
:
'
yellow
'
}
}
});
await
page
.
waitFor
(
100
);
await
page
.
callMethod
(
'
reload
'
);
});
it
(
'
check_load_url
'
,
async
()
=>
{
expect
(
await
page
.
data
(
'
loadError
'
)).
toBe
(
false
)
if
(
isMP
)
{
return
}
it
(
'
test touch event
'
,
async
()
=>
{
await
page
.
setData
({
autoTest
:
true
});
const
info
=
await
page
.
callMethod
(
'
getWindowInfo
'
);
await
program
.
tap
({
x
:
1
,
y
:
info
.
statusBarHeight
+
44
+
1
});
await
page
.
waitFor
(
500
);
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
)
==
false
)
{
expect
(
await
page
.
data
(
'
isTouchEnable
'
)).
toBe
(
true
);
}
it
(
'
test attr webview-styles
'
,
async
()
=>
{
await
page
.
setData
({
webview_styles
:
{
progress
:
{
color
:
'
#FF0
'
}
}
await
page
.
setData
({
pointerEvents
:
'
none
'
,
isTouchEnable
:
false
});
await
page
.
waitFor
(
100
);
await
program
.
tap
({
x
:
10
,
y
:
info
.
statusBarHeight
+
44
+
10
});
await
page
.
waitFor
(
500
);
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
)
==
false
)
{
expect
(
await
page
.
data
(
'
isTouchEnable
'
)).
toBe
(
false
);
}
await
page
.
setData
({
pointerEvents
:
'
auto
'
});
});
it
(
'
test event loading load
'
,
async
()
=>
{
await
page
.
callMethod
(
'
reload
'
);
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventLoading
'
))
||
(
Date
.
now
()
-
start
>
500
);
});
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
if
(
platformInfo
.
indexOf
(
'
14.5
'
)
!=
-
1
||
platformInfo
.
indexOf
(
'
13.7
'
)
!=
-
1
||
platformInfo
.
indexOf
(
'
12.4
'
)
!=
-
1
)
{
expect
(
1
).
toBe
(
1
)
return
}
expect
(
await
page
.
data
(
'
eventLoading
'
)).
toEqual
({
"
tagName
"
:
"
WEB-VIEW
"
,
type
:
'
loading
'
,
src
:
'
https://www.dcloud.io/
'
});
await
page
.
waitFor
(
100
);
await
page
.
callMethod
(
'
reload
'
);
await
page
.
waitFor
(
100
);
await
page
.
setData
({
webview_styles
:
{
progress
:
{
color
:
'
yellow
'
}
}
}
else
{
expect
(
await
page
.
data
(
'
eventLoading
'
)).
toEqual
({
tagName
:
'
WEB-VIEW
'
,
type
:
'
loading
'
,
src
:
'
https://www.dcloud.io/
'
});
await
page
.
waitFor
(
100
);
await
page
.
callMethod
(
'
reload
'
);
});
it
(
'
test touch event
'
,
async
()
=>
{
await
page
.
setData
({
autoTest
:
true
});
const
info
=
await
page
.
callMethod
(
'
getWindowInfo
'
);
await
program
.
tap
({
x
:
1
,
y
:
info
.
statusBarHeight
+
44
+
1
});
await
page
.
waitFor
(
500
);
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
)
==
false
)
{
expect
(
await
page
.
data
(
'
isTouchEnable
'
)).
toBe
(
true
);
}
await
page
.
setData
({
pointerEvents
:
'
none
'
,
isTouchEnable
:
false
});
await
page
.
waitFor
(
100
);
await
program
.
tap
({
x
:
10
,
y
:
info
.
statusBarHeight
+
44
+
10
});
await
page
.
waitFor
(
500
);
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
)
==
false
)
{
expect
(
await
page
.
data
(
'
isTouchEnable
'
)).
toBe
(
false
);
}
await
page
.
setData
({
pointerEvents
:
'
auto
'
});
}
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventLoad
'
))
||
(
Date
.
now
()
-
start
>
5000
);
});
expect
(
await
page
.
data
(
'
eventLoad
'
)).
toEqual
({
tagName
:
'
WEB-VIEW
'
,
type
:
'
load
'
,
src
:
'
https://www.dcloud.io/
'
});
});
it
(
'
test event loading load
'
,
async
()
=>
{
await
page
.
callMethod
(
'
reload
'
);
it
(
'
test event error
'
,
async
()
=>
{
const
infos
=
process
.
env
.
uniTestPlatformInfo
.
split
(
'
'
);
const
version
=
parseInt
(
infos
[
infos
.
length
-
1
]);
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
version
>
5
)
{
await
page
.
setData
({
src
:
'
https://www.dclou.io/uni-app-x
'
});
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventLoading
'
))
||
(
Date
.
now
()
-
start
>
500
);
});
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
if
(
platformInfo
.
indexOf
(
'
14.5
'
)
!=
-
1
||
platformInfo
.
indexOf
(
'
13.7
'
)
!=
-
1
||
platformInfo
.
indexOf
(
'
12.4
'
)
!=
-
1
){
expect
(
1
).
toBe
(
1
)
return
}
expect
(
await
page
.
data
(
'
eventLoading
'
)).
toEqual
({
"
tagName
"
:
"
WEB-VIEW
"
,
type
:
'
loading
'
,
src
:
'
https://www.dcloud.io/
'
});
}
else
{
expect
(
await
page
.
data
(
'
eventLoading
'
)).
toEqual
({
tagName
:
'
WEB-VIEW
'
,
type
:
'
loading
'
,
src
:
'
https://www.dcloud.io/
'
});
}
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventLoad
'
))
||
(
Date
.
now
()
-
start
>
5000
);
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventError
'
))
||
(
Date
.
now
()
-
start
>
5000
);
});
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
expect
(
await
page
.
data
(
'
eventLoad
'
)).
toEqual
({
tagName
:
"
WEB-VIEW
"
,
type
:
'
load
'
,
src
:
'
https://www.dcloud.io/
'
});
}
else
{
expect
(
await
page
.
data
(
'
eventLoad
'
)).
toEqual
({
tagName
:
'
WEB-VIEW
'
,
type
:
'
load
'
,
src
:
'
https://www.dcloud.io/
'
});
}
expect
(
await
page
.
data
(
'
eventError
'
)).
toEqual
({
tagName
:
'
WEB-VIEW
'
,
type
:
'
error
'
,
errCode
:
100002
,
errMsg
:
'
page error
'
,
url
:
'
https://www.dclou.io
'
,
fullUrl
:
'
https://www.dclou.io/uni-app-x
'
,
src
:
'
https://www.dclou.io/uni-app-x
'
});
}
await
page
.
setData
({
autoTest
:
false
});
});
it
(
'
test event error
'
,
async
()
=>
{
const
infos
=
process
.
env
.
uniTestPlatformInfo
.
split
(
'
'
);
const
version
=
parseInt
(
infos
[
infos
.
length
-
1
]);
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
&&
version
>
5
)
{
await
page
.
setData
({
src
:
'
https://www.dclou.io/uni-app-x
'
});
start
=
Date
.
now
();
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventError
'
))
||
(
Date
.
now
()
-
start
>
5000
);
});
expect
(
await
page
.
data
(
'
eventError
'
)).
toEqual
({
tagName
:
'
WEB-VIEW
'
,
type
:
'
error
'
,
errCode
:
100002
,
errMsg
:
'
page error
'
,
url
:
'
https://www.dclou.io
'
,
fullUrl
:
'
https://www.dclou.io/uni-app-x
'
,
src
:
'
https://www.dclou.io/uni-app-x
'
});
}
await
page
.
setData
({
autoTest
:
false
});
});
it
(
'
checkNativeWebView
'
,
async
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
if
(
platformInfo
.
indexOf
(
'
14.5
'
)
!=
-
1
||
platformInfo
.
indexOf
(
'
13.7
'
)
!=
-
1
||
platformInfo
.
indexOf
(
'
12.4
'
)
!=
-
1
){
expect
(
1
).
toBe
(
1
)
return
}
await
page
.
waitFor
(
300
);
const
has
=
await
page
.
callMethod
(
'
checkNativeWebView
'
)
expect
(
has
).
toBe
(
true
)
})
}
else
{
// TODO: web 端暂不支持
it
(
'
web
'
,
async
()
=>
{
it
(
'
checkNativeWebView
'
,
async
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
if
(
platformInfo
.
indexOf
(
'
14.5
'
)
!=
-
1
||
platformInfo
.
indexOf
(
'
13.7
'
)
!=
-
1
||
platformInfo
.
indexOf
(
'
12.4
'
)
!=
-
1
)
{
expect
(
1
).
toBe
(
1
)
})
}
return
}
await
page
.
waitFor
(
300
);
const
has
=
await
page
.
callMethod
(
'
checkNativeWebView
'
)
expect
(
has
).
toBe
(
true
)
})
});
pages/pages.test.js
浏览文件 @
7772a276
...
...
@@ -3,6 +3,7 @@ const isAndroid = platformInfo.startsWith('android')
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isApp
=
isAndroid
||
isIos
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isAppWebview
=
!!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
let
pageIndex
=
0
...
...
@@ -24,14 +25,14 @@ const pages = [
'
/pages/component/scroll-view/scroll-view-refresher-props
'
,
'
/pages/component/scroll-view/scroll-view-custom-refresher-props
'
,
'
/pages/component/swiper/swiper
'
,
'
/pages/component/list-view/list-view
'
,
//
'/pages/component/list-view/list-view',
// 单独测试例截图
// '/pages/component/list-view/list-view-refresh',
// 单独测试例截图
// '/pages/component/list-view/list-view-multiplex',
'
/pages/component/list-view/list-view-multiplex-input
'
,
'
/pages/component/list-view/list-view-multiplex-video
'
,
'
/pages/component/list-view/list-view-children-in-slot
'
,
//
'/pages/component/list-view/list-view-multiplex-input',
//
'/pages/component/list-view/list-view-multiplex-video',
//
'/pages/component/list-view/list-view-children-in-slot',
// 单独测试例截图
// '/pages/component/sticky-section/sticky-section',
// 单独测试例截图
...
...
@@ -262,11 +263,11 @@ const pages = [
'
/pages/template/custom-tab-bar/custom-tab-bar
'
,
// 动态内容
// '/pages/template/calendar/calendar',
'
/pages/template/schema/schema
'
,
'
/uni_modules/uni-pay-x/pages/success/success
'
,
//
'/pages/template/schema/schema',
//
'/uni_modules/uni-pay-x/pages/success/success',
// 依赖 onload 参数获取 web-view src
// '/uni_modules/uni-pay-x/pages/ad-interactive-webview/ad-interactive-webview',
'
/uni_modules/uni-pay-x/pages/pay-desk/pay-desk
'
,
//
'/uni_modules/uni-pay-x/pages/pay-desk/pay-desk',
'
/pages/template/custom-long-list/custom-long-list
'
,
'
/pages/template/test-background-color-content/test-background-color-content
'
,
'
/pages/template/slider-100/slider-100
'
,
...
...
@@ -276,6 +277,18 @@ if (isAndroid && isWeb) {
pages
.
push
(
'
/pages/API/get-battery-info/get-battery-info
'
,
)
}
if
(
!
isMP
)
{
pages
.
push
(
'
/pages/component/list-view/list-view
'
,
'
/pages/component/list-view/list-view-multiplex-input
'
,
'
/pages/component/list-view/list-view-multiplex-video
'
,
'
/pages/component/list-view/list-view-children-in-slot
'
,
'
/pages/template/schema/schema
'
,
'
/uni_modules/uni-pay-x/pages/success/success
'
,
'
/uni_modules/uni-pay-x/pages/pay-desk/pay-desk
'
)
}
if
(
isApp
&&
!
isAppWebview
)
{
...
...
pages/template/calendar/calendar.test.js
浏览文件 @
7772a276
const
PAGE_PATH
=
'
/pages/template/calendar/calendar
'
describe
(
'
calendar
'
,
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
==
'
true
'
)
{
it
(
'
dummyTest
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isApp
=
isAndroid
||
isIos
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
if
(
isWeb
||
isMP
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
==
'
true
'
)
{
it
(
'
not support
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录