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 86f81884fd977a51318c713d07e8a3111a2a6df7..981e39081e769e12f95d75c35fd2e1e75eeaf219 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 @@ -449,17 +449,22 @@ export default function audioCapturer() { }) } async function driveFn() { - console.info(`come in driveFn`); - let driver = await UiDriver.create(); - console.info(`driver is ${JSON.stringify(driver)}`); - await sleep(100); - console.info(`UiDriver start`); - let button = await driver.findComponent(BY.text('允许')); - console.info(`button is ${JSON.stringify(button)}`); - await sleep(100); - await button.click(); + try { + let driver = await UiDriver.create() + console.info(`case come in driveFn 222`) + console.info(`driver is ${JSON.stringify(driver)}`) + await sleep(100); + let button = await driver.findComponent(BY.text('允许')); + console.info(`button is ${JSON.stringify(button)}`); + await sleep(100); + await button.click(); + } catch (err) { + console.info('err is ' + err); + return; + } + } - + beforeAll(async function () { await getPermission(); await driveFn(); diff --git a/multimedia/audio/audio_js_standard/AudioCapturerChangeInfo/src/main/js/test/AudioCapturerChangeInfo.test.js b/multimedia/audio/audio_js_standard/AudioCapturerChangeInfo/src/main/js/test/AudioCapturerChangeInfo.test.js index 2152c4162fe369c96dba7d963864113d6a6bba8e..127189e9a1b6f8b93d8d611f4a718132e90499dc 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturerChangeInfo/src/main/js/test/AudioCapturerChangeInfo.test.js +++ b/multimedia/audio/audio_js_standard/AudioCapturerChangeInfo/src/main/js/test/AudioCapturerChangeInfo.test.js @@ -19,1239 +19,902 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from import { UiDriver, BY } from '@ohos.UiTest' export default function audioCapturerChange() { -describe('audioCapturerChange', function () { - let audioStreamManager; - let audioStreamManagerCB; - let Tag = "AFCapLog"; - - const audioManager = audio.getAudioManager(); - console.info(`${Tag}: Create AudioManger Object JS Framework`); - - - + describe('audioCapturerChange', function () { + let audioStreamManager; + let audioStreamManagerCB; + let Tag = "AFCapLog"; + + const audioManager = audio.getAudioManager(); + console.info(`${Tag}: Create AudioManger Object JS Framework`); + + + + + async function getPermission() { + let permissions = ['ohos.permission.MICROPHONE']; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("request success" + JSON.stringify(data)); + }) + } + async function driveFn() { + try { + let driver = await UiDriver.create() + console.info(`case come in driveFn 222`) + console.info(`driver is ${JSON.stringify(driver)}`) + await sleep(100); + console.info(`UiDriver start`); + let button = await driver.findComponent(BY.text('允许')); + console.info(`button is ${JSON.stringify(button)}`); + await sleep(100); + await button.click(); + } catch (err) { + console.info('err is ' + err); + return; + } + } - async function getPermission() { - let permissions = ['ohos.permission.MICROPHONE']; - featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { - console.info("request success" + JSON.stringify(data)); + beforeAll(async function () { + await getPermission(); + await driveFn(); + audioStreamManager = audioManager.getStreamManager(); + audioStreamManagerCB = audioManager.getStreamManager(); + console.info('TestLog: Start Testing AudioFrameworkTest Interfaces'); }) - } - async function driveFn() { - console.info(`come in driveFn`); - let driver = await UiDriver.create(); - console.info(`driver is ${JSON.stringify(driver)}`); - await sleep(100); - console.info(`UiDriver start`); - let button = await driver.findComponent(BY.text('允许')); - console.info(`button is ${JSON.stringify(button)}`); - await sleep(100); - await button.click(); - } - - beforeAll(async function () { - await getPermission(); - await driveFn(); - audioStreamManager = audioManager.getStreamManager(); - audioStreamManagerCB = audioManager.getStreamManager(); - console.info('TestLog: Start Testing AudioFrameworkTest Interfaces'); - }) - - beforeEach(async function () { - console.info(`${Tag}: beforeEach: Prerequisites at the test case level`); - await sleep(1000); - }) - afterEach(function () { - console.info(`${Tag}: afterEach: Test case-level clearance conditions`); - }) - - afterAll(async function () { - await sleep(1000); - console.info(`${Tag}: afterAll: Test suite-level cleanup condition`); - }) - - function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0100 - *@tc.name : AudioCapturerChange - ON_STATE_PREPARED - *@tc.desc : AudioCapturerChange - ON_STATE_PREPARED - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 1 - */ - it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0100', 1, async function (done) { - let audioCap; - 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 - } + beforeEach(async function () { + console.info(`${Tag}: beforeEach: Prerequisites at the test case level`); + await sleep(1000); + }) - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + afterEach(function () { + console.info(`${Tag}: afterEach: Test case-level clearance conditions`); + }) - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + afterAll(async function () { + await sleep(1000); + console.info(`${Tag}: afterAll: Test suite-level cleanup condition`); + }) - audioStreamManager.on('audioCapturerChange', async (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag} : ## CapChange on is called for element ${i} ##`); - console.info(`${Tag} : StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`); - console.info(`${Tag} : ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`); - console.info(`${Tag} : Content for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`); - console.info(`${Tag} : Stream for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`); - console.info(`${Tag} : Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`);; - let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag} : Id: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`); - console.info(`${Tag} : Type: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`); - console.info(`${Tag} : Role: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); - console.info(`${Tag} : Name: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`); - console.info(`${Tag} : Addr: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`); - console.info(`${Tag} : SR: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); - console.info(`${Tag} : C: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); - console.info(`${Tag} : CM: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); - } - if (devDescriptor != null) { - audioStreamManager.off('audioCapturerChange'); - await audioCap.release(); - expect(true).assertTrue(); - done(); - } + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0100 + *@tc.name : AudioCapturerChange - ON_STATE_PREPARED + *@tc.desc : AudioCapturerChange - ON_STATE_PREPARED + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0100', 1, async function (done) { + let audioCap; + 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 } - }); - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - } catch (err) { - console.log('err :' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0200 - *@tc.name : AudioCapturerChange - ON_STATE_RUNNING - *@tc.desc : AudioCapturerChange - ON_STATE_RUNNING - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0200', 2, async function (done) { - - 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 resultFlag = false; - - let audioCap; + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - }); + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } - audioStreamManagerCB.on('audioCapturerChange', async (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } - if (devDescriptor != null) { - resultFlag = true; - console.info(`${Tag}: [CAPTURER-CHANGE-ON-002] ResultFlag for element ${i} is: ${resultFlag}`); - audioStreamManagerCB.off('audioCapturerChange'); - console.info(`${Tag}: [CAPTURER-CHANGE-ON-002] ######### CapturerChange Off is called #########`); - - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); + audioStreamManager.on('audioCapturerChange', async (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag} : ## CapChange on is called for element ${i} ##`); + console.info(`${Tag} : StreamId for ${i} is: ${AudioCapturerChangeInfoArray[i].streamId}`); + console.info(`${Tag} : ClientUid for ${i} is: ${AudioCapturerChangeInfoArray[i].clientUid}`); + console.info(`${Tag} : Content for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.source}`); + console.info(`${Tag} : Stream for ${i} is: ${AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags}`); + console.info(`${Tag} : Flag ${i} is: ${AudioCapturerChangeInfoArray[i].capturerState}`);; + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag} : Id: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id}`); + console.info(`${Tag} : Type: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType}`); + console.info(`${Tag} : Role: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole}`); + console.info(`${Tag} : Name: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].name}`); + console.info(`${Tag} : Addr: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].address}`); + console.info(`${Tag} : SR: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]}`); + console.info(`${Tag} : C: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]}`); + console.info(`${Tag} : CM: ${i} ${AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks}`); + } + if (devDescriptor != null) { + audioStreamManager.off('audioCapturerChange'); + await audioCap.release(); + expect(true).assertTrue(); done(); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - }); + } } + }); + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); } - }); - - await audioCap.start().then(() => { - console.info(`${Tag}: Capturer started :Success `); - }).catch((err) => { - console.info(`${Tag}: Capturer start :ERROR :${err.message}`); - }); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0300 - *@tc.name : AudioCapturerChange - ON_STATE_STOPPED - *@tc.desc : AudioCapturerChange - ON_STATE_STOPPED - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0300', 2, async function (done) { - - 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 - } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0200 + *@tc.name : AudioCapturerChange - ON_STATE_RUNNING + *@tc.desc : AudioCapturerChange - ON_STATE_RUNNING + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0200', 2, async function (done) { + + 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 AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - let resultFlag = false; + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } - let audioCap; + let resultFlag = false; - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - }); + let audioCap; - await audioCap.start().then(() => { - console.info(`${Tag}: Capturer started :Success `); - }).catch((err) => { - console.info(`${Tag}: Capturer start :ERROR :${err.message}`); - }); + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + }); - await sleep(100); + audioStreamManagerCB.on('audioCapturerChange', async (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + if (devDescriptor != null) { + resultFlag = true; + console.info(`${Tag}: [CAPTURER-CHANGE-ON-002] ResultFlag for element ${i} is: ${resultFlag}`); + audioStreamManagerCB.off('audioCapturerChange'); + console.info(`${Tag}: [CAPTURER-CHANGE-ON-002] ######### CapturerChange Off is called #########`); - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } - if (devDescriptor != null) { - resultFlag = true; - console.info(`${Tag}: [CAPTURER-CHANGE-ON-003] ResultFlag for element ${i} is: ${resultFlag}`); + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + done(); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + }); + } } - } - }); + }); - await sleep(100); - - await audioCap.stop().then(() => { - console.info(`${Tag}: Capturer stopped : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer stop:ERROR :${err.message}`); - }); + await audioCap.start().then(() => { + console.info(`${Tag}: Capturer started :Success `); + }).catch((err) => { + console.info(`${Tag}: Capturer start :ERROR :${err.message}`); + }); + }) - await sleep(100); + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0300 + *@tc.name : AudioCapturerChange - ON_STATE_STOPPED + *@tc.desc : AudioCapturerChange - ON_STATE_STOPPED + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0300', 2, async function (done) { + + 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 + } - audioStreamManager.off('audioCapturerChange'); - await sleep(100); - console.info(`${Tag}: [CAPTURER-CHANGE-ON-003] ######### CapturerChange Off is called #########`); + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - }); + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } - expect(resultFlag).assertTrue(); - done(); + let resultFlag = false; - }) + let audioCap; - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0400 - *@tc.name : AudioCapturerChange - ON_STATE_RELEASED - *@tc.desc : AudioCapturerChange - ON_STATE_RELEASED - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0400', 2, async function (done) { - 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 - } + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + }); - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + await audioCap.start().then(() => { + console.info(`${Tag}: Capturer started :Success `); + }).catch((err) => { + console.info(`${Tag}: Capturer start :ERROR :${err.message}`); + }); - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + await sleep(100); - let resultFlag = false; - - let audioCap; - - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - }); - - await audioCap.start().then(() => { - console.info(`${Tag}: Capturer started :Success `); - }).catch((err) => { - console.info(`${Tag}: Capturer start :ERROR :${err.message}`); - }); - - await audioCap.stop().then(() => { - console.info(`${Tag}: Capturer stopped : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer stop:ERROR :${err.message}`); - }); - - await sleep(100); - - audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } - if (devDescriptor != null) { - resultFlag = true; - console.info(`${Tag}: [CAPTURER-CHANGE-ON-004] ResultFlag for element ${i} is: ${resultFlag}`); + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + if (devDescriptor != null) { + resultFlag = true; + console.info(`${Tag}: [CAPTURER-CHANGE-ON-003] ResultFlag for element ${i} is: ${resultFlag}`); + } } - } - }); - await sleep(100); + }); - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - }); - - await sleep(100); - - audioStreamManagerCB.off('audioCapturerChange'); - await sleep(100); - console.info(`${Tag}: [CAPTURER-CHANGE-ON-004] ######### CapturerChange Off is called #########`); - - expect(resultFlag).assertTrue(); - done(); - - }) + await sleep(100); - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0500 - *@tc.name : AudioCapturerChange - ON_SOURCE_TYPE_MIC - *@tc.desc : AudioCapturerChange - ON_SOURCE_TYPE_MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0500', 0, async function (done) { - 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 - } + await audioCap.stop().then(() => { + console.info(`${Tag}: Capturer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer stop:ERROR :${err.message}`); + }); - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + await sleep(100); - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + audioStreamManager.off('audioCapturerChange'); + await sleep(100); + console.info(`${Tag}: [CAPTURER-CHANGE-ON-003] ######### CapturerChange Off is called #########`); - let audioCap; + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + }); - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } - if (AudioCapturerChangeInfoArray[i].capturerInfo.source == 0 && devDescriptor != null) { - audioStreamManager.off('audioCapturerChange'); - expect(true).assertTrue(); - done(); - } - } - }); - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCap.release(); - } catch (err) { - console.log('err :' + JSON.stringify(err)); - expect(false).assertTrue(); + expect(resultFlag).assertTrue(); done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0600 - *@tc.name : AudioCapturerChange - ON_SOURCE_TYPE_VOICE_COMMUNICATION - *@tc.desc : AudioCapturerChange - ON_SOURCE_TYPE_VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0600', 0, async function (done) { - 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_VOICE_COMMUNICATION, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + }) - let resultFlag = false; + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0400 + *@tc.name : AudioCapturerChange - ON_STATE_RELEASED + *@tc.desc : AudioCapturerChange - ON_STATE_RELEASED + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0400', 2, async function (done) { + 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 audioCap; + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } - if (AudioCapturerChangeInfoArray[i].capturerInfo.source == 7 && devDescriptor != null) { - resultFlag = true; - console.info(`${Tag}: [CAPTURER-CHANGE-ON-006] ResultFlag for element ${i} is: ${resultFlag}`); - } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo } - }); - await sleep(100); - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - }); + let resultFlag = false; - await sleep(100); + let audioCap; - audioStreamManagerCB.off('audioCapturerChange'); - await sleep(100); - console.info(`${Tag}: [CAPTURER-CHANGE-ON-006] ######### CapturerChange Off is called #########`); + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + }); + await audioCap.start().then(() => { + console.info(`${Tag}: Capturer started :Success `); + }).catch((err) => { + console.info(`${Tag}: Capturer start :ERROR :${err.message}`); + }); - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - }); + await audioCap.stop().then(() => { + console.info(`${Tag}: Capturer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer stop:ERROR :${err.message}`); + }); - expect(resultFlag).assertTrue(); - done(); + await sleep(100); - }) + audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + if (devDescriptor != null) { + resultFlag = true; + console.info(`${Tag}: [CAPTURER-CHANGE-ON-004] ResultFlag for element ${i} is: ${resultFlag}`); + } + } + }); + await sleep(100); - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0700 - *@tc.name : AudioCapturerChange - STREAMID - *@tc.desc : AudioCapturerChange - STREAMID - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0700', 0, async function (done) { - let audioCap; - 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 - } + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + }); - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + await sleep(100); - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } - if (AudioCapturerChangeInfoArray[i].streamId != undefined && devDescriptor != null) { - audioStreamManager.off('audioCapturerChange'); - expect(true).assertTrue(); - done(); - } - } - }); - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCap.release(); - } catch (err) { - console.log('err :' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - } - }) + audioStreamManagerCB.off('audioCapturerChange'); + await sleep(100); + console.info(`${Tag}: [CAPTURER-CHANGE-ON-004] ######### CapturerChange Off is called #########`); + expect(resultFlag).assertTrue(); + done(); - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0800 - *@tc.name : AudioCapturerChange - CLIENTUID AND CAPTURERFLAG - *@tc.desc : AudioCapturerChange - CLIENTUID AND CAPTURERFLAG - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0800', 2, async function (done) { - let audioCap; - 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 - } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0500 + *@tc.name : AudioCapturerChange - ON_SOURCE_TYPE_MIC + *@tc.desc : AudioCapturerChange - ON_SOURCE_TYPE_MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0500', 0, async function (done) { + 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 AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - let clientUid = AudioCapturerChangeInfoArray[i].clientUid; - let capFlags = AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags; - let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } - if (clientUid != undefined && capFlags == 0 && devDescriptor != null) { - audioStreamManager.off('audioCapturerChange'); - expect(true).assertTrue(); - done(); - } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 } - }); - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCap.release(); - } catch (err) { - console.log('err :' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - } - }) - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0900 - *@tc.name : AudioCapturerChange - DeviceDescriptor - *@tc.desc : AudioCapturerChange - DeviceDescriptor - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0900', 2, async function (done) { - let audioCap; - 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 AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + let audioCap; - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - let Id = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id; - let dType = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType; - let dRole = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole; - let sRate = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]; - let cCount = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]; - let cMask = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks; - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) { + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + if (AudioCapturerChangeInfoArray[i].capturerInfo.source == 0 && devDescriptor != null) { audioStreamManager.off('audioCapturerChange'); expect(true).assertTrue(); done(); } } - } - }); - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCap.release(); - } catch (err) { - console.log('err :' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - } - }) - - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0100 - *@tc.name : AudioCapturerChange - OFF_STATE_PREPARED - *@tc.desc : AudioCapturerChange - OFF_STATE_PREPARED - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 1 - */ - it('SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0100', 1, async function (done) { - - 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 audioCap; - - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } - audioStreamManager.off('audioCapturerChange'); - expect(true).assertTrue(); + }); + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCap.release(); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); done(); } - }); - - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCap.release(); - } catch (err) { - console.log('err :' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0200 - *@tc.name : AudioCapturerChange - OFF_STATE_RUNNING - *@tc.desc : AudioCapturerChange - OFF_STATE_RUNNING - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 1 - */ - it('SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0200', 1, async function (done) { - - 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 audioCap; - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCap.start(); - } catch (err) { - console.log('err :' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - } + }) - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } - audioStreamManager.off('audioCapturerChange'); - expect(true).assertTrue(); - done(); + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0600 + *@tc.name : AudioCapturerChange - ON_SOURCE_TYPE_VOICE_COMMUNICATION + *@tc.desc : AudioCapturerChange - ON_SOURCE_TYPE_VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0600', 0, async function (done) { + 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 } - }); - await sleep(100); - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - }); - }) - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0300 - *@tc.name : AudioCapturerChange - OFF_STATE_STOPPED - *@tc.desc : AudioCapturerChange - OFF_STATE_STOPPED - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0300', 2, async function (done) { - - 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_VOICE_COMMUNICATION, + capturerFlags: 0 + } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + let resultFlag = false; - let audioCap; + let audioCap; - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCap.start(); - await audioCap.stop(); - } catch (err) { - console.log('err :' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - } - - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + if (AudioCapturerChangeInfoArray[i].capturerInfo.source == 7 && devDescriptor != null) { + resultFlag = true; + console.info(`${Tag}: [CAPTURER-CHANGE-ON-006] ResultFlag for element ${i} is: ${resultFlag}`); + } } - audioStreamManager.off('audioCapturerChange'); - expect(true).assertTrue(); - done(); - } - }); - await sleep(100); + }); + await sleep(100); - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - }); - }) + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + }); - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0400 - *@tc.name : AudioCapturerChange - OFF_STATE_RELEASED - *@tc.desc : AudioCapturerChange - OFF_STATE_RELEASED - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0400', 2, async function (done) { - - 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 - } + await sleep(100); - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + audioStreamManagerCB.off('audioCapturerChange'); + await sleep(100); + console.info(`${Tag}: [CAPTURER-CHANGE-ON-006] ######### CapturerChange Off is called #########`); - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCap; + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + }); - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCap.start(); - await audioCap.stop(); - } catch (err) { - console.log('err :' + JSON.stringify(err)); - expect(false).assertTrue(); + expect(resultFlag).assertTrue(); done(); - } - - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } - audioStreamManager.off('audioCapturerChange'); - expect(true).assertTrue(); - done(); - } - }); - await sleep(100); - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - }); - }) + }) - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0500 - *@tc.name : AudioCapturerChange - DeviceDescriptor - *@tc.desc : AudioCapturerChange - DeviceDescriptor - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0500', 2, async function (done) { - - 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 - } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0700 + *@tc.name : AudioCapturerChange - STREAMID + *@tc.desc : AudioCapturerChange - STREAMID + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0700', 0, async function (done) { + let audioCap; + 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 AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCap; - - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - let Id = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id; - let dType = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType; - let dRole = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole; - let sRate = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]; - let cCount = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]; - let cMask = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks; - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) { + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + if (AudioCapturerChangeInfoArray[i].streamId != undefined && devDescriptor != null) { audioStreamManager.off('audioCapturerChange'); expect(true).assertTrue(); done(); } } + }); + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCap.release(); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); } - }); - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCap.release(); - } catch (err) { - console.log('err :' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0100 - *@tc.name : AudioCapturerChange - GET_STATE_PREPARED - *@tc.desc : AudioCapturerChange - GET_STATE_PREPARED - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0100', 2, async function (done) { - let audioCap; - 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 - } - audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0800 + *@tc.name : AudioCapturerChange - CLIENTUID AND CAPTURERFLAG + *@tc.desc : AudioCapturerChange - CLIENTUID AND CAPTURERFLAG + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0800', 2, async function (done) { + let audioCap; + 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 } - }); - await sleep(100); - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - expect(false).assertTrue(); - done(); - }); - - await sleep(100); + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - await audioStreamManagerCB.getCurrentAudioCapturerInfoArray().then(function (AudioCapturerChangeInfoArray) { - console.info(`AFCapturerChangeLog: [GET_CAP_STA_1_PR] **** Get Promise Called ****`); - if (AudioCapturerChangeInfoArray != null) { + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + let clientUid = AudioCapturerChangeInfoArray[i].clientUid; + let capFlags = AudioCapturerChangeInfoArray[i].capturerInfo.capturerFlags; let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); } - if (devDescriptor != null) { - audioStreamManagerCB.off('audioCapturerChange'); - console.info(`audioCapturerChange off Success `); + if (clientUid != undefined && capFlags == 0 && devDescriptor != null) { + audioStreamManager.off('audioCapturerChange'); expect(true).assertTrue(); done(); } } + }); + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCap.release(); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); } - }).catch((err) => { - console.info('err : ' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - }); - - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - expect(false).assertTrue(); - done(); - }); - }) + }) - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0200 - *@tc.name : AudioCapturerChange - GET_STATE_RUNNING - *@tc.desc : AudioCapturerChange - GET_STATE_RUNNING - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0200', 2, async function (done) { - - 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 - } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0900 + *@tc.name : AudioCapturerChange - DeviceDescriptor + *@tc.desc : AudioCapturerChange - DeviceDescriptor + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ON_CAPTURER_CHANGE_0900', 2, async function (done) { + let audioCap; + 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 AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCap; - - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - }); - - await sleep(100); - - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + let Id = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id; + let dType = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType; + let dRole = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole; + let sRate = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]; + let cCount = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]; + let cMask = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks; + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) { + audioStreamManager.off('audioCapturerChange'); + expect(true).assertTrue(); + done(); + } + } } + }); + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCap.release(); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); } - }); + }) - await sleep(100); - await audioCap.start().then(() => { - console.info(`${Tag}: Capturer started :Success `); - }).catch((err) => { - console.info(`${Tag}: Capturer start :ERROR :${err.message}`); - expect(false).assertTrue(); - done(); - }); - await sleep(100); + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0100 + *@tc.name : AudioCapturerChange - OFF_STATE_PREPARED + *@tc.desc : AudioCapturerChange - OFF_STATE_PREPARED + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0100', 1, async function (done) { + + 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 + } - await audioStreamManager.getCurrentAudioCapturerInfoArray().then(function (AudioCapturerChangeInfoArray) { - console.info(`${Tag}: [GET_CAPTURER_STATE_2_PROMISE] **** Get Promise Called ****`); - if (AudioCapturerChangeInfoArray != null) { + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap; + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); } - if (devDescriptor != null) { - audioStreamManager.off('audioCapturerChange'); - expect(true).assertTrue(); - done(); - } + audioStreamManager.off('audioCapturerChange'); + expect(true).assertTrue(); + done(); } + }); + + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCap.release(); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); } - }).catch((err) => { - console.info('err : ' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - }); + }) - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - expect(false).assertTrue(); - done(); - }); - }) + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0200 + *@tc.name : AudioCapturerChange - OFF_STATE_RUNNING + *@tc.desc : AudioCapturerChange - OFF_STATE_RUNNING + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0200', 1, async function (done) { + + 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 + } - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0300 - *@tc.name : AudioCapturerChange - GET_STATE_STOPPED - *@tc.desc : AudioCapturerChange - GET_STATE_STOPPED - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0300', 2, async function (done) { - - 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 AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + let audioCap; + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCap.start(); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + } - let audioCap; - - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - }); - - await audioCap.start().then(() => { - console.info(`${Tag}: Capturer started :Success `); - }).catch((err) => { - console.info(`${Tag}: Capturer start :ERROR :${err.message}`); - }); - - await sleep(100); - - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + audioStreamManager.off('audioCapturerChange'); + expect(true).assertTrue(); + done(); } + }); + await sleep(100); + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0300 + *@tc.name : AudioCapturerChange - OFF_STATE_STOPPED + *@tc.desc : AudioCapturerChange - OFF_STATE_STOPPED + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0300', 2, async function (done) { + + 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 } - }); - await sleep(100); + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } - await audioCap.stop().then(() => { - console.info(`${Tag}: Capturer stopped : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer stop:ERROR :${err.message}`); - }); + let audioCap; - await sleep(100); + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCap.start(); + await audioCap.stop(); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + } - await audioStreamManager.getCurrentAudioCapturerInfoArray().then(function (AudioCapturerChangeInfoArray) { - console.info(`${Tag}: [GET_CAPTURER_STATE_3_PROMISE] **** Get Promise Called ****`); - if (AudioCapturerChangeInfoArray != null) { + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); } - if (devDescriptor != null) { - audioStreamManager.off('audioCapturerChange'); - expect(true).assertTrue(); - done(); - } + audioStreamManager.off('audioCapturerChange'); + expect(true).assertTrue(); + done(); } + }); + await sleep(100); + + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0400 + *@tc.name : AudioCapturerChange - OFF_STATE_RELEASED + *@tc.desc : AudioCapturerChange - OFF_STATE_RELEASED + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0400', 2, async function (done) { + + 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 } - }).catch((err) => { - console.info('err : ' + JSON.stringify(err)); - expect(false).assertTrue(); - done(); - }); - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - expect(false).assertTrue(); - done(); - }); - }) + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0400 - *@tc.name : AudioCapturerChange - DEVICE DESCRIPTOR - *@tc.desc : AudioCapturerChange - DEVICE DESCRIPTOR - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0400', 2, async function (done) { - let audioCap; - 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 AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + let audioCap; - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCap.start(); + await audioCap.stop(); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + } + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + audioStreamManager.off('audioCapturerChange'); + expect(true).assertTrue(); + done(); + } + }); + await sleep(100); + + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + }); + }) - let resultFlag = false; - audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0500 + *@tc.name : AudioCapturerChange - DeviceDescriptor + *@tc.desc : AudioCapturerChange - DeviceDescriptor + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_OFF_CAPTURER_CHANGE_0500', 2, async function (done) { + + 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 } - }); - await sleep(100); - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - }); + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - await sleep(100); + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCap; - await audioStreamManagerCB.getCurrentAudioCapturerInfoArray().then(function (AudioCapturerChangeInfoArray) { - console.info(`AFCapturerChangeLog: [GET_CAP_DD_PR] **** Get Promise Called ****`); - if (AudioCapturerChangeInfoArray != null) { + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { let Id = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id; let dType = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType; @@ -1261,84 +924,72 @@ describe('audioCapturerChange', function () { let cMask = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks; console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) { - audioStreamManagerCB.off('audioCapturerChange'); + audioStreamManager.off('audioCapturerChange'); expect(true).assertTrue(); done(); } } } + }); + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCap.release(); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); } - }).catch((err) => { - console.log(`${Tag}: getCurrentAudioCapturerInfoArray :ERROR:${err.message}`); - resultFlag = false; - }); - - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - }); - - expect(resultFlag).assertTrue(); - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0100 - *@tc.name : AudioCapturerChange - GET_STATE_PREPARED - *@tc.desc : AudioCapturerChange - GET_STATE_PREPARED - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0100', 2, async function (done) { - let audioCap; - 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 - } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0100 + *@tc.name : AudioCapturerChange - GET_STATE_PREPARED + *@tc.desc : AudioCapturerChange - GET_STATE_PREPARED + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0100', 2, async function (done) { + let audioCap; + 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 resultFlag = false; - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 } - }); - await sleep(100); - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - }); + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + } + }); + await sleep(100); - await sleep(100); + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + expect(false).assertTrue(); + done(); + }); - audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { - console.info(`${Tag}: [GET_CAPTURER_STATE_1_CALLBACK] **** Get Callback Called ****`); await sleep(100); - if (err) { - console.log(`${Tag}: getCurrentAudioCapturerInfoArray :ERROR:${err.message}`); - resultFlag = false; - } - else { + + await audioStreamManagerCB.getCurrentAudioCapturerInfoArray().then(function (AudioCapturerChangeInfoArray) { + console.info(`AFCapturerChangeLog: [GET_CAP_STA_1_PR] **** Get Promise Called ****`); if (AudioCapturerChangeInfoArray != null) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); @@ -1347,89 +998,88 @@ describe('audioCapturerChange', function () { console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); } if (devDescriptor != null) { - audioStreamManager.off('audioCapturerChange'); - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - done(); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - expect(false).assertTrue(); - done(); - }); + audioStreamManagerCB.off('audioCapturerChange'); + console.info(`audioCapturerChange off Success `); + expect(true).assertTrue(); + done(); } } } - } - }); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0200 - *@tc.name : AudioCapturerChange - GET_STATE_RUNNING - *@tc.desc : AudioCapturerChange - GET_STATE_RUNNING - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0200', 2, async function (done) { - - 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 - } + }).catch((err) => { + console.info('err : ' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + }); - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + expect(false).assertTrue(); + done(); + }); + }) - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0200 + *@tc.name : AudioCapturerChange - GET_STATE_RUNNING + *@tc.desc : AudioCapturerChange - GET_STATE_RUNNING + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0200', 2, async function (done) { + + 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 resultFlag = false; + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - let audioCap; + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCap; - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - }); + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + }); - await sleep(100); + await sleep(100); - audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } } - } - }); - - await sleep(100); - await audioCap.start().then(() => { - console.info(`${Tag}: Capturer started :Success `); - }).catch((err) => { - console.info(`${Tag}: Capturer start :ERROR :${err.message}`); - }); + }); - await sleep(100); + await sleep(100); + await audioCap.start().then(() => { + console.info(`${Tag}: Capturer started :Success `); + }).catch((err) => { + console.info(`${Tag}: Capturer start :ERROR :${err.message}`); + expect(false).assertTrue(); + done(); + }); - audioStreamManagerCB.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { - console.info(`${Tag}: [GET_CAPTURER_STATE_2_CALLBACK] **** Get Callback Called ****`); await sleep(100); - if (err) { - console.log(`${Tag}: getCurrentAudioCapturerInfoArray :ERROR:${err.message}`); - resultFlag = false; - } - else { + + await audioStreamManager.getCurrentAudioCapturerInfoArray().then(function (AudioCapturerChangeInfoArray) { + console.info(`${Tag}: [GET_CAPTURER_STATE_2_PROMISE] **** Get Promise Called ****`); if (AudioCapturerChangeInfoArray != null) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); @@ -1438,96 +1088,93 @@ describe('audioCapturerChange', function () { console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); } if (devDescriptor != null) { - audioStreamManagerCB.off('audioCapturerChange'); - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - done(); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - expect(false).assertTrue(); - done(); - }); + audioStreamManager.off('audioCapturerChange'); + expect(true).assertTrue(); + done(); } } } - } - }); - }) + }).catch((err) => { + console.info('err : ' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + }); - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0300 - *@tc.name : AudioCapturerChange - GET_STATE_STOPPED - *@tc.desc : AudioCapturerChange - GET_STATE_STOPPED - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0300', 2, async function (done) { - - 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 - } + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + expect(false).assertTrue(); + done(); + }); + }) - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0300 + *@tc.name : AudioCapturerChange - GET_STATE_STOPPED + *@tc.desc : AudioCapturerChange - GET_STATE_STOPPED + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0300', 2, async function (done) { + + 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 AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - let resultFlag = false; + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } - let audioCap; + let audioCap; - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - }); + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + }); - await audioCap.start().then(() => { - console.info(`${Tag}: Capturer started :Success `); - }).catch((err) => { - console.info(`${Tag}: Capturer start :ERROR :${err.message}`); - }); + await audioCap.start().then(() => { + console.info(`${Tag}: Capturer started :Success `); + }).catch((err) => { + console.info(`${Tag}: Capturer start :ERROR :${err.message}`); + }); - await sleep(100); + await sleep(100); - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } } - } - }); + }); - await sleep(100); - - await audioCap.stop().then(() => { - console.info(`${Tag}: Capturer stopped : SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: Capturer stop:ERROR :${err.message}`); - }); + await sleep(100); - await sleep(100); + await audioCap.stop().then(() => { + console.info(`${Tag}: Capturer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer stop:ERROR :${err.message}`); + }); - audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { - console.info(`${Tag}: [GET_CAPTURER_STATE_3_CALLBACK] **** Get Callback Called ****`); await sleep(100); - if (err) { - console.log(`${Tag}: getCurrentAudioCapturerInfoArray :ERROR:${err.message}`); - resultFlag = false; - } - else { + + await audioStreamManager.getCurrentAudioCapturerInfoArray().then(function (AudioCapturerChangeInfoArray) { + console.info(`${Tag}: [GET_CAPTURER_STATE_3_PROMISE] **** Get Promise Called ****`); if (AudioCapturerChangeInfoArray != null) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); @@ -1537,78 +1184,76 @@ describe('audioCapturerChange', function () { } if (devDescriptor != null) { audioStreamManager.off('audioCapturerChange'); - await audioCap.release().then(function () { - console.info(`${Tag}: Capturer release : SUCCESS`); - done(); - }).catch((err) => { - console.info(`${Tag}: Capturer release :ERROR :${err.message}`); - expect(false).assertTrue(); - done(); - }); + expect(true).assertTrue(); + done(); } } } - } - }); - }) + }).catch((err) => { + console.info('err : ' + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + }); - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0400 - *@tc.name : AudioCapturerChange - DEVICE DESCRIPTOR - *@tc.desc : AudioCapturerChange - DEVICE DESCRIPTOR - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0400', 2, async function (done) { - let audioCap; - 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 - } + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + expect(false).assertTrue(); + done(); + }); + }) - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0400 + *@tc.name : AudioCapturerChange - DEVICE DESCRIPTOR + *@tc.desc : AudioCapturerChange - DEVICE DESCRIPTOR + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_PROMISE_0400', 2, async function (done) { + let audioCap; + 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 AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } - audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { - for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { - console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); - for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { - console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); - } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo } - }); - await sleep(100); - await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { - audioCap = data; - console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); - }).catch((err) => { - console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); - expect(false).assertTrue(); - done(); - }); + let resultFlag = false; + audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + } + }); + await sleep(100); - await sleep(100); + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + }); - audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { - console.info(`${Tag}: [GET_CAPTURER_DD_CALLBACK] **** Get Callback Called ****`); await sleep(100); - if (err) { - console.log(`${Tag}: getCurrentAudioCapturerInfoArray :ERROR:${err.message}`); - resultFlag = false; - } - else { + + await audioStreamManagerCB.getCurrentAudioCapturerInfoArray().then(function (AudioCapturerChangeInfoArray) { + console.info(`AFCapturerChangeLog: [GET_CAP_DD_PR] **** Get Promise Called ****`); if (AudioCapturerChangeInfoArray != null) { for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); @@ -1621,6 +1266,92 @@ describe('audioCapturerChange', function () { let cMask = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks; console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) { + audioStreamManagerCB.off('audioCapturerChange'); + expect(true).assertTrue(); + done(); + } + } + } + } + }).catch((err) => { + console.log(`${Tag}: getCurrentAudioCapturerInfoArray :ERROR:${err.message}`); + resultFlag = false; + }); + + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0100 + *@tc.name : AudioCapturerChange - GET_STATE_PREPARED + *@tc.desc : AudioCapturerChange - GET_STATE_PREPARED + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0100', 2, async function (done) { + let audioCap; + 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 resultFlag = false; + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + } + }); + await sleep(100); + + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + }); + + await sleep(100); + + audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { + console.info(`${Tag}: [GET_CAPTURER_STATE_1_CALLBACK] **** Get Callback Called ****`); + await sleep(100); + if (err) { + console.log(`${Tag}: getCurrentAudioCapturerInfoArray :ERROR:${err.message}`); + resultFlag = false; + } + else { + if (AudioCapturerChangeInfoArray != null) { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + if (devDescriptor != null) { audioStreamManager.off('audioCapturerChange'); await audioCap.release().then(function () { console.info(`${Tag}: Capturer release : SUCCESS`); @@ -1634,9 +1365,283 @@ describe('audioCapturerChange', function () { } } } + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0200 + *@tc.name : AudioCapturerChange - GET_STATE_RUNNING + *@tc.desc : AudioCapturerChange - GET_STATE_RUNNING + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0200', 2, async function (done) { + + 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 resultFlag = false; + + let audioCap; + + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + }); + + await sleep(100); + + audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + } + }); + + await sleep(100); + await audioCap.start().then(() => { + console.info(`${Tag}: Capturer started :Success `); + }).catch((err) => { + console.info(`${Tag}: Capturer start :ERROR :${err.message}`); + }); + + await sleep(100); + + audioStreamManagerCB.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { + console.info(`${Tag}: [GET_CAPTURER_STATE_2_CALLBACK] **** Get Callback Called ****`); + await sleep(100); + if (err) { + console.log(`${Tag}: getCurrentAudioCapturerInfoArray :ERROR:${err.message}`); + resultFlag = false; + } + else { + if (AudioCapturerChangeInfoArray != null) { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + if (devDescriptor != null) { + audioStreamManagerCB.off('audioCapturerChange'); + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + done(); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + expect(false).assertTrue(); + done(); + }); + } + } + } + } + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0300 + *@tc.name : AudioCapturerChange - GET_STATE_STOPPED + *@tc.desc : AudioCapturerChange - GET_STATE_STOPPED + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0300', 2, async function (done) { + + 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 resultFlag = false; + + let audioCap; + + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + }); + + await audioCap.start().then(() => { + console.info(`${Tag}: Capturer started :Success `); + }).catch((err) => { + console.info(`${Tag}: Capturer start :ERROR :${err.message}`); + }); + + await sleep(100); + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + } + }); + + await sleep(100); + + await audioCap.stop().then(() => { + console.info(`${Tag}: Capturer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Capturer stop:ERROR :${err.message}`); + }); + + await sleep(100); + + audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { + console.info(`${Tag}: [GET_CAPTURER_STATE_3_CALLBACK] **** Get Callback Called ****`); + await sleep(100); + if (err) { + console.log(`${Tag}: getCurrentAudioCapturerInfoArray :ERROR:${err.message}`); + resultFlag = false; + } + else { + if (AudioCapturerChangeInfoArray != null) { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + let devDescriptor = AudioCapturerChangeInfoArray[i].deviceDescriptors; + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + if (devDescriptor != null) { + audioStreamManager.off('audioCapturerChange'); + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + done(); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + expect(false).assertTrue(); + done(); + }); + } + } + } + } + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0400 + *@tc.name : AudioCapturerChange - DEVICE DESCRIPTOR + *@tc.desc : AudioCapturerChange - DEVICE DESCRIPTOR + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_0400', 2, async function (done) { + let audioCap; + 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 + } + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: CapChange on is called for element ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + } + } + }); + await sleep(100); + + await audio.createAudioCapturer(AudioCapturerOptions).then((data) => { + audioCap = data; + console.info(`${Tag}: AudioCapturer Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioCapturer Created : ERROR :${err.message}`); + expect(false).assertTrue(); + done(); + }); + + await sleep(100); + + audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { + console.info(`${Tag}: [GET_CAPTURER_DD_CALLBACK] **** Get Callback Called ****`); + await sleep(100); + if (err) { + console.log(`${Tag}: getCurrentAudioCapturerInfoArray :ERROR:${err.message}`); + resultFlag = false; + } + else { + if (AudioCapturerChangeInfoArray != null) { + for (let i = 0; i < AudioCapturerChangeInfoArray.length; i++) { + console.info(`${Tag}: ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i])}`); + for (let j = 0; j < AudioCapturerChangeInfoArray[i].deviceDescriptors.length; j++) { + let Id = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].id; + let dType = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceType; + let dRole = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].deviceRole; + let sRate = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].sampleRates[0]; + let cCount = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelCounts[0]; + let cMask = AudioCapturerChangeInfoArray[i].deviceDescriptors[j].channelMasks; + console.info(`${Tag}:deviceDescriptors ${i} : ${JSON.stringify(AudioCapturerChangeInfoArray[i].deviceDescriptors[j])}`); + if (Id > 0 && dType == 15 && dRole == 1 && sRate != null && cCount != null && cMask != null) { + audioStreamManager.off('audioCapturerChange'); + await audioCap.release().then(function () { + console.info(`${Tag}: Capturer release : SUCCESS`); + done(); + }).catch((err) => { + console.info(`${Tag}: Capturer release :ERROR :${err.message}`); + expect(false).assertTrue(); + 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 3480aeeda43b078e35c6776d7af5345c68fbb9bf..fb47ef34c0e226055e8e0e6422a369ddf695540b 100644 --- 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 @@ -105,15 +105,20 @@ describe('audioFramework', function () { }) } async function driveFn() { - console.info(`come in driveFn`); - let driver = await UiDriver.create(); - console.info(`driver is ${JSON.stringify(driver)}`); - await sleep(100); - console.info(`UiDriver start`); - let button = await driver.findComponent(BY.text('允许')); - console.info(`button is ${JSON.stringify(button)}`); - await sleep(100); - await button.click(); + try { + let driver = await UiDriver.create() + console.info(`case come in driveFn 222`) + console.info(`driver is ${JSON.stringify(driver)}`) + await sleep(100); + console.info(`UiDriver start`); + let button = await driver.findComponent(BY.text('允许')); + console.info(`button is ${JSON.stringify(button)}`); + await sleep(100); + await button.click(); + } catch (err) { + console.info('err is ' + err); + return; + } } beforeAll(async function () { diff --git a/multimedia/audio/audio_js_standard/audioVoip/src/main/js/test/AudioVOIP.test.js b/multimedia/audio/audio_js_standard/audioVoip/src/main/js/test/AudioVOIP.test.js index a1516b32010a017881ebd342b4d5a2d5b00b0556..6c81ba63e75412a066e1d15b5f8cbaf4b61e6b9b 100644 --- a/multimedia/audio/audio_js_standard/audioVoip/src/main/js/test/AudioVOIP.test.js +++ b/multimedia/audio/audio_js_standard/audioVoip/src/main/js/test/AudioVOIP.test.js @@ -40,15 +40,20 @@ describe('audioVoip', function () { }) } async function driveFn() { - console.info(`come in driveFn`); - let driver = await UiDriver.create(); - console.info(`driver is ${JSON.stringify(driver)}`); - await sleep(100); - console.info(`UiDriver start`); - let button = await driver.findComponent(BY.text('允许')); - console.info(`button is ${JSON.stringify(button)}`); - await sleep(100); - await button.click(); + try { + let driver = await UiDriver.create() + console.info(`case come in driveFn 222`) + console.info(`driver is ${JSON.stringify(driver)}`) + await sleep(100); + console.info(`UiDriver start`); + let button = await driver.findComponent(BY.text('允许')); + console.info(`button is ${JSON.stringify(button)}`); + await sleep(100); + await button.click(); + } catch (err) { + console.info('err is ' + err); + return; + } } beforeAll(async function () { diff --git a/multimedia/media/media_js_standard/MediaTestBase.js b/multimedia/media/media_js_standard/MediaTestBase.js index 3a343af68f656c85555a7674bed00f6f46848f50..20a4fd1056a585bc9a38b2f413b8e11effd402f4 100644 --- a/multimedia/media/media_js_standard/MediaTestBase.js +++ b/multimedia/media/media_js_standard/MediaTestBase.js @@ -14,7 +14,7 @@ */ import resourceManager from '@ohos.resourceManager'; -import {expect} from 'deccjsunit/index' +import { expect } from 'deccjsunit/index' import router from '@system.router' import mediaLibrary from '@ohos.multimedia.mediaLibrary' import fileio from '@ohos.fileio' @@ -31,18 +31,23 @@ export async function getPermission(permissionNames) { export async function driveFn(num) { console.info(`case come in driveFn 111`) - let driver = await UiDriver.create() - console.info(`case come in driveFn 222`) - console.info(`driver is ${JSON.stringify(driver)}`) - await msleepAsync(2000) - console.info(`UiDriver start`) - for (let i = 0; i < num; i++) { - let button = await driver.findComponent(BY.text('允许')) - console.info(`button is ${JSON.stringify(button)}`) + try { + let driver = await UiDriver.create() + console.info(`case come in driveFn 222`) + console.info(`driver is ${JSON.stringify(driver)}`) + await msleepAsync(2000) + console.info(`UiDriver start`) + for (let i = 0; i < num; i++) { + let button = await driver.findComponent(BY.text('允许')) + console.info(`button is ${JSON.stringify(button)}`) + await msleepAsync(2000) + await button.click() + } await msleepAsync(2000) - await button.click() + } catch (err) { + console.info('err is ' + err); + return; } - await msleepAsync(2000) } // File operation @@ -50,7 +55,7 @@ export async function getFileDescriptor(fileName) { let fileDescriptor = undefined; await resourceManager.getResourceManager().then(async (mgr) => { await mgr.getRawFileDescriptor(fileName).then(value => { - fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length}; + fileDescriptor = { fd: value.fd, offset: value.offset, length: value.length }; console.log('case getRawFileDescriptor success fileName: ' + fileName); }).catch(error => { console.log('case getRawFileDescriptor err: ' + error); @@ -61,7 +66,7 @@ export async function getFileDescriptor(fileName) { export async function closeFileDescriptor(fileName) { await resourceManager.getResourceManager().then(async (mgr) => { - await mgr.closeRawFileDescriptor(fileName).then(()=> { + await mgr.closeRawFileDescriptor(fileName).then(() => { console.log('case closeRawFileDescriptor ' + fileName); }).catch(error => { console.log('case closeRawFileDescriptor err: ' + error); @@ -98,7 +103,7 @@ export async function closeFdNumber(fdNumber) { // wait synchronously export function msleep(time) { - for(let t = Date.now();Date.now() - t <= time;); + for (let t = Date.now(); Date.now() - t <= time;); } // wait asynchronously @@ -127,21 +132,21 @@ export function catchCallback(error) { export function checkDescription(actualDescription, descriptionKey, descriptionValue) { for (let i = 0; i < descriptionKey.length; i++) { let property = actualDescription[descriptionKey[i]]; - console.info('case key is '+ descriptionKey[i]); - console.info('case actual value is '+ property); - console.info('case hope value is '+ descriptionValue[i]); + console.info('case key is ' + descriptionKey[i]); + console.info('case actual value is ' + property); + console.info('case hope value is ' + descriptionValue[i]); expect(property).assertEqual(descriptionValue[i]); } } -export function printDescription(obj) { - let description = ""; - for(let i in obj) { +export function printDescription(obj) { + let description = ""; + for (let i in obj) { let property = obj[i]; - console.info('case key is '+ i); - console.info('case value is '+ property); - description += i + " = " + property + "\n"; - } + console.info('case key is ' + i); + console.info('case value is ' + property); + description += i + " = " + property + "\n"; + } } export async function toNewPage(pagePath1, pagePath2, page) { @@ -167,8 +172,8 @@ export async function clearRouter() { export async function getFd(pathName) { let fdObject = { - fileAsset : null, - fdNumber : null + fileAsset: null, + fdNumber: null } let displayName = pathName; const mediaTest = mediaLibrary.getMediaLibrary(); @@ -179,8 +184,8 @@ export async function getFd(pathName) { if (dataUri != undefined) { let args = dataUri.id.toString(); let fetchOp = { - selections : fileKeyObj.ID + "=?", - selectionArgs : [args], + selections: fileKeyObj.ID + "=?", + selectionArgs: [args], } let fetchFileResult = await mediaTest.getFileAssets(fetchOp); fdObject.fileAsset = await fetchFileResult.getAllObject(); @@ -192,8 +197,8 @@ export async function getFd(pathName) { export async function getAudioFd(pathName) { let fdObject = { - fileAsset : null, - fdNumber : null + fileAsset: null, + fdNumber: null } let displayName = pathName; const mediaTest = mediaLibrary.getMediaLibrary(); @@ -204,8 +209,8 @@ export async function getAudioFd(pathName) { if (dataUri != undefined) { let args = dataUri.id.toString(); let fetchOp = { - selections : fileKeyObj.ID + "=?", - selectionArgs : [args], + selections: fileKeyObj.ID + "=?", + selectionArgs: [args], } let fetchFileResult = await mediaTest.getFileAssets(fetchOp); fdObject.fileAsset = await fetchFileResult.getAllObject();