diff --git a/multimedia/media/media_js_standard/AudioPlayerTestBase.js b/multimedia/media/media_js_standard/AudioPlayerTestBase.js index f9dc9e2988d2e193bdcaa92d2c659eccbcbf2b90..a67be4e0185ffcf489d0fc9956f4fcd5ac879bd9 100644 --- a/multimedia/media/media_js_standard/AudioPlayerTestBase.js +++ b/multimedia/media/media_js_standard/AudioPlayerTestBase.js @@ -39,7 +39,7 @@ export function playAudioSource(src, duration, playTime, checkSeekTime, done) { } audioPlayer.on('dataLoad', () => { console.info('case set source success'); - expect(audioPlayer.state).assertEqual('paused'); + expect(audioPlayer.state).assertEqual('idle'); expect(audioPlayer.currentTime).assertEqual(0); expect(audioPlayer.duration).assertClose(duration, 500); // step 0: dataLoad -> play diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js index 41eaaa1233c27ded6a2fce916b42e37ba26931dc..3e42214faf3f65630dec741d536fa1fbb9225a91 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioAPI.test.js @@ -148,7 +148,7 @@ describe('PlayerLocalTestAudioAPI', function () { console.info(`case dataLoad called`); expect(audioPlayer.currentTime).assertEqual(0); expect(audioPlayer.duration).assertEqual(DURATION_TIME); - expect(audioPlayer.state).assertEqual('paused'); + expect(audioPlayer.state).assertEqual('idle'); nextStep(mySteps,done); }); audioPlayer.on('play', () => { @@ -735,7 +735,7 @@ describe('PlayerLocalTestAudioAPI', function () { expect(audioPlayer.src).assertEqual(fdHead + fileDescriptor.fd); expect(audioPlayer.currentTime).assertEqual(0); expect(audioPlayer.duration).assertEqual(DURATION_TIME); - expect(audioPlayer.state).assertEqual('paused'); + expect(audioPlayer.state).assertEqual('idle'); expect(audioPlayer.loop).assertEqual(false); done(); }) diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js index 6f980be5d84227152480c1d293b14a40111a646d..2c0c5d1eba05d036778db157c11a8e6c7ca543ea 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFUNC.test.js @@ -194,7 +194,7 @@ describe('PlayerLocalTestAudioFUNC', function () { console.info(`case dataLoad called`); expect(audioPlayer.currentTime).assertEqual(0); expect(audioPlayer.duration).assertEqual(DURATION_TIME); - expect(audioPlayer.state).assertEqual('paused'); + expect(audioPlayer.state).assertEqual('idle'); nextStep(mySteps, done); }); audioPlayer.on('play', () => { @@ -316,7 +316,40 @@ describe('PlayerLocalTestAudioFUNC', function () { VOLUME_STATE, MAX_VOLUME, RESET_STATE, RELEASE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); - audioPlayer.src = fdPath; + audioPlayer.src = fdPath; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_SEEK + * @tc.name : 001.test seek mode 0 / 0.5 * duration/ duration + * @tc.desc : Audio playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_SEEK', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, SEEK_STATE, + DURATION_TIME / 2, SEEK_STATE, DURATION_TIME, FINISH_STATE, RELEASE_STATE, END_STATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = fdHead + fileDescriptor.fd; + }) + + /* * + * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_GETTRECKDESCRIPTION + * @tc.name : 001.test getTrackDescription + * @tc.desc : Audio playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_GETTRECKDESCRIPTION', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let mySteps = new Array(SRC_STATE, GETDESCRIPTION_PROMISE, GETDESCRIPTION_CALLBACK, RELEASE_STATE, END_STATE); + initAudioPlayer(); + setCallback(mySteps, done); + audioPlayer.src = fdHead + fileDescriptor.fd; }) /* * @@ -342,7 +375,7 @@ describe('PlayerLocalTestAudioFUNC', function () { testAudioPlayer.on('dataLoad', () => { expect(testAudioPlayer.duration).assertEqual(DURATION_TIME); - expect(testAudioPlayer.state).assertEqual('paused'); + expect(testAudioPlayer.state).assertEqual('idle'); testAudioPlayer.play(); }); testAudioPlayer.on('play', () => { diff --git a/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js b/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js index 7969e22b779b93029f640a05eec436c5638d9664..1b554a13de677c468e054fe535990f21dcd484d7 100644 --- a/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js +++ b/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js @@ -18,7 +18,7 @@ import * as mediaTestBase from '../../../../../MediaTestBase.js'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' describe('RecorderLocalTestAudioAPI', function () { - let audioRecorder = media.createAudioRecorder(); + let audioRecorder = null; const END_STATE = 0; const PRE_STATE = 1; const START_STATE = 2; @@ -42,9 +42,9 @@ describe('RecorderLocalTestAudioAPI', function () { fileFormat : media.ContainerFormatType.CFT_MPEG_4A, } function initAudioRecorder() { - if (typeof (audioRecorder) != 'undefined') { + if (audioRecorder != null) { audioRecorder.release(); - audioRecorder = undefined; + audioRecorder = null; } audioRecorder = media.createAudioRecorder(); } @@ -83,7 +83,7 @@ describe('RecorderLocalTestAudioAPI', function () { case RELEASE_STATE: console.info('case to release'); audioRecorder.release(); - audioRecorder = undefined; + audioRecorder = null; break; case ERROR_STATE: console.info('case to wait error callback'); @@ -138,9 +138,7 @@ describe('RecorderLocalTestAudioAPI', function () { nextStep(mySteps,done); }); audioRecorder.on('error', (err) => { - console.info(`case error called,errName is ${err.name}`); console.info(`case error called,errCode is ${err.code}`); - console.info(`case error called,errMessage is ${err.message}`); mySteps.shift(); expect(mySteps[0]).assertEqual(ERROR_STATE); mySteps.shift(); @@ -168,36 +166,6 @@ describe('RecorderLocalTestAudioAPI', function () { console.info('afterAll case'); }) - /* * - * @tc.number : SUB_MEDIA_RECORDER_createAudioRecorder_API_0100 - * @tc.name : Create an AudioRecoder Object by function of createAudioRecorder - * @tc.desc : Reliability Test - * @tc.size : MediumTest - * @tc.type : Reliability - * @tc.level : Level2 - */ - it('SUB_MEDIA_RECORDER_createAudioRecorder_API_0100', 0, async function (done) { - let testAudioRecorder = undefined; - testAudioRecorder= media.createAudioRecorder(); - expect(testAudioRecorder != undefined).assertTrue(); - done(); - }) - - /* * - * @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0100 - * @tc.name : 01.creatAudioRecorder->prepare - * @tc.desc : Reliability Test - * @tc.size : MediumTest - * @tc.type : Reliability - * @tc.level : Level2 - */ - it('SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0100', 0, async function (done) { - let testAudioRecorder= media.createAudioRecorder(); - expect(testAudioRecorder != null).assertTrue(); - testAudioRecorder.prepare(audioConfig); - done(); - }) - /* * * @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0200 * @tc.name : 02.start->prepare @@ -1000,7 +968,7 @@ describe('RecorderLocalTestAudioAPI', function () { let mySteps = new Array(RELEASE_STATE, END_STATE); setCallback(mySteps, done); audioRecorder.release(); - audioRecorder = undefined; + audioRecorder = null; }) /* * diff --git a/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js b/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js index 8e38182136b68c2c79e861daacfb4aa0cf43b83e..e207d7f068a4079231cd8679dc86473de941fa2a 100644 --- a/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js +++ b/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js @@ -19,7 +19,7 @@ import * as videoRecorderBase from '../../../../../VideoRecorderTestBase.js'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' describe('RecorderLocalTestAudioFUNC', function () { - let audioRecorder = media.createAudioRecorder(); + let audioRecorder = null; const END_STATE = 0; const PRE_STATE = 1; const START_STATE = 2; @@ -52,9 +52,9 @@ describe('RecorderLocalTestAudioFUNC', function () { } function initAudioRecorder() { - if (typeof (audioRecorder) != 'undefined') { + if (audioRecorder != null) { audioRecorder.release(); - audioRecorder = undefined; + audioRecorder = null; } audioRecorder = media.createAudioRecorder(); } @@ -110,7 +110,7 @@ describe('RecorderLocalTestAudioFUNC', function () { case RELEASE_STATE: console.info('case to release'); audioRecorder.release(); - audioRecorder = undefined; + audioRecorder = null; break; case CHECK_STATE: mySteps.shift(); @@ -174,9 +174,7 @@ describe('RecorderLocalTestAudioFUNC', function () { nextStep(mySteps, done); }); audioRecorder.on('error', (err) => { - console.info(`case error called,errName is ${err.name}`); console.info(`case error called,errCode is ${err.code}`); - console.info(`case error called,errMessage is ${err.message}`); mySteps.shift(); expect(mySteps[0]).assertEqual(ERROR_STATE); mySteps.shift(); @@ -345,7 +343,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.type : Function * @tc.level : Level0 */ - it('SUB_MEDIA_RECORDER_CODEC_AAC_0340', 0, async function (done) { + it('SUB_MEDIA_RECORDER_CODEC_AAC_0350', 0, async function (done) { fdObject = await mediaTestBase.getAudioFd('audio_08.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; 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 01187ad8efbcf1f9d263c8cde2cbe72c50c073ad..f00a60905b5a67c82b6c62e917eb0e631e37759a 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 @@ -40,6 +40,7 @@ describe('VideoPlayerAPICallbackTest', function () { const SEEK_MODE_EVENT = 'seekMode'; const SETVOLUME_EVENT = 'volume'; const SETSPEED_EVENT = 'speed'; + const FINISH_EVENT = 'finish'; const ERROR_EVENT = 'error'; const END_EVENT = 'end'; const VOLUME_VALUE = 1; @@ -105,6 +106,7 @@ describe('VideoPlayerAPICallbackTest', function () { function setOnCallback(videoPlayer, steps, done) { videoPlayer.on('playbackCompleted', () => { console.info('case playbackCompleted success'); + toNextStep(videoPlayer, steps, done); }); videoPlayer.on('bufferingUpdate', (infoType, value) => { @@ -381,6 +383,11 @@ describe('VideoPlayerAPICallbackTest', function () { }); }); + eventEmitter.on(FINISH_EVENT, (videoPlayer, steps, done) => { + steps.shift(); + console.info('case wait for playbackCompleted'); + }); + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_fdSrc_CALLBACK_0100 * @tc.name : fd is wrong @@ -641,6 +648,22 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_PREPARE_CALLBACK_1300 + * @tc.name : 13.finish -> prepare + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MEDIA_VIDEO_PLAYER_PREPARE_CALLBACK_1300', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, + SEEK_EVENT, DURATION_TIME, FINISH_EVENT, PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_PLAY_CALLBACK_0100 * @tc.name : 01.create->play @@ -832,6 +855,22 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_PLAY_CALLBACK_1300 + * @tc.name : 13.finish -> play + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MEDIA_VIDEO_PLAYER_PLAY_CALLBACK_1300', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, + SEEK_EVENT, DURATION_TIME, FINISH_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_PAUSE_CALLBACK_0100 * @tc.name : 01.create->pause @@ -1024,6 +1063,23 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_PAUSE_CALLBACK_1300 + * @tc.name : 13.finish -> pause + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MEDIA_VIDEO_PLAYER_PAUSE_CALLBACK_1300', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, + SEEK_EVENT, DURATION_TIME, FINISH_EVENT, PAUSE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_STOP_CALLBACK_0100 * @tc.name : 001.create->stop @@ -1211,8 +1267,24 @@ describe('VideoPlayerAPICallbackTest', function () { mediaTestBase.isFileOpen(fileDescriptor, done); let videoPlayer = null; let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, - PREPARE_EVENT, PLAY_EVENT, STOP_EVENT, - STOP_EVENT, ERROR_EVENT, STOP_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); + PREPARE_EVENT, PLAY_EVENT, STOP_EVENT, STOP_EVENT, ERROR_EVENT, + STOP_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_STOP_CALLBACK_1300 + * @tc.name : 13.finish -> stop + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MEDIA_VIDEO_PLAYER_STOP_CALLBACK_1300', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, + SEEK_EVENT, DURATION_TIME, FINISH_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) @@ -1403,7 +1475,25 @@ describe('VideoPlayerAPICallbackTest', function () { mediaTestBase.isFileOpen(fileDescriptor, done); let videoPlayer = null; let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, - PREPARE_EVENT, RESET_EVENT, RESET_EVENT, ERROR_EVENT, RESET_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); + PREPARE_EVENT, RESET_EVENT, RESET_EVENT, ERROR_EVENT, + RESET_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_RESET_CALLBACK_1300 + * @tc.name : 13.finish -> reset + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MEDIA_VIDEO_PLAYER_RESET_CALLBACK_1300', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, + SEEK_EVENT, DURATION_TIME, FINISH_EVENT, RESET_EVENT, SETURL_EVENT, + PREPARE_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) @@ -1597,6 +1687,22 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_RELEASE_CALLBACK_1300 + * @tc.name : 13.finish -> RELEASE + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MEDIA_VIDEO_PLAYER_RELEASE_CALLBACK_1300', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, + SEEK_EVENT, DURATION_TIME, FINISH_EVENT, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_SEEK_CALLBACK_0100 * @tc.name : 01.create->seek @@ -1758,6 +1864,23 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_SEEK_CALLBACK_1100 + * @tc.name : 11.seek 3 times + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MEDIA_VIDEO_PLAYER_SEEK_CALLBACK_1100', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, + PREPARE_EVENT, PLAY_EVENT, SEEK_EVENT, SEEK_TIME, SEEK_EVENT, SEEK_TIME, + SEEK_EVENT, SEEK_TIME, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_SEEK_CALLBACK_1300 * @tc.name : 13.seek(-1) @@ -1790,6 +1913,22 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_SEEK_CALLBACK_1500 + * @tc.name : 13.finish -> seek + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MEDIA_VIDEO_PLAYER_SEEK_CALLBACK_1500', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, + SEEK_EVENT, DURATION_TIME, FINISH_EVENT, SEEK_EVENT, 0, ERROR_EVENT, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_CALLBACK_0100 * @tc.name : 01.create->setvolume @@ -2000,6 +2139,22 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_CALLBACK_1500 + * @tc.name : 15.finish -> setvolume + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MEDIA_VIDEO_PLAYER_SETVOLUME_CALLBACK_1500', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, + SEEK_EVENT, DURATION_TIME, FINISH_EVENT, SETVOLUME_EVENT, 1, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_SETSPEED_CALLBACK_0100 * @tc.name : 01.create->setspeed @@ -2211,5 +2366,21 @@ describe('VideoPlayerAPICallbackTest', function () { PREPARE_EVENT, PLAY_EVENT, SETSPEED_EVENT, 5, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) + + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_SETSPEED_CALLBACK_1500 + * @tc.name : 15.finish -> setspeed + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function + * @tc.level : Level2 + */ + it('SUB_MEDIA_VIDEO_PLAYER_SETSPEED_CALLBACK_1500', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETURL_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, + SEEK_EVENT, DURATION_TIME, FINISH_EVENT, SETSPEED_EVENT, 4, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) }) } 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 2b35768f2f22136d7cdc5fd819755282488105cb..105a6849d31b73392bfedc826fbac47b1e4d93ee 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 @@ -522,6 +522,23 @@ describe('VideoPlayerFuncCallbackTest', function () { eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SEEKMODE + * @tc.name : 001.test seek mode SEEK_PREV_SYNC/SEEK_NEXT_SYNC (callback) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_SEEKMODE', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT, + PREPARE_EVENT, PLAY_EVENT, SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC, + SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC,RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_CALLBACK * @tc.name : 001.test callback bufferingUpdate/videoSizeChanged/startRenderFrame/playbackCompleted @@ -628,6 +645,22 @@ describe('VideoPlayerFuncCallbackTest', function () { eventEmitter.emit('test_create'); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_GETTRECKDESCRIPTION + * @tc.name : 001.test getTrackDescription (callback) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_GETTRECKDESCRIPTION', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT, + PREPARE_EVENT, GETDESCRIPTION, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_LOOP * @tc.name : 001.test LOOP (callback) @@ -645,5 +678,24 @@ describe('VideoPlayerFuncCallbackTest', function () { SEEK_EVENT, DURATION_TIME, WAIT_EVENT, SETLOOP_EVENT, false, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) + + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_BASE + * @tc.name : 001.test video playe (callback) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_BASE', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let fdPath = fdHead + fileDescriptor.fd; + let mySteps = new Array(CREATE_EVENT, SETFDSOURCE_EVENT, fileDescriptor, SETSURFACE_EVENT, + PREPARE_EVENT, PLAY_EVENT, PAUSE_EVENT, PLAY_EVENT, STOP_EVENT, RESET_EVENT, SETSOURCE_EVENT, fdPath, + PREPARE_EVENT, SETLOOP_EVENT, true, PLAY_EVENT, SEEK_EVENT, DURATION_TIME / 2, SEEK_EVENT, 0, + SEEK_EVENT, DURATION_TIME, WAIT_EVENT, SETLOOP_EVENT, false, RELEASE_EVENT, END_EVENT); + eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); + }) }) } 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 bbe06126cdb12bee92aa456e15805720445fea6e..4143be35d6bcf082fcf44dd9a0236dc68c5a2ae9 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 @@ -22,7 +22,7 @@ export default function VideoPlayerFuncPromiseTest() { describe('VideoPlayerFuncPromiseTest', function () { const VIDEO_SOURCE = 'H264_AAC.mp4'; const AUDIO_SOURCE = '01.mp3'; - const PLAY_TIME = 3000; + const PLAY_TIME = 2000; const SEEK_TIME = 5000; const WIDTH_VALUE = 720; const HEIGHT_VALUE = 480; @@ -76,6 +76,13 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case file fail'); } + function checkTime(actualTime, expectTIme, delteTime) { + console.info('checkTime case actualTime is :' + actualTime + ', expectTIme is :' + expectTIme); + let valueTime = Math.abs(expectTIme - actualTime); + console.info('checkTime case time is :' + valueTime + ', delteTime is :' + delteTime); + expect(valueTime < delteTime).assertEqual(true); + } + function checkSpeedTime(videoPlayer, speedValue, startTime) { let newTime = videoPlayer.currentTime; if (videoPlayer.state == 'playing') { @@ -285,6 +292,92 @@ describe('VideoPlayerFuncPromiseTest', function () { done(); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SeekMode + * @tc.name : 001.seek mode SEEK_PREV_SYNC/SEEK_NEXT_SYNC (promise) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_SeekMode', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + videoPlayer = video; + expect(videoPlayer.state).assertEqual('idle'); + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + videoPlayer.url = fdHead + fileDescriptor.fd; + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + expect(videoPlayer.state).assertEqual('idle'); + console.info('case setDisplaySurface success'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.prepare().then(() => { + expect(videoPlayer.state).assertEqual('prepared'); + expect(videoPlayer.duration).assertEqual(DURATION_TIME); + expect(videoPlayer.width).assertEqual(WIDTH_VALUE); + expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); + console.info('case prepare called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + let startTime = videoPlayer.currentTime; + await videoPlayer.play().then(() => { + console.info('case play called!!'); + mediaTestBase.msleep(PLAY_TIME); + expect(videoPlayer.state).assertEqual('playing'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let endTime = videoPlayer.currentTime; + expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); + + await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_SEEK_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(seekDoneTime).assertClose(PREV_FRAME_TIME, DELTA_SEEK_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.seek(PREV_FRAME_TIME - 100, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(seekDoneTime + DELTA_SEEK_TIME).assertClose(DELTA_SEEK_TIME, DELTA_SEEK_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.seek(PREV_FRAME_TIME + 100, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(seekDoneTime).assertClose(PREV_FRAME_TIME, DELTA_SEEK_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.seek(NEXT_FRAME_TIME - 100, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(seekDoneTime).assertClose(NEXT_FRAME_TIME, DELTA_SEEK_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.seek(NEXT_FRAME_TIME + 100, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(seekDoneTime).assertClose(NEXT_FRAME_TIME + 100, DELTA_SEEK_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.release().then(() => { + console.info('case release called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + done(); + }) + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Callback * @tc.name : 001.test callback bufferingUpdate/videoSizeChanged/startRenderFrame/playbackCompleted @@ -360,6 +453,67 @@ describe('VideoPlayerFuncPromiseTest', function () { }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_GetTreckDescription + * @tc.name : 001.getTrackDescription (promise) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level1 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_GetTreckDescription', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + let arrayDescription = null; + let videoTrackKey = new Array('bitrate', 'codec_mime', 'frame_rate', 'height', + 'track_index', 'track_type', 'width'); + let audioTrackKey = new Array('bitrate', 'channel_count', 'codec_mime', 'sample_rate', + 'track_index', 'track_type'); + let videoTrackValue = new Array(1366541, 'video/x-h264', 6000, 480, 0, 1, 720); + let audioTrackValue = new Array(129207, 2, 'audio/mpeg', 44100, 1, 0); + let descriptionKey = new Array(videoTrackKey, audioTrackKey); + let descriptionValue = new Array(videoTrackValue, audioTrackValue); + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + videoPlayer = video; + expect(videoPlayer.state).assertEqual('idle'); + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + videoPlayer.url = fdHead + fileDescriptor.fd; + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + expect(videoPlayer.state).assertEqual('idle'); + console.info('case setDisplaySurface success'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.prepare().then(() => { + expect(videoPlayer.state).assertEqual('prepared'); + console.info('case prepare called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.getTrackDescription().then((arrayList) => { + console.info('case getTrackDescription called!!'); + if (typeof (arrayList) != 'undefined') { + arrayDescription = arrayList; + } else { + console.info('case getTrackDescription is failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + for (let i = 0; i < arrayDescription.length; i++) { + mediaTestBase.checkDescription(arrayDescription[i], descriptionKey[i], descriptionValue[i]); + } + + await videoPlayer.release().then(() => { + console.info('case release called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + done(); + }) + /* * * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_Loop * @tc.name : 001.Loop true (promise) @@ -808,5 +962,266 @@ describe('VideoPlayerFuncPromiseTest', function () { videoPlayer.videoScaleType = -1; }) + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_PARAMETER_0100 + * @tc.name : 001.parameter value after create/reset/release (promise) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_PARAMETER_0100', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + videoPlayer = video; + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + expect(videoPlayer.state).assertEqual('idle'); + expect(videoPlayer.url).assertEqual(''); + expect(videoPlayer.fdSrc.fd).assertEqual(0); + expect(videoPlayer.fdSrc.offset).assertEqual(0); + expect(videoPlayer.fdSrc.length).assertEqual(-1); + expect(videoPlayer.currentTime).assertEqual(-1); + expect(videoPlayer.duration).assertEqual(-1); + expect(videoPlayer.width).assertEqual(0); + expect(videoPlayer.height).assertEqual(0); + expect(videoPlayer.loop).assertEqual(false); + videoPlayer.url = fdPath; + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + expect(videoPlayer.state).assertEqual('idle'); + console.info('case setDisplaySurface success'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + await videoPlayer.prepare().then(() => { + console.info('case prepare success'); + videoPlayer.loop = true; + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + expect(videoPlayer.state).assertEqual('prepared'); + expect(videoPlayer.url).assertEqual(fdPath); + expect(videoPlayer.fdSrc.fd).assertEqual(0); + expect(videoPlayer.fdSrc.offset).assertEqual(0); + expect(videoPlayer.fdSrc.length).assertEqual(-1); + expect(videoPlayer.currentTime).assertEqual(0); + expect(videoPlayer.duration).assertEqual(DURATION_TIME); + expect(videoPlayer.width).assertEqual(WIDTH_VALUE); + expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); + expect(videoPlayer.loop).assertEqual(true); + await videoPlayer.reset().then(() => { + console.info('case reset success'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + expect(videoPlayer.state).assertEqual('idle'); + expect(videoPlayer.fdSrc.fd).assertEqual(0); + expect(videoPlayer.fdSrc.offset).assertEqual(0); + expect(videoPlayer.fdSrc.length).assertEqual(-1); + expect(videoPlayer.currentTime).assertEqual(-1); + expect(videoPlayer.duration).assertEqual(-1); + expect(videoPlayer.loop).assertEqual(false); + await videoPlayer.release().then(() => { + console.info('case release called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + done(); + }) + + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_PARAMETER_0200 + * @tc.name : 002.speed and loop value after finish (promise) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_PARAMETER_0200', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + videoPlayer = video; + expect(videoPlayer.state).assertEqual('idle'); + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + videoPlayer.on('playbackCompleted', async () => { + console.info('case playbackCompleted success'); + expect(videoPlayer.loop).assertEqual(false); + expect(videoPlayer.url).assertEqual(fdPath); + expect(videoPlayer.currentTime).assertEqual(DURATION_TIME); + expect(videoPlayer.duration).assertEqual(DURATION_TIME); + expect(videoPlayer.width).assertEqual(WIDTH_VALUE); + expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); + await videoPlayer.play().then(() => { + expect(videoPlayer.loop).assertEqual(false); + startTime = videoPlayer.currentTime; + console.info('case play called!!'); + mediaTestBase.msleep(PLAY_TIME); + expect(videoPlayer.state).assertEqual('playing'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + endTime = videoPlayer.currentTime; + checkTime(PLAY_TIME * 2, (endTime - startTime), DELTA_TIME); + 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); + mediaTestBase.msleep(PLAY_TIME); + endTime = videoPlayer.currentTime; + console.info('case setSpeed endTime is ' + endTime); + checkTime(PLAY_TIME * 0.75, (endTime - startTime), DELTA_TIME); + console.info('case setSpeed called and speedMode is ' + speedMode); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.release().then(() => { + console.info('case release called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + done(); + }); + + videoPlayer.url = fdPath; + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + expect(videoPlayer.state).assertEqual('idle'); + console.info('case setDisplaySurface success'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.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!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + let startTime = videoPlayer.currentTime; + await videoPlayer.play().then(() => { + expect(videoPlayer.loop).assertEqual(true); + console.info('case play called!!'); + mediaTestBase.msleep(1000); + expect(videoPlayer.state).assertEqual('playing'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let endTime = videoPlayer.currentTime; + checkTime(1000, (endTime - startTime), DELTA_TIME); + + expect(videoPlayer.loop).assertEqual(true); + startTime = videoPlayer.currentTime; + console.info('case startTime is :' + startTime); + 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); + mediaTestBase.msleep(PLAY_TIME); + endTime = videoPlayer.currentTime; + checkTime(PLAY_TIME * 2, (endTime - startTime), DELTA_TIME); + console.info('case setSpeed called and speedMode is ' + speedMode); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + await videoPlayer.seek(SEEK_TIME, media.SeekMode.SEEK_PREV_SYNC).then((seekDoneTime) => { + expect(videoPlayer.state).assertEqual('playing'); + expect(seekDoneTime).assertClose(PREV_FRAME_TIME, DELTA_SEEK_TIME); + console.info('case seek called and seekDoneTime is' + seekDoneTime); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + startTime = videoPlayer.currentTime; + mediaTestBase.msleep(PLAY_TIME); + endTime = videoPlayer.currentTime; + checkTime(PLAY_TIME * 2, (endTime - startTime), DELTA_TIME); + expect(videoPlayer.loop).assertEqual(true); + mediaTestBase.msleep(DURATION_TIME); + expect(videoPlayer.loop).assertEqual(true); + videoPlayer.loop = false; + }) + + /* * + * @tc.number : SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_PARAMETER_0300 + * @tc.name : 003.speed and loop value after reset (promise) + * @tc.desc : Video playback control test + * @tc.size : MediumTest + * @tc.type : Function test + * @tc.level : Level0 + */ + it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_PARAMETER_0300', 0, async function (done) { + mediaTestBase.isFileOpen(fileDescriptor, done); + let videoPlayer = null; + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + videoPlayer = video; + expect(videoPlayer.state).assertEqual('idle'); + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + videoPlayer.on('playbackCompleted', async () => { + console.info('case playbackCompleted success'); + expect(videoPlayer.loop).assertEqual(false); + await videoPlayer.release().then(() => { + console.info('case release called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + done(); + }); + + videoPlayer.url = fdPath; + await videoPlayer.setDisplaySurface(surfaceID).then(() => { + expect(videoPlayer.state).assertEqual('idle'); + console.info('case setDisplaySurface success'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.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!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + + let startTime = videoPlayer.currentTime; + await videoPlayer.play().then(() => { + expect(videoPlayer.loop).assertEqual(true); + console.info('case play called!!'); + mediaTestBase.msleep(1000); + expect(videoPlayer.state).assertEqual('playing'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + let endTime = videoPlayer.currentTime; + checkTime(1000, (endTime - startTime), DELTA_TIME); + + expect(videoPlayer.loop).assertEqual(true); + startTime = videoPlayer.currentTime; + console.info('case startTime is :' + startTime); + 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); + mediaTestBase.msleep(PLAY_TIME); + endTime = videoPlayer.currentTime; + checkTime(PLAY_TIME * 2, (endTime - startTime), DELTA_TIME); + console.info('case setSpeed called and speedMode is ' + speedMode); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + await videoPlayer.reset().then(() => { + expect(videoPlayer.loop).assertEqual(false); + expect(videoPlayer.state).assertEqual('idle'); + expect(videoPlayer.duration).assertEqual(-1); + console.info('case reset called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + videoPlayer.url = fdPath; + await videoPlayer.prepare().then(() => { + expect(videoPlayer.state).assertEqual('prepared'); + expect(videoPlayer.duration).assertEqual(DURATION_TIME); + expect(videoPlayer.width).assertEqual(WIDTH_VALUE); + expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); + console.info('case prepare called!!'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + startTime = videoPlayer.currentTime; + await videoPlayer.play().then(() => { + expect(videoPlayer.loop).assertEqual(false); + console.info('case play called!!'); + mediaTestBase.msleep(PLAY_TIME); + expect(videoPlayer.state).assertEqual('playing'); + }, mediaTestBase.failureCallback).catch(mediaTestBase.catchCallback); + endTime = videoPlayer.currentTime; + checkTime(PLAY_TIME * 2, (endTime - startTime), DELTA_TIME); + }) }) -} +} \ No newline at end of file