Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6b6a1cd8
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看板
未验证
提交
6b6a1cd8
编写于
2月 11, 2022
作者:
O
openharmony_ci
提交者:
Gitee
2月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1848 videoRecorder 测试代码添加camera组件功能
Merge pull request !1848 from FULIZHONG/recorder0209
上级
19c20ab2
094ca6c6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
433 addition
and
394 deletion
+433
-394
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js
...der/src/main/js/test/VideoRecorderAPICallbackTest.test.js
+147
-126
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
...er/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
+81
-31
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js
...der/src/main/js/test/VideoRecorderFuncPromiseTest.test.js
+205
-237
未找到文件。
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js
浏览文件 @
6b6a1cd8
...
...
@@ -14,7 +14,8 @@
*/
import
media
from
'
@ohos.multimedia.media
'
import
mediademo
from
'
@ohos.multimedia.mediademo
'
import
camera
from
'
@ohos.multimedia.camera
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
VideoRecorderAPICallbackTest
'
,
function
()
{
...
...
@@ -37,8 +38,11 @@ describe('VideoRecorderAPICallbackTest', function () {
const
SETPAUSE
=
'
setPause
'
;
const
CLOSE_STREAM
=
'
close_stream
'
;
const
ERROR_EVENT
=
'
error
'
;
let
surfaceID
=
null
;
let
mediaTest
=
null
;
let
cameraManager
;
let
cameras
;
let
captureSession
;
let
videoOutput
;
let
surfaceID
;
let
events
=
require
(
'
events
'
);
let
eventEmitter
=
new
events
.
EventEmitter
();
...
...
@@ -52,8 +56,8 @@ describe('VideoRecorderAPICallbackTest', function () {
fileFormat
:
'
mp4
'
,
videoBitrate
:
48000
,
videoCodec
:
'
video/mp4v-es
'
,
videoFrameWidth
:
12
0
,
videoFrameHeight
:
12
0
,
videoFrameWidth
:
64
0
,
videoFrameHeight
:
48
0
,
videoFrameRate
:
10
}
// orientationHint 0, 90, 180, 270
...
...
@@ -73,8 +77,8 @@ describe('VideoRecorderAPICallbackTest', function () {
fileFormat
:
'
mp4
'
,
videoBitrate
:
48000
,
videoCodec
:
'
video/mp4v-es
'
,
videoFrameWidth
:
12
0
,
videoFrameHeight
:
12
0
,
videoFrameWidth
:
64
0
,
videoFrameHeight
:
48
0
,
videoFrameRate
:
10
}
...
...
@@ -90,14 +94,13 @@ describe('VideoRecorderAPICallbackTest', function () {
function
sleep
(
time
)
{
for
(
let
t
=
Date
.
now
();
Date
.
now
()
-
t
<=
time
;);
}
;
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
})
beforeEach
(
function
()
{
mediaTest
=
null
;
surfaceID
=
null
;
console
.
info
(
'
beforeEach case
'
);
})
...
...
@@ -110,6 +113,43 @@ describe('VideoRecorderAPICallbackTest', function () {
console
.
info
(
'
afterAll case
'
);
})
async
function
initCamera
()
{
cameraManager
=
await
camera
.
getCameraManager
(
null
);
if
(
cameraManager
!=
null
)
{
console
.
info
(
'
[camera] case getCameraManager success
'
);
}
else
{
console
.
info
(
'
[camera] case getCameraManager failed
'
);
return
;
}
cameras
=
await
cameraManager
.
getCameras
();
if
(
cameras
!=
null
)
{
console
.
info
(
'
[camera] case getCameras success
'
);
}
else
{
console
.
info
(
'
[camera] case getCameras failed
'
);
}
}
async
function
initCaptureSession
(
videoOutPut
)
{
let
cameraInput
=
await
cameraManager
.
createCameraInput
(
cameras
[
0
].
cameraId
);
if
(
cameraInput
!=
null
)
{
console
.
info
(
'
[camera] case createCameraInput success
'
);
}
else
{
console
.
info
(
'
[camera] case createCameraInput failed
'
);
return
;
}
captureSession
=
await
camera
.
createCaptureSession
(
null
);
await
captureSession
.
beginConfig
();
await
captureSession
.
addInput
(
cameraInput
);
await
captureSession
.
addOutput
(
videoOutPut
);
await
captureSession
.
commitConfig
();
await
captureSession
.
start
();
}
async
function
stopCaptureSession
()
{
await
captureSession
.
stop
();
await
captureSession
.
release
();
}
function
printfError
(
error
,
done
)
{
expect
().
assertFail
();
console
.
info
(
`case error called,errMessage is
${
error
.
message
}
`
);
...
...
@@ -125,45 +165,45 @@ describe('VideoRecorderAPICallbackTest', function () {
}
}
eventEmitter
.
on
(
START_STREEAM
,
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
mediaTest
=
mediademo
.
createMediaTest
();
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
isPause
=
0
;
mediaTest
.
startStream
(
surfaceID
);
toNextStep
(
videoRecorder
,
steps
,
done
);
});
eventEmitter
.
on
(
SETEXIT
,
(
videoRecorder
,
steps
,
done
)
=>
{
mediaTest
.
isExit
=
steps
[
1
];
steps
.
shift
();
eventEmitter
.
on
(
START_STREEAM
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
if
(
videoOutput
==
null
)
{
console
.
info
(
'
[camera] case createVideoOutput failed
'
);
}
else
{
console
.
info
(
'
[camera] case createVideoOutput success
'
);
}
await
initCaptureSession
(
videoOutput
);
await
videoOutput
.
start
().
then
(()
=>
{
console
.
info
(
'
[camera] case videoOutput start success
'
);
});
toNextStep
(
videoRecorder
,
steps
,
done
);
});
eventEmitter
.
on
(
SETSTART
,
(
videoRecorder
,
steps
,
done
)
=>
{
mediaTest
.
isStart
=
steps
[
1
];
steps
.
shift
();
eventEmitter
.
on
(
SETSTART
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
toNextStep
(
videoRecorder
,
steps
,
done
);
});
eventEmitter
.
on
(
SETPAUSE
,
(
videoRecorder
,
steps
,
done
)
=>
{
mediaTest
.
isPause
=
steps
[
1
];
steps
.
shift
();
eventEmitter
.
on
(
SETPAUSE
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
toNextStep
(
videoRecorder
,
steps
,
done
);
});
eventEmitter
.
on
(
CLOSE_STREAM
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
CLOSE_STREAM
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
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
stopCaptureSession
();
toNextStep
(
videoRecorder
,
steps
,
done
);
});
eventEmitter
.
on
(
CREATE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
CREATE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
media
.
createVideoRecorder
((
err
,
recorder
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
...
...
@@ -171,76 +211,68 @@ describe('VideoRecorderAPICallbackTest', function () {
videoRecorder
=
recorder
;
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
if
((
typeof
(
err
)
!=
'
undefined
'
)
&&
(
steps
[
0
]
==
ERROR_EVENT
))
{
steps
.
shift
();
console
.
info
(
'
case createVideoRecorder error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
if
(
steps
[
0
]
==
ERROR_EVENT
)
{
steps
.
shift
();
console
.
info
(
'
case createVideoRecorder error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
}
printfError
(
err
,
done
);
}
});
});
eventEmitter
.
on
(
PREPARE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
PREPARE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
prepare
(
videoConfig
,
(
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case prepare success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
if
((
typeof
(
err
)
!=
'
undefined
'
)
&&
(
steps
[
0
]
==
ERROR_EVENT
))
{
steps
.
shift
();
console
.
info
(
'
case prepare error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
if
(
steps
[
0
]
==
ERROR_EVENT
)
{
steps
.
shift
();
console
.
info
(
'
case prepare error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
}
printfError
(
err
,
done
);
}
});
});
eventEmitter
.
on
(
PREPARE_OLNYVIDEO_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
PREPARE_OLNYVIDEO_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
prepare
(
onlyVideoConfig
,
(
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case prepare success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
if
((
typeof
(
err
)
!=
'
undefined
'
)
&&
(
steps
[
0
]
==
ERROR_EVENT
))
{
steps
.
shift
();
console
.
info
(
'
case prepare error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
if
(
steps
[
0
]
==
ERROR_EVENT
)
{
steps
.
shift
();
console
.
info
(
'
case prepare error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
}
printfError
(
err
,
done
);
}
});
});
eventEmitter
.
on
(
GETSURFACE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
GETSURFACE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
getInputSurface
((
err
,
outPutSurface
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case getInputSurface success
'
);
surfaceID
=
outPutSurface
;
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
if
((
typeof
(
err
)
!=
'
undefined
'
)
&&
(
steps
[
0
]
==
ERROR_EVENT
))
{
steps
.
shift
();
console
.
info
(
'
case getInputSurface error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
if
(
steps
[
0
]
==
ERROR_EVENT
)
{
steps
.
shift
();
console
.
info
(
'
case getInputSurface error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
}
printfError
(
err
,
done
);
}
});
});
eventEmitter
.
on
(
START_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
START_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
start
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
...
...
@@ -248,19 +280,17 @@ describe('VideoRecorderAPICallbackTest', function () {
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
if
((
typeof
(
err
)
!=
'
undefined
'
)
&&
(
steps
[
0
]
==
ERROR_EVENT
))
{
steps
.
shift
();
console
.
info
(
'
case start error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
if
(
steps
[
0
]
==
ERROR_EVENT
)
{
steps
.
shift
();
console
.
info
(
'
case start error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
}
printfError
(
err
,
done
);
}
});
});
eventEmitter
.
on
(
PAUSE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
PAUSE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
pause
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
...
...
@@ -268,19 +298,17 @@ describe('VideoRecorderAPICallbackTest', function () {
sleep
(
PAUSE_TIME
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
if
((
typeof
(
err
)
!=
'
undefined
'
)
&&
(
steps
[
0
]
==
ERROR_EVENT
))
{
steps
.
shift
();
console
.
info
(
'
case pause error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
if
(
steps
[
0
]
==
ERROR_EVENT
)
{
steps
.
shift
();
console
.
info
(
'
case pause error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
}
printfError
(
err
,
done
);
}
});
});
eventEmitter
.
on
(
RESUME_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
RESUME_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
resume
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
...
...
@@ -288,71 +316,63 @@ describe('VideoRecorderAPICallbackTest', function () {
sleep
(
RECORDER_TIME
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
if
((
typeof
(
err
)
!=
'
undefined
'
)
&&
(
steps
[
0
]
==
ERROR_EVENT
))
{
steps
.
shift
();
console
.
info
(
'
case resume error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
if
(
steps
[
0
]
==
ERROR_EVENT
)
{
steps
.
shift
();
console
.
info
(
'
case resume error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
}
printfError
(
err
,
done
);
}
});
});
eventEmitter
.
on
(
STOP_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
STOP_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
stop
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case stop success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
stopped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
if
((
typeof
(
err
)
!=
'
undefined
'
)
&&
(
steps
[
0
]
==
ERROR_EVENT
))
{
steps
.
shift
();
console
.
info
(
'
case stop error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
if
(
steps
[
0
]
==
ERROR_EVENT
)
{
steps
.
shift
();
console
.
info
(
'
case stop error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
}
printfError
(
err
,
done
);
}
});
});
eventEmitter
.
on
(
RESET_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
RESET_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
reset
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case reset success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
if
((
typeof
(
err
)
!=
'
undefined
'
)
&&
(
steps
[
0
]
==
ERROR_EVENT
))
{
steps
.
shift
();
console
.
info
(
'
case reset error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
if
(
steps
[
0
]
==
ERROR_EVENT
)
{
steps
.
shift
();
console
.
info
(
'
case reset error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
}
printfError
(
err
,
done
);
}
});
});
eventEmitter
.
on
(
RELEASE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
RELEASE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
release
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release success
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
if
((
typeof
(
err
)
!=
'
undefined
'
)
&&
(
steps
[
0
]
==
ERROR_EVENT
))
{
steps
.
shift
();
console
.
info
(
'
case release error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
if
(
steps
[
0
]
==
ERROR_EVENT
)
{
steps
.
shift
();
console
.
info
(
'
case release error hanpped
'
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
}
printfError
(
err
,
done
);
}
});
});
...
...
@@ -366,6 +386,7 @@ describe('VideoRecorderAPICallbackTest', function () {
* @tc.level : Level2
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_PREPARE_CALLBACK_0100
'
,
0
,
async
function
(
done
)
{
await
initCamera
();
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
...
...
@@ -397,7 +418,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_PREPARE_CALLBACK_0300
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
CLOSE_STREAM
,
PREPARE_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
);
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
CLOSE_STREAM
,
PREPARE_EVENT
,
ERROR_EVENT
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -412,7 +433,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_PREPARE_CALLBACK_0400
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
SETPAUSE
,
0
,
SETSTART
,
1
,
RESUME_EVENT
,
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
SETPAUSE
,
SETSTART
,
RESUME_EVENT
,
PREPARE_EVENT
,
ERROR_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -517,7 +538,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_START_CALLBACK_0300
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
START_EVENT
,
ERROR_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
START_EVENT
,
ERROR_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -532,7 +553,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_START_CALLBACK_0400
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
SETPAUSE
,
0
,
SETSTART
,
1
,
RESUME_EVENT
,
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
SETPAUSE
,
SETSTART
,
RESUME_EVENT
,
START_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -636,7 +657,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_PAUSE_CALLBACK_0300
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -651,7 +672,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_PAUSE_CALLBACK_0400
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
SETPAUSE
,
0
,
SETSTART
,
1
,
RESUME_EVENT
,
SETPAUSE
,
1
,
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
SETPAUSE
,
SETSTART
,
RESUME_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -712,7 +733,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_PAUSE_CALLBACK_0800
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
PAUSE_EVENT
,
PAUSE_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
PAUSE_EVENT
,
PAUSE_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -770,7 +791,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_RESUME_CALLBACK_0400
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
SETPAUSE
,
0
,
SETSTART
,
1
,
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
SETPAUSE
,
SETSTART
,
RESUME_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -831,7 +852,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_RESUME_CALLBACK_0800
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
SETPAUSE
,
0
,
SETSTART
,
1
,
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
SETPAUSE
,
SETSTART
,
RESUME_EVENT
,
RESUME_EVENT
,
RESUME_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -890,7 +911,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_STOP_CALLBACK_0400
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
STOP_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
STOP_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -905,7 +926,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_STOP_CALLBACK_0500
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
SETPAUSE
,
0
,
SETSTART
,
1
,
RESUME_EVENT
,
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
SETPAUSE
,
SETSTART
,
RESUME_EVENT
,
STOP_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -1010,7 +1031,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_RESET_CALLBACK_0400
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
RESET_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
RESET_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -1025,7 +1046,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_RESET_CALLBACK_0500
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
SETPAUSE
,
0
,
SETSTART
,
1
,
RESUME_EVENT
,
START_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
SETPAUSE
,
SETSTART
,
RESUME_EVENT
,
RESET_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -1128,7 +1149,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_GETSURFACE_CALLBACK_0400
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
GETSURFACE_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
SETPAUSE
,
PAUSE_EVENT
,
GETSURFACE_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
@@ -1143,7 +1164,7 @@ describe('VideoRecorderAPICallbackTest', function () {
it
(
'
SUB_MEDIA_VIDEO_RECORDER_GETSURFACE_CALLBACK_0500
'
,
0
,
async
function
(
done
)
{
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_STREEAM
,
START_EVENT
,
SETPAUSE
,
1
,
PAUSE_EVENT
,
SETPAUSE
,
0
,
SETSTART
,
1
,
RESUME_EVENT
,
GETSURFACE_EVENT
,
SETPAUSE
,
PAUSE_EVENT
,
SETPAUSE
,
SETSTART
,
RESUME_EVENT
,
GETSURFACE_EVENT
,
CLOSE_STREAM
,
RELEASE_EVENT
,
END_EVENT
);
eventEmitter
.
emit
(
mySteps
[
0
],
videoRecorder
,
mySteps
,
done
);
})
...
...
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
浏览文件 @
6b6a1cd8
...
...
@@ -14,7 +14,8 @@
*/
import
media
from
'
@ohos.multimedia.media
'
import
mediademo
from
'
@ohos.multimedia.mediademo
'
import
camera
from
'
@ohos.multimedia.camera
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
RecorderLocalTestVideoFUNC
'
,
function
()
{
...
...
@@ -31,7 +32,11 @@ describe('RecorderLocalTestVideoFUNC', function () {
const
STOP_EVENT
=
'
stop
'
;
const
RESET_EVENT
=
'
reset
'
;
const
RELEASE_EVENT
=
'
release
'
;
let
mediaTest
=
null
;
let
cameraManager
;
let
cameras
;
let
captureSession
;
let
videoOutput
;
let
surfaceID
;
let
configFile
=
{
audioBitrate
:
48000
,
audioChannels
:
2
,
...
...
@@ -41,8 +46,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
fileFormat
:
'
mp4
'
,
videoBitrate
:
48000
,
videoCodec
:
'
video/mp4v-es
'
,
videoFrameWidth
:
12
0
,
videoFrameHeight
:
12
0
,
videoFrameWidth
:
64
0
,
videoFrameHeight
:
48
0
,
videoFrameRate
:
10
}
// orientationHint 0, 90, 180, 270
...
...
@@ -62,8 +67,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
fileFormat
:
'
mp4
'
,
videoBitrate
:
48000
,
videoCodec
:
'
video/mp4v-es
'
,
videoFrameWidth
:
12
0
,
videoFrameHeight
:
12
0
,
videoFrameWidth
:
64
0
,
videoFrameHeight
:
48
0
,
videoFrameRate
:
10
}
...
...
@@ -79,14 +84,13 @@ describe('RecorderLocalTestVideoFUNC', function () {
function
sleep
(
time
)
{
for
(
let
t
=
Date
.
now
();
Date
.
now
()
-
t
<=
time
;);
}
;
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
})
beforeEach
(
function
()
{
mediaTest
=
null
;
console
.
info
(
'
beforeEach case
'
);
})
...
...
@@ -98,6 +102,43 @@ describe('RecorderLocalTestVideoFUNC', function () {
console
.
info
(
'
afterAll case
'
);
})
async
function
initCamera
()
{
cameraManager
=
await
camera
.
getCameraManager
(
null
);
if
(
cameraManager
!=
null
)
{
console
.
info
(
'
[camera] case getCameraManager success
'
);
}
else
{
console
.
info
(
'
[camera] case getCameraManager failed
'
);
return
;
}
cameras
=
await
cameraManager
.
getCameras
();
if
(
cameras
!=
null
)
{
console
.
info
(
'
[camera] case getCameras success
'
);
}
else
{
console
.
info
(
'
[camera] case getCameras failed
'
);
}
}
async
function
initCaptureSession
(
videoOutPut
)
{
let
cameraInput
=
await
cameraManager
.
createCameraInput
(
cameras
[
0
].
cameraId
);
if
(
cameraInput
!=
null
)
{
console
.
info
(
'
[camera] case createCameraInput success
'
);
}
else
{
console
.
info
(
'
[camera] case createCameraInput failed
'
);
return
;
}
captureSession
=
await
camera
.
createCaptureSession
(
null
);
await
captureSession
.
beginConfig
();
await
captureSession
.
addInput
(
cameraInput
);
await
captureSession
.
addOutput
(
videoOutPut
);
await
captureSession
.
commitConfig
();
await
captureSession
.
start
();
}
async
function
stopCaptureSession
()
{
await
captureSession
.
stop
();
await
captureSession
.
release
();
}
function
printfError
(
error
,
done
)
{
expect
().
assertFail
();
console
.
info
(
`case error called,errMessage is
${
error
.
message
}
`
);
...
...
@@ -128,7 +169,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
}
eventEmitter
.
on
(
CREATE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
CREATE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
media
.
createVideoRecorder
((
err
,
recorder
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
...
...
@@ -143,13 +184,12 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
eventEmitter
.
on
(
PREPARE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
PREPARE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
prepare
(
videoConfig
,
(
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case prepare success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
...
...
@@ -157,13 +197,12 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
eventEmitter
.
on
(
PREPARE_OLNYVIDEO_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
PREPARE_OLNYVIDEO_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
prepare
(
onlyVideoConfig
,
(
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case prepare success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
...
...
@@ -171,15 +210,13 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
eventEmitter
.
on
(
GETSURFACE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
GETSURFACE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
getInputSurface
((
err
,
surfaceID
)
=>
{
videoRecorder
.
getInputSurface
((
err
,
outPutsurface
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case getInputSurface success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
surfaceID
=
outPutsurface
;
console
.
info
(
'
case getInputSurface success :
'
+
surfaceID
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
printfError
(
err
,
done
);
...
...
@@ -187,8 +224,18 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
eventEmitter
.
on
(
START_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
START_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
if
(
videoOutput
==
null
)
{
console
.
info
(
'
case createVideoOutput failed
'
);
}
else
{
console
.
info
(
'
case createVideoOutput success
'
);
}
await
initCaptureSession
(
videoOutput
);
await
videoOutput
.
start
().
then
(()
=>
{
console
.
info
(
'
case videoOutput start success
'
);
});
videoRecorder
.
start
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case start success
'
);
...
...
@@ -201,15 +248,12 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
eventEmitter
.
on
(
PAUSE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
PAUSE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
mediaTest
.
isPause
=
1
;
sleep
(
100
);
videoRecorder
.
pause
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case pause success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
mediaTest
.
isPause
=
0
;
sleep
(
PAUSE_TIME
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
...
...
@@ -218,9 +262,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
eventEmitter
.
on
(
RESUME_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
RESUME_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
mediaTest
.
isStart
=
1
;
videoRecorder
.
resume
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case resume success
'
);
...
...
@@ -233,7 +276,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
eventEmitter
.
on
(
STOP_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
STOP_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
stop
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
...
...
@@ -246,7 +289,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
eventEmitter
.
on
(
RESET_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
RESET_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
videoRecorder
.
reset
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
...
...
@@ -259,10 +302,16 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
eventEmitter
.
on
(
RELEASE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
RELEASE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoOutput
.
stop
().
then
(()
=>
{
console
.
info
(
'
case videoOutput stop success
'
);
});
await
videoOutput
.
release
().
then
(()
=>
{
console
.
info
(
'
case videoOutput release success
'
);
});
videoOutput
=
undefined
;
await
stopCaptureSession
();
videoRecorder
.
release
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
...
...
@@ -283,6 +332,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0100
'
,
0
,
async
function
(
done
)
{
await
initCamera
();
videoConfig
.
url
=
'
file:///data/media/19.mp4
'
;
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_EVENT
,
RELEASE_EVENT
,
END_EVENT
);
...
...
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js
浏览文件 @
6b6a1cd8
...
...
@@ -14,12 +14,17 @@
*/
import
media
from
'
@ohos.multimedia.media
'
import
mediademo
from
'
@ohos.multimedia.mediademo
'
import
camera
from
'
@ohos.multimedia.camera
'
import
mediaLibrary
from
'
@ohos.multimedia.mediaLibrary
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
RecorderLocalTestVideoFUNC
'
,
function
()
{
const
RECORDER_TIME
=
3000
;
const
PAUSE_TIME
=
1000
;
let
cameraManager
;
let
cameras
;
let
captureSession
;
let
testFdNumber
;
let
configFile
=
{
audioBitrate
:
48000
,
audioChannels
:
2
,
...
...
@@ -29,8 +34,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
fileFormat
:
'
mp4
'
,
videoBitrate
:
48000
,
videoCodec
:
'
video/mp4v-es
'
,
videoFrameWidth
:
12
0
,
videoFrameHeight
:
12
0
,
videoFrameWidth
:
64
0
,
videoFrameHeight
:
48
0
,
videoFrameRate
:
10
}
...
...
@@ -50,8 +55,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
fileFormat
:
'
mp4
'
,
videoBitrate
:
48000
,
videoCodec
:
'
video/mp4v-es
'
,
videoFrameWidth
:
12
0
,
videoFrameHeight
:
12
0
,
videoFrameWidth
:
64
0
,
videoFrameHeight
:
48
0
,
videoFrameRate
:
10
}
...
...
@@ -67,7 +72,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
function
sleep
(
time
)
{
for
(
let
t
=
Date
.
now
();
Date
.
now
()
-
t
<=
time
;);
}
;
}
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
...
...
@@ -85,6 +90,85 @@ describe('RecorderLocalTestVideoFUNC', function () {
console
.
info
(
'
afterAll case
'
);
})
async
function
initCamera
()
{
cameraManager
=
await
camera
.
getCameraManager
(
null
);
if
(
cameraManager
!=
null
)
{
console
.
info
(
'
[camera] case getCameraManager success
'
);
}
else
{
console
.
info
(
'
[camera] case getCameraManager failed
'
);
return
;
}
cameras
=
await
cameraManager
.
getCameras
();
if
(
cameras
!=
null
)
{
console
.
info
(
'
[camera] case getCameras success
'
);
}
else
{
console
.
info
(
'
[camera] case getCameras failed
'
);
}
}
async
function
initCaptureSession
(
videoOutPut
)
{
let
cameraInput
=
await
cameraManager
.
createCameraInput
(
cameras
[
0
].
cameraId
);
if
(
cameraInput
!=
null
)
{
console
.
info
(
'
[camera] case createCameraInput success
'
);
}
else
{
console
.
info
(
'
[camera] case createCameraInput failed
'
);
return
;
}
captureSession
=
await
camera
.
createCaptureSession
(
null
);
await
captureSession
.
beginConfig
();
await
captureSession
.
addInput
(
cameraInput
);
await
captureSession
.
addOutput
(
videoOutPut
);
await
captureSession
.
commitConfig
();
await
captureSession
.
start
();
}
async
function
stopCaptureSession
()
{
await
captureSession
.
stop
();
await
captureSession
.
release
();
}
async
function
startVideoOutput
(
videoOutPut
)
{
if
(
videoOutPut
==
null
)
{
console
.
info
(
'
[camera] case videoOutPut is null
'
);
return
;
}
await
initCaptureSession
(
videoOutPut
);
await
videoOutPut
.
start
().
then
(()
=>
{
console
.
info
(
'
[camera] case videoOutput start success
'
);
});
}
async
function
stopVideoOutput
(
videoOutPut
)
{
await
videoOutPut
.
release
().
then
(()
=>
{
console
.
info
(
'
[camera] case videoOutput release success
'
);
});
videoOutPut
=
undefined
;
await
stopCaptureSession
();
}
async
function
getFd
()
{
let
displayName
=
'
VID_202202081551.mp4
'
;
const
medialib
=
mediaLibrary
.
getMediaLibrary
();
let
fileKeyObj
=
mediaLibrary
.
FileKey
;
let
mediaType
=
mediaLibrary
.
MediaType
.
VIDEO
;
let
publicPath
=
await
medialib
.
getPublicDirectory
(
mediaLibrary
.
DirectoryType
.
DIR_VIDEO
);
let
dataUri
=
await
medialib
.
createAsset
(
mediaType
,
displayName
,
publicPath
);
if
(
dataUri
!=
undefined
)
{
let
args
=
dataUri
.
id
.
toString
();
let
fetchOp
=
{
selections
:
fileKeyObj
.
ID
+
"
=?
"
,
selectionArgs
:
[
args
],
}
let
fetchFileResult
=
await
medialib
.
getFileAssets
(
fetchOp
);
let
fileAsset
=
await
fetchFileResult
.
getAllObject
();
let
fdNumber
=
await
fileAsset
[
0
].
open
(
'
Rw
'
);
fdNumber
=
"
fd://
"
+
fdNumber
.
toString
();
testFdNumber
=
fdNumber
;
}
}
function
failureCallback
(
error
)
{
expect
().
assertFail
();
console
.
info
(
`case error called,errMessage is
${
error
.
message
}
`
);
...
...
@@ -104,9 +188,10 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0100
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
await
initCamera
();
videoConfig
.
url
=
'
file:///data/media/01.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -121,30 +206,25 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
console
.
info
(
'
case start called
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoOutput
.
stop
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -157,9 +237,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0200
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/02.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -174,7 +254,6 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
...
...
@@ -182,33 +261,26 @@ describe('RecorderLocalTestVideoFUNC', function () {
console
.
info
(
`case getInputSurface,state is
${
videoRecorder
.
state
}
`
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
1
;
sleep
(
100
);
await
videoOutput
.
stop
();
await
videoRecorder
.
pause
().
then
(()
=>
{
console
.
info
(
'
case pause called
'
);
sleep
(
PAUSE_TIME
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
0
;
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
console
.
info
(
'
case release
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -221,9 +293,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0300
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/03.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -238,47 +310,40 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
console
.
info
(
'
case getInputSurface called
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
console
.
info
(
'
case start called
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
1
;
sleep
(
100
);
await
videoOutput
.
stop
();
await
videoRecorder
.
pause
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
sleep
(
PAUSE_TIME
);
console
.
info
(
'
case pause called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
0
;
mediaTest
.
isStart
=
1
;
await
videoOutput
.
start
();
await
videoRecorder
.
resume
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
console
.
info
(
'
case resume called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -291,9 +356,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0400
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/04.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -308,36 +373,32 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
console
.
info
(
'
case getInputSurface called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
await
videoOutput
.
stop
()
;
await
videoRecorder
.
stop
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
stopped
'
);
console
.
info
(
'
case stop called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -350,9 +411,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0500
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/05.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -367,36 +428,31 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
console
.
info
(
'
case getInputSurface called
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
await
videoOutput
.
stop
();
await
videoRecorder
.
reset
().
then
(()
=>
{
console
.
info
(
'
case reset called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -409,9 +465,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0600
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/06.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -426,44 +482,38 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
console
.
info
(
'
case getInputSurface called
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
1
;
sleep
(
100
);
await
videoOutput
.
stop
();
await
videoRecorder
.
pause
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
sleep
(
PAUSE_TIME
);
console
.
info
(
'
case pause called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
0
;
await
videoRecorder
.
stop
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
stopped
'
);
console
.
info
(
'
case stop called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -476,9 +526,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0700
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/07.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -493,44 +543,38 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
console
.
info
(
'
case getInputSurface called
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
1
;
sleep
(
100
);
await
videoOutput
.
stop
();
await
videoRecorder
.
pause
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
sleep
(
PAUSE_TIME
);
console
.
info
(
'
case pause called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
0
;
await
videoRecorder
.
reset
().
then
(()
=>
{
console
.
info
(
'
case reset called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -543,9 +587,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0800
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/08.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -560,51 +604,45 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
console
.
info
(
'
case getInputSurface called
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
1
;
sleep
(
100
);
await
videoOutput
.
stop
();
await
videoRecorder
.
pause
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
sleep
(
PAUSE_TIME
);
console
.
info
(
'
case pause called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
0
;
mediaTest
.
isStart
=
1
;
await
videoOutput
.
start
();
await
videoRecorder
.
resume
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
console
.
info
(
'
case resume called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
await
videoRecorder
.
stop
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
stopped
'
);
console
.
info
(
'
case stop called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -617,9 +655,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0900
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/09.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -634,51 +672,45 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
console
.
info
(
'
case getInputSurface called
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
1
;
sleep
(
100
);
await
videoOutput
.
stop
();
await
videoRecorder
.
pause
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
sleep
(
PAUSE_TIME
);
console
.
info
(
'
case pause called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
0
;
mediaTest
.
isStart
=
1
;
await
videoOutput
.
start
();
await
videoRecorder
.
resume
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
console
.
info
(
'
case resume called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
await
videoOutput
.
stop
();
await
videoRecorder
.
reset
().
then
(()
=>
{
console
.
info
(
'
case reset called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -692,9 +724,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1000
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/10.mp4
'
;
configFile
.
audioBitrate
=
8000
;
configFile
.
audioSampleRate
=
8000
;
...
...
@@ -712,36 +744,32 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
console
.
info
(
'
case getInputSurface called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
await
videoOutput
.
stop
()
;
await
videoRecorder
.
stop
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
stopped
'
);
console
.
info
(
'
case stop called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -755,9 +783,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1100
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/11.mp4
'
;
configFile
.
audioBitrate
=
16000
;
configFile
.
audioSampleRate
=
32000
;
...
...
@@ -775,36 +803,32 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
console
.
info
(
'
case getInputSurface called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
await
videoOutput
.
stop
()
;
await
videoRecorder
.
stop
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
stopped
'
);
console
.
info
(
'
case stop called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -818,9 +842,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1200
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/12.mp4
'
;
configFile
.
audioBitrate
=
32000
;
configFile
.
audioSampleRate
=
44100
;
...
...
@@ -838,36 +862,32 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
console
.
info
(
'
case getInputSurface called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
await
videoOutput
.
stop
()
;
await
videoRecorder
.
stop
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
stopped
'
);
console
.
info
(
'
case stop called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -881,9 +901,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1300
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/13.mp4
'
;
configFile
.
audioBitrate
=
112000
;
configFile
.
audioSampleRate
=
96000
;
...
...
@@ -901,36 +921,32 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
console
.
info
(
'
case getInputSurface called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
await
videoOutput
.
stop
()
;
await
videoRecorder
.
stop
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
stopped
'
);
console
.
info
(
'
case stop called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -943,9 +959,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1400
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
onlyVideoConfig
.
url
=
'
file:///data/media/14.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -960,31 +976,25 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
onlyVideoConfig
).
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
console
.
info
(
'
case prepare called
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
console
.
info
(
'
case start called
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoOutput
.
stop
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -997,9 +1007,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1500
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
onlyVideoConfig
.
url
=
'
file:///data/media/15.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -1014,7 +1024,6 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
onlyVideoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
...
...
@@ -1022,33 +1031,27 @@ describe('RecorderLocalTestVideoFUNC', function () {
console
.
info
(
`case getInputSurface,state is
${
videoRecorder
.
state
}
`
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
1
;
sleep
(
100
);
await
videoOutput
.
stop
();
await
videoRecorder
.
pause
().
then
(()
=>
{
console
.
info
(
'
case pause called
'
);
sleep
(
PAUSE_TIME
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
0
;
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
console
.
info
(
'
case release
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -1061,9 +1064,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1600
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
onlyVideoConfig
.
url
=
'
file:///data/media/16.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -1078,47 +1081,40 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
onlyVideoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
console
.
info
(
'
case getInputSurface called
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
console
.
info
(
'
case start called
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
1
;
sleep
(
100
);
await
videoOutput
.
stop
();
await
videoRecorder
.
pause
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
sleep
(
PAUSE_TIME
);
console
.
info
(
'
case pause called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isPause
=
0
;
mediaTest
.
isStart
=
0
;
await
videoOutput
.
start
();
await
videoRecorder
.
resume
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
console
.
info
(
'
case resume called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -1131,9 +1127,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1700
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
onlyVideoConfig
.
url
=
'
file:///data/media/17.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -1148,36 +1144,31 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
onlyVideoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
console
.
info
(
'
case getInputSurface called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
await
videoOutput
.
stop
();
await
videoRecorder
.
stop
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
stopped
'
);
console
.
info
(
'
case stop called
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -1190,9 +1181,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level1
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1800
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
onlyVideoConfig
.
url
=
'
file:///data/media/18.mp4
'
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
console
.
info
(
'
case createVideoRecorder called
'
);
...
...
@@ -1207,36 +1198,31 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
onlyVideoConfig
).
then
(()
=>
{
console
.
info
(
'
case recordr prepare called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
console
.
info
(
'
case getInputSurface called
'
);
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
case start called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
await
videoOutput
.
stop
();
await
videoRecorder
.
reset
().
then
(()
=>
{
console
.
info
(
'
case reset called
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
closeStream
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -1249,9 +1235,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1900
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/40.mp4
'
;
videoConfig
.
orientationHint
=
90
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
...
...
@@ -1267,30 +1253,24 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
console
.
info
(
'
case start called
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoOutput
.
stop
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -1303,9 +1283,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2000
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/41.mp4
'
;
videoConfig
.
orientationHint
=
180
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
...
...
@@ -1321,30 +1301,24 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
console
.
info
(
'
case start called
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoOutput
.
stop
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
...
...
@@ -1357,9 +1331,9 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2100
'
,
0
,
async
function
(
done
)
{
let
mediaTest
;
let
videoRecorder
=
undefined
;
let
surfaceID
=
''
;
let
videoOutput
;
videoConfig
.
url
=
'
file:///data/media/42.mp4
'
;
videoConfig
.
orientationHint
=
270
;
await
media
.
createVideoRecorder
().
then
((
recorder
)
=>
{
...
...
@@ -1375,30 +1349,24 @@ describe('RecorderLocalTestVideoFUNC', function () {
await
videoRecorder
.
prepare
(
videoConfig
).
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
},
failureCallback
).
catch
(
catchCallback
);
await
videoRecorder
.
getInputSurface
().
then
((
outPutSurface
)
=>
{
surfaceID
=
outPutSurface
;
mediaTest
.
isExit
=
0
;
mediaTest
.
isStart
=
1
;
mediaTest
.
startStream
(
surfaceID
);
},
failureCallback
).
catch
(
catchCallback
);
videoOutput
=
await
camera
.
createVideoOutput
(
surfaceID
);
await
startVideoOutput
(
videoOutput
);
await
videoRecorder
.
start
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
playing
'
);
console
.
info
(
'
case start called
'
);
sleep
(
RECORDER_TIME
);
},
failureCallback
).
catch
(
catchCallback
);
mediaTest
.
isExit
=
1
;
mediaTest
.
closeStream
();
await
videoOutput
.
stop
();
await
videoRecorder
.
release
().
then
(()
=>
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
case release
'
);
},
failureCallback
).
catch
(
catchCallback
);
await
stopVideoOutput
(
videoOutput
);
done
();
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录