From b4405980dccffdf95466bec819298f948c72186e Mon Sep 17 00:00:00 2001 From: fulizhong Date: Tue, 8 Mar 2022 14:47:04 +0800 Subject: [PATCH] modify MULTIPLE videoPlayer test Signed-off-by: FULIZHONG Signed-off-by: fulizhong --- .../js/test/RecorderLocalTestAudioAPI.test.js | 2 +- .../test/RecorderLocalTestAudioFUNC.test.js | 2 +- .../test/VideoPlayerFuncPromiseTest.test.js | 88 ++++++++++++++++--- .../test/VideoRecorderAPICallbackTest.test.js | 6 +- .../test/VideoRecorderFuncPromiseTest.test.js | 6 +- 5 files changed, 85 insertions(+), 19 deletions(-) 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 ed359ce2e..e246bd6e3 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 @@ -32,7 +32,7 @@ describe('RecorderLocalTestAudioAPI', function () { const SOURCE_TYPE = 1; const ENCORDER_AACLC = 3; const CHANNEL_TWO = 2; - const RECORDER_TIME = 1000; + const RECORDER_TIME = 3000; let fdPath; let fileAsset; let fdNumber; 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 b642f18a7..01c912119 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 @@ -31,7 +31,7 @@ describe('RecorderLocalTestAudioFUNC', function () { const RESET_STATE = 6; const RELEASE_STATE = 7; const ERROR_STATE = 8; - const RECORDER_TIME = 1000; + const RECORDER_TIME = 3000; const CHANNEL_ONE = 1; const CHANNEL_TWO = 2; const FORMAT_MP4 = 2; 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 a9d8a3f14..e63bcbe64 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 @@ -127,31 +127,94 @@ describe('VideoPlayerFuncPromiseTest', function () { /* * * @tc.number : SUB_MEDIA_PLAYER_MULTIPLE_0100 - * @tc.name : 001.Multi-instance (16 promise) + * @tc.name : 001.Multi-instance (2 videoPlayer promise) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test * @tc.level : Level2 */ it('SUB_MEDIA_PLAYER_MULTIPLE_0100', 0, async function (done) { - let arr = new Array(); - for (let i = 0; i < 14; i++) { + await getFd(); + setTimeout(async function() { + let testVideoPlayer1 = null; + let testVideoPlayer2 = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { - arr[i] = video - console.info('case createVideoPlayer success ' + i); + testVideoPlayer1 = video + console.info('case createVideoPlayer success '); } else { console.info('case createVideoPlayer is failed'); expect().assertFail(); } - }, failureCallback).catch(catchCallback); - } - for (let j = 0; j < 14;j++) { - await arr[j].release().then(() => { - console.info('case release success ' + j); }, failureCallback).catch(catchCallback); - } - done(); + + testVideoPlayer1.url = fdPath; + await testVideoPlayer1.setDisplaySurface(surfaceID).then(() => { + console.info('case setDisplaySurface success'); + expect(testVideoPlayer1.state).assertEqual('idle'); + }, failureCallback).catch(catchCallback); + + await testVideoPlayer1.prepare().then(() => { + console.info('case prepare called!!'); + expect(testVideoPlayer1.state).assertEqual('prepared'); + expect(testVideoPlayer1.duration).assertEqual(DURATION_TIME); + expect(testVideoPlayer1.width).assertEqual(WIDTH_VALUE); + expect(testVideoPlayer1.height).assertEqual(HEIGHT_VALUE); + }, failureCallback).catch(catchCallback); + + let startTime = testVideoPlayer1.currentTime; + await testVideoPlayer1.play().then(() => { + console.info('case play called!!'); + sleep(PLAY_TIME); + expect(testVideoPlayer1.state).assertEqual('playing'); + }, failureCallback).catch(catchCallback); + let endTime = testVideoPlayer1.currentTime; + expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); + + await testVideoPlayer1.release().then(() => { + console.info('case release called!!'); + }, failureCallback).catch(catchCallback); + testVideoPlayer1 = null; + + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + testVideoPlayer2 = video + console.info('case createVideoPlayer success '); + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, failureCallback).catch(catchCallback); + + testVideoPlayer2.url = fdPath; + await testVideoPlayer2.setDisplaySurface(surfaceID).then(() => { + console.info('case setDisplaySurface success'); + expect(testVideoPlayer2.state).assertEqual('idle'); + }, failureCallback).catch(catchCallback); + + await testVideoPlayer2.prepare().then(() => { + console.info('case prepare called!!'); + expect(testVideoPlayer2.state).assertEqual('prepared'); + expect(testVideoPlayer2.duration).assertEqual(DURATION_TIME); + expect(testVideoPlayer2.width).assertEqual(WIDTH_VALUE); + expect(testVideoPlayer2.height).assertEqual(HEIGHT_VALUE); + }, failureCallback).catch(catchCallback); + + startTime = testVideoPlayer2.currentTime; + await testVideoPlayer2.play().then(() => { + console.info('case play called!!'); + sleep(PLAY_TIME); + expect(testVideoPlayer2.state).assertEqual('playing'); + }, failureCallback).catch(catchCallback); + endTime = testVideoPlayer2.currentTime; + expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); + + await testVideoPlayer2.release().then(() => { + console.info('case release called!!'); + }, failureCallback).catch(catchCallback); + testVideoPlayer2 = null; + done(); + }, 1000); }) /* * @@ -163,7 +226,6 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0100', 0, async function (done) { - await getFd(); setTimeout(async function() { surfaceID = globalThis.value; console.info('case new surfaceID is ' + surfaceID); 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 32f4bace0..31020098e 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 @@ -44,6 +44,8 @@ describe('VideoRecorderAPICallbackTest', function () { let videoOutput; let surfaceID; let fdPath; + let fileAsset; + let fdNumber; let events = require('events'); let eventEmitter = new events.EventEmitter(); @@ -130,8 +132,8 @@ describe('VideoRecorderAPICallbackTest', function () { selectionArgs : [args], } let fetchFileResult = await mediaTest.getFileAssets(fetchOp); - let fileAsset = await fetchFileResult.getAllObject(); - let fdNumber = await fileAsset[0].open('Rw'); + fileAsset = await fetchFileResult.getAllObject(); + fdNumber = await fileAsset[0].open('Rw'); fdPath = "fd://" + fdNumber.toString(); } } 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 4b1279a53..ed5e21b54 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 @@ -25,6 +25,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let cameras; let captureSession; let fdPath; + let fileAsset; + let fdNumber; let configFile = { audioBitrate : 48000, audioChannels : 2, @@ -164,8 +166,8 @@ describe('VideoRecorderFuncPromiseTest', function () { selectionArgs : [args], } let fetchFileResult = await mediaTest.getFileAssets(fetchOp); - let fileAsset = await fetchFileResult.getAllObject(); - let fdNumber = await fileAsset[0].open('Rw'); + fileAsset = await fetchFileResult.getAllObject(); + fdNumber = await fileAsset[0].open('Rw'); fdPath = "fd://" + fdNumber.toString(); } } -- GitLab