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

!9028 avplayer新增音轨音效用例

Merge pull request !9028 from 董新丽/master
/*
* Copyright (C) 2023 Huawei Device 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 * as mediaTestBase from '../../../../../../MediaTestBase.js';
import media from '@ohos.multimedia.media'
import audio from '@ohos.multimedia.audio';
import { testAVPlayerFun, AV_PLAYER_STATE, setSource } from '../../../../../../AVPlayerTestBase.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
export default function AVPlayerAudioEffectModeTest() {
describe('AVPlayerAudioEffectModeTest', function () {
const VIDEO_SOURCE = 'H264_AAC.mp4';
const AUDIO_SOURCE = '01.mp3';
const VIDEO_NOAUDIO = 'H264_NONE.mp4'
const PLAY_TIME = 3000;
const WAIT_TIME = 500;
const APIBASELINE = 500;
const EFFECT_NONE = audio.AudioEffectMode.EFFECT_NONE;
const EFFECT_DEFAULT = audio.AudioEffectMode.EFFECT_DEFAULT;
let fileDescriptor = null;
let fileDescriptor2 = null;
let fileDescriptor3 = null;
let avPlayer = null;
beforeAll(async function() {
console.info('beforeAll case');
await mediaTestBase.getStageFileDescriptor(VIDEO_SOURCE).then((res) => {
fileDescriptor = res;
});
await mediaTestBase.getStageFileDescriptor(AUDIO_SOURCE).then((res) => {
fileDescriptor2 = res;
});
await mediaTestBase.getStageFileDescriptor(VIDEO_NOAUDIO).then((res) => {
fileDescriptor3 = res;
});
})
beforeEach(async function() {
console.info('beforeEach case');
})
afterEach(async function() {
if (avPlayer != null) {
avPlayer.release().then(() => {
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
console.info('afterEach case');
})
afterAll(async function() {
console.info('afterAll case');
await mediaTestBase.closeFileDescriptor(VIDEO_SOURCE);
await mediaTestBase.closeFileDescriptor(AUDIO_SOURCE);
await mediaTestBase.closeFileDescriptor(VIDEO_NOAUDIO);
})
function testReliability(avPlayer, invalidlist) {
for (let i = 0; i < invalidlist.length; i++) {
avPlayer.audioEffectMode = invalidlist[i];
}
}
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_AUDIOEFFECTMODE_FUNCTION_0100
* @tc.name : 001.test audioEffectMode - base function
* @tc.desc : Local Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_AUDIOEFFECTMODE_FUNCTION_0100', 0, async function (done) {
let audioEffectMode = [EFFECT_DEFAULT, EFFECT_NONE];
let i = 1;
let playCount = 1;
let resetConfig = 1;
await media.createAVPlayer().then((video) => {
if (typeof(video) != 'undefined') {
avPlayer = video;
} else {
expect().assertFail();
done();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
avPlayer.on('stateChange', async (state, reason) => {
switch (state) {
case AV_PLAYER_STATE.IDLE:
console.info(`case avPlayer.audioEffectMode is: ` + avPlayer.audioEffectMode);
if (resetConfig == 2) {
setSource(avPlayer, fileDescriptor2);
} else if (resetConfig == 3){
setSource(avPlayer, fileDescriptor3);
} else {
setSource(avPlayer, fileDescriptor);
}
break;
case AV_PLAYER_STATE.INITIALIZED:
console.info(`case avPlayer.audioEffectMode is: ` + avPlayer.audioEffectMode);
avPlayer.surfaceId = globalThis.value;
if (resetConfig == 3) {
let audioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_RINGTONE ,
usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE,
rendererFlags: 0,
}
avPlayer.audioRendererInfo = audioRendererInfo;
}
avPlayer.prepare();
break;
case AV_PLAYER_STATE.PREPARED:
console.info(`case avPlayer.audioEffectMode is: ` + avPlayer.audioEffectMode);
if (resetConfig == 2) {
expect(avPlayer.audioEffectMode).assertEqual(audioEffectMode[i%2]);
} else if (resetConfig == 3) {
expect(avPlayer.audioEffectMode).assertEqual(audioEffectMode[0]);
avPlayer.audioEffectMode = audioEffectMode[i%2];
} else {
expect(avPlayer.audioEffectMode).assertEqual(audioEffectMode[0]);
avPlayer.audioEffectMode = audioEffectMode[(i++)%2];
}
avPlayer.play();
break;
case AV_PLAYER_STATE.PLAYING:
console.info(`case avPlayer.audioEffectMode is: ` + avPlayer.audioEffectMode);
if (playCount == 1) {
avPlayer.audioEffectMode = audioEffectMode[i%2];
await mediaTestBase.msleepAsync(PLAY_TIME);
avPlayer.pause();
} else if (playCount == 2) {
expect(avPlayer.audioEffectMode).assertEqual(audioEffectMode[(i++)%2]);
avPlayer.audioEffectMode = audioEffectMode[i%2];
avPlayer.seek(avPlayer.duration);
await mediaTestBase.msleepAsync(WAIT_TIME);
} else {
expect(avPlayer.audioEffectMode).assertEqual(audioEffectMode[i%2]);
await mediaTestBase.msleepAsync(PLAY_TIME);
if (resetConfig == 2) {
resetConfig++;
avPlayer.reset();
} else {
avPlayer.release();
}
}
playCount += 1;
break;
case AV_PLAYER_STATE.PAUSED:
console.info(`case avPlayer.audioEffectMode is: ` + avPlayer.audioEffectMode);
expect(avPlayer.audioEffectMode).assertEqual(audioEffectMode[(i++)%2]);
avPlayer.audioEffectMode = audioEffectMode[i%2];
await mediaTestBase.msleepAsync(WAIT_TIME);
avPlayer.play();
break;
case AV_PLAYER_STATE.COMPLETED:
console.info(`case avPlayer.audioEffectMode is: ` + avPlayer.audioEffectMode);
expect(avPlayer.audioEffectMode).assertEqual(audioEffectMode[(i++)%2]);
avPlayer.audioEffectMode = audioEffectMode[i%2];
resetConfig++;
avPlayer.reset();
break;
case AV_PLAYER_STATE.RELEASED:
avPlayer = null;
done();
break;
default:
break;
}
})
avPlayer.on('error', (err) => {
console.error(`error occurred, message is ${err.message}`);
expect().assertFail();
avPlayer.release();
})
setSource(avPlayer, fileDescriptor);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_AUDIOEFFECTMODE_RELIABILITY_0100
* @tc.name : 002.test audioEffectMode - set nonconforming value
* @tc.desc : Local Video playback control test
* @tc.size : MediumTest
* @tc.type : Reliability test
* @tc.level : Level1
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_AUDIOEFFECTMODE_RELIABILITY_0100', 0, async function (done) {
let playCount = 1;
let expecterror = false;
let invalidlist = [-1, 1000000, '', 'aaa', undefined];
let steps = new Array('play', 'pause', 'play', 'release');
let errCnt = 0;
await media.createAVPlayer().then((video) => {
if (typeof(video) != 'undefined') {
avPlayer = video;
} else {
expect().assertFail();
done();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
avPlayer.on('stateChange', async (state, reason) => {
console.info('case current state is: ' + state);
switch (state) {
case AV_PLAYER_STATE.INITIALIZED:
avPlayer.surfaceId = globalThis.value;
avPlayer.prepare();
break;
case AV_PLAYER_STATE.PREPARED:
expecterror = true;
testReliability(avPlayer, invalidlist);
break;
case AV_PLAYER_STATE.PLAYING:
if (playCount++ == 1) {
expecterror = true;
testReliability(avPlayer, invalidlist);
} else if (playCount == 2) {
avPlayer.seek(avPlayer.duration);
await mediaTestBase.msleepAsync(WAIT_TIME);
}
break;
case AV_PLAYER_STATE.PAUSED:
expecterror = true;
testReliability(avPlayer, invalidlist);
break;
case AV_PLAYER_STATE.COMPLETED:
expecterror = true;
testReliability(avPlayer, invalidlist);
break;
case AV_PLAYER_STATE.RELEASED:
avPlayer = null;
done();
break;
default:
break;
}
})
avPlayer.on('error', (err) => {
errCnt += 1;
console.error(`error occurred, message is ${err.message}, errCnt is ${errCnt}`);
expect(expecterror).assertEqual(true);
if (errCnt == invalidlist.length) {
errCnt = 0;
expecterror = false;
switch(steps[0]) {
case 'play':
avPlayer.play();
break;
case 'pause':
avPlayer.pause();
break;
case 'release':
avPlayer.release();
break;
default:
break;
}
steps.shift();
}
})
setSource(avPlayer, fileDescriptor);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_AUDIOEFFECTMODE_RELIABILITY_0200
* @tc.name : 003.test audioEffectMode - set value in abnormal state
* @tc.desc : Local Video playback control test
* @tc.size : MediumTest
* @tc.type : Reliability test
* @tc.level : Level1
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_AUDIOEFFECTMODE_RELIABILITY_0200', 0, async function (done) {
let expecterror = false;
let audioEffectMode = [EFFECT_DEFAULT, EFFECT_NONE];
let steps = new Array('prepare', 'reset', 'release');
let errCnt = 0;
await media.createAVPlayer().then((video) => {
if (typeof(video) != 'undefined') {
avPlayer = video;
} else {
expect().assertFail();
done();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
avPlayer.on('stateChange', async (state, reason) => {
switch (state) {
case AV_PLAYER_STATE.IDLE:
expecterror = true;
avPlayer.audioEffectMode = audioEffectMode[1];
break;
case AV_PLAYER_STATE.INITIALIZED:
avPlayer.surfaceId = globalThis.value;
expecterror = true;
avPlayer.audioEffectMode = audioEffectMode[1];
break;
case AV_PLAYER_STATE.PREPARED:
avPlayer.play();
break;
case AV_PLAYER_STATE.PLAYING:
avPlayer.stop();
break;
case AV_PLAYER_STATE.STOPPED:
expecterror = true;
avPlayer.audioEffectMode = audioEffectMode[1];
break;
case AV_PLAYER_STATE.RELEASED:
avPlayer = null;
done();
break;
default:
break;
}
})
avPlayer.on('error', (err) => {
console.error(`error occurred, message is ${err.message}, errCnt is ${errCnt}`);
expect(expecterror).assertEqual(true);
expecterror = false;
switch(steps[0]) {
case 'prepare':
avPlayer.prepare();
break;
case 'reset':
avPlayer.reset();
break;
case 'release':
avPlayer.release();
break;
default:
break;
}
steps.shift();
})
setSource(avPlayer, fileDescriptor);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_AUDIOEFFECTMODE_STABILITY_0100
* @tc.name : 004.test audioEffectMode - multiple calls
* @tc.desc : Local Video playback control test
* @tc.size : MediumTest
* @tc.type : Stability test
* @tc.level : Level1
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_AUDIOEFFECTMODE_STABILITY_0100', 0, async function (done) {
let audioEffectMode = [EFFECT_DEFAULT, EFFECT_NONE];
let playCount = 1;
await media.createAVPlayer().then((video) => {
if (typeof(video) != 'undefined') {
avPlayer = video;
} else {
expect().assertFail();
done();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
avPlayer.on('stateChange', async (state, reason) => {
switch (state) {
case AV_PLAYER_STATE.INITIALIZED:
avPlayer.surfaceId = globalThis.value;
let audioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_RINGTONE ,
usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE,
rendererFlags: 0,
}
avPlayer.audioRendererInfo = audioRendererInfo;
avPlayer.prepare();
break;
case AV_PLAYER_STATE.PREPARED:
for (let i = 0; i < 1000; i++) {
avPlayer.audioEffectMode = audioEffectMode[Math.floor((Math.random()*audioEffectMode.length))];
}
avPlayer.play();
break;
case AV_PLAYER_STATE.PLAYING:
if (playCount++ == 1) {
for (let i = 0; i < 1000; i++) {
avPlayer.audioEffectMode = audioEffectMode[Math.floor((Math.random()*audioEffectMode.length))];
}
avPlayer.pause();
} else if (playCount == 2) {
avPlayer.seek(avPlayer.duration);
await mediaTestBase.msleepAsync(WAIT_TIME);
}
break;
case AV_PLAYER_STATE.PAUSED:
for (let i = 0; i < 1000; i++) {
avPlayer.audioEffectMode = audioEffectMode[Math.floor((Math.random()*audioEffectMode.length))];
}
avPlayer.play();
break;
case AV_PLAYER_STATE.COMPLETED:
for (let i = 0; i < 1000; i++) {
avPlayer.audioEffectMode = audioEffectMode[Math.floor((Math.random()*audioEffectMode.length))];
}
avPlayer.release();
break;
case AV_PLAYER_STATE.RELEASED:
avPlayer = null;
done();
break;
default:
break;
}
})
avPlayer.on('error', (err) => {
console.error(`error occurred, message is ${err.message}`);
expect().assertFail();
avPlayer.release();
})
setSource(avPlayer, fileDescriptor);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_AUDIOEFFECTMODE_APITIME_0100
* @tc.name : 005.test audioEffectMode api time
* @tc.desc : test audioEffectMode api time
* @tc.size : MediumTest
* @tc.type : performance test
* @tc.level : Level3
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_AUDIOEFFECTMODE_APITIME_0100', 0, async function (done) {
let audioEffectMode = [EFFECT_DEFAULT, EFFECT_NONE];
await media.createAVPlayer().then((video) => {
if (typeof(video) != 'undefined') {
avPlayer = video;
} else {
expect().assertFail();
done();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
avPlayer.on('stateChange', async (state, reason) => {
switch (state) {
case AV_PLAYER_STATE.INITIALIZED:
avPlayer.surfaceId = globalThis.value;
avPlayer.prepare();
break;
case AV_PLAYER_STATE.PREPARED:
let startTime = new Date().getTime();
console.info('case audioEffectMode startTime is : ' + startTime);
for (let i = 0; i < 1000; i++) {
avPlayer.audioEffectMode = audioEffectMode[Math.floor((Math.random()*audioEffectMode.length))];
}
let endTime = new Date().getTime();
console.info('case audioEffectMode endTime is : ' + endTime);
let audioEffectMode_averageTime = ((endTime - startTime) * 1000) / 1000;
console.info('case audioEffectMode_averageTime is : ' + audioEffectMode_averageTime + 'us');
expect(audioEffectMode_averageTime < APIBASELINE).assertTrue();
avPlayer.play();
break;
case AV_PLAYER_STATE.PLAYING:
await mediaTestBase.msleepAsync(PLAY_TIME);
avPlayer.release();
break;
case AV_PLAYER_STATE.RELEASED:
avPlayer = null;
done();
break;
default:
break;
}
})
avPlayer.on('error', (err) => {
console.error(`error occurred, message is ${err.message}`);
expect().assertFail();
avPlayer.release();
})
setSource(avPlayer, fileDescriptor);
})
})
}
/*
* Copyright (C) 2023 Huawei Device 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 * as mediaTestBase from '../../../../../../MediaTestBase.js';
import media from '@ohos.multimedia.media'
import { AV_PLAYER_STATE, setSource } from '../../../../../../AVPlayerTestBase.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
export default function AVPlayerMultiTrackTest() {
describe('AVPlayerMultiTrackTest', function () {
const VIDEO_SOURCE = 'mpeg4_1920_1080_aac_flac.mkv';
const VIDEO_NOAUDIO = 'H264_NONE.mp4';
const PLAY_TIME = 3000;
const LOOPCNT = 5;
const NOAUDIOTRACK = -1;
let avFd;
let audioFd;
let videoFd;
let avPlayer;
let audioTrackList = new Array();
let selectedTrack;
let currentTrack;
let defaultTrack;
let surfaceID = globalThis.value;
let changeRepeatly = false;
beforeAll(async function() {
console.info('beforeAll case');
await mediaTestBase.getStageFileDescriptor(VIDEO_SOURCE).then((res) => {
avFd = res;
});
await mediaTestBase.getStageFileDescriptor(VIDEO_NOAUDIO).then((res) => {
videoFd = res;
});
})
beforeEach(async function() {
console.info('beforeEach case');
audioTrackList = new Array();
selectedTrack = undefined;
changeRepeatly = false;
})
afterEach(async function() {
if (avPlayer != null) {
await avPlayer.release().then(() => {
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
console.info('afterEach case');
})
afterAll(async function() {
console.info('afterAll case');
await mediaTestBase.closeFileDescriptor(VIDEO_SOURCE);
await mediaTestBase.closeFileDescriptor(VIDEO_NOAUDIO);
})
function printFailureCallback(error) {
console.info(`case failureCallback promise called,errMessage is ${error.message}`);
}
function printCatchCallback(error) {
console.info(`case error catch called,errMessage is ${error.message}`);
}
async function getAudioTracks() {
console.info('case to getTrackDescription');
await avPlayer.getTrackDescription().then((arrayList) => {
console.info('case getTrackDescription called!!');
if (typeof (arrayList) != 'undefined') {
console.info('case arrayList.length is ' + arrayList.length);
for (let i = 0; i < arrayList.length; i++) {
console.info('case language_code is ' + arrayList[i]['language_code']);
if (arrayList[i]['track_type'] == 0) {
audioTrackList.push(arrayList[i]['track_index']);
}
}
} else {
console.info('case getTrackDescription is failed');
expect().assertFail();
}
})
console.info('case audioTrackList is: ' + audioTrackList);
await avPlayer.getCurrentTrack(0).then((index) => {
console.info(`case default audio track index is ${index}`);
defaultTrack = index;
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
async function getCurrentAudioTrack() {
await avPlayer.getCurrentTrack(0).then((index) => {
console.info(`case current audio track index is ${index}`);
currentTrack = index;
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
async function changeAudioTrack() {
for(let i = 0; i < audioTrackList.length; i++) {
if (audioTrackList[i] != currentTrack) {
selectedTrack = audioTrackList[i];
console.info('case new audio track is:' + selectedTrack);
break;
} else {
continue;
}
}
}
async function resetAndCallbackOff() {
console.info('case now stopped, to reset');
await avPlayer.reset().then(() => {
console.info('case reset AVPlayer success');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
avPlayer.off('stateChange');
avPlayer.off('trackChange');
avPlayer.off('error');
avPlayer.off('endOfStream');
console.info('case now stopped, to release');
await avPlayer.release().then(() => {
console.info('case release AVPlayer success');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
async function testChangeTrack(fd, preparedOp, playedOp, stoppedOp, extraOp) {
await media.createAVPlayer().then((video) => {
if (typeof(video) != 'undefined') {
console.info('case createAVPlayer success');
avPlayer = video;
} else {
console.error('case createAVPlayer failed');
expect().assertFail();
done();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
avPlayer.on('stateChange', async (state, reason) => {
console.info(`case stateChange called, state is ${state}, reason is ${reason}`);
switch (state) {
case AV_PLAYER_STATE.INITIALIZED:
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.INITIALIZED);
if (fd != audioFd) {
console.info('case is videosrc');
avPlayer.surfaceId = surfaceID;
console.info(`case avPlayer.surfaceId is ${avPlayer.surfaceId}`);
} else {
console.info('case is audiosrc');
}
await avPlayer.prepare().then(() => {
console.info('case prepare called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
break;
case AV_PLAYER_STATE.PREPARED:
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PREPARED);
expect(avPlayer.currentTime).assertEqual(0);
await preparedOp();
if (!changeRepeatly) {
console.info('case to play AVPlayer');
await avPlayer.play().then(() => {
console.info('case play AVPlayer success');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
break;
case AV_PLAYER_STATE.PLAYING:
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING);
await playedOp();
await mediaTestBase.msleepAsync(PLAY_TIME);
if (!avPlayer.loop) {
await avPlayer.stop().then(() => {
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
break;
case AV_PLAYER_STATE.STOPPED:
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.STOPPED);
await stoppedOp();
break;
case AV_PLAYER_STATE.ERROR:
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.ERROR);
expect().assertFail();
avPlayer.release().then(() => {
console.info('case release AVPlayer success');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
break;
default:
break;
}
});
avPlayer.on('trackChange', async (index, isSelection) => {
console.info(`case trackChange called, index is ${index}, isSelection is ${isSelection}`);
if (changeRepeatly) {
extraOp();
}
});
avPlayer.on('error', async (err) => {
console.error(`case error called, errMessage is ${err.message}`);
});
avPlayer.on('endOfStream', async () => {
extraOp();
});
setSource(avPlayer, fd);
}
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_FUNC_0100
* @tc.name : 001.test change default audio track
* @tc.desc : test change default audio track
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_FUNC_0100', 0, async function (done) {
async function preparedOperation() {
await getAudioTracks();
await getCurrentAudioTrack();
await changeAudioTrack();
avPlayer.selectTrack(selectedTrack);
expect(currentTrack!=selectedTrack).assertTrue();
}
async function playedOperation() {
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(selectedTrack);
}
async function stoppedOperation() {
await resetAndCallbackOff();
done();
}
await testChangeTrack(avFd, preparedOperation, playedOperation, stoppedOperation, undefined);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_FUNC_0200
* @tc.name : 002.test deselect default audio track
* @tc.desc : test deselect default audio track
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_FUNC_0200', 0, async function (done) {
async function preparedOperation() {
await getAudioTracks();
await getCurrentAudioTrack();
avPlayer.deselectTrack(currentTrack);
}
async function playedOperation() {
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(defaultTrack);
}
async function stoppedOperation() {
await resetAndCallbackOff();
done();
}
await testChangeTrack(avFd, preparedOperation, playedOperation, stoppedOperation, undefined);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_FUNC_0300
* @tc.name : 003.test select and deselect audio track
* @tc.desc : test select and deselect audio track
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_FUNC_0300', 0, async function (done) {
async function preparedOperation() {
await getAudioTracks();
await getCurrentAudioTrack();
avPlayer.selectTrack(currentTrack);
avPlayer.deselectTrack(currentTrack);
await changeAudioTrack();
avPlayer.selectTrack(selectedTrack);
avPlayer.deselectTrack(selectedTrack);
}
async function playedOperation() {
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(defaultTrack);
}
async function stoppedOperation() {
await resetAndCallbackOff();
done();
}
await testChangeTrack(avFd, preparedOperation, playedOperation, stoppedOperation, undefined);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_FUNC_0500
* @tc.name : 005.test change audio track repeatly
* @tc.desc : test change audio track repeatly
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_FUNC_0500', 0, async function (done) {
changeRepeatly = true;
let changeCnt = 0;
async function preparedOperation() {
await getAudioTracks();
await getCurrentAudioTrack();
await changeAudioTrack();
avPlayer.selectTrack(selectedTrack);
}
async function playedOperation() {
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(selectedTrack);
}
async function stoppedOperation() {
await resetAndCallbackOff();
done();
}
async function extraOperation() {
if (changeCnt < LOOPCNT) {
changeCnt += 1;
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(selectedTrack);
await changeAudioTrack();
avPlayer.selectTrack(selectedTrack);
} else {
console.info('case to play AVPlayer');
await avPlayer.play().then(() => {
console.info('case play AVPlayer success');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
}
await testChangeTrack(avFd, preparedOperation, playedOperation, stoppedOperation, extraOperation);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_FUNC_0600
* @tc.name : 006.test change audio track after re-prepared
* @tc.desc : test change audio track after re-prepared
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_FUNC_0600', 0, async function (done) {
let prepareCnt = 0;
async function preparedOperation() {
prepareCnt += 1;
console.info(`case prepareCnt is ${prepareCnt}`);
if (prepareCnt == 1) {
await getAudioTracks();
await getCurrentAudioTrack();
} if (prepareCnt == 2) {
await getCurrentAudioTrack();
} else {
await getCurrentAudioTrack();
await changeAudioTrack();
avPlayer.selectTrack(selectedTrack);
console.info('case selectedTrack is: ' + selectedTrack);
}
}
async function playedOperation() {
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(selectedTrack);
}
async function stoppedOperation() {
if (prepareCnt <= 2) {
console.info('case now stopped, to prepare');
await avPlayer.prepare().then(() => {
console.info('case prepare avPlayer success');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
} else {
await resetAndCallbackOff();
done();
}
}
await testChangeTrack(avFd, preparedOperation, playedOperation, stoppedOperation, undefined);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_0700
* @tc.name : 007.test selectTrack、seek and setSpeed
* @tc.desc : Local multi-audioTrack video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_0700', 0, async function (done) {
let eosCnt = 0;
async function preparedOperation() {
await getAudioTracks();
await getCurrentAudioTrack();
await changeAudioTrack();
avPlayer.selectTrack(selectedTrack);
console.info('case selectedTrack is: ' + selectedTrack);
avPlayer.seek(avPlayer.duration / 3);
avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_0_75_X);
avPlayer.deselectTrack(selectedTrack);
await getCurrentAudioTrack();
await changeAudioTrack();
avPlayer.selectTrack(selectedTrack);
console.info('case selectedTrack is: ' + selectedTrack);
avPlayer.loop = true;
}
async function playedOperation() {
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(selectedTrack);
await mediaTestBase.msleepAsync(2000);
avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X);
avPlayer.seek(0);
}
async function stoppedOperation() {
await resetAndCallbackOff();
done();
}
async function extraOperation() {
eosCnt += 1;
console.info(`case endOfStream called, eosCnt is ${eosCnt}`);
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(selectedTrack);
avPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_25_X);
avPlayer.seek(avPlayer.duration * 2 / 3);
if (eosCnt == LOOPCNT) {
avPlayer.loop = false;
await avPlayer.stop().then(() => {
console.info('case stop avplayer success');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
}
await testChangeTrack(avFd, preparedOperation, playedOperation, stoppedOperation, extraOperation);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_ABNORMAL_INPUT_0100
* @tc.name : 008.test selectTrack/deselectTrack/getCurrentTrack invalid input
* @tc.desc : test change audio track after re-prepared
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_MEDIA_VIDEO_PLAYER_MULTI_AUDIOTRACK_ABNORMAL_INPUT_0100', 0, async function (done) {
const NOAUDIOTRACK = -1;
let un = undefined;
let typeInvalid = [-1, 2, 1000000, '', 'aaa', un];
async function preparedOperation() {
await getAudioTracks();
await avPlayer.getCurrentTrack(0).then((index) => {
console.info(`case current audio track index is ${index}`);
}, printFailureCallback).catch(printCatchCallback);
for (let type in typeInvalid) {
console.info(`case current invalid track type in is ${typeInvalid[type]}`);
await avPlayer.getCurrentTrack(typeInvalid[type]).then((index) => {
console.info(`case current audio track index is ${index}`);
}, printFailureCallback).catch(printCatchCallback);
}
let trackInvalid = [-1, 0, 1000000, '', 'aaa', un];
for (let track in trackInvalid) {
console.info(`case current invalid track in is ${trackInvalid[track]}`);
avPlayer.selectTrack(trackInvalid[track]);
await mediaTestBase.msleepAsync(1000);
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(NOAUDIOTRACK);
}
for (let track in trackInvalid) {
console.info(`case current invalid track in 2 is ${trackInvalid[track]}`);
avPlayer.deselectTrack(trackInvalid[track]);
await mediaTestBase.msleepAsync(1000);
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(NOAUDIOTRACK);
}
await changeAudioTrack();
avPlayer.selectTrack(selectedTrack);
avPlayer.deselectTrack(NOAUDIOTRACK);
}
async function playedOperation() {
await getCurrentAudioTrack();
expect(currentTrack).assertEqual(NOAUDIOTRACK);
}
async function stoppedOperation() {
await resetAndCallbackOff();
done();
}
await testChangeTrack(videoFd, preparedOperation, playedOperation, stoppedOperation, undefined);
})
})
}
......@@ -101,6 +101,19 @@ export default function AvPlayerEnumTest() {
expect(media.AudioSourceType.AUDIO_SOURCE_TYPE_DEFAULT).assertEqual(0);
done();
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_ENUM_0500
* @tc.name : AVPlayer
* @tc.desc : AVPlayer Enumeration test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_ENUM_0500', 0, async function (done) {
expect(media.MediaDescriptionKey.MD_KEY_LANGUAGE).assertEqual("language");
done();
})
})
}
......@@ -12,12 +12,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AVPlayerAudioEffectModeTest from './AVPlayerAudioEffectModeTest.test.js'
import AVPlayerHlsFuncTest from './AVPlayerHlsFuncTest.test.js'
import AVPlayerHttpCompatibilityTest from './AVPlayerHttpCompatibilityTest.test.ets'
import AVPlayerHttpSeekTest from './AVPlayerHttpSeekTest.test.ets'
import AVPlayerLocalTest from './AVPlayerLocalTest.test.js'
import AVPlayerStabilityTest from './AVPlayerStabilityTest.test.js'
import AvPlayerEnumTest from './AvPlayerEnumTest.test.js'
import AVPlayerMultiTrackTest from './AVPlayerMultiTrackTest.test.js'
export default function testsuite() {
......@@ -26,5 +28,7 @@ export default function testsuite() {
// AVPlayerHttpSeekTest();
AvPlayerEnumTest();
AVPlayerLocalTest();
AVPlayerAudioEffectModeTest();
AVPlayerMultiTrackTest();
// AVPlayerStabilityTest();
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册