From 30b34c04c8489774d99898b4eeab86165e5c4bdb Mon Sep 17 00:00:00 2001 From: wangtao Date: Thu, 20 Oct 2022 21:31:31 +0800 Subject: [PATCH] xts for audio Signed-off-by: wangtao Change-Id: I7f7c9c36a5b86b5f5aae713cd81bfa5990042e76 --- .../src/main/js/test/AudioCapturer.test.js | 147 +- .../js/test/AudioCapturerChangeInfo.test.js | 17 +- .../js/test/AudioRendererChangeInfo.test.js | 18 +- .../audioManager/src/main/config.json | 4 + .../src/main/js/test/AudioFramework.test.js | 238 +-- .../src/main/js/test/AudioManagerApi9.test.js | 1049 ++++++++++++ .../src/main/js/test/List.test.js | 1 + .../src/main/js/test/AudioRenderer.test.js | 1458 ++++++++++++++--- 8 files changed, 2405 insertions(+), 527 deletions(-) create mode 100755 multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioManagerApi9.test.js diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js index a342fb572..cf4f6d3f2 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js @@ -357,14 +357,19 @@ describe('audioCapturer', function () { steps.shift(); let markReachParam = steps[0]; steps.shift(); - audioCap.on('markReach', markReachParam, (position) => { - console.log(`${Tag} position: ${JSON.stringify(position)}`); - console.log(`${Tag} markReachParam: ${JSON.stringify(markReachParam)}`); - if (position == markReachParam) { - markReachState = 'success' - console.info(`${Tag} AudioRenderLog: mark reached: ${JSON.stringify(position)}`); - } - }); + try{ + audioCap.on('markReach', markReachParam, (position) => { + console.log(`${Tag} position: ${JSON.stringify(position)}`); + console.log(`${Tag} markReachParam: ${JSON.stringify(markReachParam)}`); + if (position == markReachParam) { + markReachState = 'success' + console.info(`${Tag} AudioRenderLog: mark reached: ${JSON.stringify(position)}`); + } + }); + }catch(err){ + markReachState = 'error' + console.error(`${Tag} AudioRenderLog: mark reached: error: code:${err.code},message:${err.message}`); + } toNextStep(audioCap, steps, done); }); @@ -380,14 +385,19 @@ describe('audioCapturer', function () { steps.shift(); let periodReachParam = steps[0]; steps.shift(); - audioCap.on('periodReach', periodReachParam, (position) => { - console.log(`${Tag} position: ${JSON.stringify(position)}`); - console.log(`${Tag} periodReachParam: ${JSON.stringify(periodReachParam)}`); - if (position == periodReachParam) { - periodReachState = 'success' - console.info(`${Tag} AudioRenderLog: mark reached: ${JSON.stringify(position)}`); - } - }); + try{ + audioCap.on('periodReach', periodReachParam, (position) => { + console.log(`${Tag} position: ${JSON.stringify(position)}`); + console.log(`${Tag} periodReachParam: ${JSON.stringify(periodReachParam)}`); + if (position == periodReachParam) { + periodReachState = 'success' + console.info(`${Tag} AudioRenderLog: mark reached: ${JSON.stringify(position)}`); + } + }); + }catch(err){ + periodReachState = 'error' + console.error(`${Tag} AudioRenderLog: mark reached: error: code:${err.code},message:${err.message}`); + } toNextStep(audioCap, steps, done); }); eventEmitter.on(OFF_PERIODR_REACH_EVENT, (audioCap, steps, done) => { @@ -440,9 +450,6 @@ describe('audioCapturer', function () { console.info(`${Tag} AudioFrameworkTest: afterAll: Test suite-level cleanup condition`); }) - - - async function recPromise(AudioCapturerOptions, done) { let audioCap; try { @@ -2100,9 +2107,17 @@ describe('audioCapturer', function () { return done(); } + try { + await audioCapPromise.start(); + console.log(`${Tag} start ok`); + } catch (err) { + console.log(`${Tag} start err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } try { await audioCapPromise.stop(); console.log(`${Tag} stop ok`); + expect(true).assertTrue(); } catch (err) { console.log(`${Tag} stop err: ${JSON.stringify(err)}`); expect(false).assertTrue(); @@ -2439,13 +2454,8 @@ describe('audioCapturer', function () { capturerInfo: audioCapturerInfo44100, } await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(function (data) { - if (data == undefined) { - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Unsuccess : ${JSON.stringify(data)}`); - expect(true).assertTrue(); - } else { - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success: ${JSON.stringify(data)}`); - expect(false).assertTrue(); - } + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success: ${JSON.stringify(data)}`); + expect(false).assertTrue(); }).catch((err) => { console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`); expect(true).assertTrue(); @@ -2992,4 +3002,89 @@ describe('audioCapturer', function () { let mySteps = [CREATE_EVENT, AudioCapturerOptions, PERIODR_REACH_EVENT, periodReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_PERIODR_REACH_EVENT, RELEASE_EVENT, END_EVENT]; eventEmitter.emit(mySteps[0], audioCap, mySteps, done); }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0100 + *@tc.name : AudioCapturer - getAudioStreamId + *@tc.desc : AudioCapturer - getAudioStreamId + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0100', 0, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCapPromise.getAudioStreamId((err, data) => { + if (err) { + console.info(`${Tag}: getAudioStreamId : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + } else { + expect(true).assertTrue(); + console.info(`${Tag}: getAudioStreamId : Converted: ${data}`); + } + }); + await audioCapPromise.release(); + } catch (err) { + console.log(`${Tag} err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0200 + *@tc.name : AudioCapturer - getAudioStreamId + *@tc.desc : AudioCapturer - getAudioStreamId + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0200', 0, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + try { + let audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCapPromise.getAudioStreamId().then((data)=>{ + expect(true).assertTrue(); + console.info(`${Tag}: getAudioStreamId : Converted: ${data}`); + }).catch((err) => { + expect(true).assertTrue(); + console.error(`${Tag}: getAudioStreamId : ERROR : ${err}`); + }); + + await audioCapPromise.release(); + } catch (err) { + console.log(`${Tag} error code: ${err.code} ,message:${err.message}`); + expect(false).assertTrue(); + } + done(); + }) }) diff --git a/multimedia/audio/audio_js_standard/AudioCapturerChangeInfo/src/main/js/test/AudioCapturerChangeInfo.test.js b/multimedia/audio/audio_js_standard/AudioCapturerChangeInfo/src/main/js/test/AudioCapturerChangeInfo.test.js index d92214059..b7ff9799d 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturerChangeInfo/src/main/js/test/AudioCapturerChangeInfo.test.js +++ b/multimedia/audio/audio_js_standard/AudioCapturerChangeInfo/src/main/js/test/AudioCapturerChangeInfo.test.js @@ -34,22 +34,9 @@ describe('audioCapturerChange', function () { await sleep(100); console.info(`AudioFrameworkTest: beforeAll: END`); await sleep(100); - await audioManager.getStreamManager().then((data) => { - audioStreamManager = data; - console.info(`${Tag}: Get AudioStream Manager : Success `); - }).catch((err) => { - console.info(`${Tag}: Get AudioStream Manager : ERROR :${err.message}`); - }); - audioManager.getStreamManager((err, data) => { - if (err) { - console.error(`${Tag}: Get AudioStream Manager : ERROR :${err.message}`); - } - else { - audioStreamManagerCB = data; - console.info(`${Tag}: Get AudioStream Manager : Success `); - } - }); + audioStreamManager = audioManager.getStreamManager(); + audioStreamManagerCB = audioManager.getStreamManager(); await sleep(1000); console.info(`${Tag}: beforeAll: END`); }) diff --git a/multimedia/audio/audio_js_standard/AudioRendererChangeInfo/src/main/js/test/AudioRendererChangeInfo.test.js b/multimedia/audio/audio_js_standard/AudioRendererChangeInfo/src/main/js/test/AudioRendererChangeInfo.test.js index d22fb8841..b71929d9e 100644 --- a/multimedia/audio/audio_js_standard/AudioRendererChangeInfo/src/main/js/test/AudioRendererChangeInfo.test.js +++ b/multimedia/audio/audio_js_standard/AudioRendererChangeInfo/src/main/js/test/AudioRendererChangeInfo.test.js @@ -25,24 +25,10 @@ describe('audioRendererChange', function () { console.info(`${Tag} : Create AudioManger Object JS Framework`); beforeAll(async function () { - await AUDIOMANAGER.getStreamManager().then(function (data) { - audioStreamManager = data; - console.info(`${Tag} : Get AudioStream Manager : Success `); - }).catch((err) => { - console.info(`${Tag} : Get AudioStream Manager : ERROR : ${err.message}`); - }); - AUDIOMANAGER.getStreamManager((err, data) => { - if (err) { - console.error(`${Tag} : Get AudioStream Manager : ERROR : ${err.message}`); - } - else { - audioStreamManagerCB = data; - console.info(`${Tag} : Get AudioStream Manager : Success `); - } - }); + audioStreamManager = AUDIOMANAGER.getStreamManager(); + audioStreamManagerCB = AUDIOMANAGER.getStreamManager(); await sleep(1000); - console.info(`${Tag} : beforeAll: Prerequisites at the test suite level`); }) diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/config.json b/multimedia/audio/audio_js_standard/audioManager/src/main/config.json index afdbfee30..bf7ae6662 100755 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/config.json +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/config.json @@ -89,6 +89,10 @@ { "name": "ohos.permission.MODIFY_AUDIO_SETTINGS", "reason": "use ohos.permission.MODIFY_AUDIO_SETTINGS" + }, + { + "name": "ohos.permission.MANAGE_AUDIO_CONFIG", + "reason": "use ohos.permission.MANAGE_AUDIO_CONFIG" } ] } 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 7851a22d3..b54857e16 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 @@ -46,6 +46,7 @@ describe('audioFramework', function () { console.info(`${TagFrmwk}: getAudioManger : FAIL`); } } + function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } @@ -4902,7 +4903,7 @@ describe('audioFramework', function () { *@tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0100', 2,async function (done) { - let AudioRoutingManager = await audioManager.getRoutingManager(); + let AudioRoutingManager = audioManager.getRoutingManager(); AudioRoutingManager.getDevices(1, (err, value) => { // Getting all Output devices Enumb 1 = OUTPUT_DEVICES_FLAG console.info(`${TagFrmwk}: Callback: getDevices OUTPUT_DEVICES_FLAG`); @@ -4936,7 +4937,7 @@ describe('audioFramework', function () { *@tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0200', 2,async function (done) { - let AudioRoutingManager = await audioManager.getRoutingManager(); + let AudioRoutingManager = audioManager.getRoutingManager(); AudioRoutingManager.getDevices(2, (err, value) => { // Getting all Input Devices ENUM 2 = INPUT_DEVICES_FLAG console.info(`${TagFrmwk}: Callback: getDevices INPUT_DEVICES_FLAG`); @@ -4969,7 +4970,7 @@ describe('audioFramework', function () { *@tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0300', 2, async function (done) { - let AudioRoutingManager = await audioManager.getRoutingManager(); + let AudioRoutingManager = audioManager.getRoutingManager(); AudioRoutingManager.getDevices(3, (err, value) => { // Getting all devies connected 3 = ALL_DEVICES_FLAG console.info(`${TagFrmwk}: Callback: getDevices ALL_DEVICES_FLAG`); @@ -5002,7 +5003,7 @@ describe('audioFramework', function () { *@tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0400', 2, async function (done) { - let AudioRoutingManager = await audioManager.getRoutingManager(); + let AudioRoutingManager = audioManager.getRoutingManager(); AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => { console.info(`${TagFrmwk}: Callback: getDevices OUTPUT_DEVICES_FLAG`); if (err) { @@ -5034,7 +5035,7 @@ describe('audioFramework', function () { *@tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0500', 2, async function (done) { - let AudioRoutingManager = await audioManager.getRoutingManager(); + let AudioRoutingManager = audioManager.getRoutingManager(); AudioRoutingManager.getDevices(audio.DeviceFlag.INPUT_DEVICES_FLAG, (err, value) => { console.info(`${TagFrmwk}: Callback: getDevices INPUT_DEVICES_FLAG`); if (err) { @@ -5065,7 +5066,7 @@ describe('audioFramework', function () { *@tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0600', 2, async function (done) { - let AudioRoutingManager = await audioManager.getRoutingManager(); + let AudioRoutingManager = audioManager.getRoutingManager(); AudioRoutingManager.getDevices(audio.DeviceFlag.ALL_DEVICES_FLAG, (err, value) => { console.info(`${TagFrmwk}: Callback: getDevices ALL_DEVICES_FLAG`); if (err) { @@ -5096,7 +5097,7 @@ describe('audioFramework', function () { *@tc.level : Level 2 */ it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0700', 2, async function (done) { - let AudioRoutingManager = await audioManager.getRoutingManager(); + let AudioRoutingManager = audioManager.getRoutingManager(); let value = await AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG); console.info(`${TagFrmwk}: Promise: getDevices OUTPUT_DEVICES_FLAG`); value.forEach(displayDeviceProp); @@ -5111,229 +5112,6 @@ describe('audioFramework', function () { done(); }) - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0800 - *@tc.name : getDevices - INPUT device - Promise - ENAME - *@tc.desc : getDevices - INPUT device - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0800', 2, function (done) { - audioManager.getRoutingManager(async (err, AudioRoutingManager) => { - if (err) { - console.error(`${TagFrmwk}: Callback: failed to get RoutingManager ${err.message}`); - expect().assertFail(); - } else { - let value = await AudioRoutingManager.getDevices(audio.DeviceFlag.INPUT_DEVICES_FLAG) - console.info(`${TagFrmwk}: Promise: getDevices INPUT_DEVICES_FLAG`); - value.forEach(displayDeviceProp); - - if (dTValue != null && dRValue != null && devId > 0 && sRate != null && cCount != null && - cMask != null) { - console.info(`${TagFrmwk}: Promise: getDevices : INPUT_DEVICES_FLAG : PASS`); - expect(true).assertTrue(); - } else { - console.info(`${TagFrmwk}: Promise: getDevices : INPUT_DEVICES_FLAG : FAIL`); - expect(false).assertTrue(); - } - } - done(); - }); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0900 - *@tc.name : getDevices - ALL device - Promise - ENAME - *@tc.desc : getDevices - ALL device - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_GETDEVICES_0900', 2, function (done) { - audioManager.getRoutingManager(async (err, AudioRoutingManager) => { - if (err) { - console.error(`${TagFrmwk}:Callback:failed to get RoutingManager ${err.message}`); - expect().assertFail(); - } else { - let value = await AudioRoutingManager.getDevices(audio.DeviceFlag.ALL_DEVICES_FLAG) - console.info(`${TagFrmwk}: Promise: getDevices ALL_DEVICES_FLAG`); - value.forEach(displayDeviceProp); - - if (dTValue != null && dRValue != null && devId > 0 && sRate != null && cCount != null && - cMask != null) { - console.info(`${TagFrmwk}: Promise: getDevices : ALL_DEVICES_FLAG : PASS`); - expect(true).assertTrue(); - } - else { - console.info(`${TagFrmwk}: Promise: getDevices : ALL_DEVICES_FLAG : FAIL`); - expect(false).assertTrue(); - } - } - done(); - }); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100 - *@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100 - *@tc.desc : micStateChange - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0100', 2, async function (done) { - try{ - var routingManager = await audioManager.getRoutingManager(); - }catch (err) { - console.error(`${TagFrmwk}:Callback:failed to get RoutingManager ${err.message}`); - expect(false).assertTrue(); - } - let count = 0; - console.info('getRoutingManager Callback START.'); - routingManager.on('micStateChange',async (micStateChange)=>{ - count++; - }) - - try{ - let data = await audioManager.isMicrophoneMute(); - console.info('Promise isMicrophoneMute PASS:' + data); - await audioManager.setMicrophoneMute(data); - console.info('Promise setMicrophoneMute PASS.'); - let data1 = await audioManager.isMicrophoneMute(); - console.info('Promise isMicrophoneMute PASS.' + data1); - }catch (err) { - console.log('ERROR:'+JSON.stringify(err)) - expect(false).assertTrue(); - done(); - } - await sleep(2000); - expect(count).assertEqual(0); - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0200 - *@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0200 - *@tc.desc : micStateChange - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0200', 2, async function (done) { - try{ - var routingManager = await audioManager.getRoutingManager(); - }catch (err) { - console.error(`${TagFrmwk}:Callback:failed to get RoutingManager ${err.message}`); - expect(false).assertTrue(); - } - console.info('getRoutingManager Callback START.'); - let count = 0; - routingManager.on('micStateChange',async (micStateChange)=>{ - console.info("Updated micState:" + JSON.stringify(micStateChange)); - count++; - }) - - try{ - let data = await audioManager.isMicrophoneMute(); - console.info('Promise isMicrophoneMute PASS:' + data); - let micStatus = !data; - await audioManager.setMicrophoneMute(micStatus); - console.info('Promise setMicrophoneMute PASS:' + micStatus); - }catch (err) { - console.log('ERROR:'+JSON.stringify(err)) - expect(false).assertTrue(); - done(); - } - await sleep(2000); - expect(count).assertEqual(1); - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0300 - *@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0300 - *@tc.desc : micStateChange - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0300', 2, async function (done) { - try{ - var routingManager = await audioManager.getRoutingManager(); - }catch (err) { - console.error(`${TagFrmwk}:Callback:failed to get RoutingManager ${err.message}`); - expect(false).assertTrue(); - } - console.info('getRoutingManager Callback START.'); - let count = 0; - routingManager.on('micStateChange',async (micStateChange)=>{ - console.info("Updated micState:" + JSON.stringify(micStateChange)); - count++; - }) - - try{ - let data = await audioManager.isMicrophoneMute(); - console.info('Promise isMicrophoneMute PASS:' + data); - let micStatus = !data; - await audioManager.setMicrophoneMute(micStatus); - console.info('Promise setMicrophoneMute PASS:' + micStatus); - await audioManager.setMicrophoneMute(!micStatus); - console.info('Promise setMicrophoneMute PASS:' + (!micStatus)); - }catch (err) { - console.log('ERROR:'+JSON.stringify(err)) - expect(false).assertTrue(); - done(); - } - await sleep(2000); - expect(count).assertEqual(2); - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0400 - *@tc.name : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0400 - *@tc.desc : micStateChange - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_MICSTATECHANGE_0400', 2, async function (done) { - try{ - var routingManager = await audioManager.getRoutingManager(); - }catch (err) { - console.error(`${TagFrmwk}:Callback:failed to get RoutingManager ${err.message}`); - expect(false).assertTrue(); - } - let count = 0; - try { - console.info("enter SUB_AUDIO_MANAGER_micStateChange_004"); - routingManager.on('micStateChange',async (micStateChange1)=>{ - console.info("Updated micState--001:" + JSON.stringify(micStateChange1)); - routingManager.on('micStateChange',async (micStateChange)=>{ - console.info("Updated micState--002:" + JSON.stringify(micStateChange)); - count++ - }) - let data = await audioManager.isMicrophoneMute(); - console.info('Second Promise isMicrophoneMute PASS:' + data); - await audioManager.setMicrophoneMute(!data); - console.info('Second:Promise setMicrophoneMute PASS:' + (!data)); - }) - let data = await audioManager.isMicrophoneMute(); - console.info('First Promise isMicrophoneMute PASS:' + data); - await audioManager.setMicrophoneMute(!data); - console.info('First:Promise setMicrophoneMute PASS:' + (!data)); - } catch (err) { - console.log('ERROR:'+JSON.stringify(err)) - expect(false).assertTrue(); - done(); - } - - await sleep(2000); - expect(count).assertEqual(1); - done(); - }) - /** *@tc.number : SUB_MULTIMEDIA_AUDIO_DEVICEFALG_0100 *@tc.name : NONE_DEVICES_FLAG diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioManagerApi9.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioManagerApi9.test.js new file mode 100755 index 000000000..332ac3f87 --- /dev/null +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/AudioManagerApi9.test.js @@ -0,0 +1,1049 @@ +/* + * 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 * as audioTestBase from '../../../../../AudioTestBase' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +describe('audioManagerApi9', function () { + let TagFrmwk = "audioManagerApi9Test"; + console.info(`${TagFrmwk}: Create AudioManger Object JS Framework`); + let audioManager = null; + let streamManager = null; + let audioMedia = 3; + let audioRingtone = 2; + let minVol = 0; + let maxVol = 15; + let lowVol = 5; + let highVol = 14; + let outOfRangeVol = 28; + let longValue = '28374837458743875804735081439085918459801437584738967509184509813904850914375904790589104801843'; + let volNetworkId = null; + let volGroupId = null; + let volMappingId = null; + let volGroupName = null; + let volConnectType = null; + function displayVolumeGroupProp(value, index, array) { + console.info('audioManagerApi9Test: volume group networkId:' + value.networkId); + volNetworkId = value.networkId; + console.info('audioManagerApi9Test: volume group id:' + value.groupId); + volGroupId = value.groupId; + console.info('audioManagerApi9Test: volume group mappingId:' + value.mappingId); + volMappingId = value.mappingId; + console.info('audioManagerApi9Test: volume group name:' + value.groupName); + volGroupName = value.groupName; + console.info('audioManagerApi9Test: volume group connect type:' + value.ConnectType); + volConnectType = value.ConnectType; + } + function getAudioManager() { + audioManager = audio.getAudioManager(); + if (audioManager != null) { + console.info(`${TagFrmwk}: getAudioManger : PASS`); + } + else { + console.info(`${TagFrmwk}: getAudioManger : FAIL`); + } + } + function getStreamManager() { + streamManager = audioManager.getStreamManager(); + if (streamManager != null) { + console.info(`${TagFrmwk}: getStreamManager : PASS`); + } + else { + console.info(`${TagFrmwk}: getStreamManager : FAIL`); + } + } + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + beforeAll(async function () { + console.info(`${TagFrmwk}: beforeAll: Prerequisites at the test suite level`); + let permissionName1 = 'ohos.permission.MICROPHONE'; + let permissionName2 = 'ohos.permission.ACCESS_NOTIFICATION_POLICY'; + let permissionName3 = 'ohos.permission.MODIFY_AUDIO_SETTINGS'; + let permissionNameList = [permissionName1, permissionName2, permissionName3]; + let appName = 'ohos.acts.multimedia.audio.audiomanager'; + await audioTestBase.applyPermission(appName, permissionNameList); + await sleep(100); + await getAudioManager(); + getStreamManager(); + console.info(`${TagFrmwk}: beforeAll: END`); + }) + + beforeEach(async function () { + console.info(`${TagFrmwk}: beforeEach: Prerequisites at the test case level`); + await sleep(100); + }) + + afterEach(async function () { + console.info(`${TagFrmwk}: afterEach: Test case-level clearance conditions`); + await sleep(100); + }) + + afterAll(function () { + console.info(`${TagFrmwk}: afterAll: Test suite-level cleanup condition`); + }) + + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ERRORS_0100' + *@tc.name : AUDIO_ERRORS + *@tc.desc : AUDIO_ERRORS + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ERRORS_0100', 2, async function (done) { + expect(audio.AudioErrors.ERROR_INVALID_PARAM).assertEqual(6800101); + expect(audio.AudioErrors.ERROR_NO_MEMORY).assertEqual(6800102); + expect(audio.AudioErrors.ERROR_ILLEGAL_STATE).assertEqual(6800103); + expect(audio.AudioErrors.ERROR_UNSUPPORTED).assertEqual(6800104); + expect(audio.AudioErrors.ERROR_TIMEOUT).assertEqual(6800105); + expect(audio.AudioErrors.ERROR_STREAM_LIMIT).assertEqual(6800201); + expect(audio.AudioErrors.ERROR_SYSTEM).assertEqual(6800301); + await sleep(50); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_DEFAULT_VOLUME_GROUP_ID_0100' + *@tc.name : DEFAULT_VOLUME_GROUP_ID + *@tc.desc : DEFAULT_VOLUME_GROUP_ID + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_DEFAULT_VOLUME_GROUP_ID_0100', 2, async function (done) { + expect(audio.DEFAULT_VOLUME_GROUP_ID).assertEqual(1); + await sleep(50); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_DEFAULT_INTERRUPT_GROUP_ID_0100' + *@tc.name : DEFAULT_INTERRUPT_GROUP_ID + *@tc.desc : DEFAULT_INTERRUPT_GROUP_ID + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_DEFAULT_INTERRUPT_GROUP_ID_0100', 2, async function (done) { + expect(audio.DEFAULT_INTERRUPT_GROUP_ID).assertEqual(1); + await sleep(50); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_COMUNICATIONDEVICETYPE_0100' + *@tc.name : COMUNICATIONDEVICETYPE + *@tc.desc : COMUNICATIONDEVICETYPE + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_COMUNICATIONDEVICETYPE_0100', 2, async function (done) { + expect(audio.CommunicationDeviceType.SPEAKER).assertEqual(2); + await sleep(50); + done(); + }) + + + /** + *@tc.number : SUB_MULTIMEDIA_DEFAULT_INTERRUPT_GROUP_ID_0100' + *@tc.name : INTERRUPTREQUESTTYPE + *@tc.desc : INTERRUPTREQUESTTYPE + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_INTERRUPTREQUESTTYPE_0100', 2, async function (done) { + expect(audio.InterruptRequestType.INTERRUPT_REQUEST_TYPE_DEFAULT).assertEqual(0); + await sleep(50); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_DEFAULT_INTERRUPT_GROUP_ID_0100' + *@tc.name : INTERRUPTREQUESTRESULTTYPE + *@tc.desc : INTERRUPTREQUESTRESULTTYPE + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_INTERRUPTREQUESTRESULTTYPE_0100', 2, async function (done) { + expect(audio.InterruptRequestResultType.INTERRUPT_REQUEST_GRANT).assertEqual(0); + expect(audio.InterruptRequestResultType.INTERRUPT_REQUEST_REJECT).assertEqual(1); + await sleep(50); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_MANAGER_GETVOLUMEGROUPSINFOS_0100 + *@tc.name : getVolumeGroupInfos - LOCAL_NETWORK_ID - Promise + *@tc.desc : getVolumeGroupInfos - LOCAL_NETWORK_ID + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_MANAGER_GETVOLUMEGROUPSINFOS_0100', 2,async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + let value = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + // Getting Local VolumeGroupInfos + console.info(`${TagFrmwk}: Callback: getVolumeGroupInfos LOCAL_NETWORK_ID`); + value.forEach(displayVolumeGroupProp); + if (volNetworkId != null && volGroupId != null && volMappingId != null && volGroupName != null && + volConnectType != null) { + console.info('audioManagerApi9Test: Callback: getVolumeGroups : PASS'); + expect(true).assertTrue(); + } + else{ + console.info('audioManagerApi9Test: Callback: getVolumeGroups : FAIL'); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_MANAGER_GETVOLUMEGROUPSINFOS_0200 + *@tc.name : getVolumeGroupInfos - LOCAL_NETWORK_ID - Callback + *@tc.desc : getVolumeGroupInfos - LOCAL_NETWORK_ID + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_MANAGER_GETVOLUMEGROUPSINFOS_0200', 2,async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID, (err, value) => { + // Getting Local VolumeGroupInfos + console.info(`${TagFrmwk}: Callback: getVolumeGroupInfos LOCAL_NETWORK_ID`); + if (err) { + console.error(`${TagFrmwk}:Callback: OUTPUT_DEVICES_FLAG: failed to get devices ${err.message}`); + expect().assertFail(); + } + else { + console.info(`${TagFrmwk}: Callback: getDevices OUTPUT_DEVICES_FLAG`); + value.forEach(displayVolumeGroupProp); + if (volNetworkId != null && volGroupId != null && volMappingId != null && volGroupName != null && + volConnectType != null) { + console.info('audioManagerApi9Test: Callback: getVolumeGroups : PASS'); + expect(true).assertTrue(); + } + else{ + console.info('audioManagerApi9Test: Callback: getVolumeGroups : FAIL'); + expect(false).assertTrue(); + } + } + done(); + }); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0100 + * @tc.name : getVolumeGroupManager - callback + * @tc.desc : getVolumeGroupManager + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0100', 3, async function (done) { + let audioVolumeManager; + let groupId_; + try{ + audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + groupId_ = volumeGroupInfos[0].groupId + }catch(err){ + console.info('audioManagerApi9Test: getGroupManager: parameter err:'+ err.message); + expect(false).assertTrue(); + done(); + } + audioVolumeManager.getVolumeGroupManager(groupId_, (err,groupManager)=>{ + if (err) { + console.error(`audioManagerApi9Test: failed to getGroupManager: Callback: ${err.message}`); + expect(false).assertTrue(); + } else { + if((typeof groupManager) == 'object'){ + console.info('audioManagerApi9Test: Promise: getGroupManager : PASS'); + expect(true).assertTrue(); + } + else{ + console.info('audioManagerApi9Test: Promise: getGroupManager : FAIL'); + expect(false).assertTrue(); + } + } + done(); + }) + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0200 + * @tc.name : getVolumeGroupManager - prmiose + * @tc.desc : getVolumeGroupManager + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_0200', 3, async function (done) { + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + if((typeof groupManager) == 'object'){ + console.info('audioManagerApi9Test: Promise: getGroupManager : PASS'); + expect(true).assertTrue(); + } + else{ + console.info('audioManagerApi9Test: Promise: getGroupManager : FAIL'); + expect(false).assertTrue(); + } + }catch(err){ + console.info('audioManagerApi9Test: getGroupManager: parameter err:'+ err.message); + expect(false).assertTrue(); + done(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETVOLUME_0100 + * @tc.name : group manager setVolume - MEDIA - Callback + * @tc.desc : group manager Setvolo to 14 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETVOLUME_0100', 3, async function (done) { + let groupManager; + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + }catch(err){ + console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message); + expect(false).assertTrue(); + done(); + } + groupManager.setVolume(audio.AudioVolumeType.MEDIA, highVol, (err, data) => { + if (err) { + console.error(`audioManagerApi9Test: failed to set volume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + else { + console.info(`audioManagerApi9Test: callback : Meida setVolume successful `); + groupManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { + if (err) { + console.error(`audioManagerApi9Test: callback : Meida: failed to get volume ${err.message}`); + expect(false).assertTrue(); + } + else if (value == highVol) { + console.info('audioManagerApi9Test: callback : Meida getVolume: PASS :' + value); + expect(true).assertTrue(); + } + else { + console.info('audioManagerApi9Test: callback : Meida getVolume: FAIL :' + value); + expect(false).assertTrue(); + } + done(); + }); + } + }); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETVOLUME_0200 + * @tc.name : group manager setVolume - MEDIA - Promise + * @tc.desc : group manager Setvolume to 14 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETVOLUME_0200', 3, async function (done) { + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + await groupManager.setVolume(audio.AudioVolumeType.MEDIA, highVol); + let value = await groupManager.getVolume(audio.AudioVolumeType.MEDIA); + if (value == highVol) { + console.info('audioManagerApi9Test: callback : Meida getVolume: PASS :' + value); + expect(true).assertTrue(); + } + else { + console.info('audioManagerApi9Test: callback : Meida getVolume: FAIL :' + value); + expect(false).assertTrue(); + } + done(); + }catch(err){ + console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0100 + * @tc.name : getMaxVolume - RINGTONE - Callback + * @tc.desc : getMaxVolume + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0100', 3, async function (done) { + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + groupManager.getMaxVolume(audio.AudioVolumeType.RINGTONE, (err, data) => { + if (err) { + console.error(`audioManagerApi9Test: failed to getMaxVolume: Callback: ${err.message}`); + expect(false).assertTrue(); + } + else { + if (data == maxVol) { + console.info('audioManagerApi9Test: callback : Ringtone getMaxVolume: PASS :' + data); + expect(true).assertTrue(); + } + else { + console.info('audioManagerApi9Test: callback : Ringtone getMaxVolume: FAIL :' + data); + expect(false).assertTrue(); + } + } + done(); + }); + }catch(err){ + console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0200 + * @tc.name : getMaxVolume - RINGTONE - Promise + * @tc.desc : getMaxVolume + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0200', 3, async function (done) { + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + let maxVolume = await groupManager.getMaxVolume(audio.AudioVolumeType.RINGTONE); + if (maxVolume == maxVol) { + console.info('audioManagerApi9Test: promise : Ringtone getMaxVolume: PASS :' + maxVolume); + expect(true).assertTrue(); + } + else { + console.info('audioManagerApi9Test: promise : Ringtone getMaxVolume: FAIL :' + maxVolume); + expect(false).assertTrue(); + } + }catch(err){ + console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0100 + * @tc.name : getMinVolume - RINGTONE - Callback + * @tc.desc : getMinVolume + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0100', 2, async function (done) { + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + groupManager.getMinVolume(audio.AudioVolumeType.RINGTONE, (err, data) => { + if (err) { + console.error(`audioManagerApi9Test: failed to getMinVolume : Callback: ${err.message}`); + expect(false).assertTrue(); + } + else { + if (data == minVol) { + console.info('audioManagerApi9Test: callback : Ringtone getMinVolume: PASS :' + data); + expect(true).assertTrue(); + } + else { + console.info('audioManagerApi9Test: callback : Ringtone getMinVolume: FAIL :' + data); + expect(false).assertTrue(); + } + } + done(); + }); + }catch(err){ + console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0200 + * @tc.name : getMaxVolume - RINGTONE - Promise + * @tc.desc : getMaxVolume + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0200', 3, async function (done) { + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + let minVolume = await groupManager.getMinVolume(audio.AudioVolumeType.RINGTONE); + if (minVolume == minVol) { + console.info('audioManagerApi9Test: promise : Ringtone getMinVolume: PASS :' + minVolume); + expect(true).assertTrue(); + } + else { + console.info('audioManagerApi9Test: promise : Ringtone getMinVolume: FAIL :' + minVolume); + expect(false).assertTrue(); + } + }catch(err){ + console.info('audioManagerApi9Test: getVolumeGroupManager : err:'+ err.message); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0100 + * @tc.name : group manager mute - RINGTONE - Callback + * @tc.desc : mute - RINGTONE - Callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0100', 3, async function (done) { + let groupManager; + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + }catch(err){ + console.info('audioManagerApi9Test: getGroupManager mute : parameter err:'+ err.message); + expect(false).assertTrue(); + done(); + } + groupManager.mute(audio.AudioVolumeType.RINGTONE,false, (err, data)=>{ + if (err) { + console.error(`audioManagerApi9Test: failed to mute : Callback: ${err.message}`); + expect(false).assertTrue(); + } + else { + groupManager.isMute(audio.AudioVolumeType.RINGTONE, (err, data)=>{ + if (err) { + console.error(`audioManagerApi9Test: failed to isMute : Callback: ${err.message}`); + expect(false).assertTrue(); + } + else { + if(data==false){ + console.log(`audioManagerApi9Test: Promise: + Is Stream GroupManager Mute RINGTONE: FALSE: PASS:`+data); + expect(true).assertTrue(); + } + else{ + console.log(`audioManagerApi9Test: Promise: + Is Stream GroupManager Mute RINGTONE: FALSE: FAIL: `+data); + expect(false).assertTrue(); + } + } + done(); + }) + } + }) + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0200 + * @tc.name : group manager mute - RINGTONE - Promise + * @tc.desc : mute - RINGTONE - Promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_MUTE_0200', 3, async function (done) { + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + await groupManager.mute(audio.AudioVolumeType.RINGTONE,false).then(async function () { + console.log('audioManagerApi9Test: Set Stream GroupManager Mute: RINGTONE: Promise: FALSE'); + await groupManager.isMute(audio.AudioVolumeType.RINGTONE).then(function (data) { + if(data==false){ + console.log(`audioManagerApi9Test: Promise: + Is Stream GroupManager Mute RINGTONE: FALSE: PASS:`+data); + expect(true).assertTrue(); + } + else{ + console.log(`audioManagerApi9Test: Promise: + Is Stream GroupManager Mute RINGTONE: FALSE: FAIL: `+data); + expect(false).assertTrue(); + } + done(); + }); + }).catch((err) => { + console.info(`audioManagerApi9Test: Promise: + Is Stream GroupManager Mute RINGTONE: FALSE: ERROR:` + err.message); + expect(false).assertTrue(); + done(); + }); + }catch(err){ + console.info('audioManagerApi9Test: getGroupManager mute : parameter err:'+ err.message); + expect(false).assertTrue(); + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_VOLUMECHANGE_0100 + *@tc.name : OnVolumeChange - setVolume - MEDIA + *@tc.desc : OnVolumeChange - setVolume - MEDIA + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ON_VOLUMECHANGE_0100', 3, async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + audioVolumeManager.on('volumeChange', (VolumeEvent) => { + console.log(`${TagFrmwk}: Volume Change Event is called`); + switch (VolumeEvent.volumeType) { + case audio.AudioVolumeType.MEDIA: + console.info(`${TagFrmwk}: Audio VolumeEvent is : ${VolumeEvent}`); + if (VolumeEvent.volume == lowVol) { + console.info(`${TagFrmwk}: MEDIA CallBack : PASS : ${VolumeEvent.volume}`); + expect(true).assertTrue(); + } + break; + default: + console.info(`${TagFrmwk}: Audio VolumeEvent is : ${VolumeEvent}`); + expect(false).assertTrue(); + break; + } + done(); + }); + try { + await groupManager.setVolume(audioMedia, lowVol); + console.info('setVolume success') + } catch (err) { + console.log('err :' + err.message) + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETRINGERMODE_0100 + * @tc.name : group manager mute - RINGTONE - Callback + * @tc.desc : mute - RINGTONE - Callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETRINGERMODE_0100', 3, async function (done) { + let groupManager; + try{ + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + }catch(err){ + console.info('audioManagerApi9Test: getGroupManager mute : parameter err:'+ err.message); + expect(false).assertTrue(); + done(); + } + groupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err, data)=>{ + if (err) { + console.error(`audioManagerApi9Test: failed to setRingerMode : Callback: ${err.message}`); + expect(false).assertTrue(); + } + else { + groupManager.getRingerMode((err, data)=>{ + if (err) { + console.error(`audioManagerApi9Test: failed to getRingerMode : Callback: ${err.message}`); + expect(false).assertTrue(); + } + else { + if(data == audio.AudioRingMode.RINGER_MODE_NORMAL){ + console.log(`audioManagerApi9Test: Promise: + getRingerMode : PASS:`+data); + expect(true).assertTrue(); + } + else{ + console.log(`audioManagerApi9Test: Promise: + getRingerMode : FAIL: `+data); + expect(false).assertTrue(); + } + } + done(); + }) + } + }) + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETRINGERMODE_0200 + *@tc.name : setRingerMode - Normal Mode - Promise - ENAME + *@tc.desc : setRingerMode - Set Ring more to Normal Mode + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETRINGERMODE_0200', 3, async function (done) { + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + await groupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL); + let value = await groupManager.getRingerMode(); + if (value == audio.AudioRingMode.RINGER_MODE_NORMAL) { + console.info(`${TagFrmwk}: Promise: setRingerMode RINGER_MODE_NORMAL: PASS :${value}`); + expect(true).assertTrue(); + } else { + console.info(`${TagFrmwk}: Promise: setRingerMode RINGER_MODE_NORMAL: FAIL :${value}`); + expect(false).assertTrue(); + } + } catch (err) { + console.log('err :' + err.message); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ONRINGMODECHANGE_0100 + *@tc.name : OnRingMode - RINGER_MODE_NORMAL + *@tc.desc : OnRingMode - RINGER_MODE_NORMAL + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ONRINGMODECHANGE_0100', 3, async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + groupManager.on('ringerModeChange', (AudioRingMode) => { + console.log(`${TagFrmwk}: ringerMode Change Event is called`); + switch (AudioRingMode) { + case audio.AudioRingMode.RINGER_MODE_NORMAL: + console.info(`${TagFrmwk}: Audio ringerMode is : ${AudioRingMode}`); + console.info(`${TagFrmwk}: MEDIA CallBack : PASS : ${AudioRingMode}`); + expect(true).assertTrue(); + break; + default: + console.info(`${TagFrmwk}: Audio VolumeEvent is : ${AudioRingMode}`); + expect(false).assertTrue(); + break; + } + done(); + }); + try { + await groupManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL); + console.info('setRingerMode success') + } catch (err) { + console.log('err :' + err.message) + expect(false).assertTrue(); + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GSETMICROPHONEMUTE_0100 + *@tc.name : setMicrophoneMute - true - Callback + *@tc.desc : Enable mic mute + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETMICROPHONEMUTE_0100', 3, async function (done) { + let groupManager; + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + } catch (err) { + console.log('err :' + err.message); + expect(false).assertTrue(); + } + groupManager.setMicrophoneMute(true,(err, data)=>{ + if (err) { + console.error(`audioManagerApi9Test: failed to setMicrophoneMute : Callback: ${err.message}`); + expect(false).assertTrue(); + } + else { + groupManager.isMicrophoneMute((err, data)=>{ + if (err) { + console.error(`audioManagerApi9Test: failed to isMicrophoneMute : Callback: ${err.message}`); + expect(false).assertTrue(); + } + else { + if (data == true) { + console.log(`${TagFrmwk}: Callback: isMicrophoneMute: TRUE: PASS:${data}`); + expect(true).assertTrue(); + } else { + console.log(`${TagFrmwk}: Callback: isMicrophoneMute: TRUE: FAIL: ${data}`); + expect(false).assertTrue(); + } + } + done(); + }) + } + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GSETMICROPHONEMUTE_0200 + *@tc.name : setMicrophoneMute - true - Promise + *@tc.desc : Enable mic mute + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_SETMICROPHONEMUTE_0200', 3, async function (done) { + try { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + await groupManager.setMicrophoneMute(true); + let data = await groupManager.isMicrophoneMute(); + if (data == true) { + console.log(`${TagFrmwk}: Promise: isMicrophoneMute: TRUE: PASS:${data}`); + expect(true).assertTrue(); + } else { + console.log(`${TagFrmwk}: Promise: isMicrophoneMute: TRUE: FAIL: ${data}`); + expect(false).assertTrue(); + } + } catch (err) { + console.log('err :' + err.message); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ONMICSTATECHANGE_0100 + *@tc.name : OnMicStateChange + *@tc.desc : OnMicStateChange + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 3 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ONMICSTATECHANGE_0100', 2, async function (done) { + let audioVolumeManager = audioManager.getVolumeManager(); + let volumeGroupInfos = await audioVolumeManager.getVolumeGroupInfos(audio.LOCAL_NETWORK_ID); + let groupId_ = volumeGroupInfos[0].groupId; + let groupManager = await audioVolumeManager.getVolumeGroupManager(groupId_); + try { + await groupManager.setMicrophoneMute(false); + console.info('setMicrophoneMute success') + } catch (err) { + console.log('err :' + err.message) + expect(false).assertTrue(); + done(); + } + groupManager.on('micStateChange', (MicStateChangeEvent) => { + console.log(`${TagFrmwk}: Mic State Change Event is called`); + + if (MicStateChangeEvent.mute == true) { + console.info(`${TagFrmwk}: MEDIA CallBack : PASS : ${MicStateChangeEvent.mute}`); + expect(true).assertTrue(); + }else{ + console.info(`${TagFrmwk}: Audio MicStateChangeEvent is : ${MicStateChangeEvent}`); + expect(false).assertTrue(); + } + done(); + }); + try { + await groupManager.setMicrophoneMute(true); + console.info('setMicrophoneMute success') + } catch (err) { + console.log('err :' + err.message) + expect(false).assertTrue(); + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ISACTIVE_0100 + *@tc.name : isActive - Media - Promise + *@tc.desc : isActive - Media - Promise - When stream is NOT playing + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ISACTIVE_0100', 1, async function (done) { + console.log(`${TagFrmwk}: Promise : isActive Media: NOTE: audio NOT PLAYING as MEDIA for the test case to PASS`); + const PROMISE = streamManager.isActive(audioMedia); + PROMISE.then(function (data) { + if (data == false) { + console.log(`${TagFrmwk}: Promise: isActive: Media: TRUE: PASS:${data}`); + expect(true).assertTrue(); + } else { + console.log(`${TagFrmwk}: Promise: isActive: Media: TRUE: FAIL: ${data}`); + expect(false).assertTrue(); + } + }).catch(err => { + console.log('err :' + JSON.stringify(err)); + expect().assertFail(); + }); + await PROMISE; + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ISACTIVE_0100 + *@tc.name : isActive - Media - Callback + *@tc.desc : isActive - Media - Callback - When stream is NOT playing + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_STREAM_MANAGER_ISACTIVE_0100', 1, function (done) { + console.log(`${TagFrmwk}: Callback : isActive Media: NOTE: audio NOT PLAYING as MEDIA for the test case to PASS`); + streamManager.isActive(audioMedia, (err, data) => { + if (err) { + console.error(`${TagFrmwk}: Callback : Media : isActive: failed ${err.message}`); + expect().assertFail(); + } else if (data == false) { + console.log(`${TagFrmwk}: Callback: isActive: Media: TRUE: PASS:${data}`); + expect(true).assertTrue(); + } else { + console.log(`${TagFrmwk}: Callback: isActive: Media: TRUE: FAIL: ${data}`); + expect(false).assertTrue(); + } + done(); + }); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_MANAGER_SETCOMMUNICATIONDEVICE_0100 + *@tc.name : setCommunicationDevice - SPEAKER - deactivate - Promise + *@tc.desc : setCommunicationDevice speaker - Promise + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100', 1, async function (done) { + try { + let flag = true; + let AudioRoutingManager = audioManager.getRoutingManager(); + let outputDeviceDescription = await AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG); + console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100 + outputDeviceDescription is ${JSON.stringify(outputDeviceDescription)}`); + if (outputDeviceDescription.length == 1 && + outputDeviceDescription[0].deviceType== audio.DeviceType.SPEAKER) { + flag = false; + } + await AudioRoutingManager.setCommunicationDevice(2, false).then(() => { + console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100 + Promise returned to indicate that the device is set to the active status.`); + }); + await AudioRoutingManager.isCommunicationDeviceActive(audio.ActiveDeviceType.SPEAKER).then(function (value) { + if (flag == true && value == false) { + console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100 + isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`); + expect(true).assertTrue(); + } + else if (flag == false && value == true) { + console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100 + isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`); + expect(true).assertTrue(); + } + else { + console.info(`SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0100 + isCommunicationDeviceActive : SPEAKER: Deactivate : fail :${value } flag is ${flag}`); + expect(false).assertTrue(); + } + }).catch((err) => { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + }); + } catch (err) { + console.log('err :' + JSON.stringify(err)); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0200 + *@tc.name : setCommunicationDevice - SPEAKER - deactivate - Callback + *@tc.desc : setCommunicationDevice speaker - Callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_ROUTING_MANAGER_SETCOMMUNICATIONDEVICE_0200', 2,async function (done) { + let flag = true + let AudioRoutingManager = audioManager.getRoutingManager(); + let outputDeviceDescription = await AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG); + console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETCOMMUNICATIONDEVICE_0200 + outputDeviceDescription is ${JSON.stringify(outputDeviceDescription)}`); + if (outputDeviceDescription.length == 1 && outputDeviceDescription[0].deviceType == audio.DeviceType.SPEAKER) { + flag = false; + } + AudioRoutingManager.setCommunicationDevice(audio.ActiveDeviceType.SPEAKER, false, (err) => { + if (err) { + console.error(`${TagFrmwk}: Device Test: Callback : setCommunicationDevice : SPEAKER: Deactivate: Error: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwk}: Device Test: Callback : setCommunicationDevice : SPEAKER: Active`); + AudioRoutingManager.isCommunicationDeviceActive(2, (err, value) => { + if (err) { + console.error(`${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate: Error: ${err.message}`); + expect(false).assertTrue(); + } else if (value == false && flag == true) { + console.info(`${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`); + expect(true).assertTrue(); + } else if (value == true && flag == false) { + console.info(`${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate : PASS :${value } flag is ${flag}`); + expect(true).assertTrue(); + } + else { + console.info(`SUB_MULTIMEDIA_AUDIO_MANAGER_SETCOMMUNICATIONDEVICE_0200 ${TagFrmwk}: Device Test: Callback : isCommunicationDeviceActive : SPEAKER: Deactivate : FAIL :${value } flag is ${flag}`); + expect(false).assertTrue(); + } + done(); + }); + } + }); + }) + +}) \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js index c9fb777cb..254528842 100644 --- a/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js +++ b/multimedia/audio/audio_js_standard/audioManager/src/main/js/test/List.test.js @@ -14,4 +14,5 @@ */ require('./AudioFramework.test.js') +require('./AudioManagerApi9.test.js') diff --git a/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioRenderer.test.js b/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioRenderer.test.js index 820da90b2..7c05ff590 100644 --- a/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioRenderer.test.js +++ b/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioRenderer.test.js @@ -1477,6 +1477,1187 @@ describe('audioRenderer', function () { } + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0100 + * @tc.name : STREAM_VOICE_CALL AUDIO_INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.desc : STREAM_VOICE_CALL AUDIO_INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0100', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'audioInterrupt' SUCCESS "); + interrput_flag = true; + } + expect(interrput_flag).assertTrue(); + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_VOICE_CALL + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0100 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0200 + * @tc.name : STREAM_RING INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.desc : STREAM_RING INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0200', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'audioInterrupt' SUCCESS "); + interrput_flag = true; + } + expect(interrput_flag).assertTrue(); + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_RING + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0200 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0300 + * @tc.name : STREAM_MUSIC INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.desc : STREAM_MUSIC INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0300', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'audioInterrupt' SUCCESS "); + interrput_flag = true; + } + expect(interrput_flag).assertTrue(); + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_MUSIC + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0300 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0400 + * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0400', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'audioInterrupt' SUCCESS "); + interrput_flag = true; + } + expect(interrput_flag).assertTrue(); + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0400 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0500 + * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_CALL + * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_VOICE_CALL + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0500', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_VOICE_CALL + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'audioInterrupt' SUCCESS "); + interrput_flag = true; + } + expect(interrput_flag).assertTrue(); + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0500 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0600 + * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_RING + * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_RING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0600', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_RING + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'audioInterrupt' SUCCESS "); + interrput_flag = true; + } + expect(interrput_flag).assertTrue(); + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0600 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0700 + * @tc.name : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_MUSIC + * @tc.desc : STREAM_VOICE_ASSISTANT INTERRUPT STREAM_MUSIC + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_AUDIO_INTERUPT_AUDIO_0700', 2, async function (done) { + let interrput_flag = false; + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + // STREAM_MUSIC + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + audioRen.on('audioInterrupt',async (interruptEvent)=>{ + console.info("AudioFrameworkRenderLog: InterruptType : " + interruptEvent.eventType); + console.info("AudioFrameworkRenderLog: InterruptForceType : " + interruptEvent.forceType); + console.info("AudioFrameworkRenderLog: InterruptHint : " + interruptEvent.hintType); + if (interruptEvent.hintType >= 0) { + console.info("AudioFrameworkRenderLog: on'audioInterrupt' SUCCESS "); + interrput_flag = true; + } + expect(interrput_flag).assertTrue(); + }); + + let a = await audioRen.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message); + }); + await sleep(1000); + // STREAM_VOICE_ASSISTANT + let AudioRendererInfo_interrupt = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions_interrupt = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo_interrupt + } + + let audioRen_interrupt; + await audio.createAudioRenderer(AudioRendererOptions_interrupt).then(async function (data) { + audioRen_interrupt = data; + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender2 Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender2 Created : ERROR : ' + err.message); + }); + + let b = await audioRen_interrupt.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + console.info("AudioFrameworkRenderLog audioRen_interrupt setInterruptMode(INDEPENDENT_MODE) success"); + + await audioRen_interrupt.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant2 started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); + }); + await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_RENDERER_INTERUPT_AUDIO_0700 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0100 + * @tc.name : SetInterruptMode mode 0 callback,is public share mode + * @tc.desc : SetInterruptMode mode 0 callback,is public share mode + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0100", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = audio.InterruptMode.SHARE_MODE; + audioRenderer.setInterruptMode(mode, async (err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: error: ${err.message}`); + expect(false).assertTrue(); + await audioRenderer.release(); + done(); + return; + } + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: SUCCESS`); + expect(true).assertTrue(); + await audioRenderer.release(); + done(); + }) + }) + + /* + * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0200 + * @tc.desc:SetInterruptMode mode 1 callback,is independent mode + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0200", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = audio.InterruptMode.INDEPENDENT_MODE; + audioRenderer.setInterruptMode(mode, async (err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: error: ${err.message}`); + expect(false).assertTrue(); + await audioRenderer.release(); + done(); + return; + } + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: SUCCESS`); + expect(true).assertTrue(); + await audioRenderer.release(); + done(); + }) + }) + + /* + * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0300 + * @tc.desc:SetInterruptMode mode 0 promise,is public share mode + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0300", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = audio.InterruptMode.SHARE_MODE; + await audioRenderer.setInterruptMode(mode).then(data => { + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE PROMISE: SUCCESS`); + expect(true).assertTrue(); + }).catch(err => { + console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE PROMISE: error: ${err.message}`); + expect(false).assertTrue(); + }) + await audioRenderer.release(); + done(); + }) + + /* + * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0400 + * @tc.desc:SetInterruptMode mode 1 promise,is independent mode + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0400", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = audio.InterruptMode.INDEPENDENT_MODE; + await audioRenderer.setInterruptMode(mode).then(data => { + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: SUCCESS`); + expect(true).assertTrue(); + }).catch(err => { + console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: error: ${err.message}`); + expect(false).assertTrue(); + }) + await audioRenderer.release(); + done(); + }) + + /* + * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0500 + * @tc.desc:SetInterruptMode mode '1',will catch error with type error + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0500", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = '1'; + try { + let data = await audioRenderer.setInterruptMode(mode); + console.info(`${TagFrmwkRender}: SetInterruptMode STRING PROMISE: SUCCESS`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.info(`${TagFrmwkRender}: SetInterruptMode STRING PROMISE: error: ${err.message}`); + expect(true).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0600 + * @tc.desc:SetInterruptMode mode 2,set it to default SHARE_MODE + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0600", 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + let mode = 2; + try { + let data = await audioRenderer.setInterruptMode(mode); + console.info(`${TagFrmwkRender}: SetInterruptMode OUT OF BORDER PROMISE: SUCCESS`); + expect(true).assertTrue(); + done(); + } catch (err) { + console.info(`${TagFrmwkRender}: SetInterruptMode OUT OF BORDER PROMISE: ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0100 + * @tc.name : AudioRenderer - getAudioStreamId + * @tc.desc : AudioRenderer - getAudioStreamId + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + let audioStreamId; + await audioRen.getAudioStreamId().then((data) => { + audioStreamId = data; + console.info(`${TagFrmwkRender}: getAudioStreamId : Converted: ${data}`); + expect(true).assertTrue(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: getAudioStreamId : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + }); + + await audioRen.start().then(async function () { + console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS '); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: renderInstant start :ERROR code: ' + err.code + ', message: ' + err.message); + }); + await sleep(2000); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0100 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0200 + * @tc.name : AudioRenderer - getAudioStreamId + * @tc.desc : AudioRenderer - getAudioStreamId + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIO_STREAM_ID_0200', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen = await audio.createAudioRenderer(AudioRendererOptions); + await audioRen.getAudioStreamId((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getAudioStreamId : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + } else { + expect(true).assertTrue(); + console.info(`${TagFrmwkRender}: getAudioStreamId : Converted: ${data}`); + } + }); + await audioRen.release(); + } catch (err) { + console.log(`${Tag} err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0100 + * @tc.name : AudioRenderer - setVolume 0 + * @tc.desc : AudioRenderer - setVolume 0 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + let inputVolume = 0; + + await audioRen.setVolume(inputVolume).then(() => { + expect(true).assertTrue(); + console.info(`${TagFrmwkRender}: setVolume to 0 : Success`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + }); + + await sleep(2000); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0100 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0200 + * @tc.name : AudioRenderer - setVolume 15 + * @tc.desc : AudioRenderer - setVolume 15 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0200', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + let inputVolume = 15; + + await audioRen.setVolume(inputVolume).then(() => { + expect(true).assertTrue(); + console.info(`${TagFrmwkRender}: setVolume to 15 : Success`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + }); + + await sleep(1000); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0200 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0300 + * @tc.name : AudioRenderer - setVolume "string" + * @tc.desc : AudioRenderer - setVolume 'string, will return error' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0300', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + + try { + let audioRen; + + await audio.createAudioRenderer(AudioRendererOptions).then(async function (data) { + audioRen = data; + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message); + }); + + let inputVolume = "string"; + + await audioRen.setVolume(inputVolume).then(() => { + expect(false).assertTrue(); + console.info(`${TagFrmwkRender}: setVolume to string : Success`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(true).assertTrue(); + }); + + await sleep(1000); + } + catch (error) { + console.log("SUB_MULTIMEDIA_AUDIO_SET_VOLUME_0300 : error = " + error); + expect(false).assertTrue(); + } + done(); + }) /** * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_PLAY_AUDIO_0100 * @tc.name : AudioRenderer-Set1-Media @@ -3333,7 +4514,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); done(); }) @@ -3505,7 +4686,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -3594,7 +4775,7 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release(); done(); }) @@ -3681,7 +4862,7 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release(); done(); }) @@ -3768,7 +4949,7 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release(); done(); }) @@ -3855,7 +5036,7 @@ describe('audioRenderer', function () { }); expect(resultFlag).assertTrue(); - + await audioRen.release(); done(); }) @@ -3940,7 +5121,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4027,7 +5208,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4114,7 +5295,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4201,7 +5382,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4288,7 +5469,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4375,7 +5556,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4462,7 +5643,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4549,7 +5730,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4636,7 +5817,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4723,7 +5904,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4810,7 +5991,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4897,7 +6078,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -4984,7 +6165,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -5071,7 +6252,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -5158,7 +6339,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -5245,7 +6426,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -5332,7 +6513,7 @@ describe('audioRenderer', function () { console.log(`${TagFrmwkRender}: RendererInfo :ERROR: ${err.message}`); resultFlag = false; }); - + await audioRen.release(); expect(resultFlag).assertTrue(); done(); @@ -7335,6 +8516,8 @@ describe('audioRenderer', function () { console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); }); await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); expect(interrput_flag).assertTrue(); } catch (error) { @@ -7431,6 +8614,8 @@ describe('audioRenderer', function () { console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); }); await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); expect(interrput_flag).assertTrue(); } catch (error) { @@ -7527,6 +8712,8 @@ describe('audioRenderer', function () { console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); }); await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); expect(interrput_flag).assertTrue(); } catch (error) { @@ -7623,6 +8810,8 @@ describe('audioRenderer', function () { console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); }); await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); expect(interrput_flag).assertTrue(); } catch (error) { @@ -7719,6 +8908,8 @@ describe('audioRenderer', function () { console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); }); await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); expect(interrput_flag).assertFalse(); } catch (error) { @@ -7815,6 +9006,8 @@ describe('audioRenderer', function () { console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); }); await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); expect(interrput_flag).assertFalse(); } catch (error) { @@ -7911,6 +9104,8 @@ describe('audioRenderer', function () { console.info('AudioFrameworkRenderLog: renderInstant2 start :ERROR : ' + err.message); }); await sleep(2000); + await audioRen.release(); + await audioRen_interrupt.release(); expect(interrput_flag).assertTrue(); } catch (error) { @@ -7920,221 +9115,4 @@ describe('audioRenderer', function () { done(); }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0100 - * @tc.name : SetInterruptMode mode 0 callback,is public share mode - * @tc.desc : SetInterruptMode mode 0 callback,is public share mode - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0100", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = audio.InterruptMode.SHARE_MODE; - audioRenderer.setInterruptMode(mode, (err, data) => { - if (err) { - console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: error: ${err.message}`); - expect(false).assertTrue(); - done(); - return; - } - console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE CALLBACK: SUCCESS`); - expect(true).assertTrue(); - done(); - }) - }) - - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0200 - * @tc.desc:SetInterruptMode mode 1 callback,is independent mode - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0200", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = audio.InterruptMode.INDEPENDENT_MODE; - audioRenderer.setInterruptMode(mode, (err, data) => { - if (err) { - console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: error: ${err.message}`); - expect(false).assertTrue(); - done(); - return; - } - console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE CALLBACK: SUCCESS`); - expect(true).assertTrue(); - done(); - }) - }) - - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0300 - * @tc.desc:SetInterruptMode mode 0 promise,is public share mode - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0300", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = audio.InterruptMode.SHARE_MODE; - audioRenderer.setInterruptMode(mode).then(data => { - console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE PROMISE: SUCCESS`); - expect(true).assertTrue(); - done(); - }).catch(err => { - console.info(`${TagFrmwkRender}: SetInterruptMode SHARE_MODE PROMISE: error: ${err.message}`); - expect(false).assertTrue(); - done(); - }) - }) - - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0400 - * @tc.desc:SetInterruptMode mode 1 promise,is independent mode - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0400", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = audio.InterruptMode.INDEPENDENT_MODE; - audioRenderer.setInterruptMode(mode).then(data => { - console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: SUCCESS`); - expect(true).assertTrue(); - done(); - }).catch(err => { - console.info(`${TagFrmwkRender}: SetInterruptMode INDEPENDENT_MODE PROMISE: error: ${err.message}`); - expect(false).assertTrue(); - done(); - }) - }) - - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0500 - * @tc.desc:SetInterruptMode mode '1',will catch error with type error - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0500", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = '1'; - try { - let data = await audioRenderer.setInterruptMode(mode); - console.info(`${TagFrmwkRender}: SetInterruptMode STRING PROMISE: SUCCESS`); - expect(false).assertTrue(); - done(); - } catch (err) { - console.info(`${TagFrmwkRender}: SetInterruptMode STRING PROMISE: error: ${err.message}`); - expect(true).assertTrue(); - done(); - } - }) - - /* - * @tc.name:SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0600 - * @tc.desc:SetInterruptMode mode 2,set it to default SHARE_MODE - * @tc.type: FUNC - * @tc.require: Issue Number - */ - it("SUB_MULTIMEDIA_AUDIO_SETINTERRUPTMODE_0600", 2, async function (done) { - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); - let mode = 2; - try { - let data = await audioRenderer.setInterruptMode(mode); - console.info(`${TagFrmwkRender}: SetInterruptMode OUT OF BORDER PROMISE: SUCCESS`); - expect(true).assertTrue(); - done(); - } catch (err) { - console.info(`${TagFrmwkRender}: SetInterruptMode OUT OF BORDER PROMISE: ERROR: ${err.message}`); - expect(false).assertTrue(); - done(); - } - }) }) \ No newline at end of file -- GitLab