未验证 提交 35d22c84 编写于 作者: O openharmony_ci 提交者: Gitee

!2291 Updating Audio Standard JS Test scripts - Issue fix

Merge pull request !2291 from GaganP/audioframework_Master_09Mar2022
......@@ -7855,4 +7855,350 @@ describe('audioRenderer', function () {
})
/* *
* @tc.number : SUB_AUDIO_RENDERER_Play_audio_108
* @tc.name : AudioState - STATE_INVALID
* @tc.desc : AudioState - STATE_INVALID
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_RENDERER_Play_audio_108', 0, async function (done) {
expect(audio.AudioState.STATE_INVALID).assertEqual(-1);
await sleep(50);
done();
})
/* *
* @tc.number : SUB_AUDIO_RENDERER_Play_audio_109
* @tc.name : AudioState - STATE_NEW
* @tc.desc : AudioState - STATE_NEW
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_RENDERER_Play_audio_109', 0, async function (done) {
expect(audio.AudioState.STATE_NEW).assertEqual(0);
await sleep(50);
done();
})
/* *
* @tc.number : SUB_AUDIO_RENDERER_Play_audio_110
* @tc.name : AudioSampleFormat - STATE_FORMAT_INVALID
* @tc.desc : AudioSampleFormat - STATE_FORMAT_INVALID
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_RENDERER_Play_audio_110', 0, async function (done) {
expect(audio.AudioSampleFormat.SAMPLE_FORMAT_INVALID).assertEqual(-1);
await sleep(50);
done();
})
/* *
* @tc.number : SUB_AUDIO_RENDERER_Play_audio_111
* @tc.name : SourceType - SOURCE_TYPE_INVALID
* @tc.desc : SourceType - SOURCE_TYPE_INVALID
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_RENDERER_Play_audio_111', 0, async function (done) {
expect(audio.SourceType.SOURCE_TYPE_INVALID).assertEqual(-1);
await sleep(50);
done();
})
/* *
* @tc.number : SUB_AUDIO_RENDERER_Play_audio_112
* @tc.name : AudioRenderer - Pause - Callback
* @tc.desc : AudioRenderer - Pause - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_RENDERER_Play_audio_112', 0,async function (done) {
var AudioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
var AudioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_RINGTONE,
usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE,
rendererFlags: 1
}
var AudioRendererOptions = {
streamInfo: AudioStreamInfo,
rendererInfo: AudioRendererInfo
}
var resultFlag = false;
var audioRen;
await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) {
audioRen = data;
console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : '+err.message);
resultFlag = false;
});
audioRen.on('stateChange',(AudioState) => {
console.log('AudioFrameworkTest: Volume Change Event is called');
switch (AudioState) {
case audio.AudioState.STATE_PAUSED:
console.info('AudioFrameworkTest: state : STATE_PAUSED');
resultFlag = true;
break;
default:
console.info('AudioFrameworkTest: state : '+AudioState);
break;
}
});
await audioRen.start().then(async function () {
console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS ');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message);
resultFlag=false;
});
await sleep(2000);
audioRen.pause((err) => {
if (err) {
console.info('AudioFrameworkRenderLog: renderInstant Pause :ERROR : '+err.message);
resultFlag=false;
}
else{
console.info('AudioFrameworkRenderLog: renderInstant Pause :SUCCESS ');
}
});
await sleep(500);
await audioRen.stop().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message);
});
await sleep(500);
await audioRen.release().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message);
});
await sleep(500)
expect(resultFlag).assertTrue();
done();
})
/* *
* @tc.number : SUB_AUDIO_RENDERER_Play_audio_113
* @tc.name : AudioRenderer - SetRenderRate - RENDER_RATE_DOUBLE - Callback
* @tc.desc : AudioRenderer - SetRenderRate - RENDER_RATE_DOUBLE - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_RENDERER_Play_audio_113', 0,async function (done) {
var AudioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
var AudioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_RINGTONE,
usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE,
rendererFlags: 1
}
var AudioRendererOptions = {
streamInfo: AudioStreamInfo,
rendererInfo: AudioRendererInfo
}
var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav';
var AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT;
var resultFlag = true;
console.info('AudioFrameworkRenderLog: Promise : Audio Playback Function');
var audioRen;
await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) {
audioRen = data;
console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : '+err.message);
resultFlag=false;
});
console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath);
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
await audioManager.setAudioScene(AudioScene).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
await audioManager.getAudioScene().then(async function (data) {
console.info('AudioFrameworkRenderLog: getAudioScene : Value : '+data);
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
resultFlag=false;
});
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
await audioRen.getStreamInfo().then(async function (audioParamsGet) {
console.info('AudioFrameworkRenderLog: Renderer getStreamInfo:');
console.info('AudioFrameworkRenderLog: Renderer sampleFormat:' + audioParamsGet.sampleFormat);
console.info('AudioFrameworkRenderLog: Renderer samplingRate:' + audioParamsGet.samplingRate);
console.info('AudioFrameworkRenderLog: Renderer channels:' + audioParamsGet.channels);
console.info('AudioFrameworkRenderLog: Renderer encodingType:' + audioParamsGet.encodingType);
}).catch((err) => {
console.log('AudioFrameworkRenderLog: getStreamInfo :ERROR: '+err.message);
resultFlag = false;
});
await audioRen.getRendererInfo().then(async function (audioParamsGet) {
console.info('AudioFrameworkRenderLog: Renderer RendererInfo:');
console.info('AudioFrameworkRenderLog: Renderer content type:' + audioParamsGet.content);
console.info('AudioFrameworkRenderLog: Renderer usage:' + audioParamsGet.usage);
console.info('AudioFrameworkRenderLog: Renderer rendererFlags:' + audioParamsGet.rendererFlags);
}).catch((err) => {
console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message);
resultFlag = false;
});
await audioRen.start().then(async function () {
console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS ');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message);
resultFlag=false;
});
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
var bufferSize = await audioRen.getBufferSize();
console.info('AudioFrameworkRenderLog: buffer size: ' + bufferSize);
let ss = fileio.createStreamSync(fpath, 'r');
console.info('AudioFrameworkRenderLog: File Path: ' + fpath);
let discardHeader = new ArrayBuffer(44);
ss.readSync(discardHeader);
let totalSize = fileio.statSync(fpath).size;
console.info('AudioFrameworkRenderLog: File totalSize size: ' +totalSize);
totalSize = totalSize-44;
console.info('AudioFrameworkRenderLog: File size : Removing header: ' +totalSize);
let rlen = 0;
while (rlen < totalSize) {
let buf = new ArrayBuffer(bufferSize);
rlen += ss.readSync(buf);
console.info('BufferAudioFramework: bytes read from file: ' +rlen);
await audioRen.write(buf);
if (rlen > (totalSize/2)){
await audioManager.getAudioScene().then(async function (data) {
console.info('AudioFrameworkAudioScene: getAudioScene : Value : '+data);
}).catch((err) => {
console.info('AudioFrameworkAudioScene: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
}
if (rlen > (totalSize/2)){
audioRen.setRenderRate(audio.AudioRendererRate.RENDER_RATE_DOUBLE, (err) => {
if (err) {
console.info('AudioFrameworkAudioScene: setRenderRate : RENDER_RATE_DOUBLE : ERROR : '+err.message);
resultFlag=false;
}
else {
console.info('AudioFrameworkRenderLog: setRenderRate : RENDER_RATE_DOUBLE : SUCCESS');
}
});
}
}
console.info('AudioFrameworkRenderLog: Renderer after read');
audioRen.getRenderRate((err, data) => {
if (err) {
console.info('AudioFrameworkAudioScene: getRenderRate : RENDER_RATE_DOUBLE : ERROR : '+err.message);
resultFlag=false;
}
else if (data == audio.AudioRendererRate.RENDER_RATE_DOUBLE){
console.info('AudioFrameworkRenderLog: getRenderRate : RENDER_RATE_DOUBLE : PASS : '+data);
}
else{
console.info('AudioFrameworkRenderLog: getRenderRate : RENDER_RATE_DOUBLE : FAIL : '+data);
resultFlag=false;
}
});
await audioRen.drain().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer drained : SUCCESS');
}).catch((err) => {
console.error('AudioFrameworkRenderLog: Renderer drain: ERROR : '+err.message);
});
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
await audioRen.stop().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message);
});
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
await audioRen.release().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message);
});
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag);
await sleep(500)
expect(resultFlag).assertTrue();
done();
})
/* *
* @tc.number : SUB_AUDIO_RENDERER_Play_audio_114
* @tc.name : AudioEncodingType - ENCODING_TYPE_INVALID
* @tc.desc : AudioEncodingType - ENCODING_TYPE_INVALID
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_RENDERER_Play_audio_114', 0, async function (done) {
expect(audio.AudioEncodingType.ENCODING_TYPE_INVALID).assertEqual(-1);
await sleep(50);
done();
})
})
\ No newline at end of file
......@@ -14,7 +14,7 @@
*/
require('./AudioFramework.test.js')
require('./AudioPerf.test.js')
//require('./AudioPerf.test.js')
require('./AudioRenderer.test.js')
require('./SR000GHLLV.test.js')
require('./AudioCall.test.js')
......
......@@ -1303,7 +1303,7 @@ describe('audioManger', function () {
it('SUB_AUDIO_MANAGER_ON_setDeviceActive_SPEAKER_037', 0, async function (done) {
await audioManager.setDeviceActive(audio.DeviceType.SPEAKER,false).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
}).catch ((err) => {
}).catch((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Activate: Error: ${err.message}`);
});
var setflag ;
......@@ -1330,7 +1330,7 @@ describe('audioManger', function () {
});
await audioManager.setDeviceActive(audio.DeviceType.SPEAKER,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
}).catch ((err) => {
}).catch((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Activate: Error: ${err.message}`);
});
done();
......@@ -1367,7 +1367,7 @@ describe('audioManger', function () {
});
await audioManager.setDeviceActive(2,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
}).catch ((err) => {
}).catch((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Activate: Error: ${err.message}`);
});
})
......@@ -1400,7 +1400,7 @@ describe('audioManger', function () {
});
await audioManager.setDeviceActive(audio.ActiveDeviceType.BLUETOOTH_SCO,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Active');
}).catch ((err) => {
}).catch((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Activate: Error: ${err.message}`);
});
done();
......@@ -1437,7 +1437,7 @@ describe('audioManger', function () {
});
await audioManager.setDeviceActive(7,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Active');
}).catch ((err) => {
}).catch((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Activate: Error: ${err.message}`);
});
done();
......@@ -1472,7 +1472,7 @@ describe('audioManger', function () {
});
await audioManager.setDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active');
}).catch ((err) => {
}).catch((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Activate: Error: ${err.message}`);
});
done();
......@@ -1515,7 +1515,7 @@ describe('audioManger', function () {
});
await audioManager.setDeviceActive(3,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active');
}).catch ((err) => {
}).catch((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Activate: Error: ${err.message}`);
});
done();
......@@ -1543,19 +1543,19 @@ describe('audioManger', function () {
await sleep(1000);
await audioManager.setDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active');
}).catch ((err) => {
}).catch((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Activate: Error: ${err.message}`);
});
await sleep(5000);
await audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
}).catch ((err) => {
}).catch((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Activate: Error: ${err.message}`);
});
await sleep(5000);
await audioManager.setDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active Again');
}).catch ((err) => {
}).catch((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Activate Again: Error: ${err.message}`);
});
await sleep(5000);
......@@ -1577,4 +1577,36 @@ describe('audioManger', function () {
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_DeviceType_001
* @tc.name : DeviceType - INVALID
* @tc.desc : DeviceType - INVALID
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_DeviceType_001', 0, async function (done) {
expect(audio.DeviceType.INVALID).assertEqual(0);
await sleep(50);
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_DeviceType_002
* @tc.name : DeviceType - WIRED_HEADSET
* @tc.desc : DeviceType - WIRED_HEADSET
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_DeviceType_001', 0, async function (done) {
expect(audio.DeviceType.WIRED_HEADSET).assertEqual(3);
await sleep(50);
done();
})
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册