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
此差异已折叠。
点击以展开。
multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js
浏览文件 @
6b6a1cd8
...
@@ -14,7 +14,8 @@
...
@@ -14,7 +14,8 @@
*/
*/
import
media
from
'
@ohos.multimedia.media
'
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
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
describe
(
'
RecorderLocalTestVideoFUNC
'
,
function
()
{
describe
(
'
RecorderLocalTestVideoFUNC
'
,
function
()
{
...
@@ -31,7 +32,11 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -31,7 +32,11 @@ describe('RecorderLocalTestVideoFUNC', function () {
const
STOP_EVENT
=
'
stop
'
;
const
STOP_EVENT
=
'
stop
'
;
const
RESET_EVENT
=
'
reset
'
;
const
RESET_EVENT
=
'
reset
'
;
const
RELEASE_EVENT
=
'
release
'
;
const
RELEASE_EVENT
=
'
release
'
;
let
mediaTest
=
null
;
let
cameraManager
;
let
cameras
;
let
captureSession
;
let
videoOutput
;
let
surfaceID
;
let
configFile
=
{
let
configFile
=
{
audioBitrate
:
48000
,
audioBitrate
:
48000
,
audioChannels
:
2
,
audioChannels
:
2
,
...
@@ -41,8 +46,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -41,8 +46,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
fileFormat
:
'
mp4
'
,
fileFormat
:
'
mp4
'
,
videoBitrate
:
48000
,
videoBitrate
:
48000
,
videoCodec
:
'
video/mp4v-es
'
,
videoCodec
:
'
video/mp4v-es
'
,
videoFrameWidth
:
12
0
,
videoFrameWidth
:
64
0
,
videoFrameHeight
:
12
0
,
videoFrameHeight
:
48
0
,
videoFrameRate
:
10
videoFrameRate
:
10
}
}
// orientationHint 0, 90, 180, 270
// orientationHint 0, 90, 180, 270
...
@@ -62,8 +67,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -62,8 +67,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
fileFormat
:
'
mp4
'
,
fileFormat
:
'
mp4
'
,
videoBitrate
:
48000
,
videoBitrate
:
48000
,
videoCodec
:
'
video/mp4v-es
'
,
videoCodec
:
'
video/mp4v-es
'
,
videoFrameWidth
:
12
0
,
videoFrameWidth
:
64
0
,
videoFrameHeight
:
12
0
,
videoFrameHeight
:
48
0
,
videoFrameRate
:
10
videoFrameRate
:
10
}
}
...
@@ -79,14 +84,13 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -79,14 +84,13 @@ describe('RecorderLocalTestVideoFUNC', function () {
function
sleep
(
time
)
{
function
sleep
(
time
)
{
for
(
let
t
=
Date
.
now
();
Date
.
now
()
-
t
<=
time
;);
for
(
let
t
=
Date
.
now
();
Date
.
now
()
-
t
<=
time
;);
}
;
}
beforeAll
(
function
()
{
beforeAll
(
function
()
{
console
.
info
(
'
beforeAll case
'
);
console
.
info
(
'
beforeAll case
'
);
})
})
beforeEach
(
function
()
{
beforeEach
(
function
()
{
mediaTest
=
null
;
console
.
info
(
'
beforeEach case
'
);
console
.
info
(
'
beforeEach case
'
);
})
})
...
@@ -98,6 +102,43 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -98,6 +102,43 @@ describe('RecorderLocalTestVideoFUNC', function () {
console
.
info
(
'
afterAll case
'
);
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
)
{
function
printfError
(
error
,
done
)
{
expect
().
assertFail
();
expect
().
assertFail
();
console
.
info
(
`case error called,errMessage is
${
error
.
message
}
`
);
console
.
info
(
`case error called,errMessage is
${
error
.
message
}
`
);
...
@@ -128,7 +169,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -128,7 +169,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
}
}
eventEmitter
.
on
(
CREATE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
CREATE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
steps
.
shift
();
media
.
createVideoRecorder
((
err
,
recorder
)
=>
{
media
.
createVideoRecorder
((
err
,
recorder
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
...
@@ -143,13 +184,12 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -143,13 +184,12 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
});
});
eventEmitter
.
on
(
PREPARE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
PREPARE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
steps
.
shift
();
videoRecorder
.
prepare
(
videoConfig
,
(
err
)
=>
{
videoRecorder
.
prepare
(
videoConfig
,
(
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case prepare success
'
);
console
.
info
(
'
case prepare success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
toNextStep
(
videoRecorder
,
steps
,
done
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
}
else
{
printfError
(
err
,
done
);
printfError
(
err
,
done
);
...
@@ -157,13 +197,12 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -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
();
steps
.
shift
();
videoRecorder
.
prepare
(
onlyVideoConfig
,
(
err
)
=>
{
videoRecorder
.
prepare
(
onlyVideoConfig
,
(
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case prepare success
'
);
console
.
info
(
'
case prepare success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
=
mediademo
.
createMediaTest
();
toNextStep
(
videoRecorder
,
steps
,
done
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
}
else
{
printfError
(
err
,
done
);
printfError
(
err
,
done
);
...
@@ -171,15 +210,13 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -171,15 +210,13 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
});
});
eventEmitter
.
on
(
GETSURFACE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
GETSURFACE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
steps
.
shift
();
videoRecorder
.
getInputSurface
((
err
,
surfaceID
)
=>
{
videoRecorder
.
getInputSurface
((
err
,
outPutsurface
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case getInputSurface success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
prepared
'
);
mediaTest
.
isExit
=
0
;
surfaceID
=
outPutsurface
;
mediaTest
.
isStart
=
1
;
console
.
info
(
'
case getInputSurface success :
'
+
surfaceID
);
mediaTest
.
startStream
(
surfaceID
);
toNextStep
(
videoRecorder
,
steps
,
done
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
}
else
{
printfError
(
err
,
done
);
printfError
(
err
,
done
);
...
@@ -187,8 +224,18 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -187,8 +224,18 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
});
});
eventEmitter
.
on
(
START_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
START_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
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
)
=>
{
videoRecorder
.
start
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case start success
'
);
console
.
info
(
'
case start success
'
);
...
@@ -201,15 +248,12 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -201,15 +248,12 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
});
});
eventEmitter
.
on
(
PAUSE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
PAUSE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
steps
.
shift
();
mediaTest
.
isPause
=
1
;
sleep
(
100
);
videoRecorder
.
pause
((
err
)
=>
{
videoRecorder
.
pause
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case pause success
'
);
console
.
info
(
'
case pause success
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
paused
'
);
mediaTest
.
isPause
=
0
;
sleep
(
PAUSE_TIME
);
sleep
(
PAUSE_TIME
);
toNextStep
(
videoRecorder
,
steps
,
done
);
toNextStep
(
videoRecorder
,
steps
,
done
);
}
else
{
}
else
{
...
@@ -218,9 +262,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -218,9 +262,8 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
});
});
eventEmitter
.
on
(
RESUME_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
RESUME_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
steps
.
shift
();
mediaTest
.
isStart
=
1
;
videoRecorder
.
resume
((
err
)
=>
{
videoRecorder
.
resume
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
console
.
info
(
'
case resume success
'
);
console
.
info
(
'
case resume success
'
);
...
@@ -233,7 +276,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -233,7 +276,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
});
});
eventEmitter
.
on
(
STOP_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
STOP_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
steps
.
shift
();
videoRecorder
.
stop
((
err
)
=>
{
videoRecorder
.
stop
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
...
@@ -246,7 +289,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -246,7 +289,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
});
});
eventEmitter
.
on
(
RESET_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
RESET_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
steps
.
shift
();
videoRecorder
.
reset
((
err
)
=>
{
videoRecorder
.
reset
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
...
@@ -259,10 +302,16 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -259,10 +302,16 @@ describe('RecorderLocalTestVideoFUNC', function () {
});
});
});
});
eventEmitter
.
on
(
RELEASE_EVENT
,
(
videoRecorder
,
steps
,
done
)
=>
{
eventEmitter
.
on
(
RELEASE_EVENT
,
async
(
videoRecorder
,
steps
,
done
)
=>
{
steps
.
shift
();
steps
.
shift
();
mediaTest
.
isExit
=
1
;
await
videoOutput
.
stop
().
then
(()
=>
{
mediaTest
.
closeStream
();
console
.
info
(
'
case videoOutput stop success
'
);
});
await
videoOutput
.
release
().
then
(()
=>
{
console
.
info
(
'
case videoOutput release success
'
);
});
videoOutput
=
undefined
;
await
stopCaptureSession
();
videoRecorder
.
release
((
err
)
=>
{
videoRecorder
.
release
((
err
)
=>
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
if
(
typeof
(
err
)
==
'
undefined
'
)
{
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
expect
(
videoRecorder
.
state
).
assertEqual
(
'
idle
'
);
...
@@ -283,6 +332,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
...
@@ -283,6 +332,7 @@ describe('RecorderLocalTestVideoFUNC', function () {
* @tc.level : Level0
* @tc.level : Level0
*/
*/
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0100
'
,
0
,
async
function
(
done
)
{
it
(
'
SUB_MEDIA_VIDEO_RECORDER_FUNCTION_CALLBACK_0100
'
,
0
,
async
function
(
done
)
{
await
initCamera
();
videoConfig
.
url
=
'
file:///data/media/19.mp4
'
;
videoConfig
.
url
=
'
file:///data/media/19.mp4
'
;
let
videoRecorder
=
null
;
let
videoRecorder
=
null
;
let
mySteps
=
new
Array
(
CREATE_EVENT
,
PREPARE_EVENT
,
GETSURFACE_EVENT
,
START_EVENT
,
RELEASE_EVENT
,
END_EVENT
);
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
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录