未验证 提交 1f5144bc 编写于 作者: O openharmony_ci 提交者: Gitee

!6435 audio error code

Merge pull request !6435 from wangtao/mon-dev
...@@ -45,6 +45,8 @@ describe('audioCapturer', function () { ...@@ -45,6 +45,8 @@ describe('audioCapturer', function () {
const GET_STREAMINFO_EVENT = 'getStreamInfo'; const GET_STREAMINFO_EVENT = 'getStreamInfo';
const GET_AUDIOSCENE_EVENT = 'getAudioScene'; const GET_AUDIOSCENE_EVENT = 'getAudioScene';
const ERROR_EVENT = 'error'; const ERROR_EVENT = 'error';
let stringParameter = "invalid_parameter";
let numberParameter = 999999;
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
function sleep(ms) { function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
...@@ -1940,6 +1942,68 @@ describe('audioCapturer', function () { ...@@ -1940,6 +1942,68 @@ describe('audioCapturer', function () {
done(); done();
}) })
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_READ_WRITE_0200
*@tc.name : AudioCapturer-GET_AUDIO_TIME
*@tc.desc : AudioCapturer GET_AUDIO_TIME
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_READ_WRITE_0200', 2, async function (done) {
await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm");
let AudioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
let AudioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 0
}
let AudioCapturerOptions = {
streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo
}
let audioCapPromise;
try {
audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions);
console.log(`${Tag} createAudioCapturer ok`);
} catch (err) {
console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
return done();
}
try {
await audioCapPromise.start();
console.log(`${Tag} start ok`);
let audioTime = await audioCapPromise.getAudioTime();
console.log(`${Tag} audioTime: ${JSON.stringify(audioTime)}`);
expect(audioTime).assertLarger(0);
await audioCapPromise.read(stringParameter, true);
} catch (err) {
if (err.code == 6800101) {
console.log(`audioVolumeManager on : PASS : message:${err.message}`);
expect(true).assertTrue();
}else {
console.log(`audioVolumeManager on : FAIL : message:${err.message}`);
expect(false).assertTrue();
}
}
try {
await audioCapPromise.release();
} catch (err) {
console.log(`${Tag} err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
}
done();
})
/** /**
*@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_STOP_0100 *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_STOP_0100
*@tc.name : AudioCapturer-GET_AUDIO_TIME *@tc.name : AudioCapturer-GET_AUDIO_TIME
...@@ -2040,6 +2104,62 @@ describe('audioCapturer', function () { ...@@ -2040,6 +2104,62 @@ describe('audioCapturer', function () {
done(); done();
}) })
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_STOP_0100
*@tc.name : AudioCapturer-GET_AUDIO_TIME
*@tc.desc : AudioCapturer GET_AUDIO_TIME
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_STOP_0100', 2, async function (done) {
await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm");
let AudioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
let AudioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 0
}
let AudioCapturerOptions = {
streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo
}
let audioCapPromise;
try {
audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions);
console.log(`${Tag} createAudioCapturer ok`);
} catch (err) {
console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
return done();
}
try {
await audioCapPromise.stop();
} catch (err) {
if (err.code == 6800301) {
console.log(`${Tag} stop error code : PASS : message:${err.message}`);
expect(true).assertTrue();
}else {
console.log(`${Tag} stop error code : FAIL : message:${err.message}`);
expect(false).assertTrue();
}
}
try {
await audioCapPromise.release();
} catch (err) {
console.log(`${Tag} err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
}
done();
})
/** /**
*@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_GET_AUDIO_TIME_0100 *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_GET_AUDIO_TIME_0100
*@tc.name : AudioCapturer-GET_AUDIO_TIME *@tc.name : AudioCapturer-GET_AUDIO_TIME
......
...@@ -19,6 +19,11 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from ...@@ -19,6 +19,11 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
describe('audioTonePlayer',function() { describe('audioTonePlayer',function() {
let tonePlayerCallback = null; let tonePlayerCallback = null;
let name; let name;
let TagTone = 'AudioTonePlayerTest';
let stringParameter = "invalid_parameter";
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
beforeAll(function(){ beforeAll(function(){
console.log('beforeAll test suit is executed'); console.log('beforeAll test suit is executed');
}) })
...@@ -1128,4 +1133,180 @@ describe('audioTonePlayer',function() { ...@@ -1128,4 +1133,180 @@ describe('audioTonePlayer',function() {
}, 2000) }, 2000)
}) })
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0100
*@tc.name : AudioTonePlayer-create
*@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0100', 2, function(done) {
audio.createTonePlayer(stringParameter).then(async (result) => {
console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result));
await result.release().then(() => {
console.info('recPromiseFail TonePlayer : RELEASE SUCCESS');
console.info('recPromiseFail ---------RELEASE---------');
}).catch((err) => {
console.error("recPromiseFail call release fail " + JSON.stringify(err));
});
expect(false).assertTrue();
}).catch((err) => {
console.log('err :' + err.code)
if (err.code == 6800101) {
console.log(`${TagTone}: load : PASS : message:${err.message}`);
expect(true).assertTrue();
}else {
console.log(`${TagTone}: load : FAIL : message:${err.message}`);
expect(false).assertTrue();
}
});
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0100
*@tc.name : AudioTonePlayer-create
*@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_CREATETONEPLAYER_0200', 2, function(done) {
audio.createTonePlayer(stringParameter, async (err, data)=>{
if (err) {
console.log('err :' + err.code)
if (err.code == 6800101) {
console.log(`${TagTone}: load : PASS : message:${err.message}`);
expect(true).assertTrue();
}else {
console.log(`${TagTone}: load : FAIL : message:${err.message}`);
expect(false).assertTrue();
}
} else {
await data.release().then(() => {
console.info('recPromiseFail TonePlayer : RELEASE SUCCESS');
console.info('recPromiseFail ---------RELEASE---------');
}).catch((err) => {
console.error("recPromiseFail call release fail " + JSON.stringify(err));
});
expect(false).assertTrue();
}
done();
})
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0100
*@tc.name : AudioTonePlayer-create-load-stop-release success
*@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 1
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0100', 2, async function(done) {
let tPlayer = null;
let audioRendererInfo = {
"contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION,
"streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA,
"rendererFlags": 0
}
await audio.createTonePlayer(audioRendererInfo).then((result) => {
console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result));
tPlayer = result;
}).catch((err) => {
console.error("recPromiseFail call createTonePlayer fail err: "+ JSON.stringify(err)+ ' tPlayer: '+ tPlayer);
console.error("recPromiseFail call createTonePlayer ---fail");
});
await tPlayer.load(stringParameter).then(() => {
console.info('AudioFrameworkRecLog: ---------LOAD---------');
expect(false).assertTrue();
}).catch((err) => {
console.log('err :' + err.code)
if (err.code == 6800101) {
console.log(`${TagTone}: load : PASS : message:${err.message}`);
expect(true).assertTrue();
}else {
console.log(`${TagTone}: load : FAIL : message:${err.message}`);
expect(false).assertTrue();
}
});
await tPlayer.stop().then(() => {
console.info('AudioFrameworkRecLog: TonePlayer : STOP SUCCESS');
console.info('AudioFrameworkRecLog: ---------STOP---------');
}).catch((err) => {
console.error(`promise call stop ---fail error. ${err.message}`);
});
await tPlayer.release().then(() => {
console.info('recPromiseFail TonePlayer : RELEASE SUCCESS');
console.info('recPromiseFail ---------RELEASE---------');
}).catch((err) => {
console.error("recPromiseFail call release fail " + JSON.stringify(err));
});
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0200
*@tc.name : AudioTonePlayer-create-load-stop-release success
*@tc.desc : The successful test case of the promise of the dial tone of AudioTonePlayer key 1
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_TONEPLAYER_LOAD_0200', 2, async function(done) {
let time1 = (new Date()).getTime();
let tPlayer = null;
let audioRendererInfo = {
"contentType": audio.ContentType.CONTENT_TYPE_SONIFICATION,
"streamUsage": audio.StreamUsage.STREAM_USAGE_MEDIA,
"rendererFlags": 0
}
await audio.createTonePlayer(audioRendererInfo).then((result) => {
console.info("recPromiseFail call createTonePlayer-----result:" + JSON.stringify(result));
tPlayer = result;
}).catch((err) => {
console.error("recPromiseFail call createTonePlayer fail err: "+ JSON.stringify(err)+ ' tPlayer: '+ tPlayer);
console.error("recPromiseFail call createTonePlayer ---fail");
});
await tPlayer.load(stringParameter, (err, data)=>{
if (err) {
console.log('err :' + err.code)
if (err.code == 6800101) {
console.log(`${TagTone}: load : PASS : message:${err.message}`);
expect(true).assertTrue();
}else {
console.log(`${TagTone}: load : FAIL : message:${err.message}`);
expect(false).assertTrue();
}
} else {
console.info('AudioFrameworkRecLog: ---------LOAD---------');
expect(false).assertTrue();
}
});
await sleep(1000);
await tPlayer.stop().then(() => {
console.info('AudioFrameworkRecLog: TonePlayer : STOP SUCCESS');
console.info('AudioFrameworkRecLog: ---------STOP---------');
}).catch((err) => {
console.error(`promise call stop ---fail error. ${err.message}`);
});
await tPlayer.release().then(() => {
console.info('recPromiseFail TonePlayer : RELEASE SUCCESS');
console.info('recPromiseFail ---------RELEASE---------');
}).catch((err) => {
console.error("recPromiseFail call release fail " + JSON.stringify(err));
});
let time2 = (new Date).getTime();
console.info('time: ' + (time2 - time1));
done();
})
}) })
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册