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 f7b15447d475f448615e1e832e5e8359448176dd..f1fe9857be5d1ea87f9f6bad02b45b8ee87ebe91 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 @@ -22,4 +22,5 @@ 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; \ No newline at end of file +export const UNSUPORTED_OPTION_6800104 = 6800104; +export const DEAFULT_MEDIA_DB = 0.08370080590248108; \ No newline at end of file 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 24ec51e6b16e49b1ef935232adc1b1adb83c10fc..9a35457baba00d84a53723aeeac911551cfdda80 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 @@ -41,6 +41,7 @@ export default function audioManagerTest() { afterAll(function () { console.info(`${TagFrmwk}: afterAll: Test suite-level cleanup condition`); }) + function getAudioManager() { audioManager = audio.getAudioManager(); if (audioManager != null) { @@ -62,95 +63,110 @@ export default function audioManagerTest() { console.info(`${TagFrmwk}: getAudioManger : FAIL`); } } + function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } + async function getPermission() { console.info("getPermission IN\n") - let permissions = ['ohos.permission.MICROPHONE','ohos.permission.MODIFY_AUDIO_SETTINGS','ohos.permission.ACCESS_NOTIFICATION_POLICY']; + let permissions = ['ohos.permission.MICROPHONE', 'ohos.permission.MODIFY_AUDIO_SETTINGS', 'ohos.permission.ACCESS_NOTIFICATION_POLICY']; featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { console.info("request success" + JSON.stringify(data)); }) } /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0100 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0100 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0100', 0, async function (done) { try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER) + .then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); + expect(data).assertEqual(env.DEAFULT_MEDIA_DB); expect(true).assertTrue(); done(); - }).catch((error) => { - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error}`); - expect(false).assertTrue(); - done(); - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0100: error ${error.message}, code ${error.code}`); + }) + .catch((error) => { + console.log(`${TagFrmwk}: getSystemVolumeInDb : error ${error}`); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0200 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0200 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0200', 0, async function (done) { try { - for(let index in audio.AudioVolumeType){ - console.info(`####AudioVolumeType: ${index}`); - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[index], 3, audio.DeviceType.SPEAKER).then((data) => { - console.info(`####${index} adjustSystemVolumeByStep :SUCCESS ${data}`); - }).catch((error) => { - console.log(`${TagFrmwk}: ####${index} adjustSystemVolumeByStep : error ${error}`); - expect(false).assertTrue(); - done(); - }); + 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) + .then((data) => { + console.info(`${index} getSystemVolumeInDb :SUCCESS ${data}`); + db1.add(data); + }) + .catch((error) => { + console.log(`${TagFrmwk}: ${index} getSystemVolumeInDb : error ${error}`); + expect(false).assertTrue(); + done(); + }); + } + for (let i = 0; i < db1.length; i++) { + console.log(`${db1[i]}: ${db2[i]}`); + expect(Number(db1[i])).assertEqual(Number(db2[i])); } done(); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0200: error ${error.message}, code ${error.code}`); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0300 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0300 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0300', 0, async function (done) { try { let maxVol = await audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA); let minVol = await audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA); let volLevel = 0; - for(volLevel = minVol; volLevel <= maxVol; volLevel++){ - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, volLevel, audio.DeviceType.SPEAKER).then((data) => { - console.info(`#### ${volLevel} getSystemVolumeInDb :SUCCESS ${data}`); - }).catch((error) => { - console.log(`${TagFrmwk}: #### ${volLevel} getSystemVolumeInDb : error ${error}`); - expect(false).assertTrue(); - done(); - }); + for (volLevel = minVol; volLevel <= maxVol; volLevel++) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, volLevel, audio.DeviceType.SPEAKER) + .then((data) => { + console.info(` ${volLevel} getSystemVolumeInDb :SUCCESS ${data}`); + }) + .catch((error) => { + console.log(`${TagFrmwk}: ${volLevel} getSystemVolumeInDb : error ${error}`); + expect(false).assertTrue(); + done(); + }); } done(); - }catch (error){ + } catch (error) { console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0300: error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); @@ -158,828 +174,350 @@ export default function audioManagerTest() { }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0400 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0400 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0400', 0, async function (done) { try { - for(let index in audio.DeviceType){ - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 1, audio.DeviceType[index]).then((data) => { - console.info(`####${index} getSystemVolumeInDb :SUCCESS ${data}`); - }).catch((error) => { - if(index == 'DEFAULT' || index == 'MAX' || index == 'INVALID' || index == 'NONE'){ - console.log(`####${index} getSystemVolumeInDb :${error.code} ${error.message}`); - }else{ - console.log(`${TagFrmwk}: ####${index} getSystemVolumeInDb : error ${error.message} ${error.code}`); + for (let index in audio.DeviceType) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 1, audio.DeviceType[index]) + .then((data) => { + console.info(`${index} getSystemVolumeInDb :SUCCESS ${data}`); + }) + .catch((error) => { + if (index == 'DEFAULT' || index == 'MAX' || index == 'INVALID' || index == 'NONE') { + console.log(`${index} getSystemVolumeInDb :${error.code} ${error.message}`); + } else { + console.log(`${TagFrmwk}:${index} getSystemVolumeInDb : error ${error.message} ${error.code}`); expect(false).assertTrue(); done(); } }); } done(); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0400: error ${error.message}, code ${error.code}`); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB: error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0500 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0500 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0500', 0, async function (done) { try { await audioVolumeGroupManager.getSystemVolumeInDb(-1, 3, audio.DeviceType.SPEAKER).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); + console.info(`getSystemVolumeInDb :SUCCESS ${data}, testcase FAIL!`); expect(false).assertTrue(); done(); }).catch((error) => { - if(error.code == env.UNSUPORTED_OPTION_6800104){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(true).assertTrue(); + if (error) { + console.log(`${TagFrmwk}:getSystemVolumeInDb error ${error.message} ${error.code}`); + expect(Number(error.code)).assertEqual(env.UNSUPORTED_OPTION_6800104); done(); - }else{ + } else { expect(false).assertTrue(); done(); } }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0500: error ${error.message}, code ${error.code}`); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0600 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0600 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0600', 0, async function (done) { try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, -1, audio.DeviceType.SPEAKER).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(false).assertTrue(); - done(); - }).catch((error) => { - if(error.code == env.UNSUPORTED_OPTION_6800104){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(true).assertTrue(); - done(); - }else{ + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, -1, audio.DeviceType.SPEAKER) + .then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); expect(false).assertTrue(); done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0600: error ${error.message}, code ${error.code}`); + }) + .catch((error) => { + if (error) { + console.log(`${TagFrmwk}: getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(Number(error.code)).assertEqual(env.UNSUPORTED_OPTION_6800104); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0700 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0700 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0700', 0, async function (done) { try { let maxVol = audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA); - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, maxVol+1, audio.DeviceType.SPEAKER).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(false).assertTrue(); - done(); - }).catch((error) => { - if(error.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(true).assertTrue(); - done(); - }else{ + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, maxVol + 1, audio.DeviceType.SPEAKER) + .then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}, testcase FAIL!`); expect(false).assertTrue(); done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0700: error ${error.message}, code ${error.code}`); + }) + .catch((error) => { + if (error) { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(Number(error.code)).assertEqual(env.UNSUPORTED_OPTION_6800104); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0800 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0800 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0800', 0, async function (done) { try { await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, -1).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(true).assertTrue(); + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); + expect(data).assertEqual(env.DEAFULT_MEDIA_DB); done(); }).catch((error) => { - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(false).assertTrue(); - done(); + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(false).assertTrue(); + done(); }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0800: error ${error.message}, code ${error.code}`); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0900 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0900 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0900', 0, async function (done) { try { await audioVolumeGroupManager.getSystemVolumeInDb('123', 3, audio.DeviceType.SPEAKER).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); expect(false).assertTrue(); done(); }).catch((error) => { - if(error.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(true).assertTrue(); + if (error) { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); done(); - }else{ + } else { expect(false).assertTrue(); done(); } }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0900: error ${error.message}, code ${error.code}`); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1000 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1000 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1000', 0, async function (done) { try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, '123', audio.DeviceType.SPEAKER).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(false).assertTrue(); - done(); - }).catch((error) => { - if(error.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(true).assertTrue(); - done(); - }else{ - expect(false).assertTrue(); - done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1000: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1100 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1100', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.MIC).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(true).assertTrue(); - done(); - }).catch((error) => { - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(false).assertTrue(); - done(); - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1100: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1200 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1200', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(3, audio.DeviceType.SPEAKER).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(true).assertTrue(); - done(); - }).catch((error) => { - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(false).assertTrue(); - done(); - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1200: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1300 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1300', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, audio.DeviceType.SPEAKER).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(true).assertTrue(); - done(); - }).catch((error) => { - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(false).assertTrue(); - done(); - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1300: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1400 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1400', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3).then((data) => { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(true).assertTrue(); - done(); - }).catch((error) => { - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(false).assertTrue(); - done(); - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1400: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1500 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1500', 0, async function (done) { - try { - var db1 = new ArrayList(); - 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 volIndex = minVol; volIndex <= maxVol; volIndex++){ - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[typeIndex], volIndex, device[deviceIndex]).then((data) => { - db1.add(data); - }).catch((error) => { - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error}`); - expect(false).assertTrue(); - done(); - }); - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[typeIndex], volIndex, device[deviceIndex]).then((data) => { - db2.add(data); - }).catch((error) => { - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error}`); - expect(false).assertTrue(); - done(); - }); - } - } - } - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : SUCCESS`); - for(let i = 0; i < db1.length; i++){ - expect(db1[i]).assertEqual(db2[i]); - } - done(); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1500': error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0100 - *@tc.name : getSystemVolumeInDb - Media - Callback - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0100', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER, (err,data) => { - if(err){ - console.info(`####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(false).assertTrue(); - done(); - }else{ + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, '123', audio.DeviceType.SPEAKER) + .then((data) => { console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(true).assertTrue(); + expect(false).assertTrue(); done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0100: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0200 - *@tc.name : getSystemVolumeInDb - Media - Callback - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0200', 0, async function (done) { - try { - for(let index in audio.AudioVolumeType){ - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[index], 3, audio.DeviceType.SPEAKER, (err,data) => { - if(err){ - console.log(`${TagFrmwk}: ####${index} getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(false).assertTrue(); + }) + .catch((error) => { + if (error.code == env.INVALID_INPUT_PARAMETER_6800101) { + console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(true).assertTrue(); done(); - }else{ - console.info(`####${index} getSystemVolumeInDb :SUCCESS ${data}`); - } - }); - await sleep(20); - } - done(); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0200: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0300 - *@tc.name : getSystemVolumeInDb - Media - Callback - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0300', 0, async function (done) { - try { - let maxVol = await audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA); - let minVol = await audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA); - for(let volLevel = minVol; volLevel <= maxVol; volLevel++){ - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, volLevel, audio.DeviceType.SPEAKER, (err,data) => { - if(err){ - console.log(`${TagFrmwk}: ####${volLevel} getSystemVolumeInDb : error ${err.message} ${err.code}`); + } else { expect(false).assertTrue(); done(); - }else{ - console.info(`####${volLevel} getSystemVolumeInDb :SUCCESS ${data}`); } }); - await sleep(20); - } - done(); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0300: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0400 - *@tc.name : getSystemVolumeInDb - Media - Callback - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0400', 0, async function (done) { - try { - for(let index in audio.DeviceType){ - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType[index], (err,data) => { - if(err){ - if(index == 'DEFAULT' || index == 'MAX' || index == 'INVALID' || index == 'NONE'){ - console.log(`####${index} getSystemVolumeInDb :${err.code} ${err.message}`); - }else{ - console.log(`${TagFrmwk}: ####${index} getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(false).assertTrue(); - done(); - } - }else { - console.info(`####${index} getSystemVolumeInDb :SUCCESS ${data}`); - } - }); - await sleep(20); - } - done(); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0400: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0500 - *@tc.name : getSystemVolumeInDb - Media - Callback - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0500', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(-1, 3, audio.DeviceType.SPEAKER, (err,data) => { - if(err.code == env.UNSUPORTED_OPTION_6800104){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(true).assertTrue(); - done(); - }else { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(false).assertTrue(); - done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0500: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0600 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0600', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, -1, audio.DeviceType.SPEAKER, (err,data) => { - if(err.code == env.UNSUPORTED_OPTION_6800104){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(true).assertTrue(); - done(); - }else { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(false).assertTrue(); - done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0600: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0700 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0700', 0, async function (done) { - try { - let maxVol = audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA); - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, maxVol+1, audio.DeviceType.SPEAKER, (err,data) => { - if(err.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(true).assertTrue(); - done(); - }else { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(false).assertTrue(); - done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0700: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0800 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0800', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, -1, (err,data) => { - if(err){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(false).assertTrue(); - done(); - }else { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(true).assertTrue(); - done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0800: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0900 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0900', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb('123', 3, audio.DeviceType.SPEAKER, (err,data) => { - if(err.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(true).assertTrue(); - done(); - }else { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(false).assertTrue(); - done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_0900: error ${error.message}, code ${error.code}`); + } catch (error) { + console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1000: error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1000 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1100 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1000', 0, async function (done) { + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1100', 0, async function (done) { try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, '123', audio.DeviceType.SPEAKER, (err,data) => { - if(err.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(true).assertTrue(); + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.MIC) + .then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); + expect(data).assertEqual(env.DEAFULT_MEDIA_DB); done(); - }else { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); + }) + .catch((error) => { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${error.message} ${error.code}`); expect(false).assertTrue(); done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1000: error ${error.message}, code ${error.code}`); - expect(false).assertTrue(); - done(); - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1100 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1100', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.MIC, (err,data) => { - if(err){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(false).assertTrue(); - done(); - }else { - console.info(`####getSystemVolumeInDb :SUCCESS ${data}`); - expect(true).assertTrue(); - done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1100: error ${error.message}, code ${error.code}`); + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1200 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1200 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1200', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(3, audio.DeviceType.SPEAKER, (err,data) => { - if(err) { - if (err.code == env.INVALID_INPUT_PARAMETER_6800101) { - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(true).assertTrue(); - done(); - } else { - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(false).assertTrue(); - done(); - } - } - }); - }catch (error){ - if(error.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(true).assertTrue(); + await audioVolumeGroupManager.getSystemVolumeInDb(3, audio.DeviceType.SPEAKER, (err, data) => { + if (err) { + console.log(`${TagFrmwk}getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(Number(err.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); done(); - }else{ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1200: error ${error.message}, code ${error.code}`); + } else { + console.log(`${TagFrmwk}: getSystemVolumeInDb : error ${err.message} ${err.code}`); expect(false).assertTrue(); done(); } - } + }); }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1300 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1300 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1300', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, audio.DeviceType.SPEAKER, (err,data) => { - if(err){ - if(err.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(true).assertTrue(); - done(); - }else{ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(false).assertTrue(); - done(); - } - } - }); - }catch (error){ - if(error.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(true).assertTrue(); + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, audio.DeviceType.SPEAKER, (err, data) => { + if (err) { + console.log(`${TagFrmwk} getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(Number(err.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); done(); - }else{ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1300: error ${error.message}, code ${error.code}`); + } else { + console.log(`${TagFrmwk} getSystemVolumeInDb : error ${err.message} ${err.code}`); expect(false).assertTrue(); done(); } - } + }); }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1400 - *@tc.name : getSystemVolumeInDb - Media - Promise - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1400 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1400', 0, async function (done) { - try { - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, (err,data) => { - if(err){ - if(err.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(true).assertTrue(); - done(); - }else{ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${err.message} ${err.code}`); - expect(false).assertTrue(); - done(); - } - } - }); - }catch (error){ - if(error.code == env.INVALID_INPUT_PARAMETER_6800101){ - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(true).assertTrue(); + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, (err, data) => { + if (err) { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(Number(err.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); done(); - }else{ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1400: error ${error.message}, code ${error.code}`); + } else { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${err.message} ${err.code}`); expect(false).assertTrue(); done(); } - } + }); }) /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1500 - *@tc.name : getSystemVolumeInDb - Media - Callback - *@tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1500 + * @tc.name : getSystemVolumeInDb - Media - Callback + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1500', 0, async function (done) { try { var db1 = new ArrayList(); 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){ + 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 volIndex = minVol; volIndex <= maxVol; volIndex++){ - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[typeIndex], volIndex, device[deviceIndex], (err,data) => { - if(err){ - console.info(`####getSystemVolumeInDb : error ${err.message} ${err.code}`); + for (let volIndex = minVol; volIndex <= maxVol; volIndex++) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[typeIndex], volIndex, device[deviceIndex], (err, data) => { + if (err) { + console.info(`getSystemVolumeInDb : error ${err.message} ${err.code}`); expect(false).assertTrue(); done(); - }else{ + } else { db1.add(data); } }); - await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[typeIndex], volIndex, device[deviceIndex], (err,data) => { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[typeIndex], volIndex, device[deviceIndex], (err, data) => { if (err) { - console.info(`####getSystemVolumeInDb : error ${err.message} ${err.code}`); + console.info(`getSystemVolumeInDb : error ${err.message} ${err.code}`); expect(false).assertTrue(); done(); } else { @@ -990,17 +528,38 @@ export default function audioManagerTest() { } } } - console.log(`${TagFrmwk}: ####getSystemVolumeInDb : SUCCESS`); - for(let i = 0; i < db1.length; i++){ - expect(db1[i]).assertEqual(db2[i]); + console.log(`${TagFrmwk}:getSystemVolumeInDb : SUCCESS`); + for (let i = 0; i < db1.length; i++) { + expect(db1[i]).assertEqual(db2[i]); } done(); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1500: error ${error.message}, code ${error.code}`); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); expect(false).assertTrue(); done(); } }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1600 + * @tc.name : getSystemVolumeInDb - Media - Callback + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1600', 0, async function (done) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 0, audio.DeviceType.SPEAKER, (err, data) => { + if (err) { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwk}:getSystemVolumeInDb SUCCESS dB:${data}`); + expect(data).assertEqual(0); + done(); + } + }) + }) }) } diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/List.test.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/List.test.ets index cafa8c3f9186120bab59ff6a882a277de503cfc8..6139d15a1de5c9eed1c85e7610f1108ca72977af 100644 --- a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/List.test.ets +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/List.test.ets @@ -14,9 +14,6 @@ */ import isVolumeUnadjustable from './IsVolumeUnadjustable.test.ets'; import getSystemVolumeInDb from './GetSystemVolumeInDb.test.ets'; -import adjustVolumeByStep from './AdjustVolumeByStep.test.ets'; -import adjustSystemVolumeByStep from './AdjustSystemVolumeByStep.test.ets'; -import getDefaultVolume from './GetDefaultVolume.test.ets'; import getMax_Minvolume from './GetMax_Minvolume.test.ets'; export default function testsuite() { diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/Test.json b/multimedia/audio/audio_js_standard/AudioRendererEnhance/Test.json index 519f122a9aed8c028ecb4701bf0366c078a0ef45..b8b0d54beecc3918aaaf49e7ee5a24915f8c0bbd 100644 --- a/multimedia/audio/audio_js_standard/AudioRendererEnhance/Test.json +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/Test.json @@ -19,6 +19,7 @@ { "type": "ShellKit", "run-command": [ + "power-shell wakeup", "mkdir -p /data/app/el2/100/base/com.example.xts_test_case/haps/entry/files", "chmod 777 -R /data/app/el2/100/base/com.example.xts_test_case/haps/entry" ], diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetAndSetRendererSamplingRate.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetAndSetRendererSamplingRate.test.ets index e5a4ed37d3824bd9e46f874ab0187f69d9293c99..ccb2e6a703c0ebd7ebf91fcf0bc99702ba7d5071 100644 --- a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetAndSetRendererSamplingRate.test.ets +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetAndSetRendererSamplingRate.test.ets @@ -654,6 +654,5 @@ export default function audioRendererTest() { } }); }); - }) } \ 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 0e165f128f602b9e188e89e0b60434ad06a5b2e5..87d30d4bc0ce13491877997fe4238eb9ad9d04cd 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 @@ -36,8 +36,8 @@ export default function audioRendererTest() { encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, rendererFlags: 0 } let AudioRendererOptions = { @@ -138,21 +138,17 @@ export default function audioRendererTest() { try { await audioRen.getCurrentOutputDevices().then((data) => { 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}`); - try { - expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); - expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); - expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); - } catch (error) { - console.log('${TagFrmwkRender}: assertion get output deviceinfo failure'); - } + expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); + expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); + expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); done(); }).catch((error) => { - console.log("${TagFrmwkRender}: getCurrentOutputDevices : error = " + error); + console.log("${TagFrmwkRender}: getCurrentOutputDevices error = " + error); expect(false).assertTrue(); done(); }); } catch (error) { - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_PROMISE_0100: catch error = " + error); + console.info(`get current output deviceinfo unknown errro: [${error.code}, ${error.message}]`); expect(false).assertTrue(); done(); } @@ -173,7 +169,19 @@ 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(0); + expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + console.info(`${TagFrmwkRender}: Renderer get current output device SUCCESS, now stop audiorender`); + audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drain : SUCCESS, stop audiorender`); + audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopp : SUCCESS`); + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); }).catch((error) => { console.log("${TagFrmwkRender}: getCurrentOutputDevices : error = " + error); expect(false).assertTrue(); @@ -183,17 +191,6 @@ export default function audioRendererTest() { expect(false).assertTrue(); done(); } - await audioRen.drain().then(() => { - console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); - }).catch((err) => { - console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); - }); - await audioRen.stop().then(() => { - console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); - }).catch((err) => { - console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); - }); - done(); }); /** @@ -205,27 +202,18 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_CALLBACK_0100', 0, async function (done) { - try { - await audioRen.getCurrentOutputDevices((err,data) => { - if (err) { - console.info(`${TagFrmwkRender}: ####getCurrentOutputDevices : ERROR : code: ${err.code}, mesage: ${err.message}`); - expect(false).assertTrue(); - } else { - console.info(`${TagFrmwkRender}: deviceRole:${data.deviceRole}, deviceType:${data.deviceType}, id:${data.id}, address:${data.address}, sampleRates:${data.sampleRates}, channelCounts:${data.channelCounts}, channelMasks:${data.channelMasks}`); - try { - expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); - expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); - expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); - } catch (error){ - console.log('${TagFrmwkRender}: ######assertion failure'); - } - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_CALLBACK_0100: catch error, error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - }; - done(); + audioRen.getCurrentOutputDevices((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getCurrentOutputDevices ERROR ! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + } else { + 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); + done(); + } + }); }); /** @@ -237,36 +225,31 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_CALLBACK_0200', 0, async function (done) { - try { - await renderPlay(); - await audioRen.getCurrentOutputDevices((err,data) => { - if (err) { - console.info(`${TagFrmwkRender}: ####getCurrentOutputDevices : ERROR : code: ${err.code}, mesage: ${err.message}`); - expect(false).assertTrue(); - done(); - } else { - 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(true).assertTrue(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_CALLBACK_0200: catch error, error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - done(); - }; - await audioRen.drain().then(() => { - console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); - }).catch((err) => { - console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); - }); - await audioRen.stop().then(() => { - console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); - }).catch((err) => { - console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + await renderPlay(); + audioRen.getCurrentOutputDevices((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getCurrentOutputDevices ERROR! error: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + 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); + console.info(`${TagFrmwkRender}: Renderer getCurrentOutputDevices SUCCESS! now stop the audiorenderer`); + audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drain, stop the audiorenderer`); + audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopp SUCCESS, testcase SUCCESS!`); + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + } }); - done(); - }); - }) } 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 582a3f387853279e52849397db67433c124dfa07..5949abf589d3dd0bfb07f773f17134d5f4c08967 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 @@ -175,16 +175,16 @@ export default function audioRendererTest() { it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0100', 0, async function (done) { try{ await audioRen.getMaxStreamVolume().then((data) => { - console.info(`${TagFrmwkRender}: #####getMaxStreamVolume :SUCCESS ${data}`); + console.info(`${TagFrmwkRender}:getMaxStreamVolume :SUCCESS ${data}`); expect(data).assertEqual(env.OUTPUT_NUMBER_1); done(); }).catch ((error)=>{ - console.log("${TagFrmwkRender}: #####getMaxStreamVolume : error = " + error); + console.log("${TagFrmwkRender}:getMaxStreamVolume : error = " + error); expect(false).assertTrue(); done(); }); }catch(error){ - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0100: catch error = " + error); + console.log("GETMAXSTREAMVOLUME catch error = " + error); expect(false).assertTrue(); done(); } @@ -202,10 +202,10 @@ export default function audioRendererTest() { try{ await renderPlay(); await audioRen.getMaxStreamVolume().then((data) => { - console.info(`${TagFrmwkRender}: #####getMaxStreamVolume :SUCCESS ${data}`); + console.info(`${TagFrmwkRender}:getMaxStreamVolume :SUCCESS ${data}`); expect(data).assertEqual(env.OUTPUT_NUMBER_1); }).catch ((error)=>{ - console.log("${TagFrmwkRender}: #####getMaxStreamVolume : error = " + error); + console.log("${TagFrmwkRender}:getMaxStreamVolume : error = " + error); expect(false).assertTrue(); done(); }); @@ -221,7 +221,7 @@ export default function audioRendererTest() { }); done(); }catch(error){ - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0200: catch error = " + error); + console.log("GETMAXSTREAMVOLUME catch error = " + error); expect(false).assertTrue(); done(); } @@ -255,24 +255,25 @@ export default function audioRendererTest() { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - try { - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRender = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} STREAM_USAGE_MEDIA SUCCESS data value: ` + JSON.stringify(data)); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); - }); + 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; + } } catch (error) { 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: ${StreamType} 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: ${StreamType} ERROR : code: ${error.code}, mesage: ${error.message}`); expect(false).assertTrue(); done(); }); @@ -286,7 +287,7 @@ export default function audioRendererTest() { } done(); }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0300:Stream ERROR : code: ${error.code}, mesage: ${error.message}`); + console.info(`GETMAXSTREAMVOLUME Stream ERROR : code: ${error.code}, mesage: ${error.message}`); } }); @@ -301,7 +302,7 @@ export default function audioRendererTest() { it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0400', 0, async function (done) { try{ await audioRen.getMaxStreamVolume().then((data) => { - console.info(`${TagFrmwkRender}: #####getMaxStreamVolume :SUCCESS ${data}`); + console.info(`${TagFrmwkRender}:getMaxStreamVolume :SUCCESS ${data}`); expect(data).assertEqual(env.OUTPUT_NUMBER_1); audioRen.setVolume(data).then(() => { console.info(`${TagFrmwkRender}: setVolume to maxVolume Success! maxVolume: ${data}`); @@ -313,12 +314,12 @@ export default function audioRendererTest() { done(); }); }).catch ((error)=>{ - console.info(`${TagFrmwkRender}: ####getMaxStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); + console.info(`${TagFrmwkRender}:getMaxStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); expect(false).assertTrue(); done(); }); }catch(error){ - console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0400: catch error, error: [${error.code}, ${error.message}]`); + console.info(`GETMAXSTREAMVOLUME catch error, error: [${error.code}, ${error.message}]`); expect(false).assertTrue(); done(); } @@ -335,16 +336,16 @@ export default function audioRendererTest() { it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0100', 0, async function (done) { try{ await audioRen.getMinStreamVolume().then((data) => { - console.info(`${TagFrmwkRender}: ####getMinStreamVolume :SUCCESS ${data}`); + console.info(`${TagFrmwkRender}:getMinStreamVolume :SUCCESS ${data}`); expect(data).assertEqual(env.OUTPUT_NUMBER_0); done(); }).catch ((error)=>{ - console.info(`${TagFrmwkRender}: #####getMinStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); + console.info(`${TagFrmwkRender}:getMinStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); expect(false).assertTrue(); done(); }); }catch(error){ - console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0100: catch error, error: [${error.code}, ${error.message}]`); + console.info(`GETMINSTREAMVOLUME catch error, error: [${error.code}, ${error.message}]`); expect(false).assertTrue(); done(); } @@ -362,10 +363,10 @@ export default function audioRendererTest() { try{ await renderPlay(); await audioRen.getMinStreamVolume().then((data) => { - console.info(`${TagFrmwkRender}: #####getMinStreamVolume :SUCCESS ${data}`); + console.info(`${TagFrmwkRender}:getMinStreamVolume :SUCCESS ${data}`); expect(data).assertEqual(env.OUTPUT_NUMBER_0); }).catch ((error)=>{ - console.info(`${TagFrmwkRender}: ####getMinStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); + console.info(`${TagFrmwkRender}:getMinStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); expect(false).assertTrue(); done(); }); @@ -381,7 +382,7 @@ export default function audioRendererTest() { }); done(); }catch(error){ - console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0200: catch error, error: [${error.code}, ${error.message}]`); + console.info(`GETMINSTREAMVOLUME catch error, error: [${error.code}, ${error.message}]`); expect(false).assertTrue(); done(); } @@ -415,23 +416,25 @@ export default function audioRendererTest() { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - try { - 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); - }); + 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; + } } 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: ${StreamType} 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: ${StreamType} ERROR : code: ${error.code}, mesage: ${error.message}`); expect(false).assertTrue(); done(); }); @@ -445,7 +448,7 @@ export default function audioRendererTest() { } done(); }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0300:Stream ERROR : code: ${error.code}, mesage: ${error.message}`); + console.info(`GETMINSTREAMVOLUME Stream ERROR : code: ${error.code}, mesage: ${error.message}`); } }); @@ -460,7 +463,7 @@ export default function audioRendererTest() { it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0400', 0, async function (done) { try{ await audioRen.getMinStreamVolume().then((data) => { - console.info(`${TagFrmwkRender}: #####getMinStreamVolume :SUCCESS ${data}`); + console.info(`${TagFrmwkRender}: getMinStreamVolume :SUCCESS ${data}`); expect(data).assertEqual(env.OUTPUT_NUMBER_0); audioRen.setVolume(data).then(() => { console.info(`${TagFrmwkRender}: setVolume to minVolume Success! minVolume: ${data}`); @@ -472,12 +475,12 @@ export default function audioRendererTest() { done(); }); }).catch ((error)=>{ - console.info(`${TagFrmwkRender}: ####getMinStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); + console.info(`${TagFrmwkRender}:getMinStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); expect(false).assertTrue(); done(); }); }catch(error){ - console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0400: catch error, error: [${error.code}, ${error.message}]`); + console.info(`GETMINSTREAMVOLUME catch error, error: [${error.code}, ${error.message}]`); expect(false).assertTrue(); done(); } @@ -556,19 +559,20 @@ export default function audioRendererTest() { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - try { - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRender = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} STREAM_USAGE_MEDIA SUCCESS data value: ` + JSON.stringify(data)); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); - }); + 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; + } } catch (error) { console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); } - audioRen.getMaxStreamVolume((err, maxVolume) => { if (err) { console.error('${TagFrmwkRender} Get max stream volume Fail: ${err}'); @@ -591,7 +595,7 @@ export default function audioRendererTest() { done(); }catch(error){ - console.log(`${TagFrmwkRender}: ####getMaxStreamVolume: catch error, error: [${error.code}, ${error.message}]`); + console.log(`${TagFrmwkRender}:getMaxStreamVolume: catch error, error: [${error.code}, ${error.message}]`); expect(false).assertTrue(); done(); } @@ -703,18 +707,20 @@ export default function audioRendererTest() { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - try { - 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); - }); + 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; + } } catch (error) { console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); } - audioRen.getMinStreamVolume((err, minVolume) => { if (err) { console.error('${TagFrmwkRender} Get min stream volume Fail: ${err}'); @@ -735,7 +741,7 @@ export default function audioRendererTest() { } done(); }catch(error){ - console.log(`${TagFrmwkRender}: ####getMinStreamVolume: catch error, error: [${error.code}, ${error.message}]`); + console.log(`${TagFrmwkRender}:getMinStreamVolume: catch error, error: [${error.code}, ${error.message}]`); expect(false).assertTrue(); done(); } 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 a3e16f85888c397cf6718f885690f3e153171165..bd0e579f7a8e8b93f1b2ed9d60c5c4b829a91902 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 @@ -36,7 +36,7 @@ export default function audioRendererTest() { encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, usage: audio.StreamUsage.STREAM_USAGE_MEDIA, rendererFlags: 0 } @@ -144,16 +144,16 @@ export default function audioRendererTest() { it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0100', 0, async function (done) { try{ await audioRen.getUnderflowCount().then((data) => { - console.info(`${TagFrmwkRender}: ####getUnderflowCount :SUCCESS ${data}`); + console.info(`${TagFrmwkRender}:getUnderflowCount :SUCCESS ${data}`); expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); done(); }).catch ((error)=>{ - console.log("${TagFrmwkRender}: ####getUnderflowCount : error = " + error); + console.log("${TagFrmwkRender}:getUnderflowCount : error = " + error); expect(false).assertTrue(); done(); }); }catch(error){ - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0100: catch error = " + error); + console.log("GETUNDERFLOWCOUNT catch unknown error = " + error); expect(false).assertTrue(); done(); } @@ -169,29 +169,26 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0200', 0, async function (done) { - try{ + try { await renderPlay(); await audioRen.getUnderflowCount().then((data) => { - console.info(`${TagFrmwkRender}: ####getUnderflowCount :SUCCESS ${data}`); expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); - }).catch ((error)=>{ - console.log("${TagFrmwkRender}: ####getUnderflowCount : error = " + error); + audioRen.drain().then(() => { + audioRen.stop().then(() => { + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + }).catch((error) => { + console.log("${TagFrmwkRender}: getUnderflowCount : error = " + error); expect(false).assertTrue(); done(); }); - await audioRen.drain().then(() => { - console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); - }).catch((err) => { - console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); - }); - await audioRen.stop().then(() => { - console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); - }).catch((err) => { - console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); - }); - done(); - }catch(error){ - console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0200: catch error = " + error); + } catch (error) { + console.log("GETUNDERFLOWCOUNT catch unknown error = " + error); expect(false).assertTrue(); done(); } @@ -207,7 +204,7 @@ export default function audioRendererTest() { */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0300', 0, async function (done) { let StreamType; - try{ + try { for (StreamType in audio.StreamUsage) { let audioRender; let AudioStreamInfo = { @@ -217,46 +214,47 @@ export default function audioRendererTest() { encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: StreamType, + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: Number(audio.StreamUsage[StreamType]), rendererFlags: 0 } let AudioRendererOptions = { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - try { - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRender = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} STREAM_USAGE_MEDIA SUCCESS data value: ` + JSON.stringify(data)); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); - }); + 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; + } } catch (error) { console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); } - await audioRender.getUnderflowCount().then((data) => { - console.info(`${TagFrmwkRender}: ####getUnderflowCount:Stream Type: ${StreamType} SUCCESS ${data}`); - expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); - }).catch ((error)=>{ - console.info(`${TagFrmwkRender}: #####getUnderflowCount:Stream Type: ${StreamType} ERROR : code: ${error.code}, mesage: ${error.message}`); + console.info(`${TagFrmwkRender}: getUnderflowCount SUCCESS! ${StreamType} data ${data}:, now release audiorender`); + expect(data).assertLargerOrEqual(0); + }).catch((error) => { + console.info(`${TagFrmwkRender}: getUnderflowCount: ERROR : code: ${error.code}, mesage: ${error.message}`); expect(false).assertTrue(); done(); }); - sleep(1000); await audioRender.release().then(() => { - console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + console.info(`${TagFrmwkRender}: Renderer ${StreamType} release SUCCESS! `); }).catch((err) => { - console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + console.info(`${TagFrmwkRender}: Renderer release ERROR: ${err.message}`); }); } done(); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0300:Stream ERROR : code: ${error.code}, mesage: ${error.message}`); + } catch (error) { + expect(false).assertTrue(); + done(); } }); @@ -269,23 +267,17 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0100', 0, async function (done) { - try { - audioRen.getUnderflowCount((err,data) => { - if (err) { - console.info(`${TagFrmwkRender}: ####getUnderflowCount : ERROR : code: ${err.code}, mesage: ${err.message}`); - expect(false).assertTrue(); - done(); - } else { - console.info(`${TagFrmwkRender}: ####getUnderflowCount : Success ${data}`); - expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); - done(); - } - }); - }catch (error){ - console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0100: catch error, error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - done(); - }; + audioRen.getUnderflowCount((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getUnderflowCount ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}: getUnderflowCount : Success! ${data}`); + expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + done(); + } + }); }); /** @@ -297,35 +289,31 @@ export default function audioRendererTest() { * @tc.level : Level 0 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0200', 0, async function (done) { - let CallBack:any = (error,data) => { - if (error) { - console.log(`${TagFrmwkRender}: ####CallBack: execution fail,error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - done(); - }else{ - console.log(`${TagFrmwkRender}: ####CallBack: execution success, data: ${JSON.stringify(data)}`); - expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); - } - }; - try{ + try { await renderPlay(); - audioRen.getUnderflowCount(CallBack); - }catch(error){ - console.log(`${TagFrmwkRender}: ####getUnderflowCount: catch error, error: [${error.code}, ${error.message}]`); + audioRen.getUnderflowCount((error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: getUnderflowCount execution fail,error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + audioRen.drain().then(() => { + audioRen.stop().then(() => { + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + } + }); + } catch (error) { + console.log(`${TagFrmwkRender}: getUnderflowCount unknown error, error: [${error.code}, ${error.message}]`); expect(false).assertTrue(); done(); - }; - await audioRen.drain().then(() => { - console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); - }).catch((err) => { - console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); - }); - await audioRen.stop().then(() => { - console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); - }).catch((err) => { - console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); - }); - done(); + } }); /** @@ -338,18 +326,7 @@ export default function audioRendererTest() { */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0300', 0, async function (done) { let StreamType; - let CallBack:any = (error,data) => { - if (error) { - console.log(`${TagFrmwkRender}: ####CallBack: execution fail,error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - done(); - }else{ - console.log(`${TagFrmwkRender}: ####CallBack:StreamType:${StreamType} execution success, data: ${JSON.stringify(data)}`); - expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); - } - }; - - try{ + try { for (StreamType in audio.StreamUsage) { let audioRender; let AudioStreamInfo = { @@ -367,36 +344,41 @@ export default function audioRendererTest() { streamInfo: AudioStreamInfo, rendererInfo: AudioRendererInfo } - try { - await audio.createAudioRenderer(AudioRendererOptions).then((data) => { - audioRender = data; - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); - console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} STREAM_USAGE_MEDIA SUCCESS data value: ` + JSON.stringify(data)); - }).catch((err) => { - console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); - }); + 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; + } } catch (error) { console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); } - - audioRen.getUnderflowCount(CallBack); - + audioRen.getUnderflowCount((error, data) => { + if (error) { + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwkRender}:getUnderflowCount StreamType:${StreamType} execution success, data: ${JSON.stringify(data)}`); + expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + } + }); sleep(1000); await audioRender.release().then(() => { - console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + console.info(`${TagFrmwkRender}: Renderer ${StreamType} release : SUCCESS`); }).catch((err) => { console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); }); } done(); - }catch(error){ - console.log(`${TagFrmwkRender}: ####getUnderflowCount: catch error, error: [${error.code}, ${error.message}]`); + } catch (error) { expect(false).assertTrue(); done(); } }); - - }) } diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/OnOffOutputDeviceChange.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/OnOffOutputDeviceChange.test.ets index e5953d69c24c6b2ddc80058134e6ac38a9c3ca12..2d92d7a9eced25683c3a13d135aec366f0e2b3fa 100644 --- a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/OnOffOutputDeviceChange.test.ets +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/OnOffOutputDeviceChange.test.ets @@ -34,8 +34,8 @@ export default function audioRendererTest() { encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW } let AudioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, rendererFlags: 0 } let AudioRendererOptions = { @@ -76,26 +76,24 @@ export default function audioRendererTest() { * @tc.desc : AudioRenderer - on "struct" - promise * @tc.size : MEDIUM * @tc.type : Function - * @tc.level : Level 0 + * @tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_ON_CALLBACK_0100', 0, async function (done) { - let CallBack:any = (error,data) => { + try { + audioRen.on(-1, (error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: On error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { if (error) { - console.log(`${TagFrmwkRender}: ####CallBack: execution fail,error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - done(); - }else{ - console.log(`${TagFrmwkRender}: ####CallBack: execution success, data: ${JSON.stringify(data)}`); - expect(true).assertTrue(); - done(); - } - }; - try{ - audioRen.on(-1, CallBack); - }catch(error){ - if (error.code == env.INVALID_INPUT_PARAMETER_401) { - console.log(`${TagFrmwkRender}: ####on: catch error, error: [${error.code}, ${error.message}]`); - expect(true).assertTrue(); + console.log(`${TagFrmwkRender}: On catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(INVALID_INPUT_PARAMETER_401); done(); } else { expect(false).assertTrue(); @@ -110,26 +108,24 @@ export default function audioRendererTest() { * @tc.desc : AudioRenderer - on "struct" - promise * @tc.size : MEDIUM * @tc.type : Function - * @tc.level : Level 0 + * @tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_ON_CALLBACK_0200', 0, async function (done) { - let CallBack:any = (error,data) => { + try { + audioRen.on('123', (error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: On error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { if (error) { - console.log(`${TagFrmwkRender}: ####CallBack: execution fail,error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - done(); - }else{ - console.log(`${TagFrmwkRender}: ####CallBack: execution success, data: ${JSON.stringify(data)}`); - expect(true).assertTrue(); - done(); - } - }; - try{ - audioRen.on('123', CallBack); - }catch(error){ - if (error.code == env.INVALID_INPUT_PARAMETER_6800101) { - console.log(`${TagFrmwkRender}: ####on: catch error, error: [${error.code}, ${error.message}]`); - expect(true).assertTrue(); + console.log(`${TagFrmwkRender}: On catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(INVALID_INPUT_PARAMETER_6800101); done(); } else { expect(false).assertTrue(); @@ -144,26 +140,25 @@ export default function audioRendererTest() { * @tc.desc : AudioRenderer - on "struct" - promise * @tc.size : MEDIUM * @tc.type : Function - * @tc.level : Level 0 + * @tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_ON_CALLBACK_0300', 0, async function (done) { - let CallBack:any = (error,data) => { + try { + audioRen.on((error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: On execution fail,error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwkRender}: On execution success, testcase FAIL!`); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { if (error) { - console.log(`${TagFrmwkRender}: ####CallBack: execution fail,error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - done(); - }else{ - console.log(`${TagFrmwkRender}: ####CallBack: execution success, data: ${JSON.stringify(data)}`); - expect(true).assertTrue(); - done(); - } - }; - try{ - audioRen.on(CallBack); - }catch(error){ - if (error.code == 401) { - console.log(`${TagFrmwkRender}: ####on: catch error, error: [${error.code}, ${error.message}]`); - expect(true).assertTrue(); + console.log(`${TagFrmwkRender}: On: catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(INVALID_INPUT_PARAMETER_401); done(); } else { expect(false).assertTrue(); @@ -178,33 +173,31 @@ export default function audioRendererTest() { * @tc.desc : AudioRenderer - on "struct" - promise * @tc.size : MEDIUM * @tc.type : Function - * @tc.level : Level 0 + * @tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_OFF_CALLBACK_0100', 0, async function (done) { - let CallBack:any = (error,data) => { + try { + audioRen.off(-1, (error, data) => { + if (error) { + console.log(`${TagFrmwkRender}:Off execution fail,error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwkRender}:Off execution success, testcase FAIL! `); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { if (error) { - console.log(`${TagFrmwkRender}: ####CallBack: execution fail,error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - done(); - }else{ - console.log(`${TagFrmwkRender}: ####CallBack: execution success, data: ${JSON.stringify(data)}`); - expect(true).assertTrue(); - done(); - } - }; - try{ - audioRen.off(-1, CallBack); - }catch(error){ - if (error.code == env.INVALID_INPUT_PARAMETER_6800101) { - console.log(`${TagFrmwkRender}: ####on: catch error, error: [${error.code}, ${error.message}]`); - expect(true).assertTrue(); + console.log(`${TagFrmwkRender}:On catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(INVALID_INPUT_PARAMETER_6800101); done(); } else { expect(false).assertTrue(); done(); } } - }); /** @@ -213,26 +206,25 @@ export default function audioRendererTest() { * @tc.desc : AudioRenderer - on "struct" - promise * @tc.size : MEDIUM * @tc.type : Function - * @tc.level : Level 0 + * @tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_OFF_CALLBACK_0200', 0, async function (done) { - let CallBack:any = (error,data) => { + try { + audioRen.off('123', (error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: Off execution fail,error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwkRender}: Off execution success, testcase FAIL! `); + expect(true).assertTrue(); + done(); + } + }); + } catch (error) { if (error) { - console.log(`${TagFrmwkRender}: ####CallBack: execution fail,error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - done(); - }else{ - console.log(`${TagFrmwkRender}: ####CallBack: execution success, data: ${JSON.stringify(data)}`); - expect(true).assertTrue(); - done(); - } - }; - try{ - audioRen.off('123', CallBack); - }catch(error){ - if (error.code == env.UNSUPORTED_OPTION_6800104) { - console.log(`${TagFrmwkRender}: ####on: catch error, error: [${error.code}, ${error.message}]`); - expect(true).assertTrue(); + console.log(`${TagFrmwkRender}: Off catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(UNSUPORTED_OPTION_6800104); done(); } else { expect(false).assertTrue(); @@ -247,26 +239,25 @@ export default function audioRendererTest() { * @tc.desc : AudioRenderer - off "struct" - promise * @tc.size : MEDIUM * @tc.type : Function - * @tc.level : Level 0 + * @tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_RENDERER_OFF_CALLBACK_0300', 0, async function (done) { - let CallBack:any = (error,data) => { + try { + audioRen.off((error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: Off execution fail,error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwkRender}: Off execution success, testcase FAIL! `); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { if (error) { - console.log(`${TagFrmwkRender}: ####CallBack: execution fail,error: [${error.code}, ${error.message}]`); - expect(false).assertTrue(); - done(); - }else{ - console.log(`${TagFrmwkRender}: ####CallBack: execution success, data: ${JSON.stringify(data)}`); - expect(true).assertTrue(); - done(); - } - }; - try{ - audioRen.off(CallBack); - }catch(error){ - if (error.code == env.INVALID_INPUT_PARAMETER_6800101) { - console.log(`${TagFrmwkRender}: ####on: catch error, error: [${error.code}, ${error.message}]`); - expect(true).assertTrue(); + console.log(`${TagFrmwkRender}: Off catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(INVALID_INPUT_PARAMETER_6800101); done(); } else { expect(false).assertTrue(); @@ -274,6 +265,5 @@ export default function audioRendererTest() { } } }); - }) }