From 2b3a8d8c11619f84346f65658827f9df8674f4f2 Mon Sep 17 00:00:00 2001 From: XUXIAOBO Date: Thu, 16 Sep 2021 01:42:40 +0000 Subject: [PATCH] =?UTF-8?q?=E9=9F=B3=E9=A2=91=E6=92=AD=E6=94=BE=E5=99=A8js?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=81=8D=E5=8E=86=E6=92=AD=E6=94=BE=E7=A0=81?= =?UTF-8?q?=E6=B5=81=E7=94=A8=E4=BE=8B=E4=BB=A5=E5=8F=8A=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=A0=81=E6=B5=81=E3=80=82Signed-off-by:=20X?= =?UTF-8?q?UXIAOBO=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/PlayerLocalTestAudioFUNC.test.js | 35 ++++++++++-- .../test/PlayerLocalTestAudioFormat.test.js | 53 ++++++++++++++----- .../test/PlayerLocalTestAudioAPI.test.js | 31 ++++++++++- 3 files changed, 101 insertions(+), 18 deletions(-) diff --git a/multimedia/audio/audio_js_standard/audioPlayer/src/main/js/default/test/PlayerLocalTestAudioFUNC.test.js b/multimedia/audio/audio_js_standard/audioPlayer/src/main/js/default/test/PlayerLocalTestAudioFUNC.test.js index f0de95c62..880dd6d7b 100755 --- a/multimedia/audio/audio_js_standard/audioPlayer/src/main/js/default/test/PlayerLocalTestAudioFUNC.test.js +++ b/multimedia/audio/audio_js_standard/audioPlayer/src/main/js/default/test/PlayerLocalTestAudioFUNC.test.js @@ -38,7 +38,7 @@ describe('PlayerLocalTestAudioFUNC', function () { const LOOP_STATE = 11; const SECOND_INDEX = 1; const RAND_NUM = 5; - const TIME_OUT = 35000; + const TIME_OUT = 40000; const MAX_VOLUME = 1; beforeAll(function() { @@ -125,8 +125,7 @@ describe('PlayerLocalTestAudioFUNC', function () { } } - function setCallback(mySteps, done) { - console.info(`case setCallback`); + function setSrcCallback(mySteps) { audioPlayer.on('dataLoad', () => { mySteps.shift(); console.info(`case dataLoad called`); @@ -135,7 +134,9 @@ describe('PlayerLocalTestAudioFUNC', function () { expect(audioPlayer.state).assertEqual('paused'); nextStep(mySteps); }); + } + function setPlayCallback(mySteps) { audioPlayer.on('play', () => { mySteps.shift(); console.info(`case play called`); @@ -149,7 +150,9 @@ describe('PlayerLocalTestAudioFUNC', function () { expect(audioPlayer.state).assertEqual('playing'); nextStep(mySteps); }); + } + function setPauseCallback(mySteps) { audioPlayer.on('pause', () => { mySteps.shift(); console.info(`case pause called`); @@ -158,14 +161,18 @@ describe('PlayerLocalTestAudioFUNC', function () { expect(audioPlayer.state).assertEqual('paused'); nextStep(mySteps); }); + } + function setResetCallback(mySteps) { audioPlayer.on('reset', () => { mySteps.shift(); console.info(`case reset called`); expect(audioPlayer.state).assertEqual('idle'); nextStep(mySteps); }); + } + function setStopCallback(mySteps) { audioPlayer.on('stop', () => { if (mySteps[0] == RESET_STATE) { console.info(`case reset stop called`); @@ -178,7 +185,9 @@ describe('PlayerLocalTestAudioFUNC', function () { expect(audioPlayer.state).assertEqual('stopped'); nextStep(mySteps); }); + } + function setSeekCallback(mySteps) { audioPlayer.on('timeUpdate', (seekDoneTime) => { if (typeof (seekDoneTime) == 'undefined') { console.info(`case seek filed,errcode is ${seekDoneTime}`); @@ -201,7 +210,9 @@ describe('PlayerLocalTestAudioFUNC', function () { nextStep(mySteps); } }); + } + function setVolumeCallback(mySteps) { audioPlayer.on('volumeChange', () => { console.info(`case setvolume called`); mySteps.shift(); @@ -211,7 +222,9 @@ describe('PlayerLocalTestAudioFUNC', function () { } nextStep(mySteps); }); + } + function setFinishCallback(mySteps) { audioPlayer.on('finish', () => { mySteps.shift(); expect(audioPlayer.state).assertEqual('stopped'); @@ -219,7 +232,9 @@ describe('PlayerLocalTestAudioFUNC', function () { console.info(`case finish called`); nextStep(mySteps); }); + } + function setErrorCallback(mySteps) { audioPlayer.on('error', (err) => { console.info(`case error called,errName is ${err.name}`); console.info(`case error called,errCode is ${err.code}`); @@ -234,7 +249,19 @@ describe('PlayerLocalTestAudioFUNC', function () { } nextStep(mySteps); }); + } + function setCallback(mySteps, done) { + console.info(`case setCallback`); + setSrcCallback(mySteps); + setPlayCallback(mySteps); + setPauseCallback(mySteps); + setResetCallback(mySteps); + setStopCallback(mySteps); + setSeekCallback(mySteps); + setVolumeCallback(mySteps); + setFinishCallback(mySteps); + setErrorCallback(mySteps); setTimeout(function() { if (!isTimeOut) { console.info(`case is time out!`); @@ -832,4 +859,4 @@ describe('PlayerLocalTestAudioFUNC', function () { setCallback(mySteps, done); audioPlayer.src = AUDIO_SOURCE; }) -}) \ No newline at end of file +}) diff --git a/multimedia/audio/audio_js_standard/audioPlayer/src/main/js/default/test/PlayerLocalTestAudioFormat.test.js b/multimedia/audio/audio_js_standard/audioPlayer/src/main/js/default/test/PlayerLocalTestAudioFormat.test.js index ba20ec86b..bb50e1966 100644 --- a/multimedia/audio/audio_js_standard/audioPlayer/src/main/js/default/test/PlayerLocalTestAudioFormat.test.js +++ b/multimedia/audio/audio_js_standard/audioPlayer/src/main/js/default/test/PlayerLocalTestAudioFormat.test.js @@ -21,11 +21,15 @@ describe('PlayerLocalTestAudioFormat', function () { const MAX_VOLUME = 1; const PLAY_TIME = 3000; const SEEK_TIME = 10000; // 10s + let isToSeek = false; + let isToDuration = false; beforeAll(function() { console.info('beforeAll case'); }) beforeEach(function() { + isToSeek = false; + isToDuration = false; console.info('beforeEach case'); }) @@ -41,24 +45,16 @@ describe('PlayerLocalTestAudioFormat', function () { for(let t = Date.now(); Date.now() - t <= time;); } - function playSource(audioSource, done) { - let audioPlayer = media.createAudioPlayer(); - let isToSeek = false; - let isToDuration = false; - if (typeof (audioPlayer) == 'undefined') { - console.info('case create player is faild'); - expect().assertFail(); - done(); - return; - } - + function setSrcCallback(audioPlayer) { audioPlayer.on('dataLoad', () => { console.info('case set source success'); expect(audioPlayer.state).assertEqual('paused'); expect(audioPlayer.currentTime).assertEqual(0); audioPlayer.play(); }); + } + function setPlayCallback(audioPlayer) { audioPlayer.on('play', () => { console.info('case start to play'); expect(audioPlayer.state).assertEqual('playing'); @@ -69,13 +65,17 @@ describe('PlayerLocalTestAudioFormat', function () { audioPlayer.seek(SEEK_TIME); } }); + } + function setPauseCallback(audioPlayer) { audioPlayer.on('pause', () => { console.info('case now is paused'); expect(audioPlayer.state).assertEqual('paused'); audioPlayer.setVolume(MAX_VOLUME); }); + } + function setResetCallback(audioPlayer, done) { audioPlayer.on('reset', () => { console.info('case reset success'); expect(audioPlayer.state).assertEqual('idle'); @@ -83,13 +83,17 @@ describe('PlayerLocalTestAudioFormat', function () { audioPlayer = undefined; done(); }); + } + function setStopCallback(audioPlayer) { audioPlayer.on('stop', () => { console.info('case stop success'); expect(audioPlayer.state).assertEqual('stopped'); audioPlayer.reset(); }); + } + function setSeekCallback(audioPlayer, done) { audioPlayer.on('timeUpdate', (seekDoneTime) => { if (typeof (seekDoneTime) == "undefined") { console.info(`case seek filed,errcode is ${seekDoneTime}`); @@ -108,19 +112,25 @@ describe('PlayerLocalTestAudioFormat', function () { expect(audioPlayer.duration).assertEqual(seekDoneTime); } }); + } + function setVolumeCallback(audioPlayer) { audioPlayer.on('volumeChange', () => { console.info('case set volume value to ' + MAX_VOLUME); audioPlayer.play(); isToSeek = true; }); + } + function setFinishCallback(audioPlayer) { audioPlayer.on('finish', () => { console.info('case play end'); expect(audioPlayer.state).assertEqual('stopped'); audioPlayer.stop(); }); + } + function setErrorCallback(audioPlayer, done) { audioPlayer.on('error', (err) => { console.info(`case error called,errName is ${err.name}`); console.info(`case error called,errCode is ${err.code}`); @@ -129,6 +139,25 @@ describe('PlayerLocalTestAudioFormat', function () { expect().assertFail(); done(); }); + } + + function playSource(audioSource, done) { + let audioPlayer = media.createAudioPlayer(); + if (typeof (audioPlayer) == 'undefined') { + console.info('case create player is faild'); + expect().assertFail(); + done(); + return; + } + setSrcCallback(audioPlayer); + setPlayCallback(audioPlayer); + setPauseCallback(audioPlayer); + setResetCallback(audioPlayer, done); + setStopCallback(audioPlayer); + setSeekCallback(audioPlayer, done); + setVolumeCallback(audioPlayer); + setFinishCallback(audioPlayer); + setErrorCallback(audioPlayer, done); audioPlayer.src = audioSource; } @@ -563,4 +592,4 @@ describe('PlayerLocalTestAudioFormat', function () { it('SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0700', 0, async function (done) { playSource(BASIC_PATH + '62.m4a', done); }) -}) \ No newline at end of file +}) diff --git a/multimedia/audio/audio_js_standard/audioPlayer_API/src/main/js/default/test/PlayerLocalTestAudioAPI.test.js b/multimedia/audio/audio_js_standard/audioPlayer_API/src/main/js/default/test/PlayerLocalTestAudioAPI.test.js index 799d8cd40..e8f058640 100755 --- a/multimedia/audio/audio_js_standard/audioPlayer_API/src/main/js/default/test/PlayerLocalTestAudioAPI.test.js +++ b/multimedia/audio/audio_js_standard/audioPlayer_API/src/main/js/default/test/PlayerLocalTestAudioAPI.test.js @@ -127,8 +127,7 @@ describe('PlayerLocalTestAudioAPI', function () { } } - function setCallback(mySteps, done) { - console.info(`case setCallback`); + function setSrcCallback(mySteps) { audioPlayer.on('dataLoad', () => { mySteps.shift(); console.info(`case dataLoad called`); @@ -137,7 +136,9 @@ describe('PlayerLocalTestAudioAPI', function () { expect(audioPlayer.state).assertEqual('paused'); nextStep(mySteps); }); + } + function setPlayCallback(mySteps) { audioPlayer.on('play', () => { mySteps.shift(); console.info(`case play called`); @@ -150,7 +151,9 @@ describe('PlayerLocalTestAudioAPI', function () { expect(audioPlayer.state).assertEqual('playing'); nextStep(mySteps); }); + } + function setPauseCallback(mySteps) { audioPlayer.on('pause', () => { mySteps.shift(); console.info(`case pause called`); @@ -159,14 +162,18 @@ describe('PlayerLocalTestAudioAPI', function () { expect(audioPlayer.state).assertEqual('paused'); nextStep(mySteps); }); + } + function setResetCallback(mySteps) { audioPlayer.on('reset', () => { mySteps.shift(); console.info(`case reset called`); expect(audioPlayer.state).assertEqual('idle'); nextStep(mySteps); }); + } + function setStopCallback(mySteps) { audioPlayer.on('stop', () => { if (mySteps[0] == RESET_STATE) { console.info(`case reset stop called`); @@ -179,7 +186,9 @@ describe('PlayerLocalTestAudioAPI', function () { expect(audioPlayer.state).assertEqual('stopped'); nextStep(mySteps); }); + } + function setSeekCallback(mySteps) { audioPlayer.on('timeUpdate', (seekDoneTime) => { if (typeof (seekDoneTime) == 'undefined') { console.info(`case seek filed,errcode is ${seekDoneTime}`); @@ -202,7 +211,9 @@ describe('PlayerLocalTestAudioAPI', function () { nextStep(mySteps); } }); + } + function setVolumeCallback(mySteps) { audioPlayer.on('volumeChange', () => { console.info(`case setvolume called`); mySteps.shift(); @@ -212,7 +223,9 @@ describe('PlayerLocalTestAudioAPI', function () { } nextStep(mySteps); }); + } + function setFinishCallback(mySteps) { audioPlayer.on('finish', () => { mySteps.shift(); expect(audioPlayer.state).assertEqual('stopped'); @@ -220,7 +233,9 @@ describe('PlayerLocalTestAudioAPI', function () { console.info(`case finish called`); nextStep(mySteps); }); + } + function setErrorCallback(mySteps) { audioPlayer.on('error', (err) => { console.info(`case error called,errName is ${err.name}`); console.info(`case error called,errCode is ${err.code}`); @@ -240,7 +255,19 @@ describe('PlayerLocalTestAudioAPI', function () { nextStep(mySteps); } }); + } + function setCallback(mySteps, done) { + console.info(`case setCallback`); + setSrcCallback(mySteps); + setPlayCallback(mySteps); + setPauseCallback(mySteps); + setResetCallback(mySteps); + setStopCallback(mySteps); + setSeekCallback(mySteps); + setVolumeCallback(mySteps); + setFinishCallback(mySteps); + setErrorCallback(mySteps); setTimeout(function() { if (!isTimeOut) { console.info(`case is time out!`); -- GitLab