未验证 提交 c6758f83 编写于 作者: O openharmony_ci 提交者: Gitee

!8311 输出录制文件名使用时间戳生成 避免用例多次执行时报错(该文件已存在)

Merge pull request !8311 from Nicklaus/master
......@@ -16,17 +16,24 @@
import media from '@ohos.multimedia.media'
import * as mediaTestBase from './MediaTestBase.js';
async function idleCallBack(avRecorder) {
console.info('case createAVRecorder called');
await media.createAVRecorder((error, recorder) => {
export function resourceName(){
let timestamp = Date.now();
let filename = `avRecorder_${timestamp}.m4a`;
return filename;
}
export async function idleCallback(avRecorder, avConfig, done) {
console.info('case idleCallback called');
media.createAVRecorder((error, recorder) => {
if (recorder != null) {
avRecorder = recorder;
console.info('createAVRecorder success');
console.info('createAVRecorder idleCallback success');
avRecorder.prepare(avConfig)
releaseDone(avRecorder, done)
} else {
console.info(`createAVRecorder fail, error:${error}`);
console.info(`createAVRecorder idleCallback fail, error:${error}`);
}
});
return avRecorder;
}
export async function idle(avRecorder) {
......@@ -1378,6 +1385,10 @@ export async function avRecorderReliabilitTest03(avConfig, avRecorder, recorderT
await avRecorder.prepare(avConfig)
}
export async function avRecorderReliabilitTest001(avConfig, avRecorder, recorderTime, done) {
idleCallback(avRecorder, avConfig, done)
}
export async function avRecorderReliabilitTest04(avConfig, avRecorder, recorderTime, done) {
let result = true;
avRecorder = await idle(avRecorder);
......@@ -2260,25 +2271,28 @@ export async function createTimeTestCallback(avConfig, avRecorder, recorderTime,
for(var i = 0;i < 10;i++){
let start = Date.now();
console.info(`createTimeTestCallback start time is : ${start}`)
avRecorder = await idleCallBack(avRecorder);
avRecorder = await idle(avRecorder);
let end = Date.now()
let execution = parseInt(end - start)
console.info("createTimeTestCallback execution time is :" + execution)
totalTime = totalTime + execution;
await avRecorder.release().then(() => {
console.info('createTimeTestCallback avPlayer is release')
console.info(`createTimeTestCallback avRecorder.state is : ${avRecorder.state}`)
expect(avRecorder.state).assertEqual(AV_RECORDER_STATE.RELEASED);
if(i == 9){
let avg = totalTime/10;
console.info("createTimeTest avg time is :" + avg)
done();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
let avg = totalTime/10;
console.info("createTimeTest avg time is :" + avg)
done();
}
export async function prepareTimeCallback(avConfig, avRecorder, recorderTime, done) {
let totalTime = 0;
for(var i = 0;i < 10;i++){
avRecorder = await idleCallBack(avRecorder);
avRecorder = await idle(avRecorder);
await sleep(20)
let start = Date.now();
console.info(`prepareTimeWithoutCallback start time is : ${start}`)
......@@ -2310,7 +2324,7 @@ export async function getInputSurfaceTimeTestCallback(avConfig, avRecorder, reco
let totalTime = 0;
let surfaceID = null;
for(var i = 0;i < 10;i++){
avRecorder = await idleCallBack(avRecorder);
avRecorder = await idle(avRecorder);
await sleep(20)
let end;
await avRecorder.prepare(avConfig).then(() => {
......@@ -2346,7 +2360,7 @@ export async function getInputSurfaceTimeTestCallback(avConfig, avRecorder, reco
export async function startTimeTestCallback(avConfig, avRecorder, recorderTime, done) {
let totalTime = 0;
for(var i = 0;i < 10;i++){
avRecorder = await idleCallBack(avRecorder);
avRecorder = await idle(avRecorder);
await sleep(20)
let end;
await avRecorder.prepare(avConfig).then(() => {
......@@ -2380,7 +2394,7 @@ export async function startTimeTestCallback(avConfig, avRecorder, recorderTime,
export async function pauseTimeTestCallback(avConfig, avRecorder, recorderTime, done) {
let totalTime = 0;
for(var i = 0;i < 10;i++){
avRecorder = await idleCallBack(avRecorder);
avRecorder = await idle(avRecorder);
await sleep(20)
await avRecorder.prepare(avConfig).then(() => {
expect(avRecorder.state).assertEqual(AV_RECORDER_STATE.PREPARED);
......@@ -2420,7 +2434,7 @@ export async function pauseTimeTestCallback(avConfig, avRecorder, recorderTime,
export async function resumeTimeTestCallback(avConfig, avRecorder, recorderTime, done) {
let totalTime = 0;
for(var i = 0;i < 10;i++){
avRecorder = await idleCallBack(avRecorder);
avRecorder = await idle(avRecorder);
await sleep(20)
await avRecorder.prepare(avConfig).then(() => {
expect(avRecorder.state).assertEqual(AV_RECORDER_STATE.PREPARED);
......@@ -2467,7 +2481,7 @@ export async function resumeTimeTestCallback(avConfig, avRecorder, recorderTime,
export async function stopTimeTestCallback(avConfig, avRecorder, recorderTime, done) {
let totalTime = 0;
for(var i = 0;i < 10;i++){
avRecorder = await idleCallBack(avRecorder);
avRecorder = await idle(avRecorder);
await sleep(20)
await avRecorder.prepare(avConfig).then(() => {
expect(avRecorder.state).assertEqual(AV_RECORDER_STATE.PREPARED);
......@@ -2507,7 +2521,7 @@ export async function stopTimeTestCallback(avConfig, avRecorder, recorderTime, d
export async function resetTimeTestCallback(avConfig, avRecorder, recorderTime, done) {
let totalTime = 0;
for(var i = 0;i < 10;i++){
avRecorder = await idleCallBack(avRecorder);
avRecorder = await idle(avRecorder);
await sleep(20)
await avRecorder.prepare(avConfig).then(() => {
expect(avRecorder.state).assertEqual(AV_RECORDER_STATE.PREPARED);
......@@ -2547,7 +2561,7 @@ export async function resetTimeTestCallback(avConfig, avRecorder, recorderTime,
export async function releaseTimeTestCallback(avConfig, avRecorder, recorderTime, done) {
let totalTime = 0;
for(var i = 0;i < 10;i++){
avRecorder = await idleCallBack(avRecorder);
avRecorder = await idle(avRecorder);
await sleep(20)
await avRecorder.prepare(avConfig).then(() => {
expect(avRecorder.state).assertEqual(AV_RECORDER_STATE.PREPARED);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册