Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
c00030a1
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6048
Star
92
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看板
提交
c00030a1
编写于
2星期前
作者:
W
wanganxp
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://gitcode.net/dcloud/hello-uni-app-x
into dev
上级
de49f600
bdba7f46
alpha
dev
prod_alpha
v_4.41-alpha
无相关合并请求
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
843 addition
and
217 deletion
+843
-217
pages.json
pages.json
+38
-23
pages/API/create-inner-audio-context/inner-audio-path.uvue
pages/API/create-inner-audio-context/inner-audio-path.uvue
+61
-47
pages/API/create-selector-query/create-selector-query.test.js
...s/API/create-selector-query/create-selector-query.test.js
+8
-2
pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
...lement-by-id/get-element-by-id-multiple-root-node.test.js
+4
-2
pages/API/get-element-by-id/get-element-by-id.test.js
pages/API/get-element-by-id/get-element-by-id.test.js
+3
-1
pages/API/request/request.uvue
pages/API/request/request.uvue
+1
-1
pages/API/upload-file/upload-file.test.js
pages/API/upload-file/upload-file.test.js
+20
-16
pages/API/upload-file/upload-file.uvue
pages/API/upload-file/upload-file.uvue
+7
-3
pages/component/button/button.test.js
pages/component/button/button.test.js
+1
-1
pages/component/canvas/canvas.uvue
pages/component/canvas/canvas.uvue
+7
-2
pages/component/checkbox/checkbox.test.js
pages/component/checkbox/checkbox.test.js
+57
-35
pages/component/form/form.test.js
pages/component/form/form.test.js
+8
-2
pages/component/global-events/global-events.test.js
pages/component/global-events/global-events.test.js
+9
-4
pages/component/global-events/touch-events.test.js
pages/component/global-events/touch-events.test.js
+5
-1
pages/component/grid-view/grid-view.test.js
pages/component/grid-view/grid-view.test.js
+115
-0
pages/component/grid-view/grid-view.uvue
pages/component/grid-view/grid-view.uvue
+341
-0
pages/component/image/image.test.js
pages/component/image/image.test.js
+8
-22
pages/component/input/input.test.js
pages/component/input/input.test.js
+73
-51
pages/component/list-view/list-view.test.js
pages/component/list-view/list-view.test.js
+2
-2
pages/component/list-view/list-view.uvue
pages/component/list-view/list-view.uvue
+2
-0
pages/tabBar/template.uvue
pages/tabBar/template.uvue
+2
-2
pages/template/vant/vant.test.js
pages/template/vant/vant.test.js
+28
-0
pages/template/vant/vant.uvue
pages/template/vant/vant.uvue
+43
-0
未找到文件。
pages.json
浏览文件 @
c00030a1
...
...
@@ -132,7 +132,7 @@
//
#ifdef
APP-ANDROID
||
APP-IOS
||
WEB
{
"path"
:
"pages/component/sticky-section/sticky-section"
,
"group"
:
"0,1,
7
,1"
,
"group"
:
"0,1,
8
,1"
,
"style"
:
{
"navigationBarTitleText"
:
"sticky-section | 吸顶布局容器"
}
...
...
@@ -141,7 +141,7 @@
//
#ifdef
APP-ANDROID
||
APP-IOS
||
WEB
{
"path"
:
"pages/component/sticky-header/sticky-header"
,
"group"
:
"0,1,
7
,0"
,
"group"
:
"0,1,
8
,0"
,
"style"
:
{
"navigationBarTitleText"
:
"sticky-header | 吸顶布局容器"
,
"enablePullDownRefresh"
:
false
...
...
@@ -485,7 +485,7 @@
//
#ifdef
APP-ANDROID
||
APP-IOS
{
"path"
:
"pages/component/nested-scroll-header/nested-scroll-header"
,
"group"
:
"0,1,
8
,0"
,
"group"
:
"0,1,
9
,0"
,
"style"
:
{
"navigationBarTitleText"
:
"nested-scroll-header"
}
...
...
@@ -494,7 +494,7 @@
//
#ifdef
APP-ANDROID
||
APP-IOS
{
"path"
:
"pages/component/nested-scroll-body/nested-scroll-body"
,
"group"
:
"0,1,
8
,1"
,
"group"
:
"0,1,
9
,1"
,
"style"
:
{
"navigationBarTitleText"
:
"nested-scroll-body"
}
...
...
@@ -626,6 +626,15 @@
}
},
//
#endif
//
#ifdef
APP-ANDROID
||
APP-IOS
{
"path"
:
"pages/component/grid-view/grid-view"
,
"group"
:
"0,1,7"
,
"style"
:
{
"navigationBarTitleText"
:
"grid-view | 表格容器"
}
},
//
#endif
//
#ifdef
APP-ANDROID
||
APP-IOS
||
MP-WEIXIN
{
"path"
:
"pages/component/ad/list-view-ad"
,
...
...
@@ -1299,7 +1308,7 @@
}
},
//
#endif
//
#ifdef
APP
||
WEB
||
MP-WEIXIN
//
#ifdef
APP
-ANDROID
||
WEB
||
MP-WEIXIN
{
"path"
:
"pages/API/create-inner-audio-context/create-inner-audio-context"
,
"group"
:
"1,7,9"
,
...
...
@@ -1308,7 +1317,7 @@
}
},
//
#endif
//
#ifdef
APP
||
WEB
||
MP-WEIXIN
//
#ifdef
APP
-ANDROID
||
WEB
||
MP-WEIXIN
{
"path"
:
"pages/API/create-inner-audio-context/inner-audio-format"
,
"style"
:
{
...
...
@@ -1316,7 +1325,7 @@
}
},
//
#endif
//
#ifdef
APP
||
WEB
||
MP-WEIXIN
//
#ifdef
APP
-ANDROID
||
WEB
||
MP-WEIXIN
{
"path"
:
"pages/API/create-inner-audio-context/inner-audio-path"
,
"style"
:
{
...
...
@@ -1324,7 +1333,7 @@
}
},
//
#endif
//
#ifdef
APP
||
WEB
||
MP-WEIXIN
//
#ifdef
APP
-ANDROID
||
WEB
||
MP-WEIXIN
{
"path"
:
"pages/API/create-inner-audio-context/inner-audio-mult"
,
"style"
:
{
...
...
@@ -1350,7 +1359,7 @@
}
},
//
#endif
//
#ifdef
APP-ANDROID
||
APP-IOS
||
MP-WEIXIN
//
#ifdef
APP-ANDROID
||
APP-IOS
||
WEB
||
MP-WEIXIN
{
"path"
:
"pages/API/theme-change/theme-change"
,
"group"
:
"1,4,7"
,
...
...
@@ -1468,7 +1477,7 @@
{
"path"
:
"pages/API/dialog-page/dialog-2"
,
"style"
:
{
"navigationBarTitleText"
:
"dialogPage
1
"
"navigationBarTitleText"
:
"dialogPage
2
"
}
},
//
#endif
...
...
@@ -2283,18 +2292,20 @@
}
},
//
#endif
//
#ifdef
MP
{
"path"
:
"pages/template/vant-button/vant-button"
,
"style"
:
{
"navigationBarTitleText"
:
"微信自定义组件示例"
,
"usingComponents"
:
{
"van-button"
:
"/wxcomponents/vant/button/index"
}
}
}
//
#endif
//
#ifdef
MP
{
"path"
:
"pages/template/vant/vant"
,
"style"
:
{
"navigationBarTitleText"
:
"微信自定义组件示例"
,
"usingComponents"
:
{
"vant-button"
:
"/wxcomponents/vant/button/index"
,
"vant-icon"
:
"/wxcomponents/vant/icon/index"
,
"vant-info"
:
"/wxcomponents/vant/info/index"
,
"vant-loading"
:
"/wxcomponents/vant/loading/index"
}
}
}
//
#endif
],
"globalStyle"
:
{
//
#ifdef
APP-ANDROID
...
...
@@ -2403,6 +2414,10 @@
"id"
:
"component.view-container.list-view"
,
"name"
:
"list-view"
},
{
"id"
:
"component.view-container.grid-view"
,
"name"
:
"grid-view"
},
{
"id"
:
"component.view-container.sticky"
,
"name"
:
"sticky"
,
...
...
@@ -3291,4 +3306,4 @@
]
}
]
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pages/API/create-inner-audio-context/inner-audio-path.uvue
浏览文件 @
c00030a1
...
...
@@ -22,23 +22,23 @@
return {
title: 'audio-path',
playIndex: 0,
isPlaying: false,
nativePath:uni.env.CACHE_PATH+'uni-audio/test/test.mp3' as string,
sdcardPath :
'sdcard/uni-audio/test.mp3',
isPlaying: false,
nativePath: uni.env.CACHE_PATH + 'uni-audio/test/test.mp3' as string,
sdcardPath:
'sdcard/uni-audio/test.mp3',
_audioContext: null as InnerAudioContext | null,
supportPaths: [
{
description: '本地路径:/static方式',
src: '/static/test-audio/ForElise.mp3'
},
{
{
description: '本地路径:../static/',
src: '../../../static/test-audio/ForElise.mp3'
},
{
description: '本地路径:env方式',
src: 'env'
},
},
{
description: '本地路径:env方式',
src: 'env'
},
{
description: '网络路径',
src: 'https://web-ext-storage.dcloud.net.cn/uni-app-x/audio/ForElise.mp3'
...
...
@@ -55,37 +55,51 @@
}
},
onReady() {
this._audioContext = uni.createInnerAudioContext();
this._audioContext!.onPlay(() => {
console.log('开始播放');
});
this._audioContext!.onEnded(() => {
console.log('播放结束');
this.isPlaying = false;
});
this._audioContext!.onError((err) => {
this.isPlaying = false;
console.log('err', err);
});
const fileManager = uni.getFileSystemManager()
try {
fileManager.rmdirSync(uni.env.CACHE_PATH+'uni-audio/test',true)
} catch (e) {
}
try {
fileManager.mkdirSync(uni.env.CACHE_PATH+'uni-audio/test',true)
} catch (e) {
}
try{
fileManager.copyFileSync(
'/static/test-audio/ForElise.mp3',
this.nativePath)
} catch(e){
}
},
this._audioContext = uni.createInnerAudioContext();
this._audioContext!.onPlay(() => {
console.log('开始播放');
});
this._audioContext!.onEnded(() => {
console.log('播放结束');
this.isPlaying = false;
});
this._audioContext!.onError((err) => {
this.isPlaying = false;
console.log('err', err);
});
const fileManager = uni.getFileSystemManager()
fileManager.mkdir({
dirPath: uni.env.CACHE_PATH + 'uni-audio/test',
recursive: true,
success: (res) => {
fileManager.copyFile({
srcPath: '/static/test-audio/ForElise.mp3',
destPath: this.nativePath,
success: () => {
console.log("copy成功: ", res)
}
})
},
fail: (err) => {
console.log("创建路径失败: ", err.errMsg)
if (err.errMsg.includes("file already exists")) {
console.log("已经包含该路径")
fileManager.copyFile({
srcPath: '/static/test-audio/ForElise.mp3',
destPath: this.nativePath,
success: (res) => {
console.log("copy成功: ", res)
},
fail: (err) => {
console.log("copy失败: ", err)
}
})
}
}
})
},
onUnload() {
if (this._audioContext != null) {
this.pause();
...
...
@@ -97,16 +111,16 @@
this._audioContext!.pause();
this.isPlaying = false;
},
play(audioUrl
:string, index:
number) {
console.log(index,audioUrl);
play(audioUrl
: string, index :
number) {
console.log(index,
audioUrl);
if (this.isPlaying && this.playIndex == index) {
this.pause();
return;
}
if(audioUrl == 'env'){
audioUrl=this.nativePath
}
}
if (audioUrl == 'env') {
audioUrl = this.nativePath
}
this.playIndex = index
this._audioContext!.src = audioUrl;
this._audioContext!.play();
...
...
This diff is collapsed.
Click to expand it.
pages/API/create-selector-query/create-selector-query.test.js
浏览文件 @
c00030a1
...
...
@@ -76,7 +76,10 @@ describe('nodes-info', () => {
// #endif
it
(
'
test filelds
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
)
)
{
expect
(
true
).
toBe
(
true
)
}
else
{
const
pageData
=
await
page
.
data
()
...
...
@@ -85,7 +88,10 @@ describe('nodes-info', () => {
})
it
(
'
test node
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
)
)
{
expect
(
true
).
toBe
(
true
)
}
else
{
const
pageData
=
await
page
.
data
()
...
...
This diff is collapsed.
Click to expand it.
pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
浏览文件 @
c00030a1
...
...
@@ -11,8 +11,10 @@ describe("getElementByIdForMultipleRootNode", () => {
const
res
=
await
page
.
callMethod
(
"
getElementByNotExistId
"
);
expect
(
res
).
toBe
(
null
);
});
it
(
"
changeStyle
"
,
async
()
=>
{
await
page
.
callMethod
(
"
changePageHeadBackgroundColor
"
);
it
(
"
changeStyle
"
,
async
()
=>
{
if
(
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
))
{
await
page
.
callMethod
(
"
changePageHeadBackgroundColor
"
);
}
await
page
.
callMethod
(
"
changeTextColor
"
);
await
page
.
callMethod
(
"
changeViewStyle
"
);
await
page
.
waitFor
(
500
);
...
...
This diff is collapsed.
Click to expand it.
pages/API/get-element-by-id/get-element-by-id.test.js
浏览文件 @
c00030a1
...
...
@@ -11,7 +11,9 @@ describe("getElementById", () => {
expect
(
res
).
toBe
(
null
);
});
it
(
"
changeStyle
"
,
async
()
=>
{
await
page
.
callMethod
(
"
changePageHeadBackgroundColor
"
);
if
(
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
))
{
await
page
.
callMethod
(
"
changePageHeadBackgroundColor
"
);
}
await
page
.
callMethod
(
"
changeTextColor
"
);
await
page
.
callMethod
(
"
changeViewStyle
"
);
await
page
.
waitFor
(
500
);
...
...
This diff is collapsed.
Click to expand it.
pages/API/request/request.uvue
浏览文件 @
c00030a1
...
...
@@ -9,7 +9,7 @@
<text>请求方式 : {{method}}</text>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @click="
jest_respone_with_404_and_string_generics
">发起请求</button>
<button type="primary" @click="
sendRequest
">发起请求</button>
</view>
</view>
<scroll-view style="flex: 1;" show-scrollbar="true">
...
...
This diff is collapsed.
Click to expand it.
pages/API/upload-file/upload-file.test.js
浏览文件 @
c00030a1
...
...
@@ -7,35 +7,39 @@ describe('ExtApi-UploadFile', () => {
expect
(
1
).
toBe
(
1
)
})
return
}
}
const
isUploadProjectFileSupported
=
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
)
let
page
;
let
res
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
600
);
await
page
.
callMethod
(
'
jest_uploadFile
'
);
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
});
beforeEach
(
async
()
=>
{
await
page
.
setData
({
jest_result
:
false
})
});
it
(
'
Check
'
,
async
()
=>
{
expect
(
res
).
toBe
(
true
);
});
it
(
'
Check files upload
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_files_upload
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
if
(
isUploadProjectFileSupported
)
{
it
(
'
Check
'
,
async
()
=>
{
await
page
.
waitFor
(
600
);
await
page
.
callMethod
(
'
jest_uploadFile
'
);
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
);
});
it
(
'
Check files upload
'
,
async
()
=>
{
res
=
await
page
.
callMethod
(
'
jest_files_upload
'
)
await
page
.
waitFor
(
2000
);
res
=
await
page
.
data
(
'
jest_result
'
);
expect
(
res
).
toBe
(
true
)
});
}
it
(
'
Check uni.env
'
,
async
()
=>
{
await
page
.
callMethod
(
'
jest_uploadFile_with_uni_env
'
);
await
page
.
waitFor
(
2000
);
...
...
This diff is collapsed.
Click to expand it.
pages/API/upload-file/upload-file.uvue
浏览文件 @
c00030a1
...
...
@@ -9,7 +9,8 @@
<image v-if="imageSrc" :src="imageSrc" class="image" mode="widthFix"></image>
<text v-else class="uni-hello-addfile" @click="chooseImage">+ 选择图片</text>
</view>
</view>
</view>
<button @click="jest_uploadFile_with_uni_env">jest_uploadFile_with_uni_env</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
...
...
@@ -104,8 +105,11 @@
},
})
},
jest_uploadFile_with_uni_env() {
const filePath = `${uni.env.CACHE_PATH}/download/uni-app.png`
jest_uploadFile_with_uni_env() {
/**
* 微信小程序只支持USER_DATA_PATH,且子目录未创建的情况下不能直接下载到子目录内
*/
const filePath = `${uni.env.USER_DATA_PATH}/uni-app.png`
uni.downloadFile({
url: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
filePath: filePath,
...
...
This diff is collapsed.
Click to expand it.
pages/component/button/button.test.js
浏览文件 @
c00030a1
...
...
@@ -79,7 +79,7 @@ describe('Button.uvue', () => {
})
it
(
"
checkUniButtonElement
"
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
))
{
expect
(
1
).
toBe
(
1
)
return
}
...
...
This diff is collapsed.
Click to expand it.
pages/component/canvas/canvas.uvue
浏览文件 @
c00030a1
...
...
@@ -94,14 +94,19 @@
// #ifdef WEB
context.toBlob((blob : Blob) => {
this.testToBlobResult = (blob.size > 0 && blob.type == 'image/jpeg')
}, 'image/jpeg', 0.95)
}, 'image/jpeg', 0.95);
this.testToDataURLResult = this.canvasContext!.toDataURL().startsWith('data:image/png;base64')
// #endif
this.testToDataURLResult = context.toDataURL().startsWith('data:image/png;base64')
this.testCanvasContext = true
}
})
},
onReady() {
// TODO app-android 需要延迟调用
// #ifdef APP
this.testToDataURLResult = this.canvasContext!.toDataURL().startsWith('data:image/png;base64')
// #endif
// 同步调用方式,仅支持 app/web
// let canvas = uni.getElementById("canvas") as UniCanvasElement
// this.renderingContext = canvas.getContext("2d")
...
...
This diff is collapsed.
Click to expand it.
pages/component/checkbox/checkbox.test.js
浏览文件 @
c00030a1
...
...
@@ -14,18 +14,23 @@ beforeAll(async () => {
})
describe
(
'
Checkbox.uvue
'
,
()
=>
{
const
isMP
=
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
)
it
(
'
change
'
,
async
()
=>
{
expect
(
await
getData
(
'
value
'
)).
toEqual
([])
const
cb1
=
await
page
.
$
(
'
.cb1
'
)
await
cb1
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
([
'
cb
'
,
'
cb1
'
])
const
cb
=
await
page
.
$
(
'
.cb
'
)
await
cb
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
([
'
cb1
'
])
const
cb2
=
await
page
.
$
(
'
.cb2
'
)
await
cb2
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
([
'
cb1
'
])
await
cb1
.
tap
()
await
page
.
waitFor
(
100
)
expect
(
await
getData
(
'
value
'
)).
toEqual
([])
})
it
(
'
length
'
,
async
()
=>
{
...
...
@@ -42,6 +47,29 @@ describe('Checkbox.uvue', () => {
})
expect
(
await
cb
.
text
()).
toEqual
(
'
not selected
'
)
})
if
(
isMP
)
{
it
(
'
disabled
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb2
'
)
const
disabled1
=
await
cb
.
property
(
'
disabled
'
)
expect
(
disabled1
).
toBe
(
true
)
await
page
.
setData
({
disabled
:
false
,
})
const
disabled2
=
await
cb
.
property
(
'
disabled
'
)
expect
(
disabled2
).
toBe
(
false
)
})
}
else
{
it
(
'
disabled
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb2
'
)
const
disabled1
=
await
cb
.
attribute
(
'
disabled
'
)
expect
(
disabled1
).
toBe
(
true
+
''
)
await
page
.
setData
({
disabled
:
false
,
})
const
disabled2
=
await
cb
.
attribute
(
'
disabled
'
)
expect
(
disabled2
).
toBe
(
false
+
''
)
})
}
it
(
'
checked
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb
'
)
// TODO
...
...
@@ -54,44 +82,38 @@ describe('Checkbox.uvue', () => {
const
newValue2
=
await
cb
.
property
(
'
checked
'
)
expect
(
newValue2
.
toString
()).
toBe
(
false
+
''
)
})
it
(
'
color
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb
'
)
expect
(
await
cb
.
attribute
(
'
color
'
)).
toBe
(
'
#007aff
'
)
await
page
.
setData
({
color
:
'
#63acfc
'
,
if
(
!
isMP
)
{
it
(
'
color
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb
'
)
expect
(
await
cb
.
attribute
(
'
color
'
)).
toBe
(
'
#007aff
'
)
await
page
.
setData
({
color
:
'
#63acfc
'
,
})
expect
(
await
cb
.
attribute
(
'
color
'
)).
toBe
(
'
#63acfc
'
)
})
expect
(
await
cb
.
attribute
(
'
color
'
)).
toBe
(
'
#63acfc
'
)
})
it
(
'
icon color
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb
'
)
expect
(
await
cb
.
attribute
(
'
iconColor
'
)).
toBe
(
'
#211cfe
'
)
await
page
.
setData
({
iconColor
:
'
#63acfc
'
,
it
(
'
icon color
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb
'
)
expect
(
await
cb
.
attribute
(
'
iconColor
'
)).
toBe
(
'
#211cfe
'
)
await
page
.
setData
({
iconColor
:
'
#63acfc
'
,
})
expect
(
await
cb
.
attribute
(
'
iconColor
'
)).
toBe
(
'
#63acfc
'
)
})
expect
(
await
cb
.
attribute
(
'
iconColor
'
)).
toBe
(
'
#63acfc
'
)
}
)
it
(
'
foreColor
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb
'
)
expect
(
await
cb
.
attribute
(
'
foreColor
'
)).
toBe
(
'
#ff0000
'
)
await
page
.
setData
({
foreColor
:
'
#63acfe
'
,
it
(
'
foreColor
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb
'
)
expect
(
await
cb
.
attribute
(
'
foreColor
'
)).
toBe
(
'
#ff0000
'
)
await
page
.
setData
({
foreColor
:
'
#63acfe
'
,
})
expect
(
await
cb
.
attribute
(
'
foreColor
'
)).
toBe
(
'
#63acfe
'
)
})
expect
(
await
cb
.
attribute
(
'
foreColor
'
)).
toBe
(
'
#63acfe
'
)
})
it
(
'
disabled
'
,
async
()
=>
{
const
cb
=
await
page
.
$
(
'
.cb2
'
)
expect
(
await
cb
.
attribute
(
'
disabled
'
)).
toBe
(
true
+
''
)
await
page
.
setData
({
disabled
:
false
,
it
(
'
trigger UniCheckboxGroupChangeEvent
'
,
async
()
=>
{
const
element
=
await
page
.
$
(
'
.checkbox-item-0
'
)
await
element
.
tap
()
await
page
.
waitFor
(
1000
)
const
{
testEvent
}
=
await
page
.
data
()
expect
(
testEvent
).
toBe
(
true
)
})
expect
(
await
cb
.
attribute
(
'
disabled
'
)).
toBe
(
false
+
''
)
})
it
(
'
trigger UniCheckboxGroupChangeEvent
'
,
async
()
=>
{
const
element
=
await
page
.
$
(
'
.checkbox-item-0
'
)
await
element
.
tap
()
await
page
.
waitFor
(
1000
)
const
{
testEvent
}
=
await
page
.
data
()
expect
(
testEvent
).
toBe
(
true
)
})
}
})
This diff is collapsed.
Click to expand it.
pages/component/form/form.test.js
浏览文件 @
c00030a1
...
...
@@ -15,6 +15,7 @@ const CHANGE_SWITCH = false
const
CHANGE_COMMENT
=
'
备注
'
describe
(
'
form
'
,
()
=>
{
const
isMP
=
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
)
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
...
...
@@ -39,9 +40,14 @@ describe('form', () => {
expect
(
formData
[
'
age
'
]).
toBe
(
CHANGE_AGE
)
expect
(
formData
[
'
switch
'
]).
toBe
(
CHANGE_SWITCH
)
expect
(
formData
[
'
comment
'
]).
toBe
(
CHANGE_COMMENT
)
expect
(
testVerifySubmit
).
toBe
(
true
)
if
(
!
isMP
)
{
expect
(
testVerifySubmit
).
toBe
(
true
)
}
})
if
(
isMP
)
{
// 微信小程序reset和app、web表现不一致。暂时屏蔽reset测试例,后续如果拉齐再放开
return
}
it
(
'
reset
'
,
async
()
=>
{
await
changeData
(
page
)
...
...
This diff is collapsed.
Click to expand it.
pages/component/global-events/global-events.test.js
浏览文件 @
c00030a1
...
...
@@ -41,7 +41,8 @@ describe('event trigger', () => {
screenX
:
101
,
screenY
:
101
},
],
})
})
await
page
.
waitFor
(
100
)
const
touchStartTouchTargetIdentifier
=
'
1
'
const
touchStartTouchTargetValue
=
'
101
'
const
touchStartTouchIdentifier
=
await
page
.
$
(
'
#touch-start-touch-identifier
'
)
...
...
@@ -93,7 +94,8 @@ describe('event trigger', () => {
screenX
:
102
,
screenY
:
102
},
],
})
})
await
page
.
waitFor
(
100
)
const
touchMoveTouchTargetIdentifier
=
'
1
'
const
touchMoveTouchTargetValue
=
'
102
'
...
...
@@ -145,7 +147,8 @@ describe('event trigger', () => {
screenX
:
103
,
screenY
:
103
},
],
})
})
await
page
.
waitFor
(
100
)
const
touchEndTouchTargetIdentifier
=
'
1
'
const
touchEndTouchTargetValue
=
'
103
'
const
touchEndTouchIdentifier
=
await
page
.
$
(
'
#touch-end-touch-identifier
'
)
...
...
@@ -193,6 +196,7 @@ describe('event trigger', () => {
}
else
{
const
el
=
await
page
.
$
(
'
#longpress-target
'
)
await
el
.
tap
()
await
page
.
waitFor
(
100
)
const
targetX
=
'
0
'
const
targetY
=
'
0
'
const
tapEventX
=
await
page
.
$
(
'
#tap-event-x
'
)
...
...
@@ -209,7 +213,8 @@ describe('event trigger', () => {
it
(
'
longPress
'
,
async
()
=>
{
if
(
!
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
)
{
const
el
=
await
page
.
$
(
'
#longpress-target
'
)
await
el
.
longpress
()
await
el
.
longpress
()
await
page
.
waitFor
(
100
)
if
(
isMP
)
{
const
longPressTouchIdentifier
=
await
page
.
$
(
'
#long-press-touch-identifier
'
)
expect
(
await
longPressTouchIdentifier
.
text
()).
toBe
(
'
0
'
)
...
...
This diff is collapsed.
Click to expand it.
pages/component/global-events/touch-events.test.js
浏览文件 @
c00030a1
...
...
@@ -3,7 +3,11 @@ const PAGE_PATH = '/pages/component/global-events/touch-events'
describe
(
'
touch-events-test
'
,
()
=>
{
// 先屏蔽 android 及 web 平台
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
)
)
{
it
(
'
other platform
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
...
...
This diff is collapsed.
Click to expand it.
pages/component/grid-view/grid-view.test.js
0 → 100644
浏览文件 @
c00030a1
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
describe
(
'
component-native-grid-view
'
,
()
=>
{
if
(
isMP
)
{
it
(
'
skip mp
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
let
page
beforeAll
(
async
()
=>
{
//打开grid-view测试页
page
=
await
program
.
reLaunch
(
'
/pages/component/grid-view/grid-view
'
)
await
page
.
waitFor
(
600
)
})
//检测竖向scrolltop属性赋值
it
(
'
check_scroll_top
'
,
async
()
=>
{
await
page
.
callMethod
(
'
confirm_scroll_top_input
'
,
600
)
await
page
.
waitFor
(
600
)
const
listElement
=
await
page
.
$
(
'
#gridview
'
)
const
scrollTop
=
await
listElement
.
attribute
(
"
scrollTop
"
)
console
.
log
(
"
check_scroll_top---
"
+
scrollTop
)
expect
(
scrollTop
-
600
).
toBeGreaterThanOrEqual
(
0
)
})
it
(
'
Event check_scroll
'
,
async
()
=>
{
await
page
.
callMethod
(
'
confirm_scroll_top_input
'
,
300
)
await
page
.
waitFor
(
600
)
const
scrollDetail
=
await
page
.
data
(
'
scrollDetailTest
'
)
// console.log('scrollDetailTest:', scrollDetail)
expect
(
scrollDetail
.
scrollLeft
).
toBe
(
0
)
// scrollTop和deltaY 在安卓端差异 299.8095
expect
([
300
,
299.8095
]).
toContain
(
scrollDetail
.
scrollTop
);
expect
(
scrollDetail
.
scrollHeight
).
toBeGreaterThan
(
0
)
expect
(
scrollDetail
.
scrollWidth
).
toBeGreaterThan
(
0
)
expect
(
scrollDetail
.
deltaX
).
toBe
(
0
)
//此处可判断安卓issues:9121的问题
expect
([
300.1905
,
300
,
299.8095
]).
toContain
(
scrollDetail
.
deltaY
);
expect
(
await
page
.
data
(
'
isScrollTest
'
)).
toBe
(
'
scroll:Success
'
)
})
it
(
'
Event scrolltolower-滚动到底部/右边
'
,
async
()
=>
{
// 滚动到底部,是否触发scrolltolower事件
await
page
.
callMethod
(
'
confirm_scroll_top_input
'
,
2500
)
await
page
.
waitFor
(
600
)
expect
(
await
page
.
data
(
'
isScrolltolowerTest
'
)).
toBe
(
'
scrolltolower:Success-bottom
'
)
})
it
(
'
Event scrolltoupper-滚动到顶部/左边
'
,
async
()
=>
{
// 滚动到顶部50,是否触发scrolltoupper事件
await
page
.
callMethod
(
'
confirm_scroll_top_input
'
,
50
)
await
page
.
waitFor
(
1000
)
expect
(
await
page
.
data
(
'
isScrolltoupperTest
'
)).
toBe
(
'
scrolltoupper:Success-top
'
)
})
it
(
'
Event scrollend-滚动结束时触发
'
,
async
()
=>
{
// 仅App端支持,向上滑动页面
await
program
.
swipe
({
startPoint
:
{
x
:
100
,
y
:
300
},
endPoint
:
{
x
:
100
,
y
:
100
},
duration
:
100
})
await
page
.
waitFor
(
600
)
const
endDetail
=
await
page
.
data
(
'
scrollEndDetailTest
'
)
// console.log('scrollEndDetailTest:', endDetail)
expect
(
endDetail
.
deltaY
).
toBe
(
0
)
expect
(
endDetail
.
deltaX
).
toBe
(
0
)
expect
(
endDetail
.
scrollLeft
).
toBe
(
0
)
expect
(
endDetail
.
scrollTop
).
toBeGreaterThan
(
0
)
expect
(
endDetail
.
scrollHeight
).
toBeGreaterThan
(
0
)
expect
(
endDetail
.
scrollWidth
).
toBeGreaterThan
(
0
)
})
//检测竖向可滚动区域
it
(
'
check_scroll_height
'
,
async
()
=>
{
await
page
.
waitFor
(
600
)
const
value
=
await
page
.
callMethod
(
'
check_scroll_height
'
)
expect
(
value
).
toBe
(
true
)
})
// //检测下拉刷新 备注:iOS本地测试结果正确,但是自动化测试结果错误
it
(
'
check_refresher
'
,
async
()
=>
{
await
page
.
callMethod
(
'
confirm_scroll_top_input
'
,
0
)
await
page
.
setData
({
refresher_enabled_boolean
:
true
,
refresher_triggered_boolean
:
true
})
await
page
.
waitFor
(
2000
)
expect
(
await
page
.
data
(
'
refresherrefresh
'
)).
toBe
(
true
)
//延迟 等待下拉刷新执行结束 防止后续测试任务结果异常
await
page
.
waitFor
(
1000
)
})
//检测竖向scroll_into_view属性赋值 备注:iOS本地测试结果正确,但是自动化测试结果错误
it
(
'
check_scroll_into_view_top
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setScrollIntoView
'
,
'
item---3
'
)
await
page
.
waitFor
(
600
)
const
gridElement
=
await
page
.
$
(
'
#gridview
'
)
const
scrollTop
=
await
gridElement
.
attribute
(
"
scrollTop
"
)
console
.
log
(
"
check_scroll_into_view_top--
"
+
scrollTop
)
await
page
.
callMethod
(
'
setScrollIntoView
'
,
'
item---0
'
)
expect
(
scrollTop
-
280
).
toBeGreaterThanOrEqual
(
0
)
})
//检测grid-view属性变化 截图校验
it
(
'
check_grid_view_props
'
,
async
()
=>
{
await
page
.
callMethod
(
'
testModifyGridViewProps
'
)
await
page
.
waitFor
(
600
)
const
image
=
await
program
.
screenshot
({
fullPage
:
false
});
expect
(
image
).
toSaveImageSnapshot
();
})
})
This diff is collapsed.
Click to expand it.
pages/component/grid-view/grid-view.uvue
0 → 100644
浏览文件 @
c00030a1
<script>
type ScrollEventTest = {
type : string;
target : UniElement | null;
currentTarget : UniElement | null;
direction ?: string
}
type gridItemData = {
height : number,
text : string
}
import { ItemType } from '@/components/enum-data/enum-data-types'
export default {
data() {
return {
refresher_triggered_boolean: false,
refresher_enabled_boolean: false,
scroll_with_animation_boolean: false,
show_scrollbar_boolean: false,
bounces_boolean: true,
upper_threshold_input: 50,
lower_threshold_input: 50,
scroll_top_input: 0,
scroll_left_input: 0,
refresher_background_input: "#FFF",
scrollData: [] as Array<gridItemData>,
size_enum: [{ "value": 0, "name": "item---0" }, { "value": 3, "name": "item---3" }] as ItemType[],
scrollIntoView: "",
refresherrefresh: false,
refresher_default_style_input: "black",
text: ['继续下拉执行刷新', '释放立即刷新', '刷新中', ""],
state: 3,
reset: true,
// 自动化测试
isScrollTest: '',
isScrolltolowerTest: '',
isScrolltoupperTest: '',
scrollDetailTest: null as UniScrollEventDetail | null,
scrollEndDetailTest: null as UniScrollEventDetail | null,
cross_axis_count: 2,
main_axis_gap: 2,
cross_axis_gap: 2,
gridViewPadding: [10, 5, 10, 5] as Array<number>,
loadMore: true,
isLoadMore: true
}
},
onLoad() {
//静态瀑布流数据
this.scrollData = [
{ height: 300, text: "item---0" },
{ height: 150, text: "item---1" },
{ height: 120, text: "item---2" },
{ height: 100, text: "item---3" },
{ height: 100, text: "item---4" },
{ height: 150, text: "item---5" },
{ height: 140, text: "item---6" },
{ height: 190, text: "item---7" },
{ height: 160, text: "item---8" },
{ height: 120, text: "item---9" },
{ height: 109, text: "item---10" },
{ height: 102, text: "item---11" },
{ height: 123, text: "item---12" },
{ height: 156, text: "item---13" },
{ height: 177, text: "item---14" },
{ height: 105, text: "item---15" },
{ height: 110, text: "item---16" },
{ height: 90, text: "item---17" },
{ height: 130, text: "item---18" },
{ height: 140, text: "item---19" },
] as Array<gridItemData>
},
methods: {
grid_view_click() { console.log("组件被点击时触发") },
grid_view_touchstart() { console.log("手指触摸动作开始") },
grid_view_touchmove() { console.log("手指触摸后移动") },
grid_view_touchcancel() { console.log("手指触摸动作被打断,如来电提醒,弹窗") },
grid_view_touchend() { console.log("手指触摸动作结束") },
grid_view_tap() { console.log("手指触摸后马上离开") },
grid_view_longpress() { console.log("如果一个组件被绑定了 longpress 事件,那么当用户长按这个组件时,该事件将会被触发。") },
grid_view_refresherpulling(e : RefresherEvent) {
console.log("下拉刷新控件被下拉")
if (this.reset) {
if (e.detail.dy > 45) {
this.state = 1
} else {
this.state = 0
}
}
},
grid_view_refresherrefresh() {
console.log("下拉刷新被触发 ")
this.refresherrefresh = true
this.refresher_triggered_boolean = true
this.state = 2
this.reset = false;
setTimeout(() => {
this.refresher_triggered_boolean = false
}, 1500)
},
grid_view_refresherrestore() {
this.refresherrefresh = false
this.state = 3
this.reset = true
console.log("下拉刷新被复位")
},
grid_view_refresherabort() { console.log("下拉刷新被中止") },
grid_view_scrolltoupper(e : UniScrollToUpperEvent) {
console.log("滚动到顶部/左边,会触发 scrolltoupper 事件 direction=" + e.detail.direction)
this.checkEventTest({
type: e.type,
target: e.target,
currentTarget: e.currentTarget,
direction: e.detail.direction,
} as ScrollEventTest, 'scrolltoupper')
},
grid_view_scrolltolower(e : UniScrollToLowerEvent) {
console.log("滚动到底部/右边,会触发 scrolltolower 事件 direction=" + e.detail.direction)
this.checkEventTest({
type: e.type,
target: e.target,
currentTarget: e.currentTarget,
direction: e.detail.direction,
} as ScrollEventTest, 'scrolltolower')
},
grid_view_scroll(e : UniScrollEvent) {
console.log("滚动时触发,event.detail = ", e.detail)
this.scrollDetailTest = e.detail
this.checkEventTest({
type: e.type,
target: e.target,
currentTarget: e.currentTarget
} as ScrollEventTest, 'scroll')
},
grid_view_scrollend(e : UniScrollEvent) {
console.log("滚动结束时触发", e.detail)
this.scrollEndDetailTest = e.detail
this.checkEventTest({
type: e.type,
target: e.target,
currentTarget: e.currentTarget
} as ScrollEventTest, 'scrollend')
},
grid_item_click() { console.log("grid-item组件被点击时触发") },
grid_item_touchstart() { console.log("手指触摸grid-item组件动作开始") },
grid_item_touchmove() { console.log("手指触摸grid-item组件后移动") },
grid_item_touchcancel() { console.log("手指触摸grid-item组件动作被打断,如来电提醒,弹窗") },
grid_item_touchend() { console.log("手指触摸grid-item组件动作结束") },
grid_item_tap() { console.log("手指触摸grid-item组件后马上离开") },
grid_item_longpress() { console.log("grid-item组件被绑定了 longpress 事件,那么当用户长按这个组件时,该事件将会被触发。") },
change_refresher_triggered_boolean(checked : boolean) { this.refresher_triggered_boolean = checked },
change_refresher_enabled_boolean(checked : boolean) { this.refresher_enabled_boolean = checked },
change_scroll_with_animation_boolean(checked : boolean) { this.scroll_with_animation_boolean = checked },
change_show_scrollbar_boolean(checked : boolean) { this.show_scrollbar_boolean = checked },
change_bounces_boolean(checked : boolean) { this.bounces_boolean = checked },
confirm_upper_threshold_input(value : number) { this.upper_threshold_input = value },
confirm_lower_threshold_input(value : number) { this.lower_threshold_input = value },
confirm_scroll_top_input(value : number) { this.scroll_top_input = value },
confirm_scroll_left_input(value : number) { this.scroll_left_input = value },
confirm_refresher_background_input(value : string) { this.refresher_background_input = value },
item_change_size_enum(index : number) { this.scrollIntoView = "item---" + index },
//自动化测试专用
setScrollIntoView(id : string) { this.scrollIntoView = id },
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e : ScrollEventTest, eventName : String) {
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`;
switch (eventName) {
case 'scroll':
this.isScrollTest = result
break;
case 'scrolltolower':
this.isScrolltolowerTest = result + `-${e.direction}`
break;
case 'scrolltoupper':
this.isScrolltoupperTest = result + `-${e.direction}`
break;
default:
break;
}
},
//自动化测试例专用
check_scroll_height() : Boolean {
var listElement = this.$refs["gridview"] as UniElement
console.log("check_scroll_height--" + listElement.scrollHeight)
if (listElement.scrollHeight > 1400) {
return true
}
return false
},
change_refresher_style_boolean(checked : boolean) {
if (checked) {
this.refresher_default_style_input = "none"
} else {
this.refresher_default_style_input = "black"
}
},
change_load_more_boolean(checked : boolean) {
this.isLoadMore = checked
},
handleChangeCrossAxisCount(value : number) {
if (value < 2) {
uni.showToast({ title: "cross-axis-count 最小值为 2 请重新设置" })
return
}
this.cross_axis_count = value
},
handleChangeCrossAxisGap(e : UniSliderChangeEvent) {
this.cross_axis_gap = e.detail.value
},
handleChangeMainAxisGap(e : UniSliderChangeEvent) {
this.main_axis_gap = e.detail.value
},
//仅自动化测试调用
testModifyGridViewProps() {
this.cross_axis_count = 4
this.main_axis_gap = 6
this.cross_axis_gap = 6
this.gridViewPadding = [5, 10, 5, 10] as Array<number>
}
}
}
</script>
<template>
<view class="main">
<grid-view :cross-axis-count="cross_axis_count" :main-axis-gap="main_axis_gap" :cross-axis-gap="cross_axis_gap"
:bounces="bounces_boolean" :upper-threshold="upper_threshold_input" :lower-threshold="lower_threshold_input"
:scroll-top="scroll_top_input" :scroll-left="scroll_left_input" :show-scrollbar="show_scrollbar_boolean"
:scroll-into-view="scrollIntoView" :scroll-with-animation="scroll_with_animation_boolean"
:refresher-enabled="refresher_enabled_boolean" :refresher-background="refresher_background_input"
:refresher-triggered="refresher_triggered_boolean" :refresher-default-style="refresher_default_style_input"
@click="grid_view_click" @touchstart="grid_view_touchstart" @touchmove="grid_view_touchmove"
@touchcancel="grid_view_touchcancel" @touchend="grid_view_touchend" @tap="grid_view_tap"
@longpress="grid_view_longpress" @refresherpulling="grid_view_refresherpulling"
@refresherrefresh="grid_view_refresherrefresh" @refresherrestore="grid_view_refresherrestore"
@refresherabort="grid_view_refresherabort" @scrolltoupper="grid_view_scrolltoupper" ref="gridview"
@scrolltolower="grid_view_scrolltolower" @scroll="grid_view_scroll" @scrollend="grid_view_scrollend"
style="width:100%; " id="gridview" :padding="gridViewPadding">
<grid-item v-for="(item, index) in scrollData" :key="index" :id="item.text" @click="grid_item_click"
:style="{'height' : item.height}" @touchstart="grid_item_touchstart" @touchmove="grid_item_touchmove"
@touchcancel="grid_item_touchcancel" @touchend="grid_item_touchend" @tap="grid_item_tap"
@longpress="grid_item_longpress" class="grid-item">
<text>{{item.text}}</text>
</grid-item>
<grid-item slot="refresher" id="refresher" type=2 class="refresh-box">
<text class="tip-text">{{text[state]}}</text>
</grid-item>
<grid-item v-show="isLoadMore" slot="load-more" id="loadmore" type="loadmore" class="load-more-box">
<text>加载更多</text>
</grid-item>
</grid-view>
</view>
<scroll-view style="flex:1" direction="vertical">
<view class="content">
<button @click="confirm_scroll_top_input(600)">设置top600</button>
<button @click="confirm_scroll_top_input(400)">设置top400</button>
<boolean-data :defaultValue="false" title="设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发"
@change="change_refresher_triggered_boolean"></boolean-data>
<boolean-data :defaultValue="false" title="开启下拉刷新" @change="change_refresher_enabled_boolean"></boolean-data>
<boolean-data :defaultValue="false" title="开启自定义样式" @change="change_refresher_style_boolean"></boolean-data>
<boolean-data :defaultValue="false" title="是否在设置滚动条位置时使用滚动动画,设置false没有滚动动画"
@change="change_scroll_with_animation_boolean"></boolean-data>
<boolean-data :defaultValue="false" title="控制是否出现滚动条" @change="change_show_scrollbar_boolean"></boolean-data>
<boolean-data :defaultValue="true" title="控制是否回弹效果" @change="change_bounces_boolean"></boolean-data>
<boolean-data :defaultValue="true" title="是否显示加载更多" @change="change_load_more_boolean"></boolean-data>
<input-data defaultValue="2" title="设置cross-axis-count,触发 scrolltoupper 事件" type="number"
@confirm="handleChangeCrossAxisCount"></input-data>
<view class="uni-slider uni-list-cell-padding">
<text>拖动设置cross-axis-gap</text>
</view>
<view class="uni-slider uni-list-cell-padding">
<slider :max="20" :min="0" :step="1" :value="cross_axis_gap" :show-value="true"
@change="handleChangeCrossAxisGap" />
</view>
<view class="uni-slider uni-list-cell-padding">
<text>拖动设置main-axis-gap</text>
</view>
<view class="uni-slider uni-list-cell-padding">
<slider :max="20" :min="0" :step="1" :value="main_axis_gap" :show-value="true"
@change="handleChangeMainAxisGap" />
</view>
<input-data defaultValue="50" title="距顶部/左边多远时(单位px),触发 scrolltoupper 事件" type="number"
@confirm="confirm_upper_threshold_input"></input-data>
<input-data defaultValue="50" title="距底部/右边多远时(单位px),触发 scrolltolower 事件" type="number"
@confirm="confirm_lower_threshold_input"></input-data>
<input-data defaultValue="0" title="设置竖向滚动条位置" type="number" @confirm="confirm_scroll_top_input"></input-data>
<input-data defaultValue="#FFF" title="设置下拉刷新区域背景颜色" type="text"
@confirm="confirm_refresher_background_input"></input-data>
<enum-data :items="size_enum" title="通过id位置跳转" @change="item_change_size_enum"></enum-data>
</view>
</scroll-view>
</template>
<style>
.main {
max-height: 250px;
padding: 5px 0;
border-bottom: 1px solid rgba(0, 0, 0, .06);
flex-direction: row;
justify-content: center;
}
.grid-item {
width: 100%;
height: 200px;
border: 1px solid #666;
background-color: #66ccff;
align-items: center;
justify-content: center;
}
.tip-text {
color: #888;
font-size: 12px;
}
.refresh-box {
justify-content: center;
align-items: center;
flex-direction: row;
height: 45px;
width: 100%;
}
.load-more-box {
justify-content: center;
align-items: center;
flex-direction: row;
height: 45px;
width: 100%;
border-style: solid;
}
.button {
margin-top: 15px;
}
</style>
This diff is collapsed.
Click to expand it.
pages/component/image/image.test.js
浏览文件 @
c00030a1
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
component-native-image
'
,
()
=>
{
describe
(
'
component-native-image
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
let
page
;
let
start
=
0
;
async
function
getWindowInfo
()
{
...
...
@@ -79,17 +81,8 @@ describe('component-native-image', () => {
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventLoad
'
))
||
(
Date
.
now
()
-
start
>
1000
);
});
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
expect
(
await
page
.
data
(
'
eventLoad
'
)).
toEqual
({
tagName
:
'
IMAGE
'
,
type
:
'
load
'
,
width
:
10
,
height
:
10
});
return
}
expect
(
await
page
.
data
(
'
eventLoad
'
)).
toEqual
({
tagName
:
'
IMAGE
'
,
tagName
:
isMP
?
undefined
:
'
IMAGE
'
,
type
:
'
load
'
,
width
:
10
,
height
:
10
...
...
@@ -104,17 +97,10 @@ describe('component-native-image', () => {
await
page
.
waitFor
(
async
()
=>
{
return
(
await
page
.
data
(
'
eventError
'
))
||
(
Date
.
now
()
-
start
>
1000
);
});
if
(
process
.
env
.
uniTestPlatformInfo
.
toLowerCase
().
startsWith
(
'
ios
'
))
{
expect
(
await
page
.
data
(
'
eventError
'
)).
toEqual
({
tagName
:
'
IMAGE
'
,
type
:
'
error
'
});
}
else
{
expect
(
await
page
.
data
(
'
eventError
'
)).
toEqual
({
tagName
:
'
IMAGE
'
,
type
:
'
error
'
});
}
expect
(
await
page
.
data
(
'
eventError
'
)).
toEqual
({
tagName
:
isMP
?
undefined
:
'
IMAGE
'
,
type
:
'
error
'
});
await
page
.
setData
({
autoTest
:
false
...
...
This diff is collapsed.
Click to expand it.
pages/component/input/input.test.js
浏览文件 @
c00030a1
describe
(
'
component-native-input
'
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isIOS
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/component/input/input
'
)
...
...
@@ -14,31 +16,33 @@ describe('component-native-input', () => {
// })
// expect(image).toSaveImageSnapshot()
// })
// 测试焦点及键盘弹起
it
(
'
focus
'
,
async
()
=>
{
const
input
=
await
page
.
$
(
'
#uni-input-focus
'
);
expect
(
await
input
.
attribute
(
'
focus
'
)).
toBe
(
"
true
"
)
// expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
await
page
.
setData
({
focus
:
false
,
})
expect
(
await
input
.
attribute
(
'
focus
'
)).
toBe
(
"
false
"
)
// await page.waitFor(1000)
// expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false)
// await page.setData({
// focus: true,
// })
// expect(await input.attribute('focus')).toBe(true)
// await page.waitFor(1000)
// expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
// await page.setData({
// focus: false,
// })
// expect(await input.attribute('focus')).toBe(false)
// await page.waitFor(1000)
// expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false)
// await page.waitFor(1000)
});
// 测试焦点及键盘弹起
if
(
!
isMP
)
{
it
(
'
focus
'
,
async
()
=>
{
const
input
=
await
page
.
$
(
'
#uni-input-focus
'
);
expect
(
await
input
.
attribute
(
'
focus
'
)).
toBe
(
"
true
"
)
// expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
await
page
.
setData
({
focus
:
false
,
})
expect
(
await
input
.
attribute
(
'
focus
'
)).
toBe
(
"
false
"
)
// await page.waitFor(1000)
// expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false)
// await page.setData({
// focus: true,
// })
// expect(await input.attribute('focus')).toBe(true)
// await page.waitFor(1000)
// expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true)
// await page.setData({
// focus: false,
// })
// expect(await input.attribute('focus')).toBe(false)
// await page.waitFor(1000)
// expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false)
// await page.waitFor(1000)
});
}
// 测试修改value属性
it
(
"
value
"
,
async
()
=>
{
...
...
@@ -116,20 +120,49 @@ describe('component-native-input', () => {
// "backgroundColor": "#FFA500"
// })
// expect(await placeholder2.attribute("placeholder")).toEqual("占位符背景色为绿色")
// })
it
(
"
disable
"
,
async
()
=>
{
const
input
=
await
page
.
$
(
'
#uni-input-disable
'
);
expect
(
await
input
.
attribute
(
"
disabled
"
)).
toBe
(
"
true
"
)
})
// })
if
(
isMP
)
{
it
(
"
disable
"
,
async
()
=>
{
const
input
=
await
page
.
$
(
'
#uni-input-disable
'
);
expect
(
await
input
.
property
(
"
disabled
"
)).
toBe
(
true
)
})
// 如下属性在自动化测试通过property、attribute + confirmType、confirm-type均无法获取
// it("confirm-type", async () => {
// expect(await (await page.$('#uni-input-confirm-send')).attribute("confirm-type")).toEqual("send")
// expect(await (await page.$('#uni-input-confirm-search')).property("confirmType")).toEqual("search")
// expect(await (await page.$('#uni-input-confirm-next')).property("confirmType")).toEqual("next")
// expect(await (await page.$('#uni-input-confirm-go')).property("confirmType")).toEqual("go")
// expect(await (await page.$('#uni-input-confirm-done')).property("confirmType")).toEqual("done")
// })
// it("cursor-color", async () => {
// await page.setData({
// cursor_color: "red",
// })
// await page.waitFor(500)
// expect(await (await page.$('#uni-input-cursor-color')).property("cursor-color")).toBe("red")
// })
}
else
{
it
(
"
disable
"
,
async
()
=>
{
const
input
=
await
page
.
$
(
'
#uni-input-disable
'
);
expect
(
await
input
.
attribute
(
"
disabled
"
)).
toBe
(
"
true
"
)
})
it
(
"
confirm-type
"
,
async
()
=>
{
expect
(
await
(
await
page
.
$
(
'
#uni-input-confirm-send
'
)).
attribute
(
"
confirmType
"
)).
toEqual
(
"
send
"
)
expect
(
await
(
await
page
.
$
(
'
#uni-input-confirm-search
'
)).
attribute
(
"
confirmType
"
)).
toEqual
(
"
search
"
)
expect
(
await
(
await
page
.
$
(
'
#uni-input-confirm-next
'
)).
attribute
(
"
confirmType
"
)).
toEqual
(
"
next
"
)
expect
(
await
(
await
page
.
$
(
'
#uni-input-confirm-go
'
)).
attribute
(
"
confirmType
"
)).
toEqual
(
"
go
"
)
expect
(
await
(
await
page
.
$
(
'
#uni-input-confirm-done
'
)).
attribute
(
"
confirmType
"
)).
toEqual
(
"
done
"
)
})
it
(
"
cursor-color
"
,
async
()
=>
{
await
page
.
setData
({
cursor_color
:
"
red
"
,
})
await
page
.
waitFor
(
500
)
expect
(
await
(
await
page
.
$
(
'
#uni-input-cursor-color
'
)).
attribute
(
"
cursor-color
"
)).
toBe
(
"
red
"
)
})
}
it
(
"
confirm-type
"
,
async
()
=>
{
expect
(
await
(
await
page
.
$
(
'
#uni-input-confirm-send
'
)).
attribute
(
"
confirmType
"
)).
toEqual
(
"
send
"
)
expect
(
await
(
await
page
.
$
(
'
#uni-input-confirm-search
'
)).
attribute
(
"
confirmType
"
)).
toEqual
(
"
search
"
)
expect
(
await
(
await
page
.
$
(
'
#uni-input-confirm-next
'
)).
attribute
(
"
confirmType
"
)).
toEqual
(
"
next
"
)
expect
(
await
(
await
page
.
$
(
'
#uni-input-confirm-go
'
)).
attribute
(
"
confirmType
"
)).
toEqual
(
"
go
"
)
expect
(
await
(
await
page
.
$
(
'
#uni-input-confirm-done
'
)).
attribute
(
"
confirmType
"
)).
toEqual
(
"
done
"
)
})
// it("maxlength", async () => {
// const input = await page.$('.uni-input-maxlength');
...
...
@@ -139,13 +172,6 @@ describe('component-native-input', () => {
// await page.waitFor(500)
// })
it
(
"
cursor-color
"
,
async
()
=>
{
await
page
.
setData
({
cursor_color
:
"
red
"
,
})
await
page
.
waitFor
(
500
)
expect
(
await
(
await
page
.
$
(
'
#uni-input-cursor-color
'
)).
attribute
(
"
cursor-color
"
)).
toBe
(
"
red
"
)
})
it
(
"
maxlength
"
,
async
()
=>
{
const
input
=
await
page
.
$
(
'
#uni-input-maxlength
'
);
...
...
@@ -173,11 +199,7 @@ describe('component-native-input', () => {
})
it
(
"
keyboard height changed after page back
"
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
web
'
))
{
expect
(
1
).
toBe
(
1
)
return
}
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
ios
'
))
{
if
(
isWeb
||
isMP
||
isIOS
)
{
expect
(
1
).
toBe
(
1
)
return
}
...
...
This diff is collapsed.
Click to expand it.
pages/component/list-view/list-view.test.js
浏览文件 @
c00030a1
...
...
@@ -164,12 +164,12 @@ describe('component-native-list-view', () => {
await
page
.
callMethod
(
'
change_scroll_y_boolean
'
,
false
)
await
page
.
waitFor
(
600
)
}
await
page
.
callMethod
(
'
item_change_size_enum
'
,
3
)
await
page
.
callMethod
(
'
setScrollIntoView
'
,
"
item---3
"
)
await
page
.
waitFor
(
600
)
const
listElement
=
await
page
.
$
(
'
#listview
'
)
const
scrollLeft
=
await
listElement
.
attribute
(
"
scrollLeft
"
)
console
.
log
(
"
check_scroll_into_view_left--
"
+
scrollLeft
)
await
page
.
callMethod
(
'
item_change_size_enum
'
,
0
)
await
page
.
callMethod
(
'
setScrollIntoView
'
,
"
item---0
"
)
expect
(
scrollLeft
-
1080
).
toBeGreaterThanOrEqual
(
0
)
})
})
This diff is collapsed.
Click to expand it.
pages/component/list-view/list-view.uvue
浏览文件 @
c00030a1
...
...
@@ -151,6 +151,8 @@
confirm_scroll_left_input(value : number) { this.scroll_left_input = value },
confirm_refresher_background_input(value : string) { this.refresher_background_input = value },
item_change_size_enum(index : number) { this.scrollIntoView = "item---" + index },
//自动化测试专用
setScrollIntoView(id : string) { this.scrollIntoView = id },
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e : ScrollEventTest, eventName : String) {
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
...
...
This diff is collapsed.
Click to expand it.
pages/tabBar/template.uvue
浏览文件 @
c00030a1
...
...
@@ -216,8 +216,8 @@
// #endif
// #ifdef MP
{
id: 'vant
-button
',
url: 'vant
-button
',
id: 'vant',
url: 'vant',
name: '微信自定义组件示例',
open: false,
pages: [] as Page[],
...
...
This diff is collapsed.
Click to expand it.
pages/template/vant
-button/vant-button
.test.js
→
pages/template/vant
/vant
.test.js
浏览文件 @
c00030a1
jest
.
setTimeout
(
30000
);
describe
(
'
test
title
'
,
()
=>
{
let
page
,
vant
;
describe
(
'
test
vant
'
,
()
=>
{
let
page
,
vantBtnContainer
,
vantBtn
;
if
(
!
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
mp
'
))
{
it
(
'
not support
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
...
...
@@ -8,17 +8,21 @@ describe('test title', () => {
return
}
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/template/vant
-button/vant-button
'
)
page
=
await
program
.
reLaunch
(
'
/pages/template/vant
/vant
'
)
await
page
.
waitFor
(
3000
);
vant
=
await
page
.
$
(
'
van
-button
'
);
vant
BtnContainer
=
await
page
.
$
(
'
vant
-button
'
);
expect
(
await
page
.
data
(
'
jest
'
)).
toBe
(
false
);
});
afterAll
(
async
()
=>
{
expect
(
await
program
.
screenshot
()).
toSaveImageSnapshot
();
});
it
(
'
check title onClick
'
,
async
()
=>
{
const
titleText
=
await
vant
.
text
();
expect
(
titleText
).
toEqual
(
'
vant weapp的van-button按钮组件
'
);
await
vant
.
tap
()
const
titleText
=
await
vantBtnContainer
.
text
();
expect
(
titleText
).
toEqual
(
'
vant weapp的vant-button按钮组件
'
);
vantBtn
=
await
vantBtnContainer
.
$
(
'
button
'
)
await
vantBtn
.
tap
()
await
page
.
waitFor
(
1000
);
console
.
log
(
'
jest
'
,
await
page
.
data
(
'
jest
'
))
//
expect(await page.data('jest')).toBe(true);
console
.
log
(
'
jest
'
,
await
page
.
data
(
'
jest
'
))
expect
(
await
page
.
data
(
'
jest
'
)).
toBe
(
true
);
});
});
This diff is collapsed.
Click to expand it.
pages/template/vant
-button/vant-button
.uvue
→
pages/template/vant
/vant
.uvue
浏览文件 @
c00030a1
<template>
<view>
<view
style="align-items: center;"
>
<page-head title="微信小程序自定义组件示例"></page-head>
<view class="uni-list-cell-padding">
<text>
uni-app-x支持在微信小程序端引入微信小程序自定义组件。以下以vant weapp组件为例演示
</text>
</view>
<view style="text-align: center;">
<van-button type="primary" @click="onClick">vant weapp的van-button按钮组件</van-button>
</view>
<text class="uni-list-cell-padding">
uni-app-x支持在微信小程序端引入微信小程序自定义组件。以下以vant weapp组件为例演示
</text>
<text class="uni-common-mt uni-title-text uni-common-mb">vant-button组件</text>
<vant-button color="#55aa00" @click="onClick">vant weapp的vant-button按钮组件</vant-button>
<text class="uni-common-mt uni-title-text uni-common-mb">vant-icon组件</text>
<vant-icon name="balance-list" size="30" color="#aa55ff"></vant-icon>
<text class="uni-common-mt uni-title-text uni-common-mb">vant-info组件</text>
<vant-info info="99"></vant-info>
<text class="uni-common-mt uni-title-text uni-common-mb">vant-loading组件</text>
<vant-loading color="#00aaff"></vant-loading>
</view>
</template>
<script>
export default {
data() {
return {
// 自动化测试
jest: false
};
},
...
...
@@ -31,7 +35,9 @@
}
}
</script>
<style>
.van-info {
right: 200px !important;
top: 370px !important;
}
</style>
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
新手
引导
客服
返回
顶部