From 52636e5ceedc58b9f592c32e44cee4d3b57cfb5b Mon Sep 17 00:00:00 2001 From: fulizhong Date: Thu, 28 Jul 2022 15:51:04 +0800 Subject: [PATCH] modify testcases Signed-off-by: FULIZHONG Signed-off-by: fulizhong --- .../test/VideoPlayerAPICallbackTest.test.js | 76 +++++++------ .../test/VideoPlayerFuncCallbackTest.test.js | 36 +++--- .../test/VideoPlayerFuncPromiseTest.test.js | 68 ++++++------ .../test/VideoRecorderAPICallbackTest.test.js | 59 +++++----- .../VideoRecorderFuncCallbackTest.test.js | 28 +++-- .../test/VideoRecorderFuncPromiseTest.test.js | 104 +++++++++--------- 6 files changed, 186 insertions(+), 185 deletions(-) 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 3ede8e0ea..452bf662e 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 @@ -83,12 +83,12 @@ describe('VideoPlayerAPICallbackTest', function () { function failureCallback(error) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); } function catchCallback(error) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); } async function getFd() { @@ -134,7 +134,7 @@ describe('VideoPlayerAPICallbackTest', function () { function printfError(error, done) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); done(); } @@ -160,12 +160,12 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.on(CREATE_EVENT, (videoPlayer, steps, done) => { steps.shift(); media.createVideoPlayer((err, video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); console.info('case createVideoPlayer success!!'); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -178,11 +178,11 @@ describe('VideoPlayerAPICallbackTest', function () { steps.shift(); videoPlayer.url = fdPath; videoPlayer.setDisplaySurface(surfaceID, (err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success!!'); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -195,14 +195,14 @@ describe('VideoPlayerAPICallbackTest', function () { steps.shift(); videoPlayer.url = fdPath; videoPlayer.prepare((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { 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!!'); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -214,12 +214,12 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.on(GETDESCRIPTION, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.getTrackDescription((err, arrlist) => { - if (typeof (err) == 'undefined') { + if (err == null) { for (let i = 0; i < arrlist.length; i++) { printfDescription(arrlist[i]); } toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -231,12 +231,12 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.on(PLAY_EVENT, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.play((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('playing'); console.info('case play success!!'); sleep(PLAY_TIME); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -248,11 +248,11 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.on(PAUSE_EVENT, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.pause((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('paused'); console.info('case pause success!!'); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -264,11 +264,11 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.on(STOP_EVENT, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.stop((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('stopped'); console.info('case stop success!!'); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -280,11 +280,11 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.on(RESET_EVENT, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.reset((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('idle'); console.info('case reset success!!'); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -296,10 +296,10 @@ describe('VideoPlayerAPICallbackTest', function () { eventEmitter.on(RELEASE_EVENT, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.release((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case release success!!'); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -313,10 +313,10 @@ describe('VideoPlayerAPICallbackTest', function () { steps.shift(); steps.shift(); videoPlayer.seek(seekTime, (err, seekDoneTime) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case seek success and seekDoneTime is '+ seekDoneTime); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -355,11 +355,11 @@ describe('VideoPlayerAPICallbackTest', function () { steps.shift(); steps.shift(); videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC, (err, seekDoneTime) => { - if (typeof (err) == 'undefined') { + if (err == null) { checkSeekTime(media.SeekMode.SEEK_NEXT_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)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -373,10 +373,10 @@ describe('VideoPlayerAPICallbackTest', function () { steps.shift(); steps.shift(); videoPlayer.setVolume(volumeValue, (err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case setVolume success'); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -390,11 +390,11 @@ describe('VideoPlayerAPICallbackTest', function () { steps.shift(); steps.shift(); videoPlayer.setSpeed(speedValue, (err, speedMode) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(speedValue).assertEqual(speedMode); console.info('case setSpeed success and speedMode is '+ speedMode); toNextStep(videoPlayer, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); toNextStep(videoPlayer, steps, done); } else { @@ -587,7 +587,7 @@ describe('VideoPlayerAPICallbackTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, GETDESCRIPTION, - PREPARE_EVENT, RELEASE_EVENT, END_EVENT); + PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) @@ -604,7 +604,7 @@ describe('VideoPlayerAPICallbackTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PREPARE_EVENT, - PREPARE_EVENT, RELEASE_EVENT, END_EVENT); + ERROR_EVENT, PREPARE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) @@ -807,7 +807,8 @@ describe('VideoPlayerAPICallbackTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, - PREPARE_EVENT, PLAY_EVENT, PLAY_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT); + PREPARE_EVENT, PLAY_EVENT, PLAY_EVENT, ERROR_EVENT, + PLAY_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) @@ -1010,7 +1011,8 @@ describe('VideoPlayerAPICallbackTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, - PREPARE_EVENT, PLAY_EVENT, PAUSE_EVENT, PAUSE_EVENT, PAUSE_EVENT, RELEASE_EVENT, END_EVENT); + PREPARE_EVENT, PLAY_EVENT, PAUSE_EVENT, PAUSE_EVENT, ERROR_EVENT, + PAUSE_EVENT, ERROR_EVENT, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); }) @@ -1213,7 +1215,8 @@ describe('VideoPlayerAPICallbackTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, - PREPARE_EVENT, PLAY_EVENT, STOP_EVENT, STOP_EVENT, STOP_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); }) @@ -1416,7 +1419,8 @@ describe('VideoPlayerAPICallbackTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, - PREPARE_EVENT, RESET_EVENT, RESET_EVENT, RESET_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); }) @@ -1995,7 +1999,7 @@ describe('VideoPlayerAPICallbackTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, - SETVOLUME_EVENT, VOLUME_VALUE, END_EVENT); + SETVOLUME_EVENT, VOLUME_VALUE, 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 84def3464..d04339ea2 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 @@ -80,12 +80,12 @@ describe('VideoPlayerFuncCallbackTest', function () { function failureCallback(error) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); } function catchCallback(error) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); } function sleep(time) { @@ -135,7 +135,7 @@ describe('VideoPlayerFuncCallbackTest', function () { function printfError(error, done) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); done(); } @@ -177,14 +177,14 @@ describe('VideoPlayerFuncCallbackTest', function () { }); videoPlayer.on('error', (error) => { - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); }); } eventEmitter.on(CREATE_EVENT, (videoPlayer, steps, done) => { steps.shift(); media.createVideoPlayer((err, video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; setOnCallback(videoPlayer); expect(videoPlayer.state).assertEqual('idle'); @@ -200,7 +200,7 @@ describe('VideoPlayerFuncCallbackTest', function () { steps.shift(); videoPlayer.url = fdPath; videoPlayer.setDisplaySurface(surfaceID, (err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('idle'); console.info('case setDisplaySurface success!!'); toNextStep(videoPlayer, steps, done); @@ -213,7 +213,7 @@ describe('VideoPlayerFuncCallbackTest', function () { eventEmitter.on(PREPARE_EVENT, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.prepare((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('prepared'); expect(videoPlayer.duration).assertEqual(DURATION_TIME); expect(videoPlayer.width).assertEqual(WIDTH_VALUE); @@ -230,7 +230,7 @@ describe('VideoPlayerFuncCallbackTest', function () { steps.shift(); videoPlayer.url = fdPath; videoPlayer.prepare((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('prepared'); expect(videoPlayer.duration).assertEqual(DURATION_TIME); expect(videoPlayer.width).assertEqual(WIDTH_VALUE); @@ -246,7 +246,7 @@ describe('VideoPlayerFuncCallbackTest', function () { eventEmitter.on(GETDESCRIPTION, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.getTrackDescription((err, arrlist) => { - if (typeof (err) == 'undefined') { + if (err == null) { for (let i = 0; i < arrlist.length; i++) { printfDescription(arrlist[i]); } @@ -261,7 +261,7 @@ describe('VideoPlayerFuncCallbackTest', function () { steps.shift(); let startTime = videoPlayer.currentTime; videoPlayer.play((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('playing'); console.info('case play success!!'); sleep(PLAY_TIME); @@ -277,7 +277,7 @@ describe('VideoPlayerFuncCallbackTest', function () { eventEmitter.on(PAUSE_EVENT, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.pause((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('paused'); console.info('case pause success!!'); toNextStep(videoPlayer, steps, done); @@ -290,7 +290,7 @@ describe('VideoPlayerFuncCallbackTest', function () { eventEmitter.on(STOP_EVENT, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.stop((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('stopped'); console.info('case stop success!!'); toNextStep(videoPlayer, steps, done); @@ -303,7 +303,7 @@ describe('VideoPlayerFuncCallbackTest', function () { eventEmitter.on(RESET_EVENT, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.reset((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoPlayer.state).assertEqual('idle'); console.info('case reset success!!'); toNextStep(videoPlayer, steps, done); @@ -316,7 +316,7 @@ describe('VideoPlayerFuncCallbackTest', function () { eventEmitter.on(RELEASE_EVENT, (videoPlayer, steps, done) => { steps.shift(); videoPlayer.release((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case release success!!'); toNextStep(videoPlayer, steps, done); } else { @@ -355,7 +355,7 @@ describe('VideoPlayerFuncCallbackTest', function () { steps.shift(); steps.shift(); videoPlayer.seek(seekTime, (err, seekDoneTime) => { - if (typeof (err) == 'undefined') { + if (err == null) { if (seekTime > DURATION_TIME) { seekTime = DURATION_TIME; } @@ -375,7 +375,7 @@ describe('VideoPlayerFuncCallbackTest', function () { steps.shift(); steps.shift(); videoPlayer.seek(seekTime, seekMode, (err, seekDoneTime) => { - if (typeof (err) == 'undefined') { + if (err == null) { if (seekTime > DURATION_TIME) { seekTime = DURATION_TIME; } @@ -393,7 +393,7 @@ describe('VideoPlayerFuncCallbackTest', function () { steps.shift(); steps.shift(); videoPlayer.setVolume(volumeValue, (err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case setVolume success'); toNextStep(videoPlayer, steps, done); } else { @@ -433,7 +433,7 @@ describe('VideoPlayerFuncCallbackTest', function () { steps.shift(); let startTime = videoPlayer.currentTime; videoPlayer.setSpeed(speedValue, (err, speedMode) => { - if (typeof (err) == 'undefined') { + if (err == null) { sleep(1000); expect(speedValue).assertEqual(speedMode); console.info('case setSpeed success and speedMode is '+ speedMode); 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 b58b09c44..d1c1b5ddc 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 @@ -68,12 +68,12 @@ describe('VideoPlayerFuncPromiseTest', function () { function failureCallback(error) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); } function catchCallback(error) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); } async function toNewPage() { @@ -163,7 +163,7 @@ describe('VideoPlayerFuncPromiseTest', function () { let testVideoPlayer1 = null; let testVideoPlayer2 = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { testVideoPlayer1 = video console.info('case createVideoPlayer success '); } else { @@ -201,7 +201,7 @@ describe('VideoPlayerFuncPromiseTest', function () { testVideoPlayer1 = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { testVideoPlayer2 = video console.info('case createVideoPlayer success '); } else { @@ -253,7 +253,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { console.info('case createVideoPlayer success'); videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); @@ -277,13 +277,13 @@ describe('VideoPlayerFuncPromiseTest', function () { expect(videoPlayer.height).assertEqual(HEIGHT_VALUE); }, 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); await videoPlayer.release().then(() => { @@ -305,7 +305,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -361,7 +361,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -426,7 +426,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -482,7 +482,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -538,7 +538,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -595,7 +595,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -682,7 +682,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -738,7 +738,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -800,7 +800,7 @@ describe('VideoPlayerFuncPromiseTest', function () { let videoPlayer = null; let arrayDescription = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -822,7 +822,7 @@ describe('VideoPlayerFuncPromiseTest', function () { await videoPlayer.getTrackDescription().then((arrayList) => { console.info('case getTrackDescription called!!'); - if (typeof (arrayList) != 'undefined') { + if (arrayList != null) { arrayDescription = arrayList; } else { console.info('case getTrackDescription is failed'); @@ -853,7 +853,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -912,7 +912,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -973,7 +973,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1034,7 +1034,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1105,7 +1105,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1182,7 +1182,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1252,7 +1252,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1323,7 +1323,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1384,7 +1384,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1462,7 +1462,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1529,7 +1529,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1602,7 +1602,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1668,7 +1668,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1740,7 +1740,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1809,7 +1809,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1876,7 +1876,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { @@ -1934,7 +1934,7 @@ describe('VideoPlayerFuncPromiseTest', function () { console.info('case new surfaceID is ' + surfaceID); let videoPlayer = null; await media.createVideoPlayer().then((video) => { - if (typeof (video) != 'undefined') { + if (video != null) { videoPlayer = video; expect(videoPlayer.state).assertEqual('idle'); } else { diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js index 7ae25c43d..94f0c7266 100644 --- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js @@ -179,17 +179,15 @@ describe('VideoRecorderAPICallbackTest', function () { await captureSession.addInput(cameraInput); await captureSession.addOutput(videoOutPut); await captureSession.commitConfig(); - await captureSession.start(); } async function stopCaptureSession() { - await captureSession.stop(); await captureSession.release(); } function printfError(error, done) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); done(); } @@ -235,7 +233,7 @@ describe('VideoRecorderAPICallbackTest', function () { await videoOutput.release().then(() => { console.info('[camera] case videoOutput release success'); }); - videoOutput = undefined; + videoOutput = null; await stopCaptureSession(); toNextStep(videoRecorder, steps, done); }); @@ -243,12 +241,12 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(CREATE_EVENT, async (videoRecorder, steps, done) => { steps.shift(); media.createVideoRecorder((err, recorder) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case createVideoRecorder success '); videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); toNextStep(videoRecorder, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); console.info('case createVideoRecorder error hanpped'); toNextStep(videoRecorder, steps, done); @@ -261,11 +259,11 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(PREPARE_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.prepare(videoConfig, (err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case prepare success'); expect(videoRecorder.state).assertEqual('prepared'); toNextStep(videoRecorder, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); console.info('case prepare error hanpped'); toNextStep(videoRecorder, steps, done); @@ -278,11 +276,11 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(PREPARE_OLNYVIDEO_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.prepare(onlyVideoConfig, (err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case prepare success'); expect(videoRecorder.state).assertEqual('prepared'); toNextStep(videoRecorder, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); console.info('case prepare error hanpped'); toNextStep(videoRecorder, steps, done); @@ -295,11 +293,11 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(GETSURFACE_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.getInputSurface((err, outPutSurface) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case getInputSurface success'); surfaceID = outPutSurface; toNextStep(videoRecorder, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); console.info('case getInputSurface error hanpped'); toNextStep(videoRecorder, steps, done); @@ -312,12 +310,12 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(START_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.start((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case start success'); expect(videoRecorder.state).assertEqual('playing'); sleep(RECORDER_TIME); toNextStep(videoRecorder, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); console.info('case start error hanpped'); toNextStep(videoRecorder, steps, done); @@ -330,12 +328,12 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(PAUSE_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.pause((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case pause success'); sleep(PAUSE_TIME); expect(videoRecorder.state).assertEqual('paused'); toNextStep(videoRecorder, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); console.info('case pause error hanpped'); toNextStep(videoRecorder, steps, done); @@ -348,12 +346,12 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(RESUME_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.resume((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case resume success'); sleep(RECORDER_TIME); expect(videoRecorder.state).assertEqual('playing'); toNextStep(videoRecorder, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); console.info('case resume error hanpped'); toNextStep(videoRecorder, steps, done); @@ -366,11 +364,11 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(STOP_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.stop((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case stop success'); expect(videoRecorder.state).assertEqual('stopped'); toNextStep(videoRecorder, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); console.info('case stop error hanpped'); toNextStep(videoRecorder, steps, done); @@ -383,11 +381,11 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(RESET_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.reset((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case reset success'); expect(videoRecorder.state).assertEqual('idle'); toNextStep(videoRecorder, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); console.info('case reset error hanpped'); toNextStep(videoRecorder, steps, done); @@ -400,11 +398,11 @@ describe('VideoRecorderAPICallbackTest', function () { eventEmitter.on(RELEASE_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.release((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoRecorder.state).assertEqual('idle'); console.info('case release success'); toNextStep(videoRecorder, steps, done); - } else if ((typeof (err) != 'undefined') && (steps[0] == ERROR_EVENT)) { + } else if ((err != null) && (steps[0] == ERROR_EVENT)) { steps.shift(); console.info('case release error hanpped'); toNextStep(videoRecorder, steps, done); @@ -591,7 +589,7 @@ describe('VideoRecorderAPICallbackTest', function () { let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM, START_EVENT, SETPAUSE, PAUSE_EVENT, SETPAUSE, SETSTART, RESUME_EVENT, - START_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT); + START_EVENT, ERROR_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT); eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done); }) @@ -651,7 +649,8 @@ describe('VideoRecorderAPICallbackTest', function () { it('SUB_MEDIA_VIDEO_RECORDER_START_CALLBACK_0800', 0, async function (done) { let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM, - START_EVENT, START_EVENT, START_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT); + START_EVENT, START_EVENT, ERROR_EVENT, START_EVENT, + ERROR_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT); eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done); }) @@ -770,7 +769,8 @@ describe('VideoRecorderAPICallbackTest', function () { it('SUB_MEDIA_VIDEO_RECORDER_PAUSE_CALLBACK_0800', 0, async function (done) { let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM, - START_EVENT, SETPAUSE, PAUSE_EVENT, PAUSE_EVENT, PAUSE_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT); + START_EVENT, SETPAUSE, PAUSE_EVENT, PAUSE_EVENT, ERROR_EVENT, + PAUSE_EVENT, ERROR_EVENT, CLOSE_STREAM, RELEASE_EVENT, END_EVENT); eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done); }) @@ -813,7 +813,7 @@ describe('VideoRecorderAPICallbackTest', function () { it('SUB_MEDIA_VIDEO_RECORDER_RESUME_CALLBACK_0300', 0, async function (done) { let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM, - START_EVENT, RESUME_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT); + START_EVENT, RESUME_EVENT, ERROR_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT); eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done); }) @@ -890,7 +890,8 @@ describe('VideoRecorderAPICallbackTest', function () { let videoRecorder = null; let mySteps = new Array(CREATE_EVENT, PREPARE_EVENT, GETSURFACE_EVENT, START_STREEAM, START_EVENT, SETPAUSE, PAUSE_EVENT, SETPAUSE, SETSTART, - RESUME_EVENT, RESUME_EVENT, RESUME_EVENT, RELEASE_EVENT, CLOSE_STREAM, END_EVENT); + RESUME_EVENT, RESUME_EVENT, ERROR_EVENT, RESUME_EVENT, ERROR_EVENT, + RELEASE_EVENT, CLOSE_STREAM, END_EVENT); eventEmitter.emit(mySteps[0], videoRecorder, mySteps, done); }) diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js index 1a414ec52..db7014eda 100644 --- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncCallbackTest.test.js @@ -223,17 +223,15 @@ describe('VideoRecorderFuncCallbackTest', function () { await captureSession.addInput(cameraInput); await captureSession.addOutput(videoOutPut); await captureSession.commitConfig(); - await captureSession.start(); } async function stopCaptureSession() { - await captureSession.stop(); await captureSession.release(); } function printfError(error, done) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); done(); } @@ -256,7 +254,7 @@ describe('VideoRecorderFuncCallbackTest', function () { }); videoRecorder.on('error', (err) => { - console.info('case error called, errMessage is ' + err.message); + console.info('case error called, err code is ' + err.code); expect().assertFail(); }); } @@ -264,7 +262,7 @@ describe('VideoRecorderFuncCallbackTest', function () { eventEmitter.on(CREATE_EVENT, async (videoRecorder, steps, done) => { steps.shift(); media.createVideoRecorder((err, recorder) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case createVideoRecorder success '); videoRecorder = recorder; setOnCallback(videoRecorder); @@ -279,7 +277,7 @@ describe('VideoRecorderFuncCallbackTest', function () { eventEmitter.on(PREPARE_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.prepare(videoConfig, (err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case prepare success'); expect(videoRecorder.state).assertEqual('prepared'); toNextStep(videoRecorder, steps, done); @@ -292,7 +290,7 @@ describe('VideoRecorderFuncCallbackTest', function () { eventEmitter.on(PREPARE_OLNYVIDEO_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.prepare(onlyVideoConfig, (err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case prepare success'); expect(videoRecorder.state).assertEqual('prepared'); toNextStep(videoRecorder, steps, done); @@ -305,7 +303,7 @@ describe('VideoRecorderFuncCallbackTest', function () { eventEmitter.on(GETSURFACE_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.getInputSurface((err, outPutsurface) => { - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoRecorder.state).assertEqual('prepared'); surfaceID = outPutsurface; console.info('case getInputSurface success :' + surfaceID); @@ -329,7 +327,7 @@ describe('VideoRecorderFuncCallbackTest', function () { console.info('case videoOutput start success'); }); videoRecorder.start((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case start success'); expect(videoRecorder.state).assertEqual('playing'); sleep(RECORDER_TIME); @@ -343,7 +341,7 @@ describe('VideoRecorderFuncCallbackTest', function () { eventEmitter.on(PAUSE_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.pause((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case pause success'); expect(videoRecorder.state).assertEqual('paused'); sleep(PAUSE_TIME); @@ -357,7 +355,7 @@ describe('VideoRecorderFuncCallbackTest', function () { eventEmitter.on(RESUME_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.resume((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case resume success'); sleep(RECORDER_TIME); expect(videoRecorder.state).assertEqual('playing'); @@ -371,7 +369,7 @@ describe('VideoRecorderFuncCallbackTest', function () { eventEmitter.on(STOP_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.stop((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case stop success'); expect(videoRecorder.state).assertEqual('stopped'); toNextStep(videoRecorder, steps, done); @@ -384,7 +382,7 @@ describe('VideoRecorderFuncCallbackTest', function () { eventEmitter.on(RESET_EVENT, async (videoRecorder, steps, done) => { steps.shift(); videoRecorder.reset((err) => { - if (typeof (err) == 'undefined') { + if (err == null) { console.info('case reset success'); expect(videoRecorder.state).assertEqual('idle'); toNextStep(videoRecorder, steps, done); @@ -403,9 +401,9 @@ describe('VideoRecorderFuncCallbackTest', function () { await videoOutput.release().then(() => { console.info('case videoOutput release success'); }); - videoOutput = undefined; + videoOutput = null; await stopCaptureSession(); - if (typeof (err) == 'undefined') { + if (err == null) { expect(videoRecorder.state).assertEqual('idle'); console.info('case release success'); toNextStep(videoRecorder, steps, done); diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js index ff1670c8d..882d4573a 100644 --- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js @@ -124,11 +124,9 @@ describe('VideoRecorderFuncPromiseTest', function () { await captureSession.addInput(cameraInput); await captureSession.addOutput(videoOutPut); await captureSession.commitConfig(); - await captureSession.start(); } async function stopCaptureSession() { - await captureSession.stop(); await captureSession.release(); } @@ -148,7 +146,7 @@ describe('VideoRecorderFuncPromiseTest', function () { await videoOutPut.release().then(() => { console.info('[camera] case videoOutput release success'); }); - videoOutPut = undefined; + videoOutPut = null; await stopCaptureSession(); } @@ -186,12 +184,12 @@ describe('VideoRecorderFuncPromiseTest', function () { function failureCallback(error) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); } function catchCallback(error) { expect().assertFail(); - console.info(`case error called,errMessage is ${error.message}`); + console.info(`case error called,err code is ${error.code}`); } /* * @@ -203,14 +201,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0100', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('01.mp4'); videoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -253,14 +251,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0200', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('02.mp4'); videoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -310,14 +308,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0300', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('03.mp4'); videoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -375,14 +373,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0400', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('04.mp4'); videoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -431,14 +429,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0500', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('05.mp4'); videoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -486,14 +484,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0600', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('06.mp4'); videoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -548,14 +546,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0700', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('07.mp4'); videoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -610,14 +608,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0800', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('08.mp4'); videoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -680,14 +678,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_0900', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('09.mp4'); videoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -750,7 +748,7 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1000', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('10.mp4'); @@ -760,7 +758,7 @@ describe('VideoRecorderFuncPromiseTest', function () { configFile.videoBitrate = 8000; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -810,7 +808,7 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1100', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('11.mp4'); @@ -820,7 +818,7 @@ describe('VideoRecorderFuncPromiseTest', function () { configFile.videoBitrate = 16000; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -870,7 +868,7 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1200', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('12.mp4'); @@ -880,7 +878,7 @@ describe('VideoRecorderFuncPromiseTest', function () { configFile.videoBitrate = 32000; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -930,7 +928,7 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1300', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('13.mp4'); @@ -940,7 +938,7 @@ describe('VideoRecorderFuncPromiseTest', function () { configFile.videoBitrate = 112000; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -989,14 +987,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1400', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('14.mp4'); onlyVideoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -1038,14 +1036,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1500', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('15.mp4'); onlyVideoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -1096,14 +1094,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1600', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('16.mp4'); onlyVideoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -1160,14 +1158,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1700', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('17.mp4'); onlyVideoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -1215,14 +1213,14 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level1 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1800', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('18.mp4'); onlyVideoConfig.url = fdPath; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -1270,7 +1268,7 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_1900', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('40.mp4'); @@ -1278,7 +1276,7 @@ describe('VideoRecorderFuncPromiseTest', function () { videoConfig.rotation = 90; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -1319,7 +1317,7 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2000', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('41.mp4'); @@ -1327,7 +1325,7 @@ describe('VideoRecorderFuncPromiseTest', function () { videoConfig.rotation = 180; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -1368,7 +1366,7 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2100', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('42.mp4'); @@ -1376,7 +1374,7 @@ describe('VideoRecorderFuncPromiseTest', function () { videoConfig.rotation = 270; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -1417,7 +1415,7 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2200', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('43.mp4'); @@ -1425,7 +1423,7 @@ describe('VideoRecorderFuncPromiseTest', function () { configFile.videoFrameRate = 20; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -1466,7 +1464,7 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2300', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('44.mp4'); @@ -1474,7 +1472,7 @@ describe('VideoRecorderFuncPromiseTest', function () { configFile.videoFrameRate = 30; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { @@ -1515,7 +1513,7 @@ describe('VideoRecorderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_RECORDER_FUNCTION_PROMISE_2400', 0, async function (done) { - let videoRecorder = undefined; + let videoRecorder = null; let surfaceID = ''; let videoOutput; await getFd('45.mp4'); @@ -1523,7 +1521,7 @@ describe('VideoRecorderFuncPromiseTest', function () { configFile.videoFrameRate = 60; await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); - if (typeof (recorder) != 'undefined') { + if (recorder != null) { videoRecorder = recorder; expect(videoRecorder.state).assertEqual('idle'); } else { -- GitLab