diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCall.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCall.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f7c8a0fb69c72fd1b14ebd8e235088bd3f281ad4 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCall.test.js @@ -0,0 +1,1970 @@ +// @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 diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioPerf.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioPerf.test.js new file mode 100644 index 0000000000000000000000000000000000000000..37a29f75b4677b33e643dca402fee24109b19511 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioPerf.test.js @@ -0,0 +1,1085 @@ +/* + * 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 diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRenderer.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRenderer.test.js new file mode 100644 index 0000000000000000000000000000000000000000..e25000b08494d709d64f69ddebbed3dee639ca2d --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRenderer.test.js @@ -0,0 +1,7858 @@ +/* + * 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 app from '@system.app'; +import ability_featureAbility from '@ohos.ability.featureAbility'; + +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; + +describe('audioRenderer', function () { + + const audioManager = audio.getAudioManager(); + console.info('AudioFrameworkRenderLog: Create AudioManger Object JS Framework'); + var mediaDir; + + 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('AudioFrameworkRenderLog: beforeAll: Prerequisites at the test suite level'); + mediaDir = await getPathName(); + }) + + beforeEach(async function () { + console.info('AudioFrameworkRenderLog: beforeEach: Prerequisites at the test case level'); + await sleep(1000); + }) + + afterEach(function () { + console.info('AudioFrameworkRenderLog: afterEach: Test case-level clearance conditions'); + }) + + afterAll(async function () { + console.info('AudioFrameworkRenderLog: afterAll: Test suite-level cleanup condition'); + }) + + function sleep (ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + async function playbackPromise (AudioRendererOptions, fpath, AudioScene) { + var resultFlag = '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); + return resultFlag; + }); + + 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); + resultFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message); + resultFlag=false; + }); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + 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); + resultFlag = false; + }); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + + 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); + resultFlag = false; + }); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + + 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); + resultFlag=false; + }); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + + 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); + resultFlag=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); + resultFlag=false; + }); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + resultFlag=true; + console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlag); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + resultFlag=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); + resultFlag=false; + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + return resultFlag; + } + + async function playbackCB (AudioRendererOptions, fpath){ + + var resultFlag = 'new'; + + console.info('AudioFrameworkRenderLog: CALLBACK : Audio Playback Function'); + + var audioRen; + + audio.createAudioRenderer(AudioRendererOptions,(err, data) => { + if (err) { + console.error(`AudioFrameworkRenderLog: AudioRender Created : Error: ${err.message}`); + resultFlag = false; + } + else { + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : SUCCESS'); + audioRen = data; + } + }); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + + await sleep(100); + + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + console.info('AudioFrameworkRenderLog: Callback : Audio Playback Function'); + + audioRen.start((err) => { + if (err) { + console.error(`AudioFrameworkRenderLog: Renderer start failed: Error: ${err.message}`); + resultFlag=false; + } + else { + console.info('AudioFrameworkRenderLog: Renderer started'); + } + }); + await sleep(100); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + var samplingRate; + audioRen.getStreamInfo(async (err, audioParamsGet) => { + await sleep(100); + if (err) { + console.log('AudioFrameworkRenderLog: getStreamInfo :ERROR: '+err.message); + resultFlag = false; + } + else { + 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); + samplingRate = audioParamsGet.samplingRate; + } + }); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + + audioRen.getRendererInfo(async (err, audioParamsGet) => { + await sleep(100); + if (err) { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + } + else { + 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); + } + }); + await sleep(100); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + + var bufferSize; + await audioRen.getBufferSize((err,data)=> { + if (err) { + console.info('AudioFrameworkRenderLog: getBufferSize :ERROR : '+err.message); + resultFlag=false; + } + else { + console.info('AudioFrameworkRenderLog: getBufferSize :SUCCESS '+data); + bufferSize=data; + } + }); + await sleep(100); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + + 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; + let rlen = 0; + console.info('AudioFrameworkRenderLog: File size : Removing header: ' +totalSize); + await sleep(100); +// var waitTime = (totalSize/88200); + var waitTime; + switch (samplingRate) { + case 44100: + waitTime = 10; + break; + case 8000: + waitTime = 60; + break; + case 32000: + waitTime = 30; + break; + case 64000: + waitTime = 4; + break; + case 96000: + waitTime = 2; + break; + case 11025: + waitTime = 45; + break; + case 12000: + waitTime = 20; + break; + case 16000: + waitTime = 10; + break; + case 22050: + waitTime = 10; + break; + case 24000: + waitTime = 6; + break; + case 48000: + waitTime = 2; + break; + default: + waitTime = 10; + break + } + + await sleep(100); + console.info('AudioFrameworkRenderLog: waitTime : ' +waitTime); + while (rlen < totalSize) { + let buf = new ArrayBuffer(bufferSize); + rlen += ss.readSync(buf); + console.info('BufferAudioFramework: bytes read from file: ' +rlen); + await audioRen.write(buf,(err, data) => { + if (err) { + console.error(`AudioFrameworkRenderLog: Buff write: Error: ${err.message}`); + resultFlag=false; + } + else { + console.info('BufferAudioFramework: Buff write successful : '); + resultFlag=true; + } + }); + await sleep(waitTime); + } + await sleep(2000); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + ss.closeSync(); + audioRen.drain((err, state) => { + if (err) { + console.error(`AudioFrameworkRenderLog: Renderer drain failed: Error: ${err.message}`); + resultFlag=false; + } + else { + console.info('AudioFrameworkRenderLog: Renderer drained'); + } + }); + await sleep(100); + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + audioRen.stop((err, state) => { + if (err) { + console.error(`AudioFrameworkRenderLog: Renderer stop failed: Error: ${err.message}`); + resultFlag=false; + } + else { + console.info('AudioFrameworkRenderLog: Renderer stopped'); + resultFlag=true; + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + } + }); + await sleep(100); + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + if (resultFlag == false){ + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + return resultFlag; + } + audioRen.release((err, state) => { + if (err) { + console.error(`AudioFrameworkRenderLog: Renderer release failed: Error: ${err.message}`); + resultFlag=false; + } + else { + console.info('AudioFrameworkRenderLog: Renderer released'); + } + }); + await sleep(100); + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + return resultFlag; + + } + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_001 + * @tc.name : AudioRenderer-Set1-Media + * @tc.desc : AudioRenderer with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_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_RENDERER_Play_audio_002 + * @tc.name : AudioRenderer-Set2-Media + * @tc.desc : AudioRenderer with parameter set 2 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_002', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_8000, + 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-8000-2SW.wav', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_003 + * @tc.name : AudioRenderer-Set3-Media + * @tc.desc : AudioRenderer with parameter set 3 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_003', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_32000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_U8, + 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-32000-1SW.wav', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_004 + * @tc.name : AudioRenderer-Set4-Media + * @tc.desc : AudioRenderer with parameter set 4 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_004', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_64000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + 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-64000-3SW.wav', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_005 + * @tc.name : AudioRenderer-Set5-Media + * @tc.desc : AudioRenderer with parameter set 5 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_005', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_96000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + 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-96000-4SW.wav', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_006 + * @tc.name : AudioRenderer-Set6-Media + * @tc.desc : AudioRenderer with parameter set 6 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_006', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_11025, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_U8, + 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-2C-11025-1SW.wav', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_007 + * @tc.name : AudioRenderer-Set7-Media + * @tc.desc : AudioRenderer with parameter set 7 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_007', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_12000, + channels: audio.AudioChannel.CHANNEL_2, + 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-2C-12000-2SW.wav', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_008 + * @tc.name : AudioRenderer-Set8-Media + * @tc.desc : AudioRenderer with parameter set 8 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_008', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_16000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + 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-2C-16000-3SW.wav', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_009 + * @tc.name : AudioRenderer-Set9-Media + * @tc.desc : AudioRenderer with parameter set 9 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_009', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_22050, + channels: audio.AudioChannel.CHANNEL_2, + 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-2C-22050-2SW.wav', audio.AudioScene.AUDIO_SCENE_PHONE_CALL); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_010 + * @tc.name : AudioRenderer-Set10-Media + * @tc.desc : AudioRenderer with parameter set 10 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_010', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_24000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + 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-2C-24000-3SW.wav', audio.AudioScene.AUDIO_SCENE_RINGING); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_011 + * @tc.name : AudioRenderer-Set11-Media + * @tc.desc : AudioRenderer with parameter set 11 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_011', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + 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-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_012 + * @tc.name : AudioRenderer-isStreamActive - UNKNOWN - UNKNOWN + * @tc.desc : AudioRenderer-isStreamActive - UNKNOWN - UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_012', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_013 + * @tc.name : AudioRenderer-isStreamActive - SPEECH - UNKNOWN + * @tc.desc : AudioRenderer-isStreamActive - SPEECH - UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_013', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_014 + * @tc.name : AudioRenderer-isStreamActive - MUSIC - UNKNOWN + * @tc.desc : AudioRenderer-isStreamActive - MUSIC - UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_014', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_015 + * @tc.name : AudioRenderer-isStreamActive - MOVIE - UNKNOWN + * @tc.desc : AudioRenderer-isStreamActive - MOVIE - UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_015', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_016 + * @tc.name : AudioRenderer-isStreamActive - SONIFICATION - UNKNOWN + * @tc.desc : AudioRenderer-isStreamActive - SONIFICATION - UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_016', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.RINGTONE).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_017 + * @tc.name : AudioRenderer-isStreamActive - RINGTONE - UNKNOWN + * @tc.desc : AudioRenderer-isStreamActive - RINGTONE - UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_017', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.RINGTONE).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_018 + * @tc.name : AudioRenderer-isStreamActive - UNKNOWN - MEDIA + * @tc.desc : AudioRenderer-isStreamActive - UNKNOWN - MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_018', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_019 + * @tc.name : AudioRenderer-isStreamActive - SPEECH - MEDIA + * @tc.desc : AudioRenderer-isStreamActive - SPEECH - MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_019', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.VOICE_ASSISTANT).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive VOICE_ASSISTANT: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive VOICE_ASSISTANT: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_020 + * @tc.name : AudioRenderer-isStreamActive - MUSIC - MEDIA + * @tc.desc : AudioRenderer-isStreamActive - MUSIC - MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_020', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_021 + * @tc.name : AudioRenderer-isStreamActive - MOVIE - MEDIA + * @tc.desc : AudioRenderer-isStreamActive - MOVIE - MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_021', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_022 + * @tc.name : AudioRenderer-isStreamActive - SONIFICATION - MEDIA + * @tc.desc : AudioRenderer-isStreamActive - SONOTIFICATION - MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_022', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.RINGTONE).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_023 + * @tc.name : AudioRenderer-isStreamActive - RINGTONE - MEDIA + * @tc.desc : AudioRenderer-isStreamActive - RINGTONE - MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_023', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.RINGTONE).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_024 + * @tc.name : AudioRenderer-isStreamActive - UNKNOWN - VOICE_COMMUNICATION + * @tc.desc : AudioRenderer-isStreamActive - UNKNOWN - VOICE_COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_024', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_025 + * @tc.name : AudioRenderer-isStreamActive - SPEECH - VOICE_COMMUNICATION + * @tc.desc : AudioRenderer-isStreamActive - SPEECH - VOICE_COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_025', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + 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=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.VOICE_CALL).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive VOICE_CALL: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive VOICE_CALL: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_026 + * @tc.name : AudioRenderer-isStreamActive - MUSIC - VOICE_COMMUNICATION + * @tc.desc : AudioRenderer-isStreamActive - MUSIC - VOICE_COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_026', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_027 + * @tc.name : AudioRenderer-isStreamActive - MOVIE - VOICE_COMMUNICATION + * @tc.desc : AudioRenderer-isStreamActive - MOVIE - VOICE_COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_027', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_028 + * @tc.name : AudioRenderer-isStreamActive - SONOTIFICATION - VOICE_COMMUNICATION + * @tc.desc : AudioRenderer-isStreamActive - SONOTIFICATION - VOICE_COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_028', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive MEDIA: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive MEDIA: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_029 + * @tc.name : AudioRenderer-isStreamActive - RINGTONE - VOICE_COMMUNICATION + * @tc.desc : AudioRenderer-isStreamActive - RINGTONE - VOICE_COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_029', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive MEDIA: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive MEDIA: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_030 + * @tc.name : AudioRenderer-isStreamActive - UNKNOWN - NOTIFICATION_RINGTONE + * @tc.desc : AudioRenderer-isStreamActive - UNKNOWN - NOTIFICATION_RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_030', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_031 + * @tc.name : AudioRenderer-isStreamActive - SPEECH - NOTIFICATION_RINGTONE + * @tc.desc : AudioRenderer-isStreamActive - SPEECH - NOTIFICATION_RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_031', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive MEDIA: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive MEDIA: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_032 + * @tc.name : AudioRenderer-isStreamActive - MUSIC - NOTIFICATION_RINGTONE + * @tc.desc : AudioRenderer-isStreamActive - MUSIC - NOTIFICATION_RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_032', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.RINGTONE).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive RENGITONE: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_033 + * @tc.name : AudioRenderer-isStreamActive - MOVIE - NOTIFICATION_RINGTONE + * @tc.desc : AudioRenderer-isStreamActive - MOVIE - NOTIFICATION_RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_033', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_034 + * @tc.name : AudioRenderer-isStreamActive - SONOTIFICATION - NOTIFICATION_RINGTONE + * @tc.desc : AudioRenderer-isStreamActive - SONOTIFICATION - NOTIFICATION_RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_034', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive MEDIA: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive MEDIA: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_035 + * @tc.name : AudioRenderer-isStreamActive - RINGTONE - NOTIFICATION_RINGTONE + * @tc.desc : AudioRenderer-isStreamActive - RINGTONE - NOTIFICATION_RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_035', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=false; + playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(2000); + + audioManager.isActive(audio.AudioVolumeType.RINGTONE).then(function (data) { + if(data == true){ + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: PASS :'+data); + resultFlag = true; + } + else { + console.log('AudioFrameworkTest: Promise : isActive RINGTONE: FAIL :'+data); + } + + }); + + await sleep(9000); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_036 + // * @tc.name : AudioRenderer-isStreamActive - UNKNOWN - VOICE_ASSISTANT + // * @tc.desc : AudioRenderer-isStreamActive - UNKNOWN - VOICE_ASSISTANT + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_036', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + + // var resultFlag=false; + // playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + // await sleep(2000); + + // audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + // if(data == true){ + // console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + // resultFlag = true; + // } + // else { + // console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + // } + + // }); + + // await sleep(9000); + + // console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_037 + // * @tc.name : AudioRenderer-isStreamActive - SPEECH - VOICE_ASSISTANT + // * @tc.desc : AudioRenderer-isStreamActive - SPEECH - VOICE_ASSISTANT + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_037', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_SPEECH, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + + // var resultFlag=false; + // playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + // await sleep(2000); + + // audioManager.isActive(audio.AudioVolumeType.VOICE_ASSISTANT).then(function (data) { + // if(data == true){ + // console.log('AudioFrameworkTest: Promise : isActive VOICE_ASSISTANT: PASS :'+data); + // resultFlag = true; + // } + // else { + // console.log('AudioFrameworkTest: Promise : isActive VOICE_ASSISTANT: FAIL :'+data); + // } + + // }); + + // await sleep(9000); + + // console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_038 + // * @tc.name : AudioRenderer-isStreamActive - MUSIC - VOICE_ASSISTANT + // * @tc.desc : AudioRenderer-isStreamActive - MUSIC - VOICE_ASSISTANT + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_038', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_MUSIC, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + + // var resultFlag=false; + // playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + // await sleep(2000); + + // audioManager.isActive(audio.AudioVolumeType.VOICE_ASSISTANT).then(function (data) { + // if(data == true){ + // console.log('AudioFrameworkTest: Promise : isActive VOICE_ASSISTANT: PASS :'+data); + // resultFlag = true; + // } + // else { + // console.log('AudioFrameworkTest: Promise : isActive VOICE_ASSISTANT: FAIL :'+data); + // } + + // }); + + // await sleep(9000); + + // console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_039 + // * @tc.name : AudioRenderer-isStreamActive - MOVIE - VOICE_ASSISTANT + // * @tc.desc : AudioRenderer-isStreamActive - MOVIE - VOICE_ASSISTANT + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_039', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_MOVIE, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + + // var resultFlag=false; + // playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + // await sleep(2000); + + // audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + // if(data == true){ + // console.log('AudioFrameworkTest: Promise : isActive Media: PASS :'+data); + // resultFlag = true; + // } + // else { + // console.log('AudioFrameworkTest: Promise : isActive Media: FAIL :'+data); + // } + + // }); + + // await sleep(9000); + + // console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_040 + // * @tc.name : AudioRenderer-isStreamActive - SONOTIFICATION - VOICE_ASSISTANT + // * @tc.desc : AudioRenderer-isStreamActive - SONOTIFICATION - VOICE_ASSISTANT + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_040', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + + // var resultFlag=false; + // playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + // await sleep(2000); + + // audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + // if(data == true){ + // console.log('AudioFrameworkTest: Promise : isActive MEDIA: PASS :'+data); + // resultFlag = true; + // } + // else { + // console.log('AudioFrameworkTest: Promise : isActive MEDIA: FAIL :'+data); + // } + + // }); + + // await sleep(9000); + + // console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_041 + // * @tc.name : AudioRenderer-isStreamActive - RINGTONE - VOICE_ASSISTANT + // * @tc.desc : AudioRenderer-isStreamActive - RINGTONE - VOICE_ASSISTANT + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_041', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_RINGTONE, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + + // var resultFlag=false; + // playbackPromise(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav', audio.AudioScene.AUDIO_SCENE_DEFAULT); + // await sleep(2000); + + // audioManager.isActive(audio.AudioVolumeType.MEDIA).then(function (data) { + // if(data == true){ + // console.log('AudioFrameworkTest: Promise : isActive MEDIA: PASS :'+data); + // resultFlag = true; + // } + // else { + // console.log('AudioFrameworkTest: Promise : isActive MEDIA: FAIL :'+data); + // } + + // }); + + // await sleep(9000); + + // console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_042 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set1 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_042', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_043 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set2 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set2 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_043', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_044 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set3 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set3 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_044', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_045 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set4 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set4 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_045', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_046 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set5 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set5 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_046', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_047 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set6 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set6 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_047', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_048 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set7 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set7 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_048', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_049 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set8 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set8 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_049', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_050 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set9 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set9 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_050', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_051 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set10 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set10 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_051', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_052 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set11 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set11 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_052', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_053 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set12 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set12 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_053', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_054 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set13 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set13 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_054', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_055 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set14 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set14 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_055', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + 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=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_056 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set15 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set15 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_056', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_057 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set16 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set16 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_057', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_058 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set17 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set17 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_058', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_059 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set18 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set18 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_059', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_060 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set19 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set19 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_060', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_061 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set20 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set20 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_061', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_062 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set21 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set21 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_062', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_063 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set22 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set22 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_063', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_064 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set23 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set23 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_064', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_065 + * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set24 + * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set24 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_065', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag=true; + + 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); + resultFlag = false; + }); + + 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); + if (audioParamsGet.content == AudioRendererInfo.content){ + console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + resultFlag = false; + } + if (audioParamsGet.usage == AudioRendererInfo.usage){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + resultFlag = false; + } + if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + } + else{ + console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + resultFlag = false; + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_066 + // * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set25 + // * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set25 + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_066', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + + // var resultFlag=true; + + // 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); + // resultFlag = false; + // }); + + // 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); + // if (audioParamsGet.content == AudioRendererInfo.content){ + // console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + // resultFlag = false; + // } + // if (audioParamsGet.usage == AudioRendererInfo.usage){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + // resultFlag = false; + // } + // if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + // resultFlag = false; + // } + // }).catch((err) => { + // console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + // resultFlag = false; + // }); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_067 + // * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set26 + // * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set26 + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_067', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_SPEECH, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + + // var resultFlag=true; + + // 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); + // resultFlag = false; + // }); + + // 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); + // if (audioParamsGet.content == AudioRendererInfo.content){ + // console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + // resultFlag = false; + // } + // if (audioParamsGet.usage == AudioRendererInfo.usage){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + // resultFlag = false; + // } + // if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + // resultFlag = false; + // } + // }).catch((err) => { + // console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + // resultFlag = false; + // }); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_068 + // * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set27 + // * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set27 + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_068', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_MUSIC, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + // var resultFlag=true; + + // 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); + // resultFlag = false; + // }); + + // 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); + // if (audioParamsGet.content == AudioRendererInfo.content){ + // console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + // resultFlag = false; + // } + // if (audioParamsGet.usage == AudioRendererInfo.usage){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + // resultFlag = false; + // } + // if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + // resultFlag = false; + // } + // }).catch((err) => { + // console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + // resultFlag = false; + // }); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_069 + // * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set28 + // * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set28 + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_069', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_MOVIE, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + // var resultFlag=true; + + // 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); + // resultFlag = false; + // }); + + // 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); + // if (audioParamsGet.content == AudioRendererInfo.content){ + // console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + // resultFlag = false; + // } + // if (audioParamsGet.usage == AudioRendererInfo.usage){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + // resultFlag = false; + // } + // if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + // resultFlag = false; + // } + // }).catch((err) => { + // console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + // resultFlag = false; + // }); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_070 + // * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set29 + // * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set29 + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_070', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + // var resultFlag=true; + + // 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); + // resultFlag = false; + // }); + + // 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); + // if (audioParamsGet.content == AudioRendererInfo.content){ + // console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + // resultFlag = false; + // } + // if (audioParamsGet.usage == AudioRendererInfo.usage){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + // resultFlag = false; + // } + // if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + // resultFlag = false; + // } + // }).catch((err) => { + // console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + // resultFlag = false; + // }); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_071 + // * @tc.name : AudioRenderer-SET & GET AudioRendererInfo - Set30 + // * @tc.desc : AudioRenderer-SET & GET AudioRendererInfo - Set30 + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_071', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_RINGTONE, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + // var resultFlag=true; + + // 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); + // resultFlag = false; + // }); + + // 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); + // if (audioParamsGet.content == AudioRendererInfo.content){ + // console.info('AudioFrameworkRenderLog: Renderer content type: PASS: ' + audioParamsGet.content); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer content type: FAIL: ' + audioParamsGet.content); + // resultFlag = false; + // } + // if (audioParamsGet.usage == AudioRendererInfo.usage){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.usage); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.usage); + // resultFlag = false; + // } + // if (audioParamsGet.rendererFlags == AudioRendererInfo.rendererFlags){ + // console.info('AudioFrameworkRenderLog: Renderer usage type: PASS: ' + audioParamsGet.rendererFlags); + // } + // else{ + // console.info('AudioFrameworkRenderLog: Renderer usage type: FAIL: ' + audioParamsGet.rendererFlags); + // resultFlag = false; + // } + // }).catch((err) => { + // console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message); + // resultFlag = false; + // }); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + // /* * + // * @tc.number : SUB_AUDIO_RENDERER_Play_audio_072 + // * @tc.name : AudioRenderer - STATE_NEW + // * @tc.desc : AudioRenderer - STATE_NEW + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_AUDIO_RENDERER_Play_audio_072', 0,async function (done) { + // var AudioStreamInfo = { + // samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + // channels: audio.AudioChannel.CHANNEL_2, + // sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + // encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + // } + + // var AudioRendererInfo = { + // content: audio.ContentType.CONTENT_TYPE_RINGTONE, + // usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + // rendererFlags: 1 + // } + + // var AudioRendererOptions = { + // streamInfo: AudioStreamInfo, + // rendererInfo: AudioRendererInfo + // } + // var resultFlag = true; + + // 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); + // resultFlag = false; + // }); + + // if (audioRen.state==audio.AudioState.STATE_NEW) { + // console.info('AudioFrameworkRenderLog: Audio State : STATE_NEW : PASS : ' + audioRen.state); + // } + // else { + // console.info('AudioFrameworkRenderLog: Audio State : STATE_NEW : FAIL : ' + audioRen.state); + // resultFlag = false; + // } + + // await audioRen.release().then(async function () { + // console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + // }).catch((err) => { + // console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + // }); + + // expect(resultFlag).assertTrue(); + + // done(); + + // }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_073 + * @tc.name : AudioRenderer - STATE_PREPARED + * @tc.desc : AudioRenderer - STATE_PREPARED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_073', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = true; + + 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); + resultFlag = false; + }); + + if (audioRen.state==audio.AudioState.STATE_PREPARED) { + console.info('AudioFrameworkRenderLog: Audio State : STATE_PREPARED : PASS : ' + audioRen.state); + } + else { + console.info('AudioFrameworkRenderLog: Audio State : STATE_PREPARED : FAIL : ' + audioRen.state); + resultFlag = false; + } + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_074 + * @tc.name : AudioRenderer - STATE_RUNNING + * @tc.desc : AudioRenderer - STATE_RUNNING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_074', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = true; + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + await sleep(500); + + if (audioRen.state==audio.AudioState.STATE_RUNNING) { + console.info('AudioFrameworkRenderLog: Audio State : STATE_RUNNING : PASS : ' + audioRen.state); + } + else { + console.info('AudioFrameworkRenderLog: Audio State : STATE_RUNNING : FAIL : ' + audioRen.state); + resultFlag = false; + } + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_075 + * @tc.name : AudioRenderer - STATE_STOPPED + * @tc.desc : AudioRenderer - STATE_STOPPED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_075', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = true; + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + await sleep(500); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + resultFlag=false; + }); + await sleep(500); + + if (audioRen.state==audio.AudioState.STATE_STOPPED) { + console.info('AudioFrameworkRenderLog: Audio State : STATE_STOPPED : PASS : ' + audioRen.state); + } + else { + console.info('AudioFrameworkRenderLog: Audio State : STATE_STOPPED : FAIL : ' + audioRen.state); + resultFlag = false; + } + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_076 + * @tc.name : AudioRenderer - STATE_RELEASED + * @tc.desc : AudioRenderer - STATE_RELEASED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_076', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = true; + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + await sleep(500); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + resultFlag=false; + }); + await sleep(500); + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + await sleep(500); + + if (audioRen.state==audio.AudioState.STATE_RELEASED) { + console.info('AudioFrameworkRenderLog: Audio State : STATE_RELEASED : PASS : ' + audioRen.state); + } + else { + console.info('AudioFrameworkRenderLog: Audio State : STATE_RELEASED : FAIL : ' + audioRen.state); + resultFlag = false; + } + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_077 + * @tc.name : AudioRenderer - STATE_PAUSED + * @tc.desc : AudioRenderer - STATE_PAUSED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_077', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = true; + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + await sleep(500); + + await audioRen.pause().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant Pause :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant Pause :ERROR : '+err.message); + resultFlag=false; + }); + + await sleep(500); + + if (audioRen.state==audio.AudioState.STATE_PAUSED) { + console.info('AudioFrameworkRenderLog: Audio State : STATE_PAUSED : PASS : ' + audioRen.state); + } + else { + console.info('AudioFrameworkRenderLog: Audio State : STATE_PAUSED : FAIL : ' + audioRen.state); + resultFlag = false; + } + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + await sleep(500); + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_078 + * @tc.name : AudioRenderer - SetRenderRate - RENDER_RATE_DOUBLE + * @tc.desc : AudioRenderer - SetRenderRate - RENDER_RATE_DOUBLE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_078', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + var AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT; + + var resultFlag = true; + 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); + resultFlag=false; + }); + + 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); + resultFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message); + resultFlag=false; + }); + + 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); + resultFlag = false; + }); + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + var bufferSize = await audioRen.getBufferSize(); + console.info('AudioFrameworkRenderLog: buffer size: ' + bufferSize); + + 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); + resultFlag=false; + }); + } + if (rlen > (totalSize/2)){ + await audioRen.setRenderRate(audio.AudioRendererRate.RENDER_RATE_DOUBLE).then(async function () { + console.info('AudioFrameworkRenderLog: setRenderRate : RENDER_RATE_DOUBLE : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkAudioScene: setRenderRate : RENDER_RATE_DOUBLE : ERROR : '+err.message); + resultFlag=false; + }); + } + } + console.info('AudioFrameworkRenderLog: Renderer after read'); + await audioRen.getRenderRate().then(async function (data) { + if (data == audio.AudioRendererRate.RENDER_RATE_DOUBLE){ + console.info('AudioFrameworkRenderLog: getRenderRate : RENDER_RATE_DOUBLE : PASS : '+data); + } + else{ + console.info('AudioFrameworkRenderLog: getRenderRate : RENDER_RATE_DOUBLE : FAIL : '+data); + resultFlag=false; + } + }).catch((err) => { + console.info('AudioFrameworkAudioScene: getRenderRate : RENDER_RATE_DOUBLE : ERROR : '+err.message); + resultFlag=false; + }); + + await audioRen.drain().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer drained : SUCCESS'); + }).catch((err) => { + console.error('AudioFrameworkRenderLog: Renderer drain: ERROR : '+err.message); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_079 + * @tc.name : AudioRenderer - SetRenderRate - RENDER_RATE_HALF + * @tc.desc : AudioRenderer - SetRenderRate - RENDER_RATE_HALF + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_079', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + var AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT; + + var resultFlag = true; + 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); + resultFlag=false; + }); + + 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); + resultFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message); + resultFlag=false; + }); + + 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); + resultFlag = false; + }); + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + var bufferSize = await audioRen.getBufferSize(); + console.info('AudioFrameworkRenderLog: buffer size: ' + bufferSize); + + 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); + resultFlag=false; + }); + } + if (rlen > (totalSize/2)){ + await audioRen.setRenderRate(audio.AudioRendererRate.RENDER_RATE_HALF).then(async function () { + console.info('AudioFrameworkRenderLog: setRenderRate : RENDER_RATE_HALF : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkAudioScene: setRenderRate : RENDER_RATE_HALF : ERROR : '+err.message); + resultFlag=false; + }); + } + } + console.info('AudioFrameworkRenderLog: Renderer after read'); + await audioRen.getRenderRate().then(async function (data) { + if (data == audio.AudioRendererRate.RENDER_RATE_HALF){ + console.info('AudioFrameworkRenderLog: getRenderRate : RENDER_RATE_HALF : PASS : '+data); + } + else{ + console.info('AudioFrameworkRenderLog: getRenderRate : RENDER_RATE_HALF : FAIL : '+data); + resultFlag=false; + } + }).catch((err) => { + console.info('AudioFrameworkAudioScene: getRenderRate : RENDER_RATE_HALF : ERROR : '+err.message); + resultFlag=false; + }); + + await audioRen.drain().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer drained : SUCCESS'); + }).catch((err) => { + console.error('AudioFrameworkRenderLog: Renderer drain: ERROR : '+err.message); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_080 + * @tc.name : AudioRenderer - SetRenderRate - RENDER_RATE_NORMAL + * @tc.desc : AudioRenderer - SetRenderRate - RENDER_RATE_NORMAL + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_080', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + var AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT; + + var resultFlag = true; + 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); + resultFlag=false; + }); + + 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); + resultFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message); + resultFlag=false; + }); + + 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); + resultFlag = false; + }); + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + var bufferSize = await audioRen.getBufferSize(); + console.info('AudioFrameworkRenderLog: buffer size: ' + bufferSize); + + 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); + resultFlag=false; + }); + } + if (rlen > (totalSize/2)){ + await audioRen.setRenderRate(audio.AudioRendererRate.RENDER_RATE_DOUBLE).then(async function () { + console.info('AudioFrameworkRenderLog: setRenderRate : RENDER_RATE_DOUBLE : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkAudioScene: setRenderRate : RENDER_RATE_DOUBLE : ERROR : '+err.message); + resultFlag=false; + }); + } + } + + await audioRen.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(async function () { + console.info('AudioFrameworkRenderLog: setRenderRate : RENDER_RATE_NORMAL : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkAudioScene: setRenderRate : RENDER_RATE_NORMAL : ERROR : '+err.message); + resultFlag=false; + }); + + console.info('AudioFrameworkRenderLog: Renderer after read'); + await audioRen.getRenderRate().then(async function (data) { + if (data == audio.AudioRendererRate.RENDER_RATE_NORMAL){ + console.info('AudioFrameworkRenderLog: getRenderRate : RENDER_RATE_NORMAL : PASS : '+data); + } + else{ + console.info('AudioFrameworkRenderLog: getRenderRate : RENDER_RATE_NORMAL : FAIL : '+data); + resultFlag=false; + } + }).catch((err) => { + console.info('AudioFrameworkAudioScene: getRenderRate : RENDER_RATE_NORMAL : ERROR : '+err.message); + resultFlag=false; + }); + + await audioRen.drain().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer drained : SUCCESS'); + }).catch((err) => { + console.error('AudioFrameworkRenderLog: Renderer drain: ERROR : '+err.message); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_081 + * @tc.name : AudioRenderer - SetRenderRate - DEFAULT - RENDER_RATE_NORMAL + * @tc.desc : AudioRenderer - SetRenderRate - DEFAULT - RENDER_RATE_NORMAL + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_081', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + var AudioScene = audio.AudioScene.AUDIO_SCENE_DEFAULT; + + var resultFlag = true; + 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); + resultFlag=false; + }); + + 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); + resultFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: setAudioScene : ERROR : '+err.message); + resultFlag=false; + }); + + 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); + resultFlag = false; + }); + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + var bufferSize = await audioRen.getBufferSize(); + console.info('AudioFrameworkRenderLog: buffer size: ' + bufferSize); + + 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); + resultFlag=false; + }); + } + } + console.info('AudioFrameworkRenderLog: Renderer after read'); + await audioRen.getRenderRate().then(async function (data) { + if (data == audio.AudioRendererRate.RENDER_RATE_NORMAL){ + console.info('AudioFrameworkRenderLog: getRenderRate : RENDER_RATE_NORMAL : PASS : '+data); + } + else{ + console.info('AudioFrameworkRenderLog: getRenderRate : RENDER_RATE_NORMAL : FAIL : '+data); + resultFlag=false; + } + }).catch((err) => { + console.info('AudioFrameworkAudioScene: getRenderRate : RENDER_RATE_NORMAL : ERROR : '+err.message); + resultFlag=false; + }); + + await audioRen.drain().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer drained : SUCCESS'); + }).catch((err) => { + console.error('AudioFrameworkRenderLog: Renderer drain: ERROR : '+err.message); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_082 + * @tc.name : AudioRenderer-Set11-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 11 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_082', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-2C-48000-4SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_083 + * @tc.name : AudioRenderer-Set1-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_083', 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-1C-44100-2SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_084 + * @tc.name : AudioRenderer-Set2-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 2 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_084', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_8000, + 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-1C-8000-2SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_085 + * @tc.name : AudioRenderer-Set3-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 3 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_085', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_32000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_U8, + 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-1C-32000-1SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_086 + * @tc.name : AudioRenderer-Set4-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 4 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_086', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_64000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-1C-64000-3SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_087 + * @tc.name : AudioRenderer-Set5-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 5 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_087', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_96000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-1C-96000-4SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_088 + * @tc.name : AudioRenderer-Set6-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 6 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_088', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_11025, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_U8, + 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-2C-11025-1SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_089 + * @tc.name : AudioRenderer-Set7-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 7 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_089', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_12000, + channels: audio.AudioChannel.CHANNEL_2, + 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-2C-12000-2SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_090 + * @tc.name : AudioRenderer-Set8-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 8 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_090', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_16000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-2C-16000-3SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_091 + * @tc.name : AudioRenderer-Set9-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 9 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_091', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_22050, + channels: audio.AudioChannel.CHANNEL_2, + 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-2C-22050-2SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_092 + * @tc.name : AudioRenderer-Set10-Media - CALLBACK + * @tc.desc : AudioRenderer with parameter set 10 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_092', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_24000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + 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 playbackCB(AudioRendererOptions, mediaDir+'/StarWars10s-2C-24000-3SW.wav'); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_093 + * @tc.name : AudioRenderer - getAudioTime - Play + * @tc.desc : AudioRenderer - getAudioTime - Play + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_093', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + + var resultFlag = true; + 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); + resultFlag=false; + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + 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); + resultFlag = false; + }); + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + let audioTime = Date.now(); + let audioTimeStart; + let audioTimeEnd; + let audioTimeMiddle; + console.info('AudioFrameworkRenderLog: Current Time in NANOSeconds : '+audioTime); + + await audioRen.getAudioTime().then(async function (data) { + audioTime = Date.now(); + audioTimeStart = (data-audioTime)/1000000000; + console.info('AudioFrameworkRenderLog: getAudioTime : After Start : Converted: '+audioTimeStart); + console.info('AudioFrameworkRenderLog: getAudioTime : After Start : ORG: '+data); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: getAudioTime : ERROR : '+err.message); + resultFlag=false; + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + var bufferSize = await audioRen.getBufferSize(); + console.info('AudioFrameworkRenderLog: buffer size: ' + bufferSize); + + 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/3) && rlen < (totalSize/2)){ + console.info('AudioFrameworkRenderLog: getAudioTime : ENTER'); + await audioRen.getAudioTime().then(async function (data) { + audioTime = Date.now(); + audioTimeMiddle = (data-audioTime)/1000000000; + console.info('AudioFrameworkRenderLog: getAudioTime : Play iteration: Converted: '+audioTime); + console.info(`AudioFrameworkRenderLog: getAudioTime : Play iteration: ${rlen} value : ${data}`); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: getAudioTime : ERROR : '+err.message); + resultFlag=false; + }); + } + } + console.info('AudioFrameworkRenderLog: Renderer after read'); + + var gettime = audioTimeMiddle-audioTimeStart; + if (gettime > 3 && gettime < 5){ + console.info('AudioFrameworkRenderLog: getAudioTime : PASS : '+gettime); + } + else{ + console.info('AudioFrameworkRenderLog: getAudioTime : FAIL : '+gettime); + resultFlag=false; + } + + + await audioRen.drain().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer drained : SUCCESS'); + }).catch((err) => { + console.error('AudioFrameworkRenderLog: Renderer drain: ERROR : '+err.message); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + + await audioRen.getAudioTime().then(async function (data) { + audioTime = Date.now(); + audioTimeEnd = (data-audioTime)/1000000000; + console.info('AudioFrameworkRenderLog: getAudioTime : After Stop : Converted: '+audioTimeEnd); + console.info('AudioFrameworkRenderLog: getAudioTime : After Stop : ORG : '+data); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: getAudioTime : ERROR : '+err.message); + resultFlag=false; + }); + let totalAudioTime = audioTimeEnd-audioTimeStart; + console.info('AudioFrameworkRenderLog: Audio Length in Sec: '+totalAudioTime); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_094 + * @tc.name : AudioRenderer - getAudioTime - Before Play + * @tc.desc : AudioRenderer - getAudioTime - Before Play + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_094', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + + var resultFlag = true; + 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); + resultFlag=false; + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + 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); + resultFlag = false; + }); + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + let audioTime = Date.now(); + let audioTimeStart; + let audioTimeEnd; + let audioTimeMiddle; + console.info('AudioFrameworkRenderLog: Current Time in NANOSeconds : '+audioTime); + + await audioRen.getAudioTime().then(async function (data) { + audioTime = Date.now(); + audioTimeStart = (data-audioTime)/1000000000; + console.info('AudioFrameworkRenderLog: getAudioTime : After Start : Converted: '+audioTimeStart); + console.info('AudioFrameworkRenderLog: getAudioTime : After Start : ORG: '+data); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: getAudioTime : ERROR : '+err.message); + resultFlag=false; + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + var bufferSize = await audioRen.getBufferSize(); + console.info('AudioFrameworkRenderLog: buffer size: ' + bufferSize); + + 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; + var gettime = 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); + } + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + await audioRen.getAudioTime().then(async function (data) { + audioTime = Date.now(); + audioTimeEnd = (data-audioTime)/1000000000; + console.info('AudioFrameworkRenderLog: getAudioTime : After Stop : Converted: '+audioTimeEnd); + console.info('AudioFrameworkRenderLog: getAudioTime : After Stop : ORG : '+data); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: getAudioTime : ERROR : '+err.message); + resultFlag=false; + }); + let totalAudioTime = audioTimeStart-audioTimeEnd; + + if (totalAudioTime < 0){ + console.info('AudioFrameworkRenderLog: getAudioTime : PASS : '+totalAudioTime); + } + else{ + console.info('AudioFrameworkRenderLog: getAudioTime : FAIL : '+totalAudioTime); + resultFlag=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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_095 + * @tc.name : AudioRenderer - getAudioTime - after Play + * @tc.desc : AudioRenderer - getAudioTime - after Play + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_095', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + + var resultFlag = true; + 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); + resultFlag=false; + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + 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); + resultFlag = false; + }); + + 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); + resultFlag = false; + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + let audioTime = Date.now(); + let audioTimeStart; + let audioTimeEnd; + let audioTimeMiddle; + console.info('AudioFrameworkRenderLog: Current Time in NANOSeconds : '+audioTime); + + await audioRen.getAudioTime().then(async function (data) { + audioTime = Date.now(); + audioTimeStart = (data-audioTime)/1000000000; + console.info('AudioFrameworkRenderLog: getAudioTime : After Start : Converted: '+audioTimeStart); + console.info('AudioFrameworkRenderLog: getAudioTime : After Start : ORG: '+data); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: getAudioTime : ERROR : '+err.message); + resultFlag=false; + }); + + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + var bufferSize = await audioRen.getBufferSize(); + console.info('AudioFrameworkRenderLog: buffer size: ' + bufferSize); + + 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; + var gettime = 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); + } + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + await audioRen.getAudioTime().then(async function (data) { + audioTime = Date.now(); + audioTimeEnd = (data-audioTime)/1000000000; + console.info('AudioFrameworkRenderLog: getAudioTime : After Stop : Converted: '+audioTimeEnd); + console.info('AudioFrameworkRenderLog: getAudioTime : After Stop : ORG : '+data); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: getAudioTime : ERROR : '+err.message); + resultFlag=false; + }); + let totalAudioTime = audioTimeEnd-audioTimeStart; + + if (totalAudioTime > 9 && gettime < 10){ + console.info('AudioFrameworkRenderLog: getAudioTime : PASS : '+totalAudioTime); + } + else{ + console.info('AudioFrameworkRenderLog: getAudioTime : FAIL : '+totalAudioTime); + resultFlag=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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_096 + * @tc.name : AudioRenderer - getAudioTime - Error + * @tc.desc : AudioRenderer - getAudioTime - Error + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_096', 0,async function (done) { + + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + + var resultFlag = true; + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + 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); + resultFlag=false; + }); + + await audioRen.getAudioTime().then(async function (data) { + console.info('AudioFrameworkRenderLog: getAudioTime : Value : '+data); + resultFlag=false; + if (data > 0){ + console.info('AudioFrameworkRenderLog: getAudioTime : PASS : '+data); + } + else{ + console.info('AudioFrameworkRenderLog: getAudioTime : FAIL : '+data); + } + }).catch((err) => { + console.info('AudioFrameworkRenderLog: getAudioTime : ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + await sleep(500); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_097 + * @tc.name : AudioRenderer - STATE_PREPARED -Callback + * @tc.desc : AudioRenderer - STATE_PREPARED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_097', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + 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); + resultFlag = false; + }); + + audioRen.on('stateChange',(AudioState) => { + + console.log('AudioFrameworkTest: Volume Change Event is called'); + + switch (AudioState) { + case audio.AudioState.STATE_PREPARED: + console.info('AudioFrameworkTest: state : STATE_NEW'); + resultFlag = true; + break; + default: + console.info('AudioFrameworkTest: state : '+AudioState); + break; + } + }); + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + await sleep(1000); + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_098 + * @tc.name : AudioRenderer - STATE_RUNNING - Callback + * @tc.desc : AudioRenderer - STATE_RUNNING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_098', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + 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); + resultFlag = false; + }); + + audioRen.on('stateChange',(AudioState) => { + + console.log('AudioFrameworkTest: Volume Change Event is called'); + + switch (AudioState) { + case audio.AudioState.STATE_RUNNING: + console.info('AudioFrameworkTest: state : STATE_RUNNING'); + resultFlag = true; + break; + default: + console.info('AudioFrameworkTest: state : '+AudioState); + break; + } + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + await sleep(500); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + await sleep(1000); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_099 + * @tc.name : AudioRenderer - STATE_STOPPED - Callback + * @tc.desc : AudioRenderer - STATE_STOPPED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_099', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + 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); + resultFlag = false; + }); + + audioRen.on('stateChange',(AudioState) => { + + console.log('AudioFrameworkTest: Volume Change Event is called'); + + switch (AudioState) { + case audio.AudioState.STATE_STOPPED: + console.info('AudioFrameworkTest: state : STATE_STOPPED'); + resultFlag = true; + break; + default: + console.info('AudioFrameworkTest: state : '+AudioState); + break; + } + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + await sleep(500); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + resultFlag=false; + }); + await sleep(500); + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + await sleep(500); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_100 + * @tc.name : AudioRenderer - STATE_RELEASED - Callback + * @tc.desc : AudioRenderer - STATE_RELEASED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_100', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + 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); + resultFlag = false; + }); + + audioRen.on('stateChange',(AudioState) => { + + console.log('AudioFrameworkTest: Volume Change Event is called'); + + switch (AudioState) { + case audio.AudioState.STATE_RELEASED: + console.info('AudioFrameworkTest: state : STATE_RELEASED'); + resultFlag = true; + break; + default: + console.info('AudioFrameworkTest: state : '+AudioState); + break; + } + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + await sleep(500); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + resultFlag=false; + }); + await sleep(500); + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + await sleep(500); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_101 + * @tc.name : AudioRenderer - STATE_PAUSED - Callback + * @tc.desc : AudioRenderer - STATE_PAUSED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_101', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + 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); + resultFlag = false; + }); + audioRen.on('stateChange',(AudioState) => { + + console.log('AudioFrameworkTest: Volume Change Event is called'); + + switch (AudioState) { + case audio.AudioState.STATE_PAUSED: + console.info('AudioFrameworkTest: state : STATE_PAUSED'); + resultFlag = true; + break; + default: + console.info('AudioFrameworkTest: state : '+AudioState); + break; + } + }); + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + await sleep(500); + + await audioRen.pause().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant Pause :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant Pause :ERROR : '+err.message); + resultFlag=false; + }); + + await sleep(500); + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + await sleep(500); + + await audioRen.release().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message); + }); + await sleep(500) + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_102 + * @tc.name : AudioRenderer - markReached - On + * @tc.desc : AudioRenderer - markReached + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_102', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + 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); + }); + audioRen.on('markReach',55, (position) => { + console.log('AudioFrameworkTest: markReach Event is called : '+position); + resultFlag = true; + + }) + + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + 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); + resultFlag=false; + }); + + 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); + } + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_103 + * @tc.name : AudioRenderer - markReached - On - off -on + * @tc.desc : AudioRenderer - markReached + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_103', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + 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); + }); + audioRen.on('markReach',55, (position) => { + console.log('AudioFrameworkTest: markReach Event is called : '+position); +// resultFlag = true; + audioRen.off('markReach'); + audioRen.on('markReach',100, (position) => { + console.log('AudioFrameworkTest: markReach Event is called : '+position); + resultFlag = true; + + }); + + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + 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); + resultFlag=false; + }); + + 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); + } + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_104 + * @tc.name : AudioRenderer - markReached - on - on + * @tc.desc : AudioRenderer - markReached + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_104', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + 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); + }); + audioRen.on('markReach',55, (position) => { + console.log('AudioFrameworkTest: markReach Event is called : '+position); + resultFlag = true; + audioRen.on('markReach',73, (position) => { + console.log('AudioFrameworkTest: markReach Event is called : '+position); + resultFlag = false; + }); + }); + + + + + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + 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); + resultFlag=false; + }); + + 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); + } + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_105 + * @tc.name : AudioRenderer - periodReach - On + * @tc.desc : AudioRenderer - periodReach + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_105', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + 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); + }); + audioRen.on('periodReach',55, (position) => { + console.log('AudioFrameworkTest: periodReach Event is called : '+position); + resultFlag = true; + audioRen.off('periodReach'); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + 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); + resultFlag=false; + }); + + 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); + } + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_106 + * @tc.name : AudioRenderer - periodReach - On - off -on + * @tc.desc : AudioRenderer - periodReach + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_106', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + 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); + }); + audioRen.on('periodReach',55, (position) => { + console.log('AudioFrameworkTest: periodReach Event is called : '+position); + // resultFlag = true; + audioRen.off('periodReach'); + audioRen.on('periodReach',100, (position) => { + console.log('AudioFrameworkTest: periodReach Event is called : '+position); + resultFlag = true; + audioRen.off('periodReach'); + }); + + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + 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); + resultFlag=false; + }); + + 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); + } + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + expect(resultFlag).assertTrue(); + + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_RENDERER_Play_audio_107 + * @tc.name : AudioRenderer - periodReach - on - on + * @tc.desc : AudioRenderer - periodReach + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_RENDERER_Play_audio_107', 0,async function (done) { + var AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var fpath = mediaDir+'/StarWars10s-2C-48000-4SW.wav'; + 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); + }); + audioRen.on('periodReach',55, (position) => { + console.log('AudioFrameworkTest: periodReach Event is called : '+position); + resultFlag = true; + audioRen.on('periodReach',73, (position) => { + console.log('AudioFrameworkTest: periodReach Event is called : '+position); + resultFlag = false; + }); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : Path : '+fpath); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message); + resultFlag=false; + }); + + 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); + resultFlag=false; + }); + + 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); + } + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + await audioRen.stop().then(async function () { + console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message); + }); + + 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); + }); + + console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state); + + expect(resultFlag).assertTrue(); + + done(); + + }) + +}) \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js index ca720e6824b0e7aa55c385d5a95c5e873930e0a5..b52be32fec14c053a7324fdd02a2ebbedae75c20 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js @@ -14,4 +14,8 @@ */ 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 diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/SR000GHLLV.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/SR000GHLLV.test.js new file mode 100644 index 0000000000000000000000000000000000000000..59661bae4b24437452152ce0b79b0614ddbe1c9e --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/SR000GHLLV.test.js @@ -0,0 +1,6566 @@ +/* + * 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('audioCapturer', function () { + + var dateTime = new Date().getTime(); + const dirPath = '/data/accounts/account_0/appdata/RecTest'+dateTime; + var fpath = dirPath+'/capture_js.pcm'; + var audioCapCallBack; + var audioCapPromise; + console.info('AudioFrameworkRecLog: Recording files Path: '+dirPath); + + const audioManager = audio.getAudioManager(); + console.info('AudioFrameworkRenderLog: Create AudioManger Object JS Framework'); + + const audioManagerRec = audio.getAudioManager(); + console.info('AudioFrameworkRecLog: Create AudioManger Object JS Framework'); + + beforeAll(function () { + console.info('AudioFrameworkTest: beforeAll: Prerequisites at the test suite level'); + fileio.mkdirSync(dirPath); + }) + + beforeEach(async function () { + console.info('AudioFrameworkTest: beforeEach: Prerequisites at the test case level'); + await sleep(1000); + }) + + afterEach(function () { + console.info('AudioFrameworkTest: afterEach: Test case-level clearance conditions'); + }) + + afterAll(async function () { + fileio.rmdir(dirPath, function(err){ + if (!err) { + console.info('AudioFrameworkTest: Recorded files are deleted successfully'); + } + }); + await sleep(1000); + console.info('AudioFrameworkTest: afterAll: Test suite-level cleanup condition'); + }) + + function sleep (ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + + async function recPromise (AudioCapturerOptions, fpath, AudioScene) { + + var resultFlag = '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 resultFlag; + }); + + 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); + resultFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + resultFlag=false; + }); + if (resultFlag == false){ + console.info('AudioFrameworkRecLog: resultFlag : '+resultFlag); + return resultFlag; + } + + await audioCap.getStreamInfo().then(async function (audioParamsGet) { + if (audioParamsGet != undefined) { + 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); + } else { + console.info('AudioFrameworkRecLog: audioParamsGet is : '+audioParamsGet); + console.info('AudioFrameworkRecLog: audioParams getStreamInfo are incorrect: '); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRecLog: getStreamInfo :ERROR: '+err.message); + resultFlag = false; + }); + if (resultFlag == false){ + console.info('AudioFrameworkRecLog: resultFlag : '+resultFlag); + return resultFlag; + } + + await audioCap.getCapturerInfo().then(async function (audioParamsGet) { + if (audioParamsGet != undefined) { + console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); + console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source); + console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags); + }else { + console.info('AudioFrameworkRecLog: audioParamsGet is : '+audioParamsGet); + console.info('AudioFrameworkRecLog: audioParams getCapturerInfo are incorrect: '); + resultFlag = false; + } + }).catch((err) => { + console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message); + resultFlag = false; + }); + if (resultFlag == false){ + console.info('AudioFrameworkRecLog: resultFlag : '+resultFlag); + return resultFlag; + } + + await audioCap.start().then(async function () { + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + resultFlag=false; + }); + if (resultFlag == false){ + console.info('AudioFrameworkRecLog: resultFlag : '+resultFlag); + return resultFlag; + } + + 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 : '); + resultFlag=false; + return resultFlag; + } + + 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'); + resultFlag=false; + return resultFlag; + } + await sleep(100); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------READ BUFFER---------'); + var buffer = await audioCap.read(bufferSize, true); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(50); + numBuffersToCapture--; + } + await sleep(1000); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state); + + await audioCap.stop().then(async function () { + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + resultFlag=true; + console.info('AudioFrameworkRecLog: resultFlag : '+resultFlag); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + resultFlag=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); + resultFlag=false; + }); + + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state); + + return resultFlag; + + } + + + async function recCallBack (AudioCapturerOptions, fpath, AudioScene) { + + var resultFlag = true; + console.info('AudioFrameworkRecLog: CallBack : Audio Recording Function'); + //var audioCap; + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep(1000); + audioManagerRec.getAudioScene(async(err,getValue) => { + console.info('AudioFrameworkRecLog: ---------GET AUDIO SCENE---------'); + if(err){ + console.info('AudioFrameworkRecLog: getAudioScene : ERROR : '+err.message); + resultFlag=false; + }else { + console.info('AudioFrameworkRecLog: getAudioScene : Value : '+getValue); + } + }); + await sleep(1000); + await audioManagerRec.setAudioScene(AudioScene,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + resultFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + audioCapCallBack.getStreamInfo(async(err,audioParamsGet) => { + console.info('AudioFrameworkRecLog: ---------GET STREAM INFO---------'); + console.log('AudioFrameworkRecLog: Entered getStreamInfo'); + if (err){ + console.log('AudioFrameworkRecLog: getStreamInfo :ERROR: '+err.message); + resultFlag = false; + } else { + 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); + } + }); + await sleep(1000); + audioCapCallBack.getCapturerInfo(async(err,audioParamsGet) => { + console.info('AudioFrameworkRecLog: ---------GET CAPTURER INFO---------'); + if (err){ + console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message); + resultFlag = false; + } else { + console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); + console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source); + console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags); + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + resultFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + await sleep(1000); + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR '); + resultFlag=false; + return resultFlag; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + resultFlag=false; + return resultFlag; + } + + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------READ BUFFER---------'); + var buffer = await audioCapCallBack.read(bufferSize, true); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(50); + numBuffersToCapture--; + } + //await sleep(3000); + audioCapCallBack.stop(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + resultFlag=false; + } else { + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + resultFlag=true; + console.info('AudioFrameworkRecLog: resultFlag : '+resultFlag); + } + }); + await sleep(1000); + + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + resultFlag=false; + } else { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + resultFlag=true; + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + //return resultFlag; + } + }); + //await sleep(3000); + console.info('AudioFrameworkRenderLog: After all check resultFlag : '+resultFlag); + return resultFlag; + } + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_PREPARED_STATE_001 + * @tc.name : AudioCapturer-Check-STATE-PREPARED + * @tc.desc : AudioCapturer with state prepared + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_PREPARED_STATE_001', 0, async function (done) { + var stateFlag ; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag = false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO PREPARED STATE---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == audio.AudioState.STATE_PREPARED)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO PREPARED STATE : PASS---------'); + stateFlag = true; + expect(stateFlag).assertTrue(); + done(); + } + } + }); + + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_PREPARED_STATE_ENUM_002 + * @tc.name : AudioCapturer-Check-STATE-PREPARED-ENUM + * @tc.desc : AudioCapturer with state prepared + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_PREPARED_STATE_ENUM_002', 0, async function (done) { + var stateFlag ; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag = false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO PREPARED STATE---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO PREPARED STATE : PASS---------'); + stateFlag = true; + expect(stateFlag).assertTrue(); + done(); + } + } + }); + + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_RUNNING_STATE_003 + * @tc.name : AudioCapturer-Check-STATE-RUNNING + * @tc.desc : AudioCapturer with state running + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_RUNNING_STATE_003', 0, async function (done) { + var stateFlag ; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RUNNING STATE---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + await sleep(1000); + if ((audioCapCallBack.state == audio.AudioState.STATE_RUNNING)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RUNNING STATE : PASS---------'); + stateFlag = true; + } + } + }); + await sleep(1000); + await audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + stateFlag=true; + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + //return resultFlag; + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_RUNNING_STATE_EUNM_004 + * @tc.name : AudioCapturer-Check-STATE-RUNNING-ENUM + * @tc.desc : AudioCapturer with state running + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_RUNNING_STATE_EUNM_004', 0, async function (done) { + var stateFlag ; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RUNNING STATE---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + await sleep(1000); + if ((audioCapCallBack.state == 2)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RUNNING STATE : PASS---------'); + stateFlag == true; + } + } + }); + await sleep(1000); + await audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + stateFlag=true; + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + //return resultFlag; + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_STOPPED_STATE_005 + * @tc.name : AudioCapturer-Check-STATE-STOPPED + * @tc.desc : AudioCapturer with state stopped + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_STOPPED_STATE_005', 0, async function (done) { + var stateFlag ; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + await sleep(1000); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.stop(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO STOPPED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == audio.AudioState.STATE_STOPPED)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO STOPPED STATE---------'); + stateFlag = true; + } + console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag); + } + }); + await sleep(1000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + stateFlag=true; + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + //return resultFlag; + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_STOPPED_STATE_ENUM_006 + * @tc.name : AudioCapturer-Check-STATE-STOPPED-ENUM + * @tc.desc : AudioCapturer with state stopped + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_STOPPED_STATE_ENUM_006', 0, async function (done) { + var stateFlag ; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + stateFlag = true; + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + stateFlag == true; + } + }); + await sleep(1000); + audioCapCallBack.stop(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO STOPPED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 3)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO STOPPED STATE---------'); + stateFlag = true; + } + console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag); + } + }); + await sleep(1000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + stateFlag=true; + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + //return resultFlag; + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_RELEASED_STATE_007 + * @tc.name : AudioCapturer-Check-STATE-RELEASED + * @tc.desc : AudioCapturer with state released + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_RELEASED_STATE_007', 0, async function (done) { + var stateFlag ; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + await sleep(1000); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.stop(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 3)) { + stateFlag = true; + } + console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag); + } + }); + await sleep(1000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == audio.AudioState.STATE_RELEASED)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_RELEASED_STATE_ENUM_008 + * @tc.name : AudioCapturer-Check-STATE-RELEASED + * @tc.desc : AudioCapturer with state released + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_RELEASED_STATE_ENUM_008', 0, async function (done) { + var stateFlag ; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + await sleep(1000); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.stop(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 3)) { + stateFlag = true; + } + console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag); + } + }); + await sleep(1000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_GET_BUFFER_SIZE_009 + * @tc.name : AudioCapturer-get_buffer_size + * @tc.desc : AudioCapturer with state stopped + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_GET_BUFFER_SIZE_009', 0, async function (done) { + var stateFlag ; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + await sleep(1000); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(async(err,cbbufferSize) => { + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK BUFFER SIZE---------'); + console.info('AudioFrameworkRecLog: buffer size: ' + cbbufferSize); + stateFlag = true + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + console.info('AudioFrameworkRecLog: ---------AFTER CHECK BUFFER SIZE : PASS---------') + } + }); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + stateFlag=true; + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + //return resultFlag; + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_010 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_010', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : readvalue : '+buffer); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMOISE_PREPARED_STATE_011 + * @tc.name : AudioCapturer-Check-STATE-PREPARED + * @tc.desc : AudioCapturer with state prepared + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMOISE_PREPARED_STATE_011', 0, async function (done) { + var stateFlag ; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + return stateFlag; + }); + + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).then(async function () { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + await audioManagerRec.getAudioScene().then(async function (data) { + console.info('AudioFrameworkRecLog: getAudioScene : Value : '+data); + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO PREPARED STATE---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapPromise.state == audio.AudioState.STATE_PREPARED)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO PREPARED STATE : PASS---------'); + stateFlag = true; + expect(stateFlag).assertTrue(); + done(); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: getAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMOISE_PREPARED_STATE_ENUM_012 + * @tc.name : AudioCapturer-Check-STATE-PREPARED-ENUM + * @tc.desc : AudioCapturer with state prepared + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMOISE_PREPARED_STATE_ENUM_012', 0, async function (done) { + var stateFlag ; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + return stateFlag; + }); + + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).then(async function () { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + await audioManagerRec.getAudioScene().then(async function (data) { + console.info('AudioFrameworkRecLog: getAudioScene : Value : '+data); + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO PREPARED STATE---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapPromise.state == 1)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO PREPARED STATE : PASS---------'); + stateFlag = true; + expect(stateFlag).assertTrue(); + done(); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: getAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_RUNNING_STATE_013 + * @tc.name : AudioCapturer-Check-STATE-RUNNING + * @tc.desc : AudioCapturer with state running + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_RUNNING_STATE_013', 0, async function (done) { + var stateFlag ; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + return stateFlag; + }); + + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).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); + stateFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + + + await audioCapPromise.start().then(async function () { + console.info('AudioFrameworkRecLog: ---------START---------'); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapPromise.state == audio.AudioState.STATE_RUNNING)) { + stateFlag = true; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + + await audioCapPromise.release().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + stateFlag=true; + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + //return resultFlag; + }).catch ((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_RUNNING_STATE_ENUM_014 + * @tc.name : AudioCapturer-Check-STATE-RUNNING-ENUM + * @tc.desc : AudioCapturer with state running + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_RUNNING_STATE_ENUM_014', 0, async function (done) { + var stateFlag ; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + return stateFlag; + }); + + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).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); + stateFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + + + await audioCapPromise.start().then(async function () { + console.info('AudioFrameworkRecLog: ---------START---------'); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapPromise.state == 2)) { + stateFlag = true; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + + await audioCapPromise.release().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + stateFlag=true; + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + //return resultFlag; + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_STOPPED_STATE_015 + * @tc.name : AudioCapturer-Check-STATE-STOPPED + * @tc.desc : AudioCapturer with state stopped + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_STOPPED_STATE_015', 0, async function (done) { + var stateFlag ; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + return stateFlag; + }); + + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).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); + stateFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + + + await audioCapPromise.start().then(async function () { + console.info('AudioFrameworkRecLog: ---------START---------'); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapPromise.state == audio.AudioState.STATE_STOPPED)) { + stateFlag = true; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + + await audioCapPromise.stop().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + if ((audioCapPromise.state == audioCapPromise.AudioState.STATE_STOPPED)){ + stateFlag=true; + console.info('AudioFrameworkRecLog: resultFlag : '+stateFlag); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + await audioCapPromise.release().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + stateFlag=true; + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + }).catch ((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_STOPPED_STATE_ENUM_016 + * @tc.name : AudioCapturer-Check-STATE-STOPPED + * @tc.desc : AudioCapturer with state stopped + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_STOPPED_STATE_ENUM_016', 0, async function (done) { + var stateFlag ; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + return stateFlag; + }); + + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).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); + stateFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + + + await audioCapPromise.start().then(async function () { + console.info('AudioFrameworkRecLog: ---------START---------'); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapPromise.state == audio.AudioState.STATE_STOPPED)) { + stateFlag = true; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + + await audioCapPromise.stop().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + if ((audioCapPromise.state == 3)){ + stateFlag=true; + console.info('AudioFrameworkRecLog: resultFlag : '+stateFlag); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + await audioCapPromise.release().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + stateFlag=true; + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + //return resultFlag; + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_RELEASED_STATE_017 + * @tc.name : AudioCapturer-Check-STATE-RELEASED + * @tc.desc : AudioCapturer with state released + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_RELEASED_STATE_017', 0, async function (done) { + var stateFlag; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : ' + err.message); + }); + + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).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); + stateFlag = false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : ' + err.message); + stateFlag = false; + }); + + + await audioCapPromise.start().then(async function () { + console.info('AudioFrameworkRecLog: ---------START---------'); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapPromise.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + stateFlag = true; + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : ' + err.message); + stateFlag = false; + }); + await sleep(1000); + + await audioCapPromise.stop().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + stateFlag = true; + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : ' + err.message); + stateFlag = false; + }); + await sleep(1000); + await audioCapPromise.release().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapPromise.state); + if ((audioCapPromise.state == audio.AudioState.STATE_RELEASED)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + stateFlag); + expect(stateFlag).assertTrue(); + done(); + await sleep(1000); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : ' + err.message); + stateFlag = false; + }); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_RELEASED_STATE_ENUM_018 + * @tc.name : AudioCapturer-Check-STATE-RELEASED-ENUM + * @tc.desc : AudioCapturer with state released + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_RELEASED_STATE_ENUM_018', 0, async function (done) { + var stateFlag ; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + return stateFlag; + }); + + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).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); + stateFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + + + await audioCapPromise.start().then(async function () { + console.info('AudioFrameworkRecLog: ---------START---------'); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + stateFlag = true; + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + + await audioCapPromise.stop().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + stateFlag = true; + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + await audioCapPromise.release().then(async function (){ + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapPromise.state); + if ((audioCapPromise.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_GET_BUFFER_SIZE_019 + * @tc.name : AudioCapturer-get_buffer_size + * @tc.desc : AudioCapturer with state stopped + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_GET_BUFFER_SIZE_019', 0, async function (done) { + var stateFlag ; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + return stateFlag; + }); + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).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); + stateFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + await audioCapPromise.start().then(async function () { + console.info('AudioFrameworkRecLog: ---------START---------'); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapPromise.state == 2)) { + stateFlag = true; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapPromise.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + stateFlag = true; + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + + await audioCapPromise.release().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapPromise.state); + if ((audioCapPromise.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_READ_BUFFER_020 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_READ_BUFFER_020', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkpromisereadbuffer.pcm'; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + return stateFlag; + }); + await sleep(1000); + + await audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT).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); + stateFlag=false; + }); + }).catch((err) => { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + + await audioCapPromise.start().then(async function () { + console.info('AudioFrameworkRecLog: ---------START---------'); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapPromise.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapPromise.state == 2)) { + stateFlag = true; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapPromise.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + stateFlag = true; + + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + //await sleep(1000); + var numBuffersToCapture = 500; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE PROMISE READ ---------'); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + var buffer = await audioCapPromise.read(bufferSize, true); + console.info('AudioFrameworkRecLog: ---------AFTER PROMISE READ ---------'); + //await sleep(50); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + console.info('AudioFrameworkRecLog: ---------AFTER PROMISE WRITE ---------'); + //await sleep(100); + numBuffersToCapture--; + } + //await sleep(3000); + + await audioCapPromise.release().then(async function () { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapPromise.state); + if ((audioCapPromise.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_CB_021 + * @tc.name : AudioCapturer-Set1-Media + * @tc.desc : AudioCapturer with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_CB_021', 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 recCallBack(AudioCapturerOptions, dirPath+'/capture_CB_js-44100-2C-16B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(1000); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_CB_ENUM_022 + * @tc.name : AudioCapturer-Set1-Media + * @tc.desc : AudioCapturer with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_CB_ENUM_022', 0, async function (done) { + + var AudioStreamInfo = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0 + } + + var AudioCapturerInfo = { + source: 1, + capturerFlags: 1 + } + + var AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + var resultFlag = await recCallBack(AudioCapturerOptions, dirPath+'/capture_CB_js-44100-2C-16B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(1000); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_023 + * @tc.name : AudioCapturer-Set1-Media + * @tc.desc : AudioCapturer with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_023', 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_Rec_VOICE_CHAT_Promise_ENUM_024 + * @tc.name : AudioCapturer-Set1-Media + * @tc.desc : AudioCapturer with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_024', 0, async function (done) { + + var AudioStreamInfo = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0 + } + + var AudioCapturerInfo = { + source: 1, + 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_Rec_VOICE_CHAT_Promise_025 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_025', 0, async function (done) { + var audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions44100 = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + var resultFlag = await recPromise(audioCapturerOptions44100, dirPath+'/capture_js-44100-1C-16LE.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_026 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_026', 0, async function (done) { + var audioStreamInfo44100 = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + var audioCapturerInfo44100 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions44100 = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + var resultFlag = await recPromise(audioCapturerOptions44100, dirPath+'/capture_js-44100-1C-16LE.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_027 + * @tc.name : AudioRec-Set2 + * @tc.desc : record audio with parameter set 2 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_027', 0, async function (done) { + var audioStreamInfo96000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_96000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo96000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions96000 = { + streamInfo: audioStreamInfo96000, + capturerInfo: audioCapturerInfo96000, + } + + var resultFlag = await recPromise(audioCapturerOptions96000, dirPath+'/capture_js-96000-1C-S24LE.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_028 + * @tc.name : AudioRec-Set2 + * @tc.desc : record audio with parameter set 2 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_028', 0, async function (done) { + var audioStreamInfo96000 = { + samplingRate: 96000, + channels: 1, + sampleFormat: 2, + encodingType: 0, + }; + var audioCapturerInfo96000 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions96000 = { + streamInfo: audioStreamInfo96000, + capturerInfo: audioCapturerInfo96000, + } + + var resultFlag = await recPromise(audioCapturerOptions96000, dirPath+'/capture_js-96000-1C-S24LE.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_029 + * @tc.name : AudioRec-Set3 + * @tc.desc : record audio with parameter set 3 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_029', 0, async function (done) { + var audioStreamInfo48000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo48000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions48000 = { + streamInfo: audioStreamInfo48000, + capturerInfo: audioCapturerInfo48000, + } + + var resultFlag = await recPromise(audioCapturerOptions48000, dirPath+'/capture_js-48000-2C-1S32LE.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_30 + * @tc.name : AudioRec-Set3 + * @tc.desc : record audio with parameter set 3 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_30', 0, async function (done) { + var audioStreamInfo48000 = { + samplingRate: 48000, + channels: 2, + sampleFormat: 1, + encodingType: 0, + }; + var audioCapturerInfo48000 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions48000 = { + streamInfo: audioStreamInfo48000, + capturerInfo: audioCapturerInfo48000, + } + + var resultFlag = await recPromise(audioCapturerOptions48000, dirPath+'/capture_js-48000-2C-1S32LE.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_031 + * @tc.name : AudioRec-Set4 + * @tc.desc : record audio with parameter set 4 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_031', 0, async function (done) { + var audioStreamInfo8000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_8000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_U8, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo8000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions8000 = { + streamInfo: audioStreamInfo8000, + capturerInfo: audioCapturerInfo8000, + } + + var resultFlag = await recPromise(audioCapturerOptions8000, dirPath+'/capture_js-8000-1C-8B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_032 + * @tc.name : AudioRec-Set4 + * @tc.desc : record audio with parameter set 4 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_032', 0, async function (done) { + var audioStreamInfo8000 = { + samplingRate: 8000, + channels: 1, + sampleFormat: 0, + encodingType: 0, + }; + var audioCapturerInfo8000 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions8000 = { + streamInfo: audioStreamInfo8000, + capturerInfo: audioCapturerInfo8000, + } + + var resultFlag = await recPromise(audioCapturerOptions8000, dirPath+'/capture_js-8000-1C-8B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_33 + * @tc.name : AudioRec-Set5 + * @tc.desc : record audio with parameter set 5 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_33', 0, async function (done) { + var audioStreamInfo11025 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_11025, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo11025 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions11025 = { + streamInfo: audioStreamInfo11025, + capturerInfo: audioCapturerInfo11025, + } + + var resultFlag = await recPromise(audioCapturerOptions11025, dirPath+'/capture_js-11025-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_Rec_VOICE_CHAT_Promise_ENUM_034 + * @tc.name : AudioRec-Set5 + * @tc.desc : record audio with parameter set 5 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_034', 0, async function (done) { + var audioStreamInfo11025 = { + samplingRate: 11025, + channels: 2, + sampleFormat: 1, + encodingType: 0, + }; + var audioCapturerInfo11025 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions11025 = { + streamInfo: audioStreamInfo11025, + capturerInfo: audioCapturerInfo11025, + } + + var resultFlag = await recPromise(audioCapturerOptions11025, dirPath+'/capture_js-11025-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_Rec_VOICE_CHAT_Promise_035 + * @tc.name : AudioRec-Set6 + * @tc.desc : record audio with parameter set 6 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_028', 0, async function (done) { + var audioStreamInfo12000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_12000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo12000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions12000 = { + streamInfo: audioStreamInfo12000, + capturerInfo: audioCapturerInfo12000, + } + + var resultFlag = await recPromise(audioCapturerOptions12000, dirPath+'/capture_js-12000-1C-24B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_036 + * @tc.name : AudioRec-Set6 + * @tc.desc : record audio with parameter set 6 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_036', 0, async function (done) { + var audioStreamInfo12000 = { + samplingRate: 12000, + channels: 1, + sampleFormat: 2, + encodingType: 0 + }; + var audioCapturerInfo12000 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions12000 = { + streamInfo: audioStreamInfo12000, + capturerInfo: audioCapturerInfo12000, + } + + var resultFlag = await recPromise(audioCapturerOptions12000, dirPath+'/capture_js-12000-1C-24B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_037 + * @tc.name : AudioRec-Set7 + * @tc.desc : record audio with parameter set 7 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_037', 0, async function (done) { + var audioStreamInfo16000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_16000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo16000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions16000 = { + streamInfo: audioStreamInfo16000, + capturerInfo: audioCapturerInfo16000, + } + + var resultFlag = await recPromise(audioCapturerOptions16000, dirPath+'/capture_js-16000-2C-32B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_038 + * @tc.name : AudioRec-Set7 + * @tc.desc : record audio with parameter set 7 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_038', 0, async function (done) { + var audioStreamInfo16000 = { + samplingRate: 16000, + channels: 2, + sampleFormat: 3, + encodingType: 0, + }; + var audioCapturerInfo16000 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions16000 = { + streamInfo: audioStreamInfo16000, + capturerInfo: audioCapturerInfo16000, + } + + var resultFlag = await recPromise(audioCapturerOptions16000, dirPath+'/capture_js-16000-2C-32B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_039 + * @tc.name : AudioRec-Set8 + * @tc.desc : record audio with parameter set 8 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_039', 0, async function (done) { + var audioStreamInfo22050 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_22050, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_U8, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo22050 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions22050 = { + streamInfo: audioStreamInfo22050, + capturerInfo: audioCapturerInfo22050, + } + + var resultFlag = await recPromise(audioCapturerOptions22050, dirPath+'/capture_js-22050-1C-8B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_040 + * @tc.name : AudioRec-Set8 + * @tc.desc : record audio with parameter set 8 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_040', 0, async function (done) { + var audioStreamInfo22050 = { + samplingRate: 22050, + channels: 1, + sampleFormat: 0, + encodingType: 0, + }; + var audioCapturerInfo22050 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions22050 = { + streamInfo: audioStreamInfo22050, + capturerInfo: audioCapturerInfo22050, + } + + var resultFlag = await recPromise(audioCapturerOptions22050, dirPath+'/capture_js-22050-1C-8B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_041 + * @tc.name : AudioRec-Set9 + * @tc.desc : record audio with parameter set 9 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_041', 0, async function (done) { + var audioStreamInfo24000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_24000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo24000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions24000 = { + streamInfo: audioStreamInfo24000, + capturerInfo: audioCapturerInfo24000, + } + + var resultFlag = await recPromise(audioCapturerOptions24000, dirPath+'/capture_js-24000-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_Rec_VOICE_CHAT_Promise_ENUM_042 + * @tc.name : AudioRec-Set9 + * @tc.desc : record audio with parameter set 9 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_042', 0, async function (done) { + var audioStreamInfo24000 = { + samplingRate: 24000, + channels: 2, + sampleFormat: 1, + encodingType: 0, + }; + var audioCapturerInfo24000 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions24000 = { + streamInfo: audioStreamInfo24000, + capturerInfo: audioCapturerInfo24000, + } + + var resultFlag = await recPromise(audioCapturerOptions24000, dirPath+'/capture_js-24000-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_Rec_VOICE_CHAT_Promise_043 + * @tc.name : AudioRec-Set10 + * @tc.desc : record audio with parameter set 010 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_043', 0, async function (done) { + var audioStreamInfo32000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_32000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo32000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions32000 = { + streamInfo: audioStreamInfo32000, + capturerInfo: audioCapturerInfo32000, + } + + var resultFlag = await recPromise(audioCapturerOptions32000, dirPath+'/capture_js-32000-1C-24B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_044 + * @tc.name : AudioRec-Set10 + * @tc.desc : record audio with parameter set 010 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_044', 0, async function (done) { + var audioStreamInfo32000 = { + samplingRate: 32000, + channels: 1, + sampleFormat: 2, + encodingType: 0, + }; + var audioCapturerInfo32000 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions32000 = { + streamInfo: audioStreamInfo32000, + capturerInfo: audioCapturerInfo32000, + } + + var resultFlag = await recPromise(audioCapturerOptions32000, dirPath+'/capture_js-32000-1C-24B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + + /* + * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_045 + * @tc.name : AudioRec-Set11 + * @tc.desc : record audio with parameter set 011 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 +*/ + + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_045', 0, async function (done) { + var audioStreamInfo64000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_64000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo64000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions64000 = { + streamInfo: audioStreamInfo64000, + capturerInfo: audioCapturerInfo64000, + } + + var resultFlag = await recPromise(audioCapturerOptions64000, dirPath+'/capture_js-64000-2C-32B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_046 + * @tc.name : AudioRec-Set11 + * @tc.desc : record audio with parameter set 011 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_046', 0, async function (done) { + var audioStreamInfo64000 = { + samplingRate: 64000, + channels: 2, + sampleFormat: 3, + encodingType: 0, + }; + var audioCapturerInfo64000 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions64000 = { + streamInfo: audioStreamInfo64000, + capturerInfo: audioCapturerInfo64000, + } + + var resultFlag = await recPromise(audioCapturerOptions64000, dirPath+'/capture_js-64000-2C-32B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RECORD_Promise_AUDIO_SCENE_DEFAULT_047 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_RECORD_Promise_AUDIO_SCENE_DEFAULT_047', 0, async function (done) { + var audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions44100 = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + var resultFlag = await recPromise(audioCapturerOptions44100, dirPath+'/capture_js-44100-1C-16LE.pcm', audio.AudioScene.AUDIO_SCENE_DEFAULT); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RECORD_Promise_AUDIO_SCENE_DEFAULT_ENUM_048 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_RECORD_Promise_AUDIO_SCENE_DEFAULT_ENUM_048', 0, async function (done) { + var audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions44100 = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + var resultFlag = await recPromise(audioCapturerOptions44100, dirPath+'/capture_js-44100-1C-16LE.pcm', 0); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_PROMISE_RECORD_AUDIO_SCENE_RINGING_049 + * @tc.name : AudioRec-Set2 + * @tc.desc : record audio with parameter set 2 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_PROMISE_RECORD_AUDIO_SCENE_RINGING_049', 0, async function (done) { + var audioStreamInfo96000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_96000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo96000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions96000 = { + streamInfo: audioStreamInfo96000, + capturerInfo: audioCapturerInfo96000, + } + + var resultFlag = await recPromise(audioCapturerOptions96000, dirPath+'/capture_js-96000-1C-S24LE.pcm', audio.AudioScene.AUDIO_SCENE_RINGING); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_PROMISE_RECORD_AUDIO_SCENE_RINGING_ENUM_050 + * @tc.name : AudioRec-Set2 + * @tc.desc : record audio with parameter set 2 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_PROMISE_RECORD_AUDIO_SCENE_RINGING_ENUM_050', 0, async function (done) { + var audioStreamInfo96000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_96000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo96000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions96000 = { + streamInfo: audioStreamInfo96000, + capturerInfo: audioCapturerInfo96000, + } + + var resultFlag = await recPromise(audioCapturerOptions96000, dirPath+'/capture_js-96000-1C-S24LE.pcm', 1); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RECORD_PROMISE_AUDIO_SCENE_PHONE_CALL_Audio_051 + * @tc.name : AudioRec-Set3 + * @tc.desc : record audio with parameter set 3 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_RECORD_PROMISE_AUDIO_SCENE_PHONE_CALL_Audio_051', 0, async function (done) { + var audioStreamInfo48000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo48000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions48000 = { + streamInfo: audioStreamInfo48000, + capturerInfo: audioCapturerInfo48000, + } + + var resultFlag = await recPromise(audioCapturerOptions48000, dirPath+'/capture_js-48000-2C-1S32LE.pcm', audio.AudioScene.AUDIO_SCENE_PHONE_CALL); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_RECORD_PROMISE_AUDIO_SCENE_PHONE_CALL_Audio_ENUM_052 + * @tc.name : AudioRec-Set3 + * @tc.desc : record audio with parameter set 3 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_RECORD_PROMISE_AUDIO_SCENE_PHONE_CALL_Audio_ENUM_052', 0, async function (done) { + var audioStreamInfo48000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + var audioCapturerInfo48000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags : 1, + } + var audioCapturerOptions48000 = { + streamInfo: audioStreamInfo48000, + capturerInfo: audioCapturerInfo48000, + } + + var resultFlag = await recPromise(audioCapturerOptions48000, dirPath+'/capture_js-48000-2C-1S32LE.pcm', audio.AudioScene.AUDIO_SCENE_PHONE_CALL); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_053 + * @tc.name : AudioRec-Set11 + * @tc.desc : record audio with parameter set 011 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_VOIP_Rec_VOICE_CHAT_Promise_ENUM_053', 0, async function (done) { + var audioStreamInfo64000 = { + samplingRate: 64000, + channels: 2, + sampleFormat: 3, + encodingType: 0, + }; + var audioCapturerInfo64000 = { + source: 1, + capturerFlags : 1, + } + var audioCapturerOptions64000 = { + streamInfo: audioStreamInfo64000, + capturerInfo: audioCapturerInfo64000, + } + + var resultFlag = await recPromise(audioCapturerOptions64000, dirPath+'/capture_js-64000-2C-32B.pcm', 3); + await sleep(100); + console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); + + expect(resultFlag).assertTrue(); + + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_BEFORE_START_054 + * @tc.name : AudioCapturer-GET_AUDIO_TIME + * @tc.desc : AudioCapturer GET_AUDIO_TIME + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_BEFORE_START_054', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep(1000); + await audioCapCallBack.getAudioTime().then(async function (audioTime) { + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime : Success' + audioTime ); + if (audioTime == 0) { + stateFlag = true; + expect(stateFlag).assertTrue(); + } else { + stateFlag = false; + expect(stateFlag).assertTrue(); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + if (stateFlag == true) { + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + } else { + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = false; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + } + + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_START_055 + * @tc.name : AudioCapturer-GET_AUDIO_TIME + * @tc.desc : AudioCapturer GET_AUDIO_TIME + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_START_055', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep(1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + await audioCapCallBack.getAudioTime().then(async function (audioTime) { + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime AFTER START : Success' + audioTime ); + if (audioTime != 0) { + stateFlag = true; + expect(stateFlag).assertTrue(); + } else { + stateFlag = false; + expect(stateFlag).assertTrue(); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + await sleep(1000); + await audioCapCallBack.getAudioTime().then(async function (audioTime) { + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime : Success' + audioTime ); + if (audioTime != 0) { + stateFlag = true; + expect(stateFlag).assertTrue(); + } else { + stateFlag = false; + expect(stateFlag).assertTrue(); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + await sleep(1000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_READ_WRITE_056 + * @tc.name : AudioCapturer-GET_AUDIO_TIME + * @tc.desc : AudioCapturer GET_AUDIO_TIME + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_READ_WRITE_056', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep(1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + await audioCapCallBack.getAudioTime().then(async function (audioTime) { + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime AFTER WRITE : Success' + audioTime ); + if (audioTime != 0) { + stateFlag = true; + } else { + stateFlag = false; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + await audioCapCallBack.getAudioTime().then(async function (audioTime1) { + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime AFTER WRITE : Success' + audioTime1 ); + if (audioTime1 != 0) { + stateFlag = true; + } else { + stateFlag = false; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + + await audioCapCallBack.getAudioTime().then(async function (audioTime2) { + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime AFTER WRITE : Success' + audioTime2 ); + if (audioTime2 != 0) { + stateFlag = true; + } else { + stateFlag = false; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + await sleep(1000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_STOP_057 + * @tc.name : AudioCapturer-GET_AUDIO_TIME + * @tc.desc : AudioCapturer GET_AUDIO_TIME + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_STOP_057', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep(1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + await audioCapCallBack.getAudioTime().then(async function (audioTime) { + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime AFTER WRITE : Success' + audioTime ); + if (audioTime != 0) { + stateFlag = true; + } else { + stateFlag = false; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + await audioCapCallBack.getAudioTime().then(async function (audioTime1) { + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime AFTER WRITE : Success' + audioTime1 ); + if (audioTime1 != 0) { + stateFlag = true; + } else { + stateFlag = false; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + audioCapCallBack.stop(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO STOP STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 3)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO STOP STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + done(); + } + } + }); + await sleep(1000); + await audioCapCallBack.getAudioTime().then(async function (audioTime2) { + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime AFTER WRITE : Success' + audioTime2 ); + if (audioTime2 != 0) { + stateFlag == true; + } else { + stateFlag == false; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + await sleep(1000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } else { + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep (1000); + }) + + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_GET_AUDIO_TIME_058 + * @tc.name : AudioCapturer-GET_AUDIO_TIME + * @tc.desc : AudioCapturer GET_AUDIO_TIME + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_GET_AUDIO_TIME_058', 0, async function (done) { + var stateFlag ; + var audioCapCallBack ; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep(1000); + await audioCapCallBack.start().then(async function () { + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + }); + await sleep(1000); + await audioCapCallBack.getAudioTime(async(err,audioTime) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + console.info('AudioFrameworkRecLog: AudioCapturer getAudioTime : Success' + audioTime); + if (audioTime != 0) { + stateFlag = true; + } else { + stateFlag = false; + } + } + }); + await sleep(1000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } else { + stateFlag = false; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + + + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_STOP_BEFORE_START_059 + * @tc.name : AudioCapturer-GET_AUDIO_TIME + * @tc.desc : AudioCapturer GET_AUDIO_TIME + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_STOP_BEFORE_START_059', 0, async function (done) { + var stateFlag; + var audioCapPromise; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO NEW STATE---------'); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS' + audioCapCallBack.state); + stateFlag == true; + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : ' + err.message); + }); + await sleep(1000); + await audioCapPromise.stop().then(async function () { + console.info('AudioFrameworkRecLog: AudioCapturer STOPED : UNSUCCESS' + audioCapCallBack.state); + if (audioCapCallBack.state == 1) { + stateFlag = true; + } else { + stateFlag = false; + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop :ERROR : ' + err.message); + stateFlag = false; + }); + await sleep(1000); + audioCapPromise.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + stateFlag = false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /** + * @tc.number : SUB_AUDIO_VOIP_CAP_PROMISE_RELEASE_BEFORE_START_060 + * @tc.name : AudioCapturer-GET_AUDIO_TIME + * @tc.desc : AudioCapturer GET_AUDIO_TIME + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_PROMISE_RELEASE_BEFORE_START_060', 0, async function (done) { + var stateFlag ; + var audioCapPromise; + 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 + } + + await audio.createAudioCapturer(AudioCapturerOptions).then(async function (data) { + audioCapPromise = data; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'); + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO NEW STATE---------'); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + stateFlag = true; + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + await sleep(1000); + await audioCapPromise.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer released :SUCCESS '); + stateFlag=true; + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop :ERROR : '+err.message); + stateFlag=false; + expect(stateFlag).assertTrue(); + }); + await sleep(1000); + audioCapPromise.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + stateFlag = false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapPromise.state); + if ((audioCapPromise.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + + /* * + * @tc.number : SUB_AUDIO_Rec_PR_VOICE_CHAT_GET_STREAM_INFO_061 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_Rec_PR_VOICE_CHAT_GET_STREAM_INFO_061', 0, async function (done) { + var audioCapGetgetStreamInfo; + var setFlag; + var audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 1 + } + var AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(async function (data) { + if (data != undefined) { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success:'+ data.state ); + audioCapGetgetStreamInfo = data; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Unsuccess :'+ data ); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + done(); + }); + await sleep(1000); + await audioCapGetgetStreamInfo.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); + setFlag = true; + if (setFlag){ + console.info('AudioFrameworkRecLog: Capturer getStreamInfo: PASS' ); + } + }).catch((err) => { + console.log('AudioFrameworkRecLog: getStreamInfo :ERROR: '+err.message); + setFlag = false + }); + await sleep(1000); + audioCapGetgetStreamInfo.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + setFlag = false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapGetgetStreamInfo.state); + if ((audioCapGetgetStreamInfo.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + setFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + setFlag); + expect(setFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + + }) + + /* * + * @tc.number : SUB_AUDIO_Rec_PR_VOICE_CHAT_GET_STREAM_INFO_ENUM_062 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_Rec_PR_VOICE_CHAT_GET_STREAM_INFO_ENUM_062', 0, async function (done) { + var audioCapGetgetStreamInfo; + var setFlag; + var audioStreamInfo44100 = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + var audioCapturerInfo44100 = { + source: 1, + capturerFlags : 1, + } + var AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(async function (data) { + if (data != undefined) { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success:'+ data.state ); + audioCapGetgetStreamInfo = data; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Unsuccess :'+ data ); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + done(); + }); + await sleep(1000); + await audioCapGetgetStreamInfo.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); + setFlag = true ; + if (setFlag){ + console.info('AudioFrameworkRecLog: Capturer getStreamInfo: PASS' ); + } + }).catch((err) => { + console.log('AudioFrameworkRecLog: getStreamInfo :ERROR: '+err.message); + setFlag = false ; + expect(setFlag).assertTrue(); + }); + await sleep(1000); + audioCapGetgetStreamInfo.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + setFlag = false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapGetgetStreamInfo.state); + if ((audioCapGetgetStreamInfo.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + setFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + setFlag); + expect(setFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + + + }) + + /* * + * @tc.number : SUB_AUDIO_Rec_CB_VOICE_CHAT_GET_STREAM_INFO_063 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_Rec_CB_VOICE_CHAT_GET_STREAM_INFO_063', 0, async function (done) { + var audioCapGetgetStreamInfo; + var setFlag; + var audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 1 + } + var AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(async function (data) { + if (data != undefined) { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success:'+ data.state ); + audioCapGetgetStreamInfo = data; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Unsuccess :'+ data ); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + done(); + }); + await sleep(1000); + audioCapGetgetStreamInfo.getStreamInfo(async(err,audioParamsGet) => { + console.info('AudioFrameworkRecLog: ---------GET STREAM INFO---------'); + console.log('AudioFrameworkRecLog: Entered getStreamInfo'); + if (err){ + console.log('AudioFrameworkRecLog: getStreamInfo :ERROR: '+err.message); + setFlag = false; + } else { + 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); + setFlag = true; + } + await sleep (100); + done(); + }); + + audioCapGetgetStreamInfo.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + setFlag = false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapGetgetStreamInfo.state); + if ((audioCapGetgetStreamInfo.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + setFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + setFlag); + expect(setFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + + }) + + /* * + * @tc.number : SUB_AUDIO_Rec_CB_VOICE_CHAT_GET_STREAM_INFO_ENUM_064 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_Rec_CB_VOICE_CHAT_GET_STREAM_INFO_ENUM_064', 0, async function (done) { + var audioCapGetgetStreamInfo; + var setFlag; + var audioStreamInfo44100 = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + var audioCapturerInfo44100 = { + source: 1, + capturerFlags : 1, + } + var AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(async function (data) { + if (data != undefined) { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success:'+ data.state ); + audioCapGetgetStreamInfo = data; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Unsuccess :'+ data ); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + done(); + }); + await sleep(1000); + audioCapGetgetStreamInfo.getStreamInfo(async(err,audioParamsGet) => { + console.info('AudioFrameworkRecLog: ---------GET STREAM INFO---------'); + console.log('AudioFrameworkRecLog: Entered getStreamInfo'); + if (err){ + console.log('AudioFrameworkRecLog: getStreamInfo :ERROR: '+err.message); + setFlag = false; + } else { + 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); + setFlag = true; + } + await sleep(1000); + }); + + audioCapGetgetStreamInfo.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + setFlag = false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapGetgetStreamInfo.state); + if ((audioCapGetgetStreamInfo.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + setFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + setFlag); + expect(setFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + + }) + + + + /* * + * @tc.number : SUB_AUDIO_Rec_PR_VOICE_CHAT_GET_CAPTURER_INFO_065 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_Rec_PR_VOICE_CHAT_GET_CAPTURER_INFO_065', 0, async function (done) { + var audioCapGetgetCapturerInfo; + var setFlag; + var audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 1 + } + var AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(async function (data) { + if (data != undefined) { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success:'+ data.state ); + audioCapGetgetCapturerInfo = data; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Unsuccess :'+ data ); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + done(); + }); + await sleep(1000); + await audioCapGetgetCapturerInfo.getCapturerInfo().then(async function (audioParamsGet) { + console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); + console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source); + console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags); + setFlag = true; + }).catch((err) => { + console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message); + setFlag = false; + }); + await sleep(1000); + audioCapGetgetCapturerInfo.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + setFlag = false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapGetgetCapturerInfo.state); + if ((audioCapGetgetCapturerInfo.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + setFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + setFlag); + expect(setFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + + + }) + + /* * + * @tc.number : SUB_AUDIO_Rec_PR_VOICE_CHAT_GET_CAPTURER_INFO_ENUM_066 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_Rec_PR_VOICE_CHAT_GET_CAPTURER_INFO_ENUM_65', 0, async function (done) { + var audioCapGetgetCapturerInfo; + var setFlag; + var audioStreamInfo44100 = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + var audioCapturerInfo44100 = { + source: 1, + capturerFlags : 1, + } + var AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(async function (data) { + if (data != undefined) { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success:'+ data.state ); + audioCapGetgetCapturerInfo = data; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Unsuccess :'+ data ); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + done(); + }); + await sleep(1000); + await audioCapGetgetCapturerInfo.getCapturerInfo().then(async function (audioParamsGet) { + console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); + console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source); + console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags); + setFlag = true; + }).catch((err) => { + setFlag = false; + console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message);; + }); + await sleep(1000); + audioCapGetgetCapturerInfo.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + setFlag = false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapGetgetCapturerInfo.state); + if ((audioCapGetgetCapturerInfo.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + setFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + setFlag); + expect(setFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + + + }) + + /* * + * @tc.number : SUB_AUDIO_Rec_CB_VOICE_CHAT_GET_CAPTURER_INFO_067 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_Rec_CB_VOICE_CHAT_GET_CAPTURER_INFO_067', 0, async function (done) { + var audioCapGetgetCapturerInfo; + var setFlag; + var audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + var audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 1 + } + var AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(async function (data) { + if (data != undefined) { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success:'+ data.state ); + audioCapGetgetCapturerInfo = data; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Unsuccess :'+ data ); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + done(); + }); + await sleep(1000); + audioCapGetgetCapturerInfo.getCapturerInfo(async(err,audioParamsGet) => { + console.info('AudioFrameworkRecLog: ---------GET CAPTURER INFO---------'); + if (err){ + console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message); + setFlag = false; + } else { + console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); + console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source); + console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags); + setFlag = true; + await sleep (100); + done(); + } + }); + await sleep(1000); + audioCapGetgetCapturerInfo.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + setFlag = false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapGetgetCapturerInfo.state); + if ((audioCapGetgetCapturerInfo.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + setFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + setFlag); + expect(setFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + + }) + + /* * + * @tc.number : SUB_AUDIO_Rec_CB_VOICE_CHAT_GET_STREAM_INFO_ENUM_068 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_Rec_CB_VOICE_CHAT_GET_STREAM_INFO_ENUM_068', 0, async function (done) { + var audioCapGetgetCapturerInfo; + var setFlag; + var audioStreamInfo44100 = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + var audioCapturerInfo44100 = { + source: 1, + capturerFlags : 1, + } + var AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(async function (data) { + if (data != undefined) { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success:'+ data.state ); + audioCapGetgetCapturerInfo = data; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Unsuccess :'+ data ); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + done(); + }); + await sleep(1000); + audioCapGetgetCapturerInfo.getCapturerInfo(async(err,audioParamsGet) => { + console.info('AudioFrameworkRecLog: ---------GET CAPTURER INFO---------'); + if (err){ + console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message); + setFlag = false; + } else { + console.info('AudioFrameworkRecLog: Capturer CapturerInfo:'); + console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source); + console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags); + setFlag = true; + await sleep(1000); + done(); + } + }); + + audioCapGetgetCapturerInfo.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + setFlag = false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapGetgetCapturerInfo.state); + if ((audioCapGetgetCapturerInfo.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + setFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : ' + setFlag); + expect(setFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_Rec_VOICE_CHAT_PR_ENUM_AUDIO_STREAM_INFO_INVALID_069 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_Rec_VOICE_CHAT_PR_ENUM_AUDIO_STREAM_INFO_INVALID_069', 0, async function (done) { + var audioStreamInfo44100 = { + samplingRate: 0, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + var audioCapturerInfo44100 = { + source: 1, + capturerFlags : 1, + } + var AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + var audioCap; + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(async function (data) { + if (data == undefined) { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Unsuccess :'+ data); + expect(true).assertTrue(); + } else { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success:'+ data.state ); + } + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_Rec_VOICE_CHAT_PR_ENUM_AUDIO_CAPTURER_INFO_INVALID_070 + * @tc.name : AudioRec-Set1 + * @tc.desc : record audio with parameter set 1 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + + it('SUB_AUDIO_Rec_VOICE_CHAT_PR_ENUM_AUDIO_CAPTURER_INFO_INVALID_070', 0, async function (done) { + var audioStreamInfo44100 = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + var audioCapturerInfo44100 = { + source: 1000, + capturerFlags : 1, + } + var AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(async function (data) { + if (data == undefined) { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Unsuccess :'+ data ); + expect(true).assertTrue(); + } else { + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success:'+ data.state ); + } + + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_ON_ALL_CASES_071 + * @tc.name : AudioCapturer-Check-STATE-STOPPED + * @tc.desc : AudioCapturer with state stopped + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_ON_ALL_CASES_070', 0, async function (done) { + var stateFlag ; + var audioCapCallBack; + 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 + } + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep(1000); + audioCapCallBack.on('stateChange',(AudioState) => { + console.info('AudioCapturerLog: Changed State to : ' + AudioState) + switch (AudioState) { + case audio.AudioState.STATE_NEW: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------NEW--------------'); + console.info('AudioFrameworkTest: Audio State is : New'); + break; + case audio.AudioState.STATE_PREPARED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------PREPARED--------------'); + console.info('AudioFrameworkTest: Audio State is : Prepared'); + break; + case audio.AudioState.STATE_RUNNING: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RUNNING--------------'); + console.info('AudioFrameworkTest: Audio State is : Running'); + break; + case audio.AudioState.STATE_STOPPED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------STOPPED--------------'); + console.info('AudioFrameworkTest: Audio State is : stopped'); + break; + case audio.AudioState.STATE_RELEASED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RELEASED--------------'); + console.info('AudioFrameworkTest: Audio State is : released'); + break; + default: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------INVALID--------------'); + console.info('AudioFrameworkTest: Audio State is : invalid'); + break; + } + }); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag == true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + await sleep(1000); + if ((audioCapCallBack.state == 2)) { + stateFlag == true; + } + } + }); + await sleep(1000); + + audioCapCallBack.stop(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO STOPPED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == audio.AudioState.STATE_STOPPED)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO STOPPED STATE---------'); + stateFlag == true; + } + console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag); + } + }); + await sleep(1000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + stateFlag=true; + console.info('AudioFrameworkRenderLog: stateFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_ON_PREPARED_072 + * @tc.name : AudioCapturer-Check-STATE-STOPPED + * @tc.desc : AudioCapturer with state stopped + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_ON_PREPARED_072', 0, async function (done) { + var stateFlag; + var audioCapCallBack; + 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 + } + audio.createAudioCapturer(AudioCapturerOptions, async (err, value) => { + if (err) { + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS' + audioCapCallBack.state); + } + }); + await sleep(1000); + audioCapCallBack.on('stateChange', (AudioState) => { + console.info('AudioCapturerLog: Changed State to : ' + AudioState) + switch (AudioState) { + case audio.AudioState.STATE_NEW: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------NEW--------------'); + console.info('AudioFrameworkTest: Audio State is : New'); + break; + case audio.AudioState.STATE_PREPARED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------PREPARED--------------'); + console.info('AudioFrameworkTest: Audio State is : Prepared'); + break; + case audio.AudioState.STATE_RUNNING: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RUNNING--------------'); + console.info('AudioFrameworkTest: Audio State is : Running'); + break; + case audio.AudioState.STATE_STOPPED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------STOPPED--------------'); + console.info('AudioFrameworkTest: Audio State is : stopped'); + break; + case audio.AudioState.STATE_RELEASED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RELEASED--------------'); + console.info('AudioFrameworkTest: Audio State is : released'); + break; + default: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------INVALID--------------'); + console.info('AudioFrameworkTest: Audio State is : invalid'); + break; + } + }); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT, async (err, setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err) { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : ' + err.message); + stateFlag = false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : ' + setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS' + audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag == true; + } + } + }); + await sleep(1000); + audioCapCallBack.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + stateFlag = false; + } else { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapCallBack.state); + stateFlag = true; + console.info('AudioFrameworkRenderLog: stateFlag : ' + stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_ON_START_073 + * @tc.name : AudioCapturer-Check-STATE-STOPPED + * @tc.desc : AudioCapturer with state stopped + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_ON_START_073', 0, async function (done) { + var stateFlag; + var audioCapCallBack; + 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 + } + audio.createAudioCapturer(AudioCapturerOptions, async (err, value) => { + if (err) { + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS' + audioCapCallBack.state); + } + }); + await sleep(1000); + audioCapCallBack.on('stateChange', (AudioState) => { + console.info('AudioCapturerLog: Changed State to : ' + AudioState) + switch (AudioState) { + case audio.AudioState.STATE_NEW: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------NEW--------------'); + console.info('AudioFrameworkTest: Audio State is : New'); + break; + case audio.AudioState.STATE_PREPARED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------PREPARED--------------'); + console.info('AudioFrameworkTest: Audio State is : Prepared'); + break; + case audio.AudioState.STATE_RUNNING: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RUNNING--------------'); + console.info('AudioFrameworkTest: Audio State is : Running'); + break; + case audio.AudioState.STATE_STOPPED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------STOPPED--------------'); + console.info('AudioFrameworkTest: Audio State is : stopped'); + break; + case audio.AudioState.STATE_RELEASED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RELEASED--------------'); + console.info('AudioFrameworkTest: Audio State is : released'); + break; + default: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------INVALID--------------'); + console.info('AudioFrameworkTest: Audio State is : invalid'); + break; + } + }); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT, async (err, setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err) { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : ' + err.message); + stateFlag = false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : ' + setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS' + audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag == true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + await sleep(1000); + if ((audioCapCallBack.state == 2)) { + stateFlag == true; + } + } + }); + await sleep(1000); + audioCapCallBack.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + stateFlag = false; + } else { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapCallBack.state); + stateFlag = true; + console.info('AudioFrameworkRenderLog: stateFlag : ' + stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_ON_STOP_074 + * @tc.name : AudioCapturer-Check-STATE-STOPPED + * @tc.desc : AudioCapturer with state stopped + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_ON_STOP_074', 0, async function (done) { + var stateFlag; + var audioCapCallBack; + 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 + } + audio.createAudioCapturer(AudioCapturerOptions, async (err, value) => { + if (err) { + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS' + audioCapCallBack.state); + } + }); + await sleep(1000); + audioCapCallBack.on('stateChange', (AudioState) => { + console.info('AudioCapturerLog: Changed State to : ' + AudioState) + switch (AudioState) { + case audio.AudioState.STATE_NEW: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------NEW--------------'); + console.info('AudioFrameworkTest: Audio State is : New'); + break; + case audio.AudioState.STATE_PREPARED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------PREPARED--------------'); + console.info('AudioFrameworkTest: Audio State is : Prepared'); + break; + case audio.AudioState.STATE_RUNNING: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RUNNING--------------'); + console.info('AudioFrameworkTest: Audio State is : Running'); + break; + case audio.AudioState.STATE_STOPPED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------STOPPED--------------'); + console.info('AudioFrameworkTest: Audio State is : stopped'); + break; + case audio.AudioState.STATE_RELEASED: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RELEASED--------------'); + console.info('AudioFrameworkTest: Audio State is : released'); + break; + default: + console.info('AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------INVALID--------------'); + console.info('AudioFrameworkTest: Audio State is : invalid'); + break; + } + }); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT, async (err, setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err) { + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : ' + err.message); + stateFlag = false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : ' + setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS' + audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag == true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + await sleep(1000); + if ((audioCapCallBack.state == 2)) { + stateFlag == true; + } + } + }); + await sleep(1000); + + audioCapCallBack.stop(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------STOP RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO STOPPED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == audio.AudioState.STATE_STOPPED)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO STOPPED STATE---------'); + stateFlag == true; + } + console.info('AudioFrameworkRecLog: stateFlag : '+stateFlag); + } + }); + + await sleep(1000); + audioCapCallBack.release(async (err, value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message); + stateFlag = false; + } else { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCapCallBack.state); + stateFlag = true; + console.info('AudioFrameworkRenderLog: stateFlag : ' + stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_5000_REACH_075 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_5000_REACH_075', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep (1000); + audioCapCallBack.on('markReach', 5000, (position) => { + if (position == 5000) { + console.info('AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------'); + console.info('AudioRenderLog: mark reached: ' + position); + stateFlag = true; + } else { + stateFlag = false; + expect(stateFlag).assertTrue(); + done(); + } + }); + await sleep (1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : readvalue : '+buffer); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } else { + stateFlag = false; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_1000_REACH_076 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_1000_REACH_076', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep (1000); + audioCapCallBack.on('markReach', 1000, (position) => { + if (position == 1000) { + console.info('AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------'); + console.info('AudioRenderLog: mark reached: ' + position); + stateFlag = true; + } else { + stateFlag = false; + expect(stateFlag).assertTrue(); + done(); + } + }); + await sleep (1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : readvalue : '+buffer); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_10000_REACH_077 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_10000_REACH_077', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep (1000); + audioCapCallBack.on('markReach', 10000, (position) => { + if (position == 10000) { + console.info('AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------'); + console.info('AudioRenderLog: mark reached: ' + position); + stateFlag = true; + } else { + stateFlag = false; + expect(stateFlag).assertTrue(); + done(); + } + }); + await sleep (1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : readvalue : '+buffer); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_100_REACH_078 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_100_REACH_078', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep (1000); + audioCapCallBack.on('markReach', 100, (position) => { + if (position == 100) { + console.info('AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------'); + console.info('AudioRenderLog: mark reached: ' + position); + stateFlag = true; + } else { + stateFlag = false; + expect(stateFlag).assertTrue(); + done(); + } + }); + await sleep (1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : readvalue : '+buffer); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_1_REACH_079 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_1_REACH_079', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep (1000); + audioCapCallBack.on('markReach', 1, (position) => { + if (position == 1) { + console.info('AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------'); + console.info('AudioRenderLog: mark reached: ' + position); + stateFlag = true; + } else { + stateFlag = false; + expect(stateFlag).assertTrue(); + done(); + } + }); + await sleep (1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : readvalue : '+buffer); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_LARGEVALUE_REACH_081 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_LARGEVALUE_REACH_081', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep (1000); + audioCapCallBack.on('markReach', 1234567890, (position) => { + if (position == 1234567890) { + console.info('AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------'); + console.info('AudioRenderLog: mark reached: ' + position); + stateFlag = true; + } else { + stateFlag = false; + expect(stateFlag).assertTrue(); + done(); + } + }); + await sleep (1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : readvalue : '+buffer); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + }) + + + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_1000_084 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_1000_084', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep (1000); + audioCapCallBack.on('periodReach',1000, (position) => { + if (position == "1000") { + console.info('AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------'); + console.info('AudioRenderLog: mark reached: ' + position); + stateFlag = true ; + } else { + stateFlag = false; + } + }); + await sleep (1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : readvalue : '+buffer); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + if (stateFlag == true) { + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + } else { + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + expect(stateFlag).assertTrue(); + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + stateFlag=false; + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + } + + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_1_085 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_1_085', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep (1000); + audioCapCallBack.on('periodReach',1, (position) => { + if (position == "1") { + console.info('AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------'); + console.info('AudioRenderLog: mark reached: ' + position); + stateFlag = true ; + } else { + stateFlag = false; + } + }); + await sleep (1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : readvalue : '+buffer); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + if (stateFlag == true) { + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + } else { + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + expect(stateFlag).assertTrue(); + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + stateFlag=false; + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + } + + }) + + /* * + * @tc.number : SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_223750_086 + * @tc.name : AudioCapturer-Check-READ_BUFFER + * @tc.desc : AudioCapturer with read buffer + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_223750_086', 0, async function (done) { + var stateFlag ; + var fpath = dirPath+'/capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm'; + 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 + } + + audio.createAudioCapturer(AudioCapturerOptions,async(err,value) => { + if (err){ + console.info('AudioFrameworkRecLog: AudioCapturer Not Created : Fail : Stream Type: FAIL'); + } else { + audioCapCallBack = value; + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + } + }); + await sleep (1000); + audioCapCallBack.on('periodReach',223750, (position) => { + if (position == 223750) { + console.info('AudioFrameworkRecLog: ---------ON TRIGGERED SUCCESSFULLY---------'); + console.info('AudioRenderLog: periodReach: ' + position); + stateFlag = true ; + } else { + stateFlag = false; + } + }); + await sleep (1000); + audioManagerRec.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT,async(err,setValue) => { + console.info('AudioFrameworkRecLog: ---------SET AUDIO SCENE---------'); + if (err){ + console.info('AudioFrameworkRecLog: setAudioScene : ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: setAudioScene : SUCCESS '); + console.info('AudioFrameworkRecLog: setAudioScene : Value : '+setValue); + console.info('AudioFrameworkRecLog: getAudioScene : Value : startawait'); + console.info('AudioFrameworkRecLog: getAudioScene : Value : initaitestart'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS'+audioCapCallBack.state); + if ((audioCapCallBack.state == 1)) { + stateFlag = true; + } + } + }); + await sleep(1000); + audioCapCallBack.start(async (err,value) => { + console.info('AudioFrameworkRecLog: AudioCapturer : START SUCCESS'); + console.info('AudioFrameworkRecLog: ---------START---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + if ((audioCapCallBack.state == 2)) { + stateFlag = true; + } + } + }); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------GET BUFFER SIZE---------'); + var bufferSize = await audioCapCallBack.getBufferSize(); + console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize); + await sleep(1000); + console.info('AudioFrameworkRecLog: ---------OPEN FILE---------'); + var fd = fileio.openSync(fpath, 0o102, 0o777); + if (fd !== null) { + console.info('AudioFrameworkRecLog: file fd created'); + }else{ + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '); + stateFlag=false; + } + console.info('AudioFrameworkRecLog: ---------OPEN FILE IN APPEND MODE---------'); + 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'); + stateFlag=false; + } + await sleep(1000); + var numBuffersToCapture = 250; + while (numBuffersToCapture) { + console.info('AudioFrameworkRecLog: ---------BEFORE CHECK CB READ BUFFER---------'); + audioCapCallBack.read(bufferSize, true,async(err,buffer) => { + if (err) { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK CB READ BUFFER---------'); + console.info('AudioFrameworkRecLog: AudioCapturer : readvalue : '+buffer); + await sleep(50); + console.info('AudioFrameworkRecLog: ---------WRITE BUFFER---------'); + var number = fileio.writeSync(fd, buffer); + console.info('BufferRecLog: data written: ' + number); + await sleep(100); + stateFlag=true; + } + }); + numBuffersToCapture--; + } + await sleep(3000); + if (stateFlag == true) { + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + stateFlag = true; + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + } else { + audioCapCallBack.release(async(err,value) => { + console.info('AudioFrameworkRecLog: ---------RELEASE RECORD---------'); + if (err){ + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + stateFlag=false; + expect(stateFlag).assertTrue(); + } else {console.info('AudioFrameworkRecLog: ---------BEFORE CHECK AUDIO RELASED STATE---------'); + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCapCallBack.state); + if ((audioCapCallBack.state == 4)) { + console.info('AudioFrameworkRecLog: ---------AFTER CHECK AUDIO RELEASED STATE---------'); + console.info('AudioFrameworkRenderLog: resultFlag : '+stateFlag); + stateFlag=false; + expect(stateFlag).assertTrue(); + done(); + } + } + }); + await sleep(1000); + } + + }) + +}) diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/SR000GHQBN.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/SR000GHQBN.test.js new file mode 100644 index 0000000000000000000000000000000000000000..eeaec8175a67106a131d39b0f4eac3f44f23f93b --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/SR000GHQBN.test.js @@ -0,0 +1,1580 @@ +/* + * 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 diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-16000-2SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-16000-2SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..5dcdb4004a5c40c02ad178018d3e375133f380e9 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-16000-2SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-32000-1SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-32000-1SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..61d9393b79f2c32f836203522c29174943c5d3fa Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-32000-1SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-44100-2SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-44100-2SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..25fb78622a6440fe2d8175b496ba0021b02b28dc Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-44100-2SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-64000-3SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-64000-3SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..9bec09e5d63ea27d2a944e9cebf6a239f8239745 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-64000-3SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-8000-2SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-8000-2SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..708a6b49099ecbde34cbd04f4089c7bc8b9938d2 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-8000-2SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-96000-4SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-96000-4SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..5c483b7b7474d8d8190b2e146f9457fba273d850 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-1C-96000-4SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-11025-1SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-11025-1SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..523db76990b8fe912800a0133acd6852b74acb3c Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-11025-1SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-12000-2SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-12000-2SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..ea2234f5436d22ef4ca2f0dca2d7e675eea40524 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-12000-2SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-16000-3SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-16000-3SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..1c37c84b41e622e250020e08eb2be3b0ab04ffb6 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-16000-3SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-22050-2SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-22050-2SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..fe07a3ba102bb6b2ab582a91d2a19f52ba881601 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-22050-2SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-24000-3SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-24000-3SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..062f5346c7c1e63d7b8e46cfc6b521ba98ed9b25 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-24000-3SW.wav differ diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-48000-4SW.wav b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-48000-4SW.wav new file mode 100644 index 0000000000000000000000000000000000000000..2cb88e7a083279328e06067a033c951dabd531d3 Binary files /dev/null and b/multimedia/audio/audio_js_standard/audioManager/src/main/resources/rawfile/StarWars10s-2C-48000-4SW.wav differ