提交 93ff06df 编写于 作者: L li-yifan2

add audioroutingmanager.test.js

Signed-off-by: Nli-yifan2 <liyifan37@huawei.com>
上级 4dacb3c6
...@@ -5174,6 +5174,166 @@ describe('audioFramework', function () { ...@@ -5174,6 +5174,166 @@ describe('audioFramework', function () {
}); });
}) })
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100
*@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100
*@tc.desc : micStateChange
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100', 2, async function (done) {
try{
var routingManager = await audioManager.getRoutingManager();
}catch (err) {
console.error(`${TagFrmwk}:Callback:failed to get RoutingManager ${err.message}`);
expect(false).assertTrue();
}
let count = 0;
console.info('getRoutingManager Callback START.');
routingManager.on('micStateChange',async (micStateChange)=>{
count++;
})
try{
let data = await audioManager.isMicrophoneMute();
console.info('Promise isMicrophoneMute PASS:' + data);
await audioManager.setMicrophoneMute(data);
console.info('Promise setMicrophoneMute PASS.');
let data1 = await audioManager.isMicrophoneMute();
console.info('Promise isMicrophoneMute PASS.' + data1);
}catch (err) {
console.log('ERROR:'+JSON.stringify(err))
expect(false).assertTrue();
done();
}
await sleep(2000);
expect(count).assertEqual(0);
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0200
*@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0200
*@tc.desc : micStateChange
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0200', 2, async function (done) {
try{
var routingManager = await audioManager.getRoutingManager();
}catch (err) {
console.error(`${TagFrmwk}:Callback:failed to get RoutingManager ${err.message}`);
expect(false).assertTrue();
}
console.info('getRoutingManager Callback START.');
let count = 0;
routingManager.on('micStateChange',async (micStateChange)=>{
console.info("Updated micState:" + JSON.stringify(micStateChange));
count++;
})
try{
let data = await audioManager.isMicrophoneMute();
console.info('Promise isMicrophoneMute PASS:' + data);
let micStatus = !data;
await audioManager.setMicrophoneMute(micStatus);
console.info('Promise setMicrophoneMute PASS:' + micStatus);
}catch (err) {
console.log('ERROR:'+JSON.stringify(err))
expect(false).assertTrue();
done();
}
await sleep(2000);
expect(count).assertEqual(1);
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0300
*@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0300
*@tc.desc : micStateChange
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0300', 2, async function (done) {
try{
var routingManager = await audioManager.getRoutingManager();
}catch (err) {
console.error(`${TagFrmwk}:Callback:failed to get RoutingManager ${err.message}`);
expect(false).assertTrue();
}
console.info('getRoutingManager Callback START.');
let count = 0;
routingManager.on('micStateChange',async (micStateChange)=>{
console.info("Updated micState:" + JSON.stringify(micStateChange));
count++;
})
try{
let data = await audioManager.isMicrophoneMute();
console.info('Promise isMicrophoneMute PASS:' + data);
let micStatus = !data;
await audioManager.setMicrophoneMute(micStatus);
console.info('Promise setMicrophoneMute PASS:' + micStatus);
await audioManager.setMicrophoneMute(!micStatus);
console.info('Promise setMicrophoneMute PASS:' + (!micStatus));
}catch (err) {
console.log('ERROR:'+JSON.stringify(err))
expect(false).assertTrue();
done();
}
await sleep(2000);
expect(count).assertEqual(2);
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0400
*@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0400
*@tc.desc : micStateChange
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0400', 2, async function (done) {
try{
var routingManager = await audioManager.getRoutingManager();
}catch (err) {
console.error(`${TagFrmwk}:Callback:failed to get RoutingManager ${err.message}`);
expect(false).assertTrue();
}
let count = 0;
try {
console.info("enter SUB_AUDIO_MANAGER_micStateChange_004");
routingManager.on('micStateChange',async (micStateChange1)=>{
console.info("Updated micState--001:" + JSON.stringify(micStateChange1));
routingManager.on('micStateChange',async (micStateChange)=>{
console.info("Updated micState--002:" + JSON.stringify(micStateChange));
count++
})
let data = await audioManager.isMicrophoneMute();
console.info('Second Promise isMicrophoneMute PASS:' + data);
await audioManager.setMicrophoneMute(!data);
console.info('Second:Promise setMicrophoneMute PASS:' + (!data));
})
let data = await audioManager.isMicrophoneMute();
console.info('First Promise isMicrophoneMute PASS:' + data);
await audioManager.setMicrophoneMute(!data);
console.info('First:Promise setMicrophoneMute PASS:' + (!data));
} catch (err) {
console.log('ERROR:'+JSON.stringify(err))
expect(false).assertTrue();
done();
}
await sleep(2000);
expect(count).assertEqual(1);
done();
})
/** /**
*@tc.number : SUB_MULTIMEDIA_AUDIO_DEVICEFALG_0100 *@tc.number : SUB_MULTIMEDIA_AUDIO_DEVICEFALG_0100
*@tc.name : NONE_DEVICES_FLAG *@tc.name : NONE_DEVICES_FLAG
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册