From 6b2ec4b93fc23055c4a78748132fbcc20b2a50f9 Mon Sep 17 00:00:00 2001 From: FULIZHONG Date: Fri, 10 Dec 2021 01:54:38 +0000 Subject: [PATCH] open recorder js testcase Signed-off-by: FULIZHONG --- multimedia/BUILD.gn | 1 + .../audio_js_standard/audioRecorder/Test.json | 21 +++++++++++++++++++ .../js/test/RecorderLocalTestAudioAPI.test.js | 12 +++++++---- .../test/RecorderLocalTestAudioFUNC.test.js | 6 ++---- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/multimedia/BUILD.gn b/multimedia/BUILD.gn index 3458bc903..a8fd227ea 100755 --- a/multimedia/BUILD.gn +++ b/multimedia/BUILD.gn @@ -20,6 +20,7 @@ group("multimedia") { "audio/audio_js_standard/audioManager:audio_manager_js_hap", "audio/audio_js_standard/audioPlayer:audio_player_js_hap", "audio/audio_js_standard/audioPlayer_API:audio_player_api_js_hap", + "audio/audio_js_standard/audioRecorder:audio_recorder_js_hap", "media/media_cpp_test_standard:ActsMediaCppStandardTest", ] } else { diff --git a/multimedia/audio/audio_js_standard/audioRecorder/Test.json b/multimedia/audio/audio_js_standard/audioRecorder/Test.json index 7675546c9..f2ae62d2f 100644 --- a/multimedia/audio/audio_js_standard/audioRecorder/Test.json +++ b/multimedia/audio/audio_js_standard/audioRecorder/Test.json @@ -10,6 +10,27 @@ { "type": "ShellKit", "run-command": [ + "mkdir -p /data/accounts/account_0/appdata/recorder", + "touch /data/accounts/account_0/appdata/recorder/test1.m4a", + "touch /data/accounts/account_0/appdata/recorder/test2.m4a", + "touch /data/accounts/account_0/appdata/recorder/test3.m4a", + "touch /data/accounts/account_0/appdata/recorder/test4.m4a", + "touch /data/accounts/account_0/appdata/recorder/test5.mp4", + "touch /data/accounts/account_0/appdata/recorder/test6.mp4", + "touch /data/accounts/account_0/appdata/recorder/test7.m4a", + "touch /data/accounts/account_0/appdata/recorder/test8.m4a", + "touch /data/accounts/account_0/appdata/recorder/test9.mp4", + "touch /data/accounts/account_0/appdata/recorder/test10.mp4", + "touch /data/accounts/account_0/appdata/recorder/test11.m4a", + "touch /data/accounts/account_0/appdata/recorder/test12.m4a", + "touch /data/accounts/account_0/appdata/recorder/test13.m4a", + "touch /data/accounts/account_0/appdata/recorder/test14.mp4", + "touch /data/accounts/account_0/appdata/recorder/test15.m4a", + "touch /data/accounts/account_0/appdata/recorder/test16.m4a", + "touch /data/accounts/account_0/appdata/recorder/test17.m4a", + "touch /data/accounts/account_0/appdata/recorder/test18.mp4", + "touch /data/accounts/account_0/appdata/recorder/test19.m4a", + "touch /data/accounts/account_0/appdata/recorder/testAPI.m4a", "chmod -R 777 /data/accounts/account_0/appdata/recorder/*", "setenforce 0" ], diff --git a/multimedia/audio/audio_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js b/multimedia/audio/audio_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js index d3f131034..228ab339b 100644 --- a/multimedia/audio/audio_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js +++ b/multimedia/audio/audio_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js @@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' describe('RecorderLocalTestAudioAPI', function () { let audioRecorder = media.createAudioRecorder(); - let isTimeOut = false; const END_STATE = 0; const PRE_STATE = 1; const START_STATE = 2; @@ -28,11 +27,11 @@ describe('RecorderLocalTestAudioAPI', function () { const RESET_STATE = 6; const RELEASE_STATE = 7; const ERROR_STATE = 8; - const TIME_OUT = 15000; // 15s const FORMAT_M4A = 6; const SOURCE_TYPE = 1; const ENCORDER_AACLC = 3; const CHANNEL_TWO = 2; + const RECORDER_TIME = 1000; let audioConfig = { audioSourceType : SOURCE_TYPE, audioEncoder : ENCORDER_AACLC, @@ -44,6 +43,10 @@ describe('RecorderLocalTestAudioAPI', function () { location : { latitude : 1, longitude : 1 }, } + function sleep(time) { + for(let t = Date.now();Date.now() - t <= time;); + }; + function initAudioRecorder() { if (typeof (audioRecorder) != 'undefined') { audioRecorder.release(); @@ -86,6 +89,7 @@ describe('RecorderLocalTestAudioAPI', function () { case RELEASE_STATE: console.info('case to release'); audioRecorder.release(); + audioRecorder = undefined; break; case ERROR_STATE: console.info('case to wait error callback'); @@ -103,7 +107,7 @@ describe('RecorderLocalTestAudioAPI', function () { }); audioRecorder.on('start', () => { - console.info('setCallback start() case callback is called'); + console.info('setCallback start() case callback is called 111'); sleep(RECORDER_TIME); mySteps.shift(); nextStep(mySteps,done); @@ -154,7 +158,6 @@ describe('RecorderLocalTestAudioAPI', function () { }) beforeEach(function () { - isTimeOut = false; console.info('beforeEach case'); }) @@ -586,6 +589,7 @@ describe('RecorderLocalTestAudioAPI', function () { let mySteps = new Array(RELEASE_STATE, END_STATE); setCallback(mySteps, done); audioRecorder.release(); + audioRecorder = undefined; }) /* * diff --git a/multimedia/audio/audio_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js b/multimedia/audio/audio_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js index 5ead0c2fe..c2fa6a7e3 100644 --- a/multimedia/audio/audio_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js +++ b/multimedia/audio/audio_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js @@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' describe('RecorderLocalTestAudioFUNC', function () { let audioRecorder = media.createAudioRecorder(); - let isTimeOut = false; const BASIC_PATH = 'file:///data/accounts/account_0/appdata/recorder/' const END_STATE = 0; const PRE_STATE = 1; @@ -29,8 +28,7 @@ describe('RecorderLocalTestAudioFUNC', function () { const RESET_STATE = 6; const RELEASE_STATE = 7; const ERROR_STATE = 8; - const RECORDER_TIME = 5000; - const TIME_OUT = 20000; // 20s + const RECORDER_TIME = 1000; const CHANNEL_ONE = 1; const CHANNEL_TWO = 2; const FORMAT_MP4 = 2; @@ -65,7 +63,6 @@ describe('RecorderLocalTestAudioFUNC', function () { }) beforeEach(function () { - isTimeOut = false; console.info('beforeEach case'); }) @@ -111,6 +108,7 @@ describe('RecorderLocalTestAudioFUNC', function () { case RELEASE_STATE: console.info('case to release'); audioRecorder.release(); + audioRecorder = undefined; break; case ERROR_STATE: console.info('case to wait error callback'); -- GitLab