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

!3027 整合videoPlayer测试用例

Merge pull request !3027 from FULIZHONG/0422videoPlayer
...@@ -46,6 +46,7 @@ describe('VideoPlayerAPICallbackTest', function () { ...@@ -46,6 +46,7 @@ describe('VideoPlayerAPICallbackTest', function () {
const SPEED_VALUE = 1; const SPEED_VALUE = 1;
const NEXT_FRAME_TIME = 8333; const NEXT_FRAME_TIME = 8333;
const PREV_FRAME_TIME = 4166; const PREV_FRAME_TIME = 4166;
const DELTA_TIME = 100;
let surfaceID = ''; let surfaceID = '';
let fileDescriptor = undefined; let fileDescriptor = undefined;
let page = 0; let page = 0;
...@@ -326,20 +327,20 @@ describe('VideoPlayerAPICallbackTest', function () { ...@@ -326,20 +327,20 @@ describe('VideoPlayerAPICallbackTest', function () {
switch (seekMode) { switch (seekMode) {
case media.SeekMode.SEEK_NEXT_SYNC: case media.SeekMode.SEEK_NEXT_SYNC:
if (seekTime == 0) { if (seekTime == 0) {
expect(seekDoneTime).assertEqual(0); expect(seekDoneTime + DELTA_TIME).assertClose(DELTA_TIME, DELTA_TIME);
} else if (seekTime == DURATION_TIME) { } else if (seekTime == DURATION_TIME) {
expect(seekDoneTime).assertEqual(DURATION_TIME); expect(seekDoneTime).assertClose(DURATION_TIME, DELTA_TIME);
} else { } else {
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME); expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_TIME);
} }
break; break;
case media.SeekMode.SEEK_PREV_SYNC: case media.SeekMode.SEEK_PREV_SYNC:
if (seekTime == 0) { if (seekTime == 0) {
expect(seekDoneTime).assertEqual(0); expect(seekDoneTime + DELTA_TIME).assertClose(DELTA_TIME, DELTA_TIME);
} else if (seekTime == DURATION_TIME) { } else if (seekTime == DURATION_TIME) {
expect(seekDoneTime).assertEqual(PREV_FRAME_TIME); expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_TIME);
} else { } else {
expect(seekDoneTime).assertEqual(PREV_FRAME_TIME); expect(seekDoneTime).assertClose(PREV_FRAME_TIME, DELTA_TIME);
} }
break; break;
default: default:
......
...@@ -28,6 +28,8 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -28,6 +28,8 @@ describe('VideoPlayerFuncCallbackTest', function () {
const CREATE_EVENT = 'create'; const CREATE_EVENT = 'create';
const SETSURFACE_EVENT = 'setDisplaySurface'; const SETSURFACE_EVENT = 'setDisplaySurface';
const GETDESCRIPTION = 'getTrackDescription'; const GETDESCRIPTION = 'getTrackDescription';
const SETSOURCE_EVENT = 'setSource';
const SETFDSOURCE_EVENT = 'setFdSource';
const PREPARE_EVENT = 'prepare'; const PREPARE_EVENT = 'prepare';
const SRC_PREPARE_EVENT = 'src2prepare'; const SRC_PREPARE_EVENT = 'src2prepare';
const PLAY_EVENT = 'play'; const PLAY_EVENT = 'play';
...@@ -39,13 +41,16 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -39,13 +41,16 @@ describe('VideoPlayerFuncCallbackTest', function () {
const SEEK_MODE_EVENT = 'seekMode'; const SEEK_MODE_EVENT = 'seekMode';
const SETVOLUME_EVENT = 'volume'; const SETVOLUME_EVENT = 'volume';
const SETSPEED_EVENT = 'speed'; const SETSPEED_EVENT = 'speed';
const SETLOOP_EVENT = 'loop';
const WAIT_EVENT = 'wait';
const ERROR_EVENT = 'error';
const END_EVENT = 'end'; const END_EVENT = 'end';
const VOLUME_VALUE = 1;
const SPEED_VALUE = 1;
const DELTA_TIME = 1000; const DELTA_TIME = 1000;
const NEXT_FRAME_TIME = 8333; const NEXT_FRAME_TIME = 8333;
const PREV_FRAME_TIME = 4166; const PREV_FRAME_TIME = 4166;
const DELTA_SEEK_TIME = 100;
let surfaceID = ''; let surfaceID = '';
let fdHead = 'fd://';
let fileDescriptor = undefined; let fileDescriptor = undefined;
let page = 0; let page = 0;
let events = require('events'); let events = require('events');
...@@ -119,7 +124,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -119,7 +124,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
eventEmitter.emit(steps[0], videoPlayer, steps, done); eventEmitter.emit(steps[0], videoPlayer, steps, done);
} }
} }
function setOnCallback(videoPlayer) { function setOnCallback(videoPlayer, steps, done) {
videoPlayer.on('playbackCompleted', () => { videoPlayer.on('playbackCompleted', () => {
console.info('case playbackCompleted success'); console.info('case playbackCompleted success');
}); });
...@@ -139,6 +144,10 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -139,6 +144,10 @@ describe('VideoPlayerFuncCallbackTest', function () {
videoPlayer.on('error', (error) => { videoPlayer.on('error', (error) => {
console.info(`case error called,errMessage is ${error.message}`); console.info(`case error called,errMessage is ${error.message}`);
if (steps[0] == ERROR_EVENT) {
steps.shift();
toNextStep(videoPlayer, steps, done);
}
}); });
} }
...@@ -147,24 +156,56 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -147,24 +156,56 @@ describe('VideoPlayerFuncCallbackTest', function () {
media.createVideoPlayer((err, video) => { media.createVideoPlayer((err, video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
videoPlayer = video; videoPlayer = video;
setOnCallback(videoPlayer); setOnCallback(videoPlayer, steps, done);
expect(videoPlayer.state).assertEqual('idle'); expect(videoPlayer.state).assertEqual('idle');
console.info('case createVideoPlayer success!!'); console.info('case createVideoPlayer success!!');
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
}); });
}); });
eventEmitter.on(SETFDSOURCE_EVENT, (videoPlayer, steps, done) => {
steps.shift();
videoPlayer.fdSrc = steps[0];
steps.shift();
toNextStep(videoPlayer, steps, done);
});
eventEmitter.on(SETSOURCE_EVENT, (videoPlayer, steps, done) => {
steps.shift();
videoPlayer.url = steps[0];
steps.shift();
toNextStep(videoPlayer, steps, done);
});
eventEmitter.on(SETLOOP_EVENT, (videoPlayer, steps, done) => {
steps.shift();
videoPlayer.loop = steps[0];
steps.shift();
toNextStep(videoPlayer, steps, done);
});
eventEmitter.on(WAIT_EVENT, (videoPlayer, steps, done) => {
steps.shift();
sleep(PLAY_TIME);
toNextStep(videoPlayer, steps, done);
});
eventEmitter.on(SETSURFACE_EVENT, (videoPlayer, steps, done) => { eventEmitter.on(SETSURFACE_EVENT, (videoPlayer, steps, done) => {
steps.shift(); steps.shift();
videoPlayer.fdSrc = fileDescriptor;
videoPlayer.setDisplaySurface(surfaceID, (err) => { videoPlayer.setDisplaySurface(surfaceID, (err) => {
if (typeof (err) == 'undefined') { if (typeof (err) == 'undefined') {
expect(videoPlayer.state).assertEqual('idle'); expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success!!'); console.info('case setDisplaySurface success!!');
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -181,6 +222,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -181,6 +222,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
console.info('case prepare success!!'); console.info('case prepare success!!');
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -189,7 +233,6 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -189,7 +233,6 @@ describe('VideoPlayerFuncCallbackTest', function () {
eventEmitter.on(SRC_PREPARE_EVENT, (videoPlayer, steps, done) => { eventEmitter.on(SRC_PREPARE_EVENT, (videoPlayer, steps, done) => {
steps.shift(); steps.shift();
videoPlayer.fdSrc = fileDescriptor;
videoPlayer.prepare((err) => { videoPlayer.prepare((err) => {
if (typeof (err) == 'undefined') { if (typeof (err) == 'undefined') {
expect(videoPlayer.state).assertEqual('prepared'); expect(videoPlayer.state).assertEqual('prepared');
...@@ -198,6 +241,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -198,6 +241,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
console.info('case prepare success!!'); console.info('case prepare success!!');
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -212,6 +258,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -212,6 +258,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
printfDescription(arrlist[i]); printfDescription(arrlist[i]);
} }
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -229,6 +278,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -229,6 +278,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
let endTime = videoPlayer.currentTime; let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -242,6 +294,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -242,6 +294,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
expect(videoPlayer.state).assertEqual('paused'); expect(videoPlayer.state).assertEqual('paused');
console.info('case pause success!!'); console.info('case pause success!!');
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -255,6 +310,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -255,6 +310,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
expect(videoPlayer.state).assertEqual('stopped'); expect(videoPlayer.state).assertEqual('stopped');
console.info('case stop success!!'); console.info('case stop success!!');
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -268,6 +326,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -268,6 +326,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
expect(videoPlayer.state).assertEqual('idle'); expect(videoPlayer.state).assertEqual('idle');
console.info('case reset success!!'); console.info('case reset success!!');
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -280,6 +341,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -280,6 +341,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
if (typeof (err) == 'undefined') { if (typeof (err) == 'undefined') {
console.info('case release success!!'); console.info('case release success!!');
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -290,20 +354,20 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -290,20 +354,20 @@ describe('VideoPlayerFuncCallbackTest', function () {
switch (seekMode) { switch (seekMode) {
case media.SeekMode.SEEK_NEXT_SYNC: case media.SeekMode.SEEK_NEXT_SYNC:
if (seekTime == 0) { if (seekTime == 0) {
expect(seekDoneTime).assertEqual(0); expect(seekDoneTime + DELTA_SEEK_TIME).assertClose(DELTA_SEEK_TIME, DELTA_SEEK_TIME);
} else if (seekTime == DURATION_TIME) { } else if (seekTime == DURATION_TIME) {
expect(seekDoneTime).assertEqual(DURATION_TIME); expect(seekDoneTime).assertClose(DURATION_TIME, DELTA_SEEK_TIME);
} else { } else {
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME); expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_SEEK_TIME);
} }
break; break;
case media.SeekMode.SEEK_PREV_SYNC: case media.SeekMode.SEEK_PREV_SYNC:
if (seekTime == 0) { if (seekTime == 0) {
expect(seekDoneTime).assertEqual(0); expect(seekDoneTime + DELTA_SEEK_TIME).assertClose(DELTA_SEEK_TIME, DELTA_SEEK_TIME);
} else if (seekTime == DURATION_TIME) { } else if (seekTime == DURATION_TIME) {
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME); expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_SEEK_TIME);
} else { } else {
expect(seekDoneTime).assertEqual(PREV_FRAME_TIME); expect(seekDoneTime).assertClose(PREV_FRAME_TIME, DELTA_SEEK_TIME);
} }
break; break;
default: default:
...@@ -323,6 +387,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -323,6 +387,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
checkSeekTime(media.SeekMode.SEEK_PREV_SYNC, seekTime, seekDoneTime); checkSeekTime(media.SeekMode.SEEK_PREV_SYNC, seekTime, seekDoneTime);
console.info('case seek success and seekDoneTime is '+ seekDoneTime); console.info('case seek success and seekDoneTime is '+ seekDoneTime);
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -343,6 +410,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -343,6 +410,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
checkSeekTime(seekMode, seekTime, seekDoneTime); checkSeekTime(seekMode, seekTime, seekDoneTime);
console.info('case seek success and seekDoneTime is '+ seekDoneTime); console.info('case seek success and seekDoneTime is '+ seekDoneTime);
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -357,6 +427,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -357,6 +427,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
if (typeof (err) == 'undefined') { if (typeof (err) == 'undefined') {
console.info('case setVolume success'); console.info('case setVolume success');
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -400,6 +473,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -400,6 +473,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
console.info('case setSpeed success and speedMode is '+ speedMode); console.info('case setSpeed success and speedMode is '+ speedMode);
checkSpeedTime(videoPlayer, speedValue, startTime); checkSpeedTime(videoPlayer, speedValue, startTime);
toNextStep(videoPlayer, steps, done); toNextStep(videoPlayer, steps, done);
} else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) {
steps.shift();
toNextStep(videoPlayer, steps, done);
} else { } else {
printfError(err, done); printfError(err, done);
} }
...@@ -407,425 +483,229 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -407,425 +483,229 @@ describe('VideoPlayerFuncCallbackTest', function () {
}); });
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0100 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETSOURCE
* @tc.name : 001.play (callback) * @tc.name : 001.test setSorce '' (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0100', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT,
PREPARE_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0200
* @tc.name : 002.pause (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0200', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT,
PLAY_EVENT, PAUSE_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0300
* @tc.name : 003.pause->play (callback)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0300', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SETSOURCE', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let fdPath = '';
PAUSE_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT); let mySteps = new Array(CREATE_EVENT, SETSOURCE_EVENT, fdPath, ERROR_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0400 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETVOLUME
* @tc.name : 004.stop (callback) * @tc.name : 001.test SetVolume 0/0.5/1 (callback)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0400', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETVOLUME', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT,
PLAY_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT); PREPARE_EVENT, PLAY_EVENT, SETVOLUME_EVENT, 0, SETVOLUME_EVENT, 0.5, SETVOLUME_EVENT, 1,
RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0500 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETSPEED
* @tc.name : 005.reset (callback) * @tc.name : 001.test SetSpeed 0.75/1/1.25/1.75/2 (callback)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0500', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETSPEED', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT,
PLAY_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT); PREPARE_EVENT, PLAY_EVENT, SETSPEED_EVENT, media.PlaybackSpeed.SPEED_FORWARD_0_75_X,
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); SETSPEED_EVENT, media.PlaybackSpeed.SPEED_FORWARD_1_00_X,
}) SETSPEED_EVENT, media.PlaybackSpeed.SPEED_FORWARD_1_25_X,
SETSPEED_EVENT, media.PlaybackSpeed.SPEED_FORWARD_1_75_X,
/* * SETSPEED_EVENT, media.PlaybackSpeed.SPEED_FORWARD_2_00_X, RELEASE_EVENT, END_EVENT);
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0600
* @tc.name : 006.seek (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0600', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, SEEK_TIME, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0700 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SEEKMODE
* @tc.name : 007.seek mode(callback) * @tc.name : 001.test seek mode SEEK_PREV_SYNC/SEEK_NEXT_SYNC (callback)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0700', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SEEKMODE', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT,
SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC, 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); SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC,RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0800 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_CALLBACK
* @tc.name : 008.setVolume (callback) * @tc.name : 001.test callback bufferingUpdate/videoSizeChanged/startRenderFrame/playbackCompleted
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0800', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_CALLBACK', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let frameCount = -1;
SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT); let completedCount = 0;
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); let widthValue = -1;
}) let heightValue = -1;
/* * eventEmitter.on('test_create', () => {
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0900 media.createVideoPlayer((err, video) => {
* @tc.name : 009.setSpeed (callback) if (typeof (video) != 'undefined') {
* @tc.desc : Video playback control test videoPlayer = video;
* @tc.size : MediumTest expect(videoPlayer.state).assertEqual('idle');
* @tc.type : Function test console.info('case createVideoPlayer success!!');
* @tc.level : Level0 eventEmitter.emit('test_callback');
*/ }else {
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0900', 0, async function (done) { printfError(err, done);
isFileOpen(fileDescriptor, done); }
let videoPlayer = null; });
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, });
SETSPEED_EVENT, SPEED_VALUE, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1000
* @tc.name : 010.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_1000', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT,
GETDESCRIPTION, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1200
* @tc.name : 012.play->pause->stop (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1200', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1300
* @tc.name : 013.play->pause->reset (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1300', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1400
* @tc.name : 014.play->pause->seek->play (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1400', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SEEK_EVENT, SEEK_TIME, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1500
* @tc.name : 015.play->pause->seek(mode)->play (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1500', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC,
SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1600
* @tc.name : 016.play->pause->setvolume->play (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1600', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SETVOLUME_EVENT, VOLUME_VALUE, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1700
* @tc.name : 017.play->pause->setspeed->play (callback)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1700', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SETSPEED_EVENT, SPEED_VALUE, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* * eventEmitter.on('test_callback', () => {
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1800 videoPlayer.on('playbackCompleted', async () => {
* @tc.name : 018.play->stop->reset (callback) console.info('case playbackCompleted success');
* @tc.desc : Video playback control test completedCount++;
* @tc.size : MediumTest expect(widthValue).assertEqual(WIDTH_VALUE);
* @tc.type : Function test expect(heightValue).assertEqual(HEIGHT_VALUE);
* @tc.level : Level1 expect(completedCount).assertEqual(1);
*/ videoPlayer.release((err) => {
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1800', 0, async function (done) { if (typeof (err) == 'undefined') {
isFileOpen(fileDescriptor, done); console.info('case release success!!');
let videoPlayer = null; done();
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, } else {
STOP_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT); printfError(err, done);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }
}) });
});
/* * videoPlayer.on('bufferingUpdate', (infoType, value) => {
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1900 console.info('case bufferingUpdate success infoType is ' + infoType);
* @tc.name : 019.play->stop->reset->prepare->play (callback) console.info('case bufferingUpdate success value is ' + value);
* @tc.desc : Video playback control test });
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1900', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
STOP_EVENT, RESET_EVENT, SRC_PREPARE_EVENT,
PLAY_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* * videoPlayer.on('startRenderFrame', () => {
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2000 console.info('case startRenderFrame success');
* @tc.name : 020.play->seek(0)->pause->stop (callback) });
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2000', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, 0, PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* * videoPlayer.on('videoSizeChanged', (width, height) => {
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2100 console.info('case videoSizeChanged success');
* @tc.name : 021.play->seek(0, mode)->pause->stop (callback) widthValue = width;
* @tc.desc : Video playback control test heightValue = height;
* @tc.size : MediumTest });
* @tc.type : Function test eventEmitter.emit('test_setSurface');
* @tc.level : Level1 });
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2100', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_MODE_EVENT, 0, media.SeekMode.SEEK_NEXT_SYNC,
SEEK_MODE_EVENT, 0, media.SeekMode.SEEK_PREV_SYNC, PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* * eventEmitter.on('test_setSurface', () => {
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2200 videoPlayer.url = fdHead + fileDescriptor.fd;
* @tc.name : 022.play->seek(duration)->finish (callback) videoPlayer.setDisplaySurface(surfaceID, (err) => {
* @tc.desc : Video playback control test if (typeof (err) == 'undefined') {
* @tc.size : MediumTest expect(videoPlayer.state).assertEqual('idle');
* @tc.type : Function test console.info('case setDisplaySurface success!!');
* @tc.level : Level1 eventEmitter.emit('test_prepare');
*/ }else {
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2200', 0, async function (done) { printfError(err, done);
isFileOpen(fileDescriptor, done); }
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, DURATION_TIME, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
}) })
});
/* * eventEmitter.on('test_prepare', () => {
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2300 videoPlayer.prepare((err) => {
* @tc.name : 023.play->seek(duration, mode)->finish (callback) if (typeof (err) == 'undefined') {
* @tc.desc : Video playback control test expect(videoPlayer.state).assertEqual('prepared');
* @tc.size : MediumTest expect(videoPlayer.duration).assertEqual(DURATION_TIME);
* @tc.type : Function test expect(videoPlayer.width).assertEqual(WIDTH_VALUE);
* @tc.level : Level1 expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
*/ console.info('case prepare success!!');
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2300', 0, async function (done) { eventEmitter.emit('test_play');
isFileOpen(fileDescriptor, done); } else {
let videoPlayer = null; printfError(err, done);
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, }
SEEK_MODE_EVENT, DURATION_TIME, media.SeekMode.SEEK_PREV_SYNC, });
SEEK_MODE_EVENT, DURATION_TIME, media.SeekMode.SEEK_NEXT_SYNC, RELEASE_EVENT, END_EVENT); });
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
})
/* * eventEmitter.on('test_play', () => {
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2400 videoPlayer.play((err) => {
* @tc.name : 024.play->seek(out of duration) (callback) if (typeof (err) == 'undefined') {
* @tc.desc : Video playback control test expect(videoPlayer.state).assertEqual('playing');
* @tc.size : MediumTest console.info('case play success!!');
* @tc.type : Function test } else {
* @tc.level : Level2 printfError(err, done);
*/ }
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2400', 0, async function (done) { });
isFileOpen(fileDescriptor, done); });
let videoPlayer = null; eventEmitter.emit('test_create');
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, DURATION_TIME + 1, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2500 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_GETTRECKDESCRIPTION
* @tc.name : 025.play->seek(out of duration, mode) (callback) * @tc.name : 001.test getTrackDescription (callback)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2500', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_GETTRECKDESCRIPTION', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT,
SEEK_MODE_EVENT, DURATION_TIME + 1, media.SeekMode.SEEK_PREV_SYNC, PREPARE_EVENT, GETDESCRIPTION, RELEASE_EVENT, END_EVENT);
SEEK_MODE_EVENT, DURATION_TIME + 1, media.SeekMode.SEEK_NEXT_SYNC, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2600 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_LOOP
* @tc.name : 026. play->setvolume(0~1) (callback) * @tc.name : 001.test LOOP (callback)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2600', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_LOOP', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT,
SETVOLUME_EVENT, 0, SETVOLUME_EVENT, 0.2, SETVOLUME_EVENT, 0.4, SETVOLUME_EVENT, 0.6, PREPARE_EVENT, SETLOOP_EVENT, true, PLAY_EVENT, SEEK_EVENT, DURATION_TIME, WAIT_EVENT,
SETVOLUME_EVENT, 0.8, SETVOLUME_EVENT, 1, RELEASE_EVENT, END_EVENT); SEEK_EVENT, DURATION_TIME, WAIT_EVENT, SEEK_EVENT, DURATION_TIME, WAIT_EVENT,
SEEK_EVENT, DURATION_TIME, WAIT_EVENT, SETLOOP_EVENT, false, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2700 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_BASE
* @tc.name : 027.play->setspeed(0~4) (callback) * @tc.name : 001.test video playe (callback)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2700', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_BASE', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let fdPath = fdHead + fileDescriptor.fd;
SETSPEED_EVENT, media.PlaybackSpeed.SPEED_FORWARD_2_00_X, RELEASE_EVENT, END_EVENT); 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); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
}) })
}) })
...@@ -28,6 +28,7 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -28,6 +28,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
const DELTA_TIME = 1000; const DELTA_TIME = 1000;
const NEXT_FRAME_TIME = 8333; const NEXT_FRAME_TIME = 8333;
const PREV_FRAME_TIME = 4166; const PREV_FRAME_TIME = 4166;
const DELTA_SEEK_TIME = 100;
let surfaceID = ''; let surfaceID = '';
let fdHead = 'fd://'; let fdHead = 'fd://';
let fileDescriptor = undefined; let fileDescriptor = undefined;
...@@ -113,109 +114,50 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -113,109 +114,50 @@ describe('VideoPlayerFuncPromiseTest', function () {
} }
/* * /* *
* @tc.number : SUB_MEDIA_PLAYER_MULTIPLE_0100 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SetSource
* @tc.name : 001.Multi-instance (2 videoPlayer promise) * @tc.name : 001.setSorce "" (promise)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_MULTIPLE_0100', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SetSource', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let testVideoPlayer1 = null; let videoPlayer = null;
let testVideoPlayer2 = null;
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
testVideoPlayer1 = video
console.info('case createVideoPlayer success ');
} else {
console.info('case createVideoPlayer is failed');
expect().assertFail();
}
}, failureCallback).catch(catchCallback);
testVideoPlayer1.url = fdHead + fileDescriptor.fd;
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) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
testVideoPlayer2 = video console.info('case createVideoPlayer success');
console.info('case createVideoPlayer success '); videoPlayer = video;
expect(videoPlayer.state).assertEqual('idle');
} else { } else {
console.info('case createVideoPlayer is failed'); console.info('case createVideoPlayer is failed');
expect().assertFail(); expect().assertFail();
} }
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
testVideoPlayer2.url = fdHead + fileDescriptor.fd; videoPlayer.on('error', async (error) => {
await testVideoPlayer2.setDisplaySurface(surfaceID).then(() => { console.info(`case error called,errMessage is ${error.message}`);
console.info('case setDisplaySurface success'); await videoPlayer.release().then(() => {
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!!'); console.info('case release called!!');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
testVideoPlayer2 = null;
done(); done();
});
videoPlayer.url = "";
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0100 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SetVolume
* @tc.name : 001.play (promise) * @tc.name : 001.SetVolume 0/0.5/1 (promise)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0100', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SetVolume', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
console.info('case createVideoPlayer success');
videoPlayer = video; videoPlayer = video;
expect(videoPlayer.state).assertEqual('idle'); expect(videoPlayer.state).assertEqual('idle');
} else { } else {
...@@ -226,27 +168,34 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -226,27 +168,34 @@ describe('VideoPlayerFuncPromiseTest', function () {
videoPlayer.url = fdHead + fileDescriptor.fd; videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => { await videoPlayer.setDisplaySurface(surfaceID).then(() => {
console.info('case setDisplaySurface success');
expect(videoPlayer.state).assertEqual('idle'); expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.prepare().then(() => { await videoPlayer.prepare().then(() => {
console.info('case prepare called!!');
expect(videoPlayer.state).assertEqual('prepared'); expect(videoPlayer.state).assertEqual('prepared');
expect(videoPlayer.duration).assertEqual(DURATION_TIME); expect(videoPlayer.duration).assertEqual(DURATION_TIME);
expect(videoPlayer.width).assertEqual(WIDTH_VALUE); expect(videoPlayer.width).assertEqual(WIDTH_VALUE);
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
console.info('case prepare called!!');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime; let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => { await videoPlayer.play().then(() => {
console.info('case play called!!'); console.info('case play called!!');
sleep(PLAY_TIME); sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
endTime = videoPlayer.currentTime; let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
for (let i = 0; i < 3; i++) {
await videoPlayer.setVolume(i * 0.5).then(() => {
expect(videoPlayer.state).assertEqual('playing');
console.info('case setVolume called');
}, failureCallback).catch(catchCallback);
}
await videoPlayer.release().then(() => { await videoPlayer.release().then(() => {
console.info('case release called!!'); console.info('case release called!!');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
...@@ -254,14 +203,14 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -254,14 +203,14 @@ describe('VideoPlayerFuncPromiseTest', function () {
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0200 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SetSpeed
* @tc.name : 002.pause (promise) * @tc.name : 001.SetSpeed 0.75/1/1.25/1.75/2 (promise)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0200', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SetSpeed', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
...@@ -276,30 +225,70 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -276,30 +225,70 @@ describe('VideoPlayerFuncPromiseTest', function () {
videoPlayer.url = fdHead + fileDescriptor.fd; videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => { await videoPlayer.setDisplaySurface(surfaceID).then(() => {
console.info('case setDisplaySurface success');
expect(videoPlayer.state).assertEqual('idle'); expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.prepare().then(() => { await videoPlayer.prepare().then(() => {
console.info('case prepare called!!');
expect(videoPlayer.state).assertEqual('prepared'); expect(videoPlayer.state).assertEqual('prepared');
expect(videoPlayer.duration).assertEqual(DURATION_TIME); expect(videoPlayer.duration).assertEqual(DURATION_TIME);
expect(videoPlayer.width).assertEqual(WIDTH_VALUE); expect(videoPlayer.width).assertEqual(WIDTH_VALUE);
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
console.info('case prepare called!!');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime; let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => { await videoPlayer.play().then(() => {
console.info('case play called!!'); console.info('case play called!!');
sleep(PLAY_TIME); sleep(1000);
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime; let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.pause().then(() => { startTime = videoPlayer.currentTime;
expect(videoPlayer.state).assertEqual('paused'); await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_0_75_X).then((speedMode) => {
console.info('case pause called!!'); expect(videoPlayer.state).assertEqual('playing');
expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_0_75_X);
sleep(1000);
checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_0_75_X, startTime);
console.info('case setSpeed called and speedMode is ' + speedMode);
}, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime;
await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_00_X).then((speedMode) => {
expect(videoPlayer.state).assertEqual('playing');
expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_1_00_X);
sleep(1000);
checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_1_00_X, startTime);
console.info('case setSpeed called and speedMode is ' + speedMode);
}, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime;
await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_25_X).then((speedMode) => {
expect(videoPlayer.state).assertEqual('playing');
expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_1_25_X);
sleep(1000);
checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_1_25_X, startTime);
console.info('case setSpeed called and speedMode is ' + speedMode);
}, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime;
await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_1_75_X).then((speedMode) => {
expect(videoPlayer.state).assertEqual('playing');
expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_1_75_X);
sleep(1000);
checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_1_75_X, startTime);
console.info('case setSpeed called and speedMode is ' + speedMode);
}, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime;
await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X).then((speedMode) => {
expect(videoPlayer.state).assertEqual('playing');
expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_2_00_X);
sleep(1000);
checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_2_00_X, startTime);
console.info('case setSpeed called and speedMode is ' + speedMode);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => { await videoPlayer.release().then(() => {
...@@ -309,14 +298,14 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -309,14 +298,14 @@ describe('VideoPlayerFuncPromiseTest', function () {
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0300 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SeekMode
* @tc.name : 003.pause->play (promise) * @tc.name : 001.seek mode SEEK_PREV_SYNC/SEEK_NEXT_SYNC (promise)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0300', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SeekMode', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
...@@ -352,19 +341,41 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -352,19 +341,41 @@ describe('VideoPlayerFuncPromiseTest', function () {
let endTime = videoPlayer.currentTime; let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.pause().then(() => { await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('paused'); expect(videoPlayer.state).assertEqual('playing');
console.info('case pause called!!'); expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_SEEK_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime; await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
await videoPlayer.play().then(() => {
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('playing');
console.info('case play called!!'); expect(seekDoneTime).assertClose(PREV_FRAME_TIME, DELTA_SEEK_TIME);
sleep(PLAY_TIME); console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(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);
}, failureCallback).catch(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);
}, failureCallback).catch(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);
}, failureCallback).catch(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);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.release().then(() => { await videoPlayer.release().then(() => {
console.info('case release called!!'); console.info('case release called!!');
...@@ -373,16 +384,20 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -373,16 +384,20 @@ describe('VideoPlayerFuncPromiseTest', function () {
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0400 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Callback
* @tc.name : 004.stop (promise) * @tc.name : 001.test callback bufferingUpdate/videoSizeChanged/startRenderFrame/playbackCompleted
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0400', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Callback', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let frameCount = -1;
let completedCount = 0;
let widthValue = -1;
let heightValue = -1;
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
videoPlayer = video; videoPlayer = video;
...@@ -393,6 +408,35 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -393,6 +408,35 @@ describe('VideoPlayerFuncPromiseTest', function () {
} }
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
videoPlayer.on('playbackCompleted', async () => {
console.info('case playbackCompleted success');
completedCount++;
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
expect(widthValue).assertEqual(WIDTH_VALUE);
expect(heightValue).assertEqual(HEIGHT_VALUE);
//expect(frameCount).assertEqual(1);
expect(completedCount).assertEqual(1);
done();
});
videoPlayer.on('bufferingUpdate', (infoType, value) => {
console.info('case bufferingUpdate success infoType is ' + infoType);
console.info('case bufferingUpdate success value is ' + value);
});
videoPlayer.on('startRenderFrame', () => {
console.info('case startRenderFrame success');
//frameCount++;
});
videoPlayer.on('videoSizeChanged', (width, height) => {
console.info('case videoSizeChanged success');
widthValue = width;
heightValue = height;
});
videoPlayer.url = fdHead + fileDescriptor.fd; videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => { await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle'); expect(videoPlayer.state).assertEqual('idle');
...@@ -407,37 +451,25 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -407,37 +451,25 @@ describe('VideoPlayerFuncPromiseTest', function () {
console.info('case prepare called!!'); console.info('case prepare called!!');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => { await videoPlayer.play().then(() => {
console.info('case play called!!'); console.info('case play called!!');
sleep(PLAY_TIME); sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.stop().then(() => {
expect(videoPlayer.state).assertEqual('stopped');
console.info('case stop called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0500 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_GetTreckDescription
* @tc.name : 005.reset (promise) * @tc.name : 001.getTrackDescription (promise)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0500', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_GetTreckDescription', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let arrayDescription = null;
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
videoPlayer = video; videoPlayer = video;
...@@ -456,25 +488,22 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -456,25 +488,22 @@ describe('VideoPlayerFuncPromiseTest', function () {
await videoPlayer.prepare().then(() => { await videoPlayer.prepare().then(() => {
expect(videoPlayer.state).assertEqual('prepared'); 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!!'); console.info('case prepare called!!');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime; await videoPlayer.getTrackDescription().then((arrayList) => {
await videoPlayer.play().then(() => { console.info('case getTrackDescription called!!');
console.info('case play called!!'); if (typeof (arrayList) != 'undefined') {
sleep(PLAY_TIME); arrayDescription = arrayList;
expect(videoPlayer.state).assertEqual('playing'); } else {
console.info('case getTrackDescription is failed');
expect().assertFail();
}
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.reset().then(() => { for (let i = 0; i < arrayDescription.length; i++) {
expect(videoPlayer.state).assertEqual('idle'); printfDescription(arrayDescription[i]);
console.info('case reset called!!'); }
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => { await videoPlayer.release().then(() => {
console.info('case release called!!'); console.info('case release called!!');
...@@ -483,16 +512,17 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -483,16 +512,17 @@ describe('VideoPlayerFuncPromiseTest', function () {
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0600 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Loop
* @tc.name : 006.seek (promise) * @tc.name : 001.Loop true (promise)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0600', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Loop', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
let bufferCount = 0;
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
videoPlayer = video; videoPlayer = video;
...@@ -503,6 +533,22 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -503,6 +533,22 @@ describe('VideoPlayerFuncPromiseTest', function () {
} }
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
videoPlayer.on('playbackCompleted', async () => {
console.info('case playbackCompleted success');
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
expect(bufferCount).assertEqual(19);
done();
});
videoPlayer.on('bufferingUpdate', (infoType, value) => {
console.info('case bufferingUpdate success infoType is ' + infoType);
console.info('case bufferingUpdate success value is ' + value);
bufferCount++;
console.info('case bufferingUpdate bufferCount value is ' + bufferCount);
});
videoPlayer.url = fdHead + fileDescriptor.fd; videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => { await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle'); expect(videoPlayer.state).assertEqual('idle');
...@@ -510,6 +556,7 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -510,6 +556,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.prepare().then(() => { await videoPlayer.prepare().then(() => {
videoPlayer.loop = true;
expect(videoPlayer.state).assertEqual('prepared'); expect(videoPlayer.state).assertEqual('prepared');
expect(videoPlayer.duration).assertEqual(DURATION_TIME); expect(videoPlayer.duration).assertEqual(DURATION_TIME);
expect(videoPlayer.width).assertEqual(WIDTH_VALUE); expect(videoPlayer.width).assertEqual(WIDTH_VALUE);
...@@ -519,6 +566,7 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -519,6 +566,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
let startTime = videoPlayer.currentTime; let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => { await videoPlayer.play().then(() => {
expect(videoPlayer.loop).assertEqual(true);
console.info('case play called!!'); console.info('case play called!!');
sleep(PLAY_TIME); sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('playing');
...@@ -526,31 +574,32 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -526,31 +574,32 @@ describe('VideoPlayerFuncPromiseTest', function () {
let endTime = videoPlayer.currentTime; let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.seek(SEEK_TIME).then((seekDoneTime) => { for (let i = 0; i < 4; i++) {
await videoPlayer.seek(DURATION_TIME, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(PREV_FRAME_TIME); expect(seekDoneTime).assertClose(DURATION_TIME, DELTA_SEEK_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime); console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
sleep(3000);
await videoPlayer.release().then(() => { expect(videoPlayer.state).assertEqual('playing');
console.info('case release called!!'); }
}, failureCallback).catch(catchCallback); videoPlayer.loop = false;
done();
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0700 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_BASE
* @tc.name : 007.seek CLOSEST(promise) * @tc.name : 001.test video playe (promise)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0700', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_BASE', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let videoPlayer = null;
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
console.info('case createVideoPlayer success');
videoPlayer = video; videoPlayer = video;
expect(videoPlayer.state).assertEqual('idle'); expect(videoPlayer.state).assertEqual('idle');
} else { } else {
...@@ -559,18 +608,26 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -559,18 +608,26 @@ describe('VideoPlayerFuncPromiseTest', function () {
} }
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
videoPlayer.on('playbackCompleted', async () => {
console.info('case playbackCompleted success');
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
});
videoPlayer.url = fdHead + fileDescriptor.fd; videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => { await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success'); console.info('case setDisplaySurface success');
expect(videoPlayer.state).assertEqual('idle');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.prepare().then(() => { await videoPlayer.prepare().then(() => {
console.info('case prepare called!!');
expect(videoPlayer.state).assertEqual('prepared'); expect(videoPlayer.state).assertEqual('prepared');
expect(videoPlayer.duration).assertEqual(DURATION_TIME); expect(videoPlayer.duration).assertEqual(DURATION_TIME);
expect(videoPlayer.width).assertEqual(WIDTH_VALUE); expect(videoPlayer.width).assertEqual(WIDTH_VALUE);
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
console.info('case prepare called!!');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime; let startTime = videoPlayer.currentTime;
...@@ -582,1335 +639,147 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -582,1335 +639,147 @@ describe('VideoPlayerFuncPromiseTest', function () {
let endTime = videoPlayer.currentTime; let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { await videoPlayer.pause().then(() => {
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('paused');
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME); console.info('case pause called!!');
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => { await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(PREV_FRAME_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.seek(PREV_FRAME_TIME - 100, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => { await videoPlayer.stop().then(() => {
expect(videoPlayer.state).assertEqual('playing'); console.info('case stop called!!');
expect(seekDoneTime).assertEqual(0); expect(videoPlayer.state).assertEqual('stopped');
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.seek(PREV_FRAME_TIME + 100, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => { await videoPlayer.reset().then(() => {
expect(videoPlayer.state).assertEqual('playing'); console.info('case reset called!!');
expect(seekDoneTime).assertEqual(PREV_FRAME_TIME); expect(videoPlayer.state).assertEqual('idle');
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.seek(NEXT_FRAME_TIME - 100, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
await videoPlayer.seek(NEXT_FRAME_TIME + 100, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME + 100);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0800
* @tc.name : 008.setVolume (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0800', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.setVolume(1).then(() => {
expect(videoPlayer.state).assertEqual('playing');
console.info('case setVolume called');
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0900
* @tc.name : 009.setSpeed (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0900', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
startTime = videoPlayer.currentTime;
await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X).then((speedMode) => {
expect(videoPlayer.state).assertEqual('playing');
sleep(1000);
expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_2_00_X);
console.info('case setSpeed called and speedMode is ' + speedMode);
}, failureCallback).catch(catchCallback);
endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(2 * 1000, DELTA_TIME);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1000
* @tc.name : 010.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_1000', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let arrayDescription = 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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(catchCallback);
await videoPlayer.prepare().then(() => {
expect(videoPlayer.state).assertEqual('prepared');
console.info('case prepare called!!');
}, failureCallback).catch(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();
}
}, failureCallback).catch(catchCallback);
for (let i = 0; i < arrayDescription.length; i++) {
printfDescription(arrayDescription[i]);
}
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1100
* @tc.name : 011.Loop true (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1100', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(catchCallback);
await videoPlayer.prepare().then(() => {
videoPlayer.loop = true;
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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
expect(videoPlayer.loop).assertEqual(true);
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.seek(DURATION_TIME, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(DURATION_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1200
* @tc.name : 012.play->pause->stop (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1200', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.pause().then(() => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case pause called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.stop().then(() => {
expect(videoPlayer.state).assertEqual('stopped');
console.info('case stop called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1300
* @tc.name : 013.play->pause->reset (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1300', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.pause().then(() => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case pause called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.reset().then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case reset called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1400
* @tc.name : 014.play->pause->seek->play (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1400', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.pause().then(() => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case pause called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.seek(SEEK_TIME).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('paused');
expect(seekDoneTime).assertEqual(PREV_FRAME_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
expect(videoPlayer.state).assertEqual('playing');
console.info('case play called!!');
sleep(PLAY_TIME);
}, failureCallback).catch(catchCallback);
endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1500
* @tc.name : 015.play->pause->seek(mode)->play (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1500', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.pause().then(() => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case pause called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('paused');
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('paused');
expect(seekDoneTime).assertEqual(PREV_FRAME_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
expect(videoPlayer.state).assertEqual('playing');
console.info('case play called!!');
sleep(PLAY_TIME);
}, failureCallback).catch(catchCallback);
endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1600
* @tc.name : 016.play->pause->setvolume->play (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1600', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.pause().then(() => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case pause called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.setVolume(1).then(() => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case setVolume called');
}, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
expect(videoPlayer.state).assertEqual('playing');
console.info('case play called!!');
sleep(PLAY_TIME);
}, failureCallback).catch(catchCallback);
endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1700
* @tc.name : 017.play->pause->setspeed->play (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1700', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.pause().then(() => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case pause called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X).then((speedMode) => {
expect(videoPlayer.state).assertEqual('paused');
expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_2_00_X);
console.info('case setSpeed called and speedMode is ' + speedMode);
}, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
expect(videoPlayer.state).assertEqual('playing');
console.info('case play called!!');
sleep(PLAY_TIME);
}, failureCallback).catch(catchCallback);
endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1800
* @tc.name : 018.play->stop->reset (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1800', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.stop().then(() => {
expect(videoPlayer.state).assertEqual('stopped');
console.info('case stop called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.reset().then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case reset called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1900
* @tc.name : 019.play->stop->reset->prepare->play (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_1900', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.stop().then(() => {
expect(videoPlayer.state).assertEqual('stopped');
console.info('case stop called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.reset().then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case reset called!!');
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
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!!');
}, failureCallback).catch(catchCallback);
startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2000
* @tc.name : 020.play->seek(0)->pause->stop (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2000', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.seek(0).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(0);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
await videoPlayer.pause().then(() => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case pause called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.stop().then(() => {
expect(videoPlayer.state).assertEqual('stopped');
console.info('case stop called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2100
* @tc.name : 021.play->seek(0, mode)->pause->stop (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2100', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.seek(0, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(0);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
await videoPlayer.seek(0, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(0);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
await videoPlayer.pause().then(() => {
expect(videoPlayer.state).assertEqual('paused');
console.info('case pause called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.stop().then(() => {
expect(videoPlayer.state).assertEqual('stopped');
console.info('case stop called!!');
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2200
* @tc.name : 022.play->seek(duration)->finish (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2200', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.on('playbackCompleted', () => {
console.info('case playbackCompleted called!!');
expect(videoPlayer.state).assertEqual('stopped');
videoPlayer.release().then(() => {
console.info('case release called!!');
done();
}, failureCallback).catch(catchCallback);
});
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.seek(DURATION_TIME).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2300
* @tc.name : 023.play->seek(duration, mode)->finish (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2300', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.on('playbackCompleted', () => {
console.info('case playbackCompleted called!!');
expect(videoPlayer.state).assertEqual('stopped');
videoPlayer.release().then(() => {
console.info('case release called!!');
done();
}, failureCallback).catch(catchCallback);
});
videoPlayer.url = fdHead + fileDescriptor.fd; videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(catchCallback);
await videoPlayer.prepare().then(() => { await videoPlayer.prepare().then(() => {
console.info('case prepare called!!');
expect(videoPlayer.state).assertEqual('prepared'); expect(videoPlayer.state).assertEqual('prepared');
expect(videoPlayer.duration).assertEqual(DURATION_TIME); expect(videoPlayer.duration).assertEqual(DURATION_TIME);
expect(videoPlayer.width).assertEqual(WIDTH_VALUE); expect(videoPlayer.width).assertEqual(WIDTH_VALUE);
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
console.info('case prepare called!!');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
videoPlayer.loop = true;
let startTime = videoPlayer.currentTime; startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => { await videoPlayer.play().then(() => {
console.info('case play called!!'); console.info('case play called!!');
sleep(PLAY_TIME); sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime; endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.seek(DURATION_TIME, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => { await videoPlayer.seek(videoPlayer.duration / 2).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME); sleep(PLAY_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime); console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.seek(DURATION_TIME, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { await videoPlayer.seek(0).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing'); expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(DURATION_TIME); sleep(PLAY_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime); console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => { await videoPlayer.seek(videoPlayer.duration).then((seekDoneTime) => {
console.info('case release called!!'); expect(videoPlayer.state).assertEqual('playing');
sleep(PLAY_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
done(); videoPlayer.loop = false;
}) })
/* * /* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2400 * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_MULTIPLE
* @tc.name : 024.play->seek(out of duration) (promise) * @tc.name : 001.Multi-instance (2 videoPlayer promise)
* @tc.desc : Video playback control test * @tc.desc : Video playback control test
* @tc.size : MediumTest * @tc.size : MediumTest
* @tc.type : Function test * @tc.type : Function test
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2400', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_MULTIPLE', 0, async function (done) {
isFileOpen(fileDescriptor, done); isFileOpen(fileDescriptor, done);
let videoPlayer = null; let testVideoPlayer1 = null;
let testVideoPlayer2 = null;
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
videoPlayer = video; console.info('case createVideoPlayer success');
expect(videoPlayer.state).assertEqual('idle'); testVideoPlayer1 = video;
expect(testVideoPlayer1.state).assertEqual('idle');
} else { } else {
console.info('case createVideoPlayer is failed'); console.info('case createVideoPlayer is failed');
expect().assertFail(); expect().assertFail();
} }
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
testVideoPlayer1.url = fdHead + fileDescriptor.fd;
videoPlayer.on('playbackCompleted', () => { await testVideoPlayer1.setDisplaySurface(surfaceID).then(() => {
console.info('case playbackCompleted called!!');
expect(videoPlayer.state).assertEqual('stopped');
videoPlayer.release().then(() => {
console.info('case release called!!');
done();
}, failureCallback).catch(catchCallback);
});
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success'); console.info('case setDisplaySurface success');
expect(testVideoPlayer1.state).assertEqual('idle');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.prepare().then(() => { await toNewPage(page);
expect(videoPlayer.state).assertEqual('prepared'); page = (page + 1) % 2;
expect(videoPlayer.duration).assertEqual(DURATION_TIME); await msleep(1000).then(() => {}, failureCallback).catch(catchCallback);
expect(videoPlayer.width).assertEqual(WIDTH_VALUE); surfaceID = globalThis.value;
expect(videoPlayer.height).assertEqual(HEIGHT_VALUE);
console.info('case prepare called!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(PLAY_TIME);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.seek(DURATION_TIME + 1).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, (err) => {
console.info('case seek out of duration called');
done();
}).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!');
}, failureCallback).catch(catchCallback);
done();
})
/* * for (let i = 0; i < 3; i++) {
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2500
* @tc.name : 025.play->seek(out of duration, mode) (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2500', 0, async function (done) {
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
await media.createVideoPlayer().then((video) => { await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') { if (typeof (video) != 'undefined') {
videoPlayer = video; console.info('case createVideoPlayer success');
expect(videoPlayer.state).assertEqual('idle'); testVideoPlayer2 = video;
expect(testVideoPlayer2.state).assertEqual('idle');
} else { } else {
console.info('case createVideoPlayer is failed'); console.info('case createVideoPlayer is failed');
expect().assertFail(); expect().assertFail();
} }
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
testVideoPlayer2.url = fdHead + fileDescriptor.fd;
videoPlayer.on('playbackCompleted', () => { await testVideoPlayer2.setDisplaySurface(surfaceID).then(() => {
console.info('case playbackCompleted called!!');
expect(videoPlayer.state).assertEqual('stopped');
videoPlayer.release().then(() => {
console.info('case release called!!');
done();
}, failureCallback).catch(catchCallback);
});
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success'); console.info('case setDisplaySurface success');
expect(testVideoPlayer2.state).assertEqual('idle');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.prepare().then(() => { await testVideoPlayer1.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!!'); console.info('case prepare called!!');
expect(testVideoPlayer1.state).assertEqual('prepared');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime; await testVideoPlayer1.play().then(() => {
await videoPlayer.play().then(() => {
console.info('case play called!!'); console.info('case play called!!');
sleep(PLAY_TIME); expect(testVideoPlayer1.state).assertEqual('playing');
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
await videoPlayer.seek(DURATION_TIME + 1, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
await videoPlayer.seek(DURATION_TIME + 1, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => {
expect(videoPlayer.state).assertEqual('playing');
expect(seekDoneTime).assertEqual(DURATION_TIME);
console.info('case seek called and seekDoneTime is' + seekDoneTime);
}, failureCallback).catch(catchCallback);
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2600
* @tc.name : 026. play->setvolume(0~1) (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2600', 0, async function (done) {
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();
}
}, failureCallback).catch(catchCallback);
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
await videoPlayer.prepare().then(() => { await testVideoPlayer2.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!!'); console.info('case prepare called!!');
expect(testVideoPlayer2.state).assertEqual('prepared');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime; await testVideoPlayer2.play().then(() => {
await videoPlayer.play().then(() => {
console.info('case play called!!'); console.info('case play called!!');
sleep(PLAY_TIME); expect(testVideoPlayer2.state).assertEqual('playing');
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
for (let i = 0; i < 6; i++) { sleep(PLAY_TIME);
await videoPlayer.setVolume(i * 0.2).then(() => { await testVideoPlayer1.reset().then(() => {
expect(videoPlayer.state).assertEqual('playing'); console.info('case reset called!!');
console.info('case setVolume called'); expect(testVideoPlayer1.state).assertEqual('idle');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
} testVideoPlayer1.url = fdHead + fileDescriptor.fd;
await videoPlayer.release().then(() => { await testVideoPlayer2.release().then(() => {
console.info('case release called!!'); console.info('case release called!!');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
done();
})
/* *
* @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2700
* @tc.name : 028.play->setspeed(0~4) (promise)
* @tc.desc : Video playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level2
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2700', 0, async function (done) {
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();
} }
}, failureCallback).catch(catchCallback); await testVideoPlayer1.release().then(() => {
videoPlayer.url = fdHead + fileDescriptor.fd;
await videoPlayer.setDisplaySurface(surfaceID).then(() => {
expect(videoPlayer.state).assertEqual('idle');
console.info('case setDisplaySurface success');
}, failureCallback).catch(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!!');
}, failureCallback).catch(catchCallback);
let startTime = videoPlayer.currentTime;
await videoPlayer.play().then(() => {
console.info('case play called!!');
sleep(1000);
expect(videoPlayer.state).assertEqual('playing');
}, failureCallback).catch(catchCallback);
let endTime = videoPlayer.currentTime;
expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME);
startTime = videoPlayer.currentTime;
await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_2_00_X).then((speedMode) => {
expect(videoPlayer.state).assertEqual('playing');
expect(speedMode).assertEqual(media.PlaybackSpeed.SPEED_FORWARD_2_00_X);
sleep(1000);
checkSpeedTime(videoPlayer, media.PlaybackSpeed.SPEED_FORWARD_2_00_X, startTime);
console.info('case setSpeed called and speedMode is ' + speedMode);
}, failureCallback).catch(catchCallback);
await videoPlayer.release().then(() => {
console.info('case release called!!'); console.info('case release called!!');
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
done(); done();
......
...@@ -20,7 +20,7 @@ export async function toNewPage(page) { ...@@ -20,7 +20,7 @@ export async function toNewPage(page) {
if (page == 0) { if (page == 0) {
path = 'pages/surfaceTest/surfaceTest'; path = 'pages/surfaceTest/surfaceTest';
} else { } else {
path = 'pages/surfaceTest/surfaceTest2'; path = 'pages/surfaceTest2/surfaceTest2';
} }
let options = { let options = {
uri: path, uri: path,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册