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

!8096 【媒体子系统】新增覆盖

Merge pull request !8096 from 秦莉文/OpenHarmony-3.2-Release
/**
* 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)
}
......@@ -20,7 +20,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import fileio from '@ohos.fileio'
import featureAbility from '@ohos.ability.featureAbility'
import { UiDriver, BY, PointerMatrix } from '@ohos.UiTest'
const CODECMIMEVALUE = ['video/avc', 'audio/mp4a-latm', 'audio/mpeg']
const CODECMIMEVALUE = ['video/x-h264', 'audio/mpeg', 'video/avc', 'audio/mp4a-latm']
const context = featureAbility.getContext();
export async function getPermission(permissionNames) {
......
......@@ -157,7 +157,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
console.info('case getTrackDescription called!!');
if (typeof (arrayList) != 'undefined') {
for (let i = 0; i < arrayList.length; i++) {
mediaTestBase.checkDescription(arrayList[i], descriptionKey[i], descriptionValue[i]);
mediaTestBase.checkOldDescription(arrayList[i], descriptionKey[i], descriptionValue[i]);
}
} else {
console.info('case getTrackDescription is failed');
......@@ -171,7 +171,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
audioPlayer.getTrackDescription((err, arrayList) => {
if (typeof (err) == 'undefined') {
for (let i = 0; i < arrayList.length; i++) {
mediaTestBase.checkDescription(arrayList[i], descriptionKey[i], descriptionValue[i]);
mediaTestBase.checkOldDescription(arrayList[i], descriptionKey[i], descriptionValue[i]);
}
nextStep(mySteps, done);
} else {
......
......@@ -474,7 +474,7 @@ export default function AVPlayerLocalTest() {
it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_GETTRECKDESCRIPTION_0200', 0, async function (done) {
let audioTrackKey = new Array('channel_count', 'codec_mime', 'sample_rate', 'track_index',
'track_type');
let audioTrackValue = new Array(1, 2, 48000, 0, 0);
let audioTrackValue = new Array(1, 1, 48000, 0, 0);
let descriptionKey = new Array(audioTrackKey);
let descriptionValue = new Array(audioTrackValue);
testCheckTrackDescription(fileDescriptor2, avPlayer, descriptionKey, descriptionValue, done)
......
......@@ -81,7 +81,7 @@ export default function AVPlayerStabilityTest() {
beforeAll(async function () {
console.info('beforeAll case');
for(var i = 0;i < VIDEO_SOURCES.length; i++){
for (var i = 0; i < VIDEO_SOURCES.length; i++) {
await getStageFdRead(VIDEO_SOURCES[i]).then((testNumber) => {
fdNumber = testNumber;
console.info(TAG + 'this fdNumber is :' + fdNumber)
......@@ -107,12 +107,12 @@ export default function AVPlayerStabilityTest() {
}
beforeEach(async function() {
beforeEach(async function () {
console.info('beforeEach case');
await AVPlayerTestBase.sleep(1000);
})
afterEach(async function() {
afterEach(async function () {
if (avPlayer != null) {
avPlayer.release().then(() => {
console.info(TAG + 'this testCase execution completed')
......@@ -122,9 +122,9 @@ export default function AVPlayerStabilityTest() {
await AVPlayerTestBase.sleep(1000);
})
afterAll(async function() {
afterAll(async function () {
console.info('afterAll case');
for(var i = 0;i < fdNumbers.length; i++){
for (var i = 0; i < fdNumbers.length; i++) {
await mediaTestBase.closeFdNumber(fdNumbers[i]);
}
})
......@@ -223,7 +223,7 @@ export default function AVPlayerStabilityTest() {
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0500', 0, async function (done) {
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0500 start')
AVPlayerTestBase.avPlayerPlay(videos[4], avPlayer,done);
AVPlayerTestBase.avPlayerPlay(videos[4], avPlayer, done);
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_MP4_0500 end')
})
......@@ -761,19 +761,7 @@ export default function AVPlayerStabilityTest() {
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300
* @tc.name : 001.test play source 4k
* @tc.desc : Local Video play source
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300', 0, async function (done) {
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300 start')
AVPlayerTestBase.avPlayerPlay(videos[43], avPlayer, done);
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_01_0100
......@@ -895,11 +883,11 @@ export default function AVPlayerStabilityTest() {
* @tc.type : Function test
* @tc.level : Level3
*/
// it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0100', 0, async function (done) {
// console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0100 start')
// AVPlayerTestBase.createTimeWithCallback(videos[0], avPlayer, done);
// console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0100 end')
// })
// it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0100', 0, async function (done) {
// console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0100 start')
// AVPlayerTestBase.createTimeWithCallback(videos[0], avPlayer, done);
// console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0100 end')
// })
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_01_0110
......@@ -1237,5 +1225,19 @@ export default function AVPlayerStabilityTest() {
AVPlayerTestBase.firstFrameTime(videos[0], avPlayer, done);
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_PERFORMANCE_02_0100 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300
* @tc.name : 001.test play source 4k
* @tc.desc : Local Video play source
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300', 0, async function (done) {
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300 start')
AVPlayerTestBase.avPlayerPlay(videos[43], avPlayer, done);
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_FORMAT_SOURCE_0300 end')
})
})
}
\ No newline at end of file
......@@ -19,6 +19,7 @@ import AVPlayerLocalTest from './AVPlayerLocalTest.test.js'
import AVPlayerStabilityTest from './AVPlayerStabilityTest.test.js'
import AvPlayerEnumTest from './AvPlayerEnumTest.test.js'
export default function testsuite() {
// AVPlayerHlsFuncTest()
// AVPlayerHttpCompatibilityTest();
......
/*
* 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
......@@ -243,7 +243,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
videoPlayer.getTrackDescription((err, arrlist) => {
if (err == null) {
for (let i = 0; i < arrlist.length; i++) {
mediaTestBase.checkDescription(arrlist[i], descriptionKey[i], descriptionValue[i]);
mediaTestBase.checkOldDescription(arrlist[i], descriptionKey[i], descriptionValue[i]);
}
toNextStep(videoPlayer, steps, done);
} else if ((err != null) && (steps[0] == ERROR_EVENT)) {
......
......@@ -509,7 +509,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
for (let i = 0; i < arrayDescription.length; i++) {
mediaTestBase.checkDescription(arrayDescription[i], descriptionKey[i], descriptionValue[i]);
mediaTestBase.checkOldDescription(arrayDescription[i], descriptionKey[i], descriptionValue[i]);
}
await videoPlayer.release().then(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册