From 3986307e9a9d0805d743717e65796cb29f6351a7 Mon Sep 17 00:00:00 2001 From: wangzx0705 Date: Fri, 18 Aug 2023 02:43:15 +0000 Subject: [PATCH] fix xts testcase fail, and modify some testcase code Signed-off-by: wangzx0705 --- .../src/main/ets/test/Const.ets | 5 +- .../main/ets/test/GetMax_Minvolume.test.ets | 24 ++--- .../ets/test/GetSystemVolumeInDb.test.ets | 20 ++-- .../ets/test/IsVolumeUnadjustable.test.ets | 2 +- .../src/main/ets/test/Const.ets | 4 + .../ets/test/GetCurrentOutputDevices.test.ets | 8 +- .../test/GetMaxAndMinStreamVolume.test.ets | 95 ++++++++----------- .../main/ets/test/GetUnderflowCount.test.ets | 64 ++++++------- 8 files changed, 98 insertions(+), 124 deletions(-) diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/Const.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/Const.ets index f1fe9857b..92f2c5f91 100644 --- a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/Const.ets +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/Const.ets @@ -23,4 +23,7 @@ export const OUTPUT_NUMBER_1 = 1; export const INVALID_INPUT_PARAMETER_401 = 401; export const INVALID_INPUT_PARAMETER_6800101 = 6800101; export const UNSUPORTED_OPTION_6800104 = 6800104; -export const DEAFULT_MEDIA_DB = 0.08370080590248108; \ No newline at end of file +export const DEAFULT_MEDIA_DB = 0.08370080590248108; + +//---------------AudioVolumeType: not steamapi------------------ +export const AudioVolumeType = [0, 2, 3, 4, 5, 9]; \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetMax_Minvolume.test.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetMax_Minvolume.test.ets index fe25485e9..5f59617dd 100644 --- a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetMax_Minvolume.test.ets +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetMax_Minvolume.test.ets @@ -85,13 +85,11 @@ export default function audioManagerTest() { try { let maxvol; var maxvol1 = new ArrayList(); - var maxvol2 = [15, 15, 15, 15, 15, 15, 15]; - for(let index in audio.AudioVolumeType){ - maxvol = await audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType[index]); - console.info(`${index} max volume : ${maxvol}`); - if(index != 'ALL'){ - maxvol1.add(maxvol); - } + var maxvol2 = [15, 15, 15, 15, 15, 15]; + for (let index = 0; index < env.AudioVolumeType.length; index++) { + maxvol = await audioVolumeGroupManager.getMaxVolume(env.AudioVolumeType[index]); + console.info(`${env.AudioVolumeType[index]} max volume : ${maxvol}`); + maxvol1.add(maxvol); } for(let i =0; i < maxvol1.length; i++){ console.info(`check maxvolume: maxvol1 : ${maxvol1[i]}, maxvol2 : ${maxvol2[i]}`); @@ -117,13 +115,11 @@ export default function audioManagerTest() { try { let minvol; var minvol1 = new ArrayList(); - var minvol2 = [1, 1, 0, 0, 0, 1, 1]; - for(let index in audio.AudioVolumeType){ - minvol = await audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType[index]); - console.info(`${index} min volume : ${minvol}`); - if(index != 'ALL'){ - minvol1.add(minvol); - } + var minvol2 = [1, 0, 0, 1, 1, 1]; + for (let index = 0; index < env.AudioVolumeType.length; index++) { + minvol = await audioVolumeGroupManager.getMinVolume(env.AudioVolumeType[index]); + console.info(`${env.AudioVolumeType[index]} min volume : ${minvol}`); + minvol1.add(minvol); } for(let i =0; i < minvol1.length; i++){ console.info(`check minvolume minvol1 : ${minvol1[i]}, minvol2 : ${minvol2[i]}`); diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetSystemVolumeInDb.test.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetSystemVolumeInDb.test.ets index 4baba4a7a..dd3248dde 100644 --- a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetSystemVolumeInDb.test.ets +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetSystemVolumeInDb.test.ets @@ -116,15 +116,15 @@ export default function audioManagerTest() { it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0200', 0, async function (done) { try { var db1 = new ArrayList(); - var db2 = [0.06932847946882248, 0.06932847946882248, 0.08370080590248108, 0.08370080590248108, 0.08370080590248108, 0.06932847946882248, 0.06932847946882248, 0.08370080590248108]; - for (let index in audio.AudioVolumeType) { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[index], 3, audio.DeviceType.SPEAKER) + var db2 = [0.06932847946882248, 0.08370080590248108, 0.08370080590248108, 0.06932847946882248, 0.06932847946882248, 0.06932847946882248]; + for (let index = 0; index < env.AudioVolumeType.length; index++) { + await audioVolumeGroupManager.getSystemVolumeInDb(env.AudioVolumeType[index], 3, audio.DeviceType.SPEAKER) .then((data) => { - console.info(`${index} getSystemVolumeInDb :SUCCESS ${data}`); + console.info(`${env.AudioVolumeType[index]} getSystemVolumeInDb :SUCCESS ${data}`); db1.add(data); }) .catch((error) => { - console.log(`${TagFrmwk}: ${index} getSystemVolumeInDb : error ${error}`); + console.log(`${TagFrmwk}: ${env.AudioVolumeType[index]} getSystemVolumeInDb : error ${error}`); expect(false).assertTrue(); done(); }); @@ -520,11 +520,11 @@ export default function audioManagerTest() { var db2 = new ArrayList(); var device = [audio.DeviceType.SPEAKER, audio.DeviceType.EARPIECE, audio.DeviceType.WIRED_HEADSET]; for (var deviceIndex = 0; deviceIndex < device.length; deviceIndex++) { - for (let typeIndex in audio.AudioVolumeType) { - let maxVol = await audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType[typeIndex]); - let minVol = await audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType[typeIndex]); + for (let typeIndex = 0; typeIndex < env.AudioVolumeType.length; typeIndex++) { + let maxVol = await audioVolumeGroupManager.getMaxVolume(env.AudioVolumeType[typeIndex]); + let minVol = await audioVolumeGroupManager.getMinVolume(env.AudioVolumeType[typeIndex]); for (let volIndex = minVol; volIndex <= maxVol; volIndex++) { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[typeIndex], volIndex, device[deviceIndex], (err, data) => { + await audioVolumeGroupManager.getSystemVolumeInDb(env.AudioVolumeType[typeIndex], volIndex, device[deviceIndex], (err, data) => { if (err) { console.info(`getSystemVolumeInDb : error ${err.message} ${err.code}`); expect(false).assertTrue(); @@ -533,7 +533,7 @@ export default function audioManagerTest() { db1.add(data); } }); - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[typeIndex], volIndex, device[deviceIndex], (err, data) => { + await audioVolumeGroupManager.getSystemVolumeInDb(env.AudioVolumeType[typeIndex], volIndex, device[deviceIndex], (err, data) => { if (err) { console.info(`getSystemVolumeInDb : error ${err.message} ${err.code}`); expect(false).assertTrue(); diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/IsVolumeUnadjustable.test.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/IsVolumeUnadjustable.test.ets index ae2b020ce..c89881080 100644 --- a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/IsVolumeUnadjustable.test.ets +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/IsVolumeUnadjustable.test.ets @@ -106,7 +106,7 @@ export default function audioManagerTest() { it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ISVOLUMEUNADJUSTABLE_0200', 0, async function (done) { try { let bol = await audioVolumeGroupManager.isVolumeUnadjustable(); - let vol = await audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA); + let vol = await audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA); await audioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, vol + 1); let vol1 = await audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA); expect(bol).assertEqual(false); diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/Const.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/Const.ets index 0f544db1d..167faab93 100644 --- a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/Const.ets +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/Const.ets @@ -16,8 +16,12 @@ //public invalid export const OUTPUT_NUMBER_0 = 0; export const OUTPUT_NUMBER_1 = 1; +export const OUTPUT_NUMBER_2 = 2; //-------------------------------------------------------------- export const INVALID_INPUT_PARAMETER_401 = 401; export const INVALID_INPUT_PARAMETER_6800101 = 6800101; export const UNSUPORTED_OPTION_6800104 = 6800104; + +//----------------StreamUsage: not streamapi-------------------- +export const StreamUsage = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13]; \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetCurrentOutputDevices.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetCurrentOutputDevices.test.ets index 87d30d4bc..bb5cddfb9 100644 --- a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetCurrentOutputDevices.test.ets +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetCurrentOutputDevices.test.ets @@ -140,7 +140,7 @@ export default function audioRendererTest() { console.info(`${TagFrmwkRender}: deviceRole:${data.deviceRole}, deviceType:${data.deviceType}, id:${data.id}, name:${data.name}, address:${data.address}, sampleRates:${data.sampleRates}, channelCounts:${data.channelCounts}, channelMasks:${data.channelMasks}`); expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); - expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + expect(data.id).assertEqual(env.OUTPUT_NUMBER_1); done(); }).catch((error) => { console.log("${TagFrmwkRender}: getCurrentOutputDevices error = " + error); @@ -169,7 +169,7 @@ export default function audioRendererTest() { console.info(`${TagFrmwkRender}: deviceRole:${data.deviceRole}, deviceType:${data.deviceType}, id:${data.id}, address:${data.address}, sampleRates:${data.sampleRates}, channelCounts:${data.channelCounts}, channelMasks:${data.channelMasks}`); expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); - expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + expect(data.id).assertEqual(env.OUTPUT_NUMBER_1); console.info(`${TagFrmwkRender}: Renderer get current output device SUCCESS, now stop audiorender`); audioRen.drain().then(() => { console.info(`${TagFrmwkRender}: Renderer drain : SUCCESS, stop audiorender`); @@ -210,7 +210,7 @@ export default function audioRendererTest() { console.info(`${TagFrmwkRender}: deviceRole:${data.deviceRole}, deviceType:${data.deviceType}, id:${data.id}, address:${data.address}, sampleRates:${data.sampleRates}, channelCounts:${data.channelCounts}, channelMasks:${data.channelMasks}`); expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); - expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + expect(data.id).assertEqual(env.OUTPUT_NUMBER_1); done(); } }); @@ -235,7 +235,7 @@ export default function audioRendererTest() { console.info(`${TagFrmwkRender}: getCurrentOutputDevices :deviceRole:${data.deviceRole}, deviceType:${data.deviceType}, id:${data.id}, address:${data.address}, sampleRates:${data.sampleRates}, channelCounts:${data.channelCounts}, channelMasks:${data.channelMasks}`); expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); - expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + expect(data.id).assertEqual(env.OUTPUT_NUMBER_1); console.info(`${TagFrmwkRender}: Renderer getCurrentOutputDevices SUCCESS! now stop the audiorenderer`); audioRen.drain().then(() => { console.info(`${TagFrmwkRender}: Renderer drain, stop the audiorenderer`); diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetMaxAndMinStreamVolume.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetMaxAndMinStreamVolume.test.ets index 5949abf58..169f6a010 100644 --- a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetMaxAndMinStreamVolume.test.ets +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetMaxAndMinStreamVolume.test.ets @@ -236,9 +236,8 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0300', 0, async function (done) { - let StreamType; try{ - for (StreamType in audio.StreamUsage) { + for (let index = 0; index < env.StreamUsage.length; index++) { let audioRender; let AudioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, @@ -248,7 +247,7 @@ export default function audioRendererTest() { } let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: StreamType, + usage: env.StreamUsage[index], rendererFlags: 0 } let AudioRendererOptions = { @@ -256,24 +255,20 @@ export default function audioRendererTest() { rendererInfo: AudioRendererInfo } try { - if (Number(audio.StreamUsage[StreamType]) != 9) { - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRender = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); - }); - } else { - audioRender = audioRen; - } + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${env.StreamUsage[index]} SUCCESS data state: ` + Object.keys(data)); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); + }); } catch (error) { - console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); + console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); } await audioRender.getMaxStreamVolume().then((data) => { - console.info(`${TagFrmwkRender}:getMaxStreamVolume:Stream Type: ${StreamType} SUCCESS ${data}`); + console.info(`${TagFrmwkRender}:getMaxStreamVolume:Stream Type: ${env.StreamUsage[index]} SUCCESS ${data}`); expect(data).assertEqual(env.OUTPUT_NUMBER_1); }).catch ((error)=>{ - console.info(`${TagFrmwkRender}:getMaxStreamVolume:Stream Type: ${StreamType} ERROR : code: ${error.code}, mesage: ${error.message}`); + console.info(`${TagFrmwkRender}:getMaxStreamVolume:Stream Type: ${env.StreamUsage[index]} ERROR : code: ${error.code}, mesage: ${error.message}`); expect(false).assertTrue(); done(); }); @@ -397,9 +392,8 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0300', 0, async function (done) { - let StreamType; try{ - for (StreamType in audio.StreamUsage) { + for (let index = 0; index < env.StreamUsage.length; index++) { let audioRender; let AudioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, @@ -409,7 +403,7 @@ export default function audioRendererTest() { } let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: StreamType, + usage: env.StreamUsage[index], rendererFlags: 0 } let AudioRendererOptions = { @@ -417,24 +411,20 @@ export default function audioRendererTest() { rendererInfo: AudioRendererInfo } try { - if (Number(audio.StreamUsage[StreamType]) != 9) { - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRender = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); - }); - } else { - audioRender = audioRen; - } + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${env.StreamUsage[index]} SUCCESS data state: ` + Object.keys(data)); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); + }); } catch (error) { console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); } await audioRender.getMinStreamVolume().then((data) => { - console.info(`${TagFrmwkRender}:getMinStreamVolume:Stream Type: ${StreamType} SUCCESS ${data}`); + console.info(`${TagFrmwkRender}:getMinStreamVolume:Stream Type: ${env.StreamUsage[index]} SUCCESS ${data}`); expect(data).assertEqual(env.OUTPUT_NUMBER_0); }).catch ((error)=>{ - console.info(`${TagFrmwkRender}:getMinStreamVolume:Stream Type: ${StreamType} ERROR : code: ${error.code}, mesage: ${error.message}`); + console.info(`${TagFrmwkRender}:getMinStreamVolume:Stream Type: ${env.StreamUsage[index]} ERROR : code: ${error.code}, mesage: ${error.message}`); expect(false).assertTrue(); done(); }); @@ -540,9 +530,8 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_CALLBACK_0300', 0, async function (done) { - let StreamType; try{ - for (StreamType in audio.StreamUsage) { + for (let index = 0; index < env.StreamUsage.length; index++) { let audioRender; let AudioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, @@ -552,7 +541,7 @@ export default function audioRendererTest() { } let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: StreamType, + usage: env.StreamUsage[index], rendererFlags: 0 } let AudioRendererOptions = { @@ -560,16 +549,12 @@ export default function audioRendererTest() { rendererInfo: AudioRendererInfo } try { - if (Number(audio.StreamUsage[StreamType]) != 9) { - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRender = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); - }); - } else { - audioRender = audioRen; - } + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${env.StreamUsage[index]} SUCCESS data state: ` + Object.keys(data)); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); + }); } catch (error) { console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); } @@ -687,10 +672,8 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_CALLBACK_0300', 0, async function (done) { - let StreamType; - try{ - for (StreamType in audio.StreamUsage) { + for (let index = 0; index < env.StreamUsage.length; index++) { let audioRender; let AudioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, @@ -700,7 +683,7 @@ export default function audioRendererTest() { } let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: StreamType, + usage: env.StreamUsage[index], rendererFlags: 0 } let AudioRendererOptions = { @@ -708,16 +691,12 @@ export default function audioRendererTest() { rendererInfo: AudioRendererInfo } try { - if (Number(audio.StreamUsage[StreamType]) != 9) { - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRender = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); - }); - } else { - audioRender = audioRen; - } + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${env.StreamUsage[index]} SUCCESS data state: ` + Object.keys(data)); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); + }); } catch (error) { console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); } diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetUnderflowCount.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetUnderflowCount.test.ets index bd0e579f7..be15e3716 100644 --- a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetUnderflowCount.test.ets +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetUnderflowCount.test.ets @@ -145,7 +145,7 @@ export default function audioRendererTest() { try{ await audioRen.getUnderflowCount().then((data) => { console.info(`${TagFrmwkRender}:getUnderflowCount :SUCCESS ${data}`); - expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + expect(data).assertEqual(env.OUTPUT_NUMBER_0); done(); }).catch ((error)=>{ console.log("${TagFrmwkRender}:getUnderflowCount : error = " + error); @@ -172,7 +172,8 @@ export default function audioRendererTest() { try { await renderPlay(); await audioRen.getUnderflowCount().then((data) => { - expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + console.log(`getUnderflowCount :SUCCESS ${data}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_2); audioRen.drain().then(() => { audioRen.stop().then(() => { done(); @@ -203,9 +204,8 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0300', 0, async function (done) { - let StreamType; try { - for (StreamType in audio.StreamUsage) { + for (let index = 0; index < env.StreamUsage.length; index++) { let audioRender; let AudioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, @@ -215,7 +215,7 @@ export default function audioRendererTest() { } let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: Number(audio.StreamUsage[StreamType]), + usage: env.StreamUsage[index], rendererFlags: 0 } let AudioRendererOptions = { @@ -223,22 +223,18 @@ export default function audioRendererTest() { rendererInfo: AudioRendererInfo } try { - if (Number(audio.StreamUsage[StreamType]) != 9) { - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRender = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType}: ${Number(audio.StreamUsage[StreamType])}`); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.code + err.message); - }); - } else { - audioRender = audioRen; - } + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${env.StreamUsage[index]} success`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.code + err.message); + }); } catch (error) { console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); } await audioRender.getUnderflowCount().then((data) => { - console.info(`${TagFrmwkRender}: getUnderflowCount SUCCESS! ${StreamType} data ${data}:, now release audiorender`); - expect(data).assertLargerOrEqual(0); + console.info(`${TagFrmwkRender}: getUnderflowCount SUCCESS! ${env.StreamUsage[index]} data ${data}:, now release audiorender`); + expect(data).assertEqual(env.OUTPUT_NUMBER_0); }).catch((error) => { console.info(`${TagFrmwkRender}: getUnderflowCount: ERROR : code: ${error.code}, mesage: ${error.message}`); expect(false).assertTrue(); @@ -246,7 +242,7 @@ export default function audioRendererTest() { }); sleep(1000); await audioRender.release().then(() => { - console.info(`${TagFrmwkRender}: Renderer ${StreamType} release SUCCESS! `); + console.info(`${TagFrmwkRender}: Renderer ${env.StreamUsage[index]} release SUCCESS! `); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer release ERROR: ${err.message}`); }); @@ -274,7 +270,7 @@ export default function audioRendererTest() { done(); } else { console.info(`${TagFrmwkRender}: getUnderflowCount : Success! ${data}`); - expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + expect(data).assertEqual(env.OUTPUT_NUMBER_0); done(); } }); @@ -297,7 +293,8 @@ export default function audioRendererTest() { expect(false).assertTrue(); done(); } else { - expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + console.log(`getUnderflowCount :SUCCESS ${data}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_2); audioRen.drain().then(() => { audioRen.stop().then(() => { done(); @@ -325,9 +322,8 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0300', 0, async function (done) { - let StreamType; try { - for (StreamType in audio.StreamUsage) { + for (let index = 0; index < env.StreamUsage.length; index++) { let audioRender; let AudioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, @@ -337,7 +333,7 @@ export default function audioRendererTest() { } let AudioRendererInfo = { content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: StreamType, + usage: env.StreamUsage[index], rendererFlags: 0 } let AudioRendererOptions = { @@ -345,16 +341,12 @@ export default function audioRendererTest() { rendererInfo: AudioRendererInfo } try { - if (Number(audio.StreamUsage[StreamType]) != 9) { - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRender = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); - }); - } else { - audioRender = audioRen; - } + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${env.StreamUsage[index]} SUCCESS data state: ` + Object.keys(data)); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); + }); } catch (error) { console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); } @@ -363,13 +355,13 @@ export default function audioRendererTest() { expect(false).assertTrue(); done(); } else { - console.log(`${TagFrmwkRender}:getUnderflowCount StreamType:${StreamType} execution success, data: ${JSON.stringify(data)}`); - expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + console.log(`${TagFrmwkRender}:getUnderflowCount StreamType:${env.StreamUsage[index]} execution success, data: ${JSON.stringify(data)}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_0); } }); sleep(1000); await audioRender.release().then(() => { - console.info(`${TagFrmwkRender}: Renderer ${StreamType} release : SUCCESS`); + console.info(`${TagFrmwkRender}: Renderer ${env.StreamUsage[index]} release : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); -- GitLab