提交 83813a5b 编写于 作者: O openharmony_ci 提交者: Gitee

!1339 上线recorder js测试代码并优化部分代码

Merge pull request !1339 from FULIZHONG/master_1210
...@@ -20,6 +20,7 @@ group("multimedia") { ...@@ -20,6 +20,7 @@ group("multimedia") {
"audio/audio_js_standard/audioManager:audio_manager_js_hap", "audio/audio_js_standard/audioManager:audio_manager_js_hap",
"audio/audio_js_standard/audioPlayer:audio_player_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/audioPlayer_API:audio_player_api_js_hap",
"audio/audio_js_standard/audioRecorder:audio_recorder_js_hap",
"media/media_cpp_test_standard:ActsMediaCppStandardTest", "media/media_cpp_test_standard:ActsMediaCppStandardTest",
] ]
} else { } else {
......
...@@ -10,6 +10,27 @@ ...@@ -10,6 +10,27 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "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/*", "chmod -R 777 /data/accounts/account_0/appdata/recorder/*",
"setenforce 0" "setenforce 0"
], ],
......
...@@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe('RecorderLocalTestAudioAPI', function () { describe('RecorderLocalTestAudioAPI', function () {
let audioRecorder = media.createAudioRecorder(); let audioRecorder = media.createAudioRecorder();
let isTimeOut = false;
const END_STATE = 0; const END_STATE = 0;
const PRE_STATE = 1; const PRE_STATE = 1;
const START_STATE = 2; const START_STATE = 2;
...@@ -28,11 +27,11 @@ describe('RecorderLocalTestAudioAPI', function () { ...@@ -28,11 +27,11 @@ describe('RecorderLocalTestAudioAPI', function () {
const RESET_STATE = 6; const RESET_STATE = 6;
const RELEASE_STATE = 7; const RELEASE_STATE = 7;
const ERROR_STATE = 8; const ERROR_STATE = 8;
const TIME_OUT = 15000; // 15s
const FORMAT_M4A = 6; const FORMAT_M4A = 6;
const SOURCE_TYPE = 1; const SOURCE_TYPE = 1;
const ENCORDER_AACLC = 3; const ENCORDER_AACLC = 3;
const CHANNEL_TWO = 2; const CHANNEL_TWO = 2;
const RECORDER_TIME = 1000;
let audioConfig = { let audioConfig = {
audioSourceType : SOURCE_TYPE, audioSourceType : SOURCE_TYPE,
audioEncoder : ENCORDER_AACLC, audioEncoder : ENCORDER_AACLC,
...@@ -44,6 +43,10 @@ describe('RecorderLocalTestAudioAPI', function () { ...@@ -44,6 +43,10 @@ describe('RecorderLocalTestAudioAPI', function () {
location : { latitude : 1, longitude : 1 }, location : { latitude : 1, longitude : 1 },
} }
function sleep(time) {
for(let t = Date.now();Date.now() - t <= time;);
};
function initAudioRecorder() { function initAudioRecorder() {
if (typeof (audioRecorder) != 'undefined') { if (typeof (audioRecorder) != 'undefined') {
audioRecorder.release(); audioRecorder.release();
...@@ -86,6 +89,7 @@ describe('RecorderLocalTestAudioAPI', function () { ...@@ -86,6 +89,7 @@ describe('RecorderLocalTestAudioAPI', function () {
case RELEASE_STATE: case RELEASE_STATE:
console.info('case to release'); console.info('case to release');
audioRecorder.release(); audioRecorder.release();
audioRecorder = undefined;
break; break;
case ERROR_STATE: case ERROR_STATE:
console.info('case to wait error callback'); console.info('case to wait error callback');
...@@ -103,7 +107,7 @@ describe('RecorderLocalTestAudioAPI', function () { ...@@ -103,7 +107,7 @@ describe('RecorderLocalTestAudioAPI', function () {
}); });
audioRecorder.on('start', () => { audioRecorder.on('start', () => {
console.info('setCallback start() case callback is called'); console.info('setCallback start() case callback is called 111');
sleep(RECORDER_TIME); sleep(RECORDER_TIME);
mySteps.shift(); mySteps.shift();
nextStep(mySteps,done); nextStep(mySteps,done);
...@@ -154,7 +158,6 @@ describe('RecorderLocalTestAudioAPI', function () { ...@@ -154,7 +158,6 @@ describe('RecorderLocalTestAudioAPI', function () {
}) })
beforeEach(function () { beforeEach(function () {
isTimeOut = false;
console.info('beforeEach case'); console.info('beforeEach case');
}) })
...@@ -586,6 +589,7 @@ describe('RecorderLocalTestAudioAPI', function () { ...@@ -586,6 +589,7 @@ describe('RecorderLocalTestAudioAPI', function () {
let mySteps = new Array(RELEASE_STATE, END_STATE); let mySteps = new Array(RELEASE_STATE, END_STATE);
setCallback(mySteps, done); setCallback(mySteps, done);
audioRecorder.release(); audioRecorder.release();
audioRecorder = undefined;
}) })
/* * /* *
......
...@@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe('RecorderLocalTestAudioFUNC', function () { describe('RecorderLocalTestAudioFUNC', function () {
let audioRecorder = media.createAudioRecorder(); let audioRecorder = media.createAudioRecorder();
let isTimeOut = false;
const BASIC_PATH = 'file:///data/accounts/account_0/appdata/recorder/' const BASIC_PATH = 'file:///data/accounts/account_0/appdata/recorder/'
const END_STATE = 0; const END_STATE = 0;
const PRE_STATE = 1; const PRE_STATE = 1;
...@@ -29,8 +28,7 @@ describe('RecorderLocalTestAudioFUNC', function () { ...@@ -29,8 +28,7 @@ describe('RecorderLocalTestAudioFUNC', function () {
const RESET_STATE = 6; const RESET_STATE = 6;
const RELEASE_STATE = 7; const RELEASE_STATE = 7;
const ERROR_STATE = 8; const ERROR_STATE = 8;
const RECORDER_TIME = 5000; const RECORDER_TIME = 1000;
const TIME_OUT = 20000; // 20s
const CHANNEL_ONE = 1; const CHANNEL_ONE = 1;
const CHANNEL_TWO = 2; const CHANNEL_TWO = 2;
const FORMAT_MP4 = 2; const FORMAT_MP4 = 2;
...@@ -65,7 +63,6 @@ describe('RecorderLocalTestAudioFUNC', function () { ...@@ -65,7 +63,6 @@ describe('RecorderLocalTestAudioFUNC', function () {
}) })
beforeEach(function () { beforeEach(function () {
isTimeOut = false;
console.info('beforeEach case'); console.info('beforeEach case');
}) })
...@@ -111,6 +108,7 @@ describe('RecorderLocalTestAudioFUNC', function () { ...@@ -111,6 +108,7 @@ describe('RecorderLocalTestAudioFUNC', function () {
case RELEASE_STATE: case RELEASE_STATE:
console.info('case to release'); console.info('case to release');
audioRecorder.release(); audioRecorder.release();
audioRecorder = undefined;
break; break;
case ERROR_STATE: case ERROR_STATE:
console.info('case to wait error callback'); console.info('case to wait error callback');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册