diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js index 837f8ab9573eea745505a323492004c7e967f316..3f2825f5e07d3d1cae2ebf476e94cc95b9c97d80 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerAPICallbackTest.test.js @@ -46,6 +46,7 @@ describe('VideoPlayerAPICallbackTest', function () { const SPEED_VALUE = 1; const NEXT_FRAME_TIME = 8333; const PREV_FRAME_TIME = 4166; + const DELTA_TIME = 100; let surfaceID = ''; let fileDescriptor = undefined; let page = 0; @@ -326,20 +327,20 @@ describe('VideoPlayerAPICallbackTest', function () { switch (seekMode) { case media.SeekMode.SEEK_NEXT_SYNC: if (seekTime == 0) { - expect(seekDoneTime).assertEqual(0); + expect(seekDoneTime + DELTA_TIME).assertClose(DELTA_TIME, DELTA_TIME); } else if (seekTime == DURATION_TIME) { - expect(seekDoneTime).assertEqual(DURATION_TIME); + expect(seekDoneTime).assertClose(DURATION_TIME, DELTA_TIME); } else { - expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME); + expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_TIME); } break; case media.SeekMode.SEEK_PREV_SYNC: if (seekTime == 0) { - expect(seekDoneTime).assertEqual(0); + expect(seekDoneTime + DELTA_TIME).assertClose(DELTA_TIME, DELTA_TIME); } else if (seekTime == DURATION_TIME) { - expect(seekDoneTime).assertEqual(PREV_FRAME_TIME); + expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_TIME); } else { - expect(seekDoneTime).assertEqual(PREV_FRAME_TIME); + expect(seekDoneTime).assertClose(PREV_FRAME_TIME, DELTA_TIME); } break; default: diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js index e74e69964c1cda5377a24eb44450c4b07a3adefe..cbcfcbcc141352e53b52b5b033d71df09f18531c 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncCallbackTest.test.js @@ -28,6 +28,8 @@ describe('VideoPlayerFuncCallbackTest', function () { const CREATE_EVENT = 'create'; const SETSURFACE_EVENT = 'setDisplaySurface'; const GETDESCRIPTION = 'getTrackDescription'; + const SETSOURCE_EVENT = 'setSource'; + const SETFDSOURCE_EVENT = 'setFdSource'; const PREPARE_EVENT = 'prepare'; const SRC_PREPARE_EVENT = 'src2prepare'; const PLAY_EVENT = 'play'; @@ -39,13 +41,16 @@ describe('VideoPlayerFuncCallbackTest', function () { const SEEK_MODE_EVENT = 'seekMode'; const SETVOLUME_EVENT = 'volume'; const SETSPEED_EVENT = 'speed'; + const SETLOOP_EVENT = 'loop'; + const WAIT_EVENT = 'wait'; + const ERROR_EVENT = 'error'; const END_EVENT = 'end'; - const VOLUME_VALUE = 1; - const SPEED_VALUE = 1; const DELTA_TIME = 1000; const NEXT_FRAME_TIME = 8333; const PREV_FRAME_TIME = 4166; + const DELTA_SEEK_TIME = 100; let surfaceID = ''; + let fdHead = 'fd://'; let fileDescriptor = undefined; let page = 0; let events = require('events'); @@ -119,7 +124,7 @@ describe('VideoPlayerFuncCallbackTest', function () { eventEmitter.emit(steps[0], videoPlayer, steps, done); } } - function setOnCallback(videoPlayer) { + function setOnCallback(videoPlayer, steps, done) { videoPlayer.on('playbackCompleted', () => { console.info('case playbackCompleted success'); }); @@ -139,6 +144,10 @@ describe('VideoPlayerFuncCallbackTest', function () { videoPlayer.on('error', (error) => { 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 () { media.createVideoPlayer((err, video) => { if (typeof (video) != 'undefined') { videoPlayer = video; - setOnCallback(videoPlayer); + setOnCallback(videoPlayer, steps, done); expect(videoPlayer.state).assertEqual('idle'); console.info('case createVideoPlayer success!!'); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { 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) => { steps.shift(); - videoPlayer.fdSrc = fileDescriptor; videoPlayer.setDisplaySurface(surfaceID, (err) => { if (typeof (err) == 'undefined') { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success!!'); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -181,6 +222,9 @@ describe('VideoPlayerFuncCallbackTest', function () { expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); console.info('case prepare success!!'); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -189,7 +233,6 @@ describe('VideoPlayerFuncCallbackTest', function () { eventEmitter.on(SRC_PREPARE_EVENT, (videoPlayer, steps, done) => { steps.shift(); - videoPlayer.fdSrc = fileDescriptor; videoPlayer.prepare((err) => { if (typeof (err) == 'undefined') { expect(videoPlayer.state).assertEqual('prepared'); @@ -198,6 +241,9 @@ describe('VideoPlayerFuncCallbackTest', function () { expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); console.info('case prepare success!!'); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -212,8 +258,11 @@ describe('VideoPlayerFuncCallbackTest', function () { printfDescription(arrlist[i]); } toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { - printfError(err, done); + printfError(err, done); } }); }); @@ -229,6 +278,9 @@ describe('VideoPlayerFuncCallbackTest', function () { let endTime = videoPlayer.currentTime; expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -242,6 +294,9 @@ describe('VideoPlayerFuncCallbackTest', function () { expect(videoPlayer.state).assertEqual('paused'); console.info('case pause success!!'); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -255,6 +310,9 @@ describe('VideoPlayerFuncCallbackTest', function () { expect(videoPlayer.state).assertEqual('stopped'); console.info('case stop success!!'); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -268,6 +326,9 @@ describe('VideoPlayerFuncCallbackTest', function () { expect(videoPlayer.state).assertEqual('idle'); console.info('case reset success!!'); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -280,6 +341,9 @@ describe('VideoPlayerFuncCallbackTest', function () { if (typeof (err) == 'undefined') { console.info('case release success!!'); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -290,20 +354,20 @@ describe('VideoPlayerFuncCallbackTest', function () { switch (seekMode) { case media.SeekMode.SEEK_NEXT_SYNC: if (seekTime == 0) { - expect(seekDoneTime).assertEqual(0); + expect(seekDoneTime + DELTA_SEEK_TIME).assertClose(DELTA_SEEK_TIME, DELTA_SEEK_TIME); } else if (seekTime == DURATION_TIME) { - expect(seekDoneTime).assertEqual(DURATION_TIME); + expect(seekDoneTime).assertClose(DURATION_TIME, DELTA_SEEK_TIME); } else { - expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME); + expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_SEEK_TIME); } break; case media.SeekMode.SEEK_PREV_SYNC: if (seekTime == 0) { - expect(seekDoneTime).assertEqual(0); + expect(seekDoneTime + DELTA_SEEK_TIME).assertClose(DELTA_SEEK_TIME, DELTA_SEEK_TIME); } else if (seekTime == DURATION_TIME) { - expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME); + expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_SEEK_TIME); } else { - expect(seekDoneTime).assertEqual(PREV_FRAME_TIME); + expect(seekDoneTime).assertClose(PREV_FRAME_TIME, DELTA_SEEK_TIME); } break; default: @@ -323,6 +387,9 @@ describe('VideoPlayerFuncCallbackTest', function () { checkSeekTime(media.SeekMode.SEEK_PREV_SYNC, seekTime, seekDoneTime); console.info('case seek success and seekDoneTime is '+ seekDoneTime); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -343,6 +410,9 @@ describe('VideoPlayerFuncCallbackTest', function () { checkSeekTime(seekMode, seekTime, seekDoneTime); console.info('case seek success and seekDoneTime is '+ seekDoneTime); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -357,6 +427,9 @@ describe('VideoPlayerFuncCallbackTest', function () { if (typeof (err) == 'undefined') { console.info('case setVolume success'); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -400,6 +473,9 @@ describe('VideoPlayerFuncCallbackTest', function () { console.info('case setSpeed success and speedMode is '+ speedMode); checkSpeedTime(videoPlayer, speedValue, startTime); toNextStep(videoPlayer, steps, done); + } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + steps.shift(); + toNextStep(videoPlayer, steps, done); } else { printfError(err, done); } @@ -407,425 +483,229 @@ describe('VideoPlayerFuncCallbackTest', function () { }); /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0100 - * @tc.name : 001.play (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.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0300', 0, async function (done) { - isFileOpen(fileDescriptor, done); - let videoPlayer = null; - let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, - PAUSE_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT); - eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0400 - * @tc.name : 004.stop (callback) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETSOURCE + * @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_0400', 0, async function (done) { + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SETSOURCE', 0, async function (done) { isFileOpen(fileDescriptor, done); let videoPlayer = null; - let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, - PLAY_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT); + let fdPath = ''; + let mySteps = new Array(CREATE_EVENT, SETSOURCE_EVENT, fdPath, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0500 - * @tc.name : 005.reset (callback) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETVOLUME + * @tc.name : 001.test SetVolume 0/0.5/1 (callback) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test * @tc.level : Level0 */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0500', 0, async function (done) { + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETVOLUME', 0, async function (done) { isFileOpen(fileDescriptor, done); let videoPlayer = null; - let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, - PLAY_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT); - eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_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); }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0600 - * @tc.name : 006.seek (callback) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETSPEED + * @tc.name : 001.test SetSpeed 0.75/1/1.25/1.75/2 (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) { + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SETSPEED', 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); + let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT, + PREPARE_EVENT, PLAY_EVENT, SETSPEED_EVENT, media.PlaybackSpeed.SPEED_FORWARD_0_75_X, + 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); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0700 - * @tc.name : 007.seek mode(callback) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SEEKMODE + * @tc.name : 001.test seek mode SEEK_PREV_SYNC/SEEK_NEXT_SYNC (callback) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test * @tc.level : Level0 */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0700', 0, async function (done) { + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SEEKMODE', 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, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC, + let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT, + PREPARE_EVENT, PLAY_EVENT, SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC, SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC,RELEASE_EVENT, END_EVENT); - eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0800 - * @tc.name : 008.setVolume (callback) - * @tc.desc : Video playback control test - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0800', 0, async function (done) { - isFileOpen(fileDescriptor, done); - let videoPlayer = null; - let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, - SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT); - eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0900 - * @tc.name : 009.setSpeed (callback) - * @tc.desc : Video playback control test - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0900', 0, async function (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); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1000 - * @tc.name : 010.getTrackDescription (callback) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_CALLBACK + * @tc.name : 001.test callback bufferingUpdate/videoSizeChanged/startRenderFrame/playbackCompleted * @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) { + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_CALLBACK', 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); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1800 - * @tc.name : 018.play->stop->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_1800', 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, RELEASE_EVENT, END_EVENT); - eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1900 - * @tc.name : 019.play->stop->reset->prepare->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_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); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2000 - * @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); - }) + let frameCount = -1; + let completedCount = 0; + let widthValue = -1; + let heightValue = -1; + + eventEmitter.on('test_create', () => { + media.createVideoPlayer((err, video) => { + if (typeof (video) != 'undefined') { + videoPlayer = video; + expect(videoPlayer.state).assertEqual('idle'); + console.info('case createVideoPlayer success!!'); + eventEmitter.emit('test_callback'); + }else { + printfError(err, done); + } + }); + }); - /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2100 - * @tc.name : 021.play->seek(0, mode)->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_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_callback', () => { + videoPlayer.on('playbackCompleted', async () => { + console.info('case playbackCompleted success'); + completedCount++; + expect(widthValue).assertEqual(WIDTH_VALUE); + expect(heightValue).assertEqual(HEIGHT_VALUE); + expect(completedCount).assertEqual(1); + videoPlayer.release((err) => { + if (typeof (err) == 'undefined') { + console.info('case release success!!'); + done(); + } else { + printfError(err, 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'); + }); + + videoPlayer.on('videoSizeChanged', (width, height) => { + console.info('case videoSizeChanged success'); + widthValue = width; + heightValue = height; + }); + eventEmitter.emit('test_setSurface'); + }); - /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2200 - * @tc.name : 022.play->seek(duration)->finish (callback) - * @tc.desc : Video playback control test - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level1 - */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2200', 0, async function (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_setSurface', () => { + videoPlayer.url = fdHead + fileDescriptor.fd; + videoPlayer.setDisplaySurface(surfaceID, (err) => { + if (typeof (err) == 'undefined') { + expect(videoPlayer.state).assertEqual('idle'); + console.info('case setDisplaySurface success!!'); + eventEmitter.emit('test_prepare'); + }else { + printfError(err, done); + } + }) + }); - /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2300 - * @tc.name : 023.play->seek(duration, mode)->finish (callback) - * @tc.desc : Video playback control test - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level1 - */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2300', 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, 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_prepare', () => { + videoPlayer.prepare((err) => { + if (typeof (err) == 'undefined') { + 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 success!!'); + eventEmitter.emit('test_play'); + } else { + printfError(err, done); + } + }); + }); - /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2400 - * @tc.name : 024.play->seek(out of duration) (callback) - * @tc.desc : Video playback control test - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level2 - */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2400', 0, async function (done) { - isFileOpen(fileDescriptor, done); - let videoPlayer = null; - 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); + eventEmitter.on('test_play', () => { + videoPlayer.play((err) => { + if (typeof (err) == 'undefined') { + expect(videoPlayer.state).assertEqual('playing'); + console.info('case play success!!'); + } else { + printfError(err, done); + } + }); + }); + eventEmitter.emit('test_create'); }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2500 - * @tc.name : 025.play->seek(out of duration, mode) (callback) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_GETTRECKDESCRIPTION + * @tc.name : 001.test getTrackDescription (callback) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test - * @tc.level : 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); let videoPlayer = null; - let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, - SEEK_MODE_EVENT, DURATION_TIME + 1, media.SeekMode.SEEK_PREV_SYNC, - SEEK_MODE_EVENT, DURATION_TIME + 1, media.SeekMode.SEEK_NEXT_SYNC, RELEASE_EVENT, END_EVENT); - eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT, + PREPARE_EVENT, GETDESCRIPTION, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2600 - * @tc.name : 026. play->setvolume(0~1) (callback) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_LOOP + * @tc.name : 001.test LOOP (callback) * @tc.desc : Video playback control test * @tc.size : MediumTest * @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); let videoPlayer = null; - let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, - SETVOLUME_EVENT, 0, SETVOLUME_EVENT, 0.2, SETVOLUME_EVENT, 0.4, SETVOLUME_EVENT, 0.6, - SETVOLUME_EVENT, 0.8, SETVOLUME_EVENT, 1, RELEASE_EVENT, END_EVENT); - eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT, + PREPARE_EVENT, SETLOOP_EVENT, true, PLAY_EVENT, SEEK_EVENT, DURATION_TIME, WAIT_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); }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2700 - * @tc.name : 027.play->setspeed(0~4) (callback) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_BASE + * @tc.name : 001.test video playe (callback) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test - * @tc.level : 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); let videoPlayer = null; - let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, - SETSPEED_EVENT, media.PlaybackSpeed.SPEED_FORWARD_2_00_X, RELEASE_EVENT, END_EVENT); - eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + let fdPath = fdHead + fileDescriptor.fd; + let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT, + PREPARE_EVENT, PLAY_EVENT, PAUSE_EVENT, PLAY_EVENT, STOP_EVENT, RESET_EVENT, SETSOURCE_EVENT, fdPath, + PREPARE_EVENT, SETLOOP_EVENT, true, PLAY_EVENT, SEEK_EVENT, DURATION_TIME / 2, SEEK_EVENT, 0, + SEEK_EVENT, DURATION_TIME, WAIT_EVENT, SETLOOP_EVENT, false, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) }) diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js index 2c27bfc3dc2d549db146f10bcb15c3f08d458cf8..c207735a8a8a4aa3101f6ca5e32c849c67bdffa3 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js @@ -28,6 +28,7 @@ describe('VideoPlayerFuncPromiseTest', function () { const DELTA_TIME = 1000; const NEXT_FRAME_TIME = 8333; const PREV_FRAME_TIME = 4166; + const DELTA_SEEK_TIME = 100; let surfaceID = ''; let fdHead = 'fd://'; let fileDescriptor = undefined; @@ -113,109 +114,50 @@ describe('VideoPlayerFuncPromiseTest', function () { } /* * - * @tc.number : SUB_MEDIA_PLAYER_MULTIPLE_0100 - * @tc.name : 001.Multi-instance (2 videoPlayer promise) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SetSource + * @tc.name : 001.setSorce "" (promise) * @tc.desc : Video playback control test * @tc.size : MediumTest * @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); - let testVideoPlayer1 = 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; - + let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { - testVideoPlayer2 = video - console.info('case createVideoPlayer success '); + console.info('case createVideoPlayer success'); + videoPlayer = video; + expect(videoPlayer.state).assertEqual('idle'); } else { console.info('case createVideoPlayer is failed'); expect().assertFail(); } }, failureCallback).catch(catchCallback); - testVideoPlayer2.url = fdHead + fileDescriptor.fd; - await testVideoPlayer2.setDisplaySurface(surfaceID).then(() => { - console.info('case setDisplaySurface success'); - expect(testVideoPlayer2.state).assertEqual('idle'); - }, failureCallback).catch(catchCallback); - - await testVideoPlayer2.prepare().then(() => { - console.info('case prepare called!!'); - expect(testVideoPlayer2.state).assertEqual('prepared'); - expect(testVideoPlayer2.duration).assertEqual(DURATION_TIME); - expect(testVideoPlayer2.width).assertEqual(WIDTH_VALUE); - expect(testVideoPlayer2.height).assertEqual(HEIGHT_VALUE); - }, failureCallback).catch(catchCallback); - - startTime = testVideoPlayer2.currentTime; - await testVideoPlayer2.play().then(() => { - console.info('case play called!!'); - sleep(PLAY_TIME); - expect(testVideoPlayer2.state).assertEqual('playing'); - }, failureCallback).catch(catchCallback); - endTime = testVideoPlayer2.currentTime; - expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); - - await testVideoPlayer2.release().then(() => { - console.info('case release called!!'); - }, failureCallback).catch(catchCallback); - testVideoPlayer2 = null; - done(); + videoPlayer.on('error', async (error) => { + console.info(`case error called,errMessage is ${error.message}`); + await videoPlayer.release().then(() => { + console.info('case release called!!'); + }, failureCallback).catch(catchCallback); + done(); + }); + videoPlayer.url = ""; }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0100 - * @tc.name : 001.play (promise) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SetVolume + * @tc.name : 001.SetVolume 0/0.5/1 (promise) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test * @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); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { - console.info('case createVideoPlayer success'); videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -226,42 +168,49 @@ describe('VideoPlayerFuncPromiseTest', function () { videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { - console.info('case setDisplaySurface success'); expect(videoPlayer.state).assertEqual('idle'); + console.info('case setDisplaySurface success'); }, failureCallback).catch(catchCallback); await videoPlayer.prepare().then(() => { - console.info('case prepare called!!'); 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; + let 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; + let endTime = videoPlayer.currentTime; 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(() => { console.info('case release called!!'); }, failureCallback).catch(catchCallback); - done(); + done(); }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0200 - * @tc.name : 002.pause (promise) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SetSpeed + * @tc.name : 001.SetSpeed 0.75/1/1.25/1.75/2 (promise) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test * @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); let videoPlayer = null; await media.createVideoPlayer().then((video) => { @@ -276,47 +225,87 @@ describe('VideoPlayerFuncPromiseTest', function () { videoPlayer.url = fdHead + fileDescriptor.fd; await videoPlayer.setDisplaySurface(surfaceID).then(() => { - console.info('case setDisplaySurface success'); expect(videoPlayer.state).assertEqual('idle'); + console.info('case setDisplaySurface success'); }, failureCallback).catch(catchCallback); await videoPlayer.prepare().then(() => { - console.info('case prepare called!!'); 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); + sleep(1000); 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!!'); + startTime = videoPlayer.currentTime; + await videoPlayer.setSpeed(media.PlaybackSpeed.SPEED_FORWARD_0_75_X).then((speedMode) => { + 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); await videoPlayer.release().then(() => { console.info('case release called!!'); }, failureCallback).catch(catchCallback); - done(); - }) + done(); + }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0300 - * @tc.name : 003.pause->play (promise) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SeekMode + * @tc.name : 001.seek mode SEEK_PREV_SYNC/SEEK_NEXT_SYNC (promise) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test * @tc.level : Level0 */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0300', 0, async function (done) { + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SeekMode', 0, async function (done) { isFileOpen(fileDescriptor, done); let videoPlayer = null; await media.createVideoPlayer().then((video) => { @@ -352,37 +341,63 @@ describe('VideoPlayerFuncPromiseTest', function () { 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!!'); + await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_SEEK_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); }, failureCallback).catch(catchCallback); - startTime = videoPlayer.currentTime; - await videoPlayer.play().then(() => { + await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => { expect(videoPlayer.state).assertEqual('playing'); - console.info('case play called!!'); - sleep(PLAY_TIME); + expect(seekDoneTime).assertClose(PREV_FRAME_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 + 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); - endTime = videoPlayer.currentTime; - expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); await videoPlayer.release().then(() => { console.info('case release called!!'); }, failureCallback).catch(catchCallback); - done(); + done(); }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0400 - * @tc.name : 004.stop (promise) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Callback + * @tc.name : 001.test callback bufferingUpdate/videoSizeChanged/startRenderFrame/playbackCompleted * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test * @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); let videoPlayer = null; + let frameCount = -1; + let completedCount = 0; + let widthValue = -1; + let heightValue = -1; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { videoPlayer = video; @@ -393,6 +408,35 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, 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; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); @@ -407,37 +451,25 @@ describe('VideoPlayerFuncPromiseTest', function () { 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.release().then(() => { - console.info('case release called!!'); - }, failureCallback).catch(catchCallback); - done(); }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0500 - * @tc.name : 005.reset (promise) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_GetTreckDescription + * @tc.name : 001.getTrackDescription (promise) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test - * @tc.level : 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); let videoPlayer = null; + let arrayDescription = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { videoPlayer = video; @@ -456,25 +488,22 @@ describe('VideoPlayerFuncPromiseTest', function () { 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'); + 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); - let endTime = videoPlayer.currentTime; - expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); - await videoPlayer.reset().then(() => { - expect(videoPlayer.state).assertEqual('idle'); - console.info('case reset called!!'); - }, failureCallback).catch(catchCallback); + for (let i = 0; i < arrayDescription.length; i++) { + printfDescription(arrayDescription[i]); + } await videoPlayer.release().then(() => { console.info('case release called!!'); @@ -483,16 +512,17 @@ describe('VideoPlayerFuncPromiseTest', function () { }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0600 - * @tc.name : 006.seek (promise) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Loop + * @tc.name : 001.Loop true (promise) * @tc.desc : Video playback control test * @tc.size : MediumTest * @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); let videoPlayer = null; + let bufferCount = 0; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { videoPlayer = video; @@ -503,6 +533,22 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, 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; await videoPlayer.setDisplaySurface(surfaceID).then(() => { expect(videoPlayer.state).assertEqual('idle'); @@ -510,6 +556,7 @@ describe('VideoPlayerFuncPromiseTest', function () { }, 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); @@ -519,6 +566,7 @@ describe('VideoPlayerFuncPromiseTest', function () { 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'); @@ -526,31 +574,32 @@ describe('VideoPlayerFuncPromiseTest', function () { let endTime = videoPlayer.currentTime; 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(seekDoneTime).assertClose(DURATION_TIME, DELTA_SEEK_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, failureCallback).catch(catchCallback); + sleep(3000); expect(videoPlayer.state).assertEqual('playing'); - expect(seekDoneTime).assertEqual(PREV_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(); + } + videoPlayer.loop = false; }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0700 - * @tc.name : 007.seek CLOSEST(promise) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_BASE + * @tc.name : 001.test video playe (promise) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test * @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); let videoPlayer = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { + console.info('case createVideoPlayer success'); videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -559,18 +608,26 @@ describe('VideoPlayerFuncPromiseTest', function () { } }, 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; await videoPlayer.setDisplaySurface(surfaceID).then(() => { - expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success'); + expect(videoPlayer.state).assertEqual('idle'); }, failureCallback).catch(catchCallback); await videoPlayer.prepare().then(() => { + console.info('case prepare called!!'); 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; @@ -582,1337 +639,149 @@ describe('VideoPlayerFuncPromiseTest', function () { let endTime = videoPlayer.currentTime; expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); - await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { - expect(videoPlayer.state).assertEqual('playing'); - expect(seekDoneTime).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('playing'); - expect(seekDoneTime).assertEqual(PREV_FRAME_TIME); - console.info('case seek called and seekDoneTime is' + seekDoneTime); + await videoPlayer.pause().then(() => { + expect(videoPlayer.state).assertEqual('paused'); + console.info('case pause called!!'); }, failureCallback).catch(catchCallback); - await videoPlayer.seek(PREV_FRAME_TIME - 100, 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(seekDoneTime).assertEqual(0); - 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).assertEqual(PREV_FRAME_TIME); - console.info('case seek called and seekDoneTime is' + seekDoneTime); + await videoPlayer.stop().then(() => { + console.info('case stop called!!'); + expect(videoPlayer.state).assertEqual('stopped'); }, 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); + await videoPlayer.reset().then(() => { + console.info('case reset called!!'); + expect(videoPlayer.state).assertEqual('idle'); }, 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; - 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, 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, 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_2400 - * @tc.name : 024.play->seek(out of duration) (promise) - * @tc.desc : Video playback control test - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level2 - */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2400', 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; + videoPlayer.loop = true; + 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; + endTime = videoPlayer.currentTime; expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); - await videoPlayer.seek(DURATION_TIME + 1).then((seekDoneTime) => { + await videoPlayer.seek(videoPlayer.duration / 2).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(); - }) - - /* * - * @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) => { - 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'); + console.info('case seek called and seekDoneTime is' + seekDoneTime); }, 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) => { + await videoPlayer.seek(0).then((seekDoneTime) => { expect(videoPlayer.state).assertEqual('playing'); - expect(seekDoneTime).assertEqual(NEXT_FRAME_TIME); + sleep(PLAY_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) => { + await videoPlayer.seek(videoPlayer.duration).then((seekDoneTime) => { expect(videoPlayer.state).assertEqual('playing'); - expect(seekDoneTime).assertEqual(DURATION_TIME); + sleep(PLAY_TIME); console.info('case seek called and seekDoneTime is' + seekDoneTime); }, failureCallback).catch(catchCallback); + videoPlayer.loop = false; }) /* * - * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2600 - * @tc.name : 026. play->setvolume(0~1) (promise) + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_MULTIPLE + * @tc.name : 001.Multi-instance (2 videoPlayer promise) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test * @tc.level : Level2 */ - it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_2600', 0, async function (done) { + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_MULTIPLE', 0, async function (done) { isFileOpen(fileDescriptor, done); - let videoPlayer = null; + let testVideoPlayer1 = null; + let testVideoPlayer2 = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { - videoPlayer = video; - expect(videoPlayer.state).assertEqual('idle'); + console.info('case createVideoPlayer success'); + testVideoPlayer1 = video; + expect(testVideoPlayer1.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'); + testVideoPlayer1.url = fdHead + fileDescriptor.fd; + await testVideoPlayer1.setDisplaySurface(surfaceID).then(() => { console.info('case setDisplaySurface success'); + expect(testVideoPlayer1.state).assertEqual('idle'); }, 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); - - for (let i = 0; i < 6; i++) { - await videoPlayer.setVolume(i * 0.2).then(() => { - expect(videoPlayer.state).assertEqual('playing'); - console.info('case setVolume called'); - }, failureCallback).catch(catchCallback); - } + await toNewPage(page); + page = (page + 1) % 2; + await msleep(1000).then(() => {}, failureCallback).catch(catchCallback); + surfaceID = globalThis.value; - await videoPlayer.release().then(() => { - console.info('case release called!!'); - }, failureCallback).catch(catchCallback); - done(); - }) + for (let i = 0; i < 3; i++) { + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + console.info('case createVideoPlayer success'); + testVideoPlayer2 = video; + expect(testVideoPlayer2.state).assertEqual('idle'); + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, failureCallback).catch(catchCallback); + testVideoPlayer2.url = fdHead + fileDescriptor.fd; + await testVideoPlayer2.setDisplaySurface(surfaceID).then(() => { + console.info('case setDisplaySurface success'); + expect(testVideoPlayer2.state).assertEqual('idle'); + }, failureCallback).catch(catchCallback); - /* * - * @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.prepare().then(() => { + console.info('case prepare called!!'); + expect(testVideoPlayer1.state).assertEqual('prepared'); + }, 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 testVideoPlayer1.play().then(() => { + console.info('case play called!!'); + expect(testVideoPlayer1.state).assertEqual('playing'); + }, 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); + await testVideoPlayer2.prepare().then(() => { + console.info('case prepare called!!'); + expect(testVideoPlayer2.state).assertEqual('prepared'); + }, 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); + await testVideoPlayer2.play().then(() => { + console.info('case play called!!'); + expect(testVideoPlayer2.state).assertEqual('playing'); + }, 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); + sleep(PLAY_TIME); + await testVideoPlayer1.reset().then(() => { + console.info('case reset called!!'); + expect(testVideoPlayer1.state).assertEqual('idle'); + }, failureCallback).catch(catchCallback); + testVideoPlayer1.url = fdHead + fileDescriptor.fd; - await videoPlayer.release().then(() => { + await testVideoPlayer2.release().then(() => { + console.info('case release called!!'); + }, failureCallback).catch(catchCallback); + } + await testVideoPlayer1.release().then(() => { console.info('case release called!!'); }, failureCallback).catch(catchCallback); - done(); + done(); }) }) diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerTestBase.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerTestBase.js index f2680a7975c2d0aa8194762b0e0c1443aac5213c..e1c67d344c5d59918436d7c47fd7b1d9193243f1 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerTestBase.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerTestBase.js @@ -20,7 +20,7 @@ export async function toNewPage(page) { if (page == 0) { path = 'pages/surfaceTest/surfaceTest'; } else { - path = 'pages/surfaceTest/surfaceTest2'; + path = 'pages/surfaceTest2/surfaceTest2'; } let options = { uri: path,