diff --git a/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/AudioCapturerJsUnitTest.js b/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/AudioCapturerJsUnitTest.js new file mode 100644 index 0000000000000000000000000000000000000000..ea7ffe00995db0d9caac5ee09730e887530f7635 --- /dev/null +++ b/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/AudioCapturerJsUnitTest.js @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import audio from '@ohos.multimedia.audio'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +const TAG = "[AudioCapturerJsUnitTest]"; + +describe("AudioCapturerJsUnitTest", function() { + 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 audioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioCapturerInfo + } + + let audioCapturer; + + beforeAll(async function () { + // input testsuit setup step, setup invoked before all testcases + try { + audioCapturer = audio.createAudioCapturerSync(audioCapturerOptions); + console.info(`${TAG}: AudioCapturer created SUCCESS, state: ${audioCapturer.state}`); + } catch (err) { + console.error(`${TAG}: AudioCapturer created ERROR: ${err.message}`); + } + console.info(TAG + 'beforeAll called') + }) + + afterAll(function () { + + // input testsuit teardown step, teardown invoked after all testcases + audioCapturer.release().then(() => { + console.info(`${TAG}: AudioCapturer release : SUCCESS`); + }).catch((err) => { + console.info(`${TAG}: AudioCapturer release :ERROR : ${err.message}`); + }); + console.info(TAG + 'afterAll called') + }) + + beforeEach(function () { + + // input testcase setup step, setup invoked before each testcases + console.info(TAG + 'beforeEach called') + }) + + afterEach(function () { + + // input testcase teardown step, teardown invoked after each testcases + console.info(TAG + 'afterEach called') + }) + + /* + * @tc.name:SUB_AUDIO_CREATE_AUDIO_CAPUTURER_SYNC_001 + * @tc.desc:createAudioCapturerSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_CREATE_AUDIO_CAPUTURER_SYNC_001", 0, async function (done) { + try { + let value = audio.createAudioCapturerSync(audioCapturerOptions); + console.info(`SUB_AUDIO_CREATE_AUDIO_CAPUTURER_SYNC_001 SUCCESS: ${value}.`); + expect(typeof value).assertEqual('object'); + done(); + } catch (err) { + console.error(`SUB_AUDIO_CREATE_AUDIO_CAPUTURER_SYNC_001 ERROR: ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_CAPTURER_GET_STREAM_INFO_SYNC_TEST_001 + * @tc.desc:getStreamInfoSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_CAPTURER_GET_STREAM_INFO_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioCapturer.getStreamInfoSync(); + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_STREAM_INFO_SYNC_TEST_001 SUCCESS: ${data}`); + expect(data.samplingRate).assertEqual(audio.AudioSamplingRate.SAMPLE_RATE_48000); + expect(data.channels).assertEqual(audio.AudioChannel.CHANNEL_1); + expect(data.sampleFormat).assertEqual(audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE); + expect(data.encodingType).assertEqual(audio.AudioEncodingType.ENCODING_TYPE_RAW); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_STREAM_INFO_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_CAPTURER_GET_CAPTURER_INFO_SYNC_TEST_001 + * @tc.desc:getCapturerInfoSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_CAPTURER_GET_CAPTURER_INFO_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioCapturer.getCapturerInfoSync(); + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_CAPTURER_INFO_SYNC_TEST_001 SUCCESS: ${data}`); + expect(data.source).assertEqual(audio.SourceType.SOURCE_TYPE_MIC); + expect(data.capturerFlags).assertEqual(0); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_CAPTURER_INFO_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_SYNC_TEST_001 + * @tc.desc:getAudioStreamIdSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioCapturer.getAudioStreamIdSync(); + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_SYNC_TEST_001 SUCCESS: ${data}`); + expect(typeof data).assertEqual('number'); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_CAPTURER_GET_BUFFER_SIZE_SYNC_TEST_001 + * @tc.desc:getBufferSizeSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_CAPTURER_GET_BUFFER_SIZE_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioCapturer.getBufferSizeSync(); + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_BUFFER_SIZE_SYNC_TEST_001 SUCCESS: ${data}`); + expect(typeof data).assertEqual('number'); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_BUFFER_SIZE_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_CAPTURER_GET_AUDIO_TIME_SYNC_TEST_001 + * @tc.desc:getAudioTimeSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_CAPTURER_GET_AUDIO_TIME_SYNC_TEST_001', 0, async function (done) { + try { + let audioCapturer = audio.createAudioCapturerSync(audioCapturerOptions); + let data = audioCapturer.getAudioTimeSync(); + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_AUDIO_TIME_SYNC_TEST_001 SUCCESS, before start: ${data}`); + expect(data).assertEqual(0); + + await audioCapturer.start(); + data = audioCapturer.getAudioTimeSync(); + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_AUDIO_TIME_SYNC_TEST_001 SUCCESS, after start: ${data}`); + expect(data).assertLarger(0); + + await audioCapturer.stop(); + await audioCapturer.release(); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_CAPTURER_GET_AUDIO_TIME_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) +}) diff --git a/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/BUILD.gn b/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8deb54c6bcbbd761202998b7cf3672f932a328b2 --- /dev/null +++ b/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2023 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("//build/test.gni") + +module_output_path = "multimedia_audio_framework/audio_capturer_js" + +ohos_js_unittest("AudioCapturerJsUnitTest") { + module_out_path = module_output_path + + hap_profile = "./config.json" + certificate_profile = "./signature/openharmony_sx.p7b" +} + +group("jsunittest") { + testonly = true + deps = [ ":AudioCapturerJsUnitTest" ] +} diff --git a/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/config.json b/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/config.json new file mode 100644 index 0000000000000000000000000000000000000000..f9ecd195bbeca922cf0a4f5fd9a6dc219aff3a91 --- /dev/null +++ b/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 8, + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication", + "name": ".MyApplication", + "deviceType": [ + "phone", + "tablet", + "2in1" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.myapplication.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "MyApplication", + "type": "page", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } + } \ No newline at end of file diff --git a/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/signature/openharmony_sx.p7b b/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..49d5a09221f14f3d260b279ac71c241802e9391f Binary files /dev/null and b/frameworks/js/napi/audio_capturer/test/unittest/audio_capturer_test/signature/openharmony_sx.p7b differ diff --git a/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/AudioManagerJsUnitTest.js b/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/AudioManagerJsUnitTest.js new file mode 100644 index 0000000000000000000000000000000000000000..d3b305285bd584a42eb2e0af67dd5fd1a014675e --- /dev/null +++ b/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/AudioManagerJsUnitTest.js @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import audio from '@ohos.multimedia.audio'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + + +describe("AudioManagerJsUnitTest", function () { + let audioManager = audio.getAudioManager(); + + beforeAll(async function () { + + // input testsuit setup step,setup invoked before all testcases + console.info('beforeAll called') + }) + + afterAll(function () { + + // input testsuit teardown step,teardown invoked after all testcases + console.info('afterAll called') + }) + + beforeEach(function () { + + // input testcase setup step,setup invoked before each testcases + console.info('beforeEach called') + }) + + afterEach(function () { + + // input testcase teardown step,teardown invoked after each testcases + console.info('afterEach called') + }) + + /* + * @tc.name:SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_001 + * @tc.desc:getAudioScene success - AUDIO_SCENE_DEFAULT + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_001", 0, async function (done) { + audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_DEFAULT, (err) => { + if (err) { + console.error(`Failed to set the audio scene mode. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate a successful setting of the audio scene mode.'); + expect(true).assertTrue(); + + try { + let value = audioManager.getAudioSceneSync(); + console.info(`SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_001 SUCCESS: ${value}.`); + expect(value).assertEqual(audio.AudioScene.AUDIO_SCENE_DEFAULT); + done(); + } catch (err) { + console.error(`SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_001 ERROR: ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_002 + * @tc.desc:getAudioScene success - AUDIO_SCENE_RINGING + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_002", 0, async function (done) { + audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_RINGING, (err) => { + if (err) { + console.error(`Failed to set the audio scene mode. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate a successful setting of the audio scene mode.'); + expect(true).assertTrue(); + + try { + let value = audioManager.getAudioSceneSync(); + console.info(`SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_002 SUCCESS: ${value}.`); + expect(value).assertEqual(audio.AudioScene.AUDIO_SCENE_RINGING); + done(); + } catch (err) { + console.error(`SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_002 ERROR: ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_003 + * @tc.desc:getAudioScene success - AUDIO_SCENE_PHONE_CALL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_003", 0, async function (done) { + audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL, (err) => { + if (err) { + console.error(`Failed to set the audio scene mode. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate a successful setting of the audio scene mode.'); + expect(true).assertTrue(); + + try { + let value = audioManager.getAudioSceneSync(); + console.info(`SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_003 SUCCESS: ${value}.`); + expect(value).assertEqual(audio.AudioScene.AUDIO_SCENE_PHONE_CALL); + done(); + } catch (err) { + console.error(`SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_003 ERROR: ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_004 + * @tc.desc:getAudioScene success - AUDIO_SCENE_PHONE_CALL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_004", 0, async function (done) { + audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT, (err) => { + if (err) { + console.error(`Failed to set the audio scene mode. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate a successful setting of the audio scene mode.'); + expect(true).assertTrue(); + + try { + let value = audioManager.getAudioSceneSync(); + console.info(`SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_004 SUCCESS: ${value}.`); + expect(value).assertEqual(audio.AudioScene.AUDIO_SCENE_VOICE_CHAT); + done(); + } catch (err) { + console.error(`SUB_AUDIO_MANAGER_GET_AUDIO_SCENE_SYNC_004 ERROR: ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) +}) \ No newline at end of file diff --git a/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/BUILD.gn b/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b62580d6e4c8daf579d128e156ef2c16d25e0124 --- /dev/null +++ b/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2023 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("//build/test.gni") + +module_output_path = "multimedia_audio_framework/audio_manager_js" + +ohos_js_unittest("AudioManagerJsUnitTest") { + module_out_path = module_output_path + + hap_profile = "./config.json" + certificate_profile = "./signature/openharmony_sx.p7b" +} + +group("jsunittest") { + testonly = true + deps = [ ":AudioManagerJsUnitTest" ] +} diff --git a/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/config.json b/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/config.json new file mode 100644 index 0000000000000000000000000000000000000000..f9ecd195bbeca922cf0a4f5fd9a6dc219aff3a91 --- /dev/null +++ b/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 8, + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication", + "name": ".MyApplication", + "deviceType": [ + "phone", + "tablet", + "2in1" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.myapplication.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "MyApplication", + "type": "page", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } + } \ No newline at end of file diff --git a/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/signature/openharmony_sx.p7b b/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..49d5a09221f14f3d260b279ac71c241802e9391f Binary files /dev/null and b/frameworks/js/napi/audio_manager/test/unittest/audio_manager_test/signature/openharmony_sx.p7b differ diff --git a/frameworks/js/napi/audio_manager/test/unittest/group_manager_test/AudioGroupManagerJsUnitTest.js b/frameworks/js/napi/audio_manager/test/unittest/group_manager_test/AudioGroupManagerJsUnitTest.js index 2435be235fc7c68afeaed88b9a7c3c8492268949..c4dc21ccd98574d05f6f88f1b27e20419c4564a2 100644 --- a/frameworks/js/napi/audio_manager/test/unittest/group_manager_test/AudioGroupManagerJsUnitTest.js +++ b/frameworks/js/napi/audio_manager/test/unittest/group_manager_test/AudioGroupManagerJsUnitTest.js @@ -24,6 +24,10 @@ describe("AudioGroupManagerJsUnitTest", function () { let audioVolumeManager = audioManager.getVolumeManager(); const GROUP_ID = audio.DEFAULT_VOLUME_GROUP_ID; let audioVolumeGroupManager; + const ERROR_INPUT_INVALID = '401'; + const ERROR_INVALID_PARAM = '6800101'; + const MIN_VOLUME_LEVEL = 0; + const MAX_VOLUME_LEVEL = 15; beforeAll(async function () { audioVolumeGroupManager = await audioVolumeManager.getVolumeGroupManager(GROUP_ID).catch((err) => { @@ -200,4 +204,1229 @@ describe("AudioGroupManagerJsUnitTest", function () { done(); }) }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_001 + * @tc.desc:verify getVolumeSync get volume successfully - VOICE_CALL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_001", 0, async function (done) { + let volume = 6; + audioVolumeGroupManager.setVolume(audio.AudioVolumeType.VOICE_CALL, volume, (err) => { + if (err) { + console.error(`Failed to set VOICE_CALL volume. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate a successful VOICE_CALL volume setting.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.getVolumeSync(audio.AudioVolumeType.VOICE_CALL); + console.info(`get VOICE_CALL volume is obtained ${value}.`); + expect(value).assertEqual(volume); + done(); + } catch (err) { + console.error(`Failed to obtain VOICE_CALL volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_002 + * @tc.desc:verify getVolumeSync get volume successfully - RINGTONE + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_002", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getVolumeSync(audio.AudioVolumeType.RINGTONE); + console.info(`get MEDIA volume is obtained ${value}.`); + expect(value >= MIN_VOLUME_LEVEL && value <= MAX_VOLUME_LEVEL).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain RINGTONE volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_003 + * @tc.desc:verify getVolumeSync get volume successfully - MEDIA + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_003", 0, async function (done) { + let volume = 6; + audioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, volume, (err) => { + if (err) { + console.error(`Failed to set MEDIA volume. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate a successful MEDIA volume setting.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.getVolumeSync(audio.AudioVolumeType.MEDIA); + console.info(`get MEDIA volume is obtained ${value}.`); + expect(value).assertEqual(volume); + done(); + } catch (err) { + console.error(`Failed to obtain MEDIA volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_004 + * @tc.desc:verify getVolumeSync get volume successfully - ALARM + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_004", 0, async function (done) { + let volume = 6; + audioVolumeGroupManager.setVolume(audio.AudioVolumeType.ALARM, volume, (err) => { + if (err) { + console.error(`Failed to set ALARM volume. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate a successful ALARM volume setting.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.getVolumeSync(audio.AudioVolumeType.ALARM); + console.info(`get ALARM volume is obtained ${value}.`); + expect(value).assertEqual(volume); + done(); + } catch (err) { + console.error(`Failed to obtain ALARM volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_005 + * @tc.desc:verify getVolumeSync get volume successfully - ACCESSIBILITY + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_005", 0, async function (done) { + let volume = 6; + audioVolumeGroupManager.setVolume(audio.AudioVolumeType.ACCESSIBILITY, volume, (err) => { + if (err) { + console.error(`Failed to set ACCESSIBILITY volume. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate a successful ACCESSIBILITY volume setting.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.getVolumeSync(audio.AudioVolumeType.ACCESSIBILITY); + console.info(`get ACCESSIBILITY volume is obtained ${value}.`); + expect(value).assertEqual(volume); + done(); + } catch (err) { + console.error(`Failed to obtain ACCESSIBILITY volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_006 + * @tc.desc:verify getVolumeSync get volume successfully - VOICE_ASSISTANT + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_006", 0, async function (done) { + let volume = 6; + audioVolumeGroupManager.setVolume(audio.AudioVolumeType.VOICE_ASSISTANT, volume, (err) => { + if (err) { + console.error(`Failed to set VOICE_ASSISTANT volume. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate a successful VOICE_ASSISTANT volume setting.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.getVolumeSync(audio.AudioVolumeType.VOICE_ASSISTANT); + console.info(`get VOICE_ASSISTANT volume is obtained ${value}.`); + expect(value).assertEqual(volume); + done(); + } catch (err) { + console.error(`Failed to obtain VOICE_ASSISTANT volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_007 + * @tc.desc:verify getVolumeSync get volume successfully - ULTRASONIC + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_007", 0, async function (done) { + let volume = 6; + audioVolumeGroupManager.setVolume(audio.AudioVolumeType.ULTRASONIC, volume, (err) => { + if (err) { + console.error(`Failed to set ULTRASONIC volume. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate a successful ULTRASONIC volume setting.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.getVolumeSync(audio.AudioVolumeType.ULTRASONIC); + console.info(`get ULTRASONIC volume is obtained ${value}.`); + expect(value).assertEqual(volume); + done(); + } catch (err) { + console.error(`Failed to obtain ULTRASONIC volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_008 + * @tc.desc:verify getVolumeSync get volume successfully - ALL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_008", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getVolumeSync(audio.AudioVolumeType.ULTRASONIC); + console.info(`get ULTRASONIC volume is obtained ${value}.`); + expect(value >= MIN_VOLUME_LEVEL && value <= MAX_VOLUME_LEVEL).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain ALL volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_009 + * @tc.desc:verify getVolumeSync get volume fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_009", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getVolumeSync(); + console.info(`get volume is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_010 + * @tc.desc:verify getVolumeSync get volume fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_010", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getVolumeSync("Invalid type"); + console.info(`get volume is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_011 + * @tc.desc:verify getVolumeSync get volume fail(6800101) - Invalid param value : 10000 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_VOLUME_SYNC_011", 0, async function (done) { + let invalidVolumeType = 10000; + try { + let value = audioVolumeGroupManager.getVolumeSync(invalidVolumeType); + console.info(`get volume is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume. ${err}`); + expect(err.code).assertEqual(ERROR_INVALID_PARAM); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_001 + * @tc.desc:verify getMinVolumeSync get min volume successfully - VOICE_CALL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_001", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMinVolumeSync(audio.AudioVolumeType.VOICE_CALL); + console.info(`get VOICE_CALL min volume is obtained ${value}.`); + expect(value >= MIN_VOLUME_LEVEL && value < MAX_VOLUME_LEVEL).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain VOICE_CALL min volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_002 + * @tc.desc:verify getMinVolumeSync get min volume successfully - RINGTONE + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_002", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMinVolumeSync(audio.AudioVolumeType.RINGTONE); + console.info(`get RINGTONE min volume is obtained ${value}.`); + expect(value >= MIN_VOLUME_LEVEL && value < MAX_VOLUME_LEVEL).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain RINGTONE min volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_003 + * @tc.desc:verify getMinVolumeSync get min volume successfully - MEDIA + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_003", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMinVolumeSync(audio.AudioVolumeType.MEDIA); + console.info(`get MEDIA min volume is obtained ${value}.`); + expect(value >= MIN_VOLUME_LEVEL && value < MAX_VOLUME_LEVEL).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain MEDIA min volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_004 + * @tc.desc:verify getMinVolumeSync get min volume successfully - ALARM + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_004", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMinVolumeSync(audio.AudioVolumeType.ALARM); + console.info(`get ALARM min volume is obtained ${value}.`); + expect(value >= MIN_VOLUME_LEVEL && value < MAX_VOLUME_LEVEL).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain ALARM min volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_005 + * @tc.desc:verify getMinVolumeSync get min volume successfully - ACCESSIBILITY + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_005", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMinVolumeSync(audio.AudioVolumeType.ACCESSIBILITY); + console.info(`get ACCESSIBILITY min volume is obtained ${value}.`); + expect(value >= MIN_VOLUME_LEVEL && value < MAX_VOLUME_LEVEL).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain ACCESSIBILITY min volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_006 + * @tc.desc:verify getMinVolumeSync get min volume successfully - VOICE_ASSISTANT + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_006", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMinVolumeSync(audio.AudioVolumeType.VOICE_ASSISTANT); + console.info(`get VOICE_ASSISTANT min volume is obtained ${value}.`); + expect(value >= MIN_VOLUME_LEVEL && value < MAX_VOLUME_LEVEL).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain VOICE_ASSISTANT min volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_007 + * @tc.desc:verify getMinVolumeSync get min volume successfully - ULTRASONIC + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_007", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMinVolumeSync(audio.AudioVolumeType.ULTRASONIC); + console.info(`get ULTRASONIC min volume is obtained ${value}.`); + expect(value >= MIN_VOLUME_LEVEL && value < MAX_VOLUME_LEVEL).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain ULTRASONIC min volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_008 + * @tc.desc:verify getMinVolumeSync get min volume successfully - ALL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_008", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMinVolumeSync(audio.AudioVolumeType.ALL); + console.info(`get ALL min volume is obtained ${value}.`); + expect(value >= MIN_VOLUME_LEVEL && value < MAX_VOLUME_LEVEL).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain ALL min volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_009 + * @tc.desc:verify getMinVolumeSync get min volume fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_009", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMinVolumeSync(); + console.info(`get min volume is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain min volume. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_010 + * @tc.desc:verify getMinVolumeSync get volume fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_010", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMinVolumeSync("Invalid type"); + console.info(`get min volume is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain min volume. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_011 + * @tc.desc:verify getMinVolumeSync get min volume fail(6800101) - Invalid param value : 10000 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MIN_VOLUME_SYNC_011", 0, async function (done) { + let invalidVolumeType = 10000; + try { + let value = audioVolumeGroupManager.getMinVolumeSync(invalidVolumeType); + console.info(`get min volume is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain min volume. ${err}`); + expect(err.code).assertEqual(ERROR_INVALID_PARAM); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_001 + * @tc.desc:verify getMaxVolumeSync get max volume successfully - VOICE_CALL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_001", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMaxVolumeSync(audio.AudioVolumeType.VOICE_CALL); + console.info(`get VOICE_CALL max volume is obtained ${value}.`); + expect(value).assertEqual(MAX_VOLUME_LEVEL); + done(); + } catch (err) { + console.error(`Failed to obtain VOICE_CALL max volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_002 + * @tc.desc:verify getMaxVolumeSync get max volume successfully - RINGTONE + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_002", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMaxVolumeSync(audio.AudioVolumeType.RINGTONE); + console.info(`get RINGTONE max volume is obtained ${value}.`); + expect(value).assertEqual(MAX_VOLUME_LEVEL); + done(); + } catch (err) { + console.error(`Failed to obtain RINGTONE max volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_003 + * @tc.desc:verify getMaxVolumeSync get max volume successfully - MEDIA + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_003", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMaxVolumeSync(audio.AudioVolumeType.MEDIA); + console.info(`get MEDIA max volume is obtained ${value}.`); + expect(value).assertEqual(MAX_VOLUME_LEVEL); + done(); + } catch (err) { + console.error(`Failed to obtain MEDIA max volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_004 + * @tc.desc:verify getMaxVolumeSync get max volume successfully - ALARM + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_004", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMaxVolumeSync(audio.AudioVolumeType.ALARM); + console.info(`get ALARM max volume is obtained ${value}.`); + expect(value).assertEqual(MAX_VOLUME_LEVEL); + done(); + } catch (err) { + console.error(`Failed to obtain ALARM max volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_005 + * @tc.desc:verify getMaxVolumeSync get max volume successfully - ACCESSIBILITY + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_005", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMaxVolumeSync(audio.AudioVolumeType.ACCESSIBILITY); + console.info(`get ACCESSIBILITY max volume is obtained ${value}.`); + expect(value).assertEqual(MAX_VOLUME_LEVEL); + done(); + } catch (err) { + console.error(`Failed to obtain ACCESSIBILITY max volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_006 + * @tc.desc:verify getMaxVolumeSync get max volume successfully - VOICE_ASSISTANT + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_006", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMaxVolumeSync(audio.AudioVolumeType.VOICE_ASSISTANT); + console.info(`get VOICE_ASSISTANT max volume is obtained ${value}.`); + expect(value).assertEqual(MAX_VOLUME_LEVEL); + done(); + } catch (err) { + console.error(`Failed to obtain VOICE_ASSISTANT max volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_007 + * @tc.desc:verify getMaxVolumeSync get max volume successfully - ULTRASONIC + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_007", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMaxVolumeSync(audio.AudioVolumeType.ULTRASONIC); + console.info(`get ULTRASONIC max volume is obtained ${value}.`); + expect(value).assertEqual(MAX_VOLUME_LEVEL); + done(); + } catch (err) { + console.error(`Failed to obtain ULTRASONIC max volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_008 + * @tc.desc:verify getMaxVolumeSync get max volume successfully - ALL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_008", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMaxVolumeSync(audio.AudioVolumeType.ALL); + console.info(`get ALL max volume is obtained ${value}.`); + expect(value).assertEqual(MAX_VOLUME_LEVEL); + done(); + } catch (err) { + console.error(`Failed to obtain ALL max volume. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_009 + * @tc.desc:verify getMaxVolumeSync get max volume fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_009", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMaxVolumeSync(); + console.info(`get max volume is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain max volume. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_010 + * @tc.desc:verify getMaxVolumeSync get volume fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_010", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getMaxVolumeSync("Invalid type"); + console.info(`get max volume is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain max volume. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_011 + * @tc.desc:verify getMaxVolumeSync get max volume fail(6800101) - Invalid param value : 10000 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_MAX_VOLUME_SYNC_011", 0, async function (done) { + let invalidVolumeType = 10000; + try { + let value = audioVolumeGroupManager.getMaxVolumeSync(invalidVolumeType); + console.info(`get max volume is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain max volume. ${err}`); + expect(err.code).assertEqual(ERROR_INVALID_PARAM); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_001 + * @tc.desc:verify isMuteSync get mute status successfully - VOICE_CALL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_001", 0, async function (done) { + audioVolumeGroupManager.mute(audio.AudioVolumeType.VOICE_CALL, true, (err) => { + if (err) { + console.error(`Failed to mute VOICE_CALL stream. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate that VOICE_CALL stream is muted.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.VOICE_CALL); + console.info(`The mute status of VOICE_CALL stream is obtained ${value}.`); + expect(value).assertEqual(false); + done(); + } catch (err) { + console.error(`Failed to obtain VOICE_CALL mute status. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_002 + * @tc.desc:verify isMuteSync get mute status successfully - RINGTONE + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_002", 0, async function (done) { + try { + let value = audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.RINGTONE); + console.info(`The mute status of RINGTONE stream is obtained ${value}.`); + expect(typeof value).assertEqual('boolean'); + done(); + } catch (err) { + console.error(`Failed to obtain RINGTONE mute status. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_003 + * @tc.desc:verify isMuteSync get mute status successfully - MEDIA + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_003", 0, async function (done) { + audioVolumeGroupManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { + if (err) { + console.error(`Failed to mute MEDIA stream. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate that MEDIA stream is muted.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.MEDIA); + console.info(`The mute status of MEDIA stream is obtained ${value}.`); + expect(value).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain MEDIA mute status. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_004 + * @tc.desc:verify isMuteSync get mute status successfully - ALARM + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_004", 0, async function (done) { + audioVolumeGroupManager.mute(audio.AudioVolumeType.ALARM, true, (err) => { + if (err) { + console.error(`Failed to mute ALARM stream. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate that ALARM stream is muted.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.ALARM); + console.info(`The mute status of ALARM stream is obtained ${value}.`); + expect(value).assertEqual(false); + done(); + } catch (err) { + console.error(`Failed to obtain ALARM mute status. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_005 + * @tc.desc:verify isMuteSync get mute status successfully - ACCESSIBILITY + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_005", 0, async function (done) { + audioVolumeGroupManager.mute(audio.AudioVolumeType.ACCESSIBILITY, true, (err) => { + if (err) { + console.error(`Failed to mute ACCESSIBILITY stream. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate that ACCESSIBILITY stream is muted.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.ACCESSIBILITY); + console.info(`The mute status of ACCESSIBILITY stream is obtained ${value}.`); + expect(value).assertEqual(false); + done(); + } catch (err) { + console.error(`Failed to obtain ACCESSIBILITY mute status. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_006 + * @tc.desc:verify isMuteSync get mute status successfully - VOICE_ASSISTANT + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_006", 0, async function (done) { + audioVolumeGroupManager.mute(audio.AudioVolumeType.VOICE_ASSISTANT, true, (err) => { + if (err) { + console.error(`Failed to mute VOICE_ASSISTANT stream. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate that VOICE_ASSISTANT stream is muted.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.VOICE_ASSISTANT); + console.info(`The mute status of VOICE_ASSISTANT stream is obtained ${value}.`); + expect(value).assertEqual(false); + done(); + } catch (err) { + console.error(`Failed to obtain VOICE_ASSISTANT mute status. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_007 + * @tc.desc:verify isMuteSync get mute status successfully - ULTRASONIC + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_007", 0, async function (done) { + audioVolumeGroupManager.mute(audio.AudioVolumeType.ULTRASONIC, true, (err) => { + if (err) { + console.error(`Failed to mute ULTRASONIC stream. ${err}`); + expect(false).assertTrue(); + done(); + return; + } + console.info('invoked to indicate that ULTRASONIC stream is muted.'); + expect(true).assertTrue(); + + try { + let value = audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.ULTRASONIC); + console.info(`The mute status of ULTRASONIC stream is obtained ${value}.`); + expect(value).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain ULTRASONIC mute status. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_008 + * @tc.desc:verify isMuteSync get mute status successfully - ALL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_008", 0, async function (done) { + try { + let value = audioVolumeGroupManager.isMuteSync(audio.AudioVolumeType.ALL); + console.info(`The mute status of ALL stream is obtained ${value}.`); + expect(typeof value).assertEqual('boolean'); + done(); + } catch (err) { + console.error(`Failed to obtain ALL mute status. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_009 + * @tc.desc:verify isMuteSync get mute status fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_009", 0, async function (done) { + try { + let value = audioVolumeGroupManager.isMuteSync(); + console.info(`The mute status of the stream is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain mute status. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_010 + * @tc.desc:verify isMuteSync get mute status fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_010", 0, async function (done) { + try { + let value = audioVolumeGroupManager.isMuteSync("Invalid type"); + console.info(`The mute status of the stream is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain mute status. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_011 + * @tc.desc:verify isMuteSync get mute status fail(6800101) - Invalid param value : 10000 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MUTE_SYNC_011", 0, async function (done) { + let invalidVolumeType = 10000; + try { + let value = audioVolumeGroupManager.isMuteSync(invalidVolumeType); + console.info(`The mute status of the stream is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain mute status. ${err}`); + expect(err.code).assertEqual(ERROR_INVALID_PARAM); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_RINGER_MODE_SYNC_001 + * @tc.desc:verify getRingerModeSync get ringer mode successfully + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_RINGER_MODE_SYNC_001", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getRingerModeSync(); + console.info(`invoked to indicate that the ringer mode is obtained ${value}.`); + expect(typeof value).assertEqual('number'); + done(); + } catch (err) { + console.error(`Failed to obtain the ringer mode. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_IS_MICROPHONE_MUTE_SYNC_001 + * @tc.desc:verify isMicrophoneMuteSync get microphone mute status successfully + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_IS_MICROPHONE_MUTE_SYNC_001", 0, async function (done) { + try { + let value = audioVolumeGroupManager.isMicrophoneMuteSync(); + console.info(`invoked to indicate that the mute status of the microphone is obtained ${value}.`); + expect(typeof value).assertEqual('boolean'); + done(); + } catch (err) { + console.error(`Failed to obtain the mute status of the microphone. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_001 + * @tc.desc:verify getSystemVolumeInDbSync get volume db successfully - + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_001", 0, async function (done) { + let volumeLevel = 3; + try { + let value = audioVolumeGroupManager.getSystemVolumeInDbSync(audio.AudioVolumeType.VOICE_CALL, volumeLevel, + audio.DeviceType.SPEAKER); + console.info(`get volume db is obtained ${value}.`); + expect(typeof value).assertEqual('number'); + done(); + } catch (err) { + console.error(`Failed to obtain volume db. ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_100 + * @tc.desc:verify getSystemVolumeInDbSync get volume db fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_100", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getSystemVolumeInDbSync(); + console.info(`get volume db is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume db. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_101 + * @tc.desc:verify getSystemVolumeInDbSync get volume db fail(401) - Invalid param count : 1 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_101", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getSystemVolumeInDbSync(audio.AudioVolumeType.VOICE_CALL); + console.info(`get volume db is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume db. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_102 + * @tc.desc:verify getSystemVolumeInDbSync get volume db fail(401) - Invalid param count : 2 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_102", 0, async function (done) { + let volumeLevel = 3; + try { + let value = audioVolumeGroupManager.getSystemVolumeInDbSync(audio.AudioVolumeType.VOICE_CALL, + volumeLevel); + console.info(`get volume db is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume db. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_103 + * @tc.desc:verify getSystemVolumeInDbSync get volume db fail(401) - Invalid first param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_103", 0, async function (done) { + let volumeLevel = 3; + try { + let value = audioVolumeGroupManager.getSystemVolumeInDbSync("Invalid type", volumeLevel, + audio.DeviceType.SPEAKER); + console.info(`get volume db is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume db. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_104 + * @tc.desc:verify getSystemVolumeInDbSync get volume db fail(401) - Invalid second param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_104", 0, async function (done) { + try { + let value = audioVolumeGroupManager.getSystemVolumeInDbSync(audio.AudioVolumeType.VOICE_CALL, + "Invalid type", audio.DeviceType.SPEAKER); + console.info(`get volume db is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume db. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_105 + * @tc.desc:verify getSystemVolumeInDbSync get volume db fail(401) - Invalid third param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_105", 0, async function (done) { + let volumeLevel = 3; + try { + let value = audioVolumeGroupManager.getSystemVolumeInDbSync(audio.AudioVolumeType.VOICE_CALL, + volumeLevel, "Invalid type"); + console.info(`get volume db is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume db. ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_106 + * @tc.desc:verify getSystemVolumeInDbSync get volume db fail(6800101) - Invalid first param value : 10000 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_106", 0, async function (done) { + let invalidVolumeType = 10000; + let volumeLevel = 3; + try { + let value = audioVolumeGroupManager.getSystemVolumeInDbSync(invalidVolumeType, volumeLevel, + audio.DeviceType.SPEAKER); + console.info(`get volume db is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume db. ${err}`); + expect(err.code).assertEqual(ERROR_INVALID_PARAM); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_107 + * @tc.desc:verify getSystemVolumeInDbSync get volume db fail(6800101) - Invalid second param value : 100 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_107", 0, async function (done) { + let invalidVolumeLevel = 100; + try { + let value = audioVolumeGroupManager.getSystemVolumeInDbSync(audio.AudioVolumeType.VOICE_CALL, + invalidVolumeLevel, audio.DeviceType.SPEAKER); + console.info(`get volume db is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume db. ${err}`); + expect(err.code).assertEqual(ERROR_INVALID_PARAM); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_108 + * @tc.desc:verify getSystemVolumeInDbSync get volume db fail(6800101) - Invalid third param value : 10000 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_GROUP_MANAGER_GET_SYSTEM_VOLUME_IN_DB_SYNC_108", 0, async function (done) { + let invalidDeviceType = 10000; + let volumeLevel = 3; + try { + let value = audioVolumeGroupManager.getSystemVolumeInDbSync(audio.AudioVolumeType.VOICE_CALL, + volumeLevel, invalidDeviceType); + console.info(`get volume db is obtained ${value}.`); + expect(false).assertTrue(); + done(); + } catch (err) { + console.error(`Failed to obtain volume db. ${err}`); + expect(err.code).assertEqual(ERROR_INVALID_PARAM); + done(); + } + }) + + }) \ No newline at end of file diff --git a/frameworks/js/napi/audio_manager/test/unittest/group_manager_test/BUILD.gn b/frameworks/js/napi/audio_manager/test/unittest/group_manager_test/BUILD.gn index 4e93dd14484fc51404575fe257134ecb8c767bc9..b32aea0004524f74e99bd7666e47c46851dba925 100644 --- a/frameworks/js/napi/audio_manager/test/unittest/group_manager_test/BUILD.gn +++ b/frameworks/js/napi/audio_manager/test/unittest/group_manager_test/BUILD.gn @@ -13,7 +13,7 @@ import("//build/test.gni") -module_output_path = "multimedia_audio_framework/audio_manager_js" +module_output_path = "multimedia_audio_framework/audio_volume_group_manager_js" ohos_js_unittest("AudioGroupManagerJsUnitTest") { module_out_path = module_output_path diff --git a/frameworks/js/napi/audio_manager/test/unittest/routing_manager_test/AudioRoutingManagerJsTest.js b/frameworks/js/napi/audio_manager/test/unittest/routing_manager_test/AudioRoutingManagerJsTest.js index d7fac0e5626884a2116d1df5164b20e441a82972..fc67767539366ddede731aed7404bcb59b674526 100644 --- a/frameworks/js/napi/audio_manager/test/unittest/routing_manager_test/AudioRoutingManagerJsTest.js +++ b/frameworks/js/napi/audio_manager/test/unittest/routing_manager_test/AudioRoutingManagerJsTest.js @@ -21,6 +21,8 @@ const stringParameter = 'stringParameter'; const numberParameter = 12345678; describe("AudioRoutingManagerJsTest", function () { + const ERROR_INPUT_INVALID = '401'; + const ERROR_INVALID_PARAM = '6800101'; beforeAll(async function () { @@ -799,4 +801,318 @@ describe("AudioRoutingManagerJsTest", function () { done(); } }) + + /* + * @tc.name:isCommunicationDeviceActiveSync001 + * @tc.desc:Get isCommunicationDeviceActiveSync success - SPEAKER + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isCommunicationDeviceActiveSync001", 0, async function (done) { + let audioRoutingManager = null; + + try { + audioRoutingManager = audio.getAudioManager().getRoutingManager(); + await audioRoutingManager.setCommunicationDevice(audio.CommunicationDeviceType.SPEAKER, true); + let isActive = audioRoutingManager.isCommunicationDeviceActiveSync(audio.CommunicationDeviceType.SPEAKER); + console.info(`The active status of the device is obtained ${isActive}.`); + expect(isActive).assertTrue(); + + done(); + } catch(e) { + console.error(`${TAG} isCommunicationDeviceActiveSync001 ERROR: ${e.message}`); + expect(false).assertTrue(); + done(); + return; + } + }); + + /* + * @tc.name:isCommunicationDeviceActiveSync002 + * @tc.desc:Get isCommunicationDeviceActiveSync fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isCommunicationDeviceActiveSync002", 0, async function (done) { + let audioRoutingManager = null; + + try { + audioRoutingManager = audio.getAudioManager().getRoutingManager(); + let isActive = audioRoutingManager.isCommunicationDeviceActiveSync(); + console.info(`The active status of the device is obtained ${isActive}.`); + expect(false).assertTrue(); + + done(); + } catch(e) { + console.error(`${TAG} isCommunicationDeviceActiveSync002 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + return; + } + }); + + /* + * @tc.name:isCommunicationDeviceActiveSync003 + * @tc.desc:Get isCommunicationDeviceActiveSync fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isCommunicationDeviceActiveSync003", 0, async function (done) { + let audioRoutingManager = null; + + try { + audioRoutingManager = audio.getAudioManager().getRoutingManager(); + let isActive = audioRoutingManager.isCommunicationDeviceActiveSync("Invalid type"); + console.info(`The active status of the device is obtained ${isActive}.`); + expect(false).assertTrue(); + + done(); + } catch(e) { + console.error(`${TAG} isCommunicationDeviceActiveSync003 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + return; + } + }); + + /* + * @tc.name:isCommunicationDeviceActiveSync004 + * @tc.desc:Get isCommunicationDeviceActiveSync fail(6800101) - Invalid param value : 100 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isCommunicationDeviceActiveSync004", 0, async function (done) { + let invalidDeviceType = 100; + let audioRoutingManager = null; + + try { + audioRoutingManager = audio.getAudioManager().getRoutingManager(); + let isActive = audioRoutingManager.isCommunicationDeviceActiveSync(invalidDeviceType); + console.info(`The active status is obtained ${isActive}.`); + expect(false).assertTrue(); + + done(); + } catch(e) { + console.error(`${TAG} isCommunicationDeviceActiveSync004 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INVALID_PARAM); + done(); + return; + } + }); + + /* + * @tc.name:getDevicesSync001 + * @tc.desc:getDevicesSync success - INPUT_DEVICES_FLAG + * @tc.type: FUNC + * @tc.require: I6C9VA + */ + it("getDevicesSync001", 0, async function (done) { + try { + let routingManager = audio.getAudioManager().getRoutingManager(); + let AudioDeviceDescriptors = routingManager.getDevicesSync(audio.DeviceFlag.INPUT_DEVICES_FLAG); + console.info(`${TAG} getDevicesSync001 SUCCESS:`+ JSON.stringify(AudioDeviceDescriptors)); + expect(AudioDeviceDescriptors.length).assertLarger(0); + for (let i = 0; i < AudioDeviceDescriptors.length; i++) { + expect(AudioDeviceDescriptors[i].displayName!=="" + && AudioDeviceDescriptors[i].displayName!==undefined).assertTrue(); + } + done(); + } catch (e) { + console.error(`${TAG} getDevicesSync001 ERROR: ${e.message}`); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.name:getDevicesSync010 + * @tc.desc:getDevicesSync fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I6C9VA + */ + it("getDevicesSync010", 0, async function (done) { + try { + let routingManager = audio.getAudioManager().getRoutingManager(); + let AudioDeviceDescriptors = routingManager.getDevicesSync(); + console.info(`${TAG} getDevicesSync010 SUCCESS:`+ JSON.stringify(AudioDeviceDescriptors)); + expect(false).assertTrue(); + done(); + } catch (e) { + console.error(`${TAG} getDevicesSync010 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }); + + /* + * @tc.name:getDevicesSync011 + * @tc.desc:getDevicesSync fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I6C9VA + */ + it("getDevicesSync011", 0, async function (done) { + try { + let routingManager = audio.getAudioManager().getRoutingManager(); + let AudioDeviceDescriptors = routingManager.getDevicesSync("Invalid type"); + console.info(`${TAG} getDevicesSync011 SUCCESS:`+ JSON.stringify(AudioDeviceDescriptors)); + expect(false).assertTrue(); + done(); + } catch (e) { + console.error(`${TAG} getDevicesSync011 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }); + + /* + * @tc.name:getDevicesSync012 + * @tc.desc:getDevicesSync fail(6800101) - Invalid param value : 10000 + * @tc.type: FUNC + * @tc.require: I6C9VA + */ + it("getDevicesSync012", 0, async function (done) { + let invalidDeviceFlag = 10000; + try { + let routingManager = audio.getAudioManager().getRoutingManager(); + let AudioDeviceDescriptors = routingManager.getDevicesSync(invalidDeviceFlag); + console.info(`${TAG} getDevicesSync012 SUCCESS:`+ JSON.stringify(AudioDeviceDescriptors)); + expect(false).assertTrue(); + done(); + } catch (e) { + console.error(`${TAG} getDevicesSync012 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INVALID_PARAM); + done(); + } + }); + + /* + * @tc.name:getPreferredInputDeviceForCapturerInfoSyncTest001 + * @tc.desc:getPreferredInputDeviceForCapturerInfoSync success + * @tc.type: FUNC + * @tc.require: I7Q56A + */ + it("getPreferredInputDeviceForCapturerInfoSyncTest001", 0, async function (done) { + let capturerInfo = { + content : audio.ContentType.CONTENT_TYPE_MUSIC, + usage : audio.StreamUsage.STREAM_USAGE_MEDIA, + capturerFlags : 0 } + + try { + let routingManager = audio.getAudioManager().getRoutingManager(); + let data = routingManager.getPreferredInputDeviceForCapturerInfoSync(capturerInfo); + console.info(`${TAG} getPreferredInputDeviceForCapturerInfoSyncTest001 SUCCESS`+JSON.stringify(data)); + expect(true).assertTrue(); + done(); + } catch(e) { + console.error(`${TAG} getPreferredInputDeviceForCapturerInfoSyncTest001 ERROR: ${e.message}`); + expect().assertFail(); + done(); + } + }) + + /* + * @tc.name:getPreferredInputDeviceForCapturerInfoSyncTest002 + * @tc.desc:getPreferredInputDeviceForCapturerInfoSync fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7Q56A + */ + it("getPreferredInputDeviceForCapturerInfoSyncTest002", 0, async function (done) { + try { + let routingManager = audio.getAudioManager().getRoutingManager(); + let data = routingManager.getPreferredInputDeviceForCapturerInfoSync(); + console.info(`${TAG} getPreferredInputDeviceForCapturerInfoSyncTest002 SUCCESS`+JSON.stringify(data)); + expect().assertFail(); + done(); + } catch(e) { + console.error(`${TAG} getPreferredInputDeviceForCapturerInfoSyncTest002 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:getPreferredInputDeviceForCapturerInfoSyncTest003 + * @tc.desc:getPreferredInputDeviceForCapturerInfoSync fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7Q56A + */ + it("getPreferredInputDeviceForCapturerInfoSyncTest003", 0, async function (done) { + try { + let routingManager = audio.getAudioManager().getRoutingManager(); + let data = routingManager.getPreferredInputDeviceForCapturerInfoSync("Invalid type"); + console.info(`${TAG} getPreferredInputDeviceForCapturerInfoSyncTest003 SUCCESS`+JSON.stringify(data)); + expect().assertFail(); + done(); + } catch(e) { + console.error(`${TAG} getPreferredInputDeviceForCapturerInfoSyncTest003 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:getPreferredOutputDeviceForRendererInfoSyncTest001 + * @tc.desc:getPreferredOutputDeviceForRendererInfoSync success + * @tc.type: FUNC + * @tc.require: I7Q56A + */ + it("getPreferredOutputDeviceForRendererInfoSyncTest001", 0, async function (done) { + let rendererInfo = { + content : audio.ContentType.CONTENT_TYPE_MUSIC, + usage : audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags : 0 } + + try { + let routingManager = audio.getAudioManager().getRoutingManager(); + let data = routingManager.getPreferredOutputDeviceForRendererInfoSync(rendererInfo); + console.info(`${TAG} getPreferredOutputDeviceForRendererInfoSyncTest001 SUCCESS`+JSON.stringify(data)); + expect(true).assertTrue(); + done(); + } catch(e) { + console.error(`${TAG} getPreferredOutputDeviceForRendererInfoSyncTest001 ERROR: ${e.message}`); + expect().assertFail(); + done(); + } + }) + + /* + * @tc.name:getPreferredOutputDeviceForRendererInfoSyncTest002 + * @tc.desc:getPreferredOutputDeviceForRendererInfoSync fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7Q56A + */ + it("getPreferredOutputDeviceForRendererInfoSyncTest002", 0, async function (done) { + try { + let routingManager = audio.getAudioManager().getRoutingManager(); + let data = routingManager.getPreferredOutputDeviceForRendererInfoSync(); + console.info(`${TAG} getPreferredOutputDeviceForRendererInfoSyncTest002 SUCCESS`+JSON.stringify(data)); + expect().assertFail(); + done(); + } catch(e) { + console.error(`${TAG} getPreferredOutputDeviceForRendererInfoSyncTest002 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + + /* + * @tc.name:getPreferredOutputDeviceForRendererInfoSyncTest003 + * @tc.desc:getPreferredOutputDeviceForRendererInfoSync fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7Q56A + */ + it("getPreferredOutputDeviceForRendererInfoSyncTest003", 0, async function (done) { + try { + let routingManager = audio.getAudioManager().getRoutingManager(); + let data = routingManager.getPreferredOutputDeviceForRendererInfoSync("Invalid type"); + console.info(`${TAG} getPreferredOutputDeviceForRendererInfoSyncTest003 SUCCESS`+JSON.stringify(data)); + expect().assertFail(); + done(); + } catch(e) { + console.error(`${TAG} getPreferredOutputDeviceForRendererInfoSyncTest003 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + } + }) + }) diff --git a/frameworks/js/napi/audio_manager/test/unittest/routing_manager_test/BUILD.gn b/frameworks/js/napi/audio_manager/test/unittest/routing_manager_test/BUILD.gn index 82f54503057f71bb5ef4b527c2b74e7239d66592..06cce67f236f99ed942b91b60acb5f3432758fb6 100644 --- a/frameworks/js/napi/audio_manager/test/unittest/routing_manager_test/BUILD.gn +++ b/frameworks/js/napi/audio_manager/test/unittest/routing_manager_test/BUILD.gn @@ -13,7 +13,7 @@ import("//build/test.gni") -module_output_path = "multimedia_audio_framework/audio_routing_manager" +module_output_path = "multimedia_audio_framework/audio_routing_manager_js" ohos_js_unittest("AudioRoutingManagerJsTest") { module_out_path = module_output_path diff --git a/frameworks/js/napi/audio_manager/test/unittest/stream_manager_test/AudioStreamManagerJsTest.js b/frameworks/js/napi/audio_manager/test/unittest/stream_manager_test/AudioStreamManagerJsTest.js index 97beef3028d34ec527f93ae369f376edf744c2fc..9b5bc25e4ace023387bf530ebb0295be70db223d 100644 --- a/frameworks/js/napi/audio_manager/test/unittest/stream_manager_test/AudioStreamManagerJsTest.js +++ b/frameworks/js/napi/audio_manager/test/unittest/stream_manager_test/AudioStreamManagerJsTest.js @@ -19,6 +19,9 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from const TAG = "[AudioStreamManagerJsTest]"; describe("AudioStreamManagerJsTest", function () { + const ERROR_INPUT_INVALID = '401'; + const ERROR_INVALID_PARAM = '6800101'; + let AudioStreamInfo = { samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, channels: audio.AudioChannel.CHANNEL_2, @@ -37,6 +40,16 @@ describe("AudioStreamManagerJsTest", function () { rendererInfo: AudioRendererInfo } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo, + } + beforeAll(async function () { console.info(TAG + "beforeAll called"); }) @@ -348,4 +361,843 @@ describe("AudioStreamManagerJsTest", function () { done(); } }); + + /* + * @tc.name:getCurrentAudioRendererInfoArraySync001 + * @tc.desc:Get getCurrentAudioRendererInfoArraySync + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getCurrentAudioRendererInfoArraySync001", 0, async function (done) { + let audioRenderer = null; + let audioStreamManager = null; + try { + audioRenderer = await audio.createAudioRenderer(AudioRendererOptions); + audioStreamManager = audio.getAudioManager().getStreamManager(); + } catch(e) { + console.error(`${TAG} getCurrentAudioRendererInfoArraySync001 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + + try { + let audioRendererInfos = audioStreamManager.getCurrentAudioRendererInfoArraySync(); + console.info("getCurrentAudioRendererInfoArraySync001:"+JSON.stringify(audioRendererInfos)); + expect(audioRendererInfos.length).assertLarger(0); + expect(audioRendererInfos[0].deviceDescriptors[0].displayName!=="" + && audioRendererInfos[0].deviceDescriptors[0].displayName!==undefined).assertTrue(); + + await audioRenderer.release(); + done(); + } catch (err) { + console.error(`${TAG} getCurrentAudioRendererInfoArraySync001 ERROR: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + await audioRenderer.release(); + done(); + return; + } + }); + + /* + * @tc.name:getCurrentAudioRendererInfoArraySync002 + * @tc.desc:Get getCurrentAudioRendererInfoArraySync + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getCurrentAudioRendererInfoArraySync002", 0, async function (done) { + + let audioRenderer = null; + let audioStreamManager = null; + try { + audioRenderer = await audio.createAudioRenderer(AudioRendererOptions); + audioStreamManager = audio.getAudioManager().getStreamManager(); + await audioRenderer.start(); + } catch(e) { + console.error(`${TAG} getCurrentAudioRendererInfoArraySync002 ERROR: ${e.message}`); + expect().assertFail(); + await audioRenderer.release(); + done(); + return; + } + + try { + let audioRendererInfos = audioStreamManager.getCurrentAudioRendererInfoArraySync(); + console.info("AudioRendererChangeInfoArray++++:"+JSON.stringify(audioRendererInfos)); + expect(audioRendererInfos.length).assertLarger(0); + expect(audioRendererInfos[0].deviceDescriptors[0].displayName!=="" + && audioRendererInfos[0].deviceDescriptors[0].displayName!==undefined).assertTrue(); + + await audioRenderer.release(); + done(); + } catch (err) { + console.error(`${TAG} getCurrentAudioRendererInfoArraySync002 ERROR: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + await audioRenderer.release(); + done(); + } + }); + + /* + * @tc.name:getCurrentAudioRendererInfoArraySync003 + * @tc.desc:Get getCurrentAudioRendererInfoArraySync + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getCurrentAudioRendererInfoArraySync003", 0, async function (done) { + let audioRenderer = null; + let audioStreamManager = null; + + try { + audioRenderer = await audio.createAudioRenderer(AudioRendererOptions); + audioStreamManager = audio.getAudioManager().getStreamManager(); + await audioRenderer.start(); + await audioRenderer.stop(); + let audioRendererInfos = audioStreamManager.getCurrentAudioRendererInfoArraySync(); + expect(audioRendererInfos.length).assertLarger(0); + expect(audioRendererInfos[0].deviceDescriptors[0].displayName!=="" + && audioRendererInfos[0].deviceDescriptors[0].displayName!==undefined).assertTrue(); + + await audioRenderer.release(); + audioRendererInfos = audioStreamManager.getCurrentAudioRendererInfoArraySync(); + expect(audioRendererInfos.length).assertEqual(0); + done(); + } catch(e) { + console.error(`${TAG} getCurrentAudioRendererInfoArraySync003 ERROR: ${e.message}`); + expect().assertFail(); + await audioRenderer.release(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync001 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_UNKNOWN + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync001", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync(audio.StreamUsage.STREAM_USAGE_UNKNOWN); + console.info(`${TAG} getAudioEffectInfoArraySync success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync001 ERROR: ${e.message}`); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync002 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_MEDIA + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync002", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync(audio.StreamUsage.STREAM_USAGE_MEDIA); + console.info(`${TAG} getAudioEffectInfoArraySync002 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync002 ERROR: ${e.message}`); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync003 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_MUSIC + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync003", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync(audio.StreamUsage.STREAM_USAGE_MUSIC); + console.info(`${TAG} getAudioEffectInfoArraySync003 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync003 ERROR: ${e.message}`); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync004 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_VOICE_COMMUNICATION + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync004", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync(audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION); + console.info(`${TAG} getAudioEffectInfoArraySync004 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync004 ERROR: ${e.message}`); + expect().assertFail(); + done(); + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync005 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_VOICE_ASSISTANT + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync005", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync(audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT); + console.info(`${TAG} getAudioEffectInfoArraySync005 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync005 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync006 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_ALARM + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync006", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync( + audio.StreamUsage.STREAM_USAGE_ALARM); + console.info(`${TAG} getAudioEffectInfoArraySync006 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync006 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync007 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_VOICE_MESSAGE + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync007", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync( + audio.StreamUsage.STREAM_USAGE_VOICE_MESSAGE); + console.info(`${TAG} getAudioEffectInfoArraySync007 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync007 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync008 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_NOTIFICATION_RINGTONE + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync008", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync( + audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE); + console.info(`${TAG} getAudioEffectInfoArraySync008 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync008 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync009 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_RINGTONE + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync009", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync( + audio.StreamUsage.STREAM_USAGE_RINGTONE); + console.info(`${TAG} getAudioEffectInfoArraySync009 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync009 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync010 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_NOTIFICATION + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync010", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync( + audio.StreamUsage.STREAM_USAGE_NOTIFICATION); + console.info(`${TAG} getAudioEffectInfoArraySync010 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync010 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync011 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_ACCESSIBILITY + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync011", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync( + audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY); + console.info(`${TAG} getAudioEffectInfoArraySync011 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync011 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync012 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_MOVIE + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync012", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync( + audio.StreamUsage.STREAM_USAGE_MOVIE); + console.info(`${TAG} getAudioEffectInfoArraySync012 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync012 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync013 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_GAME + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync013", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync( + audio.StreamUsage.STREAM_USAGE_GAME); + console.info(`${TAG} getAudioEffectInfoArraySync013 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync013 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync014 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_AUDIOBOOK + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync014", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync( + audio.StreamUsage.STREAM_USAGE_AUDIOBOOK); + console.info(`${TAG} getAudioEffectInfoArraySync014 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync014 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync015 + * @tc.desc:Get getAudioEffectInfoArraySync success - STREAM_USAGE_NAVIGATION + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync015", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync( + audio.StreamUsage.STREAM_USAGE_NAVIGATION); + console.info(`${TAG} getAudioEffectInfoArraySync015 success:${JSON.stringify(audioEffectInfoArray)}`); + expect(audioEffectInfoArray.length).assertLarger(0); + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync015 ERROR: ${e.message}`); + expect().assertFail(); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync016 + * @tc.desc:Get getAudioEffectInfoArraySync fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync016", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync(); + console.info(`The effect modes is obtained ${audioEffectInfoArray}.`); + expect(false).assertTrue(); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync016 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync017 + * @tc.desc:Get getAudioEffectInfoArraySync fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync017", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync("Invalid type"); + console.info(`The effect modes is obtained ${audioEffectInfoArray}.`); + expect(false).assertTrue(); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync017 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + return; + } + }); + + /* + * @tc.name:getAudioEffectInfoArraySync018 + * @tc.desc:Get getAudioEffectInfoArraySync fail(6800101) - Invalid param value : 10000 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("getAudioEffectInfoArraySync018", 0, async function (done) { + let invalidVolumeType = 10000; + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioEffectInfoArray = audioStreamManager.getAudioEffectInfoArraySync(invalidVolumeType); + console.info(`The effect modes is obtained ${audioEffectInfoArray}.`); + expect(false).assertTrue(); + + done(); + } catch(e) { + console.error(`${TAG} getAudioEffectInfoArraySync018 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INVALID_PARAM); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync001 + * @tc.desc:Get isActiveSync success - VOICE_CALL - When stream is NOT playing + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync001", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync(audio.AudioVolumeType.VOICE_CALL); + console.info(`The active status is obtained ${isActive}.`); + expect(isActive).assertEqual(false); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync001 ERROR: ${e.message}`); + expect(false).assertTrue(); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync002 + * @tc.desc:Get isActiveSync success - RINGTONE - When stream is NOT playing + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync002", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync(audio.AudioVolumeType.RINGTONE); + console.info(`The active status is obtained ${isActive}.`); + expect(isActive).assertEqual(false); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync002 ERROR: ${e.message}`); + expect(false).assertTrue(); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync003 + * @tc.desc:Get isActiveSync success - MEDIA - When stream is NOT playing + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync003", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync(audio.AudioVolumeType.MEDIA); + console.info(`The active status is obtained ${isActive}.`); + expect(isActive).assertEqual(false); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync003 ERROR: ${e.message}`); + expect(false).assertTrue(); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync004 + * @tc.desc:Get isActiveSync success - ALARM - When stream is NOT playing + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync004", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync(audio.AudioVolumeType.ALARM); + console.info(`The active status is obtained ${isActive}.`); + expect(isActive).assertEqual(false); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync004 ERROR: ${e.message}`); + expect(false).assertTrue(); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync005 + * @tc.desc:Get isActiveSync success - ACCESSIBILITY - When stream is NOT playing + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync005", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync(audio.AudioVolumeType.ACCESSIBILITY); + console.info(`The active status is obtained ${isActive}.`); + expect(isActive).assertEqual(false); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync005 ERROR: ${e.message}`); + expect(false).assertTrue(); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync006 + * @tc.desc:Get isActiveSync success - VOICE_ASSISTANT - When stream is NOT playing + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync006", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync(audio.AudioVolumeType.VOICE_ASSISTANT); + console.info(`The active status is obtained ${isActive}.`); + expect(isActive).assertEqual(false); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync006 ERROR: ${e.message}`); + expect(false).assertTrue(); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync007 + * @tc.desc:Get isActiveSync success - ULTRASONIC - When stream is NOT playing + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync007", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync(audio.AudioVolumeType.ULTRASONIC); + console.info(`The active status is obtained ${isActive}.`); + expect(isActive).assertEqual(false); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync007 ERROR: ${e.message}`); + expect(false).assertTrue(); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync008 + * @tc.desc:Get isActiveSync success - ALL - When stream is NOT playing + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync008", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync(audio.AudioVolumeType.ALL); + console.info(`The active status is obtained ${isActive}.`); + expect(isActive).assertEqual(false); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync008 ERROR: ${e.message}`); + expect(false).assertTrue(); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync009 + * @tc.desc:Get isActiveSync fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync009", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync(); + console.info(`The active status is obtained ${isActive}.`); + expect(false).assertTrue(); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync009 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync010 + * @tc.desc:Get isActiveSync fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync010", 0, async function (done) { + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync("Invalid type"); + console.info(`The active status is obtained ${isActive}.`); + expect(false).assertTrue(); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync010 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INPUT_INVALID); + done(); + return; + } + }); + + /* + * @tc.name:isActiveSync011 + * @tc.desc:Get isActiveSync fail(6800101) - Invalid param value : 10000 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("isActiveSync011", 0, async function (done) { + let invalidVolumeType = 10000; + let audioStreamManager = null; + + try { + audioStreamManager = audio.getAudioManager().getStreamManager(); + let isActive = audioStreamManager.isActiveSync(invalidVolumeType); + console.info(`The active status is obtained ${isActive}.`); + expect(false).assertTrue(); + + done(); + } catch(e) { + console.error(`${TAG} isActiveSync011 ERROR: ${e.message}`); + expect(e.code).assertEqual(ERROR_INVALID_PARAM); + done(); + return; + } + }); }) diff --git a/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/AudioVolumeManagerJsUnitTest.js b/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/AudioVolumeManagerJsUnitTest.js new file mode 100644 index 0000000000000000000000000000000000000000..50a4dfbe17fe87b8e1b7eff8297844b75eaceb3b --- /dev/null +++ b/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/AudioVolumeManagerJsUnitTest.js @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import audio from '@ohos.multimedia.audio'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + + +describe("AudioVolumeManagerJsUnitTest", function () { + let audioManager = audio.getAudioManager(); + let audioVolumeManager = audioManager.getVolumeManager(); + + beforeAll(async function () { + + // input testsuit setup step,setup invoked before all testcases + console.info('beforeAll called') + }) + + afterAll(function () { + + // input testsuit teardown step,teardown invoked after all testcases + console.info('afterAll called') + }) + + beforeEach(function () { + + // input testcase setup step,setup invoked before each testcases + console.info('beforeEach called') + }) + + afterEach(function () { + + // input testcase teardown step,teardown invoked after each testcases + console.info('afterEach called') + }) + + /* + * @tc.name:SUB_AUDIO_VOLUME_MANAGER_GET_VOLUME_GROUP_MANAGER_SYNC_001 + * @tc.desc:getVolumeGroupManagerSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_VOLUME_MANAGER_GET_VOLUME_GROUP_MANAGER_SYNC_001", 0, async function (done) { + let groupid = audio.DEFAULT_VOLUME_GROUP_ID; + try { + let value = audioVolumeManager.getVolumeGroupManagerSync(groupid); + console.info(`SUB_AUDIO_VOLUME_MANAGER_GET_VOLUME_GROUP_MANAGER_SYNC_001 SUCCESS: ${value}.`); + expect(typeof value).assertEqual('object'); + done(); + } catch (err) { + console.error(`SUB_AUDIO_VOLUME_MANAGER_GET_VOLUME_GROUP_MANAGER_SYNC_001 ERROR: ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_VOLUME_MANAGER_GET_VOLUME_GROUP_INFOS_SYNC_001 + * @tc.desc:getVolumeGroupInfosSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_VOLUME_MANAGER_GET_VOLUME_GROUP_INFOS_SYNC_001", 0, async function (done) { + try { + let value = audioVolumeManager.getVolumeGroupInfosSync(audio.LOCAL_NETWORK_ID); + console.info(`SUB_AUDIO_VOLUME_MANAGER_GET_VOLUME_GROUP_INFOS_SYNC_001 SUCCESS: ${value}.`); + expect(value.length).assertLarger(0); + done(); + } catch (err) { + console.error(`SUB_AUDIO_VOLUME_MANAGER_GET_VOLUME_GROUP_INFOS_SYNC_001 ERROR: ${err}`); + expect(false).assertTrue(); + done(); + } + }) +}) \ No newline at end of file diff --git a/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/BUILD.gn b/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..46f86bc5f3b475f323a1ee51e3b273d331959096 --- /dev/null +++ b/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2023 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("//build/test.gni") + +module_output_path = "multimedia_audio_framework/audio_volume_manager_js" + +ohos_js_unittest("AudioVolumeManagerJsUnitTest") { + module_out_path = module_output_path + + hap_profile = "./config.json" + certificate_profile = "./signature/openharmony_sx.p7b" +} + +group("jsunittest") { + testonly = true + deps = [ ":AudioVolumeManagerJsUnitTest" ] +} diff --git a/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/config.json b/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/config.json new file mode 100644 index 0000000000000000000000000000000000000000..f9ecd195bbeca922cf0a4f5fd9a6dc219aff3a91 --- /dev/null +++ b/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 8, + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication", + "name": ".MyApplication", + "deviceType": [ + "phone", + "tablet", + "2in1" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.myapplication.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "MyApplication", + "type": "page", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } + } \ No newline at end of file diff --git a/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/signature/openharmony_sx.p7b b/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..49d5a09221f14f3d260b279ac71c241802e9391f Binary files /dev/null and b/frameworks/js/napi/audio_manager/test/unittest/volume_manager_test/signature/openharmony_sx.p7b differ diff --git a/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_interrupt_test/AudioRendererInterruptSyncUnitTest.js b/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_interrupt_test/AudioRendererInterruptSyncUnitTest.js new file mode 100644 index 0000000000000000000000000000000000000000..d98060dee1a3dc3d7b5094127d523e335d8d935a --- /dev/null +++ b/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_interrupt_test/AudioRendererInterruptSyncUnitTest.js @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2023 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'; + +describe("AudioRendererInterruptSyncUnitTest", function() { + const ERROR_INPUT_INVALID = '401'; + const ERROR_INVALID_PARAM = '6800101'; + 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; + + beforeAll(async function () { + // input testsuit setup step, setup invoked before all testcases + try { + audioRenderer = audio.createAudioRendererSync(audioRendererOptions); + console.info(`${TAG}: AudioRenderer created SUCCESS, state: ${audioRenderer.state}`); + } catch (err) { + console.error(`${TAG}: AudioRenderer created ERROR: ${err.message}`); + } + console.info(TAG + 'beforeAll called') + }) + + afterAll(function () { + + // input testsuit teardown step, teardown invoked after all testcases + audioRenderer.release().then(() => { + console.info(`${TAG}: AudioRenderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TAG}: AudioRenderer release :ERROR : ${err.message}`); + }); + console.info(TAG + 'afterAll called') + }) + + beforeEach(function () { + + // input testcase setup step, setup invoked before each testcases + console.info('beforeEach called') + }) + + afterEach(function () { + + // input testcase teardown step, teardown invoked after each testcases + console.info('afterEach called') + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_INTERRUPT_SYNC_TEST_001 + * @tc.desc:setInterruptModeSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_INTERRUPT_SYNC_TEST_001', 0, async function (done) { + try { + audioRenderer.setInterruptModeSync(audio.InterruptMode.INDEPENDENT_MODE); + console.info(`setInterruptModeSync success`); + expect(true).assertTrue(); + } catch (err) { + console.error(`setInterruptModeSync error: ${err}`); + expect(false).assertTrue(); + } + done() + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_INTERRUPT_SYNC_TEST_002 + * @tc.desc:setInterruptModeSync fail(401) - Invalid param count : 0 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_INTERRUPT_SYNC_TEST_002', 0, async function (done) { + try { + audioRenderer.setInterruptModeSync(); + console.info(`setInterruptModeSync success`); + expect(false).assertTrue(); + } catch (err) { + console.error(`setInterruptModeSync error: ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + } + done() + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_INTERRUPT_SYNC_TEST_003 + * @tc.desc:setInterruptModeSync fail(401) - Invalid param type : "Invalid type" + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_INTERRUPT_SYNC_TEST_003', 0, async function (done) { + try { + audioRenderer.setInterruptModeSync("Invalid type"); + console.info(`setInterruptModeSync success`); + expect(false).assertTrue(); + } catch (err) { + console.error(`setInterruptModeSync error: ${err}`); + expect(err.code).assertEqual(ERROR_INPUT_INVALID); + } + done() + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_INTERRUPT_SYNC_TEST_004 + * @tc.desc:setInterruptModeSync fail(6800101) - Invalid param value : 100 + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_INTERRUPT_SYNC_TEST_004', 0, async function (done) { + try { + audioRenderer.setInterruptModeSync(100); + console.info(`setInterruptModeSync success`); + expect(false).assertTrue(); + } catch (err) { + console.error(`setInterruptModeSync error: ${err}`); + expect(err.code).assertEqual(ERROR_INVALID_PARAM); + } + done() + }) +}) diff --git a/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/AudioRendererJsUnitTest.js b/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/AudioRendererJsUnitTest.js new file mode 100644 index 0000000000000000000000000000000000000000..e129722a9ad5a34a008dc43da20dee046b053df9 --- /dev/null +++ b/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/AudioRendererJsUnitTest.js @@ -0,0 +1,352 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import audio from '@ohos.multimedia.audio'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +const TAG = "[AudioRendererJsUnitTest]"; + +describe("AudioRendererJsUnitTest", function() { + 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; + + beforeAll(async function () { + // input testsuit setup step, setup invoked before all testcases + try { + audioRenderer = audio.createAudioRendererSync(audioRendererOptions); + console.info(`${TAG}: AudioRenderer created SUCCESS, state: ${audioRenderer.state}`); + } catch (err) { + console.error(`${TAG}: AudioRenderer created ERROR: ${err.message}`); + } + console.info(TAG + 'beforeAll called') + }) + + afterAll(function () { + + // input testsuit teardown step, teardown invoked after all testcases + audioRenderer.release().then(() => { + console.info(`${TAG}: AudioRenderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TAG}: AudioRenderer release :ERROR : ${err.message}`); + }); + console.info(TAG + 'afterAll called') + }) + + beforeEach(function () { + + // input testcase setup step, setup invoked before each testcases + console.info(TAG + 'beforeEach called') + }) + + afterEach(function () { + + // input testcase teardown step, teardown invoked after each testcases + console.info(TAG + 'afterEach called') + }) + + /* + * @tc.name:SUB_AUDIO_CREATE_AUDIO_RENDERER_SYNC_001 + * @tc.desc:createAudioRendererSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_CREATE_AUDIO_RENDERER_SYNC_001", 0, async function (done) { + try { + let value = audio.createAudioRendererSync(audioRendererOptions); + console.info(`SUB_AUDIO_CREATE_AUDIO_RENDERER_SYNC_001 SUCCESS: ${value}.`); + expect(typeof value).assertEqual('object'); + done(); + } catch (err) { + console.error(`SUB_AUDIO_CREATE_AUDIO_RENDERER_SYNC_001 ERROR: ${err}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_STREAM_INFO_SYNC_TEST_001 + * @tc.desc:getStreamInfoSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_STREAM_INFO_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioRenderer.getStreamInfoSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_STREAM_INFO_SYNC_TEST_001 SUCCESS: ${data}`); + expect(data.samplingRate).assertEqual(audio.AudioSamplingRate.SAMPLE_RATE_48000); + expect(data.channels).assertEqual(audio.AudioChannel.CHANNEL_1); + expect(data.sampleFormat).assertEqual(audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE); + expect(data.encodingType).assertEqual(audio.AudioEncodingType.ENCODING_TYPE_RAW); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_STREAM_INFO_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_RENDERER_INFO_SYNC_TEST_001 + * @tc.desc:getRendererInfoSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_RENDERER_INFO_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioRenderer.getRendererInfoSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_RENDERER_INFO_SYNC_TEST_001 SUCCESS: ${data}`); + expect(data.content).assertEqual(audio.ContentType.CONTENT_TYPE_MUSIC); + expect(data.usage).assertEqual(audio.StreamUsage.STREAM_USAGE_MEDIA); + expect(data.rendererFlags).assertEqual(0); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_RENDERER_INFO_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_AUDIO_STREAM_ID_SYNC_TEST_001 + * @tc.desc:getAudioStreamIdSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_AUDIO_STREAM_ID_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioRenderer.getAudioStreamIdSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_AUDIO_STREAM_ID_SYNC_TEST_001 SUCCESS: ${data}`); + expect(typeof data).assertEqual('number'); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_AUDIO_STREAM_ID_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_BUFFER_SIZE_SYNC_TEST_001 + * @tc.desc:getBufferSizeSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_BUFFER_SIZE_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioRenderer.getBufferSizeSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_BUFFER_SIZE_SYNC_TEST_001 SUCCESS: ${data}`); + expect(typeof data).assertEqual('number'); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_BUFFER_SIZE_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_MIN_STREAM_VOLUME_SYNC_TEST_001 + * @tc.desc:getMinStreamVolumeSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_MIN_STREAM_VOLUME_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioRenderer.getMinStreamVolumeSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_MIN_STREAM_VOLUME_SYNC_TEST_001 SUCCESS: ${data}`); + expect(typeof data).assertEqual('number'); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_MIN_STREAM_VOLUME_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_MAX_STREAM_VOLUME_SYNC_TEST_001 + * @tc.desc:getMaxStreamVolumeSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_MAX_STREAM_VOLUME_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioRenderer.getMaxStreamVolumeSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_MAX_STREAM_VOLUME_SYNC_TEST_001 SUCCESS: ${data}`); + expect(typeof data).assertEqual('number'); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_MAX_STREAM_VOLUME_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_CURRENT_OUTPUT_DEVICES_SYNC_TEST_001 + * @tc.desc:getCurrentOutputDevicesSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_CURRENT_OUTPUT_DEVICES_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioRenderer.getCurrentOutputDevicesSync(); + console.info(`${TAG}: GET_CURRENT_OUTPUT_DEVICES_SYNC_TEST_001 SUCCESS: ${JSON.stringify(data)}`); + expect(data.length).assertLarger(0); + for (let i = 0; i < data.length; i++) { + expect(data[i].displayName!=="" && data[i].displayName!==undefined).assertTrue(); + } + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_CURRENT_OUTPUT_DEVICES_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_AUDIO_TIME_SYNC_TEST_001 + * @tc.desc:getAudioTimeSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_AUDIO_TIME_SYNC_TEST_001', 0, async function (done) { + try { + let audioRenderer = audio.createAudioRendererSync(audioRendererOptions); + let data = audioRenderer.getAudioTimeSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_AUDIO_TIME_SYNC_TEST_001 SUCCESS, before start: ${data}`); + expect(data).assertEqual(0); + + await audioRenderer.start(); + data = audioRenderer.getAudioTimeSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_AUDIO_TIME_SYNC_TEST_001 SUCCESS, after start: ${data}`); + expect(data).assertLarger(0); + + await audioRenderer.stop(); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_AUDIO_TIME_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_001 + * @tc.desc:getRenderRateSync success - RENDER_RATE_NORMAL + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_001', 0, async function (done) { + await audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(() => { + console.info('setRenderRate SUCCESS'); + try { + let data = audioRenderer.getRenderRateSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_001 SUCCESS: ${data}`); + expect(data).assertEqual(audio.AudioRendererRate.RENDER_RATE_NORMAL); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }).catch((err) => { + console.error(`setRenderRate ERROR: ${err}`); + }); + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_002 + * @tc.desc:getRenderRateSync success - RENDER_RATE_DOUBLE + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_002', 0, async function (done) { + await audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_DOUBLE).then(() => { + console.info('setRenderRate SUCCESS'); + try { + let data = audioRenderer.getRenderRateSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_002 SUCCESS: ${data}`); + expect(data).assertEqual(audio.AudioRendererRate.RENDER_RATE_DOUBLE); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_002 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }).catch((err) => { + console.error(`setRenderRate ERROR: ${err}`); + }); + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_003 + * @tc.desc:getRenderRateSync success - RENDER_RATE_DOUBLE + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_003', 0, async function (done) { + await audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_HALF).then(() => { + console.info('setRenderRate SUCCESS'); + try { + let data = audioRenderer.getRenderRateSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_003 SUCCESS: ${data}`); + expect(data).assertEqual(audio.AudioRendererRate.RENDER_RATE_HALF); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_RENDER_RATE_SYNC_TEST_003 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }).catch((err) => { + console.error(`setRenderRate ERROR: ${err}`); + }); + }) + + /* + * @tc.name:SUB_AUDIO_RENDERER_GET_UNDERFLOW_COUNT_SYNC_TEST_001 + * @tc.desc:getUnderflowCountSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it('SUB_AUDIO_RENDERER_GET_UNDERFLOW_COUNT_SYNC_TEST_001', 0, async function (done) { + try { + let data = audioRenderer.getUnderflowCountSync(); + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_UNDERFLOW_COUNT_SYNC_TEST_001 SUCCESS: ${data}`); + expect(typeof data).assertEqual('number'); + done(); + } catch (err) { + console.info(`${TAG}: SUB_AUDIO_RENDERER_GET_UNDERFLOW_COUNT_SYNC_TEST_001 ERROR: ${err.message}`); + expect(false).assertTrue(); + done(); + } + }) + +}) diff --git a/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/BUILD.gn b/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..329340f4a92af8e682321d55cda26372340768ff --- /dev/null +++ b/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2023 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("//build/test.gni") + +module_output_path = "multimedia_audio_framework/audio_renderer_js" + +ohos_js_unittest("AudioRendererJsUnitTest") { + module_out_path = module_output_path + + hap_profile = "./config.json" + certificate_profile = "./signature/openharmony_sx.p7b" +} + +group("jsunittest") { + testonly = true + deps = [ ":AudioRendererJsUnitTest" ] +} diff --git a/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/config.json b/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/config.json new file mode 100644 index 0000000000000000000000000000000000000000..f9ecd195bbeca922cf0a4f5fd9a6dc219aff3a91 --- /dev/null +++ b/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 8, + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication", + "name": ".MyApplication", + "deviceType": [ + "phone", + "tablet", + "2in1" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.myapplication.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "MyApplication", + "type": "page", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } + } \ No newline at end of file diff --git a/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/signature/openharmony_sx.p7b b/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..49d5a09221f14f3d260b279ac71c241802e9391f Binary files /dev/null and b/frameworks/js/napi/audio_renderer/test/unittest/audio_renderer_test/signature/openharmony_sx.p7b differ diff --git a/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/BUILD.gn b/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3940c155cdd541226313d17a89356de1183411b5 --- /dev/null +++ b/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2023 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("//build/test.gni") + +module_output_path = "multimedia_audio_framework/tone_player_js" + +ohos_js_unittest("TonePlayerJsUnitTest") { + module_out_path = module_output_path + + hap_profile = "./config.json" + certificate_profile = "./signature/openharmony_sx.p7b" +} + +group("jsunittest") { + testonly = true + deps = [ ":TonePlayerJsUnitTest" ] +} diff --git a/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/TonePlayerJsUnitTest.js b/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/TonePlayerJsUnitTest.js new file mode 100644 index 0000000000000000000000000000000000000000..db4a0a380705054e22c5b3bb8655128d71f61e8d --- /dev/null +++ b/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/TonePlayerJsUnitTest.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import audio from '@ohos.multimedia.audio'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + + +describe("TonePlayerJsUnitTest", function () { + let audioRendererInfo = { + content : audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage : audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags : 0 + } + + beforeAll(async function () { + + // input testsuit setup step,setup invoked before all testcases + console.info('beforeAll called') + }) + + afterAll(function () { + + // input testsuit teardown step,teardown invoked after all testcases + console.info('afterAll called') + }) + + beforeEach(function () { + + // input testcase setup step,setup invoked before each testcases + console.info('beforeEach called') + }) + + afterEach(function () { + + // input testcase teardown step,teardown invoked after each testcases + console.info('afterEach called') + }) + + /* + * @tc.name:SUB_AUDIO_CREATE_TONE_PLAYER_SYNC_001 + * @tc.desc:createTonePlayerSync success + * @tc.type: FUNC + * @tc.require: I7V04L + */ + it("SUB_AUDIO_CREATE_TONE_PLAYER_SYNC_001", 0, async function (done) { + try { + let value = audio.createTonePlayerSync(audioRendererInfo); + console.info(`SUB_AUDIO_CREATE_TONE_PLAYER_SYNC_001 SUCCESS: ${value}.`); + expect(typeof value).assertEqual('object'); + done(); + } catch (err) { + console.error(`SUB_AUDIO_CREATE_TONE_PLAYER_SYNC_001 ERROR: ${err}`); + expect(false).assertTrue(); + done(); + } + }) +}) \ No newline at end of file diff --git a/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/config.json b/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/config.json new file mode 100644 index 0000000000000000000000000000000000000000..f9ecd195bbeca922cf0a4f5fd9a6dc219aff3a91 --- /dev/null +++ b/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 8, + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication", + "name": ".MyApplication", + "deviceType": [ + "phone", + "tablet", + "2in1" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.myapplication.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "MyApplication", + "type": "page", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } + } \ No newline at end of file diff --git a/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/signature/openharmony_sx.p7b b/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..49d5a09221f14f3d260b279ac71c241802e9391f Binary files /dev/null and b/frameworks/js/napi/toneplayer/test/unittest/tone_player_test/signature/openharmony_sx.p7b differ