Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
2a98d17e
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2a98d17e
编写于
10月 25, 2022
作者:
F
fulizhong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify testcases Signed-off-by: FULIZHONG<fulizhong1@huawei.com>
Signed-off-by:
N
fulizhong
<
fulizhong@huawei.com
>
上级
984837be
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
336 addition
and
311 deletion
+336
-311
multimedia/BUILD.gn
multimedia/BUILD.gn
+1
-0
multimedia/media/media_js_standard/VideoRecorderTestBase.js
multimedia/media/media_js_standard/VideoRecorderTestBase.js
+41
-25
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js
...der/src/main/js/test/VideoRecorderAPICallbackTest.test.js
+37
-9
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
...er/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
+67
-31
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js
...der/src/main/js/test/VideoRecorderFuncPromiseTest.test.js
+190
-246
未找到文件。
multimedia/BUILD.gn
浏览文件 @
2a98d17e
...
...
@@ -45,6 +45,7 @@ group("multimedia") {
"media/media_js_standard/audioRecorder:audio_recorder_js_hap",
"media/media_js_standard/recorderFormat:recorder_format_js_hap",
"media/media_js_standard/videoPlayer:video_player_js_hap",
"media/media_js_standard/videoRecorder:video_recorder_js_hap",
"medialibrary/mediaLibrary_album:mediaLibrary_album_hap",
"medialibrary/mediaLibrary_base:mediaLibrary_base_hap",
"medialibrary/mediaLibrary_favorite:mediaLibrary_favorite_hap",
...
...
multimedia/media/media_js_standard/VideoRecorderTestBase.js
浏览文件 @
2a98d17e
...
...
@@ -27,48 +27,72 @@ const BITRATE_DELTA_TIME = 20000;
const
PLAY_TIME
=
1000
;
export
async
function
initCaptureSession
(
videoOutPut
,
cameraManager
,
camera
s
,
cameraID
)
{
let
cameraInput
=
await
cameraManager
.
createCameraInput
(
camera
s
[
cameraID
].
cameraId
);
export
async
function
initCaptureSession
(
videoOutPut
,
cameraManager
,
camera
Device
,
previewOutput
)
{
let
cameraInput
=
await
cameraManager
.
createCameraInput
(
camera
Device
);
if
(
cameraInput
!=
null
)
{
console
.
info
(
'
[camera] case createCameraInput success
'
);
}
else
{
console
.
info
(
'
[camera] case createCameraInput failed
'
);
return
;
}
let
captureSession
=
await
camera
.
createCaptureSession
(
null
);
await
cameraInput
.
open
((
err
)
=>
{
if
(
err
){
console
.
info
(
'
[camera] cameraInput open Failed
'
);
return
}
console
.
info
(
'
[camera] cameraInput open success
'
);
})
let
captureSession
=
await
cameraManager
.
createCaptureSession
();
await
captureSession
.
beginConfig
();
await
captureSession
.
addInput
(
cameraInput
);
await
captureSession
.
addOutput
(
previewOutput
);
await
captureSession
.
addOutput
(
videoOutPut
);
await
captureSession
.
commitConfig
();
await
captureSession
.
start
();
return
captureSession
;
}
export
async
function
stopCaptureSession
(
captureSession
)
{
await
captureSession
.
release
();
await
captureSession
.
stop
().
then
(()
=>
{
console
.
info
(
'
[camera] case captureSession stop success
'
);
});
await
captureSession
.
release
().
then
(()
=>
{
console
.
info
(
'
[camera] case captureSession release success
'
);
});
}
export
function
getTrackArray
(
videoType
,
recorderConfigFile
)
{
export
function
getTrackArray
(
videoType
,
recorderConfigFile
,
sourceType
)
{
if
(
videoType
==
AUDIO_VIDEO_TYPE
)
{
let
audioTrack
=
new
Array
(
recorderConfigFile
.
audioBitrate
,
recorderConfigFile
.
audioChannels
,
'
audio/mpeg
'
,
recorderConfigFile
.
audioSampleRate
);
let
videoTrack
=
null
;
if
(
recorderConfigFile
.
videoCodec
==
'
video/avc
'
)
{
if
(
sourceType
==
media
.
VideoSourceType
.
VIDEO_SOURCE_TYPE_SURFACE_ES
)
{
videoTrack
=
new
Array
(
'
video/x-h264
'
,
recorderConfigFile
.
videoFrameHeight
,
recorderConfigFile
.
videoFrameWidth
);
}
else
{
videoTrack
=
new
Array
(
'
video/mpeg
'
,
recorderConfigFile
.
videoFrameHeight
,
recorderConfigFile
.
videoFrameWidth
);
if
(
recorderConfigFile
.
videoCodec
==
'
video/avc
'
)
{
videoTrack
=
new
Array
(
'
video/x-h264
'
,
recorderConfigFile
.
videoFrameHeight
,
recorderConfigFile
.
videoFrameWidth
);
}
else
{
videoTrack
=
new
Array
(
'
video/mpeg
'
,
recorderConfigFile
.
videoFrameHeight
,
recorderConfigFile
.
videoFrameWidth
);
}
}
let
trackArray
=
new
Array
(
videoTrack
,
audioTrack
);
return
trackArray
;
}
else
if
(
videoType
==
ONLYVIDEO_TYPE
)
{
let
videoTrack
=
null
;
if
(
recorderConfigFile
.
videoCodec
==
'
video/avc
'
)
{
if
(
sourceType
==
media
.
VideoSourceType
.
VIDEO_SOURCE_TYPE_SURFACE_ES
)
{
videoTrack
=
new
Array
(
'
video/x-h264
'
,
recorderConfigFile
.
videoFrameHeight
,
recorderConfigFile
.
videoFrameWidth
);
}
else
{
videoTrack
=
new
Array
(
'
video/mpeg
'
,
recorderConfigFile
.
videoFrameHeight
,
recorderConfigFile
.
videoFrameWidth
);
if
(
recorderConfigFile
.
videoCodec
==
'
video/avc
'
)
{
videoTrack
=
new
Array
(
'
video/x-h264
'
,
recorderConfigFile
.
videoFrameHeight
,
recorderConfigFile
.
videoFrameWidth
);
}
else
{
videoTrack
=
new
Array
(
'
video/mpeg
'
,
recorderConfigFile
.
videoFrameHeight
,
recorderConfigFile
.
videoFrameWidth
);
}
}
let
trackArray
=
new
Array
(
videoTrack
);
return
trackArray
;
...
...
@@ -115,6 +139,12 @@ export async function checkVideos(playFdPath, duration, trackArray, playerSurfac
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
console
.
info
(
'
[checkVideos] case checkVideos fdPath is :
'
+
playFdPath
);
videoPlayer
.
on
(
'
error
'
,
(
error
)
=>
{
console
.
info
(
`case error called,errMessage is
${
error
.
message
}
`
);
expect
().
assertFail
();
return
;
});
videoPlayer
.
url
=
playFdPath
;
let
tarckType
=
undefined
;
if
(
playerSurfaceId
!=
null
)
{
...
...
@@ -141,20 +171,6 @@ export async function checkVideos(playFdPath, duration, trackArray, playerSurfac
expect
().
assertFail
();
}
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
let
startTime
=
videoPlayer
.
currentTime
;
await
videoPlayer
.
play
().
then
(()
=>
{
console
.
info
(
'
case play called!!
'
);
mediaTestBase
.
msleep
(
PLAY_TIME
);
expect
(
videoPlayer
.
state
).
assertEqual
(
'
playing
'
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
let
endTime
=
videoPlayer
.
currentTime
;
expect
(
Math
.
abs
(
endTime
-
startTime
-
PLAY_TIME
)).
assertLess
(
DELTA_TIME
);
await
videoPlayer
.
stop
().
then
(()
=>
{
console
.
info
(
'
case stop called!!
'
);
expect
(
videoPlayer
.
state
).
assertEqual
(
'
stopped
'
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
await
videoPlayer
.
release
().
then
(()
=>
{
console
.
info
(
'
case release called!!
'
);
...
...
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js
浏览文件 @
2a98d17e
...
...
@@ -43,6 +43,13 @@ describe('VideoRecorderAPICallbackTest', function () {
let
fdPath
;
let
fdObject
;
let
cameraID
=
0
;
let
playerSurfaceId
=
''
;
let
pageId
=
0
;
let
videoProfiles
;
let
previewProfiles
;
let
previewOutput
;
const
pagePath1
=
'
pages/surfaceTest/surfaceTest
'
;
const
pagePath2
=
'
pages/surfaceTest2/surfaceTest2
'
;
let
events
=
require
(
'
events
'
);
let
eventEmitter
=
new
events
.
EventEmitter
();
...
...
@@ -79,19 +86,42 @@ describe('VideoRecorderAPICallbackTest', function () {
console
.
info
(
'
[camera] case getCameraManager failed
'
);
return
;
}
cameras
=
await
cameraManager
.
getCameras
();
await
cameraManager
.
getSupportedCameras
().
then
((
cameraDevices
)
=>
{
cameras
=
cameraDevices
;
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
if
(
cameras
!=
null
)
{
console
.
info
(
'
[camera] case getCameras success
'
);
}
else
{
console
.
info
(
'
[camera] case getCameras failed
'
);
}
await
cameraManager
.
getSupportedOutputCapability
(
cameras
[
0
]).
then
((
cameraoutputcapability
)
=>
{
console
.
info
(
'
[camera] case getSupportedOutputCapability success
'
);
videoProfiles
=
cameraoutputcapability
.
videoProfiles
;
videoProfiles
[
0
].
size
.
height
=
480
;
videoProfiles
[
0
].
size
.
width
=
640
;
previewProfiles
=
cameraoutputcapability
.
previewProfiles
;
previewProfiles
[
0
].
size
.
height
=
480
;
previewProfiles
[
0
].
size
.
width
=
640
;
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
)
if
(
previewProfiles
[
0
].
format
==
camera
.
CameraFormat
.
CAMERA_FORMAT_YUV_420_SP
)
{
console
.
info
(
'
[camera] case format is VIDEO_SOURCE_TYPE_SURFACE_YUV
'
);
videoConfig
.
videoSourceType
=
media
.
VideoSourceType
.
VIDEO_SOURCE_TYPE_SURFACE_YUV
;
}
else
{
console
.
info
(
'
[camera] case format is VIDEO_SOURCE_TYPE_SURFACE_ES
'
);
videoConfig
.
videoSourceType
=
media
.
VideoSourceType
.
VIDEO_SOURCE_TYPE_SURFACE_ES
;
}
fdObject
=
await
mediaTestBase
.
getFd
(
'
recorder_callback_api.mp4
'
);
fdPath
=
"
fd://
"
+
fdObject
.
fdNumber
.
toString
();
videoConfig
.
url
=
fdPath
;
console
.
info
(
'
beforeAll case
'
);
})
beforeEach
(
function
()
{
beforeEach
(
async
function
()
{
await
mediaTestBase
.
toNewPage
(
pagePath1
,
pagePath2
,
pageId
);
pageId
=
(
pageId
+
1
)
%
2
;
await
mediaTestBase
.
msleepAsync
(
1000
).
then
(
()
=>
{},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
playerSurfaceId
=
globalThis
.
value
;
surfaceID
=
null
;
console
.
info
(
'
beforeEach case
'
);
})
...
...
@@ -101,7 +131,7 @@ describe('VideoRecorderAPICallbackTest', function () {
})
afterAll
(
async
function
()
{
await
mediaTestBase
.
closeFd
();
await
mediaTestBase
.
closeFd
(
fdObject
.
fileAsset
,
fdObject
.
fdNumber
);
console
.
info
(
'
afterAll case
'
);
})
...
...
@@ -123,13 +153,15 @@ describe('VideoRecorderAPICallbackTest', function () {
eventEmitter
.
on
(
START_STREEAM
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
videoOutput
=
await
camera
Manager
.
createVideoOutput
(
videoProfiles
[
0
],
surfaceID
);
if
(
videoOutput
==
null
)
{
console
.
info
(
'
[camera] case createVideoOutput failed
'
);
}
else
{
console
.
info
(
'
[camera] case createVideoOutput success
'
);
}
captureSession
=
await
videoRecorderBase
.
initCaptureSession
(
videoOutput
,
cameraManager
,
cameras
,
cameraID
);
previewOutput
=
await
cameraManager
.
createPreviewOutput
(
previewProfiles
[
0
],
playerSurfaceId
)
captureSession
=
await
videoRecorderBase
.
initCaptureSession
(
videoOutput
,
cameraManager
,
cameras
[
0
],
previewOutput
);
await
videoOutput
.
start
().
then
(()
=>
{
console
.
info
(
'
[camera] case videoOutput start success
'
);
});
...
...
@@ -141,10 +173,6 @@ describe('VideoRecorderAPICallbackTest', function () {
await
videoOutput
.
stop
().
then
(()
=>
{
console
.
info
(
'
[camera] case videoOutput stop success
'
);
});
await
videoOutput
.
release
().
then
(()
=>
{
console
.
info
(
'
[camera] case videoOutput release success
'
);
});
videoOutput
=
undefined
;
await
videoRecorderBase
.
stopCaptureSession
(
captureSession
);
toNextStep
(
videoRecorder
,
steps
,
done
);
});
...
...
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
浏览文件 @
2a98d17e
此差异已折叠。
点击以展开。
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js
浏览文件 @
2a98d17e
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录