Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
757d3225
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
757d3225
编写于
3月 20, 2023
作者:
O
openharmony_ci
提交者:
Gitee
3月 20, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8072 avRecorder多场景用例 avPlayer增加api覆盖
Merge pull request !8072 from Nicklaus/master
上级
8ea871d1
e3d4bf72
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
514 addition
and
482 deletion
+514
-482
multimedia/media/media_js_standard/AVPlayerTestBase.js
multimedia/media/media_js_standard/AVPlayerTestBase.js
+7
-7
multimedia/media/media_js_standard/AVRecorderTestBase.js
multimedia/media/media_js_standard/AVRecorderTestBase.js
+390
-0
multimedia/media/media_js_standard/avRecorder/src/main/js/test/AVRecorderFuncTest.test.js
...rd/avRecorder/src/main/js/test/AVRecorderFuncTest.test.js
+110
-469
multimedia/media/media_js_standard/avRecorder/src/main/js/test/List.test.js
...edia_js_standard/avRecorder/src/main/js/test/List.test.js
+7
-6
未找到文件。
multimedia/media/media_js_standard/AVPlayerTestBase.js
浏览文件 @
757d3225
...
...
@@ -638,7 +638,7 @@ export async function seekLoopWithoutCallback(src, avPlayer, done) {
console
.
info
(
`case Initialized in, surfaceID is
${
surfaceID
}
`
);
avPlayer
=
await
idle
(
src
,
avPlayer
)
await
setSource
(
avPlayer
,
src
);
if
(
avPlayer
.
state
==
AV_PLAYER_STATE
.
INITIALIZED
)
{
if
(
avPlayer
.
state
==
'
initialized
'
)
{
avPlayer
.
surfaceId
=
surfaceID
;
preparePromise
(
avPlayer
);
await
sleep
(
2000
);
...
...
@@ -679,7 +679,7 @@ export async function prepareToStopLoop(src, avPlayer, done) {
// prepare to stop loop 1000 times
for
(
var
i
=
0
;
i
<
1000
;
i
++
){
await
avPlayer
.
prepare
().
then
(()
=>
{
expect
(
avPlayer
.
state
).
assertEqual
(
AV_PLAYER_STATE
.
PREPARED
);
expect
(
avPlayer
.
state
).
assertEqual
(
'
prepared
'
);
console
.
info
(
'
prepareToStopLoop avPlayer state is prepared
'
)
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
...
...
@@ -717,13 +717,13 @@ export async function prepareToResetLoop(src, avPlayer, done) {
await
avPlayer
.
play
().
then
(()
=>
{
console
.
info
(
'
prepareToResetLoop play success
'
);
expect
(
avPlayer
.
state
).
assertEqual
(
AV_PLAYER_STATE
.
PLAYING
);
expect
(
avPlayer
.
state
).
assertEqual
(
'
playing
'
);
},
(
err
)
=>
{
console
.
error
(
'
prepareToResetLoop play filed,error message is :
'
+
err
.
message
)
})
await
avPlayer
.
reset
().
then
(()
=>
{
expect
(
avPlayer
.
state
).
assertEqual
(
AV_PLAYER_STATE
.
IDLE
);
expect
(
avPlayer
.
state
).
assertEqual
(
'
idle
'
);
console
.
info
(
'
prepareToResetLoop avPlayer state is reset
'
)
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
...
...
@@ -1029,7 +1029,7 @@ export function playTimeCallback(avPlayer, done) {
break
;
case
AV_PLAYER_STATE
.
PAUSED
:
console
.
info
(
'
playTimeWithCallback play state is PAUSED
'
)
expect
(
avPlayer
.
state
).
assertEqual
(
AV_PLAYER_STATE
.
PAUSED
);
expect
(
avPlayer
.
state
).
assertEqual
(
'
paused
'
);
start
=
Date
.
now
();
console
.
info
(
`playTimeCallback start time is :
${
start
}
`
)
// step 3: pause -> playing loop
...
...
@@ -2118,12 +2118,12 @@ function setAVPlayerPlay(src, avPlayer, done) {
break
;
case
AV_PLAYER_STATE
.
COMPLETED
:
expect
(
avPlayer
.
currentTime
).
assertEqual
(
avPlayer
.
duration
);
expect
(
avPlayer
.
state
).
assertEqual
(
AV_PLAYER_STATE
.
COMPLETED
);
expect
(
avPlayer
.
state
).
assertEqual
(
'
completed
'
);
avPlayer
.
release
().
then
(()
=>
{
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
break
;
case
AV_PLAYER_STATE
.
RELEASED
:
expect
(
avPlayer
.
state
).
assertEqual
(
AV_PLAYER_STATE
.
RELEASED
);
expect
(
avPlayer
.
state
).
assertEqual
(
'
released
'
);
offCallback
(
avPlayer
,
[
'
stateChange
'
,
'
error
'
]);
avPlayer
=
null
;
done
();
...
...
multimedia/media/media_js_standard/AVRecorderTestBase.js
0 → 100644
浏览文件 @
757d3225
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
media
from
'
@ohos.multimedia.media
'
import
*
as
mediaTestBase
from
'
./MediaTestBase.js
'
;
export
async
function
idle
(
avRecorder
)
{
console
.
info
(
'
case createAVRecorder called
'
);
await
media
.
createAVRecorder
().
then
((
recorder
)
=>
{
if
(
recorder
!=
null
)
{
avRecorder
=
recorder
;
console
.
info
(
'
createAVRecorder success
'
);
}
else
{
console
.
info
(
'
createAVRecorder fail
'
);
}
}).
catch
((
error
)
=>
{
console
.
info
(
`createAVRecorder catchCallback, error:
${
error
}
`
);
});
return
avRecorder
;
}
export
const
AV_RECORDER_STATE
=
{
IDLE
:
'
idle
'
,
PREPARED
:
'
prepared
'
,
STARTED
:
'
started
'
,
PAUSED
:
'
paused
'
,
STOPPED
:
'
stopped
'
,
RELEASED
:
'
released
'
,
ERROR
:
'
error
'
,
}
export
function
prepareCallback
(
avRecorder
,
avConfig
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
prepare
(
avConfig
,
(
err
)
=>
{
console
.
info
(
'
case prepare called
'
+
err
);
if
(
err
==
null
)
{
console
.
info
(
'
prepare success
'
);
}
else
{
console
.
error
(
`case prepare error, errMessage is
${
err
.
message
}
`
);
}
})
}
export
function
preparePromise
(
avRecorder
,
avConfig
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
prepare
(
avConfig
).
then
(()
=>
{
console
.
info
(
'
prepare success
'
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
export
function
getInputSurfacePromise
(
avRecorder
)
{
let
surfaceID
=
null
;
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
getInputSurface
().
then
((
surfaceId
)
=>
{
console
.
info
(
'
getInputSurface success
'
);
surfaceID
=
surfaceId
;
}).
catch
((
err
)
=>
{
console
.
info
(
'
getInputSurface failed and catch error is
'
+
err
.
message
);
});
// videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID);
}
export
function
getInputSurfaceCallback
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
let
surfaceID
=
null
;
avRecorder
.
getInputSurface
((
err
,
surfaceId
)
=>
{
if
(
err
==
null
)
{
console
.
info
(
'
getInputSurface success
'
);
surfaceID
=
surfaceId
;
}
else
{
console
.
info
(
'
getInputSurface failed and error is
'
+
err
.
message
);
}
});
// videoOutput = await cameraManager.createVideoOutput(videoProfiles[0], surfaceID);
}
export
function
startCallback
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
start
((
err
)
=>
{
console
.
info
(
'
case start called
'
);
if
(
err
==
null
)
{
console
.
info
(
'
start AVRecorder success
'
);
}
else
{
console
.
info
(
'
start AVRecorder failed and error is
'
+
err
.
message
);
}
})
}
export
function
startPromise
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
start
().
then
(()
=>
{
console
.
info
(
'
start success
'
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
export
function
pauseCallback
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
pause
((
err
)
=>
{
console
.
info
(
'
case pause called
'
);
if
(
err
==
null
)
{
console
.
info
(
'
pause AVRecorder success
'
);
}
else
{
console
.
info
(
'
pause AVRecorder failed and error is
'
+
err
.
message
);
}
})
}
export
function
pausePromise
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
pause
().
then
(()
=>
{
console
.
info
(
'
pause success
'
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
export
function
resumeCallback
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
resume
((
err
)
=>
{
console
.
info
(
'
case resume called
'
);
if
(
err
==
null
)
{
console
.
info
(
'
resume AVRecorder success
'
);
}
else
{
console
.
info
(
'
resume AVRecorder failed and error is
'
+
err
.
message
);
}
})
}
export
function
resumePromise
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
resume
().
then
(()
=>
{
console
.
info
(
'
resume success
'
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
export
function
stopCallback
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
stop
((
err
)
=>
{
console
.
info
(
'
case stop called
'
);
if
(
err
==
null
)
{
console
.
info
(
'
stop AVRecorder success
'
);
}
else
{
console
.
info
(
'
stop AVRecorder failed and error is
'
+
err
.
message
);
}
})
}
export
function
stopPromise
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
stop
().
then
(()
=>
{
console
.
info
(
'
stop success
'
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
export
function
resetCallback
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
reset
((
err
)
=>
{
console
.
info
(
'
case reset called
'
);
if
(
err
==
null
)
{
console
.
info
(
'
reset AVRecorder success
'
);
}
else
{
console
.
info
(
'
reset AVRecorder failed and error is
'
+
err
.
message
);
}
})
}
export
function
resetPromise
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
reset
().
then
(()
=>
{
console
.
info
(
'
reset success
'
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
export
function
releaseCallback
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
release
((
err
)
=>
{
console
.
info
(
'
case release called
'
);
if
(
err
==
null
)
{
console
.
info
(
'
release AVRecorder success
'
);
}
else
{
console
.
info
(
'
release AVRecorder failed and error is
'
+
err
.
message
);
}
})
}
export
function
releasePromise
(
avRecorder
)
{
if
(
typeof
(
avRecorder
)
==
'
undefined
'
)
{
return
;
}
avRecorder
.
release
().
then
(()
=>
{
console
.
info
(
'
release success
'
);
},
mediaTestBase
.
failureCallback
).
catch
(
mediaTestBase
.
catchCallback
);
}
export
function
sleep
(
ms
)
{
return
new
Promise
(
resolve
=>
setTimeout
(
resolve
,
ms
));
}
export
function
offCallback
(
avRecorder
,
typeArr
)
{
if
(
avRecorder
==
null
)
{
return
;
}
for
(
let
i
=
0
;
i
<
typeArr
.
length
;
i
++
)
{
switch
(
typeArr
[
i
])
{
case
'
stateChange
'
:
avRecorder
.
off
(
'
stateChange
'
);
break
;
case
'
error
'
:
avRecorder
.
off
(
'
error
'
);
break
;
default
:
break
;
}
}
}
export
async
function
setOnCallback
(
avConfig
,
avRecorder
,
recorderTime
,
done
)
{
console
.
info
(
`case setOnCallback in`
);
avRecorder
.
on
(
'
stateChange
'
,
async
(
state
,
reason
)
=>
{
console
.
info
(
'
case state has changed, new state is :
'
+
state
);
switch
(
state
)
{
case
AV_RECORDER_STATE
.
IDLE
:
console
.
info
(
`case avRecorderWithCallBack is idle`
);
expect
(
avRecorder
.
state
).
assertEqual
(
"
idle
"
);
//start->stop->release
prepareCallback
(
avRecorder
,
avConfig
);
break
;
case
AV_RECORDER_STATE
.
PREPARED
:
console
.
info
(
`case avRecorderWithCallBack is prepared`
);
expect
(
avRecorder
.
state
).
assertEqual
(
'
prepared
'
);
startCallback
(
avRecorder
);
break
;
case
AV_RECORDER_STATE
.
STARTED
:
console
.
info
(
`case avRecorderWithCallBack is started`
)
expect
(
avRecorder
.
state
).
assertEqual
(
'
started
'
);
await
sleep
(
recorderTime
);
stopCallback
(
avRecorder
);
break
;
case
AV_RECORDER_STATE
.
PAUSED
:
console
.
info
(
`case avRecorderWithCallBackis paused`
)
expect
(
avRecorder
.
state
).
assertEqual
(
'
paused
'
);
break
;
case
AV_RECORDER_STATE
.
STOPPED
:
console
.
info
(
`case avRecorderWithCallBack is stopped`
)
expect
(
avRecorder
.
state
).
assertEqual
(
'
stopped
'
);
avRecorder
.
release
()
break
;
case
AV_RECORDER_STATE
.
RELEASED
:
console
.
info
(
`case avRecorderWithCallBack is released`
);
expect
(
avRecorder
.
state
).
assertEqual
(
'
released
'
);
done
();
break
;
case
AV_RECORDER_STATE
.
ERROR
:
console
.
info
(
`case avRecorderWithCallBack is error`
)
expect
(
avRecorder
.
state
).
assertEqual
(
'
error
'
);
break
;
default
:
console
.
info
(
'
case state is unknown
'
);
}
});
avRecorder
.
on
(
'
error
'
,
(
err
)
=>
{
console
.
info
(
'
case avRecorder.on(error) called, errMessage is
'
+
err
.
message
);
});
}
export
async
function
setPrepareOnCallback
(
avConfig
,
avRecorder
,
recorderTime
,
done
)
{
console
.
info
(
`case setOnCallback in`
);
avRecorder
.
on
(
'
stateChange
'
,
async
(
state
,
reason
)
=>
{
console
.
info
(
'
case state has changed, new state is :
'
+
state
);
switch
(
state
)
{
case
AV_RECORDER_STATE
.
PREPARED
:
console
.
info
(
`case AV_RECORDER_STATE.PREPARED`
);
expect
(
avRecorder
.
state
).
assertEqual
(
'
prepared
'
);
releaseCallback
(
avRecorder
);
break
;
case
AV_RECORDER_STATE
.
RELEASED
:
console
.
info
(
`case avRecorderReliabilitTest03 is released`
);
expect
(
avRecorder
.
state
).
assertEqual
(
'
released
'
);
done
();
break
;
case
AV_RECORDER_STATE
.
ERROR
:
console
.
info
(
`case AV_RECORDER_STATE.ERROR`
)
expect
(
avRecorder
.
state
).
assertEqual
(
'
error
'
);
break
;
default
:
console
.
info
(
'
case state is unknown
'
);
}
});
}
export
async
function
avRecorderWithCallBack
(
avConfig
,
avRecorder
,
recorderTime
,
done
)
{
avRecorder
=
await
idle
(
avRecorder
)
setOnCallback
(
avConfig
,
avRecorder
,
recorderTime
,
done
);
await
avRecorder
.
prepare
(
avConfig
)
}
export
async
function
avRecorderReliabilitTest01
(
avConfig
,
avRecorder
,
recorderTime
,
done
)
{
let
result
=
true
;
avRecorder
=
await
idle
(
avRecorder
);
console
.
info
(
'
case avConfig.url is
'
+
avConfig
.
url
);
await
avRecorder
.
pause
().
then
(()
=>
{
console
.
info
(
'
pause AVRecorder success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
pause AVRecorder failed and catch error is
'
+
err
.
message
);
result
=
false
});
expect
(
result
).
assertEqual
(
false
);
await
avRecorder
.
prepare
(
avConfig
).
then
(()
=>
{
expect
(
avRecorder
.
state
).
assertEqual
(
AV_RECORDER_STATE
.
PREPARED
);
console
.
info
(
'
prepare success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
prepare failed and catch error is
'
+
err
.
message
);
});
await
avRecorder
.
release
().
then
(()
=>
{
console
.
info
(
'
release AVRecorder success
'
);
expect
(
avRecorder
.
state
).
assertEqual
(
AV_RECORDER_STATE
.
RELEASED
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
'
release AVRecorder failed and catch error is
'
+
err
.
message
);
});
}
export
async
function
avRecorderReliabilitTest02
(
avConfig
,
avRecorder
,
recorderTime
,
done
)
{
avRecorder
=
await
idle
(
avRecorder
);
await
avRecorder
.
prepare
(
avConfig
).
then
(()
=>
{
expect
(
avRecorder
.
state
).
assertEqual
(
AV_RECORDER_STATE
.
PREPARED
);
console
.
info
(
'
avRecorderReliabilitTest02 prepare success
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
'
avRecorderReliabilitTest02 prepare failed and catch error is
'
+
err
.
message
);
});
await
avRecorder
.
release
().
then
(()
=>
{
console
.
info
(
'
avRecorderReliabilitTest02 release AVRecorder success
'
);
expect
(
avRecorder
.
state
).
assertEqual
(
AV_RECORDER_STATE
.
RELEASED
);
done
();
}).
catch
((
err
)
=>
{
console
.
info
(
'
avRecorderReliabilitTest02 release AVRecorder failed and catch error is
'
+
err
.
message
);
});
}
export
async
function
avRecorderReliabilitTest03
(
avConfig
,
avRecorder
,
recorderTime
,
done
)
{
avRecorder
=
await
idle
(
avRecorder
);
setPrepareOnCallback
(
avConfig
,
avRecorder
,
recorderTime
,
done
)
await
avRecorder
.
prepare
(
avConfig
)
}
multimedia/media/media_js_standard/avRecorder/src/main/js/test/AVRecorderFuncTest.test.js
浏览文件 @
757d3225
此差异已折叠。
点击以展开。
multimedia/media/media_js_standard/avRecorder/src/main/js/test/List.test.js
浏览文件 @
757d3225
/*
* Copyright (c) 2022
Huawei Device
Co., Ltd.
/*
*
* Copyright (c) 2022
Shenzhen Kaihong Digital Industry Development
Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
...
...
@@ -12,9 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
AVRecorderFuncTest
from
'
./AVRecorderFuncTest.test.js
'
import
avRecorderTest
from
'
./AVRecorderFuncTest.test.js
'
export
default
function
testsuite
(
recorderContxt
)
{
AVRecorderFuncTest
(
recorderContxt
)
export
default
function
testsuite
()
{
avRecorderTest
()
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录