提交 f07a0129 编写于 作者: N NOBUGGERS

新增HLS用例 Signed-off-by: NOBUGGERS <ruanmeng@huawei.com>

Signed-off-by: NNOBUGGERS <ruanmeng@huawei.com>
上级 b4a2a52f
......@@ -164,3 +164,147 @@ export async function playVideoSource(url, width, height, duration, playTime, do
console.info('case release called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
export async function testVideoSeek(url, duration, playTime, done) {
console.info(`case media source url: ${url}`)
let videoPlayer = null;
let surfaceID = globalThis.value;
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
console.info('case createVideoPlayer success');
videoPlayer = video;
} else {
console.error('case createVideoPlayer failed');
expect().assertFail();
done();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.on('videoSizeChanged', (w, h) => {
console.info('case videoSizeChanged width: ' + w + ' height: ' + h);
});
videoPlayer.on('error', (err) => {
console.error(`case error called, errMessage is ${err.message}`);
expect().assertFail();
videoPlayer.release();
done();
});
videoPlayer.url = url;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.prepare().then(() => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.play().then(() => {
console.info('case play called');
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
// pause when seeking
videoPlayer.seek(videoPlayer.duration / 3).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
expect(videoPlayer.duration).assertClose(duration, 500);
await videoPlayer.pause().then(() => {
console.info('case pause called');
expect(videoPlayer.state).assertEqual('paused');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
// play when seeking
videoPlayer.seek(0).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.play().then(() => {
console.info('case play called');
expect(videoPlayer.state).assertEqual('playing');
mediaTestBase.msleep(playTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
// setVolume when setSpeeding
videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X).then((speedMode) => {
console.info('case setSpeed called and speedMode is ' + speedMode);
expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_2_00_X);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
expect(videoPlayer.duration).assertClose(duration, 500);
await videoPlayer.setVolume(0.5).then(() => {
console.info('case setVolume called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
// setSpeed when seeking
videoPlayer.seek(0, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_00_X).then((speedMode) => {
console.info('case setSpeed called and speedMode is ' + speedMode);
expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_1_00_X);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
// seek when pausing
videoPlayer.pause().then(() => {
console.info('case pause called');
expect(videoPlayer.state).assertEqual('paused');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.seek(0, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
// seek when playing
videoPlayer.play().then(() => {
console.info('case pause called');
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.seek(videoPlayer.duration / 3, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
// seek when seeking
videoPlayer.seek(videoPlayer.duration / 3, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.seek(0, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
// stop when seeking
videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.stop().then(() => {
console.info('case stop called');
expect(videoPlayer.state).assertEqual('stopped');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.reset().then(() => {
console.info('case reset called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.url = url;
await videoPlayer.prepare().then(() => {
console.info('case prepare called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.play().then(() => {
console.info('case play called');
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
// reset when seeking
videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
console.info('case seek called and seekDoneTime is ' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.reset().then(() => {
console.info('case reset called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.url = url;
await videoPlayer.prepare().then(() => {
console.info('case prepare called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.play().then(() => {
console.info('case play called');
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
// release when seeking
videoPlayer.seek(videoPlayer.duration, media.SeekMode.SEEK_PREV_SYNC);
await videoPlayer.release().then(() => {
console.info('case release called');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
}
\ No newline at end of file
......@@ -307,39 +307,6 @@ describe('PlayerLocalTestAudioFUNC', function () {
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_SEEK
* @tc.name : 001.test seek mode 0 / 0.5 * duration/ duration
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_SEEK', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, SEEK_STATE,
DURATION_TIME / 2, SEEK_STATE, DURATION_TIME, FINISH_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_GETTRECKDESCRIPTION
* @tc.name : 001.test getTrackDescription
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_GETTRECKDESCRIPTION', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let mySteps = new Array(SRC_STATE, GETDESCRIPTION_PROMISE, GETDESCRIPTION_CALLBACK, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_LOOP
* @tc.name : 001.test loop
......
......@@ -15,4 +15,5 @@
require('./VideoPlayerHLSTest.test.js')
require('./AudioPlayerHLSTest.test.js')
require('./VideoPlayerHLSBitrateTest.test.js')
\ No newline at end of file
require('./VideoPlayerHLSBitrateTest.test.js')
require('./VideoPlayerHLSSeekTest.test.js')
\ No newline at end of file
/*
* Copyright (C) 2022 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 media from '@ohos.multimedia.media'
import {testVideoSeek} from '../../../../../VideoPlayerTestBase.js';
import * as mediaTestBase from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoPlayerHLSTest', function () {
const HTTP_PATH = 'http://123.57.24.33:8000/';
const PLAY_TIME = 3000;
const pagePath1 = 'pages/surfaceTest/surfaceTest';
const pagePath2 = 'pages/surfaceTest2/surfaceTest2';
let pageId = 0;
beforeAll(async function() {
console.info('beforeAll case');
})
beforeEach(async function() {
await mediaTestBase.toNewPage(pagePath1, pagePath2, pageId);
pageId = (pageId + 1) % 2;
await mediaTestBase.msleepAsync(1000).then(
() => {}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
console.info('beforeEach case');
})
afterEach(async function() {
await mediaTestBase.clearRouter();
console.info('afterEach case');
})
afterAll(async function() {
console.info('afterAll case');
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_HLS_SEEK
* @tc.name : 001.test hls
* @tc.desc : HLS Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('testHlsVideoPlayerSeek', 0, async function (done) {
await testVideoSeek(HTTP_PATH + '05.hls/1/index.m3u8', 10033, PLAY_TIME, done);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_HLS_SEEK_SEPARATE
* @tc.name : 001.test hls audio video separate
* @tc.desc : HLS Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('testHlsVideoPlayerSeekSeparate', 0, async function (done) {
await testVideoSeek(HTTP_PATH + '05.hls/2/index.m3u8', 10033, PLAY_TIME, done);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_HLS_SEEK_AUDIOONLY
* @tc.name : 001.test hls audio only
* @tc.desc : HLS Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('testHlsVideoPlayerSeekAudioOnly', 0, async function (done) {
await testVideoSeek(HTTP_PATH + '05.hls/audio_only/index.m3u8', 10033, PLAY_TIME, done);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_HLS_SEEK_VARIANT
* @tc.name : 001.test hls variant
* @tc.desc : HLS Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('testHlsVideoPlayerSeekVariant', 0, async function (done) {
await testVideoSeek(HTTP_PATH + '05.hls/hls_variant/index.m3u8', 10033, PLAY_TIME, done);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_HLS_SEEK_AUDIOOFF
* @tc.name : 001.test hls variant
* @tc.desc : HLS Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('testHlsVideoPlayerSeekVariantAudioOff', 0, async function (done) {
await testVideoSeek(HTTP_PATH + '05.hls/hls_variant2/index.m3u8', 10080, PLAY_TIME, done);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_HLS_SEEK_CODEC_CHAGNGE
* @tc.name : 001.test hls variant
* @tc.desc : HLS Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('testHlsVideoPlayerSeekCodecChange', 0, async function (done) {
await testVideoSeek(HTTP_PATH + '05.hls/hls_variant3/index.m3u8', 10080, PLAY_TIME, done);
done();
})
})
......@@ -13,5 +13,4 @@
* limitations under the License.
*/
require('./HttpPlayerCompatibilityTest.test.js')
require('./HttpPlayerFuncPromiseTest.test.js')
\ No newline at end of file
......@@ -1744,23 +1744,6 @@ describe('VideoPlayerAPICallbackTest', function () {
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_SEEK_CALLBACK_1100
* @tc.name : 11.seek 3 times
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level2
*/
it('SUB_MEDIA_VIDEO_PLAYER_SEEK_CALLBACK_1100', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT,
PREPARE_EVENT, PLAY_EVENT, SEEK_EVENT, SEEK_TIME, SEEK_EVENT, SEEK_TIME,
SEEK_EVENT, SEEK_TIME, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_SEEK_CALLBACK_1300
* @tc.name : 13.seek(-1)
......
......@@ -511,23 +511,6 @@ describe('VideoPlayerFuncCallbackTest', function () {
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SEEKMODE
* @tc.name : 001.test seek mode SEEK_PREV_SYNC/SEEK_NEXT_SYNC (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SEEKMODE', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT,
PREPARE_EVENT, PLAY_EVENT, SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC,
SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC,RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_CALLBACK
* @tc.name : 001.test callback bufferingUpdate/videoSizeChanged/startRenderFrame/playbackCompleted
......@@ -632,22 +615,6 @@ describe('VideoPlayerFuncCallbackTest', function () {
eventEmitter.emit('test_create');
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_GETTRECKDESCRIPTION
* @tc.name : 001.test getTrackDescription (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_GETTRECKDESCRIPTION', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT,
PREPARE_EVENT, GETDESCRIPTION, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_LOOP
* @tc.name : 001.test LOOP (callback)
......@@ -665,23 +632,4 @@ describe('VideoPlayerFuncCallbackTest', function () {
SEEK_EVENT, DURATION_TIME, WAIT_EVENT, SETLOOP_EVENT, false, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_BASE
* @tc.name : 001.test video playe (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_BASE', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let fdPath = fdHead + fileDescriptor.fd;
let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT,
PREPARE_EVENT, PLAY_EVENT, PAUSE_EVENT, PLAY_EVENT, STOP_EVENT, RESET_EVENT, SETSOURCE_EVENT, fdPath,
PREPARE_EVENT, SETLOOP_EVENT, true, PLAY_EVENT, SEEK_EVENT, DURATION_TIME / 2, SEEK_EVENT, 0,
SEEK_EVENT, DURATION_TIME, WAIT_EVENT, SETLOOP_EVENT, false, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
})
......@@ -269,92 +269,6 @@ describe('VideoPlayerFuncPromiseTest', function () {
console.info('case release called!!');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SeekMode
* @tc.name : 001.seek mode SEEK_PREV_SYNC/SEEK_NEXT_SYNC (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SeekMode', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
videoPlayer = video;
expect(videoPlayer.state).assertEqual('idle');
} else {
console.info('case createVideoPlayer is failed');
expect().assertFail();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.prepare().then(() => {
expect(videoPlayer.state).assertEqual('prepared');
expect(videoPlayer.duration).assertEqual(DURATION_TIME);
expect(videoPlayer.width).assertEqual(WIDTH_VALUE);
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
console.info('case prepare called!!');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
mediaTestBase.msleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_SEEK_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertClose(PREV_FRAME_TIME, DELTA_SEEK_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.seek(PREV_FRAME_TIME - 100, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime + DELTA_SEEK_TIME).assertClose(DELTA_SEEK_TIME, DELTA_SEEK_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.seek(PREV_FRAME_TIME + 100, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertClose(PREV_FRAME_TIME, DELTA_SEEK_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.seek(NEXT_FRAME_TIME - 100, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_SEEK_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.seek(NEXT_FRAME_TIME + 100, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertClose(NEXT_FRAME_TIME + 100, DELTA_SEEK_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
done();
})
/* *
......@@ -432,67 +346,6 @@ describe('VideoPlayerFuncPromiseTest', function () {
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_GetTreckDescription
* @tc.name : 001.getTrackDescription (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_GetTreckDescription', 0, async function (done) {
mediaTestBase.isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let arrayDescription = null;
let videoTrackKey = new Array('bitrate', 'codec_mime', 'frame_rate', 'height',
'track_index', 'track_type', 'width');
let audioTrackKey = new Array('bitrate', 'channel_count', 'codec_mime', 'sample_rate',
'track_index', 'track_type');
let videoTrackValue = new Array(1366541, 'video/x-h264', 6000, 480, 0, 1, 720);
let audioTrackValue = new Array(129207, 2, 'audio/mpeg', 44100, 1, 0);
let descriptionKey = new Array(videoTrackKey, audioTrackKey);
let descriptionValue = new Array(videoTrackValue, audioTrackValue);
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
videoPlayer = video;
expect(videoPlayer.state).assertEqual('idle');
} else {
console.info('case createVideoPlayer is failed');
expect().assertFail();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.prepare().then(() => {
expect(videoPlayer.state).assertEqual('prepared');
console.info('case prepare called!!');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
await videoPlayer.getTrackDescription().then((arrayList) => {
console.info('case getTrackDescription called!!');
if (typeof (arrayList) != 'undefined') {
arrayDescription = arrayList;
} else {
console.info('case getTrackDescription is failed');
expect().assertFail();
}
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
for (let i = 0; i < arrayDescription.length; i++) {
mediaTestBase.checkDescription(arrayDescription[i], descriptionKey[i], descriptionValue[i]);
}
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Loop
* @tc.name : 001.Loop true (promise)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册