Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
5ba217c2
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6013
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
5ba217c2
编写于
6月 03, 2024
作者:
DCloud-yinjiacheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增media自动化测试用例
上级
063d599b
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
251 addition
and
19 deletion
+251
-19
pages/API/compress-image/compress-image.test.js
pages/API/compress-image/compress-image.test.js
+22
-0
pages/API/compress-image/compress-image.uvue
pages/API/compress-image/compress-image.uvue
+30
-2
pages/API/compress-video/compress-video.test.js
pages/API/compress-video/compress-video.test.js
+22
-0
pages/API/compress-video/compress-video.uvue
pages/API/compress-video/compress-video.uvue
+24
-1
pages/API/get-image-info/get-image-info.test.js
pages/API/get-image-info/get-image-info.test.js
+30
-0
pages/API/get-image-info/get-image-info.uvue
pages/API/get-image-info/get-image-info.uvue
+10
-0
pages/API/get-video-info/get-video-info.test.js
pages/API/get-video-info/get-video-info.test.js
+36
-0
pages/API/get-video-info/get-video-info.uvue
pages/API/get-video-info/get-video-info.uvue
+22
-0
pages/API/save-image-to-photos-album/save-image-to-photos-album.test.js
...-image-to-photos-album/save-image-to-photos-album.test.js
+22
-0
pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue
...ave-image-to-photos-album/save-image-to-photos-album.uvue
+6
-2
pages/API/save-video-to-photos-album/save-video-to-photos-album.test.js
...-video-to-photos-album/save-video-to-photos-album.test.js
+22
-0
pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue
...ave-video-to-photos-album/save-video-to-photos-album.uvue
+5
-14
static/test-video/10second-demo.mp4
static/test-video/10second-demo.mp4
+0
-0
未找到文件。
pages/API/compress-image/compress-image.test.js
0 → 100644
浏览文件 @
5ba217c2
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
API-compressImage
'
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/compress-image/compress-image
'
);
await
page
.
waitFor
(
500
);
});
it
(
'
test compressImage
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
ios
'
))
{
expect
(
1
).
toBe
(
1
);
return
;
}
await
page
.
callMethod
(
'
testCompressImage
'
);
await
page
.
waitFor
(
1000
);
expect
(
await
page
.
data
(
'
imageInfoForTest
'
)).
toEqual
({
width
:
100
,
height
:
100
,
size
:
2
});
});
});
pages/API/compress-image/compress-image.uvue
浏览文件 @
5ba217c2
...
...
@@ -52,7 +52,9 @@
compressedHeight: null as number | null,
width: "auto",
height: "auto",
rotate: 0
rotate: 0,
// 自动化测试
imageInfoForTest: null
}
},
methods: {
...
...
@@ -103,7 +105,7 @@
complete: (_) => {
uni.hideLoading();
}
})
})
;
},
chooseImage() {
uni.chooseImage({
...
...
@@ -142,6 +144,32 @@
},
onRotateConfirm(value : number) {
this.rotate = value;
},
testCompressImage() {
uni.compressImage({
src: '/static/test-image/logo.png',
quality: 50,
compressedWidth: 100,
compressedHeight: 100,
success: (res) => {
uni.getImageInfo({
src: res.tempFilePath,
success: (_res) => {
// #ifdef APP-ANDROID
const size = new FileInputStream(res.tempFilePath.substring("file://".length)).available() / 1024;
// #endif
this.imageInfoForTest = {
"width": _res.width,
"height": _res.height,
"size": size.toInt()
};
}
});
},
fail: (_) => {
this.imageInfoForTest = null;
}
});
}
}
}
...
...
pages/API/compress-video/compress-video.test.js
0 → 100644
浏览文件 @
5ba217c2
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
API-compressVideo
'
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/compress-video/compress-video
'
);
await
page
.
waitFor
(
500
);
});
it
(
'
test compressVideo
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
)
||
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
ios
'
))
{
expect
(
1
).
toBe
(
1
);
return
;
}
await
page
.
callMethod
(
'
testCompressVideo
'
);
await
page
.
waitFor
(
3000
);
expect
(
await
page
.
data
(
'
videoInfoForTest
'
)).
toEqual
({
width
:
640
,
height
:
360
,
size
:
265
});
});
});
pages/API/compress-video/compress-video.uvue
浏览文件 @
5ba217c2
...
...
@@ -46,7 +46,9 @@
fps: null as number | null,
resolution: null as number | null,
qualityItemTypes: [{ "value": 0, "name": "low(低)" }, { "value": 1, "name": "medium(中)" }, { "value": 2, "name": "high(高)" }] as ItemType[],
qualityItems: ["low", "medium", "high"]
qualityItems: ["low", "medium", "high"],
// 自动化测试
videoInfoForTest: null
}
},
methods: {
...
...
@@ -111,6 +113,27 @@
},
onResolutionChange(event : UniSliderChangeEvent) {
this.resolution = event.detail.value;
},
testCompressVideo() {
uni.compressVideo({
src: '/static/test-video/10second-demo.mp4',
quality: 'medium',
success: (res) => {
uni.getVideoInfo({
src: res.tempFilePath,
success: (_res) => {
this.videoInfoForTest = {
"width": _res.width,
"height": _res.height,
"size": res.size.toInt()
};
}
});
},
fail: (_) => {
this.videoInfoForTest = null;
}
});
}
}
}
...
...
pages/API/get-image-info/get-image-info.test.js
0 → 100644
浏览文件 @
5ba217c2
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
API-getImageInfo
'
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/get-image-info/get-image-info
'
);
await
page
.
waitFor
(
500
);
});
it
(
'
test getImageInfo
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
ios
'
))
{
expect
(
1
).
toBe
(
1
);
return
;
}
await
page
.
waitFor
(
500
);
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
expect
(
await
page
.
data
(
'
imageInfoForTest
'
)).
toEqual
({
width
:
192
,
height
:
192
});
return
;
}
expect
(
await
page
.
data
(
'
imageInfoForTest
'
)).
toEqual
({
width
:
192
,
height
:
192
,
path
:
'
file:///storage/emulated/0/Android/data/io.dcloud.uniappx/apps/__UNI__HelloUniAppX/www/static/test-image/logo.png
'
,
orientation
:
'
up
'
,
type
:
'
png
'
});
});
});
pages/API/get-image-info/get-image-info.uvue
浏览文件 @
5ba217c2
...
...
@@ -39,6 +39,8 @@
absoluteImageInfo: "",
remoteImagePath: "https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/img/building.jpg",
remoteImageInfo: "",
// 自动化测试
imageInfoForTest: null,
}
},
methods: {
...
...
@@ -71,6 +73,13 @@
success: (res) => {
console.log("getImageInfo success", JSON.stringify(res));
this.absoluteImageInfo = `图片宽度: ${res.width}\n图片高度: ${res.height}\n图片路径: ${res.path}\n图片方向: ${res.orientation}\n图片格式: ${res.type}`;
this.imageInfoForTest = {
"width": res.width,
"height": res.height,
"path": res.path,
"orientation": res.orientation,
"type": res.type
};
},
fail: (err) => {
uni.showModal({
...
...
@@ -78,6 +87,7 @@
content: JSON.stringify(err),
showCancel: false
});
this.imageInfoForTest = null;
}
});
uni.getImageInfo({
...
...
pages/API/get-video-info/get-video-info.test.js
0 → 100644
浏览文件 @
5ba217c2
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
API-getVideoInfo
'
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/get-video-info/get-video-info
'
);
await
page
.
waitFor
(
500
);
});
it
(
'
test getVideoInfo
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
ios
'
))
{
expect
(
1
).
toBe
(
1
);
return
;
}
await
page
.
callMethod
(
'
testGetVideoInfo
'
);
await
page
.
waitFor
(
1000
);
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
expect
(
await
page
.
data
(
'
videoInfoForTest
'
)).
toEqual
({
duration
:
10
,
size
:
211
,
width
:
1280
,
height
:
720
});
return
;
}
expect
(
await
page
.
data
(
'
videoInfoForTest
'
)).
toEqual
({
orientation
:
'
up
'
,
type
:
'
video/mp4
'
,
duration
:
10
,
size
:
211
,
width
:
1280
,
height
:
720
,
fps
:
30
,
bitrate
:
172
});
});
});
pages/API/get-video-info/get-video-info.uvue
浏览文件 @
5ba217c2
...
...
@@ -25,6 +25,8 @@
title: "getVideoInfo",
absoluteVideoPath: "",
absoluteVideoInfo: "",
// 自动化测试
videoInfoForTest: null
}
},
methods: {
...
...
@@ -49,6 +51,26 @@
});
}
});
},
testGetVideoInfo() {
uni.getVideoInfo({
src: '/static/test-video/10second-demo.mp4',
success: (res) => {
this.videoInfoForTest = {
"orientation": res.orientation,
"type": res.type,
"duration": res.duration.toInt(),
"size": res.size,
"width": res.width,
"height": res.height,
"fps": res.fps,
"bitrate": res.bitrate
};
},
fail: (_) => {
this.videoInfoForTest = null;
}
});
}
}
}
...
...
pages/API/save-image-to-photos-album/save-image-to-photos-album.test.js
0 → 100644
浏览文件 @
5ba217c2
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
API-saveImageToPhotosAlbum
'
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/save-image-to-photos-album/save-image-to-photos-album
'
);
await
page
.
waitFor
(
500
);
});
it
(
'
test saveImageToPhotosAlbum
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
expect
(
1
).
toBe
(
1
);
return
;
}
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
await
program
.
adbCommand
(
'
pm grant io.dcloud.uniappx android.permission.WRITE_EXTERNAL_STORAGE
'
);
await
page
.
waitFor
(
500
);
}
await
page
.
callMethod
(
'
saveImage
'
);
expect
(
await
page
.
data
(
'
success
'
)).
toBe
(
true
);
});
});
pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue
浏览文件 @
5ba217c2
...
...
@@ -16,7 +16,9 @@
export default {
data() {
return {
title: "saveImageToPhotosAlbum"
title: "saveImageToPhotosAlbum",
// 自动化测试
success: false
}
},
methods: {
...
...
@@ -29,7 +31,8 @@
position: "center",
icon: "none",
title: "图片保存成功,请到手机相册查看"
})
});
this.success = true;
},
fail: (err) => {
uni.showModal({
...
...
@@ -37,6 +40,7 @@
content: JSON.stringify(err),
showCancel: false
});
this.success = false;
}
})
}
...
...
pages/API/save-video-to-photos-album/save-video-to-photos-album.test.js
0 → 100644
浏览文件 @
5ba217c2
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe
(
'
API-saveVideoToPhotosAlbum
'
,
()
=>
{
let
page
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
'
/pages/API/save-video-to-photos-album/save-video-to-photos-album
'
);
await
page
.
waitFor
(
500
);
});
it
(
'
test saveVideoToPhotosAlbum
'
,
async
()
=>
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
expect
(
1
).
toBe
(
1
);
return
;
}
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
await
program
.
adbCommand
(
'
pm grant io.dcloud.uniappx android.permission.WRITE_EXTERNAL_STORAGE
'
);
await
page
.
waitFor
(
500
);
}
await
page
.
callMethod
(
'
saveVideo
'
);
expect
(
await
page
.
data
(
'
success
'
)).
toBe
(
true
);
});
});
pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue
浏览文件 @
5ba217c2
...
...
@@ -17,7 +17,9 @@
data() {
return {
title: 'saveVideoToPhotosAlbum',
src: ''
src: '/static/test-video/10second-demo.mp4',
// 自动化测试
success: false
}
},
methods: {
...
...
@@ -31,6 +33,7 @@
icon: "none",
title: "视频保存成功,请到手机相册查看"
});
this.success = true;
},
fail: (err) => {
uni.showModal({
...
...
@@ -38,22 +41,10 @@
content: JSON.stringify(err),
showCancel: false
});
this.success = false;
}
});
}
},
onReady() {
uni.showLoading({
title: '视频下载中'
});
uni.downloadFile({
url: 'https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/video/swiper-vertical-video/uts.mp4',
success: (res) => {
console.log("download video success", res.tempFilePath);
this.src = res.tempFilePath;
uni.hideLoading();
}
});
}
}
</script>
...
...
static/test-video/10second-demo.mp4
0 → 100644
浏览文件 @
5ba217c2
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录