提交 b8724116 编写于 作者: H Harshaprasad

Updating the scripts and resources files

Signed-off-by: NHarshaprasad <harshaprasad@huawei.com>
上级 54494680
// @ts-nocheck
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:// www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import audio from '@ohos.multimedia.audio';
import fileio from '@ohos.fileio';
import ability_featureAbility from '@ohos.ability.featureAbility';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
describe('audioCall', function () {
var mediaDir;
var dateTime;
var dirPath;
var fpath;
var resultFlagRec;
var resultFlagRen;
const audioManager = audio.getAudioManager();
console.info('AudioFrameworkRenderLog: Create AudioManger Object JS Framework');
const audioManagerRec = audio.getAudioManager();
console.info('AudioFrameworkRecLog: Create AudioManger Object JS Framework');
async function getPathName(){
var path1 = '/data/accounts/account_0/applications/';
var packageName;
var context = ability_featureAbility.getContext();
await context.getBundleName()
.then((data) => {
console.info('AudioFrameworkRenderLog: Cache directory obtained. Data: ' + data);
packageName = data;
}).catch((error) => {
console.error('AudioFrameworkRenderLog: Failed to obtain the cache directory. Cause:' + error.message);
});
await sleep(200);
var mediaDirTemp = path1 + packageName + '/' + packageName + '/assets/entry/resources/rawfile';
console.info('AudioFrameworkRenderLog: Resource DIR Path : '+mediaDirTemp);
return mediaDirTemp;
}
beforeAll(async function () {
console.info('AudioFrameworkTest: beforeAll: Prerequisites at the test suite level');
mediaDir = await getPathName();
dateTime = new Date().getTime();
dirPath = '/data/accounts/account_0/applications'+'/RecTest'+dateTime;
console.info('AudioFrameworkRecLog: Recording files Path: '+dirPath);
fpath = dirPath+'/capture_js.pcm';
await sleep(100);
fileio.mkdirSync(dirPath);
console.info('AudioFrameworkTest: beforeAll: END');
})
beforeEach(async function () {
console.info('AudioFrameworkTest: beforeEach: Prerequisites at the test case level');
await sleep(500);
})
afterEach(async function () {
console.info('AudioFrameworkTest: afterEach: Test case-level clearance conditions');
await sleep(1000);
})
afterAll(async function () {
console.info('AudioFrameworkTest: afterAll: Test suite-level cleanup condition');
})
function sleep (ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function playbackPromise (AudioRendererOptions, fpath, AudioScene) {
resultFlagRen = 'new';
console.info('AudioFrameworkRenderLog: Promise : Audio Playback Function');
var audioRen;
await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) {
audioRen = data;
console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : '+err.message);
resultFlagRen=false;
return resultFlagRen;
});
console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath);
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
await audioManager.setAudioScene(AudioScene).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
await audioManager.getAudioScene().then(async function (data) {
console.info('AudioFrameworkRenderLog: getAudioScene : Value : '+data);
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlagRen=false;
});
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
resultFlagRen=false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
return resultFlagRen;
}
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
await audioRen.getStreamInfo().then(async function (audioParamsGet) {
console.info('AudioFrameworkRenderLog: Renderer getStreamInfo:');
console.info('AudioFrameworkRenderLog: Renderer sampleFormat:' + audioParamsGet.sampleFormat);
console.info('AudioFrameworkRenderLog: Renderer samplingRate:' + audioParamsGet.samplingRate);
console.info('AudioFrameworkRenderLog: Renderer channels:' + audioParamsGet.channels);
console.info('AudioFrameworkRenderLog: Renderer encodingType:' + audioParamsGet.encodingType);
}).catch((err) => {
console.log('AudioFrameworkRenderLog: getStreamInfo :ERROR: '+err.message);
resultFlagRen = false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
return resultFlagRen;
}
await audioRen.getRendererInfo().then(async function (audioParamsGet) {
console.info('AudioFrameworkRenderLog: Renderer RendererInfo:');
console.info('AudioFrameworkRenderLog: Renderer content type:' + audioParamsGet.content);
console.info('AudioFrameworkRenderLog: Renderer usage:' + audioParamsGet.usage);
console.info('AudioFrameworkRenderLog: Renderer rendererFlags:' + audioParamsGet.rendererFlags);
}).catch((err) => {
console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message);
resultFlagRen = false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
return resultFlagRen;
}
await audioRen.start().then(async function () {
console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS ');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message);
resultFlagRen=false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
return resultFlagRen;
}
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
var bufferSize;
await audioRen.getBufferSize().then(async function (data) {
console.info('AudioFrameworkRenderLog: getBufferSize :SUCCESS '+data);
bufferSize=data;
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getBufferSize :ERROR : '+err.message);
resultFlagRen=false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
return resultFlagRen;
}
let ss = fileio.createStreamSync(fpath, 'r');
console.info('AudioFrameworkRenderLog: File Path: ' + fpath);
let discardHeader = new ArrayBuffer(44);
ss.readSync(discardHeader);
let totalSize = fileio.statSync(fpath).size;
console.info('AudioFrameworkRenderLog: File totalSize size: ' +totalSize);
totalSize = totalSize-44;
console.info('AudioFrameworkRenderLog: File size : Removing header: ' +totalSize);
let rlen = 0;
while (rlen < totalSize) {
let buf = new ArrayBuffer(bufferSize);
rlen += ss.readSync(buf);
console.info('BufferAudioFramework: bytes read from file: ' +rlen);
await audioRen.write(buf);
if (rlen > (totalSize/2)){
await audioManager.getAudioScene().then(async function (data) {
console.info('AudioFrameworkAudioScene: getAudioScene : Value : '+data);
}).catch((err) => {
console.info('AudioFrameworkAudioScene: getAudioScene : ERROR : '+err.message);
resultFlagRen=false;
});
}
}
console.info('AudioFrameworkRenderLog: Renderer after read');
await audioRen.drain().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer drained : SUCCESS');
}).catch((err) => {
console.error('AudioFrameworkRenderLog: Renderer drain: ERROR : '+err.message);
resultFlagRen=false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
return resultFlagRen;
}
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
await audioRen.stop().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS');
resultFlagRen=true;
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
}).catch((err) => {
console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message);
resultFlagRen=false;
});
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
await audioRen.release().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message);
resultFlagRen=false;
});
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
return resultFlagRen;
}
async function recPromise (AudioCapturerOptions, fpath, AudioScene) {
resultFlagRec = 'new';
console.info('AudioFrameworkRecLog: Promise : Audio Recording Function');
var audioCap;
await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) {
audioCap = data;
console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message);
return resultFlagRec;
});
console.info('AudioFrameworkRecLog: AudioCapturer : Path : '+fpath);
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state);
await audioManagerRec.setAudioScene(AudioScene).then(async function () {
console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS ');
await audioManagerRec.getAudioScene().then(async function (data) {
console.info('AudioFrameworkRecLog: getAudioScene : Value : '+data);
}).catch((err) => {
console.info('AudioFrameworkRecLog: getAudioScene : ERROR : '+err.message);
resultFlagRec=false;
});
}).catch((err) => {
console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message);
resultFlagRec=false;
});
if (resultFlagRec == false){
console.info('AudioFrameworkRecLog: resultFlagRec : '+resultFlagRec);
return resultFlagRec;
}
await audioCap.getStreamInfo().then(async function (audioParamsGet) {
console.info('AudioFrameworkRecLog: Capturer getStreamInfo:');
console.info('AudioFrameworkRecLog: Capturer sampleFormat:' + audioParamsGet.sampleFormat);
console.info('AudioFrameworkRecLog: Capturer samplingRate:' + audioParamsGet.samplingRate);
console.info('AudioFrameworkRecLog: Capturer channels:' + audioParamsGet.channels);
console.info('AudioFrameworkRecLog: Capturer encodingType:' + audioParamsGet.encodingType);
}).catch((err) => {
console.log('AudioFrameworkRecLog: getStreamInfo :ERROR: '+err.message);
resultFlagRec = false;
});
if (resultFlagRec == false){
console.info('AudioFrameworkRecLog: resultFlagRec : '+resultFlagRec);
return resultFlagRec;
}
await audioCap.getCapturerInfo().then(async function (audioParamsGet) {
console.info('AudioFrameworkRecLog: Capturer CapturerInfo:');
console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source);
console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags);
}).catch((err) => {
console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message);
resultFlagRec = false;
});
if (resultFlagRec == false){
console.info('AudioFrameworkRecLog: resultFlag : '+resultFlagRec);
return resultFlagRec;
}
await audioCap.start().then(async function () {
console.info('AudioFrameworkRecLog: Capturer started :SUCCESS ');
}).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message);
resultFlagRec=false;
});
if (resultFlagRec == false){
console.info('AudioFrameworkRecLog: resultFlagRec : '+resultFlagRec);
return resultFlagRec;
}
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state);
var bufferSize = await audioCap.getBufferSize();
console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize);
var fd = fileio.openSync(fpath, 0o102, 0o777);
if (fd !== null) {
console.info('AudioFrameworkRecLog: file fd created');
}
else{
console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message);
resultFlagRec=false;
return resultFlagRec;
}
fd = fileio.openSync(fpath, 0o2002, 0o666);
if (fd !== null) {
console.info('AudioFrameworkRecLog: file fd opened : Append Mode :PASS');
}
else{
console.info('AudioFrameworkRecLog: file fd Open: Append Mode : FAILED');
resultFlagRec=false;
return resultFlagRec;
}
var numBuffersToCapture = 250;
while (numBuffersToCapture) {
var buffer = await audioCap.read(bufferSize, true);
var number = fileio.writeSync(fd, buffer);
console.info('BufferRecLog: data written: ' + number);
numBuffersToCapture--;
}
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state);
await audioCap.stop().then(async function () {
console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS');
resultFlagRec=true;
console.info('AudioFrameworkRecLog: resultFlagRec : '+resultFlagRec);
}).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message);
resultFlagRec=false;
});
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state);
await audioCap.release().then(async function () {
console.info('AudioFrameworkRecLog: Capturer release : SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message);
resultFlagRec=false;
});
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state);
return resultFlagRec;
}
/* *
* @tc.number : SUB_AUDIO_VOIP_Play_001
* @tc.name : SetAudioScene during playback
* @tc.desc : SetAudioScene during playback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_VOIP_Play_001', 0, async function (done) {
var AudioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_1,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
var AudioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_SPEECH,
usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
rendererFlags: 1
}
var AudioRendererOptions = {
streamInfo: AudioStreamInfo,
rendererInfo: AudioRendererInfo
}
var resultFlag = await playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-1C-44100-2SW.wav', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(100);
console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag);
expect(resultFlag).assertTrue();
done();
})
/* *
* @tc.number : SUB_AUDIO_VOIP_Rec_001
* @tc.name : SetAudioScene during Recording
* @tc.desc : SetAudioScene during Recording
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_VOIP_Rec_001', 0, async function (done) {
var AudioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
var AudioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 1
}
var AudioCapturerOptions = {
streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo
}
var resultFlag = await recPromise(AudioCapturerOptions, dirPath+'/capture_js-44100-2C-16B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(100);
console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag);
expect(resultFlag).assertTrue();
done();
})
/* *
* @tc.number : SUB_AUDIO_VOIP_RecPlay_001
* @tc.name : Record & play at same time - setAudioScene
* @tc.desc : Record & play at same time - setAudioScene
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_VOIP_RecPlay_001', 0, async function (done) {
var AudioStreamInfoCap = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
var AudioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 1
}
var AudioCapturerOptions = {
streamInfo: AudioStreamInfoCap,
capturerInfo: AudioCapturerInfo
}
var AudioStreamInfoRen = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_1,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
var AudioRendererInfo = {
content: audio.ContentType.CONTENT_TYPE_SPEECH,
usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
rendererFlags: 1
}
var AudioRendererOptions = {
streamInfo: AudioStreamInfoRen,
rendererInfo: AudioRendererInfo
}
recPromise(AudioCapturerOptions, dirPath+'/capture_js-44100-2C-16B-2.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(500);
await playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-1C-44100-2SW.wav', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(500);
console.info('AudioFrameworkRecLog: resultFlag : Capturer : '+resultFlagRec);
console.info('AudioFrameworkRenderLog: resultFlag : Renderer : '+resultFlagRen);
if (resultFlagRec == true){
expect(resultFlagRen).assertTrue();
}
else{
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_001
* @tc.name : setAudioScene as VOIP - Promise - ENUM
* @tc.desc : setAudioScene as VOIP - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_001', 0, async function (done) {
await audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_002
* @tc.name : getAudioScene as VOIP - Promise - ENUM
* @tc.desc : getAudioScene as VOIP - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_002', 0, async function (done) {
await audioManager.getAudioScene().then(async function (data) {
if (data == audio.AudioScene.AUDIO_SCENE_VOICE_CHAT){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_003
* @tc.name : getAudioScene as VOIP to Ringtone - Promise - ENUM
* @tc.desc : getAudioScene as VOIP to Ringtone - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_003', 0, async function (done) {
await audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_RINGING).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
await audioManager.getAudioScene().then(async function (data) {
if (data == audio.AudioScene.AUDIO_SCENE_RINGING){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_004
* @tc.name : setAudioScene as VOIP - Promise - ENUM
* @tc.desc : setAudioScene as VOIP - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_004', 0, async function (done) {
await audioManager.setAudioScene(3).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_005
* @tc.name : getAudioScene as VOIP - Promise - ENUM
* @tc.desc : getAudioScene as VOIP - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_005', 0, async function (done) {
await audioManager.getAudioScene().then(async function (data) {
if (data == 3){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_006
* @tc.name : getAudioScene as VOIP to Ringtone - Promise - ENUM
* @tc.desc : getAudioScene as VOIP to Ringtone - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_006', 0, async function (done) {
await audioManager.setAudioScene(1).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
await audioManager.getAudioScene().then(async function (data) {
if (data == 1){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_007
* @tc.name : setAudioScene as VOIP - Callback - ENAME
* @tc.desc : setAudioScene as VOIP - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_007', 0, async function (done) {
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT, (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_008
* @tc.name : getAudioScene as VOIP - Callback - ENAME
* @tc.desc : getAudioScene as VOIP - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_008', 0, async function (done) {
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == audio.AudioScene.AUDIO_SCENE_VOICE_CHAT){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_009
* @tc.name : getAudioScene as VOIP to Ringtone - Callback - ENAME
* @tc.desc : getAudioScene as VOIP to Ringtone - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_009', 0, async function (done) {
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_RINGING,async (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
await sleep(100);
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == audio.AudioScene.AUDIO_SCENE_RINGING){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
}
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_010
* @tc.name : setAudioScene as VOIP - Callback - ENUM
* @tc.desc : setAudioScene as VOIP - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_010', 0, async function (done) {
audioManager.setAudioScene(3, (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_011
* @tc.name : getAudioScene as VOIP - Callback - ENUM
* @tc.desc : getAudioScene as VOIP - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_011', 0, async function (done) {
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == 3){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_012
* @tc.name : getAudioScene as VOIP to Ringtone - Callback - ENUM
* @tc.desc : getAudioScene as VOIP to Ringtone - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_012', 0, async function (done) {
audioManager.setAudioScene(1,async (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
await sleep(100);
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == 1){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
}
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_013
* @tc.name : setAudioScene as VOIP - Promise - Out Of Range
* @tc.desc : setAudioScene as VOIP - Out Of Range
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_013', 0, async function (done) {
await audioManager.setAudioScene(10).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(false).assertTrue();
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(true).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_014
* @tc.name : setAudioScene as VOIP - Callback - Out Of Range
* @tc.desc : setAudioScene as VOIP - Out Of Range
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_014', 0, async function (done) {
audioManager.setAudioScene(-1, (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(true).assertTrue();
}
else
{
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(false).assertTrue();
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_015
* @tc.name : setAudioScene as AUDIO_SCENE_RINGING - Promise - ENUM
* @tc.desc : setAudioScene as AUDIO_SCENE_RINGING - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_015', 0, async function (done) {
await audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_RINGING).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_016
* @tc.name : getAudioScene as AUDIO_SCENE_RINGING - Promise - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_RINGING - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_016', 0, async function (done) {
await audioManager.getAudioScene().then(async function (data) {
if (data == audio.AudioScene.AUDIO_SCENE_RINGING){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_017
* @tc.name : getAudioScene as Ringtone to VOIP - Promise - ENUM
* @tc.desc : getAudioScene as Ringtone to VOIP - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_017', 0, async function (done) {
await audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
await audioManager.getAudioScene().then(async function (data) {
if (data == audio.AudioScene.AUDIO_SCENE_VOICE_CHAT){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_018
* @tc.name : setAudioScene as AUDIO_SCENE_RINGING - Promise - ENUM
* @tc.desc : setAudioScene as AUDIO_SCENE_RINGING - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_018', 0, async function (done) {
await audioManager.setAudioScene(1).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_019
* @tc.name : getAudioScene as AUDIO_SCENE_RINGING - Promise - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_RINGING - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_019', 0, async function (done) {
await audioManager.getAudioScene().then(async function (data) {
if (data == 1){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_020
* @tc.name : getAudioScene as Ringtone to VOIP - Promise - ENUM
* @tc.desc : getAudioScene as Ringtone to VOIP - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_020', 0, async function (done) {
await audioManager.setAudioScene(3).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
await audioManager.getAudioScene().then(async function (data) {
if (data == 3){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_021
* @tc.name : setAudioScene as AUDIO_SCENE_RINGING - Callback - ENAME
* @tc.desc : setAudioScene as AUDIO_SCENE_RINGING - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_021', 0, async function (done) {
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_RINGING, (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_022
* @tc.name : getAudioScene as AUDIO_SCENE_RINGING - Callback - ENAME
* @tc.desc : getAudioScene as AUDIO_SCENE_RINGING - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_022', 0, async function (done) {
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == audio.AudioScene.AUDIO_SCENE_RINGING){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_023
* @tc.name : getAudioScene as Ringtone to VOIP - Callback - ENAME
* @tc.desc : getAudioScene as Ringtone to VOIP- ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_023', 0, async function (done) {
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
await sleep(100);
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == audio.AudioScene.AUDIO_SCENE_VOICE_CHAT){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
}
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_024
* @tc.name : setAudioScene as AUDIO_SCENE_RINGING - Callback - ENUM
* @tc.desc : setAudioScene as AUDIO_SCENE_RINGING - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_024', 0, async function (done) {
audioManager.setAudioScene(1, (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_025
* @tc.name : getAudioScene as AUDIO_SCENE_RINGING - Callback - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_RINGING - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_025', 0, async function (done) {
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == 1){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_026
* @tc.name : getAudioScene as Ringtone to VOIP - Callback - ENUM
* @tc.desc : getAudioScene as Ringtone to VOIP - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_026', 0, async function (done) {
audioManager.setAudioScene(3,async (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
await sleep(100);
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == 3){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
}
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_027
* @tc.name : setAudioScene as AUDIO_SCENE_PHONE_CALL - Promise - ENUM
* @tc.desc : setAudioScene as AUDIO_SCENE_PHONE_CALL - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_027', 0, async function (done) {
await audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_028
* @tc.name : getAudioScene as AUDIO_SCENE_PHONE_CALL - Promise - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_PHONE_CALL - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_028', 0, async function (done) {
await audioManager.getAudioScene().then(async function (data) {
if (data == audio.AudioScene.AUDIO_SCENE_PHONE_CALL){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_029
* @tc.name : getAudioScene as AUDIO_SCENE_PHONE_CALL to VOIP - Promise - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_PHONE_CALL to VOIP - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_029', 0, async function (done) {
await audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
await audioManager.getAudioScene().then(async function (data) {
if (data == audio.AudioScene.AUDIO_SCENE_VOICE_CHAT){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_030
* @tc.name : setAudioScene as AUDIO_SCENE_PHONE_CALL - Promise - ENUM
* @tc.desc : setAudioScene as AUDIO_SCENE_PHONE_CALL - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_030', 0, async function (done) {
await audioManager.setAudioScene(2).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_031
* @tc.name : getAudioScene as AUDIO_SCENE_PHONE_CALL - Promise - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_PHONE_CALL - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_031', 0, async function (done) {
await audioManager.getAudioScene().then(async function (data) {
if (data == 2){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_032
* @tc.name : getAudioScene as AUDIO_SCENE_PHONE_CALL to VOIP - Promise - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_PHONE_CALL to VOIP - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_032', 0, async function (done) {
await audioManager.setAudioScene(3).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
await audioManager.getAudioScene().then(async function (data) {
if (data == 3){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_033
* @tc.name : setAudioScene as AUDIO_SCENE_PHONE_CALL - Callback - ENAME
* @tc.desc : setAudioScene as AUDIO_SCENE_PHONE_CALL - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_033', 0, async function (done) {
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_034
* @tc.name : getAudioScene as AUDIO_SCENE_PHONE_CALL - Callback - ENAME
* @tc.desc : getAudioScene as AUDIO_SCENE_PHONE_CALL - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_034', 0, async function (done) {
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == audio.AudioScene.AUDIO_SCENE_PHONE_CALL){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_035
* @tc.name : getAudioScene as AUDIO_SCENE_PHONE_CALL to VOIP - Callback - ENAME
* @tc.desc : getAudioScene as AUDIO_SCENE_PHONE_CALL to VOIP- ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_035', 0, async function (done) {
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
await sleep(100);
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == audio.AudioScene.AUDIO_SCENE_VOICE_CHAT){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
}
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_036
* @tc.name : setAudioScene as AUDIO_SCENE_PHONE_CALL - Callback - ENUM
* @tc.desc : setAudioScene as AUDIO_SCENE_PHONE_CALL - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_036', 0, async function (done) {
audioManager.setAudioScene(2, (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_037
* @tc.name : getAudioScene as AUDIO_SCENE_PHONE_CALL - Callback - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_PHONE_CALL - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_037', 0, async function (done) {
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == 2){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_038
* @tc.name : getAudioScene as Ringtone to VOIP - Callback - ENUM
* @tc.desc : getAudioScene as Ringtone to VOIP - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_038', 0, async function (done) {
audioManager.setAudioScene(3,async (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
await sleep(100);
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == 3){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
}
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_039
* @tc.name : setAudioScene as AUDIO_SCENE_DEFAULT - Promise - ENUM
* @tc.desc : setAudioScene as AUDIO_SCENE_DEFAULT - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_039', 0, async function (done) {
await audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_DEFAULT).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_040
* @tc.name : getAudioScene as AUDIO_SCENE_DEFAULT - Promise - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_DEFAULT - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_040', 0, async function (done) {
await audioManager.getAudioScene().then(async function (data) {
if (data == audio.AudioScene.AUDIO_SCENE_DEFAULT){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_041
* @tc.name : getAudioScene as AUDIO_SCENE_DEFAULT to VOIP - Promise - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_DEFAULT to VOIP - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_041', 0, async function (done) {
await audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
await audioManager.getAudioScene().then(async function (data) {
if (data == audio.AudioScene.AUDIO_SCENE_VOICE_CHAT){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_042
* @tc.name : setAudioScene as AUDIO_SCENE_DEFAULT - Promise - ENUM
* @tc.desc : setAudioScene as AUDIO_SCENE_DEFAULT - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_042', 0, async function (done) {
await audioManager.setAudioScene(0).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_043
* @tc.name : getAudioScene as AUDIO_SCENE_DEFAULT - Promise - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_DEFAULT - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_043', 0, async function (done) {
await audioManager.getAudioScene().then(async function (data) {
if (data == 0){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_044
* @tc.name : getAudioScene as AUDIO_SCENE_DEFAULT to VOIP - Promise - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_DEFAULT to VOIP - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_044', 0, async function (done) {
await audioManager.setAudioScene(3).then(async function () {
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
await audioManager.getAudioScene().then(async function (data) {
if (data == 3){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getAudioScene : ERROR : '+err.message);
resultFlag=false;
});
}).catch((err) => {
console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_045
* @tc.name : setAudioScene as AUDIO_SCENE_DEFAULT - Callback - ENAME
* @tc.desc : setAudioScene as AUDIO_SCENE_DEFAULT - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_045', 0, async function (done) {
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_DEFAULT, (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_046
* @tc.name : getAudioScene as AUDIO_SCENE_DEFAULT - Callback - ENAME
* @tc.desc : getAudioScene as AUDIO_SCENE_DEFAULT - ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_046', 0, async function (done) {
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == audio.AudioScene.AUDIO_SCENE_DEFAULT){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_047
* @tc.name : getAudioScene as AUDIO_SCENE_DEFAULT to VOIP - Callback - ENAME
* @tc.desc : getAudioScene as AUDIO_SCENE_DEFAULT to VOIP- ENAME
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_047', 0, async function (done) {
audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
await sleep(100);
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == audio.AudioScene.AUDIO_SCENE_VOICE_CHAT){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
}
});
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_048
* @tc.name : setAudioScene as AUDIO_SCENE_DEFAULT - Callback - ENUM
* @tc.desc : setAudioScene as AUDIO_SCENE_DEFAULT - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_048', 0, async function (done) {
audioManager.setAudioScene(0, (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
expect(true).assertTrue();
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_049
* @tc.name : getAudioScene as AUDIO_SCENE_DEFAULT - Callback - ENUM
* @tc.desc : getAudioScene as AUDIO_SCENE_DEFAULT - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_049', 0, async function (done) {
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == 0){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
done();
})
/* *
* @tc.number : SUB_AUDIO_CALL_AudioScene_050
* @tc.name : getAudioScene as Ringtone to VOIP - Callback - ENUM
* @tc.desc : getAudioScene as Ringtone to VOIP - ENUM
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_CALL_AudioScene_050', 0, async function (done) {
audioManager.setAudioScene(3,async (err) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else
{
await sleep(100);
console.info('AudioFrameworkRenderLog: setAudioScene : SUCCESS ');
audioManager.getAudioScene((err, data) => {
if (err) {
console.error(`AudioFrameworkRenderLog: setAudioScene : ERROR : ${err.message}`);
expect(false).assertTrue();
}
else {
if (data == 3){
console.info('AudioFrameworkRenderLog: getAudioScene : PASS : '+data);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkRenderLog: getAudioScene : FAIL : '+data);
expect(false).assertTrue();
}
}
});
await sleep(100);
}
});
done();
})
})
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:// www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import audio from '@ohos.multimedia.audio';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
describe('audioApiResponseTime', function () {
console.info('AudioFrameworkTestPerf: Running AudioManger API Perfomance Test');
var AUDIO_MEDIA = 3;
var AUDIO_RINGTONE = 2;
var MAX_VOL = 15;
var LOW_VOL = 5;
var MAXNUM = 1000;
var err;
beforeAll(function () {
console.info('AudioFrameworkTestPerf: beforeAll: Prerequisites at the test suite level');
})
beforeEach(function () {
console.info('AudioFrameworkTestPerf: beforeEach: Prerequisites at the test case level');
})
afterEach(function () {
console.info('AudioFrameworkTestPerf: afterEach: Test case-level clearance conditions');
})
afterAll(function () {
console.info('AudioFrameworkTestPerf: afterAll: Test suite-level cleanup condition');
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_001
* @tc.name : API Response - setVolume - Promise
* @tc.desc : Check setVolume API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_001', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.setVolume(AUDIO_RINGTONE,MAX_VOL);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise: setVolume Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: setVolume Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: setVolume Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_002
* @tc.name : API Response - setVolume - CallBack
* @tc.desc : Check setVolume API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_002', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.setVolume(AUDIO_MEDIA,LOW_VOL,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: setVolume Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: setVolume Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: setVolume Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_003
* @tc.name : API Response - getVolume - Promise
* @tc.desc : Check getVolume API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_003', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getVolume(AUDIO_RINGTONE);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise: getVolume Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: getVolume Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: getVolume Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_004
* @tc.name : API Response - getVolume - CallBack
* @tc.desc : Check getVolume API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_004', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getVolume(AUDIO_MEDIA,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: getVolume Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: getVolume Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: getVolume Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_005
* @tc.name : API Response - getMinVolume - Promise
* @tc.desc : Check getMinVolume API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_005', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getMinVolume(AUDIO_MEDIA);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : getMinVolume Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: getMinVolume Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: getMinVolume Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_006
* @tc.name : API Response - getMinVolume - CallBack
* @tc.desc : Check getMinVolume API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_006', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getMinVolume(AUDIO_RINGTONE,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: getMinVolume Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: getMinVolume Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: getMinVolume Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_007
* @tc.name : API Response - getMaxVolume - Promise
* @tc.desc : Check getMaxVolume API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_007', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getMaxVolume(AUDIO_MEDIA);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : getMaxVolume Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: getMaxVolume Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: getMaxVolume Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_008
* @tc.name : API Response - getMaxVolume - CallBack
* @tc.desc : Check getMaxVolume API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_008', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getMaxVolume(AUDIO_RINGTONE,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: getMaxVolume Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: getMaxVolume Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: getMaxVolume Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_009
* @tc.name : API Response - mute - Promise
* @tc.desc : Check mute API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_009', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.mute(AUDIO_MEDIA,true);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : mute Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: mute Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: mute Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_010
* @tc.name : API Response - mute - CallBack
* @tc.desc : Check mute API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_010', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.mute(AUDIO_RINGTONE,true,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: mute Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: mute Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: mute Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_011
* @tc.name : API Response - isMute - Promise
* @tc.desc : Check isMute API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_011', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.isMute(AUDIO_MEDIA);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : isMute Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: isMute Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: isMute Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_012
* @tc.name : API Response - isMute - CallBack
* @tc.desc : Check isMute API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_012', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.isMute(AUDIO_RINGTONE,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: isMute Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: isMute Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: isMute Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_013
* @tc.name : API Response - isActive - Promise
* @tc.desc : Check isActive API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_013', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.isActive(AUDIO_MEDIA);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : isActive Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: isActive Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: isActive Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_014
* @tc.name : API Response - isActive - CallBack
* @tc.desc : Check isActive API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_014', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.isActive(AUDIO_RINGTONE,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: isActive Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: isActive Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: isActive Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_015
* @tc.name : API Response - setMicrophoneMute - Promise
* @tc.desc : Check setMicrophoneMute API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_015', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.setMicrophoneMute(true);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : setMicrophoneMute Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: setMicrophoneMute Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: setMicrophoneMute Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_016
* @tc.name : API Response - setMicrophoneMute - CallBack
* @tc.desc : Check setMicrophoneMute API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_016', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.setMicrophoneMute(false,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: setMicrophoneMute Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: setMicrophoneMute Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: setMicrophoneMute Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_017
* @tc.name : API Response - isMicrophoneMute - Promise
* @tc.desc : Check isMicrophoneMute API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_017', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.isMicrophoneMute();
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : isMicrophoneMute Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: isMicrophoneMute Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: isMicrophoneMute Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_018
* @tc.name : API Response - isMicrophoneMute - CallBack
* @tc.desc : Check isMicrophoneMute API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_018', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.isMicrophoneMute((err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: isMicrophoneMute Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: isMicrophoneMute Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: isMicrophoneMute Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_019
* @tc.name : API Response - setRingerMode - Promise
* @tc.desc : Check setRingerMode API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_019', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : setRingerMode Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: setRingerMode Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: setRingerMode Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_020
* @tc.name : API Response - setRingerMode - CallBack
* @tc.desc : Check setRingerMode API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_020', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.setRingerMode(audio.AudioRingMode.RINGER_MODE_VIBRATE,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: setRingerMode Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: setRingerMode Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: setRingerMode Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_021
* @tc.name : API Response - getRingerMode - Promise
* @tc.desc : Check getRingerMode API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_021', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getRingerMode();
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : getRingerMode Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: getRingerMode Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: getRingerMode Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_022
* @tc.name : API Response - getRingerMode - CallBack
* @tc.desc : Check getRingerMode API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_022', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getRingerMode((err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: getRingerMode Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: getRingerMode Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: getRingerMode Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_023
* @tc.name : API Response - setAudioParameter - Promise
* @tc.desc : Check setAudioParameter API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_023', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.setAudioParameter('AudioPerTemp1', '8 bit');
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : setAudioParameter Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: setAudioParameter Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: setAudioParameter Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_024
* @tc.name : API Response - setAudioParameter - CallBack
* @tc.desc : Check setAudioParameter API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_024', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.setAudioParameter('AudioPerTemp2', '44100',(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: setAudioParameter Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: setAudioParameter Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: setAudioParameter Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_025
* @tc.name : API Response - getAudioParameter - Promise
* @tc.desc : Check getAudioParameter API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_025', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getAudioParameter('AudioPerTemp1');
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : getAudioParameter Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: getAudioParameter Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: getAudioParameter Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_026
* @tc.name : API Response - getAudioParameter - CallBack
* @tc.desc : Check getAudioParameter API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_026', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getAudioParameter('AudioPerTemp2',(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: getAudioParameter Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: getAudioParameter Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: getAudioParameter Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_027
* @tc.name : API Response - getDevices - Promise
* @tc.desc : Check getDevices API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_027', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getDevices(audio.DeviceFlag.INPUT_DEVICES_FLAG);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : getDevices Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: getDevices Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: getDevices Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_028
* @tc.name : API Response - getDevices - CallBack
* @tc.desc : Check getDevices API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_028', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: getDevices Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: getDevices Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: getDevices Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_029
* @tc.name : API Response - setDeviceActive - Promise
* @tc.desc : Check setDeviceActive API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_029', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.setDeviceActive(audio.ActiveDeviceType.SPEAKER,true);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : setDeviceActive Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: setDeviceActive Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: setDeviceActive Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_030
* @tc.name : API Response - setDeviceActive - CallBack
* @tc.desc : Check setDeviceActive API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_030', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.setDeviceActive(audio.ActiveDeviceType.SPEAKER,true,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: setDeviceActive Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: setDeviceActive Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: setDeviceActive Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_031
* @tc.name : API Response - isDeviceActive - Promise
* @tc.desc : Check isDeviceActive API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_031', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.isDeviceActive(audio.ActiveDeviceType.SPEAKER);
};
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: Promise : isDeviceActive Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: Promise: isDeviceActive Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: Promise: isDeviceActive Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_Performance_032
* @tc.name : API Response - isDeviceActive - CallBack
* @tc.desc : Check isDeviceActive API Response time
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_Performance_032', 0, function (done) {
let audioManagerPerf = audio.getAudioManager();
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
audioManagerPerf.isDeviceActive(audio.ActiveDeviceType.SPEAKER,(err, value) => {
if (err) {
console.error(`AudioFrameworkTestPerf: callback : ERROR : ${err.message}`);
expect(false).assertTrue();
}
});
}
let waitTime = new Date().getTime()-startTime;
let avgTime = waitTime/MAXNUM;
console.info(`AudioFrameworkTestPerf: CallBack: isDeviceActive Wait Time : ${waitTime}`);
if (avgTime<10)
{
console.info(`AudioFrameworkTestPerf: CallBack: isDeviceActive Average Time: PASS : ${avgTime}`);
expect(true).assertTrue();
}
else{
console.info(`AudioFrameworkTestPerf: CallBack: isDeviceActive Average Time: FAIL : ${avgTime}`);
expect(false).assertTrue();
}
done();
})
})
\ No newline at end of file
...@@ -14,4 +14,8 @@ ...@@ -14,4 +14,8 @@
*/ */
require('./AudioFramework.test.js') require('./AudioFramework.test.js')
require('./AudioPerf.test.js')
require('./AudioRenderer.test.js')
require('./SR000GHLLV.test.js')
require('./AudioCall.test.js')
require('./SR000GHQBN.test.js')
\ No newline at end of file
因为 它太大了无法显示 source diff 。你可以改为 查看blob
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:// www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import audio from '@ohos.multimedia.audio';
import fileio from '@ohos.fileio';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
describe('audioManger', function () {
console.info('AudioFrameworkTest: Create AudioManger Object JS Framework');
const audioManager = audio.getAudioManager();
var deviceRoleValue = null;
var deviceTypeValue = null;
var volErrorMesg = 'Error, Operation not supported or Failed';
var audioMedia = 3;
var audioRingtone = 2;
var minVol = 0;
var maxVol = 15;
var lowVol = 5;
var highVol = 14;
var outOfRangeVol = 28;
var longValue = '28374837458743875804735081439085918459801437584738967509184509813904850914375904790589104801843';
function sleep (ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function displayDeviceProp(value, index, array) {
var devRoleName;
var devTypeName;
if (value.deviceRole==1) {
devRoleName = 'INPUT_DEVICE';
}
else if (value.deviceRole==2) {
devRoleName = 'OUTPUT_DEVICE ';
}
else {
devRoleName = 'ERROR : UNKNOWN : '+value.deviceRole;
}
if (value.deviceType == 1) {
devTypeName = 'EARPIECE';
}
else if (value.deviceType == 2){
devTypeName = 'SPEAKER';
}
else if (value.deviceType == 3){
devTypeName = 'WIRED_HEADSET';
}
else if (value.deviceType == 7){
devTypeName = 'BLUETOOTH_SCO';
}
else if (value.deviceType == 8){
devTypeName = 'BLUETOOTH_A2DP';
}
else if (value.deviceType == 15){
devTypeName = 'MIC';
}
else {
devTypeName = 'ERROR : UNKNOWN :'+value.deviceType;
}
console.info(`AudioFrameworkTest: device role: ${devRoleName}`);
deviceRoleValue = value.deviceRole;
console.info(`AudioFrameworkTest: device type: ${devTypeName}`);
deviceTypeValue = value.deviceType;
}
beforeAll(function () {
console.info('AudioFrameworkTest: beforeAll: Prerequisites at the test suite level');
})
beforeEach(function () {
console.info('AudioFrameworkTest: beforeEach: Prerequisites at the test case level');
})
afterEach(async function () {
console.info('AudioFrameworkTest: afterEach: Test case-level clearance conditions');
await sleep(1000);
})
afterAll(async function () {
console.info('AudioFrameworkTest: afterAll: Test suite-level cleanup condition');
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_getAudioManger_001
* @tc.name : getAudioManger is Not returned Empty
* @tc.desc : Check getAudioManger is not empty
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_getAudioManger_001', 0, function (done) {
if(audioManager!=null){
console.info('AudioFrameworkTest: getAudioManger : PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: getAudioManger : FAIL');
expect(false).assertTrue();
}
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_PR_getDevices_output_001
* @tc.name : getDevices - Output device - Promise - ENAME
* @tc.desc : getDevices - Output device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_PR_getDevices_output_001', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
const promise = audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG)
promise.then(function (value) {
console.info('AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : FAIL');
expect(false).assertTrue();
}
});
await promise;
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_PR_getDevices_output_enum_002
* @tc.name : getDevices - Output device - Promise - ENAME -
* @tc.desc : getDevices - Output device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_PR_getDevices_output_enum_002', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
const promise = audioManager.getDevices(1)
promise.then(function (value) {
console.info('AudioFrameworkTest: Promise: getDevices OUTPUT_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Promise: getDevices : OUTPUT_DEVICES_FLAG : FAIL');
expect(false).assertTrue();
}
});
await promise;
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_PR_getDevices_input_003
* @tc.name : getDevices - Input device - Promise - ENAME
* @tc.desc : getDevices - Input device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_PR_getDevices_input_003', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
const promise = audioManager.getDevices(audio.DeviceFlag.INPUT_DEVICES_FLAG);
promise.then(function (value) {
console.info('AudioFrameworkTest: Promise: getDevices INPUT_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Promise: getDevices : INPUT_DEVICES_FLAG : PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Promise: getDevices : INPUT_DEVICES_FLAG : FAIL');
expect(false).assertTrue();
}
});
await promise;
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_PR_getDevices_input_enum_004
* @tc.name : getDevices - Input device - Promise - ENAME
* @tc.desc : getDevices - Input device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_PR_getDevices_input_enum_004', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
const promise = audioManager.getDevices(2);
promise.then(function (value) {
console.info('AudioFrameworkTest: Promise: getDevices INPUT_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Promise: getDevices : INPUT_DEVICES_FLAG : PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Promise: getDevices : INPUT_DEVICES_FLAG : FAIL');
expect(false).assertTrue();
}
});
await promise;
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_PR_getDevices_all_005
* @tc.name : getDevices - ALL device - Promise - ENAME
* @tc.desc : getDevices - ALL device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_PR_getDevices_all_005', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
const promise = audioManager.getDevices(audio.DeviceFlag.ALL_DEVICES_FLAG);
promise.then(function (value) {
console.info('AudioFrameworkTest: Promise: getDevices ALL_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Promise: getDevices : ALL_DEVICES_FLAG : PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Promise: getDevices : ALL_DEVICES_FLAG : FAIL');
expect(false).assertTrue();
}
});
await promise;
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_PR_getDevices_all_enum_006
* @tc.name : getDevices - ALL device - Promise - ENAME
* @tc.desc : getDevices - ALL device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_PR_getDevices_all_enum_006', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
const promise = audioManager.getDevices(3);
promise.then(function (value) {
console.info('AudioFrameworkTest: Promise: getDevices ALL_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Promise: getDevices : ALL_DEVICES_FLAG : PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Promise: getDevices : ALL_DEVICES_FLAG : FAIL');
expect(false).assertTrue();
}
});
await promise;
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_CB_getDevices_OUT_007
* @tc.name : getDevices - Output device - Callback - ENAME
* @tc.desc : getDevices - Output device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_CB_getDevices_OUT_007', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => {
console.info('AudioFrameworkTest: Callback: getDevices OUTPUT_DEVICES_FLAG');
if (err) {
console.error(`AudioFrameworkTest: Callback: OUTPUT_DEVICES_FLAG: failed to get devices ${err.message}`);
expect().assertFail();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices OUTPUT_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Callback: getDevices : OUTPUT_DEVICES_FLAG : PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices : OUTPUT_DEVICES_FLAG : FAIL');
expect(false).assertTrue();
}
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_CB_getDevices_OUT_ENUM_008
* @tc.name : getDevices - Output device - Callback - ENAME
* @tc.desc : getDevices - Output device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_CB_getDevices_OUT_ENUM_008', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
audioManager.getDevices(1, (err, value) => {
console.info('AudioFrameworkTest: Callback: getDevices OUTPUT_DEVICES_FLAG');
if (err) {
console.error(`AudioFrameworkTest: Callback: OUTPUT_DEVICES_FLAG: failed to get devices ${err.message}`);
expect().assertFail();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices OUTPUT_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Callback: getDevices : OUTPUT_DEVICES_FLAG : PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices : OUTPUT_DEVICES_FLAG : FAIL');
expect(false).assertTrue();
}
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_CB_getDevices_INPUT_009
* @tc.name : getDevices - Input device - Callback - ENAME
* @tc.desc : getDevices - Input device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_CB_getDevices_INPUT_009', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
audioManager.getDevices(audio.DeviceFlag.INPUT_DEVICES_FLAG, (err, value) => {
console.info('AudioFrameworkTest: Callback: getDevices INPUT_DEVICES_FLAG');
if (err) {
console.error(`AudioFrameworkTest: Callback: INPUT_DEVICES_FLAG: failed to get devices ${err.message}`);
expect().assertFail();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices INPUT_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Callback: getDevices : INPUT_DEVICES_FLAG: PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices : INPUT_DEVICES_FLAG: FAIL');
expect(false).assertTrue();
}
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_CB_getDevices_INPUT_ENUM_010
* @tc.name : getDevices - Input device - Callback - ENAME
* @tc.desc : getDevices - Input device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_CB_getDevices_INPUT_ENUM_010', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
audioManager.getDevices(2, (err, value) => {
console.info('AudioFrameworkTest: Callback: getDevices INPUT_DEVICES_FLAG');
if (err) {
console.error(`AudioFrameworkTest: Callback: INPUT_DEVICES_FLAG: failed to get devices ${err.message}`);
expect().assertFail();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices INPUT_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Callback: getDevices : INPUT_DEVICES_FLAG: PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices : INPUT_DEVICES_FLAG: FAIL');
expect(false).assertTrue();
}
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_CB_getDevices_All_011
* @tc.name : getDevices - ALL device - Callback - ENAME
* @tc.desc : getDevices - ALL device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_getDevices_All_011', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
audioManager.getDevices(audio.DeviceFlag.ALL_DEVICES_FLAG, (err, value) => {
console.info('AudioFrameworkTest: Callback: getDevices ALL_DEVICES_FLAG');
if (err) {
console.error(`AudioFrameworkTest: Callback: ALL_DEVICES_FLAG: failed to get devices ${err.message}`);
expect().assertFail();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices ALL_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Callback: getDevices : ALL_DEVICES_FLAG: PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices : ALL_DEVICES_FLAG: FAIL');
expect(false).assertTrue();
}
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_CB_getDevices_All_ENUM_012
* @tc.name : getDevices - ALL device - Callback - ENAME
* @tc.desc : getDevices - ALL device
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_CB_getDevices_All_ENUM_012', 0, async function (done) {
deviceRoleValue = null;
deviceTypeValue = null;
audioManager.getDevices(3, (err, value) => {
console.info('AudioFrameworkTest: Callback: getDevices ALL_DEVICES_FLAG');
if (err) {
console.error(`AudioFrameworkTest: Callback: ALL_DEVICES_FLAG: failed to get devices ${err.message}`);
expect().assertFail();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices ALL_DEVICES_FLAG');
value.forEach(displayDeviceProp);
if (deviceTypeValue != null && deviceRoleValue != null){
console.info('AudioFrameworkTest: Callback: getDevices : ALL_DEVICES_FLAG: PASS');
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Callback: getDevices : ALL_DEVICES_FLAG: FAIL');
expect(false).assertTrue();
}
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_013
* @tc.name : setDeviceActive - BLUETOOTH_SCO - Activate - Promise
* @tc.desc : Activate BLUETOOTH_SCO - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_013', 0, async function (done) {
await audioManager.setDeviceActive(audio.ActiveDeviceType.BLUETOOTH_SCO,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : BLUETOOTH_SCO: Activate');
audioManager.isDeviceActive(audio.ActiveDeviceType.BLUETOOTH_SCO).then(function (value){
if(value==true){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Activate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Activate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Activate : FAIL : Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_ENUM_014
* @tc.name : setDeviceActive - BLUETOOTH_SCO - Activate - Promise
* @tc.desc : Activate BLUETOOTH_SCO - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_ENUM_014', 0, async function (done) {
await audioManager.setDeviceActive(7,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : BLUETOOTH_SCO: Activate');
audioManager.isDeviceActive(7).then(function (value){
if(value==true){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Activate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Activate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Activate : FAIL : Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_015
* @tc.name : setDeviceActive - SPEAKER - deactivate - Promise
* @tc.desc : Deactivate speaker - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_015', 0, async function (done) {
await audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER,false).then(function (){
// Setting device active ENUM 2 = SPEAKER
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : SPEAKER: Deactivate');
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then(function (value){
if(value==false){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Deactivate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Deactivate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Deactivate : FAIL : Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_ENUM_016
* @tc.name : setDeviceActive - SPEAKER - deactivate - Promise
* @tc.desc : Deactivate speaker - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_ENUM_016', 0, async function (done) {
await audioManager.setDeviceActive(2,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : SPEAKER: Active');
});
await audioManager.setDeviceActive(2,false).then(function (){
// Setting device active ENUM 2 = SPEAKER
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : SPEAKER: Deactivate');
audioManager.isDeviceActive(2).then(function (value){
if(value==false){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Deactivate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Deactivate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Deactivate : FAIL : Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_017
* @tc.name : setDeviceActive - SPEAKER - Activate - Promise
* @tc.desc : Activate speaker - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_017', 0, async function (done) {
await audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : SPEAKER: Activate');
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then(function (value){
if(value==true){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Activate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Activate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Activate : FAIL :Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_ENUM_018
* @tc.name : setDeviceActive - SPEAKER - Activate - Promise
* @tc.desc : Activate speaker - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_ENUM_018', 0, async function (done) {
await audioManager.setDeviceActive(2,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : SPEAKER: Activate');
audioManager.isDeviceActive(2).then(function (value){
if(value==true){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Activate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Activate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : SPEAKER: Activate : FAIL :Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_019
* @tc.name : setDeviceActive - BLUETOOTH_SCO - deactivate - Promise
* @tc.desc : Deactivate BLUETOOTH_SCO - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_019', 0, async function (done) {
await audioManager.setDeviceActive(audio.ActiveDeviceType.BLUETOOTH_SCO,false).then(function (){
// Setting device active ENUM 3 = BLUETOOTH_SCO
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : BLUETOOTH_SCO: Deactivate');
audioManager.isDeviceActive(audio.ActiveDeviceType.BLUETOOTH_SCO).then(function (value){
if(value==false){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Deactivate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Deactivate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Deactivate : FAIL : Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_ENUM_020
* @tc.name : setDeviceActive - BLUETOOTH_SCO - deactivate - Promise
* @tc.desc : Deactivate BLUETOOTH_SCO - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_ENUM_020', 0, async function (done) {
await audioManager.setDeviceActive(7,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : BLUETOOTH_SCO: Active');
});
await audioManager.setDeviceActive(7,false).then(function (){
// Setting device active ENUM 3 = BLUETOOTH_SCO
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : BLUETOOTH_SCO: Deactivate');
audioManager.isDeviceActive(7).then(function (value){
if(value==false){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Deactivate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Deactivate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : BLUETOOTH_SCO: Deactivate : FAIL : Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_CB_Activate_021
* @tc.name : setDeviceActive - BLUETOOTH_SCO - Activate - Callback
* @tc.desc : Activate BLUETOOTH_SCO - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_CB_Activate_021', 0, async function (done) {
audioManager.setDeviceActive(audio.ActiveDeviceType.BLUETOOTH_SCO,true, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Active');
audioManager.isDeviceActive(audio.ActiveDeviceType.BLUETOOTH_SCO,(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==true){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Active : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Active : FAIL :' +value);
expect(false).assertTrue();
}
done();
});
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_CB_Activate_ENUM_022
* @tc.name : setDeviceActive - BLUETOOTH_SCO - Activate - Callback
* @tc.desc : Activate BLUETOOTH_SCO - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_CB_Activate_ENUM_022', 0, async function (done) {
audioManager.setDeviceActive(7,true, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Active');
audioManager.isDeviceActive(7,(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==true){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Active : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Active : FAIL :' +value);
expect(false).assertTrue();
}
done();
});
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_CB_DEACTIVATE_023
* @tc.name : setDeviceActive - SPEAKER - deactivate - Callback
* @tc.desc : Deactivate speaker - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_CB_DEACTIVATE_023', 0, async function (done) {
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER,false, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Deactivate: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER,(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==false){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate : FAIL :' +value);
expect(false).assertTrue();
}
done();
});
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_CB_DEACTIVATE_ENUM_024
* @tc.name : setDeviceActive - SPEAKER - deactivate - Callback
* @tc.desc : Deactivate speaker - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_CB_DEACTIVATE_ENUM_024', 0, async function (done) {
await audioManager.setDeviceActive(2,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : SPEAKER : Active');
});
audioManager.setDeviceActive(2,false, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Deactivate: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
audioManager.isDeviceActive(2,(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==false){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Deactivate : FAIL :' +value);
expect(false).assertTrue();
}
done();
});
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_CB_ACTIVATE_025
* @tc.name : setDeviceActive - SPEAKER - activate - Callback
* @tc.desc : Activate speaker - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_CB_ACTIVATE_025', 0, async function (done) {
audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER,true, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER,(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==true){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Active : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Active : FAIL :' +value);
expect(false).assertTrue();
}
done();
});
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_CB_ACTIVATE_ENUM_026
* @tc.name : setDeviceActive - SPEAKER - activate - Callback
* @tc.desc : Activate speaker - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_CB_ACTIVATE_ENUM_026 ', 0, async function (done) {
audioManager.setDeviceActive(2,true, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
audioManager.isDeviceActive(2,(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==true){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Active : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : SPEAKER: Active : FAIL :' +value);
expect(false).assertTrue();
}
done();
});
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_DEACTIVATE_027
* @tc.name : setDeviceActive - BLUETOOTH_SCO - deactivate - Callback
* @tc.desc : Deactivate BLUETOOTH_SCO - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_DEACTIVATE_027', 0, async function (done) {
audioManager.setDeviceActive(audio.ActiveDeviceType.BLUETOOTH_SCO,false, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Deactivate: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Active');
audioManager.isDeviceActive(audio.ActiveDeviceType.BLUETOOTH_SCO,(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Deactivate: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==false){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Deactivate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Deactivate : FAIL :' +value);
expect(false).assertTrue();
}
done();
});
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_DEACTIVATE_ENUM_028
* @tc.name : setDeviceActive - BLUETOOTH_SCO - deactivate - Callback
* @tc.desc : Deactivate BLUETOOTH_SCO - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_DEACTIVATE_ENUM_028', 0, async function (done) {
await audioManager.setDeviceActive(7,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : BLUETOOTH_SCO : Active');
});
audioManager.setDeviceActive(7,false, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Deactivate: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Active');
audioManager.isDeviceActive(7,async(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Deactivate: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==false){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Deactivate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : BLUETOOTH_SCO: Deactivate : FAIL :' +value);
expect(false).assertTrue();
}
done();
await sleep(1000);
});
}
done();
});
await sleep(1000);
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_029
* @tc.name : setDeviceActive - WIRED_HEADSET - Activate - Promise
* @tc.desc : Activate HEADSET - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_029', 0, async function (done) {
await audioManager.setDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : WIRED_HEADSET: Activate');
audioManager.isDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET).then(function (value){
if(value==true){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Activate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Activate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Activate : FAIL : Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_ENUM_030
* @tc.name : setDeviceActive - WIRED_HEADSET - Activate - Promise
* @tc.desc : Activate WIRED_HEADSET - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_ENUM_030', 0, async function (done) {
await audioManager.setDeviceActive(3,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : WIRED_HEADSET: Activate');
audioManager.isDeviceActive(3).then(function (value){
if(value==true){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Activate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Activate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Activate : FAIL : Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_031
* @tc.name : setDeviceActive - WIRED_HEADSET - Deactivate - Promise
* @tc.desc : Activate HEADSET - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Activate_031', 0, async function (done) {
await audioManager.setDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET,false).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : WIRED_HEADSET: Deactivate');
audioManager.isDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET).then(function (value){
if(value==false){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Deactivate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Deactivate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Deactivate : FAIL : Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_ENUM_032
* @tc.name : setDeviceActive - WIRED_HEADSET - Deactivate - Promise
* @tc.desc : Activate WIRED_HEADSET - Promise
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_PR_Deactivate_ENUM_032', 0, async function (done) {
await audioManager.setDeviceActive(3,false).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : WIRED_HEADSET: Deactivate');
audioManager.isDeviceActive(3).then(function (value){
if(value==false){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Deactivate : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Deactivate : FAIL :' +value);
expect(false).assertTrue();
}
});
}).catch((err) => {
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Deactivate : FAIL : Error :' + err.message);
expect(false).assertTrue();
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_CB_ACTIVATE_033
* @tc.name : setDeviceActive - WIRED_HEADSET - activate - Callback
* @tc.desc : Activate WIRED_HEADSET - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_CB_ACTIVATE_033', 0, async function (done) {
audioManager.setDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET ,true, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET : Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET : Active');
audioManager.isDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET ,(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET : Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==true){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET : Active : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET : Active : FAIL :' +value);
expect(false).assertTrue();
}
done();
});
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_CB_ACTIVATE_ENUM_034
* @tc.name : setDeviceActive - WIRED_HEADSET - activate - Callback
* @tc.desc : Activate WIRED_HEADSET - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_CB_ACTIVATE_ENUM_034 ', 0, async function (done) {
audioManager.setDeviceActive(3,true, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active');
audioManager.isDeviceActive(3,(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==true){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET: Active : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET: Active : FAIL :' +value);
expect(false).assertTrue();
}
done();
});
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_CB_DEACTIVATE_035
* @tc.name : setDeviceActive - WIRED_HEADSET - Deactivate - Callback
* @tc.desc : Activate WIRED_HEADSET - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_CB_DEACTIVATE_035', 0, async function (done) {
audioManager.setDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET ,false, (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET : Deactive: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET : Deactive');
audioManager.isDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET ,(err, value) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET : Deactive: Error: ${err.message}`);
expect(false).assertTrue();
}
else if(value==true){
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET : Deactive : PASS :' +value);
expect(true).assertTrue();
}
else{
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET : Deactive : FAIL :' +value);
expect(false).assertTrue();
}
done();
});
}
done();
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_CB_DEACTIVATE_ENUM_036
* @tc.name : setDeviceActive - WIRED_HEADSET - Deactivate - Callback
* @tc.desc : Deactivate WIRED_HEADSET - Callback
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_setDeviceActive_CB_DEACTIVATE_ENUM_036 ', 0, async function (done) {
var setflag;
audioManager.setDeviceActive(3, true,async (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
audioManager.setDeviceActive(3, false, async (err) => {
if (err) {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Deactive: Error: ${err.message}`);
expect(false).assertTrue();
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Deactive');
audioManager.isDeviceActive(3, async (err, value) => {
if (!value) {
expect(true).assertTrue();
//console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET: Deactive : PASS :' + value);
//setflag = true ;
//console.info('AudioFrameworkTest: Device Test: setFlag' + setflag);
}
else {
console.info('AudioFrameworkTest: Device Test: Callback : isDeviceActive : WIRED_HEADSET: Deactive : FAIL :' + value);
setflag = false ;
console.info('AudioFrameworkTest: Device Test: setFlag' + setflag);
expect(false).assertTrue();
}
done();
});
await sleep(100);
}
done();
});
await sleep(1000);
}
});
done();
await sleep(1000);
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_ON_setDeviceActive_SPEAKER_037
* @tc.name : setDeviceActive - SPEAKER
* @tc.desc : Listner on speaker active
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_ON_setDeviceActive_SPEAKER_037', 0, async function (done) {
await audioManager.setDeviceActive(audio.DeviceType.SPEAKER,false).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
}).catch ((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Activate: Error: ${err.message}`);
});
var setflag ;
audioManager.on('deviceChange', (deviceChangeAction) => {
console.info('AudioManagerLog: device connected: ' + deviceChangeAction.type);
let deviceList = deviceChangeAction.deviceDescriptors;
for (let i = 0; i < deviceList.length; i++) {
console.info('AudioManagerLog: device role: ' + deviceList[i].deviceRole);
console.info('AudioManagerLog: device type: ' + deviceList[i].deviceType);
}
if (deviceList[0].deviceType == 2) {
console.info('AudioFrameworkTest: Device Test: ON : SPEAKER ACTIVE : PASS :' +deviceList[0].deviceType);
setflag = true;
console.info('AudioManagerLog: setFlag is : ' + setflag);
expect(setflag).assertTrue();
done();
} else {
console.info('AudioFrameworkTest: Device Test: ON : SPEAKER ACTIVE : FAIL :' +deviceList[0].deviceType);
setflag = false;
console.info('AudioManagerLog: setFlag is : ' + setflag);
expect(setflag).assertTrue();
done();
}
});
await audioManager.setDeviceActive(audio.DeviceType.SPEAKER,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
}).catch ((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Activate: Error: ${err.message}`);
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_ON_setDeviceActive_SPEAKER_ENUM_038
* @tc.name : setDeviceActive - SPEAKER
* @tc.desc : Listner on speaker active
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_ON_setDeviceActive_SPEAKER_ENUM_038', 0, async function (done) {
audioManager.setDeviceActive(2,false).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : SPEAKER: Deactive');
});
audioManager.on('deviceChange', (deviceChangeAction) => {
console.info('AudioManagerLog: device connected: ' + deviceChangeAction.type);
let deviceList = deviceChangeAction.deviceDescriptors;
for (let i = 0; i < deviceList.length; i++) {
console.info('AudioManagerLog: device role: ' + deviceList[i].deviceRole);
console.info('AudioManagerLog: device type: ' + deviceList[i].deviceType);
}
if (deviceList[0].deviceType == 2) {
console.info('AudioFrameworkTest: Device Test: ON : SPEAKER ACTIVE : PASS :' +deviceList[0].deviceType);
expect(true).assertTrue();
done();
} else {
console.info('AudioFrameworkTest: Device Test: ON : SPEAKER ACTIVE : FAIL :' +deviceList[0].deviceType);
expect(false).assertTrue();
done();
}
});
await audioManager.setDeviceActive(2,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
}).catch ((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Activate: Error: ${err.message}`);
});
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_ON_setDeviceActive_BLUETOOTH_SCO_039
* @tc.name : setDeviceActive - BLUETOOTH_SCO
* @tc.desc : Listner on speaker active
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_ON_setDeviceActive_BLUETOOTH_SCO_039', 0, async function (done) {
audioManager.on('deviceChange', (deviceChangeAction) => {
console.info('AudioManagerLog: device connected: ' + deviceChangeAction.type);
let deviceList = deviceChangeAction.deviceDescriptors;
for (let i = 0; i < deviceList.length; i++) {
console.info('AudioManagerLog: device role: ' + deviceList[i].deviceRole);
console.info('AudioManagerLog: device type: ' + deviceList[i].deviceType);
}
if (deviceList[0].deviceType == 7) {
console.info('AudioFrameworkTest: Device Test: ON : SPEAKER ACTIVE : PASS :' +deviceList[0].deviceType);
expect(true).assertTrue();
done();
} else {
console.info('AudioFrameworkTest: Device Test: ON : SPEAKER ACTIVE : FAIL :' +deviceList[0].deviceType);
expect(false).assertTrue();
done();
}
});
await audioManager.setDeviceActive(audio.ActiveDeviceType.BLUETOOTH_SCO,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Active');
}).catch ((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Activate: Error: ${err.message}`);
});
done();
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_ON_setDeviceActive_BLUETOOTH_SCO_ENUM_040
* @tc.name : setDeviceActive - BLUETOOTH_SCO
* @tc.desc : Listner on speaker active
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_ON_setDeviceActive_BLUETOOTH_SCO_ENUM_040', 0, async function (done) {
audioManager.setDeviceActive(7,false).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : BLUETOOTH_SCO: Deactive');
});
audioManager.on('deviceChange', (deviceChangeAction) => {
console.info('AudioManagerLog: device connected: ' + deviceChangeAction.type);
let deviceList = deviceChangeAction.deviceDescriptors;
for (let i = 0; i < deviceList.length; i++) {
console.info('AudioManagerLog: device role: ' + deviceList[i].deviceRole);
console.info('AudioManagerLog: device type: ' + deviceList[i].deviceType);
}
if (deviceList[0].deviceType == 7) {
console.info('AudioFrameworkTest: Device Test: ON : BLUETOOTH_SCO ACTIVE : PASS :' +deviceList[0].deviceType);
expect(true).assertTrue();
done();
} else {
console.info('AudioFrameworkTest: Device Test: ON : BLUETOOTH_SCO ACTIVE : FAIL :' +deviceList[0].deviceType);
expect(false).assertTrue();
done();
}
});
await audioManager.setDeviceActive(7,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Active');
}).catch ((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : BLUETOOTH_SCO: Activate: Error: ${err.message}`);
});
done();
await sleep(1000);
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_ON_setDeviceActive_WIRED_HEADSET_041
* @tc.name : setDeviceActive - WIRED_HEADSET
* @tc.desc : Listner on WIRED_HEADSET active
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_ON_setDeviceActive_WIRED_HEADSET_ENUM_041', 0, async function (done) {
audioManager.on('deviceChange', (deviceChangeAction) => {
console.info('AudioManagerLog: device connected: ' + deviceChangeAction.type);
let deviceList = deviceChangeAction.deviceDescriptors;
for (let i = 0; i < deviceList.length; i++) {
console.info('AudioManagerLog: device role: ' + deviceList[i].deviceRole);
console.info('AudioManagerLog: device type: ' + deviceList[i].deviceType);
}
if (deviceList[0].deviceType == 3) {
console.info('AudioFrameworkTest: Device Test: ON : WIRED_HEADSET ACTIVE : PASS :' +deviceList[0].deviceType);
expect(true).assertTrue();
done();
} else {
console.info('AudioFrameworkTest: Device Test: ON : WIRED_HEADSET ACTIVE : FAIL :' +deviceList[0].deviceType);
expect(false).assertTrue();
done();
}
});
await audioManager.setDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active');
}).catch ((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Activate: Error: ${err.message}`);
});
done();
await sleep(1000);
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_ON_setDeviceActive_WIRED_HEADSET_ENUM_042
* @tc.name : setDeviceActive - WIRED_HEADSET
* @tc.desc : Listner on WIRED_HEADSET active
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_ON_setDeviceActive_WIRED_HEADSET_ENUM_042', 0, async function (done) {
let setflag;
audioManager.setDeviceActive(3,false).then(function (){
console.info('AudioFrameworkTest: Device Test: Promise : setDeviceActive : WIRED_HEADSET: Deactive');
});
audioManager.on('deviceChange', (deviceChangeAction) => {
console.info('AudioManagerLog: device connected: ' + deviceChangeAction.type);
let deviceList = deviceChangeAction.deviceDescriptors;
for (let i = 0; i < deviceList.length; i++) {
console.info('AudioManagerLog: device role: ' + deviceList[i].deviceRole);
console.info('AudioManagerLog: device type: ' + deviceList[i].deviceType);
}
if (deviceList[0].deviceType == 3) {
console.info('AudioFrameworkTest: Device Test: ON : WIRED_HEADSET ACTIVE : PASS :' +deviceList[0].deviceType);
setflag = true;
console.info('AudioManagerLog: device type: setFlag is ' + setflag);
expect(setflag).assertTrue();
done();
} else {
console.info('AudioFrameworkTest: Device Test: ON : WIRED_HEADSET ACTIVE : FAIL :' +deviceList[0].deviceType);
setflag = false;
console.info('AudioManagerLog: device type: setFlag is ' + setflag);
expect(false).assertTrue();
done();
}
});
await audioManager.setDeviceActive(3,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active');
}).catch ((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Activate: Error: ${err.message}`);
});
done();
await sleep(1000);
})
/* *
* @tc.number : SUB_AUDIO_MANAGER_ON_setDeviceActive_Combination1_043
* @tc.name : setDeviceActive - WIRED_HEADSET
* @tc.desc : Listner on WIRED_HEADSET active
* @tc.size : MEDIUM
* @tc.type : Function
* @tc.level : Level 0
*/
it('SUB_AUDIO_MANAGER_ON_setDeviceActive_Combination1_043', 0, async function (done) {
var setFalg ;
await audioManager.on('deviceChange', (deviceChangeAction) => {
console.info('AudioManagerLog: ON device connected: ' + deviceChangeAction.type);
let deviceList = deviceChangeAction.deviceDescriptors;
for (let i = 0; i < deviceList.length; i++) {
console.info('AudioManagerLog: device role: ' + deviceList[i].deviceRole);
console.info('AudioManagerLog: device type: ' + deviceList[i].deviceType);
}
});
await sleep(1000);
await audioManager.setDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active');
}).catch ((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Activate: Error: ${err.message}`);
});
await sleep(5000);
await audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Active');
}).catch ((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : SPEAKER: Activate: Error: ${err.message}`);
});
await sleep(5000);
await audioManager.setDeviceActive(audio.ActiveDeviceType.WIRED_HEADSET,true).then(function (){
console.info('AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Active Again');
}).catch ((err) => {
console.error(`AudioFrameworkTest: Device Test: Callback : setDeviceActive : WIRED_HEADSET: Activate Again: Error: ${err.message}`);
});
await sleep(5000);
await audioManager.isDeviceActive(3).then(function (value){
setFalg = value;
if(value == true){
if (setFalg == true){
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Activate : PASS :' +value);
console.info('AudioFrameworkTest: Device Test: after asseert');
}
}
else{
console.info('AudioFrameworkTest: Device Test: Promise : isDeviceActive : WIRED_HEADSET: Activate : FAIL :' +value);
}
});
console.info('AudioFrameworkTest: Device Test: after COMPLETE');
await sleep(1000);
expect(setFalg).assertTrue();
done();
})
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册