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

!7615 媒体兼容性新增压稳测试用例

Merge pull request !7615 from Nicklaus/master
......@@ -386,6 +386,150 @@ export function setAVPlayerFunCb(src, avPlayer, playTest, playTime, done) {
});
}
export function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function setAVPlayerPlayAndPauseWithCallBack(src, avPlayer, playTest, playTime, done) {
let playPauseCount = 0;
let surfaceID = globalThis.value;
console.info(`case setAVPlayerPlayAndPauseWithCallBack in, surfaceID is ${surfaceID}`);
avPlayer.on('stateChange', async (state, reason) => {
console.info(`case stateChange called, state is ${state}, reason is ${reason}`);
console.info(`case state is ${state}`);
switch (state) {
case AV_PLAYER_STATE.INITIALIZED:
avPlayer.surfaceId = surfaceID;
console.info('playPauseLoopWithCallBack play state is INITIALIZED')
// step 1: initialized -> prepared -> play
toPreparePromise(avPlayer, playTest);
await sleep(2000);
avPlayer.play()
break;
case AV_PLAYER_STATE.PLAYING:
avPlayer.loop = true;
console.info('playPauseLoopWithCallBack play state is PLAYING')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING);
playPauseCount++;
await mediaTestBase.msleepAsync(playTime);
if(playPauseCount == 1001){
// step 4: playing -> stop -> release
avPlayer.stop().then(() => {
console.info('playPauseLoopWithCallBack avPlayer from play to stop')
avPlayer.release().then(() => {
console.info('playPauseLoopWithCallBack avPlayer from stop to release')
offCallback(avPlayer, ['stateChange', 'error']);
done();
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}else{
// step 2: playing -> pause loop
avPlayer.pause().then(() => {
console.info('playPauseLoopWithCallBack avPlayer from play to pause,time is :' + playPauseCount)
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
break;
case AV_PLAYER_STATE.PAUSED:
console.info('playPauseLoopWithCallBack play state is PAUSED')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED);
// step 3: pause -> playing loop
avPlayer.play().then(() => {
console.info('playPauseLoopWithCallBack avPlayer from pause to play,time is :' + playPauseCount)
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
break;
case AV_PLAYER_STATE.ERROR:
expect().assertFail();
avPlayer.release().then(() => {
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
break;
default:
break;
}
});
avPlayer.on('error', async (err) => {
console.error(`case error called, errMessage is ${err.message}`);
expect().assertFail();
await avPlayer.release().then(() => {
avPlayer = null;
done();
});
});
}
export async function avPlayerWithCallBack(src, avPlayer, playTest, playTime, done) {
console.info(`case media source: ${src}`)
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);
setAVPlayerPlayAndPauseWithCallBack(src, avPlayer, playTest, playTime, done);
setSource(avPlayer, src);
}
async function playToPauseLoop(avPlayer){
await avPlayer.play().then(() => {
console.info('playToPauseLoop play success');
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PLAYING);
}, (err) => {
console.error('playToPauseLoop play filed,error message is :' + err.message)
})
if(avPlayer.state == AV_PLAYER_STATE.PLAYING){
avPlayer.loop = true;
await mediaTestBase.msleepAsync(2);
console.info('playToPauseLoop avPlayer from play to pause')
}
await avPlayer.pause().then(() => {
console.info('playToPauseLoop pause success');
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.PAUSED);
}, (err) => {
console.error('playToPauseLoop pause filed,error message is :' + err.message)
})
}
export async function avPlayerWithoutCallBack(src, avPlayer, playTest, done) {
let surfaceID = globalThis.value;
console.info(`case avPlayerWithoutCallBack in, surfaceID is ${surfaceID}`);
console.info(`case media source: ${src}`)
await media.createAVPlayer().then((video) => {
if (typeof(video) != 'undefined') {
console.info('case createAVPlayer success');
avPlayer = video;
} else {
console.error('case createAVPlayer failed');
expect().assertFail();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
setSource(avPlayer, src);
console.info('avPlayerWithoutCallBack setSource');
avPlayer.surfaceId = surfaceID;
if(avPlayer.state == AV_PLAYER_STATE.INITIALIZED) {
toPreparePromise(avPlayer, playTest);
await sleep(2000);
}
if(avPlayer.state == AV_PLAYER_STATE.PREPARED){
console.info('avPlayerWithoutCallBack avPlayer from PREPARED to play')
// play to pause loop 1000 times
for(var i = 0;i < 1000; i++){
await playToPauseLoop(avPlayer)
console.info(`case avPlayerWithoutCallBack playToPauseLoop is ${i}`);
}
}
await avPlayer.stop().then(() => {
console.info('avPlayerWithoutCallBack avPlayer from play to stop')
avPlayer.release().then(() => {
console.info('avPlayerWithoutCallBack avPlayer from stop to release')
expect(avPlayer.state).assertEqual(AV_PLAYER_STATE.RELEASED);
done();
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
export async function testAVPlayerFun(src, avPlayer, playTest, playTime, done) {
console.info(`case media source: ${src}`)
await media.createAVPlayer().then((video) => {
......
......@@ -5,8 +5,8 @@
"test-timeout": "180000",
"bundle-name": "ohos.acts.multimedia.avplayer",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
"shell-timeout": "1000000",
"testcase-timeout": 300000
},
"kits": [
{
......
/**
* 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';
import * as AVPlayerTestBase from '../../../../../../AVPlayerTestBase.js';
import { testAVPlayerFun, AV_PLAYER_STATE, setSource, avPlayerWithCallBack, avPlayerWithoutCallBack,
sleep } from '../../../../../../AVPlayerTestBase.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function AVPlayerStabilityTest() {
describe('AVPlayerStabilityTest', function () {
const VIDEO_SOURCE = 'H264_AAC.mp4';
const AUDIO_SOURCE = '01.mp3';
const VIDEO_NOAUDIO = 'H264_NONE.mp4'
let TAG = "[AVPlayerStabilityTest] ";
let callBackSet = 0;
const PLAY_TIME = 2;
let avPlayer = null;
let fileDescriptor = null;
let fileDescriptor2 = null;
let fileDescriptor3 = null;
let avPlayTest1 = {
width: 0,
height: 0,
duration: -1,
};
let avPlayTest2 = {
width: 0,
height: 0,
duration: -1,
};
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');
await sleep(3000);
})
afterEach(async function() {
if (avPlayer != null) {
avPlayer.release().then(() => {
console.info(TAG + 'this testCase execution completed')
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
console.info('afterEach case');
await sleep(3000);
})
afterAll(async function() {
console.info('afterAll case');
await mediaTestBase.closeFileDescriptor(VIDEO_SOURCE);
await mediaTestBase.closeFileDescriptor(AUDIO_SOURCE);
await mediaTestBase.closeFileDescriptor(VIDEO_NOAUDIO);
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0100
* @tc.name : 001.test play pause loop 1000 (waiting for callback)
* @tc.desc : Local Video play to pause 1000 times (waiting for callback)
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0100', 0, async function (done) {
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0100 start')
avPlayTest1 = { width: 720, height: 480, duration: 10034 };
avPlayerWithCallBack(fileDescriptor, avPlayer, avPlayTest1, PLAY_TIME, done);
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0100 end')
})
/* *
* @tc.number : SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0200
* @tc.name : 001.test play pause loop 1000 (do not wait for callback)
* @tc.desc : Local Video play to pause 1000 times (do not wait for callback)
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0200', 0, async function (done) {
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0200 start')
avPlayTest2 = { width: 720, height: 480, duration: 10034 };
avPlayerWithoutCallBack(fileDescriptor, avPlayer, avPlayTest2, done);
console.info(TAG + 'SUB_MULTIMEDIA_MEDIA_AVPLAYER_STABILITY_0200 end')
})
})
}
\ No newline at end of file
......@@ -16,10 +16,12 @@ 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'
export default function testsuite() {
// AVPlayerHlsFuncTest()
// AVPlayerHttpCompatibilityTest();
// AVPlayerHttpSeekTest();
AVPlayerLocalTest();
AVPlayerStabilityTest();
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册