未验证 提交 8879d41c 编写于 作者: O openharmony_ci 提交者: Gitee

!6271 【媒体子系统】audio新增接口覆盖

Merge pull request !6271 from liuxueqi/monthly_20221018
......@@ -35,22 +35,8 @@ describe('audioCapturerChange', function () {
await sleep(100);
console.info(`AudioFrameworkTest: beforeAll: END`);
await sleep(100);
await audioManager.getStreamManager().then((data) => {
audioStreamManager = data;
console.info(`${Tag}: Get AudioStream Manager : Success `);
}).catch((err) => {
console.info(`${Tag}: Get AudioStream Manager : ERROR :${err.message}`);
});
audioManager.getStreamManager((err, data) => {
if (err) {
console.error(`${Tag}: Get AudioStream Manager : ERROR :${err.message}`);
}
else {
audioStreamManagerCB = data;
console.info(`${Tag}: Get AudioStream Manager : Success `);
}
});
audioStreamManager = audioManager.getStreamManager();
audioStreamManagerCB = audioManager.getStreamManager();
await sleep(1000);
console.info(`${Tag}: beforeAll: END`);
})
......
......@@ -25,22 +25,8 @@ describe('audioRendererChange', function () {
console.info(`${Tag} : Create AudioManger Object JS Framework`);
beforeAll(async function () {
await AUDIOMANAGER.getStreamManager().then(function (data) {
audioStreamManager = data;
console.info(`${Tag} : Get AudioStream Manager : Success `);
}).catch((err) => {
console.info(`${Tag} : Get AudioStream Manager : ERROR : ${err.message}`);
});
AUDIOMANAGER.getStreamManager((err, data) => {
if (err) {
console.error(`${Tag} : Get AudioStream Manager : ERROR : ${err.message}`);
}
else {
audioStreamManagerCB = data;
console.info(`${Tag} : Get AudioStream Manager : Success `);
}
});
audioStreamManager = AUDIOMANAGER.getStreamManager();
audioStreamManagerCB = AUDIOMANAGER.getStreamManager();
await sleep(1000);
console.info(`${Tag} : beforeAll: Prerequisites at the test suite level`);
......
......@@ -5175,111 +5175,6 @@ describe('audioFramework', function () {
});
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_isCommunicationDeviceActive_0100
*@tc.name : isCommunicationDeviceActive - OUTPUT device - Promise - ENAME
*@tc.desc : isCommunicationDeviceActive - OUTPUT device
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_isCommunicationDeviceActive_0100', 2, async function (done) {
try {
let AudioRoutingManager = await audioManager.getRoutingManager();
let value = await AudioRoutingManager.isCommunicationDeviceActive(2);
if (value != null && value != undefined) {
console.info(`${TagFrmwkRender}: SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_isCommunicationDeviceActive_0100 OUT OF BORDER PROMISE: SUCCESS ${value}`);
expect(true).assertTrue();
done();
}
else {
console.info(`${TagFrmwkRender}: SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_isCommunicationDeviceActive_0100 OUT OF BORDER PROMISE: FAIL ${value}`);
expect(false).assertTrue();
done();
}
} catch (err) {
console.info(`${TagFrmwkRender}: SUB_MULTIMEDIA_AUDIO_getAudioStreamId_0100 OUT OF BORDER PROMISE: ERROR: ${err.message}`);
expect(false).assertTrue();
done();
}
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_isCommunicationDeviceActive_0200
*@tc.name : isCommunicationDeviceActive - OUTPUT device - Promise - ENAME
*@tc.desc : isCommunicationDeviceActive - OUTPUT device
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_isCommunicationDeviceActive_0200', 2, async function (done) {
let AudioRoutingManager = await audioManager.getRoutingManager();
await AudioRoutingManager.isCommunicationDeviceActive(2, (err, value) => {
if (err) {
console.info(`${TagFrmwk}: Promise:SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_isCommunicationDeviceActive_0200 : FAIL ${err}`);
expect(false).assertTrue();
done();
}
else {
if (value != null && value != undefined) {
console.info(`${TagFrmwkRender}: SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_isCommunicationDeviceActive_0200 OUT OF BORDER PROMISE: SUCCESS ${value}`);
expect(true).assertTrue();
done();
}
else {
console.info(`${TagFrmwkRender}: SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_isCommunicationDeviceActive_0200 OUT OF BORDER PROMISE: FAIL ${value}`);
expect(false).assertTrue();
done();
}
}
});
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_setCommunicationDevice_0100
*@tc.name : setCommunicationDevice - OUTPUT device - Promise - ENAME
*@tc.desc : setCommunicationDevice - OUTPUT device
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_setCommunicationDevice_0100', 2, async function (done) {
try {
let AudioRoutingManager = await audioManager.getRoutingManager();
await AudioRoutingManager.setCommunicationDevice(2, true);
expect(true).assertTrue();
} catch (err) {
console.info(`${TagFrmwkRender}: SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_setCommunicationDevice_0100 OUT OF BORDER PROMISE: ERROR: ${err.message}`);
expect(false).assertTrue();
}
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_setCommunicationDevice_0200
*@tc.name : isCommunicationDeviceActive - OUTPUT device - Promise - ENAME
*@tc.desc : isCommunicationDeviceActive - OUTPUT device
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_setCommunicationDevice_0200', 2, async function (done) {
let AudioRoutingManager = await audioManager.getRoutingManager();
await AudioRoutingManager.setCommunicationDevice(2, true, (err) => {
if (err) {
console.info(`${TagFrmwk}: Promise:SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_setCommunicationDevice_0200 : FAIL ${err}`);
expect(false).assertTrue();
}
else {
console.info(`${TagFrmwk}: Promise:SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_setCommunicationDevice_0200 : PASS`);
expect(true).assertTrue();
}
});
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100
*@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100
......@@ -5472,256 +5367,4 @@ describe('audioFramework', function () {
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ERRORS_0100'
*@tc.name : AUDIO_ERRORS
*@tc.desc : AUDIO_ERRORS
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ERRORS_0100', 2, async function (done) {
expect(audio.AudioErrors.ERROR_INVALID_PARAM).assertEqual(6800101);
expect(audio.AudioErrors.ERROR_NO_MEMORY).assertEqual(6800102);
expect(audio.AudioErrors.ERROR_ILLEGAL_STATE).assertEqual(6800103);
expect(audio.AudioErrors.ERROR_UNSUPPORTED).assertEqual(6800104);
expect(audio.AudioErrors.ERROR_TIMEOUT).assertEqual(6800105);
expect(audio.AudioErrors.ERROR_STREAM_LIMIT).assertEqual(6800201);
expect(audio.AudioErrors.ERROR_SYSTEM).assertEqual(6800301);
await sleep(50);
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_DEFAULT_VOLUME_GROUP_ID_0100'
*@tc.name : DEFAULT_VOLUME_GROUP_ID
*@tc.desc : DEFAULT_VOLUME_GROUP_ID
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_DEFAULT_VOLUME_GROUP_ID_0100', 2, async function (done) {
expect(audio.DEFAULT_VOLUME_GROUP_ID).assertEqual(1);
expect(audio.DEFAULT_INTERRUPT_GROUP_ID).assertEqual(1);
await sleep(50);
done();
})
/**
* @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0100
* @tc.name : getMinVolume - RINGTONE - Callback
* @tc.desc : getMinVolume
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0100', 2, async function (done) {
try {
let audioVolumeManager = audioManager.getVolumeManager();
let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID);
let groupId_ = volumeGroupInfos[0].groupId;
let audioGroupManager = await audioVolumeManager.getVolumeGroupManager(groupId_);
audioGroupManager.getMinVolume(audio.AudioVolumeType.RINGTONE, (err, data) => {
if (err) {
console.error(`AudioFrameworkTest: failed to getMinVolume : Callback: ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == minVol) {
console.info('AudioFrameworkTest: callback : Ringtone getMinVolume: PASS :' + data);
expect(true).assertTrue();
}
else {
console.info('AudioFrameworkTest: callback : Ringtone getMinVolume: FAIL :' + data);
expect(false).assertTrue();
}
}
done();
});
} catch (err) {
console.info('AudioFrameworkTest: getVolumeGroupManager : err:' + err.message);
expect(false).assertTrue();
done();
}
})
/**
* @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0100
* @tc.name : mute - RINGTONE - Promise
* @tc.desc : mute - RINGTONE - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0100', 2, async function (done) {
try {
let audioVolumeManager = audioManager.getVolumeManager();
let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID);
let groupId_ = volumeGroupInfos[0].groupId;
let audioGroupManager = await audioVolumeManager.getVolumeGroupManager(groupId_);
audioGroupManager.mute(audio.AudioVolumeType.RINGTONE, false).then(function () {
console.log('AudioFrameworkTest: Set Stream GroupManager Mute: RINGTONE: Promise: FALSE');
audioGroupManager.isMute(audio.AudioVolumeType.RINGTONE).then(function (data) {
if (data == false) {
console.log(`AudioFrameworkTest: Promise:
Is Stream GroupManager Mute RINGTONE: FALSE: PASS:`+ data);
expect(true).assertTrue();
}
else {
console.log(`AudioFrameworkTest: Promise:
Is Stream GroupManager Mute RINGTONE: FALSE: FAIL: `+ data);
expect(false).assertTrue();
}
done();
});
}).catch((err) => {
console.info(`AudioFrameworkTest: Promise:
Is Stream GroupManager Mute RINGTONE: FALSE: ERROR:` + err.message);
expect(false).assertTrue();
done();
});
} catch (err) {
console.info('AudioFrameworkTest: getGroupManager mute : parameter err:' + err.message);
expect(false).assertTrue();
done();
}
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ONVOLUMECHANGE_0100
*@tc.name : OnVolumeChange - setVolume - MEDIA
*@tc.desc : OnVolumeChange - setVolume - MEDIA
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ONVOLUMECHANGE_0100', 2, async function (done) {
let audioVolumeManager = audioManager.getVolumeManager();
let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID);
let groupId_ = volumeGroupInfos[0].groupId;
let audiogroupManager = await audioVolumeManager.getVolumeGroupManager(groupId_);
audioVolumeManager.on('volumeChange', (VolumeEvent) => {
console.log(`${TagFrmwk}: Volume Change Event is called`);
switch (VolumeEvent.volumeType) {
case audio.AudioVolumeType.MEDIA:
console.info(`${TagFrmwk}: Audio VolumeEvent is : ${VolumeEvent}`);
if (VolumeEvent.volume == lowVol) {
console.info(`${TagFrmwk}: MEDIA CallBack : PASS : ${VolumeEvent.volume}`);
expect(true).assertTrue();
}
break;
default:
console.info(`${TagFrmwk}: Audio VolumeEvent is : ${VolumeEvent}`);
expect(false).assertTrue();
break;
}
done();
});
try {
await audiogroupManager.setVolume(audioMedia, lowVol);
console.info('setVolume success')
} catch (err) {
console.log('err :' + err.message)
expect(false).assertTrue();
done();
}
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETRINGERMODE_0100
*@tc.name : setRingerMode - Normal Mode - Promise - ENAME
*@tc.desc : setRingerMode - Set Ring more to Normal Mode
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETRINGERMODE_0100', 2, async function (done) {
try {
let audioVolumeManager = audioManager.getVolumeManager();
let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID);
let groupId_ = volumeGroupInfos[0].groupId;
let audiogroupManager = await audioVolumeManager.getVolumeGroupManager(groupId_);
await audiogroupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL);
let value = await audiogroupManager.getRingerMode();
if (value == audio.AudioRingMode.RINGER_MODE_NORMAL) {
console.info(`${TagFrmwk}: Promise: setRingerMode RINGER_MODE_NORMAL: PASS :${value}`);
expect(true).assertTrue();
} else {
console.info(`${TagFrmwk}: Promise: setRingerMode RINGER_MODE_NORMAL: FAIL :${value}`);
expect(false).assertTrue();
}
} catch (err) {
console.log('err :' + err.message);
expect(false).assertTrue();
}
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ONRINGMODECHANGE_0100
*@tc.name : OnRingMode - RINGER_MODE_NORMAL
*@tc.desc : OnRingMode - RINGER_MODE_NORMAL
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ONRINGMODECHANGE_0100', 2, async function (done) {
let audioVolumeManager = audioManager.getVolumeManager();
let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID);
let groupId_ = volumeGroupInfos[0].groupId;
let audiogroupManager = await audioVolumeManager.getVolumeGroupManager(groupId_);
audiogroupManager.on('ringerModeChange', (AudioRingMode) => {
console.log(`${TagFrmwk}: ringerMode Change Event is called`);
switch (AudioRingMode) {
case audio.AudioRingMode.RINGER_MODE_NORMAL:
console.info(`${TagFrmwk}: Audio ringerMode is : ${AudioRingMode}`);
console.info(`${TagFrmwk}: MEDIA CallBack : PASS : ${AudioRingMode}`);
expect(true).assertTrue();
break;
default:
console.info(`${TagFrmwk}: Audio VolumeEvent is : ${AudioRingMode}`);
expect(false).assertTrue();
break;
}
done();
});
try {
await audiogroupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL);
console.info('setRingerMode success')
} catch (err) {
console.log('err :' + err.message)
expect(false).assertTrue();
done();
}
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETMICROPHONEMUTE_0100
*@tc.name : setMicrophoneMute - true - Promise
*@tc.desc : Enable mic mute
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 1
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETMICROPHONEMUTE_0100', 1, async function (done) {
try {
let audioVolumeManager = audioManager.getVolumeManager();
let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID);
let groupId_ = volumeGroupInfos[0].groupId;
let audiogroupManager = await audioVolumeManager.getVolumeGroupManager(groupId_);
await audiogroupManager.setMicrophoneMute(true);
let data = await audiogroupManager.isMicrophoneMute();
if (data == true) {
console.log(`${TagFrmwk}: Promise: isMicrophoneMute: TRUE: PASS:${data}`);
expect(true).assertTrue();
} else {
console.log(`${TagFrmwk}: Promise: isMicrophoneMute: TRUE: FAIL: ${data}`);
expect(false).assertTrue();
}
} catch (err) {
console.log('err :' + err.message);
expect(false).assertTrue();
}
done();
})
})
\ No newline at end of file
......@@ -14,4 +14,4 @@
*/
require('./AudioFramework.test.js')
require('./AudioManagerApi9.test.js')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册