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 ed359ce2e2051c98d2a7ffd0210dd5668293cf47..e246bd6e37e6ca18332075989d3ae221c4ba98f3 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 b642f18a74d404b004d587efb6ee93ba45bcf9da..01c91211913ddd3c39733777807a3ebd84c6930a 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 a9d8a3f14262947827afd11a6d1e6e3b94b7127f..e63bcbe64825adeeeb8f3acc6a000fabcdf285a7 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 32f4bace07a6eccb438714ea94f5ec0462dd0ae4..31020098e88eed3267aa34d15be2f72bc694d678 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 4b1279a5303ba3051e0d1256e9ad27fbe7e4db94..ed5e21b5456533b5f86875953faf9901996d7dcf 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(); } }