From 8d3a54e6dd7773f2bdee5c94cbd786603c4fa341 Mon Sep 17 00:00:00 2001 From: Harshaprasad Date: Wed, 29 Jun 2022 14:37:53 +0530 Subject: [PATCH] Adding scripts for State Change Listners Signed-off-by: Harshaprasad --- .../js/test/AudioCapturerChangeInfo.test.js | 1580 ++++++++++ .../main/js/test/AudioEventManagement.test.js | 274 +- .../src/main/js/test/AudioFramework.test.js | 193 +- .../src/main/js/test/AudioRenderer.test.js | 416 +-- .../js/test/AudioRendererChangeInfo.test.js | 2621 +++++++++++++++++ .../src/main/js/test/AudioVOIP.test.js | 2 +- .../src/main/js/test/List.test.js | 2 + 7 files changed, 4213 insertions(+), 875 deletions(-) create mode 100644 multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCapturerChangeInfo.test.js create mode 100644 multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRendererChangeInfo.test.js diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCapturerChangeInfo.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCapturerChangeInfo.test.js new file mode 100644 index 000000000..19efbcde6 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioCapturerChangeInfo.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('audioCapturer', function () { + var audioCapCallBack; + var audioStreamManager; + var audioStreamManagerCB; + var dirPath; + var fpath; + + const audioManager = audio.getAudioManager(); + console.info('AudioFrameworkRecLog: Create AudioManger Object JS Framework'); + + beforeAll(async function () { + console.info('AudioFrameworkTest: beforeAll: Prerequisites at the test suite level'); + dirPath = '/data/storage/el2/base/haps/entry/cache' + console.info('AudioFrameworkRecLog: Recording files Path: '+dirPath); + fpath = dirPath+'/capture_js.pcm'; + await sleep(100); + await audioManager.getStreamManager().then(async function (data) { + audioStreamManager = data; + console.info('AudioFrameworkRendererChangeLog: Get AudioStream Manager : Success '); + }).catch((err) => { + console.info('AudioFrameworkRendererChangeLog: Get AudioStream Manager : ERROR : '+err.message); + }); + + audioManager.getStreamManager((err, data) => { + if (err) { + console.error('AudioFrameworkChange: Get AudioStream Manager : ERROR : '+err.message); + } + else { + audioStreamManagerCB = data; + console.info('AudioFrameworkChange: Get AudioStream Manager : Success '); + } + }); + await sleep(1000); + console.info('AudioFrameworkTest: beforeAll: END'); + }) + + 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 () { + await sleep(1000); + console.info('AudioFrameworkTest: afterAll: Test suite-level cleanup condition'); + }) + + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + /* * + * @tc.number : SUB_AUDIO_ON_CAPTURER_CHANGE_001 + * @tc.name : AudioCapturerChange - ON_STATE_PREPARED + * @tc.desc : AudioCapturerChange - ON_STATE_PREPARED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_ON_CAPTURER_CHANGE_001', 0, async function (done) { + var audioCap ; + 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 = false; + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [CAPTURER-CHANGE-ON-001] ######### CapturerChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_ON_CAPTURER_CHANGE_002 + * @tc.name : AudioCapturerChange - ON_STATE_RUNNING + * @tc.desc : AudioCapturerChange - ON_STATE_RUNNING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_ON_CAPTURER_CHANGE_002', 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 = false; + + 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); + }); + + audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + await sleep(500); + audioStreamManagerCB.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [CAPTURER-CHANGE-ON-002] ######### CapturerChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_ON_CAPTURER_CHANGE_003 + * @tc.name : AudioCapturerChange - ON_STATE_STOPPED + * @tc.desc : AudioCapturerChange - ON_STATE_STOPPED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_ON_CAPTURER_CHANGE_003', 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 = false; + + 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); + }); + + await audioCap.start().then(async function () { + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [CAPTURER-CHANGE-ON-003] ######### CapturerChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_ON_CAPTURER_CHANGE_004 + * @tc.name : AudioCapturerChange - ON_STATE_RELEASED + * @tc.desc : AudioCapturerChange - ON_STATE_RELEASED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_ON_CAPTURER_CHANGE_004', 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 = false; + + 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); + }); + + await audioCap.start().then(async function () { + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + await audioCap.stop().then(async function () { + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + }); + + audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + await sleep (500); + + audioStreamManagerCB.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [CAPTURER-CHANGE-ON-004] ######### CapturerChange Off is called #########'); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /** + * @tc.number : SUB_AUDIO_ON_CAPTURER_CHANGE_005 + * @tc.name : AudioCapturerChange - ON_SOURCE_TYPE_MIC + * @tc.desc : AudioCapturerChange - ON_SOURCE_TYPE_MIC + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 +**/ + + it('SUB_AUDIO_ON_CAPTURER_CHANGE_005', 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 = false; + + 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); + }); + + await audioCap.start().then(async function () { + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + await audioCap.stop().then(async function () { + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + }); + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [CAPTURER-CHANGE-ON-005] ######### CapturerChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /** + * @tc.number : SUB_AUDIO_ON_CAPTURER_CHANGE_006 + * @tc.name : AudioCapturerChange - ON_SOURCE_TYPE_VOICE_COMMUNICATION + * @tc.desc : AudioCapturerChange - ON_SOURCE_TYPE_VOICE_COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 +**/ + + it('SUB_AUDIO_ON_CAPTURER_CHANGE_006', 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_VOICE_COMMUNICATION, + capturerFlags: 1 + } + + var AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + var resultFlag = false; + + var audioCap; + + audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + + await sleep (500); + + audioStreamManagerCB.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [CAPTURER-CHANGE-ON-006] ######### CapturerChange Off is called #########'); + + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_ON_CAPTURER_CHANGE_007 + * @tc.name : AudioCapturerChange - STREAMID + * @tc.desc : AudioCapturerChange - STREAMID + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_ON_CAPTURER_CHANGE_007', 0, async function (done) { + var audioCap ; + 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 = false; + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [CAPTURER-CHANGE-ON-007] ######### CapturerChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + + /* * + * @tc.number : SUB_AUDIO_ON_CAPTURER_CHANGE_008 + * @tc.name : AudioCapturerChange - CLIENTUID AND CAPTURERFLAG + * @tc.desc : AudioCapturerChange - CLIENTUID AND CAPTURERFLAG + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_ON_CAPTURER_CHANGE_008', 0, async function (done) { + var audioCap ; + 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 = false; + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [CAPTURER-CHANGE-ON-008] ######### CapturerChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + + + + /* * + * @tc.number : SUB_AUDIO_OFF_CAPTURER_CHANGE_001 + * @tc.name : AudioCapturerChange - OFF_STATE_PREPARED + * @tc.desc : AudioCapturerChange - OFF_STATE_PREPARED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_OFF_CAPTURER_CHANGE_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 = true; + + var audioCap; + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_OFF_CAPTURER_CHANGE_002 + * @tc.name : AudioCapturerChange - OFF_STATE_RUNNING + * @tc.desc : AudioCapturerChange - OFF_STATE_RUNNING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_OFF_CAPTURER_CHANGE_002', 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 = true; + 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); + }); + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_OFF_CAPTURER_CHANGE_003 + * @tc.name : AudioCapturerChange - OFF_STATE_STOPPED + * @tc.desc : AudioCapturerChange - OFF_STATE_STOPPED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_OFF_CAPTURER_CHANGE_003', 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 = true; + 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); + }); + + await audioCap.start().then(async function () { + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + }); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + + }) + + /* * + * @tc.number : SUB_AUDIO_OFF_CAPTURER_CHANGE_004 + * @tc.name : AudioCapturerChange - OFF_STATE_RELEASED + * @tc.desc : AudioCapturerChange - OFF_STATE_RELEASED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_OFF_CAPTURER_CHANGE_004', 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 = true; + 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); + }); + + await audioCap.start().then(async function () { + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + await audioCap.stop().then(async function () { + console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + }); + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_GET_CAPTURER_CHANGE_PROMISE_001 + * @tc.name : AudioCapturerChange - GET_STATE_PREPARED + * @tc.desc : AudioCapturerChange - GET_STATE_PREPARED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_GET_CAPTURER_CHANGE_PROMISE_001', 0, async function (done) { + var audioCap ; + 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 = false; + audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + + await sleep(500); + + await audioStreamManagerCB.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { + console.info('AFCapturerChangeLog: [GET_CAP_STA_1_PR] **** Get Promise Called ****'); + if (AudioCapturerChangeInfoArray!=null) { + for (let i=0;i { + console.log('AFCapLog: getCurrentAudioCapturerInfoArray :ERROR: '+err.message); + resultFlag = false; + }); + + audioStreamManagerCB.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [GET_CAPTURER_STATE_1_PR] ## CapCh Off is called ##'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_GET_CAPTURER_CHANGE_PROMISE_002 + * @tc.name : AudioCapturerChange - GET_STATE_RUNNING + * @tc.desc : AudioCapturerChange - GET_STATE_RUNNING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_GET_CAPTURER_CHANGE_PROMISE_002', 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 = false; + + 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); + }); + + await sleep(500); + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + await sleep(500); + + await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { + console.info('AFCapLog: [GET_CAPTURER_STATE_2_PROMISE] **** Get Promise Called ****'); + if (AudioCapturerChangeInfoArray!=null) { + for (let i=0;i { + console.log('AFCapLog: getCurrentAudioCapturerInfoArray :ERROR: '+err.message); + resultFlag = false; + }); + + audioStreamManager.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [GET_CAPTURER_STATE_2_PROMISE] ######### CapturerChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_GET_CAPTURER_CHANGE_PROMISE_003 + * @tc.name : AudioCapturerChange - GET_STATE_STOPPED + * @tc.desc : AudioCapturerChange - GET_STATE_STOPPED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_GET_CAPTURER_CHANGE_PROMISE_003', 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 = false; + + 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); + }); + + await audioCap.start().then(async function () { + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + }); + + await sleep(500); + + await audioStreamManager.getCurrentAudioCapturerInfoArray().then( function (AudioCapturerChangeInfoArray) { + console.info('AFCapLog: [GET_CAPTURER_STATE_3_PROMISE] **** Get Promise Called ****'); + if (AudioCapturerChangeInfoArray!=null) { + for (let i=0;i { + console.log('AFCapLog: getCurrentAudioCapturerInfoArray :ERROR: '+err.message); + resultFlag = false; + }); + + audioStreamManager.off('audioCapturerChange'); + await sleep(100); + console.info('AFCapLog: [GET_CAPTURER_STATE_3_PROMISE] ######### CapturerChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Capturer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_001 + * @tc.name : AudioCapturerChange - GET_STATE_PREPARED + * @tc.desc : AudioCapturerChange - GET_STATE_PREPARED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_001', 0, async function (done) { + var audioCap ; + 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 = false; + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { + console.info('AFCapLog: [GET_CAPTURER_STATE_1_CALLBACK] **** Get Callback Called ****'); + await sleep(100); + if (err) { + console.log('AFCapLog: getCurrentAudioCapturerInfoArray :ERROR: '+err.message); + resultFlag = false; + } + else { + if (AudioCapturerChangeInfoArray !=null) { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_002 + * @tc.name : AudioCapturerChange - GET_STATE_RUNNING + * @tc.desc : AudioCapturerChange - GET_STATE_RUNNING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_002', 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 = false; + + 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); + }); + + await sleep(500); + + audioStreamManagerCB.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManagerCB.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { + console.info('AFCapLog: [GET_CAPTURER_STATE_2_CALLBACK] **** Get Callback Called ****'); + await sleep(100); + if (err) { + console.log('AFCapLog: getCurrentAudioCapturerInfoArray :ERROR: '+err.message); + resultFlag = false; + } + else { + if (AudioCapturerChangeInfoArray !=null) { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_003 + * @tc.name : AudioCapturerChange - GET_STATE_STOPPED + * @tc.desc : AudioCapturerChange - GET_STATE_STOPPED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_GET_CAPTURER_CHANGE_CALLBACK_003', 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 = false; + + 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); + }); + + await audioCap.start().then(async function () { + console.info('AudioFrameworkRecLog: Capturer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.on('audioCapturerChange', (AudioCapturerChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.getCurrentAudioCapturerInfoArray(async (err, AudioCapturerChangeInfoArray) => { + console.info('AFCapLog: [GET_CAPTURER_STATE_3_CALLBACK] **** Get Callback Called ****'); + await sleep(100); + if (err) { + console.log('AFCapLog: getCurrentAudioCapturerInfoArray :ERROR: '+err.message); + resultFlag = false; + } + else { + if (AudioCapturerChangeInfoArray !=null) { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + +}) diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioEventManagement.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioEventManagement.test.js index 13e3bb6dc..a46949ca3 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioEventManagement.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioEventManagement.test.js @@ -13,12 +13,13 @@ * 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_audio_1', function () { +describe('audioManger', function () { console.info('AudioFrameworkTest: Create AudioManger Object JS Framework'); const audioManager = audio.getAudioManager(); var deviceRoleValue = null; @@ -59,9 +60,6 @@ describe('audioManger_audio_1', function () { else if (value.deviceType == 3){ devTypeName = 'WIRED_HEADSET'; } - else if (value.deviceType == 7){ - devTypeName = 'BLUETOOTH_SCO'; - } else if (value.deviceType == 8){ devTypeName = 'BLUETOOTH_A2DP'; } @@ -491,63 +489,7 @@ describe('audioManger_audio_1', function () { 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 @@ -665,139 +607,6 @@ describe('audioManger_audio_1', function () { 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 @@ -946,83 +755,6 @@ describe('audioManger_audio_1', function () { }); }) - /* * - * @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_DeviceType_001 * @tc.name : DeviceType - INVALID diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js index fecd22eea..3151d7355 100755 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioFramework.test.js @@ -13,11 +13,12 @@ * limitations under the License. */ + import audio from '@ohos.multimedia.audio'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; -describe('audioManger_audio_2', function () { +describe('audioManger', function () { console.info('AudioFrameworkTest: Create AudioManger Object JS Framework'); const audioManager = audio.getAudioManager(); var deviceRoleValue = null; @@ -29,7 +30,6 @@ describe('audioManger_audio_2', function () { var maxVol = 15; var lowVol = 5; var highVol = 14; - var newVol = 20; var outOfRangeVol = 28; var longValue = '28374837458743875804735081439085918459801437584738967509184509813904850914375904790589104801843'; @@ -59,9 +59,6 @@ describe('audioManger_audio_2', function () { else if (value.deviceType == 3){ devTypeName = 'WIRED_HEADSET'; } - else if (value.deviceType == 7){ - devTypeName = 'BLUETOOTH_SCO'; - } else if (value.deviceType == 8){ devTypeName = 'BLUETOOTH_A2DP'; } @@ -883,32 +880,6 @@ describe('audioManger_audio_2', function () { done(); }) - /* * - * @tc.number : SUB_AUDIO_MANAGER_SetVolume_030 - * @tc.name : setVolume - Media - Promise - Change Ringtone vol - * @tc.desc : Setvol to 20 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_AUDIO_MANAGER_SetVolume_030', 0, async function (done) { - const promise = audioManager.setVolume(audio.AudioVolumeType.MEDIA,newVol); - promise.then(function () { - audioManager.setVolume(audio.AudioVolumeType.RINGTONE,maxVol); - audioManager.getVolume(audio.AudioVolumeType.MEDIA).then(function (data) { - if(data == lowVol){ - console.info('AudioFrameworkTest: Media getVolume Promise: ENAME : PASS :' + data); - expect(true).assertTrue(); - } - else{ - console.info('AudioFrameworkTest: Media getVolume Promise: ENAME : FAIL :' + data); - expect(false).assertTrue(); - } - }); - }); - await promise; - done(); - }) /* * * @tc.number : SUB_AUDIO_MANAGER_SetVolume_026 * @tc.name : setVolume - Media - Callback - Change Ringtone vol @@ -973,35 +944,6 @@ describe('audioManger_audio_2', function () { await promise; done(); }) - /* * - * @tc.number : SUB_AUDIO_MANAGER_SetVolume_029 - * @tc.name : setVolume - Ringtone - Promise - Change Media vol - * @tc.desc : Setvol to 20 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_AUDIO_MANAGER_SetVolume_029', 0, async function (done) { - const promise = audioManager.setVolume(audio.AudioVolumeType.RINGTONE,newVol); - promise.then(function () { - console.info('AudioFrameworkTest: Ringtone setVolume promise: ENAME: successful'); - audioManager.setVolume(audio.AudioVolumeType.MEDIA,lowVol); - audioManager.getVolume(audio.AudioVolumeType.RINGTONE).then(function (data) { - if(data == highVol){ - console.info('AudioFrameworkTest: Ringtone getVolume Promise: ENAME: PASS :' + data); - expect(true).assertTrue(); - } - else{ - console.info('AudioFrameworkTest: Ringtone getVolume Promise: ENAME: FAIL :' + data); - expect(false).assertTrue(); - } - }); - }); - await promise; - done(); - }) - - /* * * @tc.number : SUB_AUDIO_MANAGER_SetVolume_028 @@ -3159,34 +3101,6 @@ describe('audioManger_audio_2', function () { }); }) - /* * - * @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_001 - * @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_001', 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(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_002 * @tc.name : setDeviceActive - SPEAKER - deactivate - Promise @@ -3244,71 +3158,7 @@ describe('audioManger_audio_2', function () { done(); }) - /* * - * @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_004 - * @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_004', 0, async function (done) { - 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(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_005 - * @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_005', 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(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_006 * @tc.name : setDeviceActive - SPEAKER - deactivate - Callback @@ -3381,42 +3231,7 @@ describe('audioManger_audio_2', function () { }); }) - /* * - * @tc.number : SUB_AUDIO_MANAGER_setDeviceActive_008 - * @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_008', 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(7,(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_setAudioParameter_001 * @tc.name : setAudioParameter - Promise - Character & Number 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 index 92b7190c8..54675cf80 100644 --- 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 @@ -23,7 +23,7 @@ import ability_featureAbility from '@ohos.ability.featureAbility'; import resourceManager from '@ohos.resourceManager'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; -describe('audioRenderer_audio_1', function () { +describe('audioRenderer', function () { let fdRead; let readpath; @@ -1400,7 +1400,7 @@ describe('audioRenderer_audio_1', function () { }); await sleep(waitTime); } - await sleep(2000); + await sleep(100); if (resultFlag == false){ console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); return resultFlag; @@ -7523,416 +7523,4 @@ describe('audioRenderer_audio_1', function () { 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 - } - - readpath='StarWars10s-2C-48000-4SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - await sleep(9000); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - 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 - } - - readpath='StarWars10s-1C-44100-2SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - await sleep(5000); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - 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 - } - - readpath='StarWars10s-1C-8000-2SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - await sleep(100); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - 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 - } - - readpath='StarWars10s-1C-32000-1SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - await sleep(100); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - 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 - } - - readpath='StarWars10s-1C-64000-3SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - await sleep(100); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - 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 - } - - readpath='StarWars10s-1C-96000-4SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - await sleep(100); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - 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 - } - - readpath='StarWars10s-2C-11025-1SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - await sleep(100); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - 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 - } - - readpath='StarWars10s-2C-12000-2SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - await sleep(100); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - 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 - } - - readpath='StarWars10s-2C-16000-3SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - await sleep(100); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - 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 - } - - readpath='StarWars10s-2C-22050-2SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - await sleep(100); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - 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 - } - - readpath='StarWars10s-2C-24000-3SW.wav' - await getFdRead(readpath, done) - var resultFlag = await playbackCB(AudioRendererOptions, readpath); - await sleep(100); - console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag); - expect(resultFlag).assertTrue(); - await closeFileDescriptor(readpath); - done(); - }) - - }) \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRendererChangeInfo.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRendererChangeInfo.test.js new file mode 100644 index 000000000..3505a1c2c --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioRendererChangeInfo.test.js @@ -0,0 +1,2621 @@ +/* + * 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 bundle from '@ohos.bundle'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import featureAbility from '@ohos.ability.featureAbility' +import ability_featureAbility from '@ohos.ability.featureAbility'; +import resourceManager from '@ohos.resourceManager'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; + +describe('audioRenderer', function () { + + var audioStreamManager; + var audioStreamManagerCB; + let fdRead; + let readpath; + const audioManager = audio.getAudioManager(); + console.info('AFRenLog: Create AudioManger Object JS Framework'); + + beforeAll(async function () { + await applyPermission(); + await audioManager.getStreamManager().then(async function (data) { + audioStreamManager = data; + console.info('AFRenLog: Get AudioStream Manager : Success '); + }).catch((err) => { + console.info('AFRenLog: Get AudioStream Manager : ERROR : '+err.message); + }); + + audioManager.getStreamManager((err, data) => { + if (err) { + console.error('AudioFrameworkChange: Get AudioStream Manager : ERROR : '+err.message); + } + else { + audioStreamManagerCB = data; + console.info('AudioFrameworkChange: Get AudioStream Manager : Success '); + } + }); + await sleep(1000); + + console.info('AFRenLog: beforeAll: Prerequisites at the test suite level'); + }) + + beforeEach(async function () { + console.info('AFRenLog: beforeEach: Prerequisites at the test case level'); + await sleep(1000); + }) + + afterEach(function () { + console.info('AFRenLog: afterEach: Test case-level clearance conditions'); + }) + + afterAll(async function () { + console.info('AFRenLog: afterAll: Test suite-level cleanup condition'); + }) + + function sleep (ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + async function getFileDescriptor(fileName) { + let fileDescriptor = undefined; + await resourceManager.getResourceManager().then(async (mgr) => { + await mgr.getRawFileDescriptor(fileName).then(value => { + fileDescriptor = { fd: value.fd, offset: value.offset, length: value.length }; + }).catch(error => { + console.log('AFRenLog:case getRawFileDescriptor err: '+error); + }); + }); + return fileDescriptor; + } + + async function closeFileDescriptor(fileName) { + await resourceManager.getResourceManager().then(async (mgr) => { + await mgr.closeRawFileDescriptor(fileName).then(value => { + console.log('AFRenLog:case closeRawFileDescriptor success for file:'+fileName); + }).catch(error => { + console.log('AFRenLog:case closeRawFileDescriptor err: '+error); + }); + }); + } + async function getFdRead(pathName, done) { + await getFileDescriptor(pathName).then((res) => { + if (res == undefined) { + expect().assertFail(); + console.info('AFRenLog:case error fileDescriptor undefined, open file fail'); + done(); + } else { + fdRead = res.fd; + console.info("AFRenLog:case 0 fdRead is: "+fdRead); + } + }) + } + async function applyPermission() { + let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.audio.audiomanager', 0, 100); + let atManager = abilityAccessCtrl.createAtManager(); + if (atManager != null) { + let tokenID = appInfo.accessTokenId; + console.info('AFRenLog:[permission] case accessTokenID is '+tokenID); + let permissionName1 = 'ohos.permission.MEDIA_LOCATION'; + let permissionName2 = 'ohos.permission.READ_MEDIA'; + let permissionName3 = 'ohos.permission.WRITE_MEDIA'; + await atManager.grantUserGrantedPermission(tokenID, permissionName1, 1).then((result) => { + console.info('AFRenLog:[permission] case grantUserGrantedPermission success :'+result); + }).catch((err) => { + console.info('AFRenLog:[permission] case grantUserGrantedPermission failed :'+err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName2, 1).then((result) => { + console.info('AFRenLog:[permission] case grantUserGrantedPermission success :'+result); + }).catch((err) => { + console.info('AFRenLog:[permission] case grantUserGrantedPermission failed :'+err); + }); + await atManager.grantUserGrantedPermission(tokenID, permissionName3, 1).then((result) => { + console.info('AFRenLog:[permission] case grantUserGrantedPermission success :'+result); + }).catch((err) => { + console.info('AFRenLog:[permission] case grantUserGrantedPermission failed :'+err); + }); + } else { + console.info('AFRenLog:[permission] case apply permission failed, createAtManager failed'); + } + } + + /* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_001 + * @tc.name : AudioRendererChange - ON_STATE_PREPARED + * @tc.desc : AudioRendererChange - ON_STATE_PREPARED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_001', 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; + + audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep (500); + + audioStreamManagerCB.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-001] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_002 + * @tc.name : AudioRendererChange - ON_STATE_RUNNING + * @tc.desc : AudioRendererChange - ON_STATE_RUNNING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_002', 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_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + 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('AFRenLog: AudioRender Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: renderInstant start :ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-002] ######### RendererChange Off is called #########'); + + + await audioRen.stop().then(async function () { + console.info('AFRenLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer stop:ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_003 + * @tc.name : AudioRendererChange - ON_STATE_STOPPED + * @tc.desc : AudioRendererChange - ON_STATE_STOPPED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_003', 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 = false; + + var audioRen; + + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AFRenLog: AudioRender Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await audioRen.start().then(async function () { + console.info('AFRenLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AFRenLog: renderInstant start :ERROR : '+err.message); + }); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: Renderer stop:ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-003] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_004 + * @tc.name : AudioRendererChange - ON_STATE_RELEASED + * @tc.desc : AudioRendererChange - ON_STATE_RELEASED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_004', 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('AFRenLog: AudioRender Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await audioRen.start().then(async function () { + console.info('AFRenLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AFRenLog: renderInstant start :ERROR : '+err.message); + }); + + await audioRen.stop().then(async function () { + console.info('AFRenLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer stop:ERROR : '+err.message); + }); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-004] ######### RendererChange Off is called #########'); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_005 + * @tc.name : AudioRendererChange - ON_STATE_PAUSED + * @tc.desc : AudioRendererChange - ON_STATE_PAUSED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_005', 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('AFRenLog: AudioRender Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await audioRen.start().then(async function () { + console.info('AFRenLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AFRenLog: renderInstant start :ERROR : '+err.message); + }); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: renderInstant Pause :ERROR : '+err.message); + }); + + await sleep (500); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-005] ######### RendererChange Off is called #########'); + + await audioRen.stop().then(async function () { + console.info('AFRenLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer stop:ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_006 + * @tc.name : AudioRendererChange - ON_CONTENT_TYPE_RINGTONE + * @tc.desc : AudioRendererChange - ON_CONTENT_TYPE_RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_006', 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; + + audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep(500); + audioStreamManagerCB.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-006] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + +/* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_007 + * @tc.name : AudioRendererChange - ON_CONTENT_TYPE_UNKNOWN + * @tc.desc : AudioRendererChange - ON_CONTENT_TYPE_UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_007', 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; + + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep (500); + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-007] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + + + + +/* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_008 + * @tc.name : AudioRendererChange - ON_CONTENT_TYPE_SPEECH + * @tc.desc : AudioRendererChange - ON_CONTENT_TYPE_SPEECH + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_008', 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; + + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep (500); + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-008] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + + +/* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_009 + * @tc.name : AudioRendererChange - ON_CONTENT_TYPE_MUSIC + * @tc.desc : AudioRendererChange - ON_CONTENT_TYPE_MUSIC + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_009', 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; + + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep (500); + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-009] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + +/* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_010 + * @tc.name : AudioRendererChange - ON_CONTENT_TYPE_MOVIES + * @tc.desc : AudioRendererChange - ON_CONTENT_TYPE_MOVIES + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_010', 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; + + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep (500); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-010] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + + +/* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_011 + * @tc.name : AudioRendererChange - ON_CONTENT_TYPE_SONIFICATION + * @tc.desc : AudioRendererChange - ON_CONTENT_TYPE_SONIFICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_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_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep (500); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-011] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + +/* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_012 + * @tc.name : AudioRendererChange - ON_STREAM_USAGE_UNKNOWN + * @tc.desc : AudioRendererChange - ON_STREAM_USAGE_UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_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_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var audioRen; + + audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManagerCB.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-012] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + +/* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_013 + * @tc.name : AudioRendererChange - ON_STREAM_USAGE_MEDIA + * @tc.desc : AudioRendererChange - ON_STREAM_USAGE_MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_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_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-013] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + + +/* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_014 + * @tc.name : AudioRendererChange - ON_STREAM_USAGE_MEDIA + * @tc.desc : AudioRendererChange - ON_STREAM_USAGE_MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_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_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-014] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + +/* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_015 + * @tc.name : AudioRendererChange - ON_STREAM_USAGE_MEDIA + * @tc.desc : AudioRendererChange - ON_STREAM_USAGE_MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_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_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep(500); + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-015] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + +/* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_016 + * @tc.name : AudioRendererChange - STREAMID + * @tc.desc : AudioRendererChange - STREAMID + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_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_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep(500); + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-015] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + + /* * + * @tc.number : SUB_AUDIO_ON_RENDERER_CHANGE_017 + * @tc.name : AudioRendererChange - CLIENTUID & RENDERERFLAG + * @tc.desc : AudioRendererChange - CLIENTUID & RENDERERFLAG + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_ON_RENDERER_CHANGE_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_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + var resultFlag = false; + + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await sleep(500); + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [RENDERER-CHANGE-ON-015] ######### RendererChange Off is called #########'); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + /* * + * @tc.number : SUB_AUDIO_OFF_RENDERER_CHANGE_001 + * @tc.name : AudioRendererChange - OFF_STATE_PREPARED + * @tc.desc : AudioRendererChange - OFF_STATE_PREPARED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_OFF_RENDERER_CHANGE_001', 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_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 1 + } + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + var resultFlag = true; + var audioRen; + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_OFF_RENDERER_CHANGE_002 + * @tc.name : AudioRendererChange - OFF_STATE_RUNNING + * @tc.desc : AudioRendererChange - OFF_STATE_RUNNING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_OFF_RENDERER_CHANGE_002', 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_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('AFRenLog: AudioRender Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: renderInstant start :ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_OFF_RENDERER_CHANGE_003 + * @tc.name : AudioRenderer - OFF_STATE_STOPPED + * @tc.desc : AudioRenderer - OFF_STATE_STOPPED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_OFF_RENDERER_CHANGE_003', 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('AFRenLog: AudioRender Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await audioRen.start().then(async function () { + console.info('AFRenLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AFRenLog: renderInstant start :ERROR : '+err.message); + }); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: Renderer stop:ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_OFF_RENDERER_CHANGE_004 + * @tc.name : AudioRendererChange - OFF_STATE_RELEASED + * @tc.desc : AudioRendererChange - OFF_STATE_RELEASED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_OFF_RENDERER_CHANGE_004', 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_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('AFRenLog: AudioRender Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await audioRen.start().then(async function () { + console.info('AFRenLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AFRenLog: renderInstant start :ERROR : '+err.message); + }); + + await audioRen.stop().then(async function () { + console.info('AFRenLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer stop:ERROR : '+err.message); + }); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_OFF_RENDERER_CHANGE_005 + * @tc.name : AudioRendererChange - OFF_STATE_PAUSED + * @tc.desc : AudioRendererChange - OFF_STATE_PAUSED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_OFF_RENDERER_CHANGE_005', 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_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('AFRenLog: AudioRender Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await audioRen.start().then(async function () { + console.info('AFRenLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AFRenLog: renderInstant start :ERROR : '+err.message); + }); + + audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: renderInstant Pause :ERROR : '+err.message); + }); + + await audioRen.stop().then(async function () { + console.info('AFRenLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer stop:ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_GET_RENDERER_CHANGE_PROMISE_001 + * @tc.name : AudioRendererChange - GET_STATE_PREPARED + * @tc.desc : AudioRendererChange - GET_STATE_PREPARED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_GET_RENDERER_CHANGE_PROMISE_001', 0, async function (done) { + var audioCap ; + 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 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; + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: AudioRenderer Created : ERROR : '+err.message); + }); + + await sleep(500); + + await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { + console.info('AFRenLog: [GET_RENDERER_STATE_1_PROMISE] ######### Get Promise is called ##########'); + if (AudioRendererChangeInfoArray!=null) { + for (let i=0;i { + console.log('AFRenLog: getCurrentAudioRendererInfoArray :ERROR: '+err.message); + resultFlag = false; + }); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [GET_RENDERER_STATE_1_PROMISE] ######### RendererChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_GET_RENDERER_CHANGE_PROMISE_002 + * @tc.name : AudioRendererChange - GET_STATE_RUNNING + * @tc.desc : AudioRendererChange - GET_STATE_RUNNING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_GET_RENDERER_CHANGE_PROMISE_002', 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 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 audioCap; + + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioCap = data; + console.info('AudioFrameworkRecLog: AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioRenderer Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Renderer start :ERROR : '+err.message); + }); + + await sleep(500); + + await audioStreamManagerCB.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { + console.info('AFRenLog: [GET_RENDERER_STATE_2_PROMISE] ######### Get Promise is called ##########'); + if (AudioRendererChangeInfoArray!=null) { + for (let i=0;i { + console.log('AFRenLog: getCurrentAudioRendererInfoArray :ERROR: '+err.message); + resultFlag = false; + }); + + audioStreamManagerCB.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [GET_RENDERER_STATE_2_PROMISE] ######### RendererChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_GET_RENDERER_CHANGE_PROMISE_003 + * @tc.name : AudioRendererChange - GET_STATE_STOPPED + * @tc.desc : AudioRendererChange - GET_STATE_STOPPED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_GET_RENDERER_CHANGE_PROMISE_003', 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 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 audioCap; + + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioCap = data; + console.info('AudioFrameworkRecLog: AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioRenderer Created : ERROR : '+err.message); + }); + + await audioCap.start().then(async function () { + console.info('AudioFrameworkRecLog: Renderer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Renderer start :ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Renderer stop:ERROR : '+err.message); + }); + + await sleep(500); + + await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { + console.info('AFRenLog: [GET_RENDERER_STATE_3_PROMISE] ######### Get Promise is called ##########'); + if (AudioRendererChangeInfoArray!=null) { + for (let i=0;i { + console.log('AFRenLog: getCurrentAudioRendererInfoArray :ERROR: '+err.message); + resultFlag = false; + }); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [GET_RENDERER_STATE_3_PROMISE] ######### RendererChange Off is called #########'); + + await audioCap.release().then(async function () { + console.info('AudioFrameworkRecLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_GET_RENDERER_CHANGE_PROMISE_004 + * @tc.name : AudioRendererChange - GET_STATE_PAUSED + * @tc.desc : AudioRendererChange - GET_STATE_PAUSED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_GET_RENDERER_CHANGE_PROMISE_004', 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('AFRenLog: AudioRender Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await audioRen.start().then(async function () { + console.info('AFRenLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AFRenLog: renderInstant start :ERROR : '+err.message); + }); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: renderInstant Pause :ERROR : '+err.message); + }); + + await sleep (500); + + await audioStreamManager.getCurrentAudioRendererInfoArray().then( function (AudioRendererChangeInfoArray) { + console.info('AFRenLog: [GET_RENDERER_STATE_5_PROMISE] ######### Get Promise is called ##########'); + if (AudioRendererChangeInfoArray!=null) { + for (let i=0;i { + console.log('AFRenLog: getCurrentAudioRendererInfoArray :ERROR: '+err.message); + resultFlag = false; + }); + + audioStreamManager.off('audioRendererChange'); + await sleep(100); + console.info('AFRenLog: [GET_RENDERER_STATE_5_PROMISE] ######### RendererChange Off is called #########'); + + await audioRen.stop().then(async function () { + console.info('AFRenLog: Renderer stopped : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer stop:ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + + /* * + * @tc.number : SUB_AUDIO_GET_RENDERER_CHANGE_CALLBACK_001 + * @tc.name : AudioRendererChange - GET_STATE_PREPARED + * @tc.desc : AudioRendererChange - GET_STATE_PREPARED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0*/ + + it('SUB_AUDIO_GET_RENDERER_CHANGE_CALLBACK_001', 0, async function (done) { + var audioCap ; + 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 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; + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: AudioRenderer Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => { + console.info('AFRenLog: [GET_RENDERER_STATE_1_CALLBACK] **** Get Callback Called ****'); + await sleep(100); + if (err) { + console.log('AFRenLog: getCurrentAudioRendererInfoArray :ERROR: '+err.message); + resultFlag = false; + } + else { + if (AudioRendererChangeInfoArray !=null) { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + /* * + * @tc.number : SUB_AUDIO_GET_RENDERER_CHANGE_CALLBACK_002 + * @tc.name : AudioRendererChange - GET_STATE_RUNNING + * @tc.desc : AudioRendererChange - GET_STATE_RUNNING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_GET_RENDERER_CHANGE_CALLBACK_002', 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 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 audioCap; + + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioCap = data; + console.info('AudioFrameworkRecLog: AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioRenderer Created : ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManagerCB.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Renderer start :ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManagerCB.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => { + console.info('AFRenLog: [GET_RENDERER_STATE_2_CALLBACK] **** Get Callback Called ****'); + await sleep(100); + if (err) { + console.log('AFRenLog: getCurrentAudioRendererInfoArray :ERROR: '+err.message); + resultFlag = false; + } + else { + if (AudioRendererChangeInfoArray !=null) { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_GET_RENDERER_CHANGE_CALLBACK_003 + * @tc.name : AudioRendererChange - GET_STATE_STOPPED + * @tc.desc : AudioRendererChange - GET_STATE_STOPPED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + * */ + + + it('SUB_AUDIO_GET_RENDERER_CHANGE_CALLBACK_003', 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 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 audioCap; + + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioCap = data; + console.info('AudioFrameworkRecLog: AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AudioFrameworkRecLog: AudioRenderer Created : ERROR : '+err.message); + }); + + await audioCap.start().then(async function () { + console.info('AudioFrameworkRecLog: Renderer started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRecLog: Renderer start :ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Renderer stop:ERROR : '+err.message); + }); + + await sleep(500); + + audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => { + console.info('AFRenLog: [GET_RENDERER_STATE_3_CALLBACK] **** Get Callback Called ****'); + await sleep(100); + if (err) { + console.log('AFRenLog: getCurrentAudioRendererInfoArray :ERROR: '+err.message); + resultFlag = false; + } + else { + if (AudioRendererChangeInfoArray !=null) { + for (let i=0;i { + console.info('AudioFrameworkRecLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + + }) + + /* * + * @tc.number : SUB_AUDIO_GET_RENDERER_CHANGE_CALLBACK_004 + * @tc.name : AudioRendererChange - GET_STATE_PAUSED + * @tc.desc : AudioRendererChange - GET_STATE_PAUSED + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_AUDIO_GET_RENDERER_CHANGE_CALLBACK_004', 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('AFRenLog: AudioRender Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: AudioRender Created : ERROR : '+err.message); + }); + + await audioRen.start().then(async function () { + console.info('AFRenLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AFRenLog: renderInstant start :ERROR : '+err.message); + }); + + audioStreamManager.on('audioRendererChange', (AudioRendererChangeInfoArray) => { + for (let i=0;i { + console.info('AFRenLog: renderInstant Pause :ERROR : '+err.message); + }); + + await sleep (500); + + audioStreamManager.getCurrentAudioRendererInfoArray(async (err, AudioRendererChangeInfoArray) => { + console.info('AFRenLog: [GET_RENDERER_STATE_5_CALLBACK] **** Get Callback Called ****'); + await sleep(100); + if (err) { + console.log('AFRenLog: getCurrentAudioRendererInfoArray :ERROR: '+err.message); + resultFlag = false; + } + else { + if (AudioRendererChangeInfoArray !=null) { + for (let i=0;i { + console.info('AFRenLog: Renderer stop:ERROR : '+err.message); + }); + + await audioRen.release().then(async function () { + console.info('AFRenLog: Renderer release : SUCCESS'); + }).catch((err) => { + console.info('AFRenLog: Renderer release :ERROR : '+err.message); + }); + + expect(resultFlag).assertTrue(); + done(); + }) + + +}) \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioVOIP.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioVOIP.test.js index 607687b57..f50e380f7 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioVOIP.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioVOIP.test.js @@ -24,7 +24,7 @@ import featureAbility from '@ohos.ability.featureAbility' import resourceManager from '@ohos.resourceManager'; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'; -describe('audioRenderer_audio_2', function () { +describe('audioRenderer', function () { var mediaDir; let fdRead; let readpath; 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 fe05387b0..04b312452 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 @@ -20,4 +20,6 @@ require('./AudioCall.test.js') require('./AudioCapturer.test.js') require('./AudioEventManagement.test.js') require('./AudioRenderer.test.js') +require('./AudioRendererChangeInfo.test.js') +require('./AudioCapturerChangeInfo.test.js') -- GitLab