diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js index 8cde62dfcfb63dbce17a2cdd2209c70737744b5a..3467d0c50c5c909e5a95053c97ce6a69e3e48e29 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js @@ -45,6 +45,8 @@ describe('audioCapturer', function () { const GET_STREAMINFO_EVENT = 'getStreamInfo'; const GET_AUDIOSCENE_EVENT = 'getAudioScene'; const ERROR_EVENT = 'error'; + let stringParameter = "invalid_parameter"; + let numberParameter = 999999; let eventEmitter = new events.EventEmitter(); function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); @@ -1940,6 +1942,68 @@ describe('audioCapturer', function () { 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.name : AudioCapturer-GET_AUDIO_TIME @@ -2040,6 +2104,62 @@ describe('audioCapturer', function () { 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.name : AudioCapturer-GET_AUDIO_TIME diff --git a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js index 7ed81ae397239aff9ca9fe9c511504b4c55ab2d3..c05f15d30bdec982f54a8a2e199fe3b6f5d7441e 100644 --- a/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js +++ b/multimedia/audio/audio_js_standard/AudioTonePlayer/src/main/js/test/AudioTonePlayer.test.js @@ -19,6 +19,11 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from describe('audioTonePlayer',function() { let tonePlayerCallback = null; let name; + let TagTone = 'AudioTonePlayerTest'; + let stringParameter = "invalid_parameter"; + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } beforeAll(function(){ console.log('beforeAll test suit is executed'); }) @@ -1128,4 +1133,180 @@ describe('audioTonePlayer',function() { }, 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 diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js index 20d42d14f222c1e34895f96f530f16ac914bb034..39cd5975d44cd74b6152a3d20d0890a8d542fbc2 100755 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js @@ -37,6 +37,8 @@ describe('audioFramework', function () { let highVol = 14; let outOfRangeVol = 28; let longValue = '28374837458743875804735081439085918459801437584738967509184509813904850914375904790589104801843'; + let stringParameter = "invalid_parameter"; + let numberParameter = 999999; function getAudioManager() { audioManager = audio.getAudioManager(); if (audioManager != null) { @@ -958,6 +960,154 @@ describe('audioFramework', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETVOLUME_2900 + *@tc.name : setVolume Callback + *@tc.desc : Setvolume + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETVOLUME_2900', 2, function (done) { + audioManager.setVolume(stringParameter, lowVol, (err) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.info('${TagFrmwk}: Callback: setVolume : FAIL'); + expect(false).assertTrue(); + } + done(); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETVOLUME_3000 + *@tc.name : setVolume Promise + *@tc.desc : Setvolume + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETVOLUME_3000', 2, async function (done) { + try { + await audioManager.setVolume(numberParameter, highVol); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: setVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETVOLUME_3100 + *@tc.name : setVolume Promise + *@tc.desc : Setvolume + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETVOLUME_3100', 2, async function (done) { + try { + await audioManager.setVolume(audio.AudioVolumeType.MEDIA, stringParameter); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETVOLUME_3200 + *@tc.name : setVolume Promise + *@tc.desc : Setvolume + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETVOLUME_3200', 2, async function (done) { + try { + await audioManager.setVolume(audio.AudioVolumeType.MEDIA, numberParameter); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: setVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETVOLUME_0100 + *@tc.name : getVolume Promise + *@tc.desc : getVolume + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETVOLUME_0100', 2, async function (done) { + try { + await audioManager.getVolume(audio.AudioVolumeType.MEDIA, numberParameter); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: getVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETVOLUME_0200 + *@tc.name : getVolume Promise + *@tc.desc : getVolume + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETVOLUME_0200', 2, async function (done) { + try { + await audioManager.getVolume(audio.AudioVolumeType.MEDIA, numberParameter); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: getVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETMAXVOLUME_0100 *@tc.name : getMaxVolume - Media - Promise @@ -1260,6 +1410,59 @@ describe('audioFramework', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETMAXVOLUME_1300 + *@tc.name : getMaxVolume - Callback + *@tc.desc : getMaxVolume + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETMAXVOLUME_1300', 2, async function (done) { + audioManager.getMaxVolume(numberParameter, (err, value) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: getMaxVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMaxVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.info(`${TagFrmwk}: Callback: setVolume : FAIL`); + expect(false).assertTrue(); + } + done(); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETMAXVOLUME_1400 + *@tc.name : getMaxVolume Promise + *@tc.desc : getMaxVolume + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETMAXVOLUME_1400', 2, async function (done) { + try { + await audioManager.getMaxVolume(stringParameter); + expect(false).assertTrue(); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getMaxVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMaxVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETMINVOLUME_0100 *@tc.name : getMinVolume - Media - Promise @@ -1618,6 +1821,60 @@ describe('audioFramework', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETMINVOLUME_1300 + *@tc.name : getMinVolume - Callback + *@tc.desc : getMinVolume + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETMINVOLUME_1300', 2, async function (done) { + await audioManager.setVolume(audioRingtone, highVol); + audioManager.getMinVolume(numberParameter, (err, value) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: setVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.info(`${TagFrmwk}: Callback: setVolume : FAIL`); + expect(false).assertTrue(); + } + done(); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETMINVOLUME_1400 + *@tc.name : getMinVolume Promise + *@tc.desc : getMinVolume + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETMINVOLUME_1400', 2, async function (done) { + try { + await audioManager.getMinVolume(stringParameter); + expect(false).assertTrue(); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getMinVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMinVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETDEVICES_0100 *@tc.name : getDevices - Output device - Promise @@ -1949,7 +2206,7 @@ describe('audioFramework', function () { *@tc.type : Function *@tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETDEVICES_1200', 2, function (done) { + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETDEVICES_1200', 2, function (done) { audioManager.getDevices(audio.DeviceFlag.ALL_DEVICES_FLAG, (err, value) => { console.info(`${TagFrmwk}: Callback: getDevices ALL_DEVICES_FLAG`); if (err) { @@ -1970,6 +2227,58 @@ describe('audioFramework', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETDEVICES_1300 + *@tc.name : getDevices - ALL device - Callback - ENAME + *@tc.desc : getDevices - ALL device + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETDEVICES_1300', 2, function (done) { + audioManager.getDevices(numberParameter, (err, value) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: getDevices : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getDevices : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.info(`${TagFrmwk}: Callback: getDevices : FAIL`); + expect(false).assertTrue(); + } + done(); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETDEVICES_1400 + *@tc.name : getDevices - ALL device - Callback - ENAME + *@tc.desc : getDevices - ALL device + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETDEVICES_1400', 2, async function (done) { + try { + await audioManager.getDevices(stringParameter); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getDevices : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getDevices : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETRINGERMODE_0100 *@tc.name : setRingerMode - Normal Mode - Promise @@ -2331,6 +2640,59 @@ describe('audioFramework', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETRINGERMODE_1300 + *@tc.name : setRingerMode - Vibration Mode - Callback + *@tc.desc : setRingerMode - Set Ring more to Vibration Mode + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETRINGERMODE_1300', 2, function (done) { + audioManager.setRingerMode(stringParameter, (err, value) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setRingerMode : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setRingerMode : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.info(`${TagFrmwk}: Callback: setRingerMode : FAIL`); + expect(false).assertTrue(); + } + done(); + }); + }) + + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETRINGERMODE_1400 + *@tc.name : setRingerMode - Vibration Mode - Callback + *@tc.desc : setRingerMode - Set Ring more to Vibration Mode + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETRINGERMODE_1400', 2, async function (done) { + try { + await audioManager.setRingerMode(stringParameter); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setRingerMode : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setRingerMode : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_MUTE_0100 *@tc.name : mute - Media - callback @@ -3218,6 +3580,84 @@ describe('audioFramework', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_MUTE_2100 + *@tc.name : mute - callback + *@tc.desc : mute - callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_MUTE_2100', 3, async function (done) { + audioManager.mute(stringParameter, false, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getMinVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMinVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`${TagFrmwk}: failed to getMinVolume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }) + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_MUTE_2200 + *@tc.name : mute - callback + *@tc.desc : mute - callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_MUTE_2200', 3, async function (done) { + await audioManager.mute(numberParameter, false).then(async function () { + console.log(`${TagFrmwk}: Set Stream GroupManager Mute: RINGTONE: Promise: FALSE`); + expect(false).assertTrue(); + }).catch((err) => { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: getMinVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMinVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + }); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_MUTE_2300 + *@tc.name : mute - callback + *@tc.desc : mute - callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_MUTE_2300', 3, async function (done) { + await audioManager.mute(stringParameter, false).then((resolve)=> { + console.log(`${TagFrmwk}: Set Stream GroupManager Mute: RINGTONE: Promise: FALSE`); + expect(false).assertTrue(); + }, (err) => { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setRingerMode : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setRingerMode : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + }) + done(); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_ISACTIVE_0100 *@tc.name : isActive - Media - Promise @@ -3425,6 +3865,61 @@ describe('audioFramework', function () { }); }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_ISACTIVE_0900 + *@tc.name : isActive - Promise + *@tc.desc : isActive - Promise + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_ISACTIVE_0900', 2, async function (done) { + await audioManager.isActive(stringParameter, false).then((resolve)=> { + console.log(`${TagFrmwk}: Set Stream GroupManager Mute: RINGTONE: Promise: FALSE`); + expect(false).assertTrue(); + }, (err) => { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: isActive : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: isActive : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + }) + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_ISACTIVE_1000 + *@tc.name : isActive - Callback + *@tc.desc : isActive - Callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_ISACTIVE_1000', 2, function (done) { + console.log(`${TagFrmwk}: Callback : isActive Ringtone: ENAME: NOTE: audio NOT PLAYING as MEDIA for the test case to PASS`); + audioManager.isActive(numberParameter, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: isActive : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: isActive : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`${TagFrmwk}: failed to isActive: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETMICROPHONEMUTE_0100 *@tc.name : setMicrophoneMute - true - Promise @@ -3545,6 +4040,59 @@ describe('audioFramework', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETMICROPHONEMUTE_0500 + *@tc.name : setMicrophoneMute - Promise + *@tc.desc : Disable mic mute + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETMICROPHONEMUTE_0500', 1, async function (done) { + await audioManager.setMicrophoneMute(stringParameter).then(()=>{ + console.log(`${TagFrmwk}: setMicrophoneMute : ERROR : message:${err.message}`); + expect(false).assertTrue(); + }).catch (err =>{ + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setMicrophoneMute : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setMicrophoneMute : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + }) + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETMICROPHONEMUTE_0600 + *@tc.name : setMicrophoneMute - false - Callback + *@tc.desc : Disable mic mute + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETMICROPHONEMUTE_0600', 1, function (done) { + audioManager.setMicrophoneMute(numberParameter, (err) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getMinVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMinVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`${TagFrmwk}: failed to getMinVolume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0100 *@tc.name : setDeviceActive - SPEAKER - deactivate - Promise @@ -3692,6 +4240,58 @@ describe('audioFramework', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0500 + *@tc.name : setDeviceActive - Callback + *@tc.desc : Activate - Callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0500', 1, async function (done) { + await audioManager.setDeviceActive(stringParameter, true).then(()=>{ + console.log(`${TagFrmwk}: setDeviceActive : ERROR : message:${err.message}`); + expect(false).assertTrue(); + }).catch (err =>{ + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setDeviceActive : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setDeviceActive : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + }) + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0600 + *@tc.name : setDeviceActive - Callback + *@tc.desc : Activate - Callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETDEVICEACTIVE_0600', 1, function (done) { + audioManager.setDeviceActive(numberParameter, true, (err) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: setDeviceActive : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setDeviceActive : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`${TagFrmwk}: failed to setDeviceActive: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }); + }) /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETAUDIOPARAMETER_0100 @@ -4051,6 +4651,59 @@ describe('audioFramework', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETAUDIOPARAMETER_1300 + *@tc.name : setAudioParameter - Promise + *@tc.desc : setAudioParameter - Promise + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETAUDIOPARAMETER_1300', 2, async function (done) { + try { + await audioManager.setAudioParameter(numberParameter, numberParameter); + expect(false).assertTrue(); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setAudioParameter : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setAudioParameter : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETAUDIOPARAMETER_1400 + *@tc.name : setAudioParameter - Callback + *@tc.desc : setAudioParameter - Callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_SETAUDIOPARAMETER_1400', 2, function (done) { + audioManager.setAudioParameter(numberParameter, '16 bit', (err) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setAudioParameter : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setAudioParameter : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`${TagFrmwk}: failed to setAudioParameter: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETAUDIOPARAMETER_0100 *@tc.name : getAudioParameter - Promise - Character & Number @@ -4409,6 +5062,59 @@ describe('audioFramework', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETAUDIOPARAMETER_1300 + *@tc.name : getAudioParameter - Promise + *@tc.desc : getAudioParameter - Promise + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETAUDIOPARAMETER_1300', 2, async function (done) { + try { + await audioManager.getAudioParameter(numberParameter); + expect(false).assertTrue(); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getAudioParameter : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getAudioParameter : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_GETAUDIOPARAMETER_1400 + *@tc.name : getAudioParameter - Callback + *@tc.desc : getAudioParameter - Callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_MANAGER_GETAUDIOPARAMETER_1400', 2, function (done) { + audioManager.getAudioParameter(numberParameter, (err) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getAudioParameter : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getAudioParameter : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`${TagFrmwk}: failed to getAudioParameter: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_ONVOLUMECHANGE_0100 *@tc.name : OnVolumeChange - setVolume - MEDIA diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioManagerApi9.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioManagerApi9.test.js index d8c309de6143b2f7c8b39187e7dd0fff1c58a158..8a3236a9d2b90a2f1997098bbe520833c4130007 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioManagerApi9.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioManagerApi9.test.js @@ -35,6 +35,8 @@ describe('audioManagerApi9', function () { let volMappingId = null; let volGroupName = null; let volConnectType = null; + let stringParameter = "invalid_parameter"; + let numberParameter = 999999; function displayVolumeGroupProp(value, index, array) { console.info('audioManagerApi9Test: volume group networkId:' + value.networkId); volNetworkId = value.networkId; @@ -251,6 +253,36 @@ describe('audioManagerApi9', function () { }); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_MANAGER_GETVOLUMEGROUPSINFOS_0300 + *@tc.name : getVolumeGroupInfos - LOCAL_NETWORK_ID - Callback + *@tc.desc : getVolumeGroupInfos - LOCAL_NETWORK_ID + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_MANAGER_GETVOLUMEGROUPSINFOS_0300', 2,async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + audioVolumeManager.getVolumeGroupInfos(numberParameter, (err, value) => { + // Getting Local VolumeGroupInfos + console.info(`${TagFrmwk}: Callback: getVolumeGroupInfos LOCAL_NETWORK_ID`); + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getVolumeGroupInfos on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getVolumeGroupInfos on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.info('audioManagerErrorCodeTest: Callback: getVolumeGroups : FAIL'); + expect(false).assertTrue(); + } + done(); + }); + }) /** * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0100 * @tc.name : getVolumeGroupManager - callback @@ -320,6 +352,60 @@ describe('audioManagerApi9', function () { done(); }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0300 + * @tc.name : getVolumeGroupManager - callback + * @tc.desc : getVolumeGroupManager + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0300', 3, async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + audioVolumeManager.getVolumeGroupManager(stringParameter, (err,groupManager)=>{ + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getVolumeGroupManager : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getVolumeGroupManager : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } else { + console.info('audioManagerErrorCodeTest: Promise: getGroupManager : FAIL'); + expect(false).assertTrue(); + } + done(); + }) + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0400 + * @tc.name : getVolumeGroupManager - prmiose + * @tc.desc : getVolumeGroupManager + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0400', 3, async function (done) { + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let groupManager = await audioVolumeManager.getVolumeGroupManager(numberParameter); + expect(false).assertTrue(); + }catch(err){ + console.log('err :' + err.code) + if (err.code == 6800301) { + console.log(`${TagFrmwk}: getVolumeGroupManager : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getVolumeGroupManager : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + /** * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETVOLUME_0100 * @tc.name : group manager setVolume - MEDIA - Callback @@ -336,7 +422,7 @@ describe('audioManagerApi9', function () { let groupId_ = volumeGroupInfos[0].groupId groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); } catch (err) { - console.info('audioManagerApi9Test: getVolumeGroupManager : err:' + err.message); + console.info('audioManagerApi9Test: setVolume : err:' + err.message); expect(false).assertTrue(); done(); } @@ -392,10 +478,167 @@ describe('audioManagerApi9', function () { } done(); } catch (err) { - console.info('audioManagerApi9Test: getVolumeGroupManager : err:' + err.message); + console.info('audioManagerApi9Test: setVolume : err:' + err.message); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_ERRORCODE_VOLUME_GROUP_MANAGER_SETVOLUME_0300 + * @tc.name : group manager setVolume - MEDIA - Callback + * @tc.desc : group manager Setvolo to 14 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_ERRORCODE_VOLUME_GROUP_MANAGER_SETVOLUME_0300', 3, async function (done) { + let groupManager; + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + }catch(err){ + console.info('audioManagerErrorCodeTest: setVolume : err:'+ err.message); + expect(false).assertTrue(); + done(); + } + groupManager.setVolume(stringParameter, highVol, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to set volume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_ERRORCODE_VOLUME_GROUP_MANAGER_SETVOLUME_0400 + * @tc.name : group manager setVolume - MEDIA - Callback + * @tc.desc : group manager Setvolo to 14 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_ERRORCODE_VOLUME_GROUP_MANAGER_SETVOLUME_0400', 3, async function (done) { + let groupManager; + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + }catch(err){ + console.info('audioManagerErrorCodeTest: getVolumeGroupManager : err:'+ err.message); + expect(false).assertTrue(); + done(); + } + groupManager.setVolume(numberParameter, highVol, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: setVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to set volume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_ERRORCODE_VOLUME_GROUP_MANAGER_GETVOLUME_0100 + * @tc.name : group manager getVolume - MEDIA - Callback + * @tc.desc : group manager Setvoloe + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_ERRORCODE_VOLUME_GROUP_MANAGER_GETVOLUME_0100', 3, async function (done) { + let groupManager; + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + }catch(err){ + console.info('audioManagerErrorCodeTest: getVolumeGroupManager : err:'+ err.message); + expect(false).assertTrue(); + done(); + } + groupManager.getVolume(stringParameter, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + else { + console.error(`audioManagerErrorCodeTest: failed to get volume: Callback: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_ERRORCODE_VOLUME_GROUP_MANAGER_GETVOLUME_0200 + * @tc.name : group manager getVolume - MEDIA - Callback + * @tc.desc : group manager getVolume + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_ERRORCODE_VOLUME_GROUP_MANAGER_GETVOLUME_0200', 3, async function (done) { + let groupManager; + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + }catch(err){ + console.info('audioManagerErrorCodeTest: getVolumeGroupManager : err:'+ err.message); expect(false).assertTrue(); done(); } + groupManager.getVolume(numberParameter, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: getVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to getVolume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }); }) /** @@ -466,6 +709,81 @@ describe('audioManagerApi9', function () { done(); }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0300 + * @tc.name : getMaxVolume - Callback + * @tc.desc : getMaxVolume + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0300', 3, async function (done) { + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + groupManager.getMaxVolume(stringParameter, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getMaxVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMaxVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to getMaxVolume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }); + } catch (err) { + console.info('audioManagerApi9Test: getMaxVolume : err:' + err.message); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0400 + * @tc.name : getMaxVolume - RINGTONE - Promise + * @tc.desc : getMaxVolume + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0400', 3, async function (done) { + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + let maxVolume = await groupManager.getMaxVolume(numberParameter); + console.info('audioManagerApi9Test: promise : Ringtone getMaxVolume: FAIL :' + maxVolume); + expect(false).assertTrue(); + } catch (err) { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: getMaxVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMaxVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to getMaxVolume: Callback: ${err.message}`); + expect(false).assertTrue(); + done(); + } + } + done(); + }) + /** * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0100 * @tc.name : getMinVolume - RINGTONE - Callback @@ -535,29 +853,104 @@ describe('audioManagerApi9', function () { }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0100 - * @tc.name : group manager mute - RINGTONE - Callback - * @tc.desc : mute - RINGTONE - Callback + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0300 + * @tc.name : getMinVolume - Callback + * @tc.desc : getMinVolume * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 3 */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0100', 3, async function (done) { - let groupManager; + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0300', 3, async function (done) { try { let audioVolumeManager = audioManager.getVolumeManager(); let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); let groupId_ = volumeGroupInfos[0].groupId; - groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + groupManager.getMinVolume(stringParameter, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getMinVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMinVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to getMinVolume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }); } catch (err) { - console.info('audioManagerApi9Test: getGroupManager mute : parameter err:' + err.message); + console.info('audioManagerApi9Test: getMinVolume : err:' + err.message); expect(false).assertTrue(); done(); } - groupManager.mute(audio.AudioVolumeType.RINGTONE, false, (err, data) => { + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0400 + * @tc.name : getMinVolume - RINGTONE - Promise + * @tc.desc : getMinVolume + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0400', 3, async function (done) { + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + let maxVolume = await groupManager.getMinVolume(numberParameter); + console.info('audioManagerApi9Test: promise : Ringtone getMinVolume: FAIL :' + maxVolume); + expect(false).assertTrue(); + } catch (err) { if (err) { - console.error(`audioManagerApi9Test: failed to mute : Callback: ${err.message}`); - expect(false).assertTrue(); + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: getMinVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMinVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to getMinVolume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0100 + * @tc.name : group manager mute - RINGTONE - Callback + * @tc.desc : mute - RINGTONE - Callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0100', 3, async function (done) { + let groupManager; + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + } catch (err) { + console.info('audioManagerApi9Test: getGroupManager mute : parameter err:' + err.message); + expect(false).assertTrue(); + done(); + } + groupManager.mute(audio.AudioVolumeType.RINGTONE, false, (err, data) => { + if (err) { + console.error(`audioManagerApi9Test: failed to mute : Callback: ${err.message}`); + expect(false).assertTrue(); } else { groupManager.isMute(audio.AudioVolumeType.RINGTONE, (err, data) => { @@ -625,6 +1018,89 @@ describe('audioManagerApi9', function () { } }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0300 + * @tc.name : group manager mute - RINGTONE - Callback + * @tc.desc : mute - RINGTONE - Callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0300', 3, async function (done) { + let groupManager; + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + } catch (err) { + console.info('audioManagerApi9Test: getGroupManager mute : parameter err:' + err.message); + expect(false).assertTrue(); + done(); + } + groupManager.mute(streamManager, false, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: getMinVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMinVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to getMinVolume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + done(); + }) + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0400 + * @tc.name : group manager mute - RINGTONE - Promise + * @tc.desc : mute - RINGTONE - Promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0400', 3, async function (done) { + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + await groupManager.mute(audio.AudioVolumeType.RINGTONE, false).then(async function () { + console.log('audioManagerApi9Test: Set Stream GroupManager Mute: RINGTONE: Promise: FALSE'); + await groupManager.isMute(numberParameter).then(function (data) { + expect(false).assertTrue(); + }); + }).catch((err) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: getMinVolume : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: getMinVolume : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to getMinVolume: Callback: ${err.message}`); + expect(false).assertTrue(); + + }; + done(); + }); + } catch (err) { + console.info('audioManagerApi9Test: getGroupManager mute : parameter err:' + err.message); + expect(false).assertTrue(); + done(); + } + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_VOLUMECHANGE_0100 *@tc.name : OnVolumeChange - setVolume - MEDIA @@ -744,6 +1220,80 @@ describe('audioManagerApi9', function () { done(); }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETRINGERMODE_0300 + * @tc.name : group manager mute - RINGTONE - Callback + * @tc.desc : mute - RINGTONE - Callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETRINGERMODE_0300', 3, async function (done) { + let groupManager; + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + } catch (err) { + console.info('audioManagerApi9Test: getGroupManager mute : parameter err:' + err.message); + expect(false).assertTrue(); + done(); + } + groupManager.setRingerMode(stringParameter, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setRingerMode : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setRingerMode : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to setRingerMode: Callback: ${err.message}`); + expect(false).assertTrue(); + }; + done(); + }) + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETRINGERMODE_0400 + *@tc.name : setRingerMode - Normal Mode - Promise - ENAME + *@tc.desc : setRingerMode - Set Ring more to Normal Mode + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETRINGERMODE_0400', 3, async function (done) { + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + await groupManager.setRingerMode(numberParameter); + expect(false).assertTrue(); + } catch (err) { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: setRingerMode : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setRingerMode : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to setRingerMode: Callback: ${err.message}`); + expect(false).assertTrue(); + }; + } + done(); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ONRINGMODECHANGE_0100 *@tc.name : OnRingMode - RINGER_MODE_NORMAL @@ -828,13 +1378,13 @@ describe('audioManagerApi9', function () { }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETMICROPHONEMUTE_0200 - *@tc.name : setMicrophoneMute - true - Promise - *@tc.desc : Enable mic mute - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 3 - */ + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETMICROPHONEMUTE_0200 + *@tc.name : setMicrophoneMute - true - Promise + *@tc.desc : Enable mic mute + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 3 + */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETMICROPHONEMUTE_0200', 3, async function (done) { try { let audioVolumeManager = audioManager.getVolumeManager(); @@ -857,6 +1407,74 @@ describe('audioManagerApi9', function () { done(); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GSETMICROPHONEMUTE_0300 + *@tc.name : setMicrophoneMute - true - Callback + *@tc.desc : Enable mic mute + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETMICROPHONEMUTE_0300', 3, async function (done) { + let groupManager; + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + } catch (err) { + console.log('err :' + err.message); + expect(false).assertTrue(); + done(); + } + groupManager.setMicrophoneMute(numberParameter, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setMicrophoneMute : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setMicrophoneMute : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to setMicrophoneMute: Callback: ${err.message}`); + expect(false).assertTrue(); + }; + done(); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GSETMICROPHONEMUTE_0400 + *@tc.name : setMicrophoneMute - true - Promise + *@tc.desc : Enable mic mute + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETMICROPHONEMUTE_0400', 3, async function (done) { + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + await groupManager.setMicrophoneMute(stringParameter); + expect(false).assertTrue(); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setMicrophoneMute : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setMicrophoneMute : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + /** *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ONMICSTATECHANGE_0100 *@tc.name : OnMicStateChange @@ -953,7 +1571,62 @@ describe('audioManagerApi9', function () { }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100 + *@tc.number : SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ISACTIVE_0300 + *@tc.name : isActive - Media - Promise + *@tc.desc : isActive - Media - Promise - When stream is NOT playing + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ISACTIVE_0300', 1, async function (done) { + try{ + const PROMISE = await streamManager.isActive(stringParameter); + console.log(`${TagFrmwk}: isActive : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: isActive : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: isActive : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ISACTIVE_0400 + *@tc.name : isActive - Media - Callback + *@tc.desc : isActive - Media - Callback - When stream is NOT playing + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ISACTIVE_0400', 1, function (done) { + console.log(`${TagFrmwk}: Callback : isActive Media: NOTE: audio NOT PLAYING as MEDIA for the test case to PASS`); + streamManager.isActive(numberParameter, (err, data) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: isActive : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: isActive : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`audioManagerErrorCodeTest: failed to isActive: Callback: ${err.message}`); + expect(false).assertTrue(); + }; + done(); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETCOMMUNICATIONDEVICE_0100 *@tc.name : setCommunicationDevice - SPEAKER - deactivate - Promise *@tc.desc : setCommunicationDevice speaker - Promise *@tc.size : MEDIUM @@ -1048,22 +1721,144 @@ describe('audioManagerApi9', function () { }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100 - *@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100 - *@tc.desc : micStateChange - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100', 2, async function (done) { - let audioVolumeManager = audioManager.getVolumeManager(); - let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); - let groupId_ = volumeGroupInfos[0].groupId - let VolumeGroupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); - let count = 0; - console.info('getVolumeGroupManager Callback START.'); - VolumeGroupManager.on('micStateChange', async (micStateChange) => { - + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETCOMMUNICATIONDEVICE_0300 + *@tc.name : setCommunicationDevice - SPEAKER - deactivate - Promise + *@tc.desc : setCommunicationDevice speaker - Promise + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0300', 1, async function (done) { + try { + let flag = true; + let AudioRoutingManager = audioManager.getRoutingManager(); + + await AudioRoutingManager.setCommunicationDevice(stringParameter, false).then(() => { + console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100 + Promise returned to indicate that the device is set to the active status.`); + }).catch((err) => { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: setCommunicationDevice : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setCommunicationDevice : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + }); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0400 + *@tc.name : setCommunicationDevice - SPEAKER - deactivate - Callback + *@tc.desc : setCommunicationDevice speaker - Callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0400', 2, async function (done) { + let flag = true + let AudioRoutingManager = audioManager.getRoutingManager(); + AudioRoutingManager.setCommunicationDevice(numberParameter, false, (err) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: setCommunicationDevice : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: setCommunicationDevice : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`${TagFrmwk}: failed to setCommunicationDevice: Callback: ${err.message}`); + expect(false).assertTrue(); + }; + done(); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_ISCOMMUNICATIONDEVICE_0100 + *@tc.name : isCommunicationDeviceActive - Promise + *@tc.desc : isCommunicationDeviceActive + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_ISCOMMUNICATIONDEVICE_0100', 1, async function (done) { + try { + let AudioRoutingManager = audioManager.getRoutingManager(); + await AudioRoutingManager.isCommunicationDeviceActive(stringParameter).then(() => { + expect(false).assertTrue(); + }).catch((err) => { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`${TagFrmwk}: isCommunicationDeviceActive : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: isCommunicationDeviceActive : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + }); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_ISCOMMUNICATIONDEVICE_0200 + *@tc.name : isCommunicationDeviceActive Callback + *@tc.desc : isCommunicationDeviceActive + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_ISCOMMUNICATIONDEVICE_0200', 2, async function (done) { + let AudioRoutingManager = audioManager.getRoutingManager(); + AudioRoutingManager.isCommunicationDeviceActive(numberParameter, (err) => { + if (err) { + console.log('err :' + err.code) + if (err.code == 6800104) { + console.log(`${TagFrmwk}: isCommunicationDeviceActive : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`${TagFrmwk}: isCommunicationDeviceActive : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + } + else { + console.error(`${TagFrmwk}: failed to isCommunicationDeviceActive: Callback: ${err.message}`); + expect(false).assertTrue(); + }; + done(); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100 + *@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100 + *@tc.desc : micStateChange + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100', 2, async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId + let VolumeGroupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + let count = 0; + console.info('getVolumeGroupManager Callback START.'); + VolumeGroupManager.on('micStateChange', async (micStateChange) => { + console.info('micStateChange is ' + micStateChange.mute); count++; }) @@ -1197,4 +1992,373 @@ describe('audioManagerApi9', function () { done(); }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_MANAGER_ON_0100 + *@tc.name : audioVolumeManager on + *@tc.desc : audioVolumeManager on + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_MANAGER_ON_0100', 2, async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + let stringParameter = "invalid_parameter"; + try { + audioVolumeManager.on(stringParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } 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(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_MANAGER_ON_0200 + *@tc.name : audioVolumeManager on + *@tc.desc : audioVolumeManager on + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_MANAGER_ON_0200', 2, async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + let numberParameter = 1; + try { + audioVolumeManager.on(numberParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + if (err.code == 401) { + console.log(`audioVolumeManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`audioVolumeManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_0100 + *@tc.name : volumeGroupManager on + *@tc.desc : volumeGroupManager on + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_0100', 2, async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + let stringParameter = "invalid_parameter"; + + try { + groupManager.on(stringParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`groupManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`groupManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_0200 + *@tc.name : volumeGroupManager on + *@tc.desc : volumeGroupManager on + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_0200', 2, async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + let numberParameter = 1; + try { + groupManager.on(numberParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 401) { + console.log(`groupManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`groupManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_ON_0100 + *@tc.name : routingManager on + *@tc.desc : routingManager on + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_ON_0100', 2, async function (done) { + let AudioRoutingManager = audioManager.getRoutingManager(); + let stringParameter = "invalid_parameter"; + + try { + AudioRoutingManager.on(stringParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`AudioRoutingManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`AudioRoutingManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_ON_0200 + *@tc.name : routingManager on + *@tc.desc : routingManager on + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_ON_0200', 2, async function (done) { + let AudioRoutingManager = audioManager.getRoutingManager(); + let numberParameter = 1; + try { + AudioRoutingManager.on(numberParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 401) { + console.log(`AudioRoutingManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`AudioRoutingManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_OFF_0100 + *@tc.name : routingManager off + *@tc.desc : routingManager off + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_OFF_0100', 2, async function (done) { + let AudioRoutingManager = audioManager.getRoutingManager(); + let stringParameter = "invalid_parameter"; + + try { + AudioRoutingManager.off(stringParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`AudioRoutingManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`AudioRoutingManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_OFF_0200 + *@tc.name : routingManager off + *@tc.desc : routingManager off + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_OFF_0200', 2, async function (done) { + let AudioRoutingManager = audioManager.getRoutingManager(); + let numberParameter = 1; + try { + AudioRoutingManager.off(numberParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 401) { + console.log(`AudioRoutingManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`AudioRoutingManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ON_0100 + *@tc.name : audioStreamManager on + *@tc.desc : audioStreamManager on + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ON_0100', 2, async function (done) { + let audioStreamManager = audioManager.getStreamManager(); + let stringParameter = "invalid_parameter"; + + try { + audioStreamManager.on(stringParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`audioStreamManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`audioStreamManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ON_0200 + *@tc.name : audioStreamManager on + *@tc.desc : audioStreamManager on + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ON_0200', 2, async function (done) { + let audioStreamManager = audioManager.getStreamManager(); + let numberParameter = 1; + try { + audioStreamManager.on(numberParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 401) { + console.log(`audioStreamManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`audioStreamManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_OFF_0100 + *@tc.name : audioStreamManager off + *@tc.desc : audioStreamManager off + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_OFF_0100', 2, async function (done) { + let audioStreamManager = audioManager.getStreamManager(); + let stringParameter = "invalid_parameter"; + + try { + audioStreamManager.off(stringParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 6800101) { + console.log(`audioStreamManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`audioStreamManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_OFF_0200 + *@tc.name : audioStreamManager off + *@tc.desc : audioStreamManager off + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_OFF_0200', 2, async function (done) { + let audioStreamManager = audioManager.getStreamManager(); + let numberParameter = 1; + try { + audioStreamManager.off(numberParameter, (ChangeEvent) => { + console.log(`${TagFrmwk}: Change Event is called : Error`); + expect(false).assertTrue(); + done(); + }); + } catch (err) { + console.log('err :' + err.code) + if (err.code == 401) { + console.log(`audioStreamManager on : PASS : message:${err.message}`); + expect(true).assertTrue(); + }else { + console.log(`audioStreamManager on : FAIL : message:${err.message}`); + expect(false).assertTrue(); + } + done(); + } + }) + }) \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioRenderer.test.js b/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioRenderer.test.js index 7499e7d83f2e10b5a943a905bfb09f1b3d86fc56..d91c8afe59ff00b54d1b0b1ae388cb412a7206e0 100644 --- a/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioRenderer.test.js +++ b/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioRenderer.test.js @@ -29,8 +29,10 @@ describe('audioRenderer', function () { let TagFrmwkAudioScene = "AudioFrameworkAudioScene"; let fdPath; let filePath; + let stringParameter = "invalid_parameter"; + let numberParameter = 999999; console.info(`${TagFrmwkRender}: Create AudioManger Object JS Framework`); - + beforeAll(function () { console.info(`${TagFrmwkRender}: beforeAll: Prerequisites at the test suite level`); }) @@ -1213,7 +1215,7 @@ describe('audioRenderer', function () { } } console.info(`${TagFrmwkRender}: Renderer after read`); - + await sleep(2000); audioRen.getRenderRate((err, data) => { if (err) { console.info(`${TagFrmwkAudioScene}: getRenderRate : RENDER_RATE_DOUBLE : ERROR : ${err.message}`); @@ -3302,6 +3304,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -3333,7 +3340,11 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -3387,6 +3398,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -3420,7 +3436,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -3474,6 +3494,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -3507,7 +3532,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -3561,6 +3590,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -3594,7 +3628,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -3648,6 +3686,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -3681,7 +3724,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -3735,6 +3782,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -3768,7 +3820,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -3822,6 +3878,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -3855,7 +3916,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -3909,6 +3974,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -3942,7 +4012,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -3996,6 +4070,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4029,7 +4108,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4083,6 +4166,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4116,7 +4204,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4170,6 +4262,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4203,7 +4300,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4257,6 +4358,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4290,7 +4396,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4344,6 +4454,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4377,7 +4492,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4431,6 +4550,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4464,7 +4588,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4518,6 +4646,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4551,7 +4684,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4605,6 +4742,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4638,7 +4780,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4692,6 +4838,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4725,7 +4876,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4779,6 +4934,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4812,7 +4972,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4866,6 +5030,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4899,7 +5068,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -4953,6 +5126,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -4986,7 +5164,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -5040,6 +5222,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -5073,7 +5260,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -5127,6 +5318,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -5160,7 +5356,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -5214,6 +5414,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -5247,7 +5452,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -5301,6 +5510,11 @@ describe('audioRenderer', function () { if (isPass) { resultFlag = true; expect(resultFlag).assertTrue(); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } @@ -5334,7 +5548,11 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) @@ -6471,8 +6689,8 @@ describe('audioRenderer', function () { /** * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7600 - * @tc.name : AudioRenderer - getAudioTime - Error - * @tc.desc : AudioRenderer - getAudioTime - Error + * @tc.name : AudioRenderer - SetRenderRate - RENDER_RATE_HALF - CALLBACK + * @tc.desc : AudioRenderer - SetRenderRate - RENDER_RATE_HALF - CALLBACK * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 @@ -6480,9 +6698,9 @@ describe('audioRenderer', function () { it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7600', 2, async function (done) { let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_24000, channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } @@ -6497,11 +6715,11 @@ describe('audioRenderer', function () { rendererInfo: AudioRendererInfo } - readPath = 'StarWars10s-2C-48000-4SW.wav'; + readPath = 'StarWars10s-2C-24000-3SW.wav' await getFdRead(readPath, done); - let resultFlag = true; - console.info(`${TagFrmwkRender}: AudioRenderer : Path : ${readPath}`); + let AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT; + let resultFlag = true; console.info(`${TagFrmwkRender}: Promise : Audio Playback Function`); let audioRen; @@ -6528,130 +6746,134 @@ describe('audioRenderer', function () { return; } - await audioRen.getAudioTime().then((data) => { - console.info(`${TagFrmwkRender}: getAudioTime : Value : ${data}`); - resultFlag = true; - if (data > 0) { - console.info(`${TagFrmwkRender}: getAudioTime : PASS : ${data}`); - } - else { - console.info(`${TagFrmwkRender}: getAudioTime : FAIL : ${data}`); - } + console.info(`${TagFrmwkRender}: AudioRenderer : Path : ${readPath}`); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + await audioRen.getStreamInfo().then((audioParamsGet) => { + console.info(`${TagFrmwkRender}: Renderer getStreamInfo: ${JSON.stringify(audioParamsGet)}`); }).catch((err) => { - console.info(`${TagFrmwkRender}: getAudioTime : ERROR : ${err.message}`); + console.log(`${TagFrmwkRender}: getStreamInfo :ERROR: ${err.message}`); + resultFlag = false; }); - await audioRen.release().then(() => { - console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + await audioRen.getRendererInfo().then((audioParamsGet) => { + console.info(`${TagFrmwkRender}: Renderer RendererInfo: ${JSON.stringify(audioParamsGet)}`); }).catch((err) => { - console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); + resultFlag = false; }); - console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); - - console.info(`${TagFrmwkRender}: resultFlag : ${resultFlag}`); - - await sleep(500); + await audioRen.start().then(() => { + console.info(`${TagFrmwkRender}: renderInstant started :SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: renderInstant start :ERROR : ${err.message}`); + resultFlag = false; + }); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readPath); - done(); - }) + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + let bufferSize = await audioRen.getBufferSize(); + console.info(`${TagFrmwkRender}: buffer size: ${bufferSize}`); - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7700 - * @tc.name : AudioRenderer - STATE_PREPARED -Callback - * @tc.desc : AudioRenderer - STATE_PREPARED - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7700', 2, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_RINGTONE, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, - rendererFlags: 0 - } - - let AudioRendererOptions = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo + let ss = fileio.fdopenStreamSync(fdRead, 'r'); + console.info(`${TagFrmwkRender}:case 2:AudioFrameworkRenderLog: File Path: ${ss}`); + let discardHeader = new ArrayBuffer(44); + ss.readSync(discardHeader); + let totalSize = fileio.fstatSync(fdRead).size; + console.info(`${TagFrmwkRender}:case 3 : AudioFrameworkRenderLog: File totalSize size: ${totalSize}`); + totalSize = totalSize - 44; + console.info(`${TagFrmwkRender}: File size : Removing header: ${totalSize}`); + let rlen = 0; + while (rlen < totalSize / 4) { + let buf = new ArrayBuffer(bufferSize); + rlen += ss.readSync(buf); + console.info(`${TagFrmwkRender}:BufferAudioFramework: bytes read from file: ${rlen}`); + await audioRen.write(buf); + if (rlen > (totalSize / 8)) { + await AUDIOMANAGER.getAudioScene().then((data) =>{ + console.info(`${TagFrmwkAudioScene}: getAudioScene : Value : ${data}`); + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getAudioScene : ERROR : ${err.message}`); + resultFlag = false; + }); + } + if (rlen > (totalSize / 8)) { + audioRen.setRenderRate(audio.AudioRendererRate.RENDER_RATE_HALF, (err) => { + if (err) { + console.info(`${TagFrmwkAudioScene}: setRenderRate : RENDER_RATE_HALF : ERROR : ${err.message}`); + resultFlag = false; + } else { + console.info(`${TagFrmwkRender}: setRenderRate : RENDER_RATE_HALF : SUCCESS`); + } + }); + } } - let resultFlag = false; - - let audioRen; - let isPass = false; - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRen = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); - LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; - LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; - let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; - if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { - isPass = true; - return; + console.info(`${TagFrmwkRender}: Renderer after read`); + await sleep(2000); + await audioRen.getRenderRate().then((data) => { + if (data == audio.AudioRendererRate.RENDER_RATE_HALF) { + console.info(`${TagFrmwkRender}: getRenderRate : RENDER_RATE_HALF : PASS : ${data}`); + } + else { + console.info(`${TagFrmwkRender}: getRenderRate : RENDER_RATE_HALF : FAIL : ${data}`); + resultFlag = false; } + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getRenderRate : RENDER_RATE_HALF : ERROR : ${err.message}`); resultFlag = false; }); - console.log(`isPass: ${isPass}`); - if (isPass) { - resultFlag = true; - expect(resultFlag).assertTrue(); - done(); - return; - } - audioRen.on('stateChange', (AudioState) => { + await audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); - console.log(`${TagFrmwk}: Volume Change Event is called`); + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); - switch (AudioState) { - case audio.AudioState.STATE_RELEASED: - console.info(`${TagFrmwk}: state : STATE_NEW`); - resultFlag = true; - break; - default: - console.info(`${TagFrmwk}: state : ${AudioState}`); - break; - } + await audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); }); - await sleep(1000); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + await audioRen.release().then(() => { console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - await sleep(1000); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + console.info(`${TagFrmwkRender}: resultFlag : ${resultFlag}`); + + await sleep(500) + expect(resultFlag).assertTrue(); + await closeFileDescriptor(readPath); done(); }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7800 - * @tc.name : AudioRenderer - STATE_RUNNING - Callback - * @tc.desc : AudioRenderer - STATE_RUNNING + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7700 + * @tc.name : AudioRenderer - SetRenderRate - RENDER_RATE_NORMAL - CALLBACK + * @tc.desc : AudioRenderer - SetRenderRate - RENDER_RATE_NORMAL - CALLBACK * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7800', 2, async function (done) { + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7700', 2, async function (done) { + let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } @@ -6665,45 +6887,30 @@ describe('audioRenderer', function () { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - let resultFlag = false; + + readPath = 'StarWars10s-1C-44100-2SW.wav' + await getFdRead(readPath, done); + let AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT; + + let resultFlag = true; + console.info(`${TagFrmwkRender}: Promise : Audio Playback Function`); let audioRen; - let isPass = false; await audio.createAudioRenderer(AudioRendererOptions).then((data) => { audioRen = data; console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); - LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; - LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; - let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; - if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { - isPass = true; - return; - } resultFlag = false; }); - console.log(`isPass: ${isPass}`); - if (isPass) { - resultFlag = true; - expect(resultFlag).assertTrue(); - done(); - return; - } - - audioRen.on('stateChange', (AudioState) => { - console.log(`${TagFrmwk}: Volume Change Event is called`); + console.info(`${TagFrmwkRender}: AudioRenderer : Path : ${readPath}`); - switch (AudioState) { - case audio.AudioState.STATE_RUNNING: - console.info(`${TagFrmwk}: state : STATE_RUNNING`); - resultFlag = true; - break; - default: - console.info(`${TagFrmwk}: state : ${AudioState}`); - break; - } + await audioRen.getRendererInfo().then((audioParamsGet) => { + console.info(`${TagFrmwkRender}: Renderer RendererInfo: ${JSON.stringify(audioParamsGet)}`); + }).catch((err) => { + console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); + resultFlag = false; }); await audioRen.start().then(() => { @@ -6713,7 +6920,72 @@ describe('audioRenderer', function () { resultFlag = false; }); - await sleep(500); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + let bufferSize = await audioRen.getBufferSize(); + console.info(`${TagFrmwkRender}: buffer size: ${bufferSize}`); + + let ss = fileio.fdopenStreamSync(fdRead, 'r'); + console.info(`${TagFrmwkRender}:case 2:AudioFrameworkRenderLog: File Path: ${ss}`); + let discardHeader = new ArrayBuffer(44); + ss.readSync(discardHeader); + let totalSize = fileio.fstatSync(fdRead).size; + console.info(`${TagFrmwkRender}:case 3 : AudioFrameworkRenderLog: File totalSize size: ${totalSize}`); + totalSize = totalSize - 44; + console.info(`${TagFrmwkRender}: File size : Removing header: ${totalSize}`); + let rlen = 0; + while (rlen < totalSize / 4) { + let buf = new ArrayBuffer(bufferSize); + rlen += ss.readSync(buf); + console.info(`${TagFrmwkRender}:BufferAudioFramework: bytes read from file: ${rlen}`); + await audioRen.write(buf); + if (rlen > (totalSize / 8)) { + await AUDIOMANAGER.getAudioScene().then((data) =>{ + console.info(`${TagFrmwkAudioScene}: getAudioScene : Value : ${data}`); + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getAudioScene : ERROR : ${err.message}`); + resultFlag = false; + }); + } + if (rlen > (totalSize / 8)) { + await audioRen.setRenderRate(audio.AudioRendererRate.RENDER_RATE_DOUBLE).then(() => { + console.info(`${TagFrmwkRender}: setRenderRate : RENDER_RATE_DOUBLE : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: setRenderRate : RENDER_RATE_DOUBLE : ERROR : ${err.message}`); + resultFlag = false; + }); + } + } + audioRen.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) => { + if (err) { + console.info(`${TagFrmwkAudioScene}: setRenderRate : RENDER_RATE_HALF : ERROR : ${err.message}`); + resultFlag = false; + } else { + console.info(`${TagFrmwkRender}: setRenderRate : RENDER_RATE_HALF : SUCCESS`); + } + }); + console.info(`${TagFrmwkRender}: Renderer after read`); + await audioRen.getRenderRate().then((data) => { + if (data == audio.AudioRendererRate.RENDER_RATE_NORMAL) { + console.info(`${TagFrmwkRender}: getRenderRate : RENDER_RATE_NORMAL : PASS : ${data}`); + } + else { + console.info(`${TagFrmwkRender}: getRenderRate : RENDER_RATE_NORMAL : FAIL : ${data}`); + resultFlag = false; + } + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getRenderRate : RENDER_RATE_NORMAL : ERROR : ${err.message}`); + resultFlag = false; + }); + + await audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); await audioRen.stop().then(() => { console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); @@ -6721,32 +6993,40 @@ describe('audioRenderer', function () { console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); }); + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + await audioRen.release().then(() => { console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - await sleep(1000); - expect(resultFlag).assertTrue(); + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + console.info(`${TagFrmwkRender}: resultFlag : ${resultFlag}`); + + await sleep(500) + expect(resultFlag).assertTrue(); + await closeFileDescriptor(readPath); done(); }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7900 - * @tc.name : AudioRenderer - STATE_STOPPED - Callback - * @tc.desc : AudioRenderer - STATE_STOPPED + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7800 + * @tc.name : AudioRenderer - SetRenderRate - UNSUPPORT_OPTION - CALLBACK + * @tc.desc : AudioRenderer - SetRenderRate - UNSUPPORT_OPTION - CALLBACK * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7900', 2, async function (done) { + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7800', 2, async function (done) { + let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } @@ -6760,45 +7040,30 @@ describe('audioRenderer', function () { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - let resultFlag = false; + + readPath = 'StarWars10s-1C-44100-2SW.wav' + await getFdRead(readPath, done); + let AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT; + + let resultFlag = true; + console.info(`${TagFrmwkRender}: Promise : Audio Playback Function`); let audioRen; - let isPass = false; await audio.createAudioRenderer(AudioRendererOptions).then((data) => { audioRen = data; console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); - LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; - LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; - let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; - if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { - isPass = true; - return; - } resultFlag = false; }); - console.log(`isPass: ${isPass}`); - if (isPass) { - resultFlag = true; - expect(resultFlag).assertTrue(); - done(); - return; - } - - audioRen.on('stateChange', (AudioState) => { - console.log(`${TagFrmwk}: Volume Change Event is called`); + console.info(`${TagFrmwkRender}: AudioRenderer : Path : ${readPath}`); - switch (AudioState) { - case audio.AudioState.STATE_STOPPED: - console.info(`${TagFrmwk}: state : STATE_STOPPED`); - resultFlag = true; - break; - default: - console.info(`${TagFrmwk}: state : ${AudioState}`); - break; - } + await audioRen.getRendererInfo().then((audioParamsGet) => { + console.info(`${TagFrmwkRender}: Renderer RendererInfo: ${JSON.stringify(audioParamsGet)}`); + }).catch((err) => { + console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); + resultFlag = false; }); await audioRen.start().then(() => { @@ -6808,42 +7073,110 @@ describe('audioRenderer', function () { resultFlag = false; }); - await sleep(500); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + let bufferSize = await audioRen.getBufferSize(); + console.info(`${TagFrmwkRender}: buffer size: ${bufferSize}`); + + let ss = fileio.fdopenStreamSync(fdRead, 'r'); + console.info(`${TagFrmwkRender}:case 2:AudioFrameworkRenderLog: File Path: ${ss}`); + let discardHeader = new ArrayBuffer(44); + ss.readSync(discardHeader); + let totalSize = fileio.fstatSync(fdRead).size; + console.info(`${TagFrmwkRender}:case 3 : AudioFrameworkRenderLog: File totalSize size: ${totalSize}`); + totalSize = totalSize - 44; + console.info(`${TagFrmwkRender}: File size : Removing header: ${totalSize}`); + let rlen = 0; + while (rlen < totalSize / 4) { + let buf = new ArrayBuffer(bufferSize); + rlen += ss.readSync(buf); + console.info(`${TagFrmwkRender}:BufferAudioFramework: bytes read from file: ${rlen}`); + await audioRen.write(buf); + if (rlen > (totalSize / 8)) { + await AUDIOMANAGER.getAudioScene().then((data) =>{ + console.info(`${TagFrmwkAudioScene}: getAudioScene : Value : ${data}`); + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getAudioScene : ERROR : ${err.message}`); + resultFlag = false; + }); + } + if (rlen > (totalSize / 8)) { + await audioRen.setRenderRate(audio.AudioRendererRate.RENDER_RATE_DOUBLE).then(() => { + console.info(`${TagFrmwkRender}: setRenderRate : RENDER_RATE_DOUBLE : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: setRenderRate : RENDER_RATE_DOUBLE : ERROR : ${err.message}`); + resultFlag = false; + }); + } + } + audioRen.setRenderRate(numberParameter, (err) => { + if (err) { + if (err.code == 6800104) { + console.info(`${TagFrmwkRender}: setRenderRate : PASS`); + } else { + console.info(`${TagFrmwkAudioScene}: setRenderRate, caught err, but dismatch : FAILED`); + resultFlag = false; + } + } else { + console.info(`${TagFrmwkAudioScene}: setRenderRate : FAILED`); + resultFlag = false; + } + }); + console.info(`${TagFrmwkRender}: Renderer after read`); + await audioRen.getRenderRate().then((data) => {}).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getRenderRate : RENDER_RATE_NORMAL : ERROR : ${err.message}`); + resultFlag = false; + }); + + await audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); await audioRen.stop().then(() => { console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); - resultFlag = false; }); - await sleep(500); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); await audioRen.release().then(() => { console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - await sleep(500); - expect(resultFlag).assertTrue(); + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + console.info(`${TagFrmwkRender}: resultFlag : ${resultFlag}`); + + await sleep(500) + + expect(resultFlag).assertTrue(); + await closeFileDescriptor(readPath); done(); }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8000 - * @tc.name : AudioRenderer - STATE_RELEASED - Callback - * @tc.desc : AudioRenderer - STATE_RELEASED + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7900 + * @tc.name : AudioRenderer - SetRenderRate - INVALID_PARAM - CALLBACK + * @tc.desc : AudioRenderer - SetRenderRate - INVALID_PARAM - CALLBACK * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8000', 2, async function (done) { + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_7900', 2, async function (done) { + let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } @@ -6857,45 +7190,30 @@ describe('audioRenderer', function () { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - let resultFlag = false; + + readPath = 'StarWars10s-1C-44100-2SW.wav' + await getFdRead(readPath, done); + let AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT; + + let resultFlag = true; + console.info(`${TagFrmwkRender}: Promise : Audio Playback Function`); let audioRen; - let isPass = false; await audio.createAudioRenderer(AudioRendererOptions).then((data) => { audioRen = data; console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); - LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; - LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; - let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; - if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { - isPass = true; - return; - } resultFlag = false; }); - console.log(`isPass: ${isPass}`); - if (isPass) { - resultFlag = true; - expect(resultFlag).assertTrue(); - done(); - return; - } - - audioRen.on('stateChange', (AudioState) => { - console.log(`${TagFrmwk}: Volume Change Event is called`); + console.info(`${TagFrmwkRender}: AudioRenderer : Path : ${readPath}`); - switch (AudioState) { - case audio.AudioState.STATE_RELEASED: - console.info(`${TagFrmwk}: state : STATE_RELEASED`); - resultFlag = true; - break; - default: - console.info(`${TagFrmwk}: state : ${AudioState}`); - break; - } + await audioRen.getRendererInfo().then((audioParamsGet) => { + console.info(`${TagFrmwkRender}: Renderer RendererInfo: ${JSON.stringify(audioParamsGet)}`); + }).catch((err) => { + console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); + resultFlag = false; }); await audioRen.start().then(() => { @@ -6905,38 +7223,106 @@ describe('audioRenderer', function () { resultFlag = false; }); - await sleep(500); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + let bufferSize = await audioRen.getBufferSize(); + console.info(`${TagFrmwkRender}: buffer size: ${bufferSize}`); + + let ss = fileio.fdopenStreamSync(fdRead, 'r'); + console.info(`${TagFrmwkRender}:case 2:AudioFrameworkRenderLog: File Path: ${ss}`); + let discardHeader = new ArrayBuffer(44); + ss.readSync(discardHeader); + let totalSize = fileio.fstatSync(fdRead).size; + console.info(`${TagFrmwkRender}:case 3 : AudioFrameworkRenderLog: File totalSize size: ${totalSize}`); + totalSize = totalSize - 44; + console.info(`${TagFrmwkRender}: File size : Removing header: ${totalSize}`); + let rlen = 0; + while (rlen < totalSize / 4) { + let buf = new ArrayBuffer(bufferSize); + rlen += ss.readSync(buf); + console.info(`${TagFrmwkRender}:BufferAudioFramework: bytes read from file: ${rlen}`); + await audioRen.write(buf); + if (rlen > (totalSize / 8)) { + await AUDIOMANAGER.getAudioScene().then((data) =>{ + console.info(`${TagFrmwkAudioScene}: getAudioScene : Value : ${data}`); + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getAudioScene : ERROR : ${err.message}`); + resultFlag = false; + }); + } + if (rlen > (totalSize / 8)) { + await audioRen.setRenderRate(audio.AudioRendererRate.RENDER_RATE_DOUBLE).then(() => { + console.info(`${TagFrmwkRender}: setRenderRate : RENDER_RATE_DOUBLE : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: setRenderRate : RENDER_RATE_DOUBLE : ERROR : ${err.message}`); + resultFlag = false; + }); + } + } + audioRen.setRenderRate(stringParameter, (err) => { + if (err) { + if (err.code == 6800101) { + console.info(`${TagFrmwkRender}: setRenderRate : PASS`); + } else { + console.info(`${TagFrmwkAudioScene}: setRenderRate caught err, but dismatch : FAILED`); + resultFlag = false; + } + } else { + console.info(`${TagFrmwkAudioScene}: setRenderRate : FAILED`); + resultFlag = false; + } + }); + console.info(`${TagFrmwkRender}: Renderer after read`); + await audioRen.getRenderRate().then((data) => {}).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getRenderRate : ERROR : ${err.message}`); + resultFlag = false; + }); + + await audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); await audioRen.stop().then(() => { console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); - resultFlag = false; }); - await sleep(500); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); await audioRen.release().then(() => { console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - await sleep(500); - expect(resultFlag).assertTrue(); + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + console.info(`${TagFrmwkRender}: resultFlag : ${resultFlag}`); + await sleep(500) + + expect(resultFlag).assertTrue(); + await closeFileDescriptor(readPath); done(); }) - + /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8100 - * @tc.name : AudioRenderer - STATE_PAUSED - Callback - * @tc.desc : AudioRenderer - STATE_PAUSED + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8000 + * @tc.name : AudioRenderer - SetRenderRate - UNSUPPORT_OPTION + * @tc.desc : AudioRenderer - SetRenderRate - UNSUPPORT_OPTION * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8100', 2, async function (done) { + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8000', 2, async function (done) { + let AudioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, channels: audio.AudioChannel.CHANNEL_2, @@ -6954,7 +7340,13 @@ describe('audioRenderer', function () { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - let resultFlag = false; + + readPath = 'StarWars10s-2C-48000-4SW.wav'; + await getFdRead(readPath, done); + let AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT; + + let resultFlag = true; + console.info(`${TagFrmwkRender}: Promise : Audio Playback Function`); let audioRen; let isPass = false; @@ -6979,20 +7371,25 @@ describe('audioRenderer', function () { done(); return; } - audioRen.on('stateChange', (AudioState) => { - console.log(`${TagFrmwk}: Volume Change Event is called`); + console.info(`${TagFrmwkRender}: AudioRenderer : Path : ${readPath}`); - switch (AudioState) { - case audio.AudioState.STATE_PAUSED: - console.info(`${TagFrmwk}: state : STATE_PAUSED`); - resultFlag = true; - break; - default: - console.info(`${TagFrmwk}: state : ${AudioState}`); - break; - } + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + await audioRen.getStreamInfo().then((audioParamsGet) => { + console.info(`${TagFrmwkRender}: Renderer getStreamInfo: ${JSON.stringify(audioParamsGet)}`); + }).catch((err) => { + console.log(`${TagFrmwkRender}: getStreamInfo :ERROR: ${err.message}`); + resultFlag = false; + }); + + await audioRen.getRendererInfo().then((audioParamsGet) => { + console.info(`${TagFrmwkRender}: Renderer RendererInfo: ${JSON.stringify(audioParamsGet)}`); + }).catch((err) => { + console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); + resultFlag = false; }); + await audioRen.start().then(() => { console.info(`${TagFrmwkRender}: renderInstant started :SUCCESS`); }).catch((err) => { @@ -7000,105 +7397,103 @@ describe('audioRenderer', function () { resultFlag = false; }); - await sleep(500); - await audioRen.pause().then(() => { - console.info(`${TagFrmwkRender}: renderInstant Pause :SUCCESS`); - }).catch((err) => { - console.info(`${TagFrmwkRender}: renderInstant Pause :ERROR : ${err.message}`); + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + let bufferSize = await audioRen.getBufferSize(); + console.info(`${TagFrmwkRender}: buffer size: ${bufferSize}`); + + let ss = fileio.fdopenStreamSync(fdRead, 'r'); + console.info(`${TagFrmwkRender}:case 2:AudioFrameworkRenderLog: File Path: ${ss}`); + let discardHeader = new ArrayBuffer(44); + ss.readSync(discardHeader); + let totalSize = fileio.fstatSync(fdRead).size; + console.info(`${TagFrmwkRender}:case 3 : AudioFrameworkRenderLog: File totalSize size: ${totalSize}`); + totalSize = totalSize - 44; + console.info(`${TagFrmwkRender}: File size : Removing header: ${totalSize}`); + let rlen = 0; + while (rlen < totalSize / 4) { + let buf = new ArrayBuffer(bufferSize); + rlen += ss.readSync(buf); + console.info(`${TagFrmwkRender}:BufferAudioFramework: bytes read from file: ${rlen}`); + await audioRen.write(buf); + if (rlen > (totalSize / 8)) { + await AUDIOMANAGER.getAudioScene().then((data) =>{ + console.info(`${TagFrmwkAudioScene}: getAudioScene : Value : ${data}`); + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getAudioScene : ERROR : ${err.message}`); + resultFlag = false; + }); + } + if (rlen > (totalSize / 8)) { + await audioRen.setRenderRate(numberParameter).then(() => { + console.info(`${TagFrmwkRender}: setRenderRate : FAILED`); + }).catch((err) => { + if (err.code == 6800104) { + console.info(`${TagFrmwkRender}: setRenderRate : SUCCESS`); + } else { + console.info(`${TagFrmwkRender}: setRenderRate : caught err but dismatch : FAILED`); + resultFlag = false; + } + }); + } + } + + console.info(`${TagFrmwkRender}: Renderer after read`); + await audioRen.getRenderRate().then((data) => {}).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getRenderRate : RENDER_RATE_DOUBLE : ERROR : ${err.message}`); resultFlag = false; }); - await sleep(500); + await audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + await audioRen.stop().then(() => { console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); }); - await sleep(500); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); await audioRen.release().then(() => { console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - await sleep(500) - expect(resultFlag).assertTrue(); + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); - done(); + console.info(`${TagFrmwkRender}: resultFlag : ${resultFlag}`); - }) + await sleep(500) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8200 - * @tc.name : AudioState - STATE_INVALID - * @tc.desc : AudioState - STATE_INVALID - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8200', 2, async function (done) { - expect(audio.AudioState.STATE_INVALID).assertEqual(-1); - await sleep(50); - done(); - }) + expect(resultFlag).assertTrue(); - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8300 - * @tc.name : AudioState - STATE_NEW - * @tc.desc : AudioState - STATE_NEW - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8300', 2, async function (done) { - expect(audio.AudioState.STATE_NEW).assertEqual(0); - await sleep(50); + await closeFileDescriptor(readPath); done(); - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8400 - * @tc.name : AudioSampleFormat - STATE_FORMAT_INVALID - * @tc.desc : AudioSampleFormat - STATE_FORMAT_INVALID - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8400', 2, async function (done) { - expect(audio.AudioSampleFormat.SAMPLE_FORMAT_INVALID).assertEqual(-1); - await sleep(50); - done(); }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8500 - * @tc.name : SourceType - SOURCE_TYPE_INVALID - * @tc.desc : SourceType - SOURCE_TYPE_INVALID + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8100 + * @tc.name : AudioRenderer - SetRenderRate - INVALID_PARAM + * @tc.desc : AudioRenderer - SetRenderRate - INVALID_PARAM * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8500', 2, async function (done) { - expect(audio.SourceType.SOURCE_TYPE_INVALID).assertEqual(-1); - await sleep(50); - done(); - }) + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8100', 2, async function (done) { - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8600 - * @tc.name : AudioRenderer - Pause - Callback - * @tc.desc : AudioRenderer - Pause - Callback - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8600', 2, async function (done) { let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_24000, channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } @@ -7112,7 +7507,13 @@ describe('audioRenderer', function () { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - let resultFlag = false; + + readPath = 'StarWars10s-2C-24000-3SW.wav' + await getFdRead(readPath, done); + let AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT; + + let resultFlag = true; + console.info(`${TagFrmwkRender}: Promise : Audio Playback Function`); let audioRen; let isPass = false; @@ -7137,20 +7538,25 @@ describe('audioRenderer', function () { done(); return; } - audioRen.on('stateChange', (AudioState) => { - console.log(`${TagFrmwk}: Volume Change Event is called`); + console.info(`${TagFrmwkRender}: AudioRenderer : Path : ${readPath}`); - switch (AudioState) { - case audio.AudioState.STATE_PAUSED: - console.info(`${TagFrmwk}: state : STATE_PAUSED`); - resultFlag = true; - break; - default: - console.info(`${TagFrmwk}: state : ${AudioState}`); - break; - } + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + await audioRen.getStreamInfo().then((audioParamsGet) => { + console.info(`${TagFrmwkRender}: Renderer getStreamInfo: ${JSON.stringify(audioParamsGet)}`); + }).catch((err) => { + console.log(`${TagFrmwkRender}: getStreamInfo :ERROR: ${err.message}`); + resultFlag = false; + }); + + await audioRen.getRendererInfo().then((audioParamsGet) => { + console.info(`${TagFrmwkRender}: Renderer RendererInfo: ${JSON.stringify(audioParamsGet)}`); + }).catch((err) => { + console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); + resultFlag = false; }); + await audioRen.start().then(() => { console.info(`${TagFrmwkRender}: renderInstant started :SUCCESS`); }).catch((err) => { @@ -7158,73 +7564,108 @@ describe('audioRenderer', function () { resultFlag = false; }); - await sleep(2000); - audioRen.pause((err) => { - if (err) { - console.info(`${TagFrmwkRender}: renderInstant Pause :ERROR : ${err.message}`); - resultFlag = false; + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + let bufferSize = await audioRen.getBufferSize(); + console.info(`${TagFrmwkRender}: buffer size: ${bufferSize}`); + + let ss = fileio.fdopenStreamSync(fdRead, 'r'); + console.info(`${TagFrmwkRender}:case 2:AudioFrameworkRenderLog: File Path: ${ss}`); + let discardHeader = new ArrayBuffer(44); + ss.readSync(discardHeader); + let totalSize = fileio.fstatSync(fdRead).size; + console.info(`${TagFrmwkRender}:case 3 : AudioFrameworkRenderLog: File totalSize size: ${totalSize}`); + totalSize = totalSize - 44; + console.info(`${TagFrmwkRender}: File size : Removing header: ${totalSize}`); + let rlen = 0; + while (rlen < totalSize / 4) { + let buf = new ArrayBuffer(bufferSize); + rlen += ss.readSync(buf); + console.info(`${TagFrmwkRender}:BufferAudioFramework: bytes read from file: ${rlen}`); + await audioRen.write(buf); + if (rlen > (totalSize / 8)) { + await AUDIOMANAGER.getAudioScene().then((data) =>{ + console.info(`${TagFrmwkAudioScene}: getAudioScene : Value : ${data}`); + }).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getAudioScene : ERROR : ${err.message}`); + resultFlag = false; + }); } - else { - console.info(`${TagFrmwkRender}: renderInstant Pause :SUCCESS`); + if (rlen > (totalSize / 8)) { + await audioRen.setRenderRate(stringParameter).then(() => { + console.info(`${TagFrmwkRender}: setRenderRate : FAILED`); + }).catch((err) => { + if (err.code == 6800101) { + console.info(`${TagFrmwkRender}: setRenderRate : SUCCESS`); + } else { + console.info(`${TagFrmwkRender}: setRenderRate : caught err but dismatch : FAILED`); + resultFlag = false; + } + }); } + } + console.info(`${TagFrmwkRender}: Renderer after read`); + await audioRen.getRenderRate().then((data) => {}).catch((err) => { + console.info(`${TagFrmwkAudioScene}: getRenderRate : RENDER_RATE_HALF : ERROR : ${err.message}`); + resultFlag = false; }); - await sleep(500); + + await audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); await audioRen.stop().then(() => { console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); }); - await sleep(500); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); await audioRen.release().then(() => { console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + console.info(`${TagFrmwkRender}: resultFlag : ${resultFlag}`); + await sleep(500) expect(resultFlag).assertTrue(); + await closeFileDescriptor(readPath); done(); }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8700 - * @tc.name : AudioEncodingType - ENCODING_TYPE_INVALID - * @tc.desc : AudioEncodingType - ENCODING_TYPE_INVALID + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8200 + * @tc.name : AudioRenderer - getAudioTime - Error + * @tc.desc : AudioRenderer - getAudioTime - Error * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8700', 2, async function (done) { - expect(audio.AudioEncodingType.ENCODING_TYPE_INVALID).assertEqual(-1); - await sleep(50); - done(); - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8800 - * @tc.name : StreamUsage - STREAM_USAGE_VOICE_ASSISTANT - * @tc.desc : StreamUsage - STREAM_USAGE_VOICE_ASSISTANT - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8800', 2, async function (done) { + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8200', 2, async function (done) { let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, rendererFlags: 0 } @@ -7233,41 +7674,88 @@ describe('audioRenderer', function () { rendererInfo: AudioRendererInfo } - try { - readPath = 'StarWars10s-1C-44100-2SW.wav'; - await getFdRead(readPath, done); - let resultFlag = await playbackPromise(AudioRendererOptions, filePath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); - await sleep(100); - console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag); + readPath = 'StarWars10s-2C-48000-4SW.wav'; + await getFdRead(readPath, done); + let resultFlag = true; + console.info(`${TagFrmwkRender}: AudioRenderer : Path : ${readPath}`); + + console.info(`${TagFrmwkRender}: Promise : Audio Playback Function`); + + let audioRen; + let isPass = false; + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); + LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; + LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; + let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; + if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { + isPass = true; + return; + } + resultFlag = false; + }); + console.log(`isPass: ${isPass}`); + if (isPass) { + resultFlag = true; expect(resultFlag).assertTrue(); - await closeFileDescriptor(readPath); - } catch (error) { - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8800 : error = " + error); - expect(false).assertTrue(); + done(); + return; } + + await audioRen.getAudioTime().then((data) => { + console.info(`${TagFrmwkRender}: getAudioTime : Value : ${data}`); + resultFlag = true; + if (data > 0) { + console.info(`${TagFrmwkRender}: getAudioTime : PASS : ${data}`); + } + else { + console.info(`${TagFrmwkRender}: getAudioTime : FAIL : ${data}`); + } + }).catch((err) => { + console.info(`${TagFrmwkRender}: getAudioTime : ERROR : ${err.message}`); + }); + + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + + console.info(`${TagFrmwkRender}: AudioRenderer : STATE : ${audioRen.state}`); + + console.info(`${TagFrmwkRender}: resultFlag : ${resultFlag}`); + + await sleep(500); + + expect(resultFlag).assertTrue(); + await closeFileDescriptor(readPath); done(); + }) + /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0100 - * @tc.name : STREAM_VOICE_CALL INTERRUPT STREAM_VOICE_ASSISTANT - * @tc.desc : STREAM_VOICE_CALL INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8300 + * @tc.name : AudioRenderer - STATE_PREPARED -Callback + * @tc.desc : AudioRenderer - STATE_PREPARED * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0100', 2, async function (done) { - let interrput_flag = false; + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8300', 2, async function (done) { let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, rendererFlags: 0 } @@ -7275,95 +7763,78 @@ describe('audioRenderer', function () { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } + let resultFlag = false; - try { - let audioRen; - await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { - audioRen = data; - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); - }); - - audioRen.on('interrupt',async (interruptEvent)=>{ - console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); - console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); - console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); - if (interruptEvent.hintType >= 0) { - console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); - interrput_flag = true; - } - }); - - let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); - - await audioRen.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); - }); - await sleep(1000); - // STREAM_VOICE_CALL - let AudioRendererInfo_interrupt = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 + let audioRen; + let isPass = false; + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); + LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; + LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; + let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; + if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { + isPass = true; + return; } + resultFlag = false; + }); + console.log(`isPass: ${isPass}`); + if (isPass) { + resultFlag = true; + expect(resultFlag).assertTrue(); + done(); + return; + } - let AudioRendererOptions_interrupt = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo_interrupt - } + audioRen.on('stateChange', (AudioState) => { - let audioRen_interrupt; - await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { - audioRen_interrupt = data; - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); - }); + console.log(`${TagFrmwk}: Volume Change Event is called`); - let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + switch (AudioState) { + case audio.AudioState.STATE_RELEASED: + console.info(`${TagFrmwk}: state : STATE_NEW`); + resultFlag = true; + break; + default: + console.info(`${TagFrmwk}: state : ${AudioState}`); + break; + } + }); + await sleep(1000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + await sleep(1000); + expect(resultFlag).assertTrue(); - await audioRen_interrupt.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); - }); - await sleep(2000); - expect(interrput_flag).assertTrue(); - } - catch (error) { - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0100 : error = " + error); - expect(false).assertTrue(); - } done(); + }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0200 - * @tc.name : STREAM_RING INTERRUPT STREAM_VOICE_ASSISTANT - * @tc.desc : STREAM_RING INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8400 + * @tc.name : AudioRenderer - STATE_RUNNING - Callback + * @tc.desc : AudioRenderer - STATE_RUNNING * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0200', 2, async function (done) { - let interrput_flag = false; + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8400', 2, async function (done) { let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, rendererFlags: 0 } @@ -7371,95 +7842,94 @@ describe('audioRenderer', function () { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } + let resultFlag = false; - try { - let audioRen; - await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { - audioRen = data; - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); - }); - - audioRen.on('interrupt',async (interruptEvent)=>{ - console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); - console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); - console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); - if (interruptEvent.hintType >= 0) { - console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); - interrput_flag = true; - } - }); - - let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); - - await audioRen.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); - }); - await sleep(1000); - // STREAM_RING - let AudioRendererInfo_interrupt = { - content: audio.ContentType.CONTENT_TYPE_RINGTONE, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, - rendererFlags: 0 + let audioRen; + let isPass = false; + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); + LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; + LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; + let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; + if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { + isPass = true; + return; } + resultFlag = false; + }); + console.log(`isPass: ${isPass}`); + if (isPass) { + resultFlag = true; + expect(resultFlag).assertTrue(); + done(); + return; + } - let AudioRendererOptions_interrupt = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo_interrupt + audioRen.on('stateChange', (AudioState) => { + + console.log(`${TagFrmwk}: Volume Change Event is called`); + + switch (AudioState) { + case audio.AudioState.STATE_RUNNING: + console.info(`${TagFrmwk}: state : STATE_RUNNING`); + resultFlag = true; + break; + default: + console.info(`${TagFrmwk}: state : ${AudioState}`); + break; } + }); - let audioRen_interrupt; - await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { - audioRen_interrupt = data; - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); - }); + await audioRen.start().then(() => { + console.info(`${TagFrmwkRender}: renderInstant started :SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: renderInstant start :ERROR : ${err.message}`); + resultFlag = false; + }); - let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + await sleep(500); + + await audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + await sleep(1000); + + expect(resultFlag).assertTrue(); - await audioRen_interrupt.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); - }); - await sleep(2000); - expect(interrput_flag).assertTrue(); - } - catch (error) { - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0200 : error = " + error); - expect(false).assertTrue(); - } done(); + }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0300 - * @tc.name : STREAM_MUSIC INTERRUPT STREAM_VOICE_ASSISTANT - * @tc.desc : STREAM_MUSIC INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8500 + * @tc.name : AudioRenderer - STATE_STOPPED - Callback + * @tc.desc : AudioRenderer - STATE_STOPPED * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0300', 2, async function (done) { - let interrput_flag = false; + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8500', 2, async function (done) { let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, rendererFlags: 0 } @@ -7467,95 +7937,96 @@ describe('audioRenderer', function () { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } + let resultFlag = false; - try { - let audioRen; - await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { - audioRen = data; - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); - }); + let audioRen; + let isPass = false; + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); + LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; + LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; + let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; + if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { + isPass = true; + return; + } + resultFlag = false; + }); + console.log(`isPass: ${isPass}`); + if (isPass) { + resultFlag = true; + expect(resultFlag).assertTrue(); + done(); + return; + } - audioRen.on('interrupt',async (interruptEvent)=>{ - console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); - console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); - console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); - if (interruptEvent.hintType >= 0) { - console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); - interrput_flag = true; - } - }); + audioRen.on('stateChange', (AudioState) => { - let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + console.log(`${TagFrmwk}: Volume Change Event is called`); - await audioRen.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); - }); - await sleep(1000); - // STREAM_MUSIC - let AudioRendererInfo_interrupt = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 + switch (AudioState) { + case audio.AudioState.STATE_STOPPED: + console.info(`${TagFrmwk}: state : STATE_STOPPED`); + resultFlag = true; + break; + default: + console.info(`${TagFrmwk}: state : ${AudioState}`); + break; } + }); - let AudioRendererOptions_interrupt = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo_interrupt - } + await audioRen.start().then(() => { + console.info(`${TagFrmwkRender}: renderInstant started :SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: renderInstant start :ERROR : ${err.message}`); + resultFlag = false; + }); - let audioRen_interrupt; - await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { - audioRen_interrupt = data; - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); - }); + await sleep(500); - let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + await audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + resultFlag = false; + }); + await sleep(500); + + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + await sleep(500); + + expect(resultFlag).assertTrue(); - await audioRen_interrupt.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); - }); - await sleep(2000); - expect(interrput_flag).assertTrue(); - } - catch (error) { - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0300 : error = " + error); - expect(false).assertTrue(); - } done(); + }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0400 - * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_ASSISTANT - * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8600 + * @tc.name : AudioRenderer - STATE_RELEASED - Callback + * @tc.desc : AudioRenderer - STATE_RELEASED * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0400', 2, async function (done) { - let interrput_flag = false; + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8600', 2, async function (done) { let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, rendererFlags: 0 } @@ -7563,20 +8034,1025 @@ describe('audioRenderer', function () { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } + let resultFlag = false; - try { - let audioRen; - await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { - audioRen = data; - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); - }); - - audioRen.on('interrupt',async (interruptEvent)=>{ - console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); - console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + let audioRen; + let isPass = false; + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); + LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; + LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; + let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; + if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { + isPass = true; + return; + } + resultFlag = false; + }); + console.log(`isPass: ${isPass}`); + if (isPass) { + resultFlag = true; + expect(resultFlag).assertTrue(); + done(); + return; + } + + audioRen.on('stateChange', (AudioState) => { + + console.log(`${TagFrmwk}: Volume Change Event is called`); + + switch (AudioState) { + case audio.AudioState.STATE_RELEASED: + console.info(`${TagFrmwk}: state : STATE_RELEASED`); + resultFlag = true; + break; + default: + console.info(`${TagFrmwk}: state : ${AudioState}`); + break; + } + }); + + await audioRen.start().then(() => { + console.info(`${TagFrmwkRender}: renderInstant started :SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: renderInstant start :ERROR : ${err.message}`); + resultFlag = false; + }); + + await sleep(500); + + await audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + resultFlag = false; + }); + await sleep(500); + + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + await sleep(500); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8700 + * @tc.name : AudioRenderer - STATE_PAUSED - Callback + * @tc.desc : AudioRenderer - STATE_PAUSED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8700', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + let resultFlag = false; + + let audioRen; + let isPass = false; + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); + LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; + LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; + let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; + if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { + isPass = true; + return; + } + resultFlag = false; + }); + console.log(`isPass: ${isPass}`); + if (isPass) { + resultFlag = true; + expect(resultFlag).assertTrue(); + done(); + return; + } + audioRen.on('stateChange', (AudioState) => { + + console.log(`${TagFrmwk}: Volume Change Event is called`); + + switch (AudioState) { + case audio.AudioState.STATE_PAUSED: + console.info(`${TagFrmwk}: state : STATE_PAUSED`); + resultFlag = true; + break; + default: + console.info(`${TagFrmwk}: state : ${AudioState}`); + break; + } + }); + await audioRen.start().then(() => { + console.info(`${TagFrmwkRender}: renderInstant started :SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: renderInstant start :ERROR : ${err.message}`); + resultFlag = false; + }); + + await sleep(500); + + await audioRen.pause().then(() => { + console.info(`${TagFrmwkRender}: renderInstant Pause :SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: renderInstant Pause :ERROR : ${err.message}`); + resultFlag = false; + }); + + await sleep(500); + await audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + await sleep(500); + + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8800 + * @tc.name : AudioState - STATE_INVALID + * @tc.desc : AudioState - STATE_INVALID + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8800', 2, async function (done) { + expect(audio.AudioState.STATE_INVALID).assertEqual(-1); + await sleep(50); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8900 + * @tc.name : AudioState - STATE_NEW + * @tc.desc : AudioState - STATE_NEW + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8900', 2, async function (done) { + expect(audio.AudioState.STATE_NEW).assertEqual(0); + await sleep(50); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_9000 + * @tc.name : AudioSampleFormat - STATE_FORMAT_INVALID + * @tc.desc : AudioSampleFormat - STATE_FORMAT_INVALID + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_9000', 2, async function (done) { + expect(audio.AudioSampleFormat.SAMPLE_FORMAT_INVALID).assertEqual(-1); + await sleep(50); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_9100 + * @tc.name : SourceType - SOURCE_TYPE_INVALID + * @tc.desc : SourceType - SOURCE_TYPE_INVALID + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_9100', 2, async function (done) { + expect(audio.SourceType.SOURCE_TYPE_INVALID).assertEqual(-1); + await sleep(50); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_9200 + * @tc.name : AudioRenderer - Pause - Callback + * @tc.desc : AudioRenderer - Pause - Callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_9200', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + let resultFlag = false; + + let audioRen; + let isPass = false; + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ${err.message}`); + LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; + LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; + let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; + if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { + isPass = true; + return; + } + resultFlag = false; + }); + console.log(`isPass: ${isPass}`); + if (isPass) { + resultFlag = true; + expect(resultFlag).assertTrue(); + done(); + return; + } + audioRen.on('stateChange', (AudioState) => { + + console.log(`${TagFrmwk}: Volume Change Event is called`); + + switch (AudioState) { + case audio.AudioState.STATE_PAUSED: + console.info(`${TagFrmwk}: state : STATE_PAUSED`); + resultFlag = true; + break; + default: + console.info(`${TagFrmwk}: state : ${AudioState}`); + break; + } + }); + await audioRen.start().then(() => { + console.info(`${TagFrmwkRender}: renderInstant started :SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: renderInstant start :ERROR : ${err.message}`); + resultFlag = false; + }); + + await sleep(2000); + + audioRen.pause((err) => { + if (err) { + console.info(`${TagFrmwkRender}: renderInstant Pause :ERROR : ${err.message}`); + resultFlag = false; + } + else { + console.info(`${TagFrmwkRender}: renderInstant Pause :SUCCESS`); + } + }); + await sleep(500); + + await audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + await sleep(500); + + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_9300 + * @tc.name : AudioEncodingType - ENCODING_TYPE_INVALID + * @tc.desc : AudioEncodingType - ENCODING_TYPE_INVALID + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_9300', 2, async function (done) { + expect(audio.AudioEncodingType.ENCODING_TYPE_INVALID).assertEqual(-1); + await sleep(50); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_9400 + * @tc.name : StreamUsage - STREAM_USAGE_VOICE_ASSISTANT + * @tc.desc : StreamUsage - STREAM_USAGE_VOICE_ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_9400', 2, async function (done) { + + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + readPath = 'StarWars10s-1C-44100-2SW.wav'; + await getFdRead(readPath, done); + let resultFlag = await playbackPromise(AudioRendererOptions, filePath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag); + expect(resultFlag).assertTrue(); + await closeFileDescriptor(readPath); + } catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_8800 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0100 + * @tc.name : STREAM_VOICE_CALL INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.desc : STREAM_VOICE_CALL INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0100', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); + interrput_flag = true; + } + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_VOICE_CALL + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + expect(interrput_flag).assertTrue(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0100 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0200 + * @tc.name : STREAM_RING INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.desc : STREAM_RING INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0200', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); + interrput_flag = true; + } + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_RING + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + expect(interrput_flag).assertTrue(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0200 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0300 + * @tc.name : STREAM_MUSIC INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.desc : STREAM_MUSIC INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0300', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); + interrput_flag = true; + } + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_MUSIC + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + expect(interrput_flag).assertTrue(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0300 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0400 + * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0400', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); + interrput_flag = true; + } + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + expect(interrput_flag).assertTrue(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0400 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0500 + * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_CALL + * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_CALL + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0500', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_VOICE_CALL + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); + interrput_flag = true; + } + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + expect(interrput_flag).assertFalse(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0500 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0600 + * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_RING + * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_RING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0600', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_RING + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); + interrput_flag = true; + } + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + expect(interrput_flag).assertFalse(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0600 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0700 + * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_MUSIC + * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_MUSIC + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0700', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_MUSIC + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); if (interruptEvent.hintType >= 0) { console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); @@ -7620,315 +9096,438 @@ describe('audioRenderer', function () { await audioRen_interrupt.start().then(async function () { console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + expect(interrput_flag).assertTrue(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0700 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0100 + * @tc.name : SetInterruptMode mode 0 callback,is public share mode + * @tc.desc : SetInterruptMode mode 0 callback,is public share mode + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0100", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = audio.InterruptMode.SHARE_MODE; + audioRenderer.setInterruptMode(mode, async (err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: error: ${err.message}`); + expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + return; + } + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: SUCCESS`); + expect(true).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + }); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0200 + * @tc.name : SetInterruptMode mode 0 callback,is public share mode + * @tc.desc : SetInterruptMode mode 0 callback,is public share mode + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0200", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = audio.InterruptMode.INDEPENDENT_MODE; + audioRenderer.setInterruptMode(mode, async (err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: error: ${err.message}`); + expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + return; + } + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: SUCCESS`); + expect(true).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + }); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0300 + * @tc.name : SetInterruptMode mode 0 callback,is public share mode + * @tc.desc : SetInterruptMode mode 0 callback,is public share mode + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0300", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = audio.InterruptMode.SHARE_MODE; + audioRenderer.setInterruptMode(mode).then(async data => { + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE PROMISE: SUCCESS`); + expect(true).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - await sleep(2000); - expect(interrput_flag).assertTrue(); - } - catch (error) { - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0400 : error = " + error); + done(); + }).catch(async err => { + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE PROMISE: error: ${err.message}`); expect(false).assertTrue(); - } - done(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + }); }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0500 - * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_CALL - * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_CALL + * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0400 + * @tc.name : SetInterruptMode mode 1 promise,is independent mode + * @tc.desc : SetInterruptMode mode 1 promise,is independent mode * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0500', 2, async function (done) { - let interrput_flag = false; - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0400", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - // STREAM_VOICE_CALL - let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, rendererFlags: 0 } - - let AudioRendererOptions = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo } - - try { - let audioRen; - await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { - audioRen = data; - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); - }); - - audioRen.on('interrupt',async (interruptEvent)=>{ - console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); - console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); - console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); - if (interruptEvent.hintType >= 0) { - console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); - interrput_flag = true; - } - }); - - let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); - - await audioRen.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); - }); - await sleep(1000); - // STREAM_VOICE_ASSISTANT - let AudioRendererInfo_interrupt = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - } - - let AudioRendererOptions_interrupt = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo_interrupt - } - - let audioRen_interrupt; - await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { - audioRen_interrupt = data; - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = audio.InterruptMode.INDEPENDENT_MODE; + audioRenderer.setInterruptMode(mode).then(async data => { + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: SUCCESS`); + expect(true).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - - let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); - - await audioRen_interrupt.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + done(); + }).catch(async err => { + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: error: ${err.message}`); + expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - await sleep(2000); - expect(interrput_flag).assertFalse(); - } - catch (error) { - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0500 : error = " + error); - expect(false).assertTrue(); - } - done(); + done(); + }); }) + /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0600 - * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_RING - * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_RING + * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0500 + * @tc.name : SetInterruptMode invalid param callback + * @tc.desc : SetInterruptMode invalid param callback * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0600', 2, async function (done) { - let interrput_flag = false; - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0500", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - // STREAM_RING - let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_RINGTONE, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, rendererFlags: 0 } - - let AudioRendererOptions = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo } - - try { - let audioRen; - await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { - audioRen = data; - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); - }); - - audioRen.on('interrupt',async (interruptEvent)=>{ - console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); - console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); - console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); - if (interruptEvent.hintType >= 0) { - console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); - interrput_flag = true; + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + audioRenderer.setInterruptMode(stringParameter, async (err, data) => { + if (err) { + if (err.code == 6800101) { + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: SUCCESS`); + expect(true).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + return; } + } + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: error: ${err.message}`); + expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); + done(); + return; + }); + }) - let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); - - await audioRen.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + /* + * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0600 + * @tc.name : SetInterruptMode invalid param promise + * @tc.desc : SetInterruptMode invalid param promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0600", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + audioRenderer.setInterruptMode(stringParameter).then(async data => { + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: error`); + expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - await sleep(1000); - // STREAM_VOICE_ASSISTANT - let AudioRendererInfo_interrupt = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - } - - let AudioRendererOptions_interrupt = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo_interrupt + done(); + }).catch(async err => { + if (err.code == 6800101){ + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: SUCCESS`); + expect(true).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + } else { + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: error`); + expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); } + }); + }) - let audioRen_interrupt; - await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { - audioRen_interrupt = data; - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + /* + * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0700 + * @tc.name : SetInterruptMode invalid param promise + * @tc.desc : SetInterruptMode invalid param promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0700", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = 2; + try { + let data = await audioRenderer.setInterruptMode(mode); + console.info(`${TagFrmwkRender}: SetInterruptMode OUT OF BORDER PROMISE: SUCCESS`); + expect(true).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - - let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); - - await audioRen_interrupt.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + done(); + } catch (err) { + console.info(`${TagFrmwkRender}: SetInterruptMode OUT OF BORDER PROMISE: ERROR: ${err.message}`); + expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - await sleep(2000); - expect(interrput_flag).assertFalse(); - } - catch (error) { - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0600 : error = " + error); - expect(false).assertTrue(); + done(); } - done(); }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0700 - * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_MUSIC - * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_MUSIC + /* + * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0800 + * @tc.name : SetInterruptMode invalid param promise + * @tc.desc : SetInterruptMode invalid param promise * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it('SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0700', 2, async function (done) { - let interrput_flag = false; - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0800", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - // STREAM_MUSIC - let AudioRendererInfo = { + let audioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_MUSIC, usage: audio.StreamUsage.STREAM_USAGE_MEDIA, rendererFlags: 0 } - - let AudioRendererOptions = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo } - + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = 2; try { - let audioRen; - await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { - audioRen = data; - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); - }); - - audioRen.on('interrupt',async (interruptEvent)=>{ - console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); - console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); - console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); - if (interruptEvent.hintType >= 0) { - console.info("AudioFrameworkRenderLog: on'interrupt' SUCCESS "); - interrput_flag = true; + audioRenderer.setInterruptMode(mode, async (err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: error: ${err.message}`); + expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + return; } - }); - - let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); - - await audioRen.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); - }); - await sleep(1000); - // STREAM_VOICE_ASSISTANT - let AudioRendererInfo_interrupt = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - } - - let AudioRendererOptions_interrupt = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo_interrupt - } - - let audioRen_interrupt; - await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { - audioRen_interrupt = data; - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); - console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); - }).catch((err) => { - console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); - }); - - let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); - console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); - - await audioRen_interrupt.start().then(async function () { - console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: SUCCESS`); + expect(true).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + }) + } catch (err) { + console.info(`${TagFrmwkRender}: SetInterruptMode OUT OF BORDER PROMISE: ERROR: ${err.message}`); + expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); }).catch((err) => { - console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); - await sleep(2000); - expect(interrput_flag).assertTrue(); - } - catch (error) { - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0700 : error = " + error); - expect(false).assertTrue(); + done(); } - done(); }) /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0100 - * @tc.name : SetInterruptMode mode 0 callback,is public share mode - * @tc.desc : SetInterruptMode mode 0 callback,is public share mode + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0100 + * @tc.name : AudioRenderer - getAudioStreamId + * @tc.desc : AudioRenderer - getAudioStreamId * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 2 */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0100", 2, async function (done) { + it("SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0100", 2, async function (done) { let audioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, channels: audio.AudioChannel.CHANNEL_1, @@ -7945,27 +9544,37 @@ describe('audioRenderer', function () { rendererInfo: audioRendererInfo } let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = audio.InterruptMode.SHARE_MODE; - audioRenderer.setInterruptMode(mode, (err, data) => { - if (err) { - console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: error: ${err.message}`); - expect(false).assertTrue(); - done(); - return; - } - console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: SUCCESS`); + try { + let data = await audioRenderer.getAudioStreamId(); + console.info(`${TagFrmwkRender}: SUB_MULTIMEDIA_AUDIO_getAudioStreamId_0100 OUT OF BORDER PROMISE: SUCCESS ${data}`); expect(true).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); - }) + } catch (err) { + console.info(`${TagFrmwkRender}: SUB_MULTIMEDIA_AUDIO_getAudioStreamId_0100 OUT OF BORDER PROMISE: ERROR: ${err.message}`); + expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + } }) - - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0200 - * @tc.desc:SetInterruptMode mode 1 callback,is independent mode - * @tc.type: FUNC - * @tc.require: Issue Number + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0200 + * @tc.name : AudioRenderer - getAudioStreamId + * @tc.desc : AudioRenderer - getAudioStreamId + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0200", 2, async function (done) { + it("SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0200", 2, async function (done) { let audioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, channels: audio.AudioChannel.CHANNEL_1, @@ -7982,27 +9591,38 @@ describe('audioRenderer', function () { rendererInfo: audioRendererInfo } let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = audio.InterruptMode.INDEPENDENT_MODE; - audioRenderer.setInterruptMode(mode, (err, data) => { + await audioRenderer.getAudioStreamId(async (err, data) => { if (err) { console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: error: ${err.message}`); expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); return; } - console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: SUCCESS`); + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: SUCCESS ${data}`); expect(true).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); done(); }) }) - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0300 - * @tc.desc:SetInterruptMode mode 0 promise,is public share mode - * @tc.type: FUNC - * @tc.require: Issue Number + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0300 + * @tc.name : AudioRenderer - getAudioStreamId + * @tc.desc : AudioRenderer - getAudioStreamId + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0300", 2, async function (done) { + it("SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0300", 2, async function (done) { let audioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, channels: audio.AudioChannel.CHANNEL_1, @@ -8019,194 +9639,459 @@ describe('audioRenderer', function () { rendererInfo: audioRendererInfo } let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = audio.InterruptMode.SHARE_MODE; - audioRenderer.setInterruptMode(mode).then(data => { - console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE PROMISE: SUCCESS`); - expect(true).assertTrue(); - done(); - }).catch(err => { - console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE PROMISE: error: ${err.message}`); - expect(false).assertTrue(); + await audioRenderer.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + await audioRenderer.getAudioStreamId(async (err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK : ${err.message}`); + if (err.code == 6800103) { + console.log(`${TagFrmwkRender}:SetInterruptMode : SUCCESS`); + expect(true).assertTrue(); + } else { + console.log(`${TagFrmwkRender}: SetInterruptMode : error : ${err.code}`); + expect(false).assertTrue(); + } + } else { + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: SUCCESS ${data}`); + expect(false).assertTrue(); + } done(); }) }) - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0400 - * @tc.desc:SetInterruptMode mode 1 promise,is independent mode - * @tc.type: FUNC - * @tc.require: Issue Number + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0100 + * @tc.name : AudioRenderer - setVolume 0 - promise + * @tc.desc : AudioRenderer - setVolume 0 - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + let audioRen; + try { + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + let inputVolume = 0; + + await audioRen.setVolume(inputVolume).then(() => { + expect(true).assertTrue(); + console.info(`${TagFrmwkRender}: setVolume to 0 : Success`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + }); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0100 : error = " + error); + expect(false).assertTrue(); + } + await sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0200 + * @tc.name : AudioRenderer - setVolume 16 - promise + * @tc.desc : AudioRenderer - setVolume 16 - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0200', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + let audioRen; + try { + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + let inputVolume = 16; + + await audioRen.setVolume(inputVolume).then(() => { + expect(false).assertTrue(); + console.info(`${TagFrmwkRender}: setVolume to 16 TEST: ERROR`); + }).catch((err) => { + if (err.code == 6800104) { + console.info(`${TagFrmwkRender}: setVolume to 16 : OK`); + expect(true).assertTrue(); + } else { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + } + }); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0200 : error = " + error); + expect(false).assertTrue(); + } + await sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0300 + * @tc.name : AudioRenderer - setVolume "string" - promise + * @tc.desc : AudioRenderer - setVolume "string" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0400", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + it('SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0300', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - let audioRendererInfo = { + let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_MUSIC, usage: audio.StreamUsage.STREAM_USAGE_MEDIA, rendererFlags: 0 } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = audio.InterruptMode.INDEPENDENT_MODE; - audioRenderer.setInterruptMode(mode).then(data => { - console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: SUCCESS`); - expect(true).assertTrue(); - done(); - }).catch(err => { - console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: error: ${err.message}`); + let audioRen; + try { + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + let inputVolume = "string"; + + await audioRen.setVolume(inputVolume).then(() => { + expect(false).assertTrue(); + console.info(`${TagFrmwkRender}: setVolume to string TEST: ERROR`); + }).catch((err) => { + if (err.code == 6800101) { + console.info(`${TagFrmwkRender}: setVolume : SUCCESS : code: ${err.code}, mesage: ${err.message}`); + expect(true).assertTrue(); + } else { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + } + }); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0300 : error = " + error); expect(false).assertTrue(); - done(); - }) + } + await sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); }) - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0500 - * @tc.desc:SetInterruptMode mode '1',will catch error with type error - * @tc.type: FUNC - * @tc.require: Issue Number + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0400 + * @tc.name : AudioRenderer - setVolume 0 - callback + * @tc.desc : AudioRenderer - setVolume 0 - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0500", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + it('SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0400', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - let audioRendererInfo = { + let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, rendererFlags: 0 } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = '1'; + let audioRen; try { - let data = await audioRenderer.setInterruptMode(mode); - console.info(`${TagFrmwkRender}: SetInterruptMode STRING PROMISE: SUCCESS`); + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + let inputVolume = 0; + + audioRen.setVolume(inputVolume, (err)=>{ + if(err) { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + } else { + expect(true).assertTrue(); + console.info(`${TagFrmwkRender}: setVolume to 0 : Success`); + } + }); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0100 : error = " + error); expect(false).assertTrue(); - done(); - } catch (err) { - console.info(`${TagFrmwkRender}: SetInterruptMode STRING PROMISE: error: ${err.message}`); - expect(true).assertTrue(); - done(); } + await sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); }) - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0600 - * @tc.desc:SetInterruptMode mode 2,set it to default SHARE_MODE - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0600", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0500 + * @tc.name : AudioRenderer - setVolume 16 - callback + * @tc.desc : AudioRenderer - setVolume 16 - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0500', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - let audioRendererInfo = { + let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_MUSIC, usage: audio.StreamUsage.STREAM_USAGE_MEDIA, rendererFlags: 0 } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = 2; + let audioRen; try { - let data = await audioRenderer.setInterruptMode(mode); - console.info(`${TagFrmwkRender}: SetInterruptMode OUT OF BORDER PROMISE: SUCCESS`); - expect(true).assertTrue(); - done(); - } catch (err) { - console.info(`${TagFrmwkRender}: SetInterruptMode OUT OF BORDER PROMISE: ERROR: ${err.message}`); + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + let inputVolume = 16; + + audioRen.setVolume(inputVolume, (err)=>{ + if(err) { + if (err.code == 6800104) { + console.info(`${TagFrmwkRender}: setVolume to 16 : OK`); + expect(true).assertTrue(); + } else { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + } + } else { + expect(false).assertTrue(); + console.info(`${TagFrmwkRender}: setVolume to 16 TEST: ERROR`); + } + }); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0200 : error = " + error); expect(false).assertTrue(); - done(); } + await sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); }) - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_getAudioStreamId_0600 - * @tc.desc:getAudioStreamId mode 2,set it to default SHARE_MODE - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SUB_MULTIMEDIA_AUDIO_getAudioStreamId_0100", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0600 + * @tc.name : AudioRenderer - setVolume "string" - callback + * @tc.desc : AudioRenderer - setVolume "string" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0600', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - let audioRendererInfo = { + let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_MUSIC, usage: audio.StreamUsage.STREAM_USAGE_MEDIA, rendererFlags: 0 } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let audioRen; try { - let data = await audioRenderer.getAudioStreamId(); - console.info(`${TagFrmwkRender}: SUB_MULTIMEDIA_AUDIO_getAudioStreamId_0100 OUT OF BORDER PROMISE: SUCCESS ${data}`); - expect(true).assertTrue(); - done(); - } catch (err) { - console.info(`${TagFrmwkRender}: SUB_MULTIMEDIA_AUDIO_getAudioStreamId_0100 OUT OF BORDER PROMISE: ERROR: ${err.message}`); + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + let inputVolume = "string"; + + audioRen.setVolume(inputVolume, (err)=>{ + if(err) { + if (err.code == 6800101) { + console.info(`${TagFrmwkRender}: setVolume to 16 : OK`); + expect(true).assertTrue(); + } else { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + } + } else { + expect(false).assertTrue(); + console.info(`${TagFrmwkRender}: setVolume to 16 TEST: ERROR`); + } + }); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0300 : error = " + error); expect(false).assertTrue(); - done(); } + await sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); }) - - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_getAudioStreamId_0200 - * @tc.desc:getAudioStreamId callback,is independent mode - * @tc.type: FUNC - * @tc.require: Issue Number + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_ON_THROW_0100 + * @tc.name : AUDIO_RENDERER_ON_THROW_ERR + * @tc.desc : AUDIO_RENDERER_ON_THROW_ERR + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 */ - it("SUB_MULTIMEDIA_AUDIO_getAudioStreamId_0200", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + it('SUB_MULTIMEDIA_AUDIO_RENDERER_ON_THROW_0100', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, channels: audio.AudioChannel.CHANNEL_1, sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } - let audioRendererInfo = { + // STREAM_MUSIC + let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_MUSIC, usage: audio.StreamUsage.STREAM_USAGE_MEDIA, rendererFlags: 0 } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - await audioRenderer.getAudioStreamId((err, data) => { - if (err) { - console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: error: ${err.message}`); + let audioRen; + try { + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('invalidString',async (data)=>{ + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0700 : error = " + error); + expect(false).assertTrue(); + }); + } + catch (error) { + if (error.code == 6800101) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_ON_THROW_0100 : SUCCESS"); + expect(true).assertTrue(); + } else { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_ON_THROW_0100 : error = " + error.code); expect(false).assertTrue(); - done(); - return; } - console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: SUCCESS ${data}`); - expect(true).assertTrue(); - done(); - }) + } + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + done(); }) - }) \ No newline at end of file