From 55712074c6c6be8b2bfe7aab82b01ff2d5204336 Mon Sep 17 00:00:00 2001 From: fulizhong Date: Fri, 15 Jul 2022 15:28:20 +0800 Subject: [PATCH] modify testcases Signed-off-by: FULIZHONG Signed-off-by: fulizhong --- .../media/media_js_standard/MediaTestBase.js | 25 ++++++++++ .../media_js_standard/audioRecorder/Test.json | 3 +- .../test/RecorderLocalTestAudioFUNC.test.js | 46 +++++++++---------- .../recorderFormat/Test.json | 2 +- ...dioRecorderFormatCompatibilityTest.test.js | 6 +-- 5 files changed, 54 insertions(+), 28 deletions(-) diff --git a/multimedia/media/media_js_standard/MediaTestBase.js b/multimedia/media/media_js_standard/MediaTestBase.js index dda5fb3f0..e15b6b660 100644 --- a/multimedia/media/media_js_standard/MediaTestBase.js +++ b/multimedia/media/media_js_standard/MediaTestBase.js @@ -169,6 +169,31 @@ export async function getFd(pathName) { return fdObject; } +export async function getAudioFd(pathName) { + let fdObject = { + fileAsset : null, + fdNumber : null + } + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.AUDIO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections : fileKeyObj.ID + "=?", + selectionArgs : [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + fdObject.fileAsset = await fetchFileResult.getAllObject(); + fdObject.fdNumber = await fdObject.fileAsset[0].open('rw'); + console.info('case getFd number is: ' + fdObject.fdNumber); + } + return fdObject; +} + export async function closeFd(fileAsset, fdNumber) { if (fileAsset != null) { await fileAsset[0].close(fdNumber).then(() => { diff --git a/multimedia/media/media_js_standard/audioRecorder/Test.json b/multimedia/media/media_js_standard/audioRecorder/Test.json index 67543d85b..39dee9724 100644 --- a/multimedia/media/media_js_standard/audioRecorder/Test.json +++ b/multimedia/media/media_js_standard/audioRecorder/Test.json @@ -10,7 +10,8 @@ { "type": "ShellKit", "run-command": [ - "rm -rf /storage/media/100/local/files/Videos/audio_*" + "rm -rf /storage/media/100/local/files/Videos/audio_*", + "rm -rf /storage/media/100/local/files/Audios/audio_*" ], "teardown-command":[ ] 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 6d6760638..8e3818213 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 @@ -30,7 +30,7 @@ describe('RecorderLocalTestAudioFUNC', function () { const RELEASE_STATE = 7; const ERROR_STATE = 8; const CHECK_STATE = 9; - const RECORDER_TIME = 1000; + const RECORDER_TIME = 3000; const CHANNEL_ONE = 1; const CHANNEL_TWO = 2; const FORMAT_MP4 = media.AudioOutputFormat.MPEG_4; @@ -193,7 +193,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0100', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_01.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_01.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; let trackArray = videoRecorderBase.getTrackArray(ONLYAUDIO_TYPE, audioConfig); @@ -213,7 +213,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0210', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_02.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_02.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.numberOfChannels = CHANNEL_ONE; @@ -234,7 +234,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0220', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_03.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_03.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.numberOfChannels = CHANNEL_TWO; @@ -255,7 +255,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0310', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_04.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_04.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.audioSampleRate = 8000; // samplerate 8000 @@ -277,7 +277,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0320', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_05.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_05.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.audioSampleRate = 32000; // samplerate 32000 @@ -300,7 +300,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0330', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_06.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_06.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.audioSampleRate = 44100; // samplerate 44100 @@ -323,7 +323,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0340', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_07.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_07.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.audioSampleRate = 64000; // samplerate 64000 @@ -346,7 +346,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0340', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_08.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_08.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.audioSampleRate = 96000; // samplerate 96000 @@ -417,7 +417,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0430', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_11.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_11.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.audioSampleRate = 44100; // samplerate 44100 @@ -441,7 +441,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0440', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_12.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_12.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.audioSampleRate = 44100; // samplerate 44100 @@ -465,7 +465,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_CODEC_AAC_0450', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_13.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_13.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.audioSampleRate = 44100; // samplerate 44100 @@ -513,7 +513,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_FORMAT_MP4_0200', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_15.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_15.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.audioEncodeBitRate = 22050; // samplerate 22050 @@ -537,7 +537,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_AUDIO_FUNCTION_06_0100', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_16.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_16.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.format = FORMAT_M4A; @@ -558,7 +558,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_AUDIO_FUNCTION_06_0200', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_17.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_17.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.format = FORMAT_M4A; @@ -579,7 +579,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_AUDIO_FUNCTION_06_0300', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_18.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_18.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.format = FORMAT_M4A; @@ -600,7 +600,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_AUDIO_FUNCTION_06_0500', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_19.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_19.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.format = FORMAT_M4A; @@ -621,7 +621,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_AUDIO_FUNCTION_06_0600', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_20.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_20.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.format = FORMAT_M4A; @@ -642,7 +642,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_AUDIO_FUNCTION_06_0700', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_21.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_21.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.format = FORMAT_M4A; @@ -663,7 +663,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_AUDIO_FUNCTION_06_0800', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_22.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_22.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.format = FORMAT_M4A; @@ -684,7 +684,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_AUDIO_FUNCTION_06_0900', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_23.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_23.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.format = FORMAT_M4A; @@ -706,7 +706,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_AUDIO_FUNCTION_06_1000', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_24.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_24.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); audioConfig.uri = fdPath; audioConfig.format = FORMAT_M4A; @@ -822,7 +822,7 @@ describe('RecorderLocalTestAudioFUNC', function () { * @tc.level : Level0 */ it('SUB_MEDIA_RECORDER_AUDIO_FUNCTION_06_1500', 0, async function (done) { - fdObject = await mediaTestBase.getFd('audio_29.m4a'); + fdObject = await mediaTestBase.getAudioFd('audio_29.m4a'); fdPath = "fd://" + fdObject.fdNumber.toString(); let newAudioConfig = { audioEncodeBitRate : 22050, diff --git a/multimedia/media/media_js_standard/recorderFormat/Test.json b/multimedia/media/media_js_standard/recorderFormat/Test.json index fc4f4c46b..5eca3fb17 100644 --- a/multimedia/media/media_js_standard/recorderFormat/Test.json +++ b/multimedia/media/media_js_standard/recorderFormat/Test.json @@ -10,7 +10,7 @@ { "type": "ShellKit", "run-command": [ - "rm -rf /storage/media/100/local/files/Videos/COMPATIBILITY*" + "rm -rf /storage/media/100/local/files/Audios/COMPATIBILITY*" ], "teardown-command":[ ] diff --git a/multimedia/media/media_js_standard/recorderFormat/src/main/js/test/AudioRecorderFormatCompatibilityTest.test.js b/multimedia/media/media_js_standard/recorderFormat/src/main/js/test/AudioRecorderFormatCompatibilityTest.test.js index 7983c9711..76494637d 100644 --- a/multimedia/media/media_js_standard/recorderFormat/src/main/js/test/AudioRecorderFormatCompatibilityTest.test.js +++ b/multimedia/media/media_js_standard/recorderFormat/src/main/js/test/AudioRecorderFormatCompatibilityTest.test.js @@ -41,7 +41,7 @@ describe('AudioRecorderFormatCompatibilityTest', function () { audioSampleRate : 22050, numberOfChannels : 2, format : media.AudioOutputFormat.AAC_ADTS, - uri : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.m4a', + uri : 'fd://', location : { latitude : 1, longitude : 1 }, } @@ -114,8 +114,8 @@ describe('AudioRecorderFormatCompatibilityTest', function () { let displayName = pathName; const mediaTest = mediaLibrary.getMediaLibrary(); let fileKeyObj = mediaLibrary.FileKey; - let mediaType = mediaLibrary.MediaType.VIDEO; - let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let mediaType = mediaLibrary.MediaType.AUDIO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO); let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); if (dataUri != undefined) { let args = dataUri.id.toString(); -- GitLab