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

!8288 【媒体子系统】新增audio覆盖

Merge pull request !8288 from 秦莉文/OpenHarmony-3.2-Release
......@@ -17,7 +17,7 @@ import audio from '@ohos.multimedia.audio';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function audioManagerApi9() {
describe('audioManagerApi9', function () {
describe('audioManagerApi9', function () {
let TagFrmwk = "audioManagerApi9Test";
console.info(`${TagFrmwk}: Create AudioManger Object JS Framework`);
let audioManager = null;
......@@ -164,16 +164,16 @@ describe('audioManagerApi9', function () {
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0100', 3, async function (done) {
let audioVolumeManager = audioManager.getVolumeManager();
audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID, (err,groupManager)=>{
audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID, (err, groupManager) => {
if (err) {
console.error(`audioManagerApi9Test: failed to getGroupManager: Callback: ${err.message}`);
expect(false).assertTrue();
} else {
if((typeof groupManager) == 'object'){
if ((typeof groupManager) == 'object') {
console.info('audioManagerApi9Test: Promise: getGroupManager : PASS');
expect(true).assertTrue();
}
else{
else {
console.info('audioManagerApi9Test: Promise: getGroupManager : FAIL');
expect(false).assertTrue();
}
......@@ -192,19 +192,19 @@ describe('audioManagerApi9', function () {
* @tc.level : Level 3
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0200', 3, async function (done) {
try{
try {
let audioVolumeManager = audioManager.getVolumeManager();
let groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
if((typeof groupManager) == 'object'){
if ((typeof groupManager) == 'object') {
console.info('audioManagerApi9Test: Promise: getGroupManager : PASS');
expect(true).assertTrue();
}
else{
else {
console.info('audioManagerApi9Test: Promise: getGroupManager : FAIL');
expect(false).assertTrue();
}
}catch(err){
console.info('audioManagerApi9Test: getGroupManager: parameter err:'+ err.message);
} catch (err) {
console.info('audioManagerApi9Test: getGroupManager: parameter err:' + err.message);
expect(false).assertTrue();
done();
}
......@@ -221,11 +221,11 @@ describe('audioManagerApi9', function () {
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETVOLUME_0100', 3, async function (done) {
let groupManager;
try{
try {
let audioVolumeManager = audioManager.getVolumeManager();
groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
}catch(err){
console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message);
} catch (err) {
console.info('audioManagerApi9Test: getVolumeGroupManager : err:' + err.message);
expect(false).assertTrue();
done();
}
......@@ -255,7 +255,7 @@ describe('audioManagerApi9', function () {
* @tc.level : Level 3
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETVOLUME_0200', 3, async function (done) {
try{
try {
let audioVolumeManager = audioManager.getVolumeManager();
let groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
let value = await groupManager.getVolume(audio.AudioVolumeType.MEDIA);
......@@ -268,8 +268,8 @@ describe('audioManagerApi9', function () {
expect(false).assertTrue();
}
done();
}catch(err){
console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message);
} catch (err) {
console.info('audioManagerApi9Test: getVolumeGroupManager : err:' + err.message);
expect(false).assertTrue();
done();
}
......@@ -284,7 +284,7 @@ describe('audioManagerApi9', function () {
* @tc.level : Level 3
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0100', 3, async function (done) {
try{
try {
let audioVolumeManager = audioManager.getVolumeManager();
let groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
groupManager.getMaxVolume(audio.AudioVolumeType.RINGTONE, (err, data) => {
......@@ -304,8 +304,8 @@ describe('audioManagerApi9', function () {
}
done();
});
}catch(err){
console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message);
} catch (err) {
console.info('audioManagerApi9Test: getVolumeGroupManager : err:' + err.message);
expect(false).assertTrue();
done();
}
......@@ -320,7 +320,7 @@ describe('audioManagerApi9', function () {
* @tc.level : Level 3
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0200', 3, async function (done) {
try{
try {
let audioVolumeManager = audioManager.getVolumeManager();
let groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
let maxVolume = await groupManager.getMaxVolume(audio.AudioVolumeType.RINGTONE);
......@@ -332,8 +332,8 @@ describe('audioManagerApi9', function () {
console.info('audioManagerApi9Test: promise : Ringtone getMaxVolume: FAIL :' + maxVolume);
expect(false).assertTrue();
}
}catch(err){
console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message);
} catch (err) {
console.info('audioManagerApi9Test: getVolumeGroupManager : err:' + err.message);
expect(false).assertTrue();
}
done();
......@@ -348,7 +348,7 @@ describe('audioManagerApi9', function () {
* @tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0100', 2, async function (done) {
try{
try {
let audioVolumeManager = audioManager.getVolumeManager();
let groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
groupManager.getMinVolume(audio.AudioVolumeType.RINGTONE, (err, data) => {
......@@ -368,8 +368,8 @@ describe('audioManagerApi9', function () {
}
done();
});
}catch(err){
console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message);
} catch (err) {
console.info('audioManagerApi9Test: getVolumeGroupManager : err:' + err.message);
expect(false).assertTrue();
done();
}
......@@ -384,7 +384,7 @@ describe('audioManagerApi9', function () {
* @tc.level : Level 3
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0200', 3, async function (done) {
try{
try {
let audioVolumeManager = audioManager.getVolumeManager();
let groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
let minVolume = await groupManager.getMinVolume(audio.AudioVolumeType.RINGTONE);
......@@ -396,8 +396,8 @@ describe('audioManagerApi9', function () {
console.info('audioManagerApi9Test: promise : Ringtone getMinVolume: FAIL :' + minVolume);
expect(false).assertTrue();
}
}catch(err){
console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message);
} catch (err) {
console.info('audioManagerApi9Test: getVolumeGroupManager : err:' + err.message);
expect(false).assertTrue();
}
done();
......@@ -413,23 +413,23 @@ describe('audioManagerApi9', function () {
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ISMUTE_0100', 3, async function (done) {
let groupManager;
try{
try {
let audioVolumeManager = audioManager.getVolumeManager();
groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
}catch(err){
console.info('audioManagerApi9Test: getGroupManager mute : parameter err:'+ err.message);
} catch (err) {
console.info('audioManagerApi9Test: getGroupManager mute : parameter err:' + err.message);
expect(false).assertTrue();
done();
}
groupManager.isMute(audio.AudioVolumeType.RINGTONE, (err, data)=>{
groupManager.isMute(audio.AudioVolumeType.RINGTONE, (err, data) => {
if (err) {
console.error(`audioManagerApi9Test: failed to isMute : Callback: ${err.message}`);
expect(false).assertTrue();
}
else {
console.log(`audioManagerApi9Test: Promise:
Is Stream GroupManager Mute RINGTONE: FALSE: PASS:`+data);
Is Stream GroupManager Mute RINGTONE: FALSE: PASS:`+ data);
expect(true).assertTrue();
}
done();
......@@ -445,12 +445,12 @@ describe('audioManagerApi9', function () {
* @tc.level : Level 3
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ISMUTE_0200', 3, async function (done) {
try{
try {
let audioVolumeManager = audioManager.getVolumeManager();
let groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
await groupManager.isMute(audio.AudioVolumeType.RINGTONE).then(function (data) {
console.log(`audioManagerApi9Test: Promise:
Is Stream GroupManager Mute RINGTONE: FALSE: PASS:`+data);
Is Stream GroupManager Mute RINGTONE: FALSE: PASS:`+ data);
expect(true).assertTrue();
done();
}).catch((err) => {
......@@ -459,8 +459,8 @@ describe('audioManagerApi9', function () {
expect(false).assertTrue();
done();
});
}catch(err){
console.info('audioManagerApi9Test: getGroupManager ismute : parameter err:'+ err.message);
} catch (err) {
console.info('audioManagerApi9Test: getGroupManager ismute : parameter err:' + err.message);
expect(false).assertTrue();
done();
}
......@@ -468,17 +468,25 @@ describe('audioManagerApi9', function () {
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_VOLUMECHANGE_0100
*@tc.name : OnVolumeChange - setVolume - MEDIA
*@tc.desc : OnVolumeChange - setVolume - MEDIA
*@tc.name : OnVolumeChange - setVolume - RINGTONE
*@tc.desc : OnVolumeChange - setVolume - RINGTONE
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 3
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_VOLUMECHANGE_0100', 3, async function (done) {
let audioVolumeManager = audioManager.getVolumeManager();
audioVolumeManager.on('volumeChange', (VolumeEvent) => {});
expect(true).assertTrue();
await audioManager.setVolume(audio.AudioVolumeType.RINGTONE, 7);
audioVolumeManager.on('volumeChange', (VolumeEvent) => {
console.info('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_VOLUMECHANGE_0100 AudioVolumeType is ' + VolumeEvent.volumeType)
console.info('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_VOLUMECHANGE_0100 volume is ' + VolumeEvent.volume)
console.info('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_VOLUMECHANGE_0100 updateUi is ' + VolumeEvent.updateUi)
expect(VolumeEvent.volumeType).assertEqual(2);
expect(VolumeEvent.volume).assertEqual(11);
expect(VolumeEvent.updateUi).assertEqual(false);
done();
});
await audioManager.setVolume(audio.AudioVolumeType.RINGTONE, 11);
})
/**
......@@ -491,30 +499,30 @@ describe('audioManagerApi9', function () {
*/
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETRINGERMODE_0100', 3, async function (done) {
let groupManager;
try{
try {
let audioVolumeManager = audioManager.getVolumeManager();
groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
}catch(err){
console.info('audioManagerApi9Test: getGroupManager mute : parameter err:'+ err.message);
} catch (err) {
console.info('audioManagerApi9Test: getGroupManager mute : parameter err:' + err.message);
expect(false).assertTrue();
done();
}
groupManager.getRingerMode((err, data)=>{
groupManager.getRingerMode((err, data) => {
if (err) {
console.error(`audioManagerApi9Test: failed to getRingerMode : Callback: ${err.message}`);
expect(false).assertTrue();
}
else {
if( data == audio.AudioRingMode.RINGER_MODE_SILENT ||
if (data == audio.AudioRingMode.RINGER_MODE_SILENT ||
data == audio.AudioRingMode.RINGER_MODE_VIBRATE ||
data == audio.AudioRingMode.RINGER_MODE_NORMAL){
data == audio.AudioRingMode.RINGER_MODE_NORMAL) {
console.log(`audioManagerApi9Test: Promise:
getRingerMode : PASS:`+data);
getRingerMode : PASS:`+ data);
expect(true).assertTrue();
}
else{
else {
console.log(`audioManagerApi9Test: Promise:
getRingerMode : FAIL: `+data);
getRingerMode : FAIL: `+ data);
expect(false).assertTrue();
}
}
......@@ -563,7 +571,7 @@ describe('audioManagerApi9', function () {
try {
let audioVolumeManager = audioManager.getVolumeManager();
let groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
groupManager.on('ringerModeChange', (AudioRingMode) => {});
groupManager.on('ringerModeChange', (AudioRingMode) => { });
expect(true).assertTrue();
done();
} catch (err) {
......@@ -584,13 +592,13 @@ describe('audioManagerApi9', function () {
it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETMICROPHONEMUTE_0100', 3, async function (done) {
let audioVolumeManager = audioManager.getVolumeManager();
let groupManager = await audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID);
groupManager.setMicrophoneMute(true,(err, data)=>{
groupManager.setMicrophoneMute(true, (err, data) => {
if (err) {
console.error(`audioManagerApi9Test: failed to setMicrophoneMute : Callback: ${err.message}`);
expect(false).assertTrue();
}
else {
groupManager.isMicrophoneMute((err, data)=>{
groupManager.isMicrophoneMute((err, data) => {
if (err) {
console.error(`audioManagerApi9Test: failed to isMicrophoneMute : Callback: ${err.message}`);
expect(false).assertTrue();
......@@ -663,7 +671,7 @@ describe('audioManagerApi9', function () {
if (MicStateChangeEvent.mute == true) {
console.info(`${TagFrmwk}: MEDIA CallBack : PASS : ${MicStateChangeEvent.mute}`);
expect(true).assertTrue();
}else{
} else {
console.info(`${TagFrmwk}: Audio MicStateChangeEvent is : ${MicStateChangeEvent}`);
expect(false).assertTrue();
}
......@@ -747,7 +755,7 @@ describe('audioManagerApi9', function () {
console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100
outputDeviceDescription is ${JSON.stringify(outputDeviceDescription)}`);
if (outputDeviceDescription.length == 1 &&
outputDeviceDescription[0].deviceType== audio.DeviceType.SPEAKER) {
outputDeviceDescription[0].deviceType == audio.DeviceType.SPEAKER) {
flag = false;
}
await AudioRoutingManager.setCommunicationDevice(2, false).then(() => {
......@@ -757,17 +765,17 @@ describe('audioManagerApi9', function () {
await AudioRoutingManager.isCommunicationDeviceActive(audio.ActiveDeviceType.SPEAKER).then(function (value) {
if (flag == true && value == false) {
console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100
isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`);
isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value} flag is ${flag}`);
expect(true).assertTrue();
}
else if (flag == false && value == true) {
console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100
isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`);
isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value} flag is ${flag}`);
expect(true).assertTrue();
}
else {
console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100
isCommunicationDeviceActive : SPEAKER: Deactivate : fail :${value } flag is ${flag}`);
isCommunicationDeviceActive : SPEAKER: Deactivate : fail :${value} flag is ${flag}`);
expect(false).assertTrue();
}
}).catch((err) => {
......@@ -789,7 +797,7 @@ describe('audioManagerApi9', function () {
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0200', 2,async function (done) {
it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0200', 2, async function (done) {
let flag = true
let AudioRoutingManager = audioManager.getRoutingManager();
let outputDeviceDescription = await AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG);
......@@ -810,14 +818,14 @@ describe('audioManagerApi9', function () {
console.error(`${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate: Error: ${err.message}`);
expect(false).assertTrue();
} else if (value == false && flag == true) {
console.info(`${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`);
console.info(`${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value} flag is ${flag}`);
expect(true).assertTrue();
} else if (value == true && flag == false) {
console.info(`${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`);
console.info(`${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value} flag is ${flag}`);
expect(true).assertTrue();
}
else {
console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0200 ${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate : FAIL :${value } flag is ${flag}`);
console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0200 ${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate : FAIL :${value} flag is ${flag}`);
expect(false).assertTrue();
}
done();
......@@ -968,5 +976,5 @@ describe('audioManagerApi9', function () {
done();
})
})
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册