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

!2289 修改视频播放多实例用例逻辑

Merge pull request !2289 from FULIZHONG/OpenHarmony-3.1-Release
......@@ -32,7 +32,7 @@ describe('RecorderLocalTestAudioAPI', function () {
const SOURCE_TYPE = 1;
const ENCORDER_AACLC = 3;
const CHANNEL_TWO = 2;
const RECORDER_TIME = 1000;
const RECORDER_TIME = 3000;
let fdPath;
let fileAsset;
let fdNumber;
......
......@@ -31,7 +31,7 @@ describe('RecorderLocalTestAudioFUNC', function () {
const RESET_STATE = 6;
const RELEASE_STATE = 7;
const ERROR_STATE = 8;
const RECORDER_TIME = 1000;
const RECORDER_TIME = 3000;
const CHANNEL_ONE = 1;
const CHANNEL_TWO = 2;
const FORMAT_MP4 = 2;
......
......@@ -127,31 +127,96 @@ describe('VideoPlayerFuncPromiseTest', function () {
/* *
* @tc.number : SUB_MEDIA_PLAYER_MULTIPLE_0100
* @tc.name : 001.Multi-instance (16 promise)
* @tc.name : 001.Multi-instance (2 videoPlayer promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MEDIA_PLAYER_MULTIPLE_0100', 0, async function (done) {
let arr = new Array();
for (let i = 0; i < 14; i++) {
await getFd();
setTimeout(async function() {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
let testVideoPlayer1 = null;
let testVideoPlayer2 = null;
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
arr[i] = video
console.info('case createVideoPlayer success ' + i);
testVideoPlayer1 = video
console.info('case createVideoPlayer success ');
} else {
console.info('case createVideoPlayer is failed');
expect().assertFail();
}
}, failureCallback).catch(catchCallback);
}
for (let j = 0; j < 14;j++) {
await arr[j].release().then(() => {
console.info('case release success ' + j);
}, failureCallback).catch(catchCallback);
}
done();
testVideoPlayer1.url = fdPath;
await testVideoPlayer1.setDisplaySurface(surfaceID).then(() => {
console.info('case setDisplaySurface success');
expect(testVideoPlayer1.state).assertEqual('idle');
}, failureCallback).catch(catchCallback);
await testVideoPlayer1.prepare().then(() => {
console.info('case prepare called!!');
expect(testVideoPlayer1.state).assertEqual('prepared');
expect(testVideoPlayer1.duration).assertEqual(DURATION_TIME);
expect(testVideoPlayer1.width).assertEqual(WIDTH_VALUE);
expect(testVideoPlayer1.height).assertEqual(HEIGHT_VALUE);
}, failureCallback).catch(catchCallback);
let startTime = testVideoPlayer1.currentTime;
await testVideoPlayer1.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(testVideoPlayer1.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = testVideoPlayer1.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await testVideoPlayer1.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
testVideoPlayer1 = null;
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
testVideoPlayer2 = video
console.info('case createVideoPlayer success ');
} else {
console.info('case createVideoPlayer is failed');
expect().assertFail();
}
}, failureCallback).catch(catchCallback);
testVideoPlayer2.url = fdPath;
await testVideoPlayer2.setDisplaySurface(surfaceID).then(() => {
console.info('case setDisplaySurface success');
expect(testVideoPlayer2.state).assertEqual('idle');
}, failureCallback).catch(catchCallback);
await testVideoPlayer2.prepare().then(() => {
console.info('case prepare called!!');
expect(testVideoPlayer2.state).assertEqual('prepared');
expect(testVideoPlayer2.duration).assertEqual(DURATION_TIME);
expect(testVideoPlayer2.width).assertEqual(WIDTH_VALUE);
expect(testVideoPlayer2.height).assertEqual(HEIGHT_VALUE);
}, failureCallback).catch(catchCallback);
startTime = testVideoPlayer2.currentTime;
await testVideoPlayer2.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(testVideoPlayer2.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
endTime = testVideoPlayer2.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await testVideoPlayer2.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
testVideoPlayer2 = null;
done();
}, 1000);
})
/* *
......@@ -163,7 +228,6 @@ describe('VideoPlayerFuncPromiseTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0100', 0, async function (done) {
await getFd();
setTimeout(async function() {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
......
......@@ -44,6 +44,8 @@ describe('VideoRecorderAPICallbackTest', function () {
let videoOutput;
let surfaceID;
let fdPath;
let fileAsset;
let fdNumber;
let events = require('events');
let eventEmitter = new events.EventEmitter();
......@@ -130,8 +132,8 @@ describe('VideoRecorderAPICallbackTest', function () {
selectionArgs : [args],
}
let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
let fileAsset = await fetchFileResult.getAllObject();
let fdNumber = await fileAsset[0].open('Rw');
fileAsset = await fetchFileResult.getAllObject();
fdNumber = await fileAsset[0].open('Rw');
fdPath = "fd://" + fdNumber.toString();
}
}
......
......@@ -25,6 +25,8 @@ describe('VideoRecorderFuncPromiseTest', function () {
let cameras;
let captureSession;
let fdPath;
let fileAsset;
let fdNumber;
let configFile = {
audioBitrate : 48000,
audioChannels : 2,
......@@ -164,8 +166,8 @@ describe('VideoRecorderFuncPromiseTest', function () {
selectionArgs : [args],
}
let fetchFileResult = await mediaTest.getFileAssets(fetchOp);
let fileAsset = await fetchFileResult.getAllObject();
let fdNumber = await fileAsset[0].open('Rw');
fileAsset = await fetchFileResult.getAllObject();
fdNumber = await fileAsset[0].open('Rw');
fdPath = "fd://" + fdNumber.toString();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册