From 2ae9dc64c5548933783bd03f9d7f5deccd0122a8 Mon Sep 17 00:00:00 2001 From: fulizhong Date: Tue, 13 Dec 2022 11:37:58 +0800 Subject: [PATCH] modify testcase Signed-off-by: NOBUGGERS Signed-off-by: fulizhong --- .../js/test/PlayerLocalTestAudioAPI.test.js | 21 +++-------- .../js/test/PlayerLocalTestAudioFUNC.test.js | 37 ++++++------------- .../test/PlayerLocalTestAudioFormat.test.js | 4 +- 3 files changed, 17 insertions(+), 45 deletions(-) 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 b9826f289..15c01eb4d 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 @@ -128,6 +128,9 @@ describe('PlayerLocalTestAudioAPI', function () { case SEEK_STATE: console.info(`case seek to time is ${mySteps[SECOND_INDEX]}`); audioPlayer.seek(mySteps[SECOND_INDEX]); + mySteps.shift(); + mySteps.shift(); + nextStep(mySteps, done); break; case VOLUME_STATE: console.info(`case to setVolume`); @@ -206,22 +209,7 @@ describe('PlayerLocalTestAudioAPI', function () { console.info(`case seek filed,errcode is ${seekDoneTime}`); return; } - if (mySteps[0] != SEEK_STATE) { - return; - } - mySteps.shift(); - mySteps.shift(); - console.info(`case seekDoneTime is ${seekDoneTime}`); - console.info(`case seek called`); - expect(audioPlayer.currentTime + DELTA_TIME).assertClose(seekDoneTime + DELTA_TIME, DELTA_TIME); - console.info(`case loop is ${audioPlayer.loop}`); - if ((audioPlayer.loop == true) && (seekDoneTime == DURATION_TIME)) { - console.info('case loop is true'); - sleep(PLAY_STATE); - } - if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == 'paused')) { - nextStep(mySteps,done); - } + console.info(`case timeUpdate, seekDoneTime is ${seekDoneTime}`); }); audioPlayer.on('volumeChange', () => { console.info(`case setvolume called`); @@ -250,6 +238,7 @@ describe('PlayerLocalTestAudioAPI', function () { nextStep(mySteps,done); } else if (mySteps[0] == ERROR_STATE) { mySteps.shift(); + nextStep(mySteps,done); } else if (mySteps[0] == END_STATE) { console.info('case release player error'); } else { 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 297db8c77..159a07057 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 @@ -129,6 +129,11 @@ describe('PlayerLocalTestAudioFUNC', function () { case SEEK_STATE: console.info(`case seek to time is ${mySteps[SECOND_INDEX]}`); audioPlayer.seek(mySteps[SECOND_INDEX]); + if (mySteps[2] != ERROR_STATE) { + mySteps.shift(); + mySteps.shift(); + nextStep(mySteps, done); + } break; case VOLUME_STATE: console.info(`case to setVolume`); @@ -139,6 +144,7 @@ describe('PlayerLocalTestAudioFUNC', function () { mySteps.shift(); audioPlayer.release(); audioPlayer = undefined; + nextStep(mySteps, done); break; case LOOP_STATE: audioPlayer.loop = mySteps[SECOND_INDEX]; @@ -205,26 +211,7 @@ describe('PlayerLocalTestAudioFUNC', function () { nextStep(mySteps,done); }); audioPlayer.on('timeUpdate', (seekDoneTime) => { - if (typeof (seekDoneTime) == 'undefined') { - console.info(`case seek filed,errcode is ${seekDoneTime}`); - return; - } - if (mySteps[0] != SEEK_STATE) { - return; - } - mySteps.shift(); - mySteps.shift(); - console.info(`case seekDoneTime is ${seekDoneTime}`); - console.info(`case seek called`); - expect(audioPlayer.currentTime + DELTA_TIME).assertClose(seekDoneTime + DELTA_TIME, DELTA_TIME); - console.info(`case loop is ${audioPlayer.loop}`); - if ((audioPlayer.loop == true) && (seekDoneTime == DURATION_TIME)) { - console.info('case loop is true'); - sleep(PLAY_STATE); - } - if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == 'paused')) { - nextStep(mySteps,done); - } + console.info('case timeUpdate seekDoneTime is' + seekDoneTime); }); audioPlayer.on('volumeChange', () => { console.info(`case setvolume called`); @@ -243,18 +230,16 @@ describe('PlayerLocalTestAudioFUNC', function () { nextStep(mySteps,done); }); audioPlayer.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}`); if ((mySteps[0] == SEEK_STATE) || (mySteps[0] == VOLUME_STATE)) { mySteps.shift(); mySteps.shift(); - mySteps.shift(); } else { mySteps.shift(); - mySteps.shift(); } - nextStep(mySteps,done); + expect(mySteps[0]).assertEqual(ERROR_STATE); + mySteps.shift(); + nextStep(mySteps, done); }); } @@ -452,7 +437,7 @@ describe('PlayerLocalTestAudioFUNC', function () { */ it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1500', 0, async function (done) { let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME, - PLAY_STATE, FINISH_STATE, END_STATE); + PLAY_STATE, FINISH_STATE, RESET_STATE, RELEASE_STATE, END_STATE); initAudioPlayer(); setCallback(mySteps, done); audioPlayer.src = fdPath; diff --git a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js index 943356a85..7a137c4fc 100644 --- a/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js +++ b/multimedia/media/media_js_standard/audioPlayer/src/main/js/test/PlayerLocalTestAudioFormat.test.js @@ -114,13 +114,11 @@ describe('PlayerLocalTestAudioFormat', function () { return; } console.info('case seek success, and seek time is ' + seekDoneTime); - if (!isToDuration) { + if ((!isToDuration) && (seekDoneTime >= SEEK_TIME)) { expect(SEEK_TIME).assertEqual(seekDoneTime); isToDuration = true; sleep(PLAY_TIME); audioPlayer.seek(audioPlayer.duration); - } else { - expect(audioPlayer.duration).assertEqual(seekDoneTime); } }); audioPlayer.on('volumeChange', () => { -- GitLab