diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/BUILD.gn b/multimedia/audio/audio_js_standard/AudioCapturer/BUILD.gn index 7563ec8dd241c52eb903a01124fddce312be8bbd..d68e264a3ac2fcbec1bcba6dae106bb0d6a24099 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/BUILD.gn +++ b/multimedia/audio/audio_js_standard/AudioCapturer/BUILD.gn @@ -1,35 +1,35 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//test/xts/tools/build/suite.gni") - -ohos_js_hap_suite("audio_capturer_js_hap") { - hap_profile = "./src/main/config.json" - deps = [ - ":audio_capturer_js_assets", - ":audio_capturer_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsAudioCapturerJsTest" - subsystem_name = "multimedia" - part_name = "audio_framework" -} -ohos_js_assets("audio_capturer_js_assets") { - js2abc = true - hap_profile = "./src/main/config.json" - source_dir = "./src/main/js" -} -ohos_resources("audio_capturer_resources") { - sources = [ "./src/main/resources" ] - hap_profile = "./src/main/config.json" -} +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("audio_capturer_js_hap") { + hap_profile = "./src/main/config.json" + deps = [ + ":audio_capturer_js_assets", + ":audio_capturer_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAudioCapturerJsTest" + subsystem_name = "multimedia" + part_name = "audio_framework" +} +ohos_js_assets("audio_capturer_js_assets") { + js2abc = true + hap_profile = "./src/main/config.json" + source_dir = "./src/main/js" +} +ohos_resources("audio_capturer_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/Test.json b/multimedia/audio/audio_js_standard/AudioCapturer/Test.json index 535ea2ed41ef9190fd4932a5275b2af935254a2e..3586ff9137ed3992eaa949ce8480fa028dc310a2 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/Test.json +++ b/multimedia/audio/audio_js_standard/AudioCapturer/Test.json @@ -1,38 +1,41 @@ -{ - "description": "Configuration for audio manager Tests", - "driver": { - "type": "OHJSUnitTest", - "test-timeout": "1500000", - "testcase-timeout": "50000", - "bundle-name": "ohos.acts.multimedia.audio.audiocapturer", - "package-name": "ohos.acts.multimedia.audio.audiocapturer", - "shell-timeout": "60000" - }, - "kits": [ - { - "test-file-name": [ - "ActsAudioCapturerJsTest.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - }, - { - "type": "ShellKit", - "run-command": [ - "power-shell wakeup", - "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", - "power-shell setmode 602" - ], - "teardown-command":[ - "power-shell setmode 600" - ], - "cleanup-apps": true - }, - { - "type": "PushKit", - "pre-push": [], - "push": [ - ] - } - ] +{ + "description": "Configuration for audio manager Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "1500000", + "testcase-timeout": "50000", + "bundle-name": "ohos.acts.multimedia.audio.audiocapturer", + "package-name": "ohos.acts.multimedia.audio.audiocapturer", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAudioCapturerJsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "power-shell wakeup", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", + "power-shell setmode 602", + "mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.audio.audiocapturer/haps/entry/files", + "chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.audio.audiocapturer/haps/entry" + ], + "teardown-command":[ + "power-shell setmode 600" + ], + "cleanup-apps": true + }, + { + "type": "PushKit", + "pre-push": [], + "push": [ + "./resource/media/audioplayer/wav/pcm_48ksr_32kbr_2ch.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiocapturer/haps/entry/files/" + ] + } + ] } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/config.json b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/config.json index 6d7c6df4e1eb94ad3ee4281ad6137fbb2fc95412..6cc291f78422e0296254e5366869a97175e47504 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/config.json +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/config.json @@ -1,111 +1,111 @@ -{ - "app": { - "bundleName": "ohos.acts.multimedia.audio.audiocapturer", - "vendor": "example", - "version": { - "code": 1, - "name": "1.0" - }, - "apiVersion": { - "compatible": 5, - "target": 5, - "releaseType": "Beta1" - } - }, - "deviceConfig": {}, - "module": { - "package": "ohos.acts.multimedia.audio.audiocapturer", - "name": ".entry", - "deviceType": [ - "tablet", - "default", - "phone", - "2in1" - ], - "distro": { - "deliveryWithInstall": true, - "moduleName": "entry", - "moduleType": "entry" - }, - "reqPermissions": [ - { - "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", - "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" - }, - { - "name": "ohos.permission.MICROPHONE", - "reason": "use ohos.permission.MICROPHONE" - }, - { - "name": "ohos.permission.MANAGE_AUDIO_CONFIG", - "reason": "use ohos.permission.MANAGE_AUDIO_CONFIG" - } - ], - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "formsEnabled": false, - "name": ".MainAbility", - "srcLanguage": "js", - "srcPath": "MainAbility", - "icon": "$media:icon", - "description": "$string:MainAbility_desc", - "label": "$string:MainAbility_label", - "type": "page", - "visible": true, - "launchType": "standard" - }, - { - "orientation": "unspecified", - "formsEnabled": false, - "name": ".TestAbility", - "srcLanguage": "js", - "srcPath": "TestAbility", - "icon": "$media:icon", - "description": "$string:TestAbility_desc", - "label": "$string:TestAbility_label", - "type": "page", - "visible": true, - "launchType": "standard" - } - ], - "js": [ - { - "pages": [ - "pages/index/index" - ], - "name": "default", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - }, - { - "pages": [ - "pages/index/index" - ], - "name": ".TestAbility", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ], - "testRunner": { - "name": "OpenHarmonyTestRunner", - "srcPath": "TestRunner" - }, - "mainAbility": ".MainAbility", - "srcPath": "" - } +{ + "app": { + "bundleName": "ohos.acts.multimedia.audio.audiocapturer", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.multimedia.audio.audiocapturer", + "name": ".entry", + "deviceType": [ + "tablet", + "default", + "phone", + "2in1" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "reqPermissions": [ + { + "name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", + "reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS" + }, + { + "name": "ohos.permission.MICROPHONE", + "reason": "use ohos.permission.MICROPHONE" + }, + { + "name": "ohos.permission.MANAGE_AUDIO_CONFIG", + "reason": "use ohos.permission.MANAGE_AUDIO_CONFIG" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "js", + "srcPath": "MainAbility", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "label": "$string:MainAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + }, + { + "orientation": "unspecified", + "formsEnabled": false, + "name": ".TestAbility", + "srcLanguage": "js", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "pages": [ + "pages/index/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "testRunner": { + "name": "OpenHarmonyTestRunner", + "srcPath": "TestRunner" + }, + "mainAbility": ".MainAbility", + "srcPath": "" + } } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/app.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/app.js index 5b800cb12b0028e95ecb52e5684d1d336ae51e1c..8606ad5b597855ec8095ba3ebc0ba6df5d5efe8c 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/app.js +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/app.js @@ -1,22 +1,22 @@ -/* - * Copyright (c) 2022 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. - */ -export default { - onCreate() { - console.info("============== AceApplication onCreate =============="); - }, - onDestroy() { - console.info('=============AceApplication onDestroy============='); - } -}; +/* + * Copyright (c) 2022 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. + */ +export default { + onCreate() { + console.info("============== AceApplication onCreate =============="); + }, + onDestroy() { + console.info('=============AceApplication onDestroy============='); + } +}; diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/i18n/en-US.json b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/i18n/en-US.json index e63c70d978a3a53be988388c87182f81785e170c..a4c13dcbdc39c537073f638393d7726ac9a5cdc4 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/i18n/en-US.json +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/i18n/en-US.json @@ -1,6 +1,6 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } +{ + "strings": { + "hello": "Hello", + "world": "World" + } } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/i18n/zh-CN.json b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/i18n/zh-CN.json index de6ee5748322f44942c1b003319d8e66c837675f..b1c02368f72f929e4375a43170444de95dcc5984 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/i18n/zh-CN.json +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/i18n/zh-CN.json @@ -1,6 +1,6 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } +{ + "strings": { + "hello": "您好", + "world": "世界" + } } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.css b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.css index b6c4207e3d98d227f135ee57bfa49b98cfb93faf..4bc7e63ea5e31c4348c35c119629b7e5967e1cc1 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.css +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.css @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2022 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. - */ - -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} +/* + * Copyright (c) 2022 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. + */ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.hml b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.hml index 153d713d137f27cf989ffbaee2e886f92898056e..cce488f1b24747634323fdeb72cd088e4d5934fb 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.hml +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.hml @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2022 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. - */ - -
- - Hello, World! - {{ $t('strings.hello') }} {{ title }} - -
+/* + * Copyright (c) 2022 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. + */ + +
+ + Hello, World! + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.js index 329d972406d066b00b64da8a3d363b64f31367a9..845ed71224353adaf5cb090e74a5e6b2be8577b8 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.js +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/MainAbility/pages/index/index.js @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2022 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 file from '@system.file' - -const injectRef = Object.getPrototypeOf(global) || global -injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - }, - onReady() { - }, -} - +/* + * Copyright (c) 2022 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 file from '@system.file' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + }, + onReady() { + }, +} + diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/app.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/app.js index d5ee271df29e516d1c8929054283e5f2bf5c981c..cdc31f3dcf031e2f6a7665d9653e53bb649e21c5 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/app.js +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/app.js @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from '@ohos/hypium' -import testsuite from '../test/List.test' - -export default { - onCreate() { - console.info('TestApplication onCreate') - var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - }, - onDestroy() { - console.info("TestApplication onDestroy"); - } -}; +/* + * Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('TestApplication onCreate') + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info("TestApplication onDestroy"); + } +}; diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/i18n/en-US.json b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/i18n/en-US.json index 55561b83737c3c31d082fbfa11e5fc987a351104..3cb24b374b1d919ca8eac0638f361692b603a900 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/i18n/en-US.json +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/i18n/en-US.json @@ -1,8 +1,8 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - }, - "Files": { - } +{ + "strings": { + "hello": "Hello", + "world": "World" + }, + "Files": { + } } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/i18n/zh-CN.json b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/i18n/zh-CN.json index cce1af06761a42add0cac1a0567aa3237eda8cb4..c804e32c0c3103929baca5617cdac70be11fdba1 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/i18n/zh-CN.json +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/i18n/zh-CN.json @@ -1,8 +1,8 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - }, - "Files": { - } +{ + "strings": { + "hello": "您好", + "world": "世界" + }, + "Files": { + } } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.css b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.css index b21c92c6290ea747bd891e2ab673721afc5521ed..b1bcd43387ba131cc1d30975ff7508a6f8084a4b 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.css +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.css @@ -1,30 +1,30 @@ -.container { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - left: 0px; - top: 0px; - width: 100%; - height: 100%; -} - -.title { - font-size: 60px; - text-align: center; - width: 100%; - height: 40%; - margin: 10px; -} - -@media screen and (device-type: phone) and (orientation: landscape) { - .title { - font-size: 60px; - } -} - -@media screen and (device-type: tablet) and (orientation: landscape) { - .title { - font-size: 100px; - } +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.title { + font-size: 60px; + text-align: center; + width: 100%; + height: 40%; + margin: 10px; +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.hml b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.hml index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..f629c71a9be857db6cdf94149652a191b9b272ea 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.hml +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.hml @@ -1,5 +1,5 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
+
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.js index d94b75c085fa1c16a0b2721609b18c57a7295476..88b083a7f6b979019d6a2c5ad20b19c5fd43286b 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.js +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestAbility/pages/index/index.js @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2022 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. - */ - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - } -} - - - +/* + * Copyright (c) 2022 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. + */ + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + } +} + + + diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestRunner/OpenHarmonyTestRunner.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestRunner/OpenHarmonyTestRunner.js index b9e78ce7cf73f1ade6ba52a408a44e33f5430f0d..c5fa8620ca77d381f20b65a903b833e6e3378c97 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestRunner/OpenHarmonyTestRunner.js +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/TestRunner/OpenHarmonyTestRunner.js @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' - -function translateParamsToString(parameters) { - const keySet = new Set([ - '-s class', '-s notClass', '-s suite', '-s itName', - '-s level', '-s testType', '-s size', '-s timeout', - '-s package', '-s dryRun' - ]) - let targetParams = ''; - for (const key in parameters) { - if (keySet.has(key)) { - targetParams += ' ' + key + ' ' + parameters[key] - } - } - return targetParams.trim() -} - - export default { - onPrepare() { - console.info('OpenHarmonyTestRunner OnPrepare') - }, - onRun() { - console.log('OpenHarmonyTestRunner onRun run') - var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - - var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' - - var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName - cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) - var debug = abilityDelegatorArguments.parameters["-D"] - console.info('debug value : '+debug) - if (debug == 'true') - { - cmd += ' -D' - } - console.info('cmd : '+cmd) - abilityDelegator.executeShellCommand(cmd, (err, data) => { - console.info('executeShellCommand : err : ' + JSON.stringify(err)); - console.info('executeShellCommand : data : ' + data.stdResult); - console.info('executeShellCommand : data : ' + data.exitCode); - }) - } -}; +/* + * Copyright (c) 2022 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package', '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + + export default { + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + }, + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + console.info('debug value : '+debug) + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, (err, data) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + data.stdResult); + console.info('executeShellCommand : data : ' + data.exitCode); + }) + } +}; diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js index 86f81884fd977a51318c713d07e8a3111a2a6df7..263acbb1e9c05fa28944e8cd9c7155875f4ffe02 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturer.test.js @@ -1,3120 +1,3120 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http:// www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import audio from '@ohos.multimedia.audio'; -import fileio from '@ohos.fileio'; -import featureAbility from '@ohos.ability.featureAbility'; -import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; -import { UiDriver, BY } from '@ohos.UiTest' -export default function audioCapturer() { - - describe('audioCapturer', function () { - let Tag = 'AudioCpaturer'; - let dirPath; - let bufferSize; - const LE24 = -1; - const LE32 = -1; - let markReachState = 'unknow'; - let periodReachState = 'unknow'; - let events = require('events'); - const CREATE_EVENT = 'create'; - const START_EVENT = 'start'; - const GET_BUFFERSIZE_EVENT = 'get_buffersize'; - const READ_EVENT = 'read'; - const STOP_EVENT = 'stop'; - const RELEASE_EVENT = 'release'; - const STATE_CHANGE_EVENT = 'on_state_change'; - const MARK_REACH_EVENT = 'on_mark_reach'; - const OFF_MARK_REACH_EVENT = 'off_mark_reach' - const PERIODR_REACH_EVENT = 'on_period_reach'; - const OFF_PERIODR_REACH_EVENT = 'off_period_reach'; - const END_EVENT = 'end'; - const GET_AUDIOTIME_EVENT = 'getAudioTime'; - const GET_CAPTURERINFO_EVENT = 'getCapturerInfo'; - const GET_STREAMINFO_EVENT = 'getStreamInfo'; - const GET_AUDIOSCENE_EVENT = 'getAudioScene'; - const ERROR_EVENT = 'error'; - let eventEmitter = new events.EventEmitter(); - function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } - async function toNextStep(audioCap, steps, done) { - if (steps[0] == END_EVENT) { - await sleep(1000); - if (markReachState == 'success' || markReachState == 'invalid_failure') { - console.log(`${Tag} markReachState: ${JSON.stringify(markReachState)}`); - expect(true).assertTrue(); - } else if (markReachState == 'failure') { - expect(false).assertTrue(); - } - markReachState = 'unknow';//recover state - - if (periodReachState == 'success' || periodReachState == 'invalid_failure') { - console.log(`${Tag} periodReachState: ${JSON.stringify(periodReachState)}`); - expect(true).assertTrue(); - } else if (periodReachState == 'failure') { - expect(false).assertTrue(); - } - periodReachState = 'unknow'; - - console.info(`${Tag} case done!!`); - done(); - } else { - eventEmitter.emit(steps[0], audioCap, steps, done); - } - } - eventEmitter.on(CREATE_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(CREATE_EVENT)}`); - steps.shift(); - audio.createAudioCapturer(steps[0], (err, data) => { - console.log(`${Tag} enter createAudioCapturer`); - steps.shift(); - if (err && steps[0] == ERROR_EVENT) { - console.log(`${Tag} CREATE_EVENT error success`); - steps.shift(); - toNextStep(audioCap, steps, done); - } else if (err) { - console.log(`${Tag} create err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - steps = [END_EVENT]; - toNextStep(audioCap, steps, done); - } else { - console.log(`${Tag} create success`); - audioCap = data; - expect(audioCap.state).assertEqual(audio.AudioState.STATE_PREPARED); - toNextStep(audioCap, steps, done); - } - }); - }); - eventEmitter.on(START_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(START_EVENT)}`); - steps.shift(); - audioCap.start(async (err) => { - console.log(`${Tag} enter start`); - if (err && steps[0] == ERROR_EVENT) { - console.log(`${Tag} START_EVENT error success`); - steps.shift(); - toNextStep(audioCap, steps, done); - } else if (err) { - console.log(`${Tag} start err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - await releaseFun(audioCap, done); - } else { - console.log(`${Tag} start success`); - expect(audioCap.state).assertEqual(audio.AudioState.STATE_RUNNING); - toNextStep(audioCap, steps, done); - } - }); - }); - eventEmitter.on(GET_BUFFERSIZE_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(GET_BUFFERSIZE_EVENT)}`); - steps.shift(); - audioCap.getBufferSize(async (err, size) => { - console.log(`${Tag} enter getBufferSize`); - if (err && steps[0] == ERROR_EVENT) { - console.log(`${Tag} GET_BUFFERSIZE_EVENT error success`); - steps.shift(); - toNextStep(audioCap, steps, done); - } else if (err) { - console.log(`${Tag} start err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - await releaseFun(audioCap, done); - } else { - console.log(`${Tag} getBufferSize success`); - bufferSize = size; - console.log(`${Tag} bufferSize: ${JSON.stringify(bufferSize)}`); - toNextStep(audioCap, steps, done); - } - }); - }); - - eventEmitter.on(READ_EVENT, async (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(READ_EVENT)}`); - steps.shift(); - let fd = fileio.openSync(dirPath, 0o102, 0o777); - if (fd !== null) { - console.info(`${Tag} AudioFrameworkRecLog: file fd created`); - } - else { - console.info(`${Tag} AudioFrameworkRecLog: Capturer start : ERROR `); - expect(false).assertTrue(); - done(); - return; - } - - fd = fileio.openSync(dirPath, 0o2002, 0o666); - if (fd !== null) { - console.info(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode : PASS`); - } - else { - console.info(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); - expect(false).assertTrue(); - done(); - return; - } - let numBuffersToCapture = 45; - while (numBuffersToCapture) { - try { - await new Promise((resolve, reject) => { - audioCap.read(bufferSize, true, (err, buffer) => { - if (err) { - console.info(`${Tag} AudioFrameworkRecLog: Capturer release :ERROR : ${JSON.stringify(err.message)}`); - reject(err); - } else { - let number = fileio.writeSync(fd, buffer); - console.info(`${Tag} AudioFrameworkRecLog:BufferRecLog: data written: ${JSON.stringify(number)}`); - resolve(); - } - }); - }) - } catch (err) { - console.info(`${Tag} read err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - done(); - } - numBuffersToCapture--; - } - console.log(`${Tag} read success`); - toNextStep(audioCap, steps, done); - }); - - eventEmitter.on(STOP_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(STOP_EVENT)}`); - steps.shift(); - audioCap.stop(async (err) => { - console.log(`${Tag} enter stop`); - if (err && steps[0] == ERROR_EVENT) { - console.log(`${Tag} STOP_EVENT error success`); - steps.shift(); - toNextStep(audioCap, steps, done); - } else if (err) { - console.log(`${Tag} stop err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - await releaseFun(audioCap, done); - } else { - console.log(`${Tag} stop success`); - expect(audioCap.state).assertEqual(audio.AudioState.STATE_STOPPED); - toNextStep(audioCap, steps, done); - } - }); - }); - eventEmitter.on(RELEASE_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(RELEASE_EVENT)}`); - steps.shift(); - audioCap.release(async (err) => { - console.log(`${Tag} enter release`); - if (err && steps[0] == ERROR_EVENT) { - console.log(`${Tag} RELEASE_EVENT error success`); - steps.shift(); - toNextStep(audioCap, steps, done); - } else if (err) { - console.log(`${Tag} release err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - await releaseFun(audioCap, done); - return; - } else { - console.log(`${Tag} release success`); - expect(audioCap.state).assertEqual(audio.AudioState.STATE_RELEASED); - toNextStep(audioCap, steps, done); - } - }); - }); - eventEmitter.on(GET_AUDIOTIME_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(GET_AUDIOTIME_EVENT)}`); - steps.shift(); - audioCap.getAudioTime(async (err, audioTime) => { - console.log(`${Tag} enter getAudioTime`); - if (err && steps[0] == ERROR_EVENT) { - console.log(`${Tag} GET_AUDIOTIME_EVENT error success`); - steps.shift(); - toNextStep(audioCap, steps, done); - } else if (err) { - console.log(`${Tag} getAudioTime err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - await releaseFun(audioCap, done); - return; - } else { - console.log(`${Tag} getAudioTime success`); - expect(audioTime).assertLarger(0); - toNextStep(audioCap, steps, done); - } - }); - }); - eventEmitter.on(GET_CAPTURERINFO_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(GET_CAPTURERINFO_EVENT)}`); - steps.shift(); - audioCap.getCapturerInfo(async (err, audioParamsGet) => { - if (err && steps[0] == ERROR_EVENT) { - console.log(`${Tag} GET_CAPTURERINFO_EVENT error success`); - steps.shift(); - toNextStep(audioCap, steps, done); - } else if (err) { - console.log(`${Tag} getCapturerInfo err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - await releaseFun(audioCap, done); - return; - } else { - console.info(`${Tag} AudioFrameworkRecLog: Capturer CapturerInfo:`); - console.info(`${Tag} AudioFrameworkRecLog: Capturer SourceType: ${JSON.stringify(audioParamsGet.source)}`); - console.info(`${Tag} AudioFrameworkRecLog: Capturer capturerFlags: ${JSON.stringify(audioParamsGet.capturerFlags)}`); - toNextStep(audioCap, steps, done); - } - }); - }); - eventEmitter.on(GET_STREAMINFO_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(GET_STREAMINFO_EVENT)}`); - steps.shift(); - audioCap.getStreamInfo(async (err, audioParamsGet) => { - if (err && steps[0] == ERROR_EVENT) { - console.log(`${Tag} GET_STREAMINFO_EVENT error success`); - steps.shift(); - toNextStep(audioCap, steps, done); - } else if (err) { - console.log(`${Tag} getStreamInfo err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - await releaseFun(audioCap, done); - return; - } else { - console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:`); - console.info(`${Tag} AudioFrameworkRecLog: Capturer sampleFormat: ${JSON.stringify(audioParamsGet.sampleFormat)}`); - console.info(`${Tag} AudioFrameworkRecLog: Capturer samplingRate: ${JSON.stringify(audioParamsGet.samplingRate)}`); - console.info(`${Tag} AudioFrameworkRecLog: Capturer channels: ${JSON.stringify(audioParamsGet.channels)}`); - console.info(`${Tag} AudioFrameworkRecLog: Capturer encodingType: ${JSON.stringify(audioParamsGet.encodingType)}`); - toNextStep(audioCap, steps, done); - } - }); - }); - - eventEmitter.on(GET_AUDIOSCENE_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(GET_AUDIOSCENE_EVENT)}`); - steps.shift(); - AUDIOMANAGERREC.getAudioScene(async (err, getValue) => { - if (err && steps[0] == ERROR_EVENT) { - console.log(`${Tag} GET_AUDIOSCENE_EVENT error success`); - steps.shift(); - toNextStep(audioCap, steps, done); - } else if (err) { - console.log(`${Tag} getStreamInfo err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - await releaseFun(audioCap, done); - return; - } else { - console.info(`${Tag} AudioFrameworkRecLog: getAudioScene : Value : ${JSON.stringify(getValue)}`); - toNextStep(audioCap, steps, done); - } - }); - }); - - eventEmitter.on(STATE_CHANGE_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(STATE_CHANGE_EVENT)}`); - steps.shift(); - console.log(`${Tag} STATE_CHANGE_EVENT register success`); - audioCap.on('stateChange', (AudioState) => { - console.info(`${Tag} AudioCapturerLog: Changed State to : ${JSON.stringify(AudioState)}`); - switch (AudioState) { - case audio.AudioState.STATE_NEW: - console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------NEW--------------`); - console.info(`${Tag} AudioFrameworkTest: Audio State is : New`); - break; - case audio.AudioState.STATE_PREPARED: - console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------PREPARED--------------`); - console.info(`${Tag} AudioFrameworkTest: Audio State is : Prepared`); - break; - case audio.AudioState.STATE_RUNNING: - console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RUNNING--------------`); - console.info(`${Tag} AudioFrameworkTest: Audio State is : Running`); - break; - case audio.AudioState.STATE_STOPPED: - console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------STOPPED--------------`); - console.info(`${Tag} AudioFrameworkTest: Audio State is : stopped`); - break; - case audio.AudioState.STATE_RELEASED: - console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RELEASED--------------`); - console.info(`${Tag} AudioFrameworkTest: Audio State is : released`); - break; - default: - console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------INVALID--------------`); - console.info(`${Tag} AudioFrameworkTest: Audio State is : invalid`); - break; - } - }); - toNextStep(audioCap, steps, done); - }); - - eventEmitter.on(MARK_REACH_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(MARK_REACH_EVENT)}`); - steps.shift(); - let markReachParam = steps[0]; - steps.shift(); - try { - audioCap.on('markReach', markReachParam, (position) => { - console.log(`${Tag} position: ${JSON.stringify(position)}`); - console.log(`${Tag} markReachParam: ${JSON.stringify(markReachParam)}`); - if (position == markReachParam) { - markReachState = 'success' - console.info(`${Tag} AudioRenderLog: mark reached: ${JSON.stringify(position)}`); - } - }); - toNextStep(audioCap, steps, done); - } - catch (error) { - if (error.code == 401) { - markReachState = 'invalid_failure'; - toNextStep(audioCap, steps, done); - } else { - console.info("err" + error.code); - toNextStep(audioCap, steps, done); - } - } - }); - - eventEmitter.on(OFF_MARK_REACH_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(OFF_MARK_REACH_EVENT)}`); - steps.shift(); - audioCap.off('markReach'); - toNextStep(audioCap, steps, done); - }); - - eventEmitter.on(PERIODR_REACH_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(PERIODR_REACH_EVENT)}`); - steps.shift(); - let periodReachParam = steps[0]; - steps.shift(); - try { - audioCap.on('periodReach', periodReachParam, (position) => { - console.log(`${Tag} position: ${JSON.stringify(position)}`); - console.log(`${Tag} periodReachParam: ${JSON.stringify(periodReachParam)}`); - if (position == periodReachParam) { - periodReachState = 'success' - console.info(`${Tag} AudioRenderLog: mark reached: ${JSON.stringify(position)}`); - } - }); - toNextStep(audioCap, steps, done); - } - catch (error) { - if (error.code == 401) { - markReachState = 'invalid_failure'; - toNextStep(audioCap, steps, done); - } else { - console.info("err" + error.code); - toNextStep(audioCap, steps, done); - } - } - - }); - eventEmitter.on(OFF_PERIODR_REACH_EVENT, (audioCap, steps, done) => { - console.log(`${Tag} emit: ${JSON.stringify(OFF_PERIODR_REACH_EVENT)}`); - steps.shift(); - audioCap.off('periodReach'); - toNextStep(audioCap, steps, done); - }); - async function releaseFun(audioCap, done) { - try { - await audioCap.release(); - console.log(`${Tag} release success`); - done(); - } catch (err) { - console.log(`${Tag} release fail,err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - done(); - } - } - - async function getFd(fileName) { - let context = await featureAbility.getContext(); - await context.getFilesDir().then((data) => { - dirPath = data + '/' + fileName; - console.info(`${Tag} case2 dirPath is ${JSON.stringify(dirPath)}`); - }) - } - const AUDIOMANAGERREC = audio.getAudioManager(); - console.info(`${Tag} AudioFrameworkRecLog: Create AudioManger Object JS Framework`); - - async function getPermission() { - let permissions = ['ohos.permission.MICROPHONE']; - featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { - console.info("request success" + JSON.stringify(data)); - }) - } - async function driveFn() { - console.info(`come in driveFn`); - let driver = await UiDriver.create(); - console.info(`driver is ${JSON.stringify(driver)}`); - await sleep(100); - console.info(`UiDriver start`); - let button = await driver.findComponent(BY.text('允许')); - console.info(`button is ${JSON.stringify(button)}`); - await sleep(100); - await button.click(); - } - - beforeAll(async function () { - await getPermission(); - await driveFn(); - console.info('TestLog: Start Testing AudioFrameworkTest Interfaces'); - }) - - beforeEach(async function () { - console.info(`${Tag} AudioFrameworkTest: beforeEach: Prerequisites at the test case level`); - await sleep(1000); - }) - - afterEach(function () { - console.info(`${Tag} AudioFrameworkTest: afterEach: Test case-level clearance conditions`); - }) - - afterAll(function () { - console.info(`${Tag} AudioFrameworkTest: afterAll: Test suite-level cleanup condition`); - }) - - async function recPromise(AudioCapturerOptions, done) { - let audioCap; - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: success`); - } catch (err) { - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`); - LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; - LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; - let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; - if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { - done(); - return; - } - expect(false).assertTrue(); - done(); - return; - } - - try { - let audioParamsGet = await audioCap.getStreamInfo(); - if (audioParamsGet != undefined && audioParamsGet != null) { - console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:${JSON.stringify(audioParamsGet)}`); - } else { - console.info(`${Tag} AudioFrameworkRecLog: audioParamsGet are incorrect,is : ${JSON.stringify(audioParamsGet)}`); - expect(false).assertTrue(); - } - } catch (err) { - console.log(`${Tag} AudioFrameworkRecLog: getStreamInfo :ERROR: ${JSON.stringify(err.message)}`); - expect(false).assertTrue(); - } - - try { - let audioParamsGet = await audioCap.getCapturerInfo(); - if (audioParamsGet != undefined) { - console.info(`${Tag} AudioFrameworkRecLog: Capturer CapturerInfo: ${JSON.stringify(audioParamsGet)}`); - } else { - console.info(`${Tag} AudioFrameworkRecLog: audioParamsGet are incorrect , is : ${JSON.stringify(audioParamsGet)}`); - expect(false).assertTrue(); - } - } catch (err) { - console.log(`${Tag} AudioFrameworkRecLog: CapturerInfo :ERROR: ${JSON.stringify(err.message)}`); - expect(false).assertTrue(); - } - - try { - await audioCap.start(); - console.log(`${Tag} start ok`); - let bufferSize = await audioCap.getBufferSize(); - console.log(`${Tag} bufferSize: ${JSON.stringify(bufferSize)} , dirPath: ${JSON.stringify(dirPath)}`); - let fd = fileio.openSync(dirPath, 0o102, 0o777); - console.log(`${Tag} fd: ${JSON.stringify(fd)}`); - if (fd !== null) { - console.info(`${Tag} AudioFrameworkRecLog: file fd created`); - } - else { - console.info(`${Tag} AudioFrameworkRecLog: Capturer start : ERROR `); - expect(false).assertTrue(); - } - - fd = fileio.openSync(dirPath, 0o2002, 0o666); - console.log(`${Tag} fd-re: ${JSON.stringify(fd)}`); - if (fd !== null) { - console.info(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode :PASS`); - } - else { - console.info(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); - expect(false).assertTrue(); - } - - let numBuffersToCapture = 45; - while (numBuffersToCapture) { - console.info(`${Tag} AudioFrameworkRecLog: ---------READ BUFFER---------`); - let buffer = await audioCap.read(bufferSize, true); - console.info(`${Tag} AudioFrameworkRecLog: ---------WRITE BUFFER---------`); - let number = fileio.writeSync(fd, buffer); - console.info(`${Tag} AudioFrameworkRecLog:BufferRecLog: data written: ${JSON.stringify(number)}`); - numBuffersToCapture--; - } - console.log(`${Tag} read ok`); - await audioCap.stop(); - console.log(`${Tag} stop ok`); - } catch (err) { - console.log(`${Tag} start-read-stop err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - try { - await audioCap.release(); - console.log(`${Tag} release ok`); - } catch (err) { - console.log(`${Tag} release err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - } - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_PREPARED_STATE_0100 - *@tc.name : - *@tc.desc : createAudioCapturer callback - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 1 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_PREPARED_STATE_0100', 1, function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - console.log(`${Tag} AudioCapturerOptions= ${JSON.stringify(AudioCapturerOptions)}`); - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, RELEASE_EVENT, END_EVENT]; - console.log(`${Tag} mySteps= ${JSON.stringify(mySteps)}`); - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_RUNNING_STATE_0100 - *@tc.name : AudioCapturer-Check-STATE-RUNNING - *@tc.desc : AudioCapturer with state running - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 1 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_RUNNING_STATE_0100', 1, function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, START_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_STOPPED_STATE_0100 - *@tc.name : AudioCapturer-Check-STATE-STOPPED - *@tc.desc : AudioCapturer with state stopped - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 1 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_STOPPED_STATE_0100', 1, function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, START_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_GET_BUFFER_SIZE_0100 - *@tc.name : AudioCapturer-get_buffer_size - *@tc.desc : AudioCapturer with state stopped - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 1 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_GET_BUFFER_SIZE_0100', 1, function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, START_EVENT, GET_BUFFERSIZE_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_0100 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 1 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_0100', 1, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMOISE_PREPARED_STATE_0100 - *@tc.name : AudioCapturer-Check-STATE-PREPARED - *@tc.desc : AudioCapturer with state prepared - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMOISE_PREPARED_STATE_0100', 0, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCapPromise; - await audio.createAudioCapturer(AudioCapturerOptions).then(function (data) { - audioCapPromise = data; - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: success`); - expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_PREPARED); - expect(audioCapPromise.state).assertEqual(1); - }).catch((err) => { - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`); - expect(false).assertTrue(); - }); - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RUNNING_STATE_0100 - *@tc.name : AudioCapturer-Check-STATE-RUNNING - *@tc.desc : AudioCapturer with state running - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RUNNING_STATE_0100', 0, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCapPromise.start(); - expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RUNNING); - expect(audioCapPromise.state).assertEqual(2); - await audioCapPromise.release(); - } catch (err) { - console.log(`${Tag} err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_STOPPED_STATE_0100 - *@tc.name : AudioCapturer-Check-STATE-STOPPED - *@tc.desc : AudioCapturer with state stopped - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_STOPPED_STATE_0100', 2, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCapPromise.start(); - expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RUNNING); - await audioCapPromise.stop(); - expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_STOPPED); - expect(audioCapPromise.state).assertEqual(3); - await audioCapPromise.release() - } catch (err) { - console.log(`${Tag} err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RELEASED_STATE_0100 - *@tc.name : AudioCapturer-Check-STATE-RELEASED - *@tc.desc : AudioCapturer with state released - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RELEASED_STATE_0100', 2, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCapPromise.start(); - await audioCapPromise.stop(); - await audioCapPromise.release(); - expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RELEASED); - expect(audioCapPromise.state).assertEqual(4); - } catch (err) { - console.log(`${Tag} err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_BUFFER_SIZE_0100 - *@tc.name : AudioCapturer-get_buffer_size - *@tc.desc : AudioCapturer with state stopped - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_BUFFER_SIZE_0100', 2, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - } catch (err) { - console.log(`${Tag} createAudioCapturer err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - done(); - return; - } - try { - await audioCapPromise.start(); - expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RUNNING); - let bufferSize = await audioCapPromise.getBufferSize(); - console.info(`${Tag} AudioFrameworkRecLog: buffer size: ${JSON.stringify(bufferSize)}`); - } catch (err) { - console.log(`${Tag} start-getBufferSize err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - try { - await audioCapPromise.release(); - expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RELEASED); - } catch (err) { - console.log(`${Tag} release err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_READ_BUFFER_0100 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_READ_BUFFER_0100', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkpromisereadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - } catch (err) { - console.log(`${Tag} createAudioCapturer err : ${JSON.stringify(err)}`); - expect(false).assertTrue(); - done(); - return; - } - try { - await audioCapPromise.start(); - expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RUNNING); - bufferSize = await audioCapPromise.getBufferSize(); - console.info(`${Tag} AudioFrameworkRecLog: buffer size: ${JSON.stringify(bufferSize)}`); - } catch (err) { - console.log(`${Tag} start-getBufferSize err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - - let fd = fileio.openSync(dirPath, 0o102, 0o777); - if (fd !== null) { - console.info(`${Tag} AudioFrameworkRecLog: file fd created`); - } - else { - console.info(`${Tag} AudioFrameworkRecLog: Capturer start :ERROR :`); - expect(false).assertTrue(); - done(); - return; - } - - fd = fileio.openSync(dirPath, 0o2002, 0o666); - if (fd !== null) { - console.info(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode :PASS`); - } - else { - console.info(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); - expect(false).assertTrue(); - done(); - return; - } - - try { - let numBuffersToCapture = 45; - while (numBuffersToCapture) { - let buffer = await audioCapPromise.read(bufferSize, true); - console.info(`${Tag} AudioFrameworkRecLog: ---------AFTER PROMISE READ ---------`); - let number = fileio.writeSync(fd, buffer); - console.info(`${Tag} BufferRecLog: data written: ${JSON.stringify(number)}`); - numBuffersToCapture--; - } - } catch (err) { - console.info(`${Tag} AudioFrameworkRecLog: read err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - - try { - await audioCapPromise.release(); - expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RELEASED); - } catch (err) { - console.log(`${Tag} release err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_CB_0100 - *@tc.name : AudioCapturer-Set1-Media - *@tc.desc : AudioCapturer with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_CB_0100', 2, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - await getFd("capture_CB_js-44100-2C-16B.pcm"); - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, GET_AUDIOSCENE_EVENT, GET_STREAMINFO_EVENT, GET_CAPTURERINFO_EVENT, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_CB_ENUM_0100 - *@tc.name : AudioCapturer-Set1-Media - *@tc.desc : AudioCapturer with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_CB_ENUM_0100', 2, async function (done) { - - let AudioStreamInfo = { - samplingRate: 44100, - channels: 1, - sampleFormat: 1, - encodingType: 0 - } - let AudioCapturerInfo = { - source: 3, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - await getFd("capture_CB_js-44100-2C-16B.pcm"); - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, ERROR_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0100 - *@tc.name : AudioCapturer-Set1-Media - *@tc.desc : AudioCapturer with parameter set 7 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0100', 2, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_VOICE_COMMUNICATION, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - await getFd("capture_js-44100-2C-16B.pcm"); - await recPromise(AudioCapturerOptions, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0100 - *@tc.name : AudioCapturer-Set1-Media - *@tc.desc : AudioCapturer with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0100', 2, async function (done) { - let AudioStreamInfo = { - samplingRate: 44100, - channels: 1, - sampleFormat: 1, - encodingType: 0 - } - let AudioCapturerInfo = { - source: 0, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - await getFd("capture_js-44100-2C-16B.pcm"); - await recPromise(AudioCapturerOptions, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0200 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0200', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo44100 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions44100 = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - - await getFd("capture_js-44100-1C-16LE.pcm"); - await recPromise(audioCapturerOptions44100, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0200 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0200', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: 44100, - channels: 1, - sampleFormat: 1, - encodingType: 0, - }; - let audioCapturerInfo44100 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions44100 = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - - await getFd("capture_js-44100-1C-16LE.pcm"); - await recPromise(audioCapturerOptions44100, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0300 - *@tc.name : AudioRec-Set2 - *@tc.desc : record audio with parameter set 2 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0300', 2, async function (done) { - let audioStreamInfo96000 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_96000, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo96000 = { - source: audio.SourceType.SOURCE_TYPE_VOICE_RECOGNITION, - capturerFlags: 0 - } - let audioCapturerOptions96000 = { - streamInfo: audioStreamInfo96000, - capturerInfo: audioCapturerInfo96000, - } - - await getFd("capture_js-96000-1C-S24LE.pcm"); - await recPromise(audioCapturerOptions96000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0300 - *@tc.name : AudioRec-Set2 - *@tc.desc : record audio with parameter set 2 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0300', 2, async function (done) { - let audioStreamInfo96000 = { - samplingRate: 96000, - channels: 1, - sampleFormat: 2, - encodingType: 0, - }; - let audioCapturerInfo96000 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions96000 = { - streamInfo: audioStreamInfo96000, - capturerInfo: audioCapturerInfo96000, - } - - await getFd("capture_js-96000-1C-S24LE.pcm"); - await recPromise(audioCapturerOptions96000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0400 - *@tc.name : AudioRec-Set3 - *@tc.desc : record audio with parameter set 3 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0400', 2, async function (done) { - let audioStreamInfo48000 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo48000 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions48000 = { - streamInfo: audioStreamInfo48000, - capturerInfo: audioCapturerInfo48000, - } - - await getFd("capture_js-48000-2C-1S32LE.pcm"); - await recPromise(audioCapturerOptions48000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0400 - *@tc.name : AudioRec-Set3 - *@tc.desc : record audio with parameter set 3 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0400', 2, async function (done) { - let audioStreamInfo48000 = { - samplingRate: 48000, - channels: 2, - sampleFormat: 1, - encodingType: 0, - }; - let audioCapturerInfo48000 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions48000 = { - streamInfo: audioStreamInfo48000, - capturerInfo: audioCapturerInfo48000, - } - - await getFd("capture_js-48000-2C-1S32LE.pcm"); - await recPromise(audioCapturerOptions48000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0500 - *@tc.name : AudioRec-Set4 - *@tc.desc : record audio with parameter set 4 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0500', 2, async function (done) { - let audioStreamInfo8000 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_8000, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_U8, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo8000 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions8000 = { - streamInfo: audioStreamInfo8000, - capturerInfo: audioCapturerInfo8000, - } - - await getFd("capture_js-8000-1C-8B.pcm"); - await recPromise(audioCapturerOptions8000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0500 - *@tc.name : AudioRec-Set4 - *@tc.desc : record audio with parameter set 4 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0500', 2, async function (done) { - let audioStreamInfo8000 = { - samplingRate: 8000, - channels: 1, - sampleFormat: 0, - encodingType: 0, - }; - let audioCapturerInfo8000 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions8000 = { - streamInfo: audioStreamInfo8000, - capturerInfo: audioCapturerInfo8000, - } - - await getFd("capture_js-8000-1C-8B.pcm"); - await recPromise(audioCapturerOptions8000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0600 - *@tc.name : AudioRec-Set5 - *@tc.desc : record audio with parameter set 5 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0600', 2, async function (done) { - let audioStreamInfo11025 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_11025, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo11025 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions11025 = { - streamInfo: audioStreamInfo11025, - capturerInfo: audioCapturerInfo11025, - } - - await getFd("capture_js-11025-2C-16B.pcm"); - await recPromise(audioCapturerOptions11025, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0600 - *@tc.name : AudioRec-Set5 - *@tc.desc : record audio with parameter set 5 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0600', 2, async function (done) { - let audioStreamInfo11025 = { - samplingRate: 11025, - channels: 2, - sampleFormat: 1, - encodingType: 0, - }; - let audioCapturerInfo11025 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions11025 = { - streamInfo: audioStreamInfo11025, - capturerInfo: audioCapturerInfo11025, - } - - await getFd("capture_js-11025-2C-16B.pcm"); - await recPromise(audioCapturerOptions11025, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0700 - *@tc.name : AudioRec-Set6 - *@tc.desc : record audio with parameter set 6 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0700', 2, async function (done) { - let audioStreamInfo12000 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_12000, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo12000 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions12000 = { - streamInfo: audioStreamInfo12000, - capturerInfo: audioCapturerInfo12000, - } - - await getFd("capture_js-12000-1C-24B.pcm"); - await recPromise(audioCapturerOptions12000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0700 - *@tc.name : AudioRec-Set6 - *@tc.desc : record audio with parameter set 6 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0700', 2, async function (done) { - let audioStreamInfo12000 = { - samplingRate: 12000, - channels: 1, - sampleFormat: 2, - encodingType: 0 - }; - let audioCapturerInfo12000 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions12000 = { - streamInfo: audioStreamInfo12000, - capturerInfo: audioCapturerInfo12000, - } - - await getFd("capture_js-12000-1C-24B.pcm"); - await recPromise(audioCapturerOptions12000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0800 - *@tc.name : AudioRec-Set7 - *@tc.desc : record audio with parameter set 7 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0800', 2, async function (done) { - let audioStreamInfo16000 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_16000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo16000 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions16000 = { - streamInfo: audioStreamInfo16000, - capturerInfo: audioCapturerInfo16000, - } - - await getFd("capture_js-16000-2C-32B.pcm"); - await recPromise(audioCapturerOptions16000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0800 - *@tc.name : AudioRec-Set7 - *@tc.desc : record audio with parameter set 7 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0800', 2, async function (done) { - let audioStreamInfo16000 = { - samplingRate: 16000, - channels: 2, - sampleFormat: 3, - encodingType: 0, - }; - let audioCapturerInfo16000 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions16000 = { - streamInfo: audioStreamInfo16000, - capturerInfo: audioCapturerInfo16000, - } - - await getFd("capture_js-16000-2C-32B.pcm"); - await recPromise(audioCapturerOptions16000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0900 - *@tc.name : AudioRec-Set8 - *@tc.desc : record audio with parameter set 8 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0900', 2, async function (done) { - let audioStreamInfo22050 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_22050, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_U8, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo22050 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions22050 = { - streamInfo: audioStreamInfo22050, - capturerInfo: audioCapturerInfo22050, - } - - await getFd("capture_js-22050-1C-8B.pcm"); - await recPromise(audioCapturerOptions22050, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0900 - *@tc.name : AudioRec-Set8 - *@tc.desc : record audio with parameter set 8 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0900', 2, async function (done) { - let audioStreamInfo22050 = { - samplingRate: 22050, - channels: 1, - sampleFormat: 0, - encodingType: 0, - }; - let audioCapturerInfo22050 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions22050 = { - streamInfo: audioStreamInfo22050, - capturerInfo: audioCapturerInfo22050, - } - - await getFd("capture_js-22050-1C-8B.pcm"); - await recPromise(audioCapturerOptions22050, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1000 - *@tc.name : AudioRec-Set9 - *@tc.desc : record audio with parameter set 9 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1000', 2, async function (done) { - let audioStreamInfo24000 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_24000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo24000 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions24000 = { - streamInfo: audioStreamInfo24000, - capturerInfo: audioCapturerInfo24000, - } - - await getFd("capture_js-24000-2C-16B.pcm"); - await recPromise(audioCapturerOptions24000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1000 - *@tc.name : AudioRec-Set9 - *@tc.desc : record audio with parameter set 9 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1000', 2, async function (done) { - let audioStreamInfo24000 = { - samplingRate: 24000, - channels: 2, - sampleFormat: 1, - encodingType: 0, - }; - let audioCapturerInfo24000 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions24000 = { - streamInfo: audioStreamInfo24000, - capturerInfo: audioCapturerInfo24000, - } - - await getFd("capture_js-24000-2C-16B.pcm"); - await recPromise(audioCapturerOptions24000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1100 - *@tc.name : AudioRec-Set10 - *@tc.desc : record audio with parameter set 010 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1100', 2, async function (done) { - let audioStreamInfo32000 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_32000, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo32000 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions32000 = { - streamInfo: audioStreamInfo32000, - capturerInfo: audioCapturerInfo32000, - } - - await getFd("capture_js-32000-1C-24B.pcm"); - await recPromise(audioCapturerOptions32000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1100 - *@tc.name : AudioRec-Set10 - *@tc.desc : record audio with parameter set 010 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1100', 2, async function (done) { - let audioStreamInfo32000 = { - samplingRate: 32000, - channels: 1, - sampleFormat: 2, - encodingType: 0, - }; - let audioCapturerInfo32000 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions32000 = { - streamInfo: audioStreamInfo32000, - capturerInfo: audioCapturerInfo32000, - } - - await getFd("capture_js-32000-1C-24B.pcm"); - await recPromise(audioCapturerOptions32000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1200 - *@tc.name : AudioRec-Set11 - *@tc.desc : record audio with parameter set 011 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1200', 2, async function (done) { - let audioStreamInfo64000 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_64000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo64000 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions64000 = { - streamInfo: audioStreamInfo64000, - capturerInfo: audioCapturerInfo64000, - } - - await getFd("capture_js-64000-2C-32B.pcm"); - await recPromise(audioCapturerOptions64000, done); - }) - - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1200 - *@tc.name : AudioRec-Set11 - *@tc.desc : record audio with parameter set 011 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1200', 2, async function (done) { - let audioStreamInfo64000 = { - samplingRate: 64000, - channels: 2, - sampleFormat: 3, - encodingType: 0, - }; - let audioCapturerInfo64000 = { - source: 0, - capturerFlags: 0 - } - let audioCapturerOptions64000 = { - streamInfo: audioStreamInfo64000, - capturerInfo: audioCapturerInfo64000, - } - - await getFd("capture_js-64000-2C-32B.pcm"); - await recPromise(audioCapturerOptions64000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1300 - *@tc.name : AudioRec-Set11 , SourceType set SOURCE_TYPE_VOICE_RECOGNITION - *@tc.desc : record audio with parameter set 011 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1300', 2, async function (done) { - let audioStreamInfo64000 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_64000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo64000 = { - source: audio.SourceType.SOURCE_TYPE_VOICE_RECOGNITION, - capturerFlags: 0 - } - let audioCapturerOptions64000 = { - streamInfo: audioStreamInfo64000, - capturerInfo: audioCapturerInfo64000, - } - - await getFd("capture_js-64000-2C-32B.pcm"); - await recPromise(audioCapturerOptions64000, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_RECORD_PROMISE_AUDIO_SCENE_DEFAULT_0100 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_RECORD_PROMISE_AUDIO_SCENE_DEFAULT_0100', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo44100 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions44100 = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - - await getFd("capture_js-44100-1C-16LE.pcm"); - await recPromise(audioCapturerOptions44100, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_RECORD_PROMISE_AUDIO_SCENE_DEFAULT_ENUM_0100 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_RECORD_PROMISE_AUDIO_SCENE_DEFAULT_ENUM_0100', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, - }; - let audioCapturerInfo44100 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let audioCapturerOptions44100 = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - - await getFd("capture_js-44100-1C-16LE.pcm"); - await recPromise(audioCapturerOptions44100, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_START_0100 - *@tc.name : AudioCapturer-GET_AUDIO_TIME - *@tc.desc : AudioCapturer GET_AUDIO_TIME - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_START_0100', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, START_EVENT, GET_AUDIOTIME_EVENT, GET_AUDIOTIME_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_READ_WRITE_0100 - *@tc.name : AudioCapturer-GET_AUDIO_TIME - *@tc.desc : AudioCapturer GET_AUDIO_TIME - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_READ_WRITE_0100', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - console.log(`${Tag} createAudioCapturer ok`); - } catch (err) { - console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - return done(); - } - - try { - await audioCapPromise.start(); - console.log(`${Tag} start ok`); - let audioTime = await audioCapPromise.getAudioTime(); - console.log(`${Tag} audioTime: ${JSON.stringify(audioTime)}`); - expect(audioTime).assertLarger(0); - - let bufferSize = await audioCapPromise.getBufferSize(); - console.log(`${Tag} AudioFrameworkRecLog: buffer size: ${JSON.stringify(bufferSize)}`); - let fd = fileio.openSync(dirPath, 0o102, 0o777); - console.log(`${Tag} fd: ${JSON.stringify(fd)}`); - if (fd !== null) { - console.log(`${Tag} AudioFrameworkRecLog: file fd created`); - } else { - console.log(`${Tag} AudioFrameworkRecLog: Capturer start :ERROR :`); - expect(false).assertTrue(); - done(); - return; - } - - fd = fileio.openSync(dirPath, 0o2002, 0o666); - console.log(`${Tag} fd1: ${JSON.stringify(fd)}`); - if (fd !== null) { - console.log(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode :PASS`); - } else { - console.log(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); - expect(false).assertTrue(); - done(); - return; - } - let numBuffersToCapture = 45; - while (numBuffersToCapture) { - let buffer = await audioCapPromise.read(bufferSize, true); - let audioTime1 = await audioCapPromise.getAudioTime(); - console.log(`${Tag} audioTime1: ${JSON.stringify(audioTime1)}`); - expect(audioTime1).assertLarger(0); - let number = fileio.writeSync(fd, buffer); - console.info(`${Tag} AudioFrameworkRecLog:BufferRecLog: data written: ${JSON.stringify(number)}`); - numBuffersToCapture--; - } - - let audioTime2 = await audioCapPromise.getAudioTime(); - console.log(`${Tag} audioTime2: ${JSON.stringify(audioTime2)}`); - expect(audioTime2).assertLarger(0); - } catch (err) { - console.log(`${Tag} start-getAudioTime-getBufferSize-read-getAudioTimein- err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - - try { - await audioCapPromise.release(); - } catch (err) { - console.log(`${Tag} err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_STOP_0100 - *@tc.name : AudioCapturer-GET_AUDIO_TIME - *@tc.desc : AudioCapturer GET_AUDIO_TIME - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_STOP_0100', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - console.log(`${Tag} createAudioCapturer ok`); - } catch (err) { - console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - return done(); - } - - try { - await audioCapPromise.start(); - console.log(`${Tag} start ok`); - let audioTime = await audioCapPromise.getAudioTime(); - console.log(`${Tag} audioTime: ${JSON.stringify(audioTime)}`); - expect(audioTime).assertLarger(0); - - let bufferSize = await audioCapPromise.getBufferSize(); - console.log(`${Tag} AudioFrameworkRecLog: buffer size: ${JSON.stringify(bufferSize)}`); - let fd = fileio.openSync(dirPath, 0o102, 0o777); - console.log(`${Tag} fd: ${JSON.stringify(fd)}`); - if (fd !== null) { - console.log(`${Tag} AudioFrameworkRecLog: file fd created`); - } - else { - console.log(`${Tag} AudioFrameworkRecLog: Capturer start :ERROR :`); - expect(false).assertTrue(); - done(); - return; - } - - fd = fileio.openSync(dirPath, 0o2002, 0o666); - console.log(`${Tag} fd1: ${JSON.stringify(fd)}`); - if (fd !== null) { - console.log(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode :PASS`); - } - else { - console.log(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); - expect(false).assertTrue(); - done(); - return; - } - let numBuffersToCapture = 45; - while (numBuffersToCapture) { - let buffer = await audioCapPromise.read(bufferSize, true); - let audioTime1 = await audioCapPromise.getAudioTime(); - console.log(`${Tag} audioTime1: ${JSON.stringify(audioTime1)}`); - expect(audioTime1).assertLarger(0); - let number = fileio.writeSync(fd, buffer); - console.info(`${Tag} AudioFrameworkRecLog:BufferRecLog: data written: ${JSON.stringify(number)}`); - numBuffersToCapture--; - } - } catch (err) { - console.log(`${Tag} start-getAudioTime-getBufferSize-read-getAudioTimein- err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - try { - await audioCapPromise.stop(); - let audioTime2 = await audioCapPromise.getAudioTime(); - console.log(`${Tag} audioTime2: ${JSON.stringify(audioTime2)}`); - expect(audioTime2).assertLarger(0); - } catch (err) { - console.log(`${Tag} stop-getAudioTimein- err: ${JSON.stringify(err)}`); - expect(true).assertTrue(); - } - - try { - await audioCapPromise.release(); - } catch (err) { - console.log(`${Tag} err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_GET_AUDIO_TIME_0100 - *@tc.name : AudioCapturer-GET_AUDIO_TIME - *@tc.desc : AudioCapturer GET_AUDIO_TIME - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_GET_AUDIO_TIME_0100', 2, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - } catch (err) { - console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - return done(); - } - try { - await audioCapPromise.start(); - let audioTime = await audioCapPromise.getAudioTime(); - console.log(`${Tag} audioTime: ${JSON.stringify(audioTime)}`) - expect(audioTime).assertLarger(0); - } catch (err) { - console.log(`${Tag} start-getAudioTime err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - try { - await audioCapPromise.release(); - } catch (err) { - console.log(`${Tag} err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_STOP_BEFORE_START_0100 - *@tc.name : AudioCapturer-GET_AUDIO_TIME - *@tc.desc : AudioCapturer createAudioCapturer->stop->release - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_STOP_BEFORE_START_0100', 2, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - console.log(`${Tag} createAudioCapturer ok`); - } catch (err) { - console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - return done(); - } - - try { - await audioCapPromise.start(); - console.log(`${Tag} start ok`); - } catch (err) { - console.log(`${Tag} start err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - try { - await audioCapPromise.stop(); - console.log(`${Tag} stop ok`); - expect(true).assertTrue(); - } catch (err) { - console.log(`${Tag} stop err: ${JSON.stringify(err)}`); - expect(true).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RELEASE_BEFORE_START_0100 - *@tc.name : AudioCapturer-GET_AUDIO_TIME - *@tc.desc : AudioCapturer GET_AUDIO_TIME - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RELEASE_BEFORE_START_0100', 2, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - } catch (err) { - console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - return done(); - } - - try { - await audioCapPromise.release(); - expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RELEASED); - } catch (err) { - console.log(`${Tag} release err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - try { - await audioCapPromise.release(); - } catch (err) { - console.log(`${Tag} re-release err: ${JSON.stringify(err)}`); - expect(true).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_STREAM_INFO_0100 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_STREAM_INFO_0100', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioCapturerInfo44100 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - - let audioCap; - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - } catch (err) { - console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - return done(); - } - - try { - let audioParamsGet = await audioCap.getStreamInfo(); - console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:${JSON.stringify(audioParamsGet)}`); - } catch (err) { - console.log(`${Tag} getStreamInfo err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - - try { - await audioCap.release(); - } catch (err) { - console.log(`${Tag} release err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_STREAM_INFO_ENUM_0100 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_STREAM_INFO_ENUM_0100', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: 44100, - channels: 1, - sampleFormat: 1, - encodingType: 0, - }; - let audioCapturerInfo44100 = { - source: 0, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - - let audioCap; - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - } catch (err) { - console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - return done(); - } - - try { - let audioParamsGet = await audioCap.getStreamInfo(); - console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:${JSON.stringify(audioParamsGet)}`); - } catch (err) { - console.log(`${Tag} getStreamInfo err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - - try { - await audioCap.release(); - } catch (err) { - console.log(`${Tag} release err: ${JSON.stringify(err)}`); - console.log(`${Tag} audioCap.state: ${JSON.stringify(audioCap.state)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_CB_VOICE_CHAT_GET_STREAM_INFO_0200 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_REC_CB_VOICE_CHAT_GET_STREAM_INFO_0200', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let audioCapturerInfo44100 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - - let audioCap; - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - } catch (err) { - console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - return done(); - } - - try { - let audioParamsGet = await audioCap.getStreamInfo(); - console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:${JSON.stringify(audioParamsGet)}`); - } catch (err) { - console.log(`${Tag} getStreamInfo err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - - audioCap.release((err) => { - if (err) { - console.log(`${Tag} release err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - done(); - return; - } - expect(audioCap.state).assertEqual(audio.AudioState.STATE_RELEASED); - done(); - }) - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_CAPTURER_INFO_0300 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_CAPTURER_INFO_0300', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioCapturerInfo44100 = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - - let audioCap; - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - } catch (err) { - console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - return done(); - } - - try { - let audioParamsGet = await audioCap.getCapturerInfo(); - console.info(`${Tag} AudioFrameworkRecLog: Capturer CapturerInfo: ${JSON.stringify(audioParamsGet)}`); - } catch (err) { - console.log(`${Tag} getStreamInfo err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - - try { - await audioCap.release(); - } catch (err) { - console.log(`${Tag} release err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_CAPTURER_INFO_ENUM_0300 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_CAPTURER_INFO_ENUM_0300', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: 44100, - channels: 1, - sampleFormat: 1, - encodingType: 0, - }; - let audioCapturerInfo44100 = { - source: 0, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - - let audioCap; - try { - audioCap = await audio.createAudioCapturer(AudioCapturerOptions); - } catch (err) { - console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - return done(); - } - - try { - let audioParamsGet = await audioCap.getCapturerInfo(); - console.info(`${Tag} AudioFrameworkRecLog: Capturer CapturerInfo: ${JSON.stringify(audioParamsGet)}`); - } catch (err) { - console.log(`${Tag} getStreamInfo err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - - try { - await audioCap.release(); - } catch (err) { - console.log(`${Tag} release err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_VOICE_CHAT_PR_ENUM_AUDIO_STREAM_INFO_INVALID_0100 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_REC_VOICE_CHAT_PR_ENUM_AUDIO_STREAM_INFO_INVALID_0100', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: 0, - channels: 1, - sampleFormat: 1, - encodingType: 0, - }; - let audioCapturerInfo44100 = { - source: 0, - capturerFlags: 0 - } - let AudioCapturerOptionsInvalid = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(function (data) { - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success: ${JSON.stringify(data)}`); - expect(false).assertTrue(); - }).catch((err) => { - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`); - expect(true).assertTrue(); - }); - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_VOICE_CHAT_PR_ENUM_AUDIO_CAPTURER_INFO_INVALID_0100 - *@tc.name : AudioRec-Set1 - *@tc.desc : record audio with parameter set 1 - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_REC_VOICE_CHAT_PR_ENUM_AUDIO_CAPTURER_INFO_INVALID_0100', 2, async function (done) { - let audioStreamInfo44100 = { - samplingRate: 44100, - channels: 1, - sampleFormat: 1, - encodingType: 0, - }; - let audioCapturerInfo44100 = { - source: 1000, - capturerFlags: 0 - } - let AudioCapturerOptionsInvalid = { - streamInfo: audioStreamInfo44100, - capturerInfo: audioCapturerInfo44100, - } - - await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(function (data) { - if (data == undefined) { - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Unsuccess : ${JSON.stringify(data)}`); - expect(true).assertTrue(); - } else { - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success: ${JSON.stringify(data)}`); - expect(false).assertTrue(); - } - - }).catch((err) => { - console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`); - expect(true).assertTrue(); - }); - done(); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0100 - *@tc.name : AudioCapturer-Check-STATE-STOPPED - *@tc.desc : AudioCapturer with state stopped - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0100', 2, function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, STATE_CHANGE_EVENT, START_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0200 - *@tc.name : AudioCapturer-Check-STATE-STOPPED - *@tc.desc : AudioCapturer with state stopped - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0200', 2, function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, STATE_CHANGE_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0300 - *@tc.name : AudioCapturer-Check-STATE-STOPPED - *@tc.desc : AudioCapturer with state stopped - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0300', 2, function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, STATE_CHANGE_EVENT, START_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0400 - *@tc.name : AudioCapturer-Check-STATE-STOPPED - *@tc.desc : AudioCapturer with state stopped - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0400', 2, function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, STATE_CHANGE_EVENT, START_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0100 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0100', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let markReachParam = 5000; - markReachState = 'failure'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0200 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0200', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let markReachParam = 1000; - markReachState = 'failure'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0300 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0300', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let markReachParam = 10000; - markReachState = 'failure'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0400 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0400', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let markReachParam = 100; - markReachState = 'failure'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0500 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0500', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let markReachParam = 1; - markReachState = 'failure'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0600 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0600', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let markReachParam = 0; - markReachState = 'fail'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0700 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0700', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let markReachParam = 1234567890; - markReachState = 'invalid_failure'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0800 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0800', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let markReachParam = -2; - markReachState = 'fail'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0100 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0100', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let periodReachParam = 1000; - periodReachState = 'failure'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, PERIODR_REACH_EVENT, periodReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_PERIODR_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0200 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0200', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let periodReachParam = 1; - periodReachState = 'failure'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, PERIODR_REACH_EVENT, periodReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_PERIODR_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0300 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0300', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let periodReachParam = -2; - periodReachState = 'fail'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, PERIODR_REACH_EVENT, periodReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_PERIODR_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0400 - *@tc.name : AudioCapturer-Check-READ_BUFFER - *@tc.desc : AudioCapturer with read buffer - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0400', 2, async function (done) { - await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - - let audioCap = null; - let periodReachParam = 223750; - periodReachState = 'invalid_failure'; - let mySteps = [CREATE_EVENT, AudioCapturerOptions, PERIODR_REACH_EVENT, periodReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_PERIODR_REACH_EVENT, RELEASE_EVENT, END_EVENT]; - eventEmitter.emit(mySteps[0], audioCap, mySteps, done); - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0100 - *@tc.name : AudioCapturer - getAudioStreamId - *@tc.desc : AudioCapturer - getAudioStreamId - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0100', 0, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - let audioCapPromise; - try { - audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCapPromise.getAudioStreamId((err, data) => { - if (err) { - console.info(`${Tag}: getAudioStreamId : ERROR : code: ${err.code}, mesage: ${err.message}`); - expect(false).assertTrue(); - } else { - expect(true).assertTrue(); - console.info(`${Tag}: getAudioStreamId : Converted: ${data}`); - } - }); - await audioCapPromise.release(); - } catch (err) { - console.log(`${Tag} err: ${JSON.stringify(err)}`); - expect(false).assertTrue(); - } - done(); - }) - - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0200 - *@tc.name : AudioCapturer - getAudioStreamId - *@tc.desc : AudioCapturer - getAudioStreamId - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0200', 0, async function (done) { - let AudioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - let AudioCapturerInfo = { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0 - } - let AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - try { - let audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); - await audioCapPromise.getAudioStreamId().then((data) => { - expect(true).assertTrue(); - console.info(`${Tag}: getAudioStreamId : Converted: ${data}`); - }).catch((err) => { - expect(true).assertTrue(); - console.error(`${Tag}: getAudioStreamId : ERROR : ${err}`); - }); - - await audioCapPromise.release(); - } catch (err) { - console.log(`${Tag} error code: ${err.code} ,message:${err.message}`); - expect(false).assertTrue(); - } - done(); - }) - }) +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http:// www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import audio from '@ohos.multimedia.audio'; +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; +import { UiDriver, BY } from '@ohos.UiTest' +export default function audioCapturer() { + + describe('audioCapturer', function () { + let Tag = 'AudioCpaturer'; + let dirPath; + let bufferSize; + const LE24 = -1; + const LE32 = -1; + let markReachState = 'unknow'; + let periodReachState = 'unknow'; + let events = require('events'); + const CREATE_EVENT = 'create'; + const START_EVENT = 'start'; + const GET_BUFFERSIZE_EVENT = 'get_buffersize'; + const READ_EVENT = 'read'; + const STOP_EVENT = 'stop'; + const RELEASE_EVENT = 'release'; + const STATE_CHANGE_EVENT = 'on_state_change'; + const MARK_REACH_EVENT = 'on_mark_reach'; + const OFF_MARK_REACH_EVENT = 'off_mark_reach' + const PERIODR_REACH_EVENT = 'on_period_reach'; + const OFF_PERIODR_REACH_EVENT = 'off_period_reach'; + const END_EVENT = 'end'; + const GET_AUDIOTIME_EVENT = 'getAudioTime'; + const GET_CAPTURERINFO_EVENT = 'getCapturerInfo'; + const GET_STREAMINFO_EVENT = 'getStreamInfo'; + const GET_AUDIOSCENE_EVENT = 'getAudioScene'; + const ERROR_EVENT = 'error'; + let eventEmitter = new events.EventEmitter(); + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + async function toNextStep(audioCap, steps, done) { + if (steps[0] == END_EVENT) { + await sleep(1000); + if (markReachState == 'success' || markReachState == 'invalid_failure') { + console.log(`${Tag} markReachState: ${JSON.stringify(markReachState)}`); + expect(true).assertTrue(); + } else if (markReachState == 'failure') { + expect(false).assertTrue(); + } + markReachState = 'unknow';//recover state + + if (periodReachState == 'success' || periodReachState == 'invalid_failure') { + console.log(`${Tag} periodReachState: ${JSON.stringify(periodReachState)}`); + expect(true).assertTrue(); + } else if (periodReachState == 'failure') { + expect(false).assertTrue(); + } + periodReachState = 'unknow'; + + console.info(`${Tag} case done!!`); + done(); + } else { + eventEmitter.emit(steps[0], audioCap, steps, done); + } + } + eventEmitter.on(CREATE_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(CREATE_EVENT)}`); + steps.shift(); + audio.createAudioCapturer(steps[0], (err, data) => { + console.log(`${Tag} enter createAudioCapturer`); + steps.shift(); + if (err && steps[0] == ERROR_EVENT) { + console.log(`${Tag} CREATE_EVENT error success`); + steps.shift(); + toNextStep(audioCap, steps, done); + } else if (err) { + console.log(`${Tag} create err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + steps = [END_EVENT]; + toNextStep(audioCap, steps, done); + } else { + console.log(`${Tag} create success`); + audioCap = data; + expect(audioCap.state).assertEqual(audio.AudioState.STATE_PREPARED); + toNextStep(audioCap, steps, done); + } + }); + }); + eventEmitter.on(START_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(START_EVENT)}`); + steps.shift(); + audioCap.start(async (err) => { + console.log(`${Tag} enter start`); + if (err && steps[0] == ERROR_EVENT) { + console.log(`${Tag} START_EVENT error success`); + steps.shift(); + toNextStep(audioCap, steps, done); + } else if (err) { + console.log(`${Tag} start err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + await releaseFun(audioCap, done); + } else { + console.log(`${Tag} start success`); + expect(audioCap.state).assertEqual(audio.AudioState.STATE_RUNNING); + toNextStep(audioCap, steps, done); + } + }); + }); + eventEmitter.on(GET_BUFFERSIZE_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(GET_BUFFERSIZE_EVENT)}`); + steps.shift(); + audioCap.getBufferSize(async (err, size) => { + console.log(`${Tag} enter getBufferSize`); + if (err && steps[0] == ERROR_EVENT) { + console.log(`${Tag} GET_BUFFERSIZE_EVENT error success`); + steps.shift(); + toNextStep(audioCap, steps, done); + } else if (err) { + console.log(`${Tag} start err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + await releaseFun(audioCap, done); + } else { + console.log(`${Tag} getBufferSize success`); + bufferSize = size; + console.log(`${Tag} bufferSize: ${JSON.stringify(bufferSize)}`); + toNextStep(audioCap, steps, done); + } + }); + }); + + eventEmitter.on(READ_EVENT, async (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(READ_EVENT)}`); + steps.shift(); + let fd = fileio.openSync(dirPath, 0o102, 0o777); + if (fd !== null) { + console.info(`${Tag} AudioFrameworkRecLog: file fd created`); + } + else { + console.info(`${Tag} AudioFrameworkRecLog: Capturer start : ERROR `); + expect(false).assertTrue(); + done(); + return; + } + + fd = fileio.openSync(dirPath, 0o2002, 0o666); + if (fd !== null) { + console.info(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode : PASS`); + } + else { + console.info(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); + expect(false).assertTrue(); + done(); + return; + } + let numBuffersToCapture = 45; + while (numBuffersToCapture) { + try { + await new Promise((resolve, reject) => { + audioCap.read(bufferSize, true, (err, buffer) => { + if (err) { + console.info(`${Tag} AudioFrameworkRecLog: Capturer release :ERROR : ${JSON.stringify(err.message)}`); + reject(err); + } else { + let number = fileio.writeSync(fd, buffer); + console.info(`${Tag} AudioFrameworkRecLog:BufferRecLog: data written: ${JSON.stringify(number)}`); + resolve(); + } + }); + }) + } catch (err) { + console.info(`${Tag} read err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + } + numBuffersToCapture--; + } + console.log(`${Tag} read success`); + toNextStep(audioCap, steps, done); + }); + + eventEmitter.on(STOP_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(STOP_EVENT)}`); + steps.shift(); + audioCap.stop(async (err) => { + console.log(`${Tag} enter stop`); + if (err && steps[0] == ERROR_EVENT) { + console.log(`${Tag} STOP_EVENT error success`); + steps.shift(); + toNextStep(audioCap, steps, done); + } else if (err) { + console.log(`${Tag} stop err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + await releaseFun(audioCap, done); + } else { + console.log(`${Tag} stop success`); + expect(audioCap.state).assertEqual(audio.AudioState.STATE_STOPPED); + toNextStep(audioCap, steps, done); + } + }); + }); + eventEmitter.on(RELEASE_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(RELEASE_EVENT)}`); + steps.shift(); + audioCap.release(async (err) => { + console.log(`${Tag} enter release`); + if (err && steps[0] == ERROR_EVENT) { + console.log(`${Tag} RELEASE_EVENT error success`); + steps.shift(); + toNextStep(audioCap, steps, done); + } else if (err) { + console.log(`${Tag} release err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + await releaseFun(audioCap, done); + return; + } else { + console.log(`${Tag} release success`); + expect(audioCap.state).assertEqual(audio.AudioState.STATE_RELEASED); + toNextStep(audioCap, steps, done); + } + }); + }); + eventEmitter.on(GET_AUDIOTIME_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(GET_AUDIOTIME_EVENT)}`); + steps.shift(); + audioCap.getAudioTime(async (err, audioTime) => { + console.log(`${Tag} enter getAudioTime`); + if (err && steps[0] == ERROR_EVENT) { + console.log(`${Tag} GET_AUDIOTIME_EVENT error success`); + steps.shift(); + toNextStep(audioCap, steps, done); + } else if (err) { + console.log(`${Tag} getAudioTime err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + await releaseFun(audioCap, done); + return; + } else { + console.log(`${Tag} getAudioTime success`); + expect(audioTime).assertLarger(0); + toNextStep(audioCap, steps, done); + } + }); + }); + eventEmitter.on(GET_CAPTURERINFO_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(GET_CAPTURERINFO_EVENT)}`); + steps.shift(); + audioCap.getCapturerInfo(async (err, audioParamsGet) => { + if (err && steps[0] == ERROR_EVENT) { + console.log(`${Tag} GET_CAPTURERINFO_EVENT error success`); + steps.shift(); + toNextStep(audioCap, steps, done); + } else if (err) { + console.log(`${Tag} getCapturerInfo err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + await releaseFun(audioCap, done); + return; + } else { + console.info(`${Tag} AudioFrameworkRecLog: Capturer CapturerInfo:`); + console.info(`${Tag} AudioFrameworkRecLog: Capturer SourceType: ${JSON.stringify(audioParamsGet.source)}`); + console.info(`${Tag} AudioFrameworkRecLog: Capturer capturerFlags: ${JSON.stringify(audioParamsGet.capturerFlags)}`); + toNextStep(audioCap, steps, done); + } + }); + }); + eventEmitter.on(GET_STREAMINFO_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(GET_STREAMINFO_EVENT)}`); + steps.shift(); + audioCap.getStreamInfo(async (err, audioParamsGet) => { + if (err && steps[0] == ERROR_EVENT) { + console.log(`${Tag} GET_STREAMINFO_EVENT error success`); + steps.shift(); + toNextStep(audioCap, steps, done); + } else if (err) { + console.log(`${Tag} getStreamInfo err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + await releaseFun(audioCap, done); + return; + } else { + console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:`); + console.info(`${Tag} AudioFrameworkRecLog: Capturer sampleFormat: ${JSON.stringify(audioParamsGet.sampleFormat)}`); + console.info(`${Tag} AudioFrameworkRecLog: Capturer samplingRate: ${JSON.stringify(audioParamsGet.samplingRate)}`); + console.info(`${Tag} AudioFrameworkRecLog: Capturer channels: ${JSON.stringify(audioParamsGet.channels)}`); + console.info(`${Tag} AudioFrameworkRecLog: Capturer encodingType: ${JSON.stringify(audioParamsGet.encodingType)}`); + toNextStep(audioCap, steps, done); + } + }); + }); + + eventEmitter.on(GET_AUDIOSCENE_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(GET_AUDIOSCENE_EVENT)}`); + steps.shift(); + AUDIOMANAGERREC.getAudioScene(async (err, getValue) => { + if (err && steps[0] == ERROR_EVENT) { + console.log(`${Tag} GET_AUDIOSCENE_EVENT error success`); + steps.shift(); + toNextStep(audioCap, steps, done); + } else if (err) { + console.log(`${Tag} getStreamInfo err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + await releaseFun(audioCap, done); + return; + } else { + console.info(`${Tag} AudioFrameworkRecLog: getAudioScene : Value : ${JSON.stringify(getValue)}`); + toNextStep(audioCap, steps, done); + } + }); + }); + + eventEmitter.on(STATE_CHANGE_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(STATE_CHANGE_EVENT)}`); + steps.shift(); + console.log(`${Tag} STATE_CHANGE_EVENT register success`); + audioCap.on('stateChange', (AudioState) => { + console.info(`${Tag} AudioCapturerLog: Changed State to : ${JSON.stringify(AudioState)}`); + switch (AudioState) { + case audio.AudioState.STATE_NEW: + console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------NEW--------------`); + console.info(`${Tag} AudioFrameworkTest: Audio State is : New`); + break; + case audio.AudioState.STATE_PREPARED: + console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------PREPARED--------------`); + console.info(`${Tag} AudioFrameworkTest: Audio State is : Prepared`); + break; + case audio.AudioState.STATE_RUNNING: + console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RUNNING--------------`); + console.info(`${Tag} AudioFrameworkTest: Audio State is : Running`); + break; + case audio.AudioState.STATE_STOPPED: + console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------STOPPED--------------`); + console.info(`${Tag} AudioFrameworkTest: Audio State is : stopped`); + break; + case audio.AudioState.STATE_RELEASED: + console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------RELEASED--------------`); + console.info(`${Tag} AudioFrameworkTest: Audio State is : released`); + break; + default: + console.info(`${Tag} AudioFrameworkTest:--------CHANGE IN AUDIO STATE----------INVALID--------------`); + console.info(`${Tag} AudioFrameworkTest: Audio State is : invalid`); + break; + } + }); + toNextStep(audioCap, steps, done); + }); + + eventEmitter.on(MARK_REACH_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(MARK_REACH_EVENT)}`); + steps.shift(); + let markReachParam = steps[0]; + steps.shift(); + try { + audioCap.on('markReach', markReachParam, (position) => { + console.log(`${Tag} position: ${JSON.stringify(position)}`); + console.log(`${Tag} markReachParam: ${JSON.stringify(markReachParam)}`); + if (position == markReachParam) { + markReachState = 'success' + console.info(`${Tag} AudioRenderLog: mark reached: ${JSON.stringify(position)}`); + } + }); + toNextStep(audioCap, steps, done); + } + catch (error) { + if (error.code == 401) { + markReachState = 'invalid_failure'; + toNextStep(audioCap, steps, done); + } else { + console.info("err" + error.code); + toNextStep(audioCap, steps, done); + } + } + }); + + eventEmitter.on(OFF_MARK_REACH_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(OFF_MARK_REACH_EVENT)}`); + steps.shift(); + audioCap.off('markReach'); + toNextStep(audioCap, steps, done); + }); + + eventEmitter.on(PERIODR_REACH_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(PERIODR_REACH_EVENT)}`); + steps.shift(); + let periodReachParam = steps[0]; + steps.shift(); + try { + audioCap.on('periodReach', periodReachParam, (position) => { + console.log(`${Tag} position: ${JSON.stringify(position)}`); + console.log(`${Tag} periodReachParam: ${JSON.stringify(periodReachParam)}`); + if (position == periodReachParam) { + periodReachState = 'success' + console.info(`${Tag} AudioRenderLog: mark reached: ${JSON.stringify(position)}`); + } + }); + toNextStep(audioCap, steps, done); + } + catch (error) { + if (error.code == 401) { + markReachState = 'invalid_failure'; + toNextStep(audioCap, steps, done); + } else { + console.info("err" + error.code); + toNextStep(audioCap, steps, done); + } + } + + }); + eventEmitter.on(OFF_PERIODR_REACH_EVENT, (audioCap, steps, done) => { + console.log(`${Tag} emit: ${JSON.stringify(OFF_PERIODR_REACH_EVENT)}`); + steps.shift(); + audioCap.off('periodReach'); + toNextStep(audioCap, steps, done); + }); + async function releaseFun(audioCap, done) { + try { + await audioCap.release(); + console.log(`${Tag} release success`); + done(); + } catch (err) { + console.log(`${Tag} release fail,err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + } + } + + async function getFd(fileName) { + let context = await featureAbility.getContext(); + await context.getFilesDir().then((data) => { + dirPath = data + '/' + fileName; + console.info(`${Tag} case2 dirPath is ${JSON.stringify(dirPath)}`); + }) + } + const AUDIOMANAGERREC = audio.getAudioManager(); + console.info(`${Tag} AudioFrameworkRecLog: Create AudioManger Object JS Framework`); + + async function getPermission() { + let permissions = ['ohos.permission.MICROPHONE']; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("request success" + JSON.stringify(data)); + }) + } + async function driveFn() { + console.info(`come in driveFn`); + let driver = await UiDriver.create(); + console.info(`driver is ${JSON.stringify(driver)}`); + await sleep(100); + console.info(`UiDriver start`); + let button = await driver.findComponent(BY.text('允许')); + console.info(`button is ${JSON.stringify(button)}`); + await sleep(100); + await button.click(); + } + + beforeAll(async function () { + await getPermission(); + await driveFn(); + console.info('TestLog: Start Testing AudioFrameworkTest Interfaces'); + }) + + beforeEach(async function () { + console.info(`${Tag} AudioFrameworkTest: beforeEach: Prerequisites at the test case level`); + await sleep(1000); + }) + + afterEach(function () { + console.info(`${Tag} AudioFrameworkTest: afterEach: Test case-level clearance conditions`); + }) + + afterAll(function () { + console.info(`${Tag} AudioFrameworkTest: afterAll: Test suite-level cleanup condition`); + }) + + async function recPromise(AudioCapturerOptions, done) { + let audioCap; + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: success`); + } catch (err) { + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`); + LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; + LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; + let sampleFormat = AudioRendererOptions.streamInfo.sampleFormat; + if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { + done(); + return; + } + expect(false).assertTrue(); + done(); + return; + } + + try { + let audioParamsGet = await audioCap.getStreamInfo(); + if (audioParamsGet != undefined && audioParamsGet != null) { + console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:${JSON.stringify(audioParamsGet)}`); + } else { + console.info(`${Tag} AudioFrameworkRecLog: audioParamsGet are incorrect,is : ${JSON.stringify(audioParamsGet)}`); + expect(false).assertTrue(); + } + } catch (err) { + console.log(`${Tag} AudioFrameworkRecLog: getStreamInfo :ERROR: ${JSON.stringify(err.message)}`); + expect(false).assertTrue(); + } + + try { + let audioParamsGet = await audioCap.getCapturerInfo(); + if (audioParamsGet != undefined) { + console.info(`${Tag} AudioFrameworkRecLog: Capturer CapturerInfo: ${JSON.stringify(audioParamsGet)}`); + } else { + console.info(`${Tag} AudioFrameworkRecLog: audioParamsGet are incorrect , is : ${JSON.stringify(audioParamsGet)}`); + expect(false).assertTrue(); + } + } catch (err) { + console.log(`${Tag} AudioFrameworkRecLog: CapturerInfo :ERROR: ${JSON.stringify(err.message)}`); + expect(false).assertTrue(); + } + + try { + await audioCap.start(); + console.log(`${Tag} start ok`); + let bufferSize = await audioCap.getBufferSize(); + console.log(`${Tag} bufferSize: ${JSON.stringify(bufferSize)} , dirPath: ${JSON.stringify(dirPath)}`); + let fd = fileio.openSync(dirPath, 0o102, 0o777); + console.log(`${Tag} fd: ${JSON.stringify(fd)}`); + if (fd !== null) { + console.info(`${Tag} AudioFrameworkRecLog: file fd created`); + } + else { + console.info(`${Tag} AudioFrameworkRecLog: Capturer start : ERROR `); + expect(false).assertTrue(); + } + + fd = fileio.openSync(dirPath, 0o2002, 0o666); + console.log(`${Tag} fd-re: ${JSON.stringify(fd)}`); + if (fd !== null) { + console.info(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode :PASS`); + } + else { + console.info(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); + expect(false).assertTrue(); + } + + let numBuffersToCapture = 45; + while (numBuffersToCapture) { + console.info(`${Tag} AudioFrameworkRecLog: ---------READ BUFFER---------`); + let buffer = await audioCap.read(bufferSize, true); + console.info(`${Tag} AudioFrameworkRecLog: ---------WRITE BUFFER---------`); + let number = fileio.writeSync(fd, buffer); + console.info(`${Tag} AudioFrameworkRecLog:BufferRecLog: data written: ${JSON.stringify(number)}`); + numBuffersToCapture--; + } + console.log(`${Tag} read ok`); + await audioCap.stop(); + console.log(`${Tag} stop ok`); + } catch (err) { + console.log(`${Tag} start-read-stop err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + try { + await audioCap.release(); + console.log(`${Tag} release ok`); + } catch (err) { + console.log(`${Tag} release err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + } + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_PREPARED_STATE_0100 + *@tc.name : + *@tc.desc : createAudioCapturer callback + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_PREPARED_STATE_0100', 1, function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + console.log(`${Tag} AudioCapturerOptions= ${JSON.stringify(AudioCapturerOptions)}`); + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, RELEASE_EVENT, END_EVENT]; + console.log(`${Tag} mySteps= ${JSON.stringify(mySteps)}`); + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_RUNNING_STATE_0100 + *@tc.name : AudioCapturer-Check-STATE-RUNNING + *@tc.desc : AudioCapturer with state running + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_RUNNING_STATE_0100', 1, function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, START_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_STOPPED_STATE_0100 + *@tc.name : AudioCapturer-Check-STATE-STOPPED + *@tc.desc : AudioCapturer with state stopped + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_STOPPED_STATE_0100', 1, function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, START_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_GET_BUFFER_SIZE_0100 + *@tc.name : AudioCapturer-get_buffer_size + *@tc.desc : AudioCapturer with state stopped + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_GET_BUFFER_SIZE_0100', 1, function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, START_EVENT, GET_BUFFERSIZE_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_0100 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 1 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_0100', 1, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMOISE_PREPARED_STATE_0100 + *@tc.name : AudioCapturer-Check-STATE-PREPARED + *@tc.desc : AudioCapturer with state prepared + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMOISE_PREPARED_STATE_0100', 0, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCapPromise; + await audio.createAudioCapturer(AudioCapturerOptions).then(function (data) { + audioCapPromise = data; + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: success`); + expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_PREPARED); + expect(audioCapPromise.state).assertEqual(1); + }).catch((err) => { + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`); + expect(false).assertTrue(); + }); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RUNNING_STATE_0100 + *@tc.name : AudioCapturer-Check-STATE-RUNNING + *@tc.desc : AudioCapturer with state running + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RUNNING_STATE_0100', 0, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCapPromise.start(); + expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RUNNING); + expect(audioCapPromise.state).assertEqual(2); + await audioCapPromise.release(); + } catch (err) { + console.log(`${Tag} err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_STOPPED_STATE_0100 + *@tc.name : AudioCapturer-Check-STATE-STOPPED + *@tc.desc : AudioCapturer with state stopped + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_STOPPED_STATE_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCapPromise.start(); + expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RUNNING); + await audioCapPromise.stop(); + expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_STOPPED); + expect(audioCapPromise.state).assertEqual(3); + await audioCapPromise.release() + } catch (err) { + console.log(`${Tag} err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RELEASED_STATE_0100 + *@tc.name : AudioCapturer-Check-STATE-RELEASED + *@tc.desc : AudioCapturer with state released + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RELEASED_STATE_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCapPromise.start(); + await audioCapPromise.stop(); + await audioCapPromise.release(); + expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RELEASED); + expect(audioCapPromise.state).assertEqual(4); + } catch (err) { + console.log(`${Tag} err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_BUFFER_SIZE_0100 + *@tc.name : AudioCapturer-get_buffer_size + *@tc.desc : AudioCapturer with state stopped + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_BUFFER_SIZE_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + } catch (err) { + console.log(`${Tag} createAudioCapturer err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + try { + await audioCapPromise.start(); + expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RUNNING); + let bufferSize = await audioCapPromise.getBufferSize(); + console.info(`${Tag} AudioFrameworkRecLog: buffer size: ${JSON.stringify(bufferSize)}`); + } catch (err) { + console.log(`${Tag} start-getBufferSize err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + try { + await audioCapPromise.release(); + expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RELEASED); + } catch (err) { + console.log(`${Tag} release err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_READ_BUFFER_0100 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_READ_BUFFER_0100', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkpromisereadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + } catch (err) { + console.log(`${Tag} createAudioCapturer err : ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + try { + await audioCapPromise.start(); + expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RUNNING); + bufferSize = await audioCapPromise.getBufferSize(); + console.info(`${Tag} AudioFrameworkRecLog: buffer size: ${JSON.stringify(bufferSize)}`); + } catch (err) { + console.log(`${Tag} start-getBufferSize err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + + let fd = fileio.openSync(dirPath, 0o102, 0o777); + if (fd !== null) { + console.info(`${Tag} AudioFrameworkRecLog: file fd created`); + } + else { + console.info(`${Tag} AudioFrameworkRecLog: Capturer start :ERROR :`); + expect(false).assertTrue(); + done(); + return; + } + + fd = fileio.openSync(dirPath, 0o2002, 0o666); + if (fd !== null) { + console.info(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode :PASS`); + } + else { + console.info(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); + expect(false).assertTrue(); + done(); + return; + } + + try { + let numBuffersToCapture = 45; + while (numBuffersToCapture) { + let buffer = await audioCapPromise.read(bufferSize, true); + console.info(`${Tag} AudioFrameworkRecLog: ---------AFTER PROMISE READ ---------`); + let number = fileio.writeSync(fd, buffer); + console.info(`${Tag} BufferRecLog: data written: ${JSON.stringify(number)}`); + numBuffersToCapture--; + } + } catch (err) { + console.info(`${Tag} AudioFrameworkRecLog: read err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + + try { + await audioCapPromise.release(); + expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RELEASED); + } catch (err) { + console.log(`${Tag} release err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_CB_0100 + *@tc.name : AudioCapturer-Set1-Media + *@tc.desc : AudioCapturer with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_CB_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + await getFd("capture_CB_js-44100-2C-16B.pcm"); + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, GET_AUDIOSCENE_EVENT, GET_STREAMINFO_EVENT, GET_CAPTURERINFO_EVENT, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_CB_ENUM_0100 + *@tc.name : AudioCapturer-Set1-Media + *@tc.desc : AudioCapturer with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_CB_ENUM_0100', 2, async function (done) { + + let AudioStreamInfo = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0 + } + let AudioCapturerInfo = { + source: 3, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + await getFd("capture_CB_js-44100-2C-16B.pcm"); + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, ERROR_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0100 + *@tc.name : AudioCapturer-Set1-Media + *@tc.desc : AudioCapturer with parameter set 7 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_VOICE_COMMUNICATION, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + await getFd("capture_js-44100-2C-16B.pcm"); + await recPromise(AudioCapturerOptions, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0100 + *@tc.name : AudioCapturer-Set1-Media + *@tc.desc : AudioCapturer with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0 + } + let AudioCapturerInfo = { + source: 0, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + await getFd("capture_js-44100-2C-16B.pcm"); + await recPromise(AudioCapturerOptions, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0200 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0200', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions44100 = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await getFd("capture_js-44100-1C-16LE.pcm"); + await recPromise(audioCapturerOptions44100, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0200 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0200', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + let audioCapturerInfo44100 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions44100 = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await getFd("capture_js-44100-1C-16LE.pcm"); + await recPromise(audioCapturerOptions44100, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0300 + *@tc.name : AudioRec-Set2 + *@tc.desc : record audio with parameter set 2 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0300', 2, async function (done) { + let audioStreamInfo96000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_96000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo96000 = { + source: audio.SourceType.SOURCE_TYPE_VOICE_RECOGNITION, + capturerFlags: 0 + } + let audioCapturerOptions96000 = { + streamInfo: audioStreamInfo96000, + capturerInfo: audioCapturerInfo96000, + } + + await getFd("capture_js-96000-1C-S24LE.pcm"); + await recPromise(audioCapturerOptions96000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0300 + *@tc.name : AudioRec-Set2 + *@tc.desc : record audio with parameter set 2 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0300', 2, async function (done) { + let audioStreamInfo96000 = { + samplingRate: 96000, + channels: 1, + sampleFormat: 2, + encodingType: 0, + }; + let audioCapturerInfo96000 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions96000 = { + streamInfo: audioStreamInfo96000, + capturerInfo: audioCapturerInfo96000, + } + + await getFd("capture_js-96000-1C-S24LE.pcm"); + await recPromise(audioCapturerOptions96000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0400 + *@tc.name : AudioRec-Set3 + *@tc.desc : record audio with parameter set 3 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0400', 2, async function (done) { + let audioStreamInfo48000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo48000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions48000 = { + streamInfo: audioStreamInfo48000, + capturerInfo: audioCapturerInfo48000, + } + + await getFd("capture_js-48000-2C-1S32LE.pcm"); + await recPromise(audioCapturerOptions48000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0400 + *@tc.name : AudioRec-Set3 + *@tc.desc : record audio with parameter set 3 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0400', 2, async function (done) { + let audioStreamInfo48000 = { + samplingRate: 48000, + channels: 2, + sampleFormat: 1, + encodingType: 0, + }; + let audioCapturerInfo48000 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions48000 = { + streamInfo: audioStreamInfo48000, + capturerInfo: audioCapturerInfo48000, + } + + await getFd("capture_js-48000-2C-1S32LE.pcm"); + await recPromise(audioCapturerOptions48000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0500 + *@tc.name : AudioRec-Set4 + *@tc.desc : record audio with parameter set 4 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0500', 2, async function (done) { + let audioStreamInfo8000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_8000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_U8, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo8000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions8000 = { + streamInfo: audioStreamInfo8000, + capturerInfo: audioCapturerInfo8000, + } + + await getFd("capture_js-8000-1C-8B.pcm"); + await recPromise(audioCapturerOptions8000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0500 + *@tc.name : AudioRec-Set4 + *@tc.desc : record audio with parameter set 4 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0500', 2, async function (done) { + let audioStreamInfo8000 = { + samplingRate: 8000, + channels: 1, + sampleFormat: 0, + encodingType: 0, + }; + let audioCapturerInfo8000 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions8000 = { + streamInfo: audioStreamInfo8000, + capturerInfo: audioCapturerInfo8000, + } + + await getFd("capture_js-8000-1C-8B.pcm"); + await recPromise(audioCapturerOptions8000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0600 + *@tc.name : AudioRec-Set5 + *@tc.desc : record audio with parameter set 5 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0600', 2, async function (done) { + let audioStreamInfo11025 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_11025, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo11025 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions11025 = { + streamInfo: audioStreamInfo11025, + capturerInfo: audioCapturerInfo11025, + } + + await getFd("capture_js-11025-2C-16B.pcm"); + await recPromise(audioCapturerOptions11025, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0600 + *@tc.name : AudioRec-Set5 + *@tc.desc : record audio with parameter set 5 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0600', 2, async function (done) { + let audioStreamInfo11025 = { + samplingRate: 11025, + channels: 2, + sampleFormat: 1, + encodingType: 0, + }; + let audioCapturerInfo11025 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions11025 = { + streamInfo: audioStreamInfo11025, + capturerInfo: audioCapturerInfo11025, + } + + await getFd("capture_js-11025-2C-16B.pcm"); + await recPromise(audioCapturerOptions11025, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0700 + *@tc.name : AudioRec-Set6 + *@tc.desc : record audio with parameter set 6 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0700', 2, async function (done) { + let audioStreamInfo12000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_12000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo12000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions12000 = { + streamInfo: audioStreamInfo12000, + capturerInfo: audioCapturerInfo12000, + } + + await getFd("capture_js-12000-1C-24B.pcm"); + await recPromise(audioCapturerOptions12000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0700 + *@tc.name : AudioRec-Set6 + *@tc.desc : record audio with parameter set 6 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0700', 2, async function (done) { + let audioStreamInfo12000 = { + samplingRate: 12000, + channels: 1, + sampleFormat: 2, + encodingType: 0 + }; + let audioCapturerInfo12000 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions12000 = { + streamInfo: audioStreamInfo12000, + capturerInfo: audioCapturerInfo12000, + } + + await getFd("capture_js-12000-1C-24B.pcm"); + await recPromise(audioCapturerOptions12000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0800 + *@tc.name : AudioRec-Set7 + *@tc.desc : record audio with parameter set 7 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0800', 2, async function (done) { + let audioStreamInfo16000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_16000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo16000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions16000 = { + streamInfo: audioStreamInfo16000, + capturerInfo: audioCapturerInfo16000, + } + + await getFd("capture_js-16000-2C-32B.pcm"); + await recPromise(audioCapturerOptions16000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0800 + *@tc.name : AudioRec-Set7 + *@tc.desc : record audio with parameter set 7 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0800', 2, async function (done) { + let audioStreamInfo16000 = { + samplingRate: 16000, + channels: 2, + sampleFormat: 3, + encodingType: 0, + }; + let audioCapturerInfo16000 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions16000 = { + streamInfo: audioStreamInfo16000, + capturerInfo: audioCapturerInfo16000, + } + + await getFd("capture_js-16000-2C-32B.pcm"); + await recPromise(audioCapturerOptions16000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0900 + *@tc.name : AudioRec-Set8 + *@tc.desc : record audio with parameter set 8 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_0900', 2, async function (done) { + let audioStreamInfo22050 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_22050, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_U8, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo22050 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions22050 = { + streamInfo: audioStreamInfo22050, + capturerInfo: audioCapturerInfo22050, + } + + await getFd("capture_js-22050-1C-8B.pcm"); + await recPromise(audioCapturerOptions22050, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0900 + *@tc.name : AudioRec-Set8 + *@tc.desc : record audio with parameter set 8 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_0900', 2, async function (done) { + let audioStreamInfo22050 = { + samplingRate: 22050, + channels: 1, + sampleFormat: 0, + encodingType: 0, + }; + let audioCapturerInfo22050 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions22050 = { + streamInfo: audioStreamInfo22050, + capturerInfo: audioCapturerInfo22050, + } + + await getFd("capture_js-22050-1C-8B.pcm"); + await recPromise(audioCapturerOptions22050, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1000 + *@tc.name : AudioRec-Set9 + *@tc.desc : record audio with parameter set 9 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1000', 2, async function (done) { + let audioStreamInfo24000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_24000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo24000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions24000 = { + streamInfo: audioStreamInfo24000, + capturerInfo: audioCapturerInfo24000, + } + + await getFd("capture_js-24000-2C-16B.pcm"); + await recPromise(audioCapturerOptions24000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1000 + *@tc.name : AudioRec-Set9 + *@tc.desc : record audio with parameter set 9 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1000', 2, async function (done) { + let audioStreamInfo24000 = { + samplingRate: 24000, + channels: 2, + sampleFormat: 1, + encodingType: 0, + }; + let audioCapturerInfo24000 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions24000 = { + streamInfo: audioStreamInfo24000, + capturerInfo: audioCapturerInfo24000, + } + + await getFd("capture_js-24000-2C-16B.pcm"); + await recPromise(audioCapturerOptions24000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1100 + *@tc.name : AudioRec-Set10 + *@tc.desc : record audio with parameter set 010 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1100', 2, async function (done) { + let audioStreamInfo32000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_32000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo32000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions32000 = { + streamInfo: audioStreamInfo32000, + capturerInfo: audioCapturerInfo32000, + } + + await getFd("capture_js-32000-1C-24B.pcm"); + await recPromise(audioCapturerOptions32000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1100 + *@tc.name : AudioRec-Set10 + *@tc.desc : record audio with parameter set 010 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1100', 2, async function (done) { + let audioStreamInfo32000 = { + samplingRate: 32000, + channels: 1, + sampleFormat: 2, + encodingType: 0, + }; + let audioCapturerInfo32000 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions32000 = { + streamInfo: audioStreamInfo32000, + capturerInfo: audioCapturerInfo32000, + } + + await getFd("capture_js-32000-1C-24B.pcm"); + await recPromise(audioCapturerOptions32000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1200 + *@tc.name : AudioRec-Set11 + *@tc.desc : record audio with parameter set 011 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1200', 2, async function (done) { + let audioStreamInfo64000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_64000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo64000 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions64000 = { + streamInfo: audioStreamInfo64000, + capturerInfo: audioCapturerInfo64000, + } + + await getFd("capture_js-64000-2C-32B.pcm"); + await recPromise(audioCapturerOptions64000, done); + }) + + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1200 + *@tc.name : AudioRec-Set11 + *@tc.desc : record audio with parameter set 011 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_ENUM_1200', 2, async function (done) { + let audioStreamInfo64000 = { + samplingRate: 64000, + channels: 2, + sampleFormat: 3, + encodingType: 0, + }; + let audioCapturerInfo64000 = { + source: 0, + capturerFlags: 0 + } + let audioCapturerOptions64000 = { + streamInfo: audioStreamInfo64000, + capturerInfo: audioCapturerInfo64000, + } + + await getFd("capture_js-64000-2C-32B.pcm"); + await recPromise(audioCapturerOptions64000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1300 + *@tc.name : AudioRec-Set11 , SourceType set SOURCE_TYPE_VOICE_RECOGNITION + *@tc.desc : record audio with parameter set 011 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_REC_VOICE_CHAT_PROMISE_1300', 2, async function (done) { + let audioStreamInfo64000 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_64000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo64000 = { + source: audio.SourceType.SOURCE_TYPE_VOICE_RECOGNITION, + capturerFlags: 0 + } + let audioCapturerOptions64000 = { + streamInfo: audioStreamInfo64000, + capturerInfo: audioCapturerInfo64000, + } + + await getFd("capture_js-64000-2C-32B.pcm"); + await recPromise(audioCapturerOptions64000, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_RECORD_PROMISE_AUDIO_SCENE_DEFAULT_0100 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RECORD_PROMISE_AUDIO_SCENE_DEFAULT_0100', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions44100 = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await getFd("capture_js-44100-1C-16LE.pcm"); + await recPromise(audioCapturerOptions44100, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_RECORD_PROMISE_AUDIO_SCENE_DEFAULT_ENUM_0100 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RECORD_PROMISE_AUDIO_SCENE_DEFAULT_ENUM_0100', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + }; + let audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let audioCapturerOptions44100 = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await getFd("capture_js-44100-1C-16LE.pcm"); + await recPromise(audioCapturerOptions44100, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_START_0100 + *@tc.name : AudioCapturer-GET_AUDIO_TIME + *@tc.desc : AudioCapturer GET_AUDIO_TIME + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_START_0100', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, START_EVENT, GET_AUDIOTIME_EVENT, GET_AUDIOTIME_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_READ_WRITE_0100 + *@tc.name : AudioCapturer-GET_AUDIO_TIME + *@tc.desc : AudioCapturer GET_AUDIO_TIME + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_READ_WRITE_0100', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + console.log(`${Tag} createAudioCapturer ok`); + } catch (err) { + console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + return done(); + } + + try { + await audioCapPromise.start(); + console.log(`${Tag} start ok`); + let audioTime = await audioCapPromise.getAudioTime(); + console.log(`${Tag} audioTime: ${JSON.stringify(audioTime)}`); + expect(audioTime).assertLarger(0); + + let bufferSize = await audioCapPromise.getBufferSize(); + console.log(`${Tag} AudioFrameworkRecLog: buffer size: ${JSON.stringify(bufferSize)}`); + let fd = fileio.openSync(dirPath, 0o102, 0o777); + console.log(`${Tag} fd: ${JSON.stringify(fd)}`); + if (fd !== null) { + console.log(`${Tag} AudioFrameworkRecLog: file fd created`); + } else { + console.log(`${Tag} AudioFrameworkRecLog: Capturer start :ERROR :`); + expect(false).assertTrue(); + done(); + return; + } + + fd = fileio.openSync(dirPath, 0o2002, 0o666); + console.log(`${Tag} fd1: ${JSON.stringify(fd)}`); + if (fd !== null) { + console.log(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode :PASS`); + } else { + console.log(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); + expect(false).assertTrue(); + done(); + return; + } + let numBuffersToCapture = 45; + while (numBuffersToCapture) { + let buffer = await audioCapPromise.read(bufferSize, true); + let audioTime1 = await audioCapPromise.getAudioTime(); + console.log(`${Tag} audioTime1: ${JSON.stringify(audioTime1)}`); + expect(audioTime1).assertLarger(0); + let number = fileio.writeSync(fd, buffer); + console.info(`${Tag} AudioFrameworkRecLog:BufferRecLog: data written: ${JSON.stringify(number)}`); + numBuffersToCapture--; + } + + let audioTime2 = await audioCapPromise.getAudioTime(); + console.log(`${Tag} audioTime2: ${JSON.stringify(audioTime2)}`); + expect(audioTime2).assertLarger(0); + } catch (err) { + console.log(`${Tag} start-getAudioTime-getBufferSize-read-getAudioTimein- err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + + try { + await audioCapPromise.release(); + } catch (err) { + console.log(`${Tag} err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_STOP_0100 + *@tc.name : AudioCapturer-GET_AUDIO_TIME + *@tc.desc : AudioCapturer GET_AUDIO_TIME + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_GET_AUDIO_TIME_AFTER_STOP_0100', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + console.log(`${Tag} createAudioCapturer ok`); + } catch (err) { + console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + return done(); + } + + try { + await audioCapPromise.start(); + console.log(`${Tag} start ok`); + let audioTime = await audioCapPromise.getAudioTime(); + console.log(`${Tag} audioTime: ${JSON.stringify(audioTime)}`); + expect(audioTime).assertLarger(0); + + let bufferSize = await audioCapPromise.getBufferSize(); + console.log(`${Tag} AudioFrameworkRecLog: buffer size: ${JSON.stringify(bufferSize)}`); + let fd = fileio.openSync(dirPath, 0o102, 0o777); + console.log(`${Tag} fd: ${JSON.stringify(fd)}`); + if (fd !== null) { + console.log(`${Tag} AudioFrameworkRecLog: file fd created`); + } + else { + console.log(`${Tag} AudioFrameworkRecLog: Capturer start :ERROR :`); + expect(false).assertTrue(); + done(); + return; + } + + fd = fileio.openSync(dirPath, 0o2002, 0o666); + console.log(`${Tag} fd1: ${JSON.stringify(fd)}`); + if (fd !== null) { + console.log(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode :PASS`); + } + else { + console.log(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); + expect(false).assertTrue(); + done(); + return; + } + let numBuffersToCapture = 45; + while (numBuffersToCapture) { + let buffer = await audioCapPromise.read(bufferSize, true); + let audioTime1 = await audioCapPromise.getAudioTime(); + console.log(`${Tag} audioTime1: ${JSON.stringify(audioTime1)}`); + expect(audioTime1).assertLarger(0); + let number = fileio.writeSync(fd, buffer); + console.info(`${Tag} AudioFrameworkRecLog:BufferRecLog: data written: ${JSON.stringify(number)}`); + numBuffersToCapture--; + } + } catch (err) { + console.log(`${Tag} start-getAudioTime-getBufferSize-read-getAudioTimein- err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + try { + await audioCapPromise.stop(); + let audioTime2 = await audioCapPromise.getAudioTime(); + console.log(`${Tag} audioTime2: ${JSON.stringify(audioTime2)}`); + expect(audioTime2).assertLarger(0); + } catch (err) { + console.log(`${Tag} stop-getAudioTimein- err: ${JSON.stringify(err)}`); + expect(true).assertTrue(); + } + + try { + await audioCapPromise.release(); + } catch (err) { + console.log(`${Tag} err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_GET_AUDIO_TIME_0100 + *@tc.name : AudioCapturer-GET_AUDIO_TIME + *@tc.desc : AudioCapturer GET_AUDIO_TIME + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_GET_AUDIO_TIME_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + } catch (err) { + console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + return done(); + } + try { + await audioCapPromise.start(); + let audioTime = await audioCapPromise.getAudioTime(); + console.log(`${Tag} audioTime: ${JSON.stringify(audioTime)}`) + expect(audioTime).assertLarger(0); + } catch (err) { + console.log(`${Tag} start-getAudioTime err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + try { + await audioCapPromise.release(); + } catch (err) { + console.log(`${Tag} err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_STOP_BEFORE_START_0100 + *@tc.name : AudioCapturer-GET_AUDIO_TIME + *@tc.desc : AudioCapturer createAudioCapturer->stop->release + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_STOP_BEFORE_START_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + console.log(`${Tag} createAudioCapturer ok`); + } catch (err) { + console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + return done(); + } + + try { + await audioCapPromise.start(); + console.log(`${Tag} start ok`); + } catch (err) { + console.log(`${Tag} start err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + try { + await audioCapPromise.stop(); + console.log(`${Tag} stop ok`); + expect(true).assertTrue(); + } catch (err) { + console.log(`${Tag} stop err: ${JSON.stringify(err)}`); + expect(true).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RELEASE_BEFORE_START_0100 + *@tc.name : AudioCapturer-GET_AUDIO_TIME + *@tc.desc : AudioCapturer GET_AUDIO_TIME + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_PROMISE_RELEASE_BEFORE_START_0100', 2, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + } catch (err) { + console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + return done(); + } + + try { + await audioCapPromise.release(); + expect(audioCapPromise.state).assertEqual(audio.AudioState.STATE_RELEASED); + } catch (err) { + console.log(`${Tag} release err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + try { + await audioCapPromise.release(); + } catch (err) { + console.log(`${Tag} re-release err: ${JSON.stringify(err)}`); + expect(true).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_STREAM_INFO_0100 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_STREAM_INFO_0100', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + let audioCap; + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + } catch (err) { + console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + return done(); + } + + try { + let audioParamsGet = await audioCap.getStreamInfo(); + console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:${JSON.stringify(audioParamsGet)}`); + } catch (err) { + console.log(`${Tag} getStreamInfo err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + + try { + await audioCap.release(); + } catch (err) { + console.log(`${Tag} release err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_STREAM_INFO_ENUM_0100 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_STREAM_INFO_ENUM_0100', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + let audioCapturerInfo44100 = { + source: 0, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + let audioCap; + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + } catch (err) { + console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + return done(); + } + + try { + let audioParamsGet = await audioCap.getStreamInfo(); + console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:${JSON.stringify(audioParamsGet)}`); + } catch (err) { + console.log(`${Tag} getStreamInfo err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + + try { + await audioCap.release(); + } catch (err) { + console.log(`${Tag} release err: ${JSON.stringify(err)}`); + console.log(`${Tag} audioCap.state: ${JSON.stringify(audioCap.state)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_CB_VOICE_CHAT_GET_STREAM_INFO_0200 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_REC_CB_VOICE_CHAT_GET_STREAM_INFO_0200', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + let audioCap; + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + } catch (err) { + console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + return done(); + } + + try { + let audioParamsGet = await audioCap.getStreamInfo(); + console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:${JSON.stringify(audioParamsGet)}`); + } catch (err) { + console.log(`${Tag} getStreamInfo err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + + audioCap.release((err) => { + if (err) { + console.log(`${Tag} release err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + done(); + return; + } + expect(audioCap.state).assertEqual(audio.AudioState.STATE_RELEASED); + done(); + }) + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_CAPTURER_INFO_0300 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_CAPTURER_INFO_0300', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioCapturerInfo44100 = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + let audioCap; + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + } catch (err) { + console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + return done(); + } + + try { + let audioParamsGet = await audioCap.getCapturerInfo(); + console.info(`${Tag} AudioFrameworkRecLog: Capturer CapturerInfo: ${JSON.stringify(audioParamsGet)}`); + } catch (err) { + console.log(`${Tag} getStreamInfo err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + + try { + await audioCap.release(); + } catch (err) { + console.log(`${Tag} release err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_CAPTURER_INFO_ENUM_0300 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_REC_PR_VOICE_CHAT_GET_CAPTURER_INFO_ENUM_0300', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + let audioCapturerInfo44100 = { + source: 0, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + let audioCap; + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + } catch (err) { + console.log(`${Tag} createAudioCapturer err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + return done(); + } + + try { + let audioParamsGet = await audioCap.getCapturerInfo(); + console.info(`${Tag} AudioFrameworkRecLog: Capturer CapturerInfo: ${JSON.stringify(audioParamsGet)}`); + } catch (err) { + console.log(`${Tag} getStreamInfo err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + + try { + await audioCap.release(); + } catch (err) { + console.log(`${Tag} release err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_VOICE_CHAT_PR_ENUM_AUDIO_STREAM_INFO_INVALID_0100 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_REC_VOICE_CHAT_PR_ENUM_AUDIO_STREAM_INFO_INVALID_0100', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: 0, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + let audioCapturerInfo44100 = { + source: 0, + capturerFlags: 0 + } + let AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(function (data) { + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success: ${JSON.stringify(data)}`); + expect(false).assertTrue(); + }).catch((err) => { + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`); + expect(true).assertTrue(); + }); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_REC_VOICE_CHAT_PR_ENUM_AUDIO_CAPTURER_INFO_INVALID_0100 + *@tc.name : AudioRec-Set1 + *@tc.desc : record audio with parameter set 1 + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_REC_VOICE_CHAT_PR_ENUM_AUDIO_CAPTURER_INFO_INVALID_0100', 2, async function (done) { + let audioStreamInfo44100 = { + samplingRate: 44100, + channels: 1, + sampleFormat: 1, + encodingType: 0, + }; + let audioCapturerInfo44100 = { + source: 1000, + capturerFlags: 0 + } + let AudioCapturerOptionsInvalid = { + streamInfo: audioStreamInfo44100, + capturerInfo: audioCapturerInfo44100, + } + + await audio.createAudioCapturer(AudioCapturerOptionsInvalid).then(function (data) { + if (data == undefined) { + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Unsuccess : ${JSON.stringify(data)}`); + expect(true).assertTrue(); + } else { + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success: ${JSON.stringify(data)}`); + expect(false).assertTrue(); + } + + }).catch((err) => { + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`); + expect(true).assertTrue(); + }); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0100 + *@tc.name : AudioCapturer-Check-STATE-STOPPED + *@tc.desc : AudioCapturer with state stopped + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0100', 2, function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, STATE_CHANGE_EVENT, START_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0200 + *@tc.name : AudioCapturer-Check-STATE-STOPPED + *@tc.desc : AudioCapturer with state stopped + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0200', 2, function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, STATE_CHANGE_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0300 + *@tc.name : AudioCapturer-Check-STATE-STOPPED + *@tc.desc : AudioCapturer with state stopped + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0300', 2, function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, STATE_CHANGE_EVENT, START_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0400 + *@tc.name : AudioCapturer-Check-STATE-STOPPED + *@tc.desc : AudioCapturer with state stopped + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_ON_0400', 2, function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, STATE_CHANGE_EVENT, START_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0100 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0100', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let markReachParam = 5000; + markReachState = 'failure'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0200 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0200', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let markReachParam = 1000; + markReachState = 'failure'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0300 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0300', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let markReachParam = 10000; + markReachState = 'failure'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0400 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0400', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let markReachParam = 100; + markReachState = 'failure'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0500 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0500', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let markReachParam = 1; + markReachState = 'failure'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0600 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0600', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let markReachParam = 0; + markReachState = 'fail'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0700 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0700', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let markReachParam = 1234567890; + markReachState = 'invalid_failure'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0800 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_MARK_REACH_0800', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let markReachParam = -2; + markReachState = 'fail'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, MARK_REACH_EVENT, markReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_MARK_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0100 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0100', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let periodReachParam = 1000; + periodReachState = 'failure'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, PERIODR_REACH_EVENT, periodReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_PERIODR_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0200 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0200', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let periodReachParam = 1; + periodReachState = 'failure'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, PERIODR_REACH_EVENT, periodReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_PERIODR_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0300 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0300', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let periodReachParam = -2; + periodReachState = 'fail'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, PERIODR_REACH_EVENT, periodReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_PERIODR_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0400 + *@tc.name : AudioCapturer-Check-READ_BUFFER + *@tc.desc : AudioCapturer with read buffer + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_VOIP_CAP_CB_READ_BUFFER_PERIOD_REACH_0400', 2, async function (done) { + await getFd("capture_CB_js-44100-2C-S16LE-checkcbreadbuffer.pcm"); + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + + let audioCap = null; + let periodReachParam = 223750; + periodReachState = 'invalid_failure'; + let mySteps = [CREATE_EVENT, AudioCapturerOptions, PERIODR_REACH_EVENT, periodReachParam, START_EVENT, GET_BUFFERSIZE_EVENT, READ_EVENT, OFF_PERIODR_REACH_EVENT, RELEASE_EVENT, END_EVENT]; + eventEmitter.emit(mySteps[0], audioCap, mySteps, done); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0100 + *@tc.name : AudioCapturer - getAudioStreamId + *@tc.desc : AudioCapturer - getAudioStreamId + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0100', 0, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + let audioCapPromise; + try { + audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCapPromise.getAudioStreamId((err, data) => { + if (err) { + console.info(`${Tag}: getAudioStreamId : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + } else { + expect(true).assertTrue(); + console.info(`${Tag}: getAudioStreamId : Converted: ${data}`); + } + }); + await audioCapPromise.release(); + } catch (err) { + console.log(`${Tag} err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + }) + + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0200 + *@tc.name : AudioCapturer - getAudioStreamId + *@tc.desc : AudioCapturer - getAudioStreamId + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_GET_AUDIO_STREAM_ID_0200', 0, async function (done) { + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + let AudioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + let AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + try { + let audioCapPromise = await audio.createAudioCapturer(AudioCapturerOptions); + await audioCapPromise.getAudioStreamId().then((data) => { + expect(true).assertTrue(); + console.info(`${Tag}: getAudioStreamId : Converted: ${data}`); + }).catch((err) => { + expect(true).assertTrue(); + console.error(`${Tag}: getAudioStreamId : ERROR : ${err}`); + }); + + await audioCapPromise.release(); + } catch (err) { + console.log(`${Tag} error code: ${err.code} ,message:${err.message}`); + expect(false).assertTrue(); + } + done(); + }) + }) } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturerInterrupt.test.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturerInterrupt.test.js index a7abbc77ac6df0d4acbca1746478ed7f6244597e..f5e1cf10cd0742409cba9ac631fd8cca02c40035 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturerInterrupt.test.js +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioCapturerInterrupt.test.js @@ -1,1503 +1,1503 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http:// www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import audio from '@ohos.multimedia.audio'; -import featureAbility from '@ohos.ability.featureAbility'; -import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; -import { UiDriver, BY } from '@ohos.UiTest' -export default function audioCapturerInterrupt() { - describe("AudioCapturerInterruptUnitTest", function () { - async function getPermission() { - let permissions = ['ohos.permission.MICROPHONE']; - featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { - console.info("request success" + JSON.stringify(data)); - }) - } - async function driveFn() { - console.info(`come in driveFn`); - let driver = await UiDriver.create(); - console.info(`driver is ${JSON.stringify(driver)}`); - await sleep(100); - console.info(`UiDriver start`); - let button = await driver.findComponent(BY.text('允许')); - console.info(`button is ${JSON.stringify(button)}`); - await sleep(100); - await button.click(); - } - - beforeAll(async function () { - // await getPermission(); - // await driveFn(); - console.info('beforeAll called') - }) - - afterAll(function () { - console.info('afterAll called') - }) - - beforeEach(function () { - console.info('beforeEach called') - }) - - afterEach(function () { - console.info('afterEach called') - }) - - let capturerInfo = { - "MIC": { - source: audio.SourceType.SOURCE_TYPE_MIC, - capturerFlags: 0, - }, - 'VOICE_RECOGNITION': { - source: audio.SourceType.SOURCE_TYPE_VOICE_RECOGNITION, - capturerFlags: 0, - }, - 'VOICE_COMMUNICATION': { - source: audio.SourceType.SOURCE_TYPE_VOICE_COMMUNICATION, - capturerFlags: 0, - } - } - - let renderInfo = { - 'MUSIC': { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0, - }, - 'VOICE_CALL': { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 - }, - 'RINGTONE': { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, - rendererFlags: 0, - }, - 'VOICE_ASSISTANT': { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - }, - 'ULTRASONIC': { - content: audio.ContentType.CONTENT_TYPE_ULTRASONIC, - usage: audio.StreamUsage.STREAM_USAGE_SYSTEM, - rendererFlags: 0 - }, - 'ALARM': { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_ALARM, - rendererFlags: 0 - }, - 'ACCESSIBILITY': { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, - rendererFlags: 0 - }, - 'SPEECH': { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - }, - 'MOVIE': { - content: audio.ContentType.CONTENT_TYPE_MOVIE, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - }, - 'UNKNOW': { - content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, - rendererFlags: 0 - }, - } - - let streamInfo = { - '16000': { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_16000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - '44100': { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - '48000': { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - } - - async function createAudioRenderer(AudioRendererInfo, AudioStreamInfo, done) { - let render = null; - - var AudioRendererOptions = { - streamInfo: AudioStreamInfo, - rendererInfo: AudioRendererInfo - } - try { - render = await audio.createAudioRenderer(AudioRendererOptions) - console.log("createAudioRenderer success.") - } catch (err) { - console.log("createAudioRenderer err:" + JSON.stringify(err)) - expect(false).assertEqual(true) - done() - } - return render - } - - async function renderStart(render, done) { - try { - await render.start() - console.log("renderStart success.") - } catch (err) { - await renderRelease(render, done) - console.log("renderStart err:" + JSON.stringify(err)) - expect(false).assertEqual(true) - done() - } - } - - async function renderRelease(render, done) { - if (render.state == audio.AudioState.STATE_RELEASED) { - console.log("renderRelease render state: " + render.state) - return - } - try { - await render.release() - console.log("renderRelease success.") - } catch (err) { - console.log("renderRelease err:" + JSON.stringify(err)) - expect(false).assertEqual(true) - done() - } - } - - async function createAudioCapturer(AudioCapturerInfo, AudioStreamInfo, done) { - console.info('createAudioCapturer come in ') - - - let capturer = null; - - var AudioCapturerOptions = { - streamInfo: AudioStreamInfo, - capturerInfo: AudioCapturerInfo - } - try { - capturer = await audio.createAudioCapturer(AudioCapturerOptions) - console.log("createAudioCapturer success.") - } catch (err) { - console.log("createAudioCapturer err:" + JSON.stringify(err)) - expect(false).assertEqual(true) - done() - } - return capturer - } - - async function capturerStart(capturer, done) { - console.info('capturerStart come in') - try { - await capturer.start() - console.log("capturerStart success.") - } catch (err) { - await capturerRelease(capturer, done) - console.log("capturerStart err:" + JSON.stringify(err)) - expect(false).assertEqual(true) - done() - } - } - - async function capturerStartFail(capturer, done, capturer1) { - try { - await capturer.start() - console.log("capturerStartFail success.") - } catch (err) { - console.log("capturerStartFail err:" + JSON.stringify(err)) - await capturerRelease(capturer, done) - await capturerRelease(capturer1, done) - expect(true).assertEqual(true) - done() - } - } - - async function capturerRelease(capturer, done) { - if (capturer.state == audio.AudioState.STATE_RELEASED) { - console.log("capturerRelease current state: " + capturer.state) - return - } - try { - await capturer.release() - console.log("capturerRelease success.") - } catch (err) { - console.log("capturerRelease err:" + JSON.stringify(err)) - expect(false).assertEqual(true) - done() - } - } - - function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001 - *@tc.name : AudioCapturer MIC INTERRUPT MIC - *@tc.desc : AudioCapturer MIC INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001', 0, async function (done) { - try { - let flag1 = false; - let flag2 = false; - console.info('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001 come in ') - console.info('capturerInfo[MIC] is ' + capturerInfo['MIC'] + 'streamInfo[16000]' + streamInfo['16000']) - let capture1 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - - console.info('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001 capture1 is ' + capture1) - await capturerStart(capture1, done) - capture1.on("audioInterrupt", async (eventAction) => { - flag1 = true; - console.log("01 capture1.eventAction:" + JSON.stringify(eventAction)) - }) - - let capture2 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - console.info('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001 capture2 is ' + capture2) - - await capturerStartFail(capture2, done, capture1) - capture2.on("audioInterrupt", async (eventAction) => { - flag2 = true; - console.log("01 capture2.eventAction:" + JSON.stringify(eventAction)) - }) - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture1, done) - await capturerRelease(capture2, done) - done() - } - catch (err) { - console.info('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001 err is ' + err.message) - } - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_002 - *@tc.name : AudioCapturer VOICE_RECOGNITION INTERRUPT MIC - *@tc.desc : AudioCapturer VOICE_RECOGNITION INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_002', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture1 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture1, done) - capture1.on("audioInterrupt", async (eventAction) => { - flag1 = true; - console.log("02 capture1.eventAction:" + JSON.stringify(eventAction)) - }) - - let capture2 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStartFail(capture2, done, capture1) - capture2.on("audioInterrupt", async (eventAction) => { - flag2 = true; - console.log("02 capture2.eventAction:" + JSON.stringify(eventAction)) - }) - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture1, done) - await capturerRelease(capture2, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_003 - *@tc.name : AudioCapturer VOICE_COMMUNICATION INTERRUPT MIC - *@tc.desc : AudioCapturer VOICE_COMMUNICATION INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_003', 0, async function (done) { - - let capture1 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture1, done) - capture1.on("audioInterrupt", async (eventAction) => { - console.log("03 capture1.eventAction:" + JSON.stringify(eventAction)) - expect(eventAction.hintType).assertEqual(audio.InterruptHint.INTERRUPT_HINT_STOP) - }) - - let capture2 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture2, done) - await sleep(500) - await capturerRelease(capture2, done) - await capturerRelease(capture1, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_004 - *@tc.name : AudioCapturer MUSIC INTERRUPT MIC - *@tc.desc : AudioCapturer MUSIC INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_004', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("04 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['MUSIC'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("04 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_005 - *@tc.name : AudioCapturer VOICE_CALL INTERRUPT MIC - *@tc.desc : AudioCapturer VOICE_CALL INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_005', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("05 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['VOICE_CALL'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("05 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_006 - *@tc.name : AudioCapturer RING INTERRUPT MIC - *@tc.desc : AudioCapturer RING INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_006', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("06 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['RING'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("06 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_007 - *@tc.name : AudioCapturer VOICE_ASSISTANT INTERRUPT MIC - *@tc.desc : AudioCapturer VOICE_ASSISTANT INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_007', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("07 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['VOICE_ASSISTANT'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("07 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_009 - *@tc.name : AudioCapturer ALARM INTERRUPT MIC - *@tc.desc : AudioCapturer ALARM INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_009', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("10 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['ALARM'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("10 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_010 - *@tc.name : AudioCapturer ACCESSIBILITY INTERRUPT MIC - *@tc.desc : AudioCapturer ACCESSIBILITY INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_010', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("09 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['ACCESSIBILITY'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("09 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0011 - *@tc.name : AudioCapturer SPEECH INTERRUPT MIC - *@tc.desc : AudioCapturer SPEECH INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0011', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("31 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['SPEECH'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("31 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0012 - *@tc.name : AudioCapturer MOVIE INTERRUPT MIC - *@tc.desc : AudioCapturer MOVIE INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0012', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("32 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['MOVIE'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("32 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0013 - *@tc.name : AudioCapturer UNKNOW INTERRUPT MIC - *@tc.desc : AudioCapturer UNKNOW INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0013', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("33 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['UNKNOW'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("33 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0014 - *@tc.name : AudioCapturer MIC INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer MIC INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0014', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture1 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture1, done) - capture1.on("audioInterrupt", async (eventAction) => { - flag1 = true; - console.log("11 capture1.eventAction:" + JSON.stringify(eventAction)) - }) - - let capture2 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStartFail(capture2, done, capture1) - capture2.on("audioInterrupt", async (eventAction) => { - flag2 = true; - console.log("11 capture2.eventAction:" + JSON.stringify(eventAction)) - }) - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture1, done) - await capturerRelease(capture2, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_015 - *@tc.name : AudioCapturer VOICE_RECOGNITION INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer VOICE_RECOGNITION INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_015', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture1 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture1, done) - capture1.on("audioInterrupt", async (eventAction) => { - flag1 = true; - console.log("12 capture1.eventAction:" + JSON.stringify(eventAction)) - }) - - let capture2 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStartFail(capture2, done, capture1) - capture2.on("audioInterrupt", async (eventAction) => { - flag2 = true; - console.log("12 capture2.eventAction:" + JSON.stringify(eventAction)) - }) - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture1, done) - await capturerRelease(capture2, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_016 - *@tc.name : AudioCapturer VOICE_COMMUNICATION INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer VOICE_COMMUNICATION INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_016', 0, async function (done) { - let capture1 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture1, done) - capture1.on("audioInterrupt", async (eventAction) => { - console.log("20 capture1.eventAction:" + JSON.stringify(eventAction)) - expect(eventAction.hintType).assertEqual(audio.InterruptHint.INTERRUPT_HINT_STOP) - }) - - let capture2 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture2, done) - await sleep(500) - await capturerRelease(capture2, done) - await capturerRelease(capture1, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_017 - *@tc.name : AudioCapturer MUSIC INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer MUSIC INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_017', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("13 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['MUSIC'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("13 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_018 - *@tc.name : AudioCapturer VOICE_CALL INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer VOICE_CALL INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_018', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("14 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['VOICE_CALL'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("14 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_019 - *@tc.name : AudioCapturer RING INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer RING INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_019', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("15 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['RING'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("15 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_020 - *@tc.name : AudioCapturer VOICE_ASSISTANT INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer VOICE_ASSISTANT INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_020', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("16 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['VOICE_ASSISTANT'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("16 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_022 - *@tc.name : AudioCapturer ALARM INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer ALARM INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_022', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("19 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['ALARM'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("19 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_023 - *@tc.name : AudioCapturer MIC INTERRUPT MIC - *@tc.desc : AudioCapturer MIC INTERRUPT MIC - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_023', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("18 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['ACCESSIBILITY'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("18 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_024 - *@tc.name : AudioCapturer SPEECH INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer SPEECH INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_024', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("34 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['SPEECH'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("34 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_025 - *@tc.name : AudioCapturer MOVIE INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer MOVIE INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_025', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("35 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['MOVIE'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("35 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_026 - *@tc.name : AudioCapturer UNKNOW INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer UNKNOW INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_026', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("36 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['UNKNOW'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("36 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_027 - *@tc.name : AudioCapturer MIC INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer MIC INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_027', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture1 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture1, done) - capture1.on("audioInterrupt", async (eventAction) => { - flag1 = true; - console.log("021 capture1.eventAction:" + JSON.stringify(eventAction)) - }) - - let capture2 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - await capturerStartFail(capture2, done, capture1) - capture2.on("audioInterrupt", async (eventAction) => { - flag2 = true; - console.log("021 capture2.eventAction:" + JSON.stringify(eventAction)) - }) - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture1, done) - await capturerRelease(capture2, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_028 - *@tc.name : AudioCapturer VOICE_RECOGNITION INTERRUPT VOICE_RECOGNITION - *@tc.desc : AudioCapturer VOICE_RECOGNITION INTERRUPT VOICE_RECOGNITION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_028', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture1 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture1, done) - capture1.on("audioInterrupt", async (eventAction) => { - flag1 = true; - console.log("22 capture1.eventAction:" + JSON.stringify(eventAction)) - }) - - let capture2 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - await capturerStartFail(capture2, done, capture1) - capture2.on("audioInterrupt", async (eventAction) => { - flag2 = true; - console.log("22 capture2.eventAction:" + JSON.stringify(eventAction)) - }) - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture1, done) - await capturerRelease(capture2, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_029 - *@tc.name : AudioCapturer VOICE_COMMUNICATION INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer VOICE_COMMUNICATION INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_029', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture1 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture1, done) - capture1.on("audioInterrupt", async (eventAction) => { - flag1 = true; - console.log("23 capture1.eventAction:" + JSON.stringify(eventAction)) - }) - - let capture2 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStartFail(capture2, done, capture1) - capture2.on("audioInterrupt", async (eventAction) => { - flag2 = true; - console.log("23 capture2.eventAction:" + JSON.stringify(eventAction)) - }) - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture1, done) - await capturerRelease(capture2, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_030 - *@tc.name : AudioCapturer MUSIC INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer MUSIC INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_030', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("24 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['MUSIC'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("24 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_031 - *@tc.name : AudioCapturer VOICE_CALL INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer VOICE_CALL INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_031', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("25 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['VOICE_CALL'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("25 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_032 - *@tc.name : AudioCapturer RING INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer RING INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_032', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("26 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['RING'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("26 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_033 - *@tc.name : AudioCapturer VOICE_ASSISTANT INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer VOICE_ASSISTANT INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_033', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("27 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['VOICE_ASSISTANT'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("27 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_035 - *@tc.name : AudioCapturer ALARM INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer ALARM INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_035', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("30 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['ALARM'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("30 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_036 - *@tc.name : AudioCapturer ACCESSIBILITY INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer ACCESSIBILITY INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_036', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("29 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['ACCESSIBILITY'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("29 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0037 - *@tc.name : AudioCapturer SPEECH INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer SPEECH INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0037', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("37 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['SPEECH'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("37 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_038 - *@tc.name : AudioCapturer MOVIE INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer MOVIE INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_038', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("38 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['MOVIE'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("38 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - /** - *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_039 - *@tc.name : AudioCapturer UNKNOW INTERRUPT VOICE_COMMUNICATION - *@tc.desc : AudioCapturer UNKNOW INTERRUPT VOICE_COMMUNICATION - *@tc.size : MEDIUM - *@tc.type : Function - *@tc.level : Level 0 - */ - it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_039', 0, async function (done) { - let flag1 = false; - let flag2 = false; - let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - await capturerStart(capture, done) - capture.on("audioInterrupt", async (eventAction) => { - console.log("39 capture.eventAction:" + JSON.stringify(eventAction)) - flag1 = true; - }) - - let render = await createAudioRenderer(renderInfo['UNKNOW'], streamInfo['44100']) - await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - await renderStart(render, done) - render.on("audioInterrupt", async (eventAction) => { - console.log("39 render.eventAction:" + JSON.stringify(eventAction)) - flag2 = true; - }) - - await sleep(500) - expect(flag1 == false && flag2 == false).assertTrue() - await capturerRelease(capture, done) - await renderRelease(render, done) - done() - }) - - // it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_008', 0, async function (done) { - // let flag1 = false; - // let flag2 = false; - // let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) - // await capturerStart(capture, done) - // capture.on("audioInterrupt", async (eventAction) => { - // console.log("08 capture.eventAction:" + JSON.stringify(eventAction)) - // flag1 = true; - // }) - - // let render = await createAudioRenderer(renderInfo['ULTRASONIC'], streamInfo['44100']) - // await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - // await renderStart(render, done) - // render.on("audioInterrupt", async (eventAction) => { - // console.log("08 render.eventAction:" + JSON.stringify(eventAction)) - // flag2 = true; - // }) - - // await sleep(500) - // console.info('flag1 is '+ flag1); - // console.info('flag2 is '+ flag2); - // expect(flag1 == false && flag2 == false).assertTrue() - // await capturerRelease(capture, done) - // await renderRelease(render, done) - // done() - // }) - - // it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_021', 0, async function (done) { - // let flag1 = false; - // let flag2 = false; - // let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) - // await capturerStart(capture, done) - // capture.on("audioInterrupt", async (eventAction) => { - // console.log("17 capture.eventAction:" + JSON.stringify(eventAction)) - // flag1 = true; - // }) - - // let render = await createAudioRenderer(renderInfo['ULTRASONIC'], streamInfo['44100']) - // await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - // await renderStart(render, done) - // render.on("audioInterrupt", async (eventAction) => { - // console.log("17 render.eventAction:" + JSON.stringify(eventAction)) - // flag2 = true; - // }) - - // await sleep(500) - // expect(flag1 == false && flag2 == false).assertTrue() - // await capturerRelease(capture, done) - // await renderRelease(render, done) - // done() - // }) - - // it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_034', 0, async function (done) { - // let flag1 = false; - // let flag2 = false; - // let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) - // await capturerStart(capture, done) - // capture.on("audioInterrupt", async (eventAction) => { - // console.log("28 capture.eventAction:" + JSON.stringify(eventAction)) - // flag1 = true; - // }) - - // let render = await createAudioRenderer(renderInfo['ULTRASONIC'], streamInfo['44100']) - // await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) - // await renderStart(render, done) - // render.on("audioInterrupt", async (eventAction) => { - // console.log("08 render.eventAction:" + JSON.stringify(eventAction)) - // flag2 = true; - // }) - - // await sleep(500) - // expect(flag1 == false && flag2 == false).assertTrue() - // await capturerRelease(capture, done) - // await renderRelease(render, done) - // done() - // }) - }) -} +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http:// www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import audio from '@ohos.multimedia.audio'; +import featureAbility from '@ohos.ability.featureAbility'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; +import { UiDriver, BY } from '@ohos.UiTest' +export default function audioCapturerInterrupt() { + describe("AudioCapturerInterruptUnitTest", function () { + async function getPermission() { + let permissions = ['ohos.permission.MICROPHONE']; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("request success" + JSON.stringify(data)); + }) + } + async function driveFn() { + console.info(`come in driveFn`); + let driver = await UiDriver.create(); + console.info(`driver is ${JSON.stringify(driver)}`); + await sleep(100); + console.info(`UiDriver start`); + let button = await driver.findComponent(BY.text('允许')); + console.info(`button is ${JSON.stringify(button)}`); + await sleep(100); + await button.click(); + } + + beforeAll(async function () { + // await getPermission(); + // await driveFn(); + console.info('beforeAll called') + }) + + afterAll(function () { + console.info('afterAll called') + }) + + beforeEach(function () { + console.info('beforeEach called') + }) + + afterEach(function () { + console.info('afterEach called') + }) + + let capturerInfo = { + "MIC": { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0, + }, + 'VOICE_RECOGNITION': { + source: audio.SourceType.SOURCE_TYPE_VOICE_RECOGNITION, + capturerFlags: 0, + }, + 'VOICE_COMMUNICATION': { + source: audio.SourceType.SOURCE_TYPE_VOICE_COMMUNICATION, + capturerFlags: 0, + } + } + + let renderInfo = { + 'MUSIC': { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0, + }, + 'VOICE_CALL': { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + }, + 'RINGTONE': { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0, + }, + 'VOICE_ASSISTANT': { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + }, + 'ULTRASONIC': { + content: audio.ContentType.CONTENT_TYPE_ULTRASONIC, + usage: audio.StreamUsage.STREAM_USAGE_SYSTEM, + rendererFlags: 0 + }, + 'ALARM': { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_ALARM, + rendererFlags: 0 + }, + 'ACCESSIBILITY': { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, + rendererFlags: 0 + }, + 'SPEECH': { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + }, + 'MOVIE': { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + }, + 'UNKNOW': { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 0 + }, + } + + let streamInfo = { + '16000': { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_16000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + '44100': { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + '48000': { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + } + + async function createAudioRenderer(AudioRendererInfo, AudioStreamInfo, done) { + let render = null; + + var AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try { + render = await audio.createAudioRenderer(AudioRendererOptions) + console.log("createAudioRenderer success.") + } catch (err) { + console.log("createAudioRenderer err:" + JSON.stringify(err)) + expect(false).assertEqual(true) + done() + } + return render + } + + async function renderStart(render, done) { + try { + await render.start() + console.log("renderStart success.") + } catch (err) { + await renderRelease(render, done) + console.log("renderStart err:" + JSON.stringify(err)) + expect(false).assertEqual(true) + done() + } + } + + async function renderRelease(render, done) { + if (render.state == audio.AudioState.STATE_RELEASED) { + console.log("renderRelease render state: " + render.state) + return + } + try { + await render.release() + console.log("renderRelease success.") + } catch (err) { + console.log("renderRelease err:" + JSON.stringify(err)) + expect(false).assertEqual(true) + done() + } + } + + async function createAudioCapturer(AudioCapturerInfo, AudioStreamInfo, done) { + console.info('createAudioCapturer come in ') + + + let capturer = null; + + var AudioCapturerOptions = { + streamInfo: AudioStreamInfo, + capturerInfo: AudioCapturerInfo + } + try { + capturer = await audio.createAudioCapturer(AudioCapturerOptions) + console.log("createAudioCapturer success.") + } catch (err) { + console.log("createAudioCapturer err:" + JSON.stringify(err)) + expect(false).assertEqual(true) + done() + } + return capturer + } + + async function capturerStart(capturer, done) { + console.info('capturerStart come in') + try { + await capturer.start() + console.log("capturerStart success.") + } catch (err) { + await capturerRelease(capturer, done) + console.log("capturerStart err:" + JSON.stringify(err)) + expect(false).assertEqual(true) + done() + } + } + + async function capturerStartFail(capturer, done, capturer1) { + try { + await capturer.start() + console.log("capturerStartFail success.") + } catch (err) { + console.log("capturerStartFail err:" + JSON.stringify(err)) + await capturerRelease(capturer, done) + await capturerRelease(capturer1, done) + expect(true).assertEqual(true) + done() + } + } + + async function capturerRelease(capturer, done) { + if (capturer.state == audio.AudioState.STATE_RELEASED) { + console.log("capturerRelease current state: " + capturer.state) + return + } + try { + await capturer.release() + console.log("capturerRelease success.") + } catch (err) { + console.log("capturerRelease err:" + JSON.stringify(err)) + expect(false).assertEqual(true) + done() + } + } + + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001 + *@tc.name : AudioCapturer MIC INTERRUPT MIC + *@tc.desc : AudioCapturer MIC INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001', 0, async function (done) { + try { + let flag1 = false; + let flag2 = false; + console.info('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001 come in ') + console.info('capturerInfo[MIC] is ' + capturerInfo['MIC'] + 'streamInfo[16000]' + streamInfo['16000']) + let capture1 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + + console.info('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001 capture1 is ' + capture1) + await capturerStart(capture1, done) + capture1.on("audioInterrupt", async (eventAction) => { + flag1 = true; + console.log("01 capture1.eventAction:" + JSON.stringify(eventAction)) + }) + + let capture2 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + console.info('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001 capture2 is ' + capture2) + + await capturerStartFail(capture2, done, capture1) + capture2.on("audioInterrupt", async (eventAction) => { + flag2 = true; + console.log("01 capture2.eventAction:" + JSON.stringify(eventAction)) + }) + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture1, done) + await capturerRelease(capture2, done) + done() + } + catch (err) { + console.info('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_001 err is ' + err.message) + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_002 + *@tc.name : AudioCapturer VOICE_RECOGNITION INTERRUPT MIC + *@tc.desc : AudioCapturer VOICE_RECOGNITION INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_002', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture1 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture1, done) + capture1.on("audioInterrupt", async (eventAction) => { + flag1 = true; + console.log("02 capture1.eventAction:" + JSON.stringify(eventAction)) + }) + + let capture2 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStartFail(capture2, done, capture1) + capture2.on("audioInterrupt", async (eventAction) => { + flag2 = true; + console.log("02 capture2.eventAction:" + JSON.stringify(eventAction)) + }) + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture1, done) + await capturerRelease(capture2, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_003 + *@tc.name : AudioCapturer VOICE_COMMUNICATION INTERRUPT MIC + *@tc.desc : AudioCapturer VOICE_COMMUNICATION INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_003', 0, async function (done) { + + let capture1 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture1, done) + capture1.on("audioInterrupt", async (eventAction) => { + console.log("03 capture1.eventAction:" + JSON.stringify(eventAction)) + expect(eventAction.hintType).assertEqual(audio.InterruptHint.INTERRUPT_HINT_STOP) + }) + + let capture2 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture2, done) + await sleep(500) + await capturerRelease(capture2, done) + await capturerRelease(capture1, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_004 + *@tc.name : AudioCapturer MUSIC INTERRUPT MIC + *@tc.desc : AudioCapturer MUSIC INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_004', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("04 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['MUSIC'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("04 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_005 + *@tc.name : AudioCapturer VOICE_CALL INTERRUPT MIC + *@tc.desc : AudioCapturer VOICE_CALL INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_005', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("05 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['VOICE_CALL'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("05 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_006 + *@tc.name : AudioCapturer RING INTERRUPT MIC + *@tc.desc : AudioCapturer RING INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_006', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("06 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['RING'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("06 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_007 + *@tc.name : AudioCapturer VOICE_ASSISTANT INTERRUPT MIC + *@tc.desc : AudioCapturer VOICE_ASSISTANT INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_007', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("07 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['VOICE_ASSISTANT'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("07 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_009 + *@tc.name : AudioCapturer ALARM INTERRUPT MIC + *@tc.desc : AudioCapturer ALARM INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_009', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("10 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['ALARM'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("10 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_010 + *@tc.name : AudioCapturer ACCESSIBILITY INTERRUPT MIC + *@tc.desc : AudioCapturer ACCESSIBILITY INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_010', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("09 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['ACCESSIBILITY'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("09 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0011 + *@tc.name : AudioCapturer SPEECH INTERRUPT MIC + *@tc.desc : AudioCapturer SPEECH INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0011', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("31 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['SPEECH'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("31 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0012 + *@tc.name : AudioCapturer MOVIE INTERRUPT MIC + *@tc.desc : AudioCapturer MOVIE INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0012', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("32 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['MOVIE'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("32 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0013 + *@tc.name : AudioCapturer UNKNOW INTERRUPT MIC + *@tc.desc : AudioCapturer UNKNOW INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0013', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("33 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['UNKNOW'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("33 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0014 + *@tc.name : AudioCapturer MIC INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer MIC INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0014', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture1 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture1, done) + capture1.on("audioInterrupt", async (eventAction) => { + flag1 = true; + console.log("11 capture1.eventAction:" + JSON.stringify(eventAction)) + }) + + let capture2 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStartFail(capture2, done, capture1) + capture2.on("audioInterrupt", async (eventAction) => { + flag2 = true; + console.log("11 capture2.eventAction:" + JSON.stringify(eventAction)) + }) + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture1, done) + await capturerRelease(capture2, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_015 + *@tc.name : AudioCapturer VOICE_RECOGNITION INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer VOICE_RECOGNITION INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_015', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture1 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture1, done) + capture1.on("audioInterrupt", async (eventAction) => { + flag1 = true; + console.log("12 capture1.eventAction:" + JSON.stringify(eventAction)) + }) + + let capture2 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStartFail(capture2, done, capture1) + capture2.on("audioInterrupt", async (eventAction) => { + flag2 = true; + console.log("12 capture2.eventAction:" + JSON.stringify(eventAction)) + }) + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture1, done) + await capturerRelease(capture2, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_016 + *@tc.name : AudioCapturer VOICE_COMMUNICATION INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer VOICE_COMMUNICATION INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_016', 0, async function (done) { + let capture1 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture1, done) + capture1.on("audioInterrupt", async (eventAction) => { + console.log("20 capture1.eventAction:" + JSON.stringify(eventAction)) + expect(eventAction.hintType).assertEqual(audio.InterruptHint.INTERRUPT_HINT_STOP) + }) + + let capture2 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture2, done) + await sleep(500) + await capturerRelease(capture2, done) + await capturerRelease(capture1, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_017 + *@tc.name : AudioCapturer MUSIC INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer MUSIC INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_017', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("13 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['MUSIC'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("13 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_018 + *@tc.name : AudioCapturer VOICE_CALL INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer VOICE_CALL INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_018', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("14 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['VOICE_CALL'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("14 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_019 + *@tc.name : AudioCapturer RING INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer RING INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_019', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("15 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['RING'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("15 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_020 + *@tc.name : AudioCapturer VOICE_ASSISTANT INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer VOICE_ASSISTANT INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_020', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("16 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['VOICE_ASSISTANT'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("16 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_022 + *@tc.name : AudioCapturer ALARM INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer ALARM INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_022', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("19 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['ALARM'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("19 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_023 + *@tc.name : AudioCapturer MIC INTERRUPT MIC + *@tc.desc : AudioCapturer MIC INTERRUPT MIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_023', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("18 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['ACCESSIBILITY'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("18 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_024 + *@tc.name : AudioCapturer SPEECH INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer SPEECH INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_024', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("34 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['SPEECH'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("34 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_025 + *@tc.name : AudioCapturer MOVIE INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer MOVIE INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_025', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("35 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['MOVIE'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("35 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_026 + *@tc.name : AudioCapturer UNKNOW INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer UNKNOW INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_026', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("36 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['UNKNOW'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("36 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_027 + *@tc.name : AudioCapturer MIC INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer MIC INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_027', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture1 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture1, done) + capture1.on("audioInterrupt", async (eventAction) => { + flag1 = true; + console.log("021 capture1.eventAction:" + JSON.stringify(eventAction)) + }) + + let capture2 = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + await capturerStartFail(capture2, done, capture1) + capture2.on("audioInterrupt", async (eventAction) => { + flag2 = true; + console.log("021 capture2.eventAction:" + JSON.stringify(eventAction)) + }) + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture1, done) + await capturerRelease(capture2, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_028 + *@tc.name : AudioCapturer VOICE_RECOGNITION INTERRUPT VOICE_RECOGNITION + *@tc.desc : AudioCapturer VOICE_RECOGNITION INTERRUPT VOICE_RECOGNITION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_028', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture1 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture1, done) + capture1.on("audioInterrupt", async (eventAction) => { + flag1 = true; + console.log("22 capture1.eventAction:" + JSON.stringify(eventAction)) + }) + + let capture2 = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + await capturerStartFail(capture2, done, capture1) + capture2.on("audioInterrupt", async (eventAction) => { + flag2 = true; + console.log("22 capture2.eventAction:" + JSON.stringify(eventAction)) + }) + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture1, done) + await capturerRelease(capture2, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_029 + *@tc.name : AudioCapturer VOICE_COMMUNICATION INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer VOICE_COMMUNICATION INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_029', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture1 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture1, done) + capture1.on("audioInterrupt", async (eventAction) => { + flag1 = true; + console.log("23 capture1.eventAction:" + JSON.stringify(eventAction)) + }) + + let capture2 = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStartFail(capture2, done, capture1) + capture2.on("audioInterrupt", async (eventAction) => { + flag2 = true; + console.log("23 capture2.eventAction:" + JSON.stringify(eventAction)) + }) + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture1, done) + await capturerRelease(capture2, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_030 + *@tc.name : AudioCapturer MUSIC INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer MUSIC INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_030', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("24 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['MUSIC'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("24 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_031 + *@tc.name : AudioCapturer VOICE_CALL INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer VOICE_CALL INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_031', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("25 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['VOICE_CALL'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("25 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_032 + *@tc.name : AudioCapturer RING INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer RING INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_032', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("26 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['RING'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("26 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_033 + *@tc.name : AudioCapturer VOICE_ASSISTANT INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer VOICE_ASSISTANT INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_033', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("27 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['VOICE_ASSISTANT'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("27 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_035 + *@tc.name : AudioCapturer ALARM INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer ALARM INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_035', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("30 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['ALARM'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("30 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_036 + *@tc.name : AudioCapturer ACCESSIBILITY INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer ACCESSIBILITY INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_036', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("29 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['ACCESSIBILITY'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("29 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0037 + *@tc.name : AudioCapturer SPEECH INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer SPEECH INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_0037', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("37 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['SPEECH'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("37 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_038 + *@tc.name : AudioCapturer MOVIE INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer MOVIE INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_038', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("38 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['MOVIE'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("38 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_039 + *@tc.name : AudioCapturer UNKNOW INTERRUPT VOICE_COMMUNICATION + *@tc.desc : AudioCapturer UNKNOW INTERRUPT VOICE_COMMUNICATION + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_039', 0, async function (done) { + let flag1 = false; + let flag2 = false; + let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + await capturerStart(capture, done) + capture.on("audioInterrupt", async (eventAction) => { + console.log("39 capture.eventAction:" + JSON.stringify(eventAction)) + flag1 = true; + }) + + let render = await createAudioRenderer(renderInfo['UNKNOW'], streamInfo['44100']) + await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + await renderStart(render, done) + render.on("audioInterrupt", async (eventAction) => { + console.log("39 render.eventAction:" + JSON.stringify(eventAction)) + flag2 = true; + }) + + await sleep(500) + expect(flag1 == false && flag2 == false).assertTrue() + await capturerRelease(capture, done) + await renderRelease(render, done) + done() + }) + + // it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_008', 0, async function (done) { + // let flag1 = false; + // let flag2 = false; + // let capture = await createAudioCapturer(capturerInfo['MIC'], streamInfo['16000']) + // await capturerStart(capture, done) + // capture.on("audioInterrupt", async (eventAction) => { + // console.log("08 capture.eventAction:" + JSON.stringify(eventAction)) + // flag1 = true; + // }) + + // let render = await createAudioRenderer(renderInfo['ULTRASONIC'], streamInfo['44100']) + // await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + // await renderStart(render, done) + // render.on("audioInterrupt", async (eventAction) => { + // console.log("08 render.eventAction:" + JSON.stringify(eventAction)) + // flag2 = true; + // }) + + // await sleep(500) + // console.info('flag1 is '+ flag1); + // console.info('flag2 is '+ flag2); + // expect(flag1 == false && flag2 == false).assertTrue() + // await capturerRelease(capture, done) + // await renderRelease(render, done) + // done() + // }) + + // it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_021', 0, async function (done) { + // let flag1 = false; + // let flag2 = false; + // let capture = await createAudioCapturer(capturerInfo['VOICE_RECOGNITION'], streamInfo['16000']) + // await capturerStart(capture, done) + // capture.on("audioInterrupt", async (eventAction) => { + // console.log("17 capture.eventAction:" + JSON.stringify(eventAction)) + // flag1 = true; + // }) + + // let render = await createAudioRenderer(renderInfo['ULTRASONIC'], streamInfo['44100']) + // await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + // await renderStart(render, done) + // render.on("audioInterrupt", async (eventAction) => { + // console.log("17 render.eventAction:" + JSON.stringify(eventAction)) + // flag2 = true; + // }) + + // await sleep(500) + // expect(flag1 == false && flag2 == false).assertTrue() + // await capturerRelease(capture, done) + // await renderRelease(render, done) + // done() + // }) + + // it('SUB_MULTIMEDIA_AUDIO_CAPTURER_INTERRUPT_TEST_034', 0, async function (done) { + // let flag1 = false; + // let flag2 = false; + // let capture = await createAudioCapturer(capturerInfo['VOICE_COMMUNICATION'], streamInfo['16000']) + // await capturerStart(capture, done) + // capture.on("audioInterrupt", async (eventAction) => { + // console.log("28 capture.eventAction:" + JSON.stringify(eventAction)) + // flag1 = true; + // }) + + // let render = await createAudioRenderer(renderInfo['ULTRASONIC'], streamInfo['44100']) + // await render.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE) + // await renderStart(render, done) + // render.on("audioInterrupt", async (eventAction) => { + // console.log("08 render.eventAction:" + JSON.stringify(eventAction)) + // flag2 = true; + // }) + + // await sleep(500) + // expect(flag1 == false && flag2 == false).assertTrue() + // await capturerRelease(capture, done) + // await renderRelease(render, done) + // done() + // }) + }) +} diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioPlaybackCapturer.test.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioPlaybackCapturer.test.js new file mode 100644 index 0000000000000000000000000000000000000000..58d07bb908967419da54c243cba1524f0ad3f2c2 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/AudioPlaybackCapturer.test.js @@ -0,0 +1,420 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http:// www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import audio from '@ohos.multimedia.audio'; +import fileio from '@ohos.fileio'; +import featureAbility from '@ohos.ability.featureAbility'; +import resourceManager from '@ohos.resourceManager'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; +import { UiDriver, BY } from '@ohos.UiTest' +export default function audioCapturer() { + + describe('AudioPlaybackCapturer', function () { + let Tag = 'AudioPlaybackCapturerTest'; + let fdRead; + let readPath; + let fdPath; + let filePath; + let dirPath; + const LE24 = -1; + const LE32 = -1; + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + async function getPermission() { + let permissions = ['ohos.permission.MICROPHONE']; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("request success" + JSON.stringify(data)); + }) + } + async function driveFn() { + console.info(`come in driveFn`); + let driver = await UiDriver.create(); + console.info(`driver is ${JSON.stringify(driver)}`); + await sleep(100); + console.info(`UiDriver start`); + let button = await driver.findComponent(BY.text('允许')); + console.info(`button is ${JSON.stringify(button)}`); + await sleep(100); + await button.click(); + } + beforeAll(async function () { + await getPermission(); + await driveFn(); + console.info('TestLog: Start Testing AudioPlaybackCapturer Interfaces'); + }) + + beforeEach(async function () { + console.info(`${Tag} AudioFrameworkTest: beforeEach: Prerequisites at the test case level`); + await sleep(1000); + }) + + afterEach(function () { + console.info(`${Tag} AudioFrameworkTest: afterEach: Test case-level clearance conditions`); + }) + + afterAll(function () { + console.info(`${Tag} AudioFrameworkTest: afterAll: Test suite-level cleanup condition`); + }) + async function closeFileDescriptor(fileName) { + await resourceManager.getResourceManager().then(async (mgr) => { + await mgr.closeRawFileDescriptor(fileName).then(value => { + console.log(`${Tag}:case closeRawFileDescriptor success for file:${fileName}`); + }).catch(error => { + console.log(`${Tag}:case closeRawFileDescriptor err: ${error}`); + }); + }); + } + async function getFd(fileName) { + let context = await featureAbility.getContext(); + await context.getFilesDir().then((data) => { + dirPath = data + '/' + fileName; + console.info(`${Tag} case2 dirPath is ${JSON.stringify(dirPath)}`); + }) + } + + async function getFdRead(pathName, done) { + let context = await featureAbility.getContext(); + console.info(`case0 context is : ${context}`); + await context.getFilesDir().then((data) => { + console.info(`case1 getFilesDir is path : ${data}`); + filePath = data + '/' + pathName; + console.info(`case4 filePath is : ${filePath}`); + + }) + fdPath = 'fd://'; + await fileio.open(filePath).then((fdNumber) => { + fdPath = fdPath + '' + fdNumber; + fdRead = fdNumber; + console.info(`[fileIO]case open fd success,fdPath is : ${fdPath}`); + console.info(`[fileIO]case open fd success,fdRead is : ${fdRead}`); + + }, (err) => { + console.info(`[fileIO]case open fd failed : ${err}`); + }).catch((error) => { + console.info(`[fileIO]case catch open fd error : ${error}`); + }); + } + async function playbackPromise(AudioRendererOptions, pathName) { + let resultFlag = false; + let audioRen; + let isPass = false; + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info(`${Tag}: AudioRender Created : Success : Stream Type: SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: AudioRender Created : ERROR : ${err.message}`); + resultFlag = false; + }); + console.log(`isPass: ${isPass}`); + if (isPass) { + resultFlag = true; + return resultFlag; + } + console.info(`${Tag}: AudioRenderer : STATE : ${audioRen.state}`); + + await audioRen.start().then(() => { + console.info(`${Tag}: renderInstant started :SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: renderInstant start :ERROR : ${err.message}`); + resultFlag = false; + }); + + console.info(`${Tag}: AudioRenderer : STATE : ${audioRen.state}`); + + let bufferSize; + await audioRen.getBufferSize().then((data) => { + console.info(`${Tag}: getBufferSize :SUCCESS ${data}`); + bufferSize = data; + }).catch((err) => { + console.info(`${Tag}: getBufferSize :ERROR : ${err.message}`); + resultFlag = false; + }); + + let ss = fileio.fdopenStreamSync(fdRead, 'r'); + console.info(`${Tag}:case 2:AudioFrameworkRenderLog: File Path: ${ss}`); + let discardHeader = new ArrayBuffer(44); + console.info(`${Tag}:case 2-1:AudioFrameworkRenderLog: File Path: `); + ss.readSync(discardHeader); + console.info(`${Tag}:case 2-2:AudioFrameworkRenderLog: File Path: `); + let totalSize = fileio.fstatSync(fdRead).size; + console.info(`${Tag}:case 3 : AudioFrameworkRenderLog: File totalSize size: ${totalSize}`); + totalSize = totalSize - 44; + console.info(`${Tag}: File size : Removing header: ${totalSize}`); + let rlen = 0; + while (rlen < totalSize / 4) { + let buf = new ArrayBuffer(bufferSize); + rlen += ss.readSync(buf); + console.info(`${Tag}:BufferAudioFramework: bytes read from file: ${rlen}`); + await audioRen.write(buf); + } + + console.info(`${Tag}: Renderer after read`); + + await audioRen.drain().then(() => { + console.info(`${Tag}: Renderer drained : SUCCESS`); + }).catch((err) => { + console.error(`${Tag}: Renderer drain: ERROR : ${err.message}`); + }); + + console.info(`${Tag}: AudioRenderer : STATE : ${audioRen.state}`); + + await audioRen.stop().then(() => { + console.info(`${Tag}: Renderer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Renderer stop:ERROR : ${err.message}`); + }); + + console.info(`${Tag}: AudioRenderer : STATE : ${audioRen.state}`); + + await audioRen.release().then(() => { + console.info(`${Tag}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${Tag}: Renderer release :ERROR : ${err.message}`); + }); + + console.info(`${Tag}: AudioRenderer : STATE : ${audioRen.state}`); + return resultFlag; + } + async function recPromise(AudioCapturerOptions,AudioRendererOptions, pathName,done) { + let audioCap; + try { + audioCap = await audio.createAudioCapturer(AudioCapturerOptions); + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: success`); + } catch (err) { + console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`); + LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE; + LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE; + let sampleFormat = AudioCapturerOptions.streamInfo.sampleFormat; + if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) { + done(); + return; + } + expect(false).assertTrue(); + done(); + return; + } + + try { + let audioParamsGet = await audioCap.getStreamInfo(); + if (audioParamsGet != undefined && audioParamsGet != null) { + console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:${JSON.stringify(audioParamsGet)}`); + } else { + console.info(`${Tag} AudioFrameworkRecLog: audioParamsGet are incorrect,is : ${JSON.stringify(audioParamsGet)}`); + expect(false).assertTrue(); + } + } catch (err) { + console.log(`${Tag} AudioFrameworkRecLog: getStreamInfo :ERROR: ${JSON.stringify(err.message)}`); + expect(false).assertTrue(); + } + + try { + let audioParamsGet = await audioCap.getCapturerInfo(); + if (audioParamsGet != undefined) { + console.info(`${Tag} AudioFrameworkRecLog: Capturer CapturerInfo: ${JSON.stringify(audioParamsGet)}`); + } else { + console.info(`${Tag} AudioFrameworkRecLog: audioParamsGet are incorrect , is : ${JSON.stringify(audioParamsGet)}`); + expect(false).assertTrue(); + } + } catch (err) { + console.log(`${Tag} AudioFrameworkRecLog: CapturerInfo :ERROR: ${JSON.stringify(err.message)}`); + expect(false).assertTrue(); + } + + try { + await audioCap.start(); + console.log(`${Tag} start ok`); + await playbackPromise(AudioRendererOptions, pathName); + + let bufferSize = await audioCap.getBufferSize(); + console.log(`${Tag} bufferSize: ${JSON.stringify(bufferSize)} , dirPath: ${JSON.stringify(dirPath)}`); + let fd = fileio.openSync(dirPath, 0o102, 0o777); + console.log(`${Tag} fd: ${JSON.stringify(fd)}`); + if (fd !== null) { + console.info(`${Tag} AudioFrameworkRecLog: file fd created`); + } + else { + console.info(`${Tag} AudioFrameworkRecLog: Capturer start : ERROR `); + expect(false).assertTrue(); + } + + fd = fileio.openSync(dirPath, 0o2002, 0o666); + console.log(`${Tag} fd-re: ${JSON.stringify(fd)}`); + if (fd !== null) { + console.info(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode :PASS`); + } + else { + console.info(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`); + expect(false).assertTrue(); + } + + let numBuffersToCapture = 45; + while (numBuffersToCapture) { + console.info(`${Tag} AudioFrameworkRecLog: ---------READ BUFFER---------`); + let buffer = await audioCap.read(bufferSize, true); + console.info(`${Tag} AudioFrameworkRecLog: ---------WRITE BUFFER---------`); + let number = fileio.writeSync(fd, buffer); + console.info(`${Tag} AudioFrameworkRecLog:BufferRecLog: data written: ${JSON.stringify(number)}`); + numBuffersToCapture--; + } + console.log(`${Tag} read ok`); + await audioCap.stop(); + console.log(`${Tag} stop ok`); + } catch (err) { + console.log(`${Tag} start-read-stop err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + try { + await audioCap.release(); + console.log(`${Tag} release ok`); + } catch (err) { + console.log(`${Tag} release err: ${JSON.stringify(err)}`); + expect(false).assertTrue(); + } + done(); + } + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_INNER_CAPTURER_PROMISE_0100 + *@tc.name : SOURCE_TYPE_PLAYBACK_CAPTURER_PRIVACY_TYPE_PUBLIC + *@tc.desc : SOURCE_TYPE_PLAYBACK_CAPTURER_PRIVACY_TYPE_PUBLIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_INNER_CAPTURER_PROMISE_0100', 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + } + let audioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_PLAYBACK_CAPTURE, + capturerFlags: 0 + } + let playbackCaptureConfig = { + CaptureFilterOptions: [ + { + usage: audio.StreamUsage.STREAM_USAGE_MEDIA + } + ] + } + let audioCapturerOptions = { + streamInfo: audioStreamInfo, + capturerInfo: audioCapturerInfo, + playbackCaptureConfig: playbackCaptureConfig, + } + + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let AudioRendererInfo = { + + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let AudioPrivacyType = { + privacyType:audio.AudioPrivacyType.PRIVACY_TYPE_PUBLIC + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo, + privacyType : AudioPrivacyType + } + readPath = 'pcm_48ksr_32kbr_2ch.wav' + await getFdRead(readPath, done); + await getFd("capture_js-48000-2C-1S32LE.pcm"); + await recPromise(audioCapturerOptions,AudioRendererOptions,filePath,done); + await sleep(100); + await closeFileDescriptor(readPath); + done(); + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_INNER_CAPTURER_PROMISE_0200 + *@tc.name : SOURCE_TYPE_PLAYBACK_CAPTURER_PRIVACY_TYPE_PUBLIC + *@tc.desc : SOURCE_TYPE_PLAYBACK_CAPTURER_PRIVACY_TYPE_PUBLIC + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_INNER_CAPTURER_PROMISE_0200', 2, async function (done) { + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW, + } + let audioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_PLAYBACK_CAPTURE, + capturerFlags: 0 + } + let playbackCaptureConfig = { + CaptureFilterOptions: [ + { + usage: audio.StreamUsage.STREAM_USAGE_MOVIE + } + ] + } + let audioCapturerOptions = { + streamInfo: audioStreamInfo, + capturerInfo: audioCapturerInfo, + playbackCaptureConfig: playbackCaptureConfig, + } + + let AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let AudioRendererInfo = { + + usage: audio.StreamUsage.STREAM_USAGE_MOVIE, + rendererFlags: 0 + } + let AudioPrivacyType = { + privacyType:audio.AudioPrivacyType.PRIVACY_TYPE_PRIVATE + } + + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo, + privacyType : AudioPrivacyType + } + readPath = 'pcm_48ksr_32kbr_2ch.wav' + await getFdRead(readPath, done); + await getFd("capture_js-44100-2C-1S32LE.pcm"); + await recPromise(audioCapturerOptions,AudioRendererOptions,filePath,done); + await sleep(100); + await closeFileDescriptor(readPath); + done(); + }) + + + + + + + + }) + +} diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/List.test.js b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/List.test.js index a086d3f20a85b4baf2a1a5ef1a327f6e0babaef6..ffd39df8d069482f3a5e41831c8f2489336b53b5 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/List.test.js +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/js/test/List.test.js @@ -1,24 +1,26 @@ -/** - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - import audioCapturer from './AudioCapturer.test.js' - import AudioCapturerInterruptUnitTest from './AudioCapturerInterrupt.test.js' - - export default function testsuite() { - audioCapturer() - AudioCapturerInterruptUnitTest() - } - - +/** + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + import audioCapturer from './AudioCapturer.test.js' + import AudioCapturerInterruptUnitTest from './AudioCapturerInterrupt.test.js' + import AudioPlaybackCapturer from './AudioPlaybackCapturer.test.js' + + export default function testsuite() { + audioCapturer() + AudioCapturerInterruptUnitTest() + AudioPlaybackCapturer() + } + + diff --git a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/resources/base/element/string.json b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/resources/base/element/string.json index 054c46cf82e60c39de9ec845737cdda67a89676d..a4311fdbd2698c510a48ba2b754eb7a868367984 100644 --- a/multimedia/audio/audio_js_standard/AudioCapturer/src/main/resources/base/element/string.json +++ b/multimedia/audio/audio_js_standard/AudioCapturer/src/main/resources/base/element/string.json @@ -1,28 +1,28 @@ -{ - "string": [ - { - "name": "app_name", - "value": "JsHelloWorld" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - }, - { - "name": "MainAbility_desc", - "value": "description" - }, - { - "name": "MainAbility_label", - "value": "label" - }, - { - "name": "TestAbility_desc", - "value": "description" - }, - { - "name": "TestAbility_label", - "value": "label" - } - ] +{ + "string": [ + { + "name": "app_name", + "value": "JsHelloWorld" + }, + { + "name": "mainability_description", + "value": "hap sample empty page" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" + } + ] } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioEffect.test.js b/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioEffect.test.js index ed9415511a292015a24f3e5d0d84ba9f44075756..41c8c917a3120c9950d58acfa1ab2e2aa45091f4 100644 --- a/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioEffect.test.js +++ b/multimedia/audio/audio_js_standard/audioRenderer/src/main/js/test/AudioEffect.test.js @@ -1,4424 +1,4424 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http:// www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import audio from '@ohos.multimedia.audio'; -import fs from '@ohos.file.fs'; -import featureAbility from '@ohos.ability.featureAbility' -import { - describe, - beforeAll, - beforeEach, - afterEach, - afterAll, - it, - expect -} from 'deccjsunit/index'; - -describe('AudioEffect', function () { - let TAG = "[EffectManagerInterfaceTest] "; - let audioStreamManager = audio.getAudioManager().getStreamManager(); - let audioRenderer = null; - let streamNum = 0; - let audioRendererList = []; - let audioRendererOptionsList = [] - let audioEffectModeList = []; - let bufferSizeList = []; - let pathDir = ''; - let testCaseName = ''; - let audioPaths = [ - 'pcm_48ksr_32kbr_2ch.wav' - ] - let audioRendererOptions = { - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 - } - } - - beforeAll(async function () { - console.info(TAG + 'TestLog: Start Testing AudioEffectTest Interfaces'); - }) - - beforeEach(async function () { - console.info(TAG + 'AudioEffectTest: beforeEach: Prerequisites at the test case level'); - await sleep(1000); - }) - - afterEach(async function () { - console.info(TAG + 'AudioEffectTest: afterEach: Test case-level clearance conditions'); - }) - - afterAll(async function () { - console.info(TAG + 'AudioEffectTest: afterAll: Test suite-level cleanup condition'); - }) - - function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } - - - - async function getPath() { - console.log(TAG + 'TestLog: Start Testing getPath '); - let context = await featureAbility.getContext() - await context.getFilesDir().then((data) => { - pathDir = data + '/'; - console.log(TAG + testCaseName + `TestLog: Start Testing getPath ${pathDir} `); - }) - } - - - async function createAudioRenderer() { - if (audioRendererList && audioRendererList.length) { - audioRendererList.map(async (audioRenderer, index) => { - console.log(`create audio renderer release index: ${index} length : ${audioRendererList.length}`) - if (audioRendererList[index]) { - await audioRendererList[index].release(); - audioRendererList[index] = null; - } - }) - } - for (let index = 0; index < streamNum; index++) { - console.log(TAG + testCaseName + `create ${JSON.stringify(audioRendererOptionsList[index])} `); - audioRendererList[index] = await audio.createAudioRenderer(audioRendererOptionsList[index]).then((data) => { - console.log(TAG + testCaseName + `create1 ${JSON.stringify(data)} `); - return data - }).catch((err) => { - console.log(TAG + testCaseName + `create Error ${JSON.stringify(err)} `); - }); - console.log(TAG + testCaseName + `create ${JSON.stringify(audioRendererList[index])} `); - console.log(TAG + testCaseName + `TestLog: Start Testing createAudioRenderer create ${index} rendererObj`); - } - } - - function isCheckAudioRendererObj() { - let status = true - for (let index = 0; index < audioRendererList.length; index++) { - console.log('isCheckAudioRendererObj status ' + audioRendererList[index] === null) - console.log('isCheckAudioRendererObj audioRendererList :' + index + audioRendererList[index] + `length : ${audioRendererList.length} `) - if (audioRendererList[index] === null) { - status = false - return status - } - } - return status - } - - - async function setAudioEffectMode(assertFunction, done) { - if (isCheckAudioRendererObj()) { - for (let index = 0; index < audioRendererList.length; index++) { - await audioRendererList[index].setAudioEffectMode(audioEffectModeList[index]).then(() => { - console.log(TAG + testCaseName + `setAudioEffectMode audioRendererList ${index} success `); - }).catch((err) => { - console.log(TAG + testCaseName + `setAudioEffectMode audioRendererList ${index} failed `); - assertFunction(); - done() - }) - } - } else { - assertFunction(); - done() - } - } - - function isCheckAllWriteSuccess(arr) { - if (Array.isArray(arr) && arr.length > 0) { - return arr.every(v => v === true) - } else { - return false - } - } - - async function start(assertFunction, done) { - let stateGroup = [audio.AudioState.STATE_PREPARED, audio.AudioState.STATE_PAUSED, audio.AudioState.STATE_STOPPED] - if (isCheckAudioRendererObj()) { - for (let index = 0; index < audioRendererList.length; index++) { - console.log('current audio renderer state : ' + audioRendererList[index].state) - if (stateGroup.indexOf(audioRendererList[index].state) === -1) { - console.log(TAG + testCaseName + `start state ${index} faile `); - assertFunction(); - done() - } else { - await audioRendererList[index].start().then(() => { - console.log(TAG + testCaseName + `start audioRendererList ${index} success `); - }).catch((err) => { - console.log(TAG + testCaseName + `start audioRendererList ${index} failed `); - assertFunction(); - done() - }) - } - } - } else { - console.log('start is isCheckAudioRendererObj Fail') - assertFunction(); - done() - } - } - - async function writeRender(assertFunction, done) { - console.log(TAG + ' writeRender start'); - if (isCheckAudioRendererObj()) { - await Promise.all(audioRendererList.map((item, index) => asyncWriteFunc(index))).then((resArray) => { - console.log(TAG + testCaseName + `writeRender end ${JSON.stringify(resArray)}`) - if (isCheckAllWriteSuccess(resArray)) { - console.log(TAG + testCaseName + `all write render success ; status ${JSON.stringify(resArray)}`) - } else { - console.log(TAG + testCaseName + `all write render fail ; status ${JSON.stringify(resArray)}`) - assertFunction() - done() - } - }).catch((errArray) => { - console.log(TAG + testCaseName + `writeRender error ${JSON.stringify(errArray)}`) - console.log(TAG + testCaseName + `all write render fail ; status ${JSON.stringify(errArray)}`) - assertFunction() - done() - }) - } else { - assertFunction(); - done() - } - } - - function asyncWriteFunc(index) { - return new Promise(async (resolve, reject) => { - let bfsize = 0; - let sr = audioRendererOptionsList[index].streamInfo.samplingRate; - let chn = audioRendererOptionsList[index].streamInfo.channels; - bufferSizeList[index] = await audioRendererList[index].getBufferSize() - console.log(TAG + testCaseName + `getBufferSize audioRendererList ${index} ${bufferSizeList[index]} SUCCESS`); - let path = pathDir + audioPaths[index] - console.log(TAG + testCaseName + `audio path ${path} `); - try { - console.log(TAG + testCaseName + 'fs start'); - let stat = await fs.stat(path); - console.log(TAG + testCaseName + "fs stat SUCCESS"); - let len = stat.size % bufferSizeList[index] == 0 ? Math.floor(stat.size / bufferSizeList[index]) : Math.floor(stat.size / bufferSizeList[index] + 1); - console.log(TAG + testCaseName + `len ${len}`); - let file = await fs.open(path, 0o0); - console.log(TAG + testCaseName + "open SUCCESS"); - let buf = new ArrayBuffer(bufferSizeList[index]); - while (true) { - for (let i = 0; i < len; i++) { - let options = { - offset: i * bufferSizeList[index], - length: bufferSizeList[index] - } - let readsize = await fs.read(file.fd, buf, options); - let time = Date.now(); - let writeSize = await new Promise((resolve, reject) => { - audioRendererList[index].write(buf, (err, writeSize) => { - time = Date.now(); - if (err) { - reject(err) - } else { - resolve(writeSize) - } - }) - }) - } - break - } - console.log(TAG + testCaseName + "writeRender success" + `audioRendererList ${index} write end, state:${audioRendererList[index].state}\n`); - console.log(TAG + testCaseName + "writeRender " + ` file descriptor: ${file.fd} `); - await fs.close(file.fd).then(() => { - console.log(TAG + testCaseName + "writeRender success" + `audioRendererList close success`); - resolve(true) - }).catch((err) => { - console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList close : Error: ${JSON.stringify(err)}\n`); - resolve(false) - }) - } catch (err) { - console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList write : Error: ${JSON.stringify(err)}\n`); - reject(false) - } - }) - } - - async function writeStandRender(index, path, assertFunction, done) { - let bfsize = 0; - let sr = audioRendererOptionsList[index].streamInfo.samplingRate; - let chn = audioRendererOptionsList[index].streamInfo.channels; - bufferSizeList[index] = await audioRendererList[index].getBufferSize() - console.log(TAG + testCaseName + `getBufferSize audioRendererList ${index} ${bufferSizeList[index]} SUCCESS`); - console.log(TAG + testCaseName + `audio path ${path} `); - try { - console.log(TAG + testCaseName + 'fs start'); - let stat = await fs.stat(path); - console.log(TAG + testCaseName + "fs stat SUCCESS"); - let len = stat.size % bufferSizeList[index] == 0 ? Math.floor(stat.size / bufferSizeList[index]) : Math.floor(stat.size / bufferSizeList[index] + 1); - console.log(TAG + testCaseName + `len ${len}`); - let file = await fs.open(path, 0o0); - console.log(TAG + testCaseName + "open SUCCESS"); - let buf = new ArrayBuffer(bufferSizeList[index]); - while (true) { - for (let i = 0; i < len; i++) { - let options = { - offset: i * bufferSizeList[index], - length: bufferSizeList[index] - } - let readsize = await fs.read(file.fd, buf, options); - let time = Date.now(); - let writeSize = await new Promise((resolve, reject) => { - audioRendererList[index].write(buf, (err, writeSize) => { - time = Date.now(); - if (err) { - reject(err) - } else { - resolve(writeSize) - } - }) - }) - } - break - } - console.log(TAG + testCaseName + "writeRender success" + `audioRendererList ${index} write end, state:${audioRendererList[index].state}\n`); - console.log(TAG + testCaseName + "writeRender " + ` file descriptor: ${file.fd} `); - await fs.close(file.fd).then(() => { - console.log(TAG + testCaseName + "writeRender success" + `audioRendererList close success`); - }).catch((err) => { - console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList close : Error: ${JSON.stringify(err)}\n`); - }) - } catch (err) { - console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList write : Error: ${JSON.stringify(err)}\n`); - assertFunction() - done() - } - } - - async function writeRenderChange(assertFunction, done) { - console.log(TAG + ' writeRender start'); - if (isCheckAudioRendererObj()) { - await Promise.all(audioRendererList.map((item, index) => asyncWriteChangeFunc(index))).then((resArray) => { - console.log(TAG + testCaseName + `writeRender end ${JSON.stringify(resArray)}`) - if (isCheckAllWriteSuccess(resArray)) { - console.log(TAG + testCaseName + `all write render success ; status ${JSON.stringify(resArray)}`) - } else { - console.log(TAG + testCaseName + `all write render fail ; status ${JSON.stringify(resArray)}`) - assertFunction() - done() - } - }).catch((errArray) => { - console.log(TAG + testCaseName + `writeRender error ${JSON.stringify(errArray)}`) - console.log(TAG + testCaseName + `all write render fail ; status ${JSON.stringify(errArray)}`) - assertFunction() - done() - }) - } else { - assertFunction(); - done() - } - } - - function asyncWriteChangeFunc(index) { - return new Promise(async (resolve, reject) => { - let bfsize = 0; - let sr = audioRendererOptionsList[index].streamInfo.samplingRate; - let chn = audioRendererOptionsList[index].streamInfo.channels; - bufferSizeList[index] = await audioRendererList[index].getBufferSize() - console.log(TAG + testCaseName + `getBufferSize audioRendererList ${index} ${bufferSizeList[index]} SUCCESS`); - let path = pathDir + audioPaths[index] - console.log(TAG + testCaseName + `audio path ${path} `); - try { - console.log(TAG + testCaseName + 'fs start'); - let stat = await fs.stat(path); - console.log(TAG + testCaseName + "fs stat SUCCESS"); - let len = stat.size % bufferSizeList[index] == 0 ? Math.floor(stat.size / bufferSizeList[index]) : Math.floor(stat.size / bufferSizeList[index] + 1); - console.log(TAG + testCaseName + `len ${len}`); - let file = await fs.open(path, 0o0); - console.log(TAG + testCaseName + "open SUCCESS"); - let buf = new ArrayBuffer(bufferSizeList[index]); - while (true) { - for (let i = 0; i < len; i++) { - if (i === Math.floor(len / 2)) { - if (index === 1) { - await audioRendererList[index].setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE) - } - } - let options = { - offset: i * bufferSizeList[index], - length: bufferSizeList[index] - } - let readsize = await fs.read(file.fd, buf, options); - let time = Date.now(); - let writeSize = await new Promise((resolve, reject) => { - audioRendererList[index].write(buf, (err, writeSize) => { - time = Date.now(); - if (err) { - reject(err) - } else { - resolve(writeSize) - } - }) - }) - } - break - } - console.log(TAG + testCaseName + "writeRender success" + `audioRendererList ${index} write end, state:${audioRendererList[index].state}\n`); - console.log(TAG + testCaseName + "writeRender " + ` file descriptor: ${file.fd} `); - await fs.close(file.fd).then(() => { - console.log(TAG + testCaseName + "writeRender success" + `audioRendererList close success`); - resolve(true) - }).catch((err) => { - console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList close : Error: ${JSON.stringify(err)}\n`); - resolve(false) - }) - } catch (err) { - console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList write : Error: ${JSON.stringify(err)}\n`); - reject(false) - } - }) - - } - - - async function release(assertFunction, done) { - if (isCheckAudioRendererObj()) { - for (let index = 0; index < audioRendererList.length; index++) { - await audioRendererList[index].release() - audioRendererList[index] = null - } - } else { - assertFunction(); - done() - } - } - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0100 - * @tc.name : GET_AUDIOEFFECTINFOARRY - UNKNOWN - Promise - * @tc.desc : GET_AUDIOEFFECTINFOARRY - UNKNOWN - UNKNOWN & UNKNOWN - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0100', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_UNKNOWN).then((audioEffectInfoArray) => { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - }).catch((err) => { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0200 - * @tc.name : GET_AUDIOEFFECTINFOARRY - MEDIA - Promise - * @tc.desc : GET_AUDIOEFFECTINFOARRY - MEDIA - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0200', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_MEDIA).then((audioEffectInfoArray) => { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - }).catch((err) => { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0300 - * @tc.name : GET_AUDIOEFFECTINFOARRY - VOICE_CALL - Promise - * @tc.desc : GET_AUDIOEFFECTINFOARRY - VOICE_CALL - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0300', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION).then((audioEffectInfoArray) => { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - }).catch((err) => { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0400 - * @tc.name : GET_AUDIOEFFECTINFOARRY - RING - Promise - * @tc.desc : GET_AUDIOEFFECTINFOARRY - RING - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0400', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE).then((audioEffectInfoArray) => { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - }).catch((err) => { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0500 - * @tc.name : GET_AUDIOEFFECTINFOARRY - MOVIE - Promise - * @tc.desc : GET_AUDIOEFFECTINFOARRY - MOVIE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0500', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_MEDIA).then((audioEffectInfoArray) => { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - }).catch((err) => { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0600 - * @tc.name : GET_AUDIOEFFECTINFOARRY - MUSIC - Callback - * @tc.desc : GET_AUDIOEFFECTINFOARRY - MUSIC - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0600', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_MUSIC, async (err, audioEffectInfoArray) => { - if (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } else { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - } - }); - - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0700 - * @tc.name : GET_AUDIOEFFECTINFOARRY - ALARM - Callback - * @tc.desc : GET_AUDIOEFFECTINFOARRY - ALARM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0700', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_ALARM, async (err, audioEffectInfoArray) => { - if (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } else { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - } - }); - - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0800 - * @tc.name : GET_AUDIOEFFECTINFOARRY - VOICE_ASSISTANT - Callback - * @tc.desc : GET_AUDIOEFFECTINFOARRY - VOICE_ASSISTANT - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0800', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, async (err, audioEffectInfoArray) => { - if (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } else { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - } - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0900 - * @tc.name : GET_AUDIOEFFECTINFOARRY - ACCESSIBILITY - Callback - * @tc.desc : GET_AUDIOEFFECTINFOARRY - ACCESSIBILITY - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0900', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, async (err, audioEffectInfoArray) => { - if (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } else { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - } - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1000 - * @tc.name : GET_AUDIOEFFECTINFOARRY - VOICE_MESSAGE - Callback - * @tc.desc : GET_AUDIOEFFECTINFOARRY - VOICE_MESSAGE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1000', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_VOICE_MESSAGE, async (err, audioEffectInfoArray) => { - if (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } else { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - } - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1100 - * @tc.name : GET_AUDIOEFFECTINFOARRY - RINGTONE - Callback - * @tc.desc : GET_AUDIOEFFECTINFOARRY - RINGTONE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1100', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_RINGTONE, async (err, audioEffectInfoArray) => { - if (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } else { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - } - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1200 - * @tc.name : GET_AUDIOEFFECTINFOARRY - NOTIFICATION - Callback - * @tc.desc : GET_AUDIOEFFECTINFOARRY - NOTIFICATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1200', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_NOTIFICATION, async (err, audioEffectInfoArray) => { - if (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } else { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - } - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1300 - * @tc.name : GET_AUDIOEFFECTINFOARRY - GAME - Callback - * @tc.desc : GET_AUDIOEFFECTINFOARRY - GAME - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1300', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_GAME, async (err, audioEffectInfoArray) => { - if (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } else { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - } - }); - - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1400 - * @tc.name : GET_AUDIOEFFECTINFOARRY - AUDIOBOOK - Promise - * @tc.desc : GET_AUDIOEFFECTINFOARRY - AUDIOBOOK - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1400', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_AUDIOBOOK).then((audioEffectInfoArray) => { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - }).catch((err) => { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1500 - * @tc.name : GET_AUDIOEFFECTINFOARRY - NAVIGATION - Promise - * @tc.desc : GET_AUDIOEFFECTINFOARRY - NAVIGATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1500', 2, async function (done) { - try { - audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_NAVIGATION).then((audioEffectInfoArray) => { - expect(audioEffectInfoArray[0]).assertEqual(0); - expect(audioEffectInfoArray[1]).assertEqual(1); - console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); - done(); - }).catch((err) => { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - }); - } catch (err) { - console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); - expect(false).asserttrue(); - done(); - } - - }) - - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0100 - * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & UNKNOWN - Promise - * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & UNKNOWN - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0100', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0100 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0200 - * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & MEDIA - Promise - * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & MEDIA - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0200', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0200 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0300 - * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & COMMUNICATION - Promise - * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & COMMUNICATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0300', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0300 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0400 - * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & ASSISTANT - Promise - * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & ASSISTANT - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0400', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0400 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0500 - * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & ALARM - Callback - * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & ALARM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0500', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0500 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: audio.StreamUsage.STREAM_USAGE_ALARM, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0600 - * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & RINGTONE - Callback - * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & RINGTONE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0600', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0600 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0700 - * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & ACCESSIBILITY - Callback - * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & ACCESSIBILITY - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0700', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0700 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0800 - * @tc.name : GET_SET_AudioEffectMode-SPEECH & UNKNOWN - Promise - * @tc.desc : GET_SET_AudioEffectMode-SPEECH & UNKNOWN - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0800', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0800 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0900 - * @tc.name : GET_SET_AudioEffectMode-SPEECH & MEDIA - Promise - * @tc.desc : GET_SET_AudioEffectMode-SPEECH & MEDIA - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0900', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0900 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1000 - * @tc.name : GET_SET_AudioEffectMode-SPEECH & COMMUNICATION - Promise - * @tc.desc : GET_SET_AudioEffectMode-SPEECH & COMMUNICATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1000', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1000 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1100 - * @tc.name : GET_SET_AudioEffectMode-SPEECH & ASSISTANT - Promise - * @tc.desc : GET_SET_AudioEffectMode-SPEECH & ASSISTANT - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1100', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1100 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1200 - * @tc.name : GET_SET_AudioEffectMode-SPEECH & ALARM - Callback - * @tc.desc : GET_SET_AudioEffectMode-SPEECH & ALARM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1200', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1200 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_ALARM, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1300 - * @tc.name : GET_SET_AudioEffectMode-SPEECH & RINGTONE - Callback - * @tc.desc : GET_SET_AudioEffectMode-SPEECH & RINGTONE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1300', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1300 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1400 - * @tc.name : GET_SET_AudioEffectMode-SPEECH & ACCESSIBILITY - Callback - * @tc.desc : GET_SET_AudioEffectMode-SPEECH & ACCESSIBILITY - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1400', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1400 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1500 - * @tc.name : GET_SET_AudioEffectMode-MUSIC & UNKNOWN - Promise - * @tc.desc : GET_SET_AudioEffectMode-MUSIC & UNKNOWN - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1500', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1500 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1600 - * @tc.name : GET_SET_AudioEffectMode-MUSIC & MEDIA - Promise - * @tc.desc : GET_SET_AudioEffectMode-MUSIC & MEDIA - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1600', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1600 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1700 - * @tc.name : GET_SET_AudioEffectMode-MUSIC & COMMUNICATION - Promise - * @tc.desc : GET_SET_AudioEffectMode-MUSIC & COMMUNICATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1700', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1700 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1800 - * @tc.name : GET_SET_AudioEffectMode-MUSIC & ASSISTANT - Promise - * @tc.desc : GET_SET_AudioEffectMode-MUSIC & ASSISTANT - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1800', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1800 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1900 - * @tc.name : GET_SET_AudioEffectMode-MUSIC & ALARM - Callback - * @tc.desc : GET_SET_AudioEffectMode-MUSIC & ALARM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1900', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1900 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_ALARM, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2000 - * @tc.name : GET_SET_AudioEffectMode-MUSIC & RINGTONE - Callback - * @tc.desc : GET_SET_AudioEffectMode-MUSIC & RINGTONE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2000', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2000 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2100 - * @tc.name : GET_SET_AudioEffectMode-MUSIC & ACCESSIBILITY - Callback - * @tc.desc : GET_SET_AudioEffectMode-MUSIC & ACCESSIBILITY - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2100', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2100 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2200 - * @tc.name : GET_SET_AudioEffectMode-MOVIE & UNKNOWN - Promise - * @tc.desc : GET_SET_AudioEffectMode-MOVIE & UNKNOWN - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2200', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2200 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MOVIE, - usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2300 - * @tc.name : GET_SET_AudioEffectMode-MOVIE & MEDIA - Promise - * @tc.desc : GET_SET_AudioEffectMode-MOVIE & MEDIA - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2300', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2300 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MOVIE, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2400 - * @tc.name : GET_SET_AudioEffectMode-MOVIE & COMMUNICATION - Promise - * @tc.desc : GET_SET_AudioEffectMode-MOVIE & COMMUNICATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2400', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2400 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MOVIE, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2500 - * @tc.name : GET_SET_AudioEffectMode-MOVIE & ASSISTANT - Promise - * @tc.desc : GET_SET_AudioEffectMode-MOVIE & ASSISTANT - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2500', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2500 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MOVIE, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2600 - * @tc.name : GET_SET_AudioEffectMode-MOVIE & ALARM - Callback - * @tc.desc : GET_SET_AudioEffectMode-MOVIE & ALARM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2600', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2600 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MOVIE, - usage: audio.StreamUsage.STREAM_USAGE_ALARM, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2700 - * @tc.name : GET_SET_AudioEffectMode-MOVIE & RINGTONE - Callback - * @tc.desc : GET_SET_AudioEffectMode-MOVIE & RINGTONE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2700', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2700 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MOVIE, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2800 - * @tc.name : GET_SET_AudioEffectMode-MOVIE & ACCESSIBILITY - Callback - * @tc.desc : GET_SET_AudioEffectMode-MOVIE & ACCESSIBILITY - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2800', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2800 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_MOVIE, - usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2900 - * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & UNKNOWN - Promise - * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & UNKNOWN - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2900', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2900 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SONIFICATION, - usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3000 - * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & MEDIA - Promise - * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & MEDIA - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3000', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3000 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SONIFICATION, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3100 - * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & COMMUNICATION - Promise - * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & COMMUNICATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3100', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3100 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SONIFICATION, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3200 - * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & ASSISTANT - Promise - * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & ASSISTANT - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3200', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3200 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SONIFICATION, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3300 - * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & ALARM - Callback - * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & ALARM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3300', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3300 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SONIFICATION, - usage: audio.StreamUsage.STREAM_USAGE_ALARM, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3400 - * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & RINGTONE - Callback - * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & RINGTONE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3400', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3400 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SONIFICATION, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3500 - * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & ACCESSIBILITY - Callback - * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & ACCESSIBILITY - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3500', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3500 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_SONIFICATION, - usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3600 - * @tc.name : GET_SET_AudioEffectMode-RINGTONE & UNKNOWN - Promise - * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & UNKNOWN - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3600', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3600 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_RINGTONE, - usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3700 - * @tc.name : GET_SET_AudioEffectMode-RINGTONE & MEDIA - Promise - * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & MEDIA - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3700', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3700 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_RINGTONE, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3800 - * @tc.name : GET_SET_AudioEffectMode-RINGTONE & COMMUNICATION - Promise - * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & COMMUNICATION - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3800', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3800 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_RINGTONE, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3900 - * @tc.name : GET_SET_AudioEffectMode-RINGTONE & ASSISTANT - Promise - * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & ASSISTANT - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3900', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3900 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_RINGTONE, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 1) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { - if (audioEffectMode == 0) { - expect(true).assertTrue(); - console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.release(); - done(); - } - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - }).catch((err) => { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - }) - } - - - }).catch((err) => { - console.log(TAG + "getAudioEffectMode failed" + err.message); - expect(false).assertTrue(); - done(); - }) - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4000 - * @tc.name : GET_SET_AudioEffectMode-RINGTONE & ALARM - Callback - * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & ALARM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4000', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4000 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_RINGTONE, - usage: audio.StreamUsage.STREAM_USAGE_ALARM, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4100 - * @tc.name : GET_SET_AudioEffectMode-RINGTONE & RINGTONE - Callback - * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & RINGTONE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4100', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4100 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_RINGTONE, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4200 - * @tc.name : GET_SET_AudioEffectMode-RINGTONE & ACCESSIBILITY - Callback - * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & ACCESSIBILITY - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4200', 2, async function (done) { - console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4200 come in') - let audioStreamInfo = { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, - channels: audio.AudioChannel.CHANNEL_1, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - } - - let audioRendererInfo = { - content: audio.ContentType.CONTENT_TYPE_RINGTONE, - usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, - rendererFlags: 0 - } - - let audioRendererOptions = { - streamInfo: audioStreamInfo, - rendererInfo: audioRendererInfo - } - - let audioRenderer; - await audio.createAudioRenderer(audioRendererOptions).then((data) => { - audioRenderer = data; - console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); - }).catch((err) => { - console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); - }); - await audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 1) { - console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); - audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { - if (err) { - console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - - } else { - console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); - audioRenderer.getAudioEffectMode((err, effectmode) => { - if (effectmode == 0) { - expect(true).assertTrue(); - console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); - audioRenderer.release(); - done(); - } else { - console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); - expect(false).assertTrue(); - done(); - } - }); - } - - - }); - } else { - console.log(TAG + "getAudioEffectMode failed" + err.message); - done(); - } - }); - - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0100 - * @tc.name : AudioEffect_Play_MUSIC_UNKNOWN - * @tc.desc : AudioEffect_Play_MUSIC - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0100', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0100]' - console.info(TAG + testCaseName + 'start') - streamNum = 1 - audioRendererList = [] - await getPath() - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_UNKNOWN, - usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, - rendererFlags: 0 - } - }] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT - ]; - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - ] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0200 - * @tc.name : AudioEffect_Play_MUSIC - * @tc.desc : AudioEffect_Play_MUSIC - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0200', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0200]' - console.info(TAG + testCaseName + 'start') - streamNum = 1 - audioRendererList = [] - await getPath() - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT - ]; - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - ] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0300 - * @tc.name : AudioEffect_Play_VOICE_CALL - * @tc.desc : AudioEffect_Play_VOICE_CALL - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0300', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0300]' - console.info(TAG + testCaseName + 'start') - streamNum = 1 - audioRendererList = [] - await getPath() - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, - rendererFlags: 0 - } - }] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT - ]; - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - ] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0400 - * @tc.name : AudioEffect_Play_RING - * @tc.desc : AudioEffect_Play_RING - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0400', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0400]' - console.info(TAG + testCaseName + 'start') - streamNum = 1 - audioRendererList = [] - await getPath() - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, - rendererFlags: 0 - } - }] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT - ]; - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - ] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0500 - * @tc.name : AudioEffect_Play_MOVIE - * @tc.desc : AudioEffect_Play_MOVIE - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0500', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0500]' - console.info(TAG + testCaseName + 'start') - streamNum = 1 - audioRendererList = [] - await getPath() - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MOVIE, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT - ]; - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - ] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0600 - * @tc.name : AudioEffect_Play_SPEECH - * @tc.desc : AudioEffect_Play_SPEECH - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0600', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0600]' - console.info(TAG + testCaseName + 'start') - streamNum = 1 - audioRendererList = [] - await getPath() - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT - ]; - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - ] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0700 - * @tc.name : AudioEffect_Play_ALARM - * @tc.desc : AudioEffect_Play_ALARM - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0700', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0700]' - console.info(TAG + testCaseName + 'start') - streamNum = 1 - audioRendererList = [] - await getPath() - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_ALARM, - rendererFlags: 0 - } - }] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT - ]; - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - ] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0800 - * @tc.name : AudioEffect_Play_VOICE_ASSISTANT - * @tc.desc : AudioEffect_Play_VOICE_ASSISTANT - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0800', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0800]' - console.info(TAG + testCaseName + 'start') - streamNum = 1 - audioRendererList = [] - await getPath() - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, - rendererFlags: 0 - } - }] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT - ]; - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - ] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0900 - * @tc.name : AudioEffect_Play_ACCESSIBILITY - * @tc.desc : AudioEffect_Play_ACCESSIBILITY - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0900', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0900]' - console.info(TAG + testCaseName + 'start') - streamNum = 1 - audioRendererList = [] - await getPath() - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_SPEECH, - usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, - rendererFlags: 0 - } - }] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT - ]; - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - ] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - - - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1000 - * @tc.name : AudioEffect_Play_SameStreams_DiffAudioEffectMode - * @tc.desc : AudioEffect_Play_SameStreams_DiffAudioEffectMode - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1000', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1000]' - console.info(TAG + testCaseName + 'start') - streamNum = 2 - audioRendererList = [] - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }, { - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }] - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - 'pcm_48ksr_32kbr_2ch.wav' - ] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT, - audio.AudioEffectMode.EFFECT_NONE, - ]; - await getPath() - audioRendererList = [] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1100 - * @tc.name : AudioEffect_Play_SameStreams_SameAudioEffectMode_EFFECT_NONE - * @tc.desc : AudioEffect_Play_SameStreams_SameAudioEffectMode_EFFECT_NONE - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1100', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1100]' - console.info(TAG + testCaseName + 'start') - streamNum = 2 - audioRendererList = [] - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }, { - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }] - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - 'pcm_48ksr_32kbr_2ch.wav' - ] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_NONE, - audio.AudioEffectMode.EFFECT_NONE, - ]; - await getPath() - audioRendererList = [] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1200 - * @tc.name : AudioEffect_Play_SameStreams_SameAudioEffectMode_EFFECT_DEFAULT - * @tc.desc : AudioEffect_Play_SameStreams_SameAudioEffectMode_EFFECT_DEFAULT - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1200', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1200]' - console.info(TAG + testCaseName + 'start') - streamNum = 2 - audioRendererList = [] - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }, { - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }] - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - 'pcm_48ksr_32kbr_2ch.wav' - - ] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT, - audio.AudioEffectMode.EFFECT_DEFAULT, - ]; - await getPath() - audioRendererList = [] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) - /** - * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1300 - * @tc.name : AudioEffect_Play_DiffStreams_DiffAudioEffectMode - * @tc.desc : AudioEffect_Play_DiffStreams_DiffAudioEffectMode - * @tc.type : Function - * @tc.level : Level 2 - */ - it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1300', 1, async function (done) { - testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1300]' - console.info(TAG + testCaseName + 'start') - streamNum = 2 - audioRendererList = [] - audioRendererOptionsList = [{ - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MUSIC, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }, { - streamInfo: { - samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, - channels: audio.AudioChannel.CHANNEL_2, - sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, - encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW - }, - rendererInfo: { - content: audio.ContentType.CONTENT_TYPE_MOVIE, - usage: audio.StreamUsage.STREAM_USAGE_MEDIA, - rendererFlags: 0 - } - }] - audioPaths = [ - 'StarWars10s-2C-48000-4SW.wav', - 'pcm_48ksr_32kbr_2ch.wav' - ] - audioEffectModeList = [ - audio.AudioEffectMode.EFFECT_DEFAULT, - audio.AudioEffectMode.EFFECT_NONE, - ]; - await getPath() - audioRendererList = [] - console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); - await createAudioRenderer(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); - await setAudioEffectMode(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); - await start(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); - await writeRender(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); - await release(expect().assertFail, done) - console.log(TAG + testCaseName + 'TestLog: Start Testing end'); - done() - }) +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http:// www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import audio from '@ohos.multimedia.audio'; +import fs from '@ohos.file.fs'; +import featureAbility from '@ohos.ability.featureAbility' +import { + describe, + beforeAll, + beforeEach, + afterEach, + afterAll, + it, + expect +} from 'deccjsunit/index'; + +describe('AudioEffect', function () { + let TAG = "[EffectManagerInterfaceTest] "; + let audioStreamManager = audio.getAudioManager().getStreamManager(); + let audioRenderer = null; + let streamNum = 0; + let audioRendererList = []; + let audioRendererOptionsList = [] + let audioEffectModeList = []; + let bufferSizeList = []; + let pathDir = ''; + let testCaseName = ''; + let audioPaths = [ + 'pcm_48ksr_32kbr_2ch.wav' + ] + let audioRendererOptions = { + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + } + + beforeAll(async function () { + console.info(TAG + 'TestLog: Start Testing AudioEffectTest Interfaces'); + }) + + beforeEach(async function () { + console.info(TAG + 'AudioEffectTest: beforeEach: Prerequisites at the test case level'); + await sleep(1000); + }) + + afterEach(async function () { + console.info(TAG + 'AudioEffectTest: afterEach: Test case-level clearance conditions'); + }) + + afterAll(async function () { + console.info(TAG + 'AudioEffectTest: afterAll: Test suite-level cleanup condition'); + }) + + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + + + async function getPath() { + console.log(TAG + 'TestLog: Start Testing getPath '); + let context = await featureAbility.getContext() + await context.getFilesDir().then((data) => { + pathDir = data + '/'; + console.log(TAG + testCaseName + `TestLog: Start Testing getPath ${pathDir} `); + }) + } + + + async function createAudioRenderer() { + if (audioRendererList && audioRendererList.length) { + audioRendererList.map(async (audioRenderer, index) => { + console.log(`create audio renderer release index: ${index} length : ${audioRendererList.length}`) + if (audioRendererList[index]) { + await audioRendererList[index].release(); + audioRendererList[index] = null; + } + }) + } + for (let index = 0; index < streamNum; index++) { + console.log(TAG + testCaseName + `create ${JSON.stringify(audioRendererOptionsList[index])} `); + audioRendererList[index] = await audio.createAudioRenderer(audioRendererOptionsList[index]).then((data) => { + console.log(TAG + testCaseName + `create1 ${JSON.stringify(data)} `); + return data + }).catch((err) => { + console.log(TAG + testCaseName + `create Error ${JSON.stringify(err)} `); + }); + console.log(TAG + testCaseName + `create ${JSON.stringify(audioRendererList[index])} `); + console.log(TAG + testCaseName + `TestLog: Start Testing createAudioRenderer create ${index} rendererObj`); + } + } + + function isCheckAudioRendererObj() { + let status = true + for (let index = 0; index < audioRendererList.length; index++) { + console.log('isCheckAudioRendererObj status ' + audioRendererList[index] === null) + console.log('isCheckAudioRendererObj audioRendererList :' + index + audioRendererList[index] + `length : ${audioRendererList.length} `) + if (audioRendererList[index] === null) { + status = false + return status + } + } + return status + } + + + async function setAudioEffectMode(assertFunction, done) { + if (isCheckAudioRendererObj()) { + for (let index = 0; index < audioRendererList.length; index++) { + await audioRendererList[index].setAudioEffectMode(audioEffectModeList[index]).then(() => { + console.log(TAG + testCaseName + `setAudioEffectMode audioRendererList ${index} success `); + }).catch((err) => { + console.log(TAG + testCaseName + `setAudioEffectMode audioRendererList ${index} failed `); + assertFunction(); + done() + }) + } + } else { + assertFunction(); + done() + } + } + + function isCheckAllWriteSuccess(arr) { + if (Array.isArray(arr) && arr.length > 0) { + return arr.every(v => v === true) + } else { + return false + } + } + + async function start(assertFunction, done) { + let stateGroup = [audio.AudioState.STATE_PREPARED, audio.AudioState.STATE_PAUSED, audio.AudioState.STATE_STOPPED] + if (isCheckAudioRendererObj()) { + for (let index = 0; index < audioRendererList.length; index++) { + console.log('current audio renderer state : ' + audioRendererList[index].state) + if (stateGroup.indexOf(audioRendererList[index].state) === -1) { + console.log(TAG + testCaseName + `start state ${index} faile `); + assertFunction(); + done() + } else { + await audioRendererList[index].start().then(() => { + console.log(TAG + testCaseName + `start audioRendererList ${index} success `); + }).catch((err) => { + console.log(TAG + testCaseName + `start audioRendererList ${index} failed `); + assertFunction(); + done() + }) + } + } + } else { + console.log('start is isCheckAudioRendererObj Fail') + assertFunction(); + done() + } + } + + async function writeRender(assertFunction, done) { + console.log(TAG + ' writeRender start'); + if (isCheckAudioRendererObj()) { + await Promise.all(audioRendererList.map((item, index) => asyncWriteFunc(index))).then((resArray) => { + console.log(TAG + testCaseName + `writeRender end ${JSON.stringify(resArray)}`) + if (isCheckAllWriteSuccess(resArray)) { + console.log(TAG + testCaseName + `all write render success ; status ${JSON.stringify(resArray)}`) + } else { + console.log(TAG + testCaseName + `all write render fail ; status ${JSON.stringify(resArray)}`) + assertFunction() + done() + } + }).catch((errArray) => { + console.log(TAG + testCaseName + `writeRender error ${JSON.stringify(errArray)}`) + console.log(TAG + testCaseName + `all write render fail ; status ${JSON.stringify(errArray)}`) + assertFunction() + done() + }) + } else { + assertFunction(); + done() + } + } + + function asyncWriteFunc(index) { + return new Promise(async (resolve, reject) => { + let bfsize = 0; + let sr = audioRendererOptionsList[index].streamInfo.samplingRate; + let chn = audioRendererOptionsList[index].streamInfo.channels; + bufferSizeList[index] = await audioRendererList[index].getBufferSize() + console.log(TAG + testCaseName + `getBufferSize audioRendererList ${index} ${bufferSizeList[index]} SUCCESS`); + let path = pathDir + audioPaths[index] + console.log(TAG + testCaseName + `audio path ${path} `); + try { + console.log(TAG + testCaseName + 'fs start'); + let stat = await fs.stat(path); + console.log(TAG + testCaseName + "fs stat SUCCESS"); + let len = stat.size % bufferSizeList[index] == 0 ? Math.floor(stat.size / bufferSizeList[index]) : Math.floor(stat.size / bufferSizeList[index] + 1); + console.log(TAG + testCaseName + `len ${len}`); + let file = await fs.open(path, 0o0); + console.log(TAG + testCaseName + "open SUCCESS"); + let buf = new ArrayBuffer(bufferSizeList[index]); + while (true) { + for (let i = 0; i < len; i++) { + let options = { + offset: i * bufferSizeList[index], + length: bufferSizeList[index] + } + let readsize = await fs.read(file.fd, buf, options); + let time = Date.now(); + let writeSize = await new Promise((resolve, reject) => { + audioRendererList[index].write(buf, (err, writeSize) => { + time = Date.now(); + if (err) { + reject(err) + } else { + resolve(writeSize) + } + }) + }) + } + break + } + console.log(TAG + testCaseName + "writeRender success" + `audioRendererList ${index} write end, state:${audioRendererList[index].state}\n`); + console.log(TAG + testCaseName + "writeRender " + ` file descriptor: ${file.fd} `); + await fs.close(file.fd).then(() => { + console.log(TAG + testCaseName + "writeRender success" + `audioRendererList close success`); + resolve(true) + }).catch((err) => { + console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList close : Error: ${JSON.stringify(err)}\n`); + resolve(false) + }) + } catch (err) { + console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList write : Error: ${JSON.stringify(err)}\n`); + reject(false) + } + }) + } + + async function writeStandRender(index, path, assertFunction, done) { + let bfsize = 0; + let sr = audioRendererOptionsList[index].streamInfo.samplingRate; + let chn = audioRendererOptionsList[index].streamInfo.channels; + bufferSizeList[index] = await audioRendererList[index].getBufferSize() + console.log(TAG + testCaseName + `getBufferSize audioRendererList ${index} ${bufferSizeList[index]} SUCCESS`); + console.log(TAG + testCaseName + `audio path ${path} `); + try { + console.log(TAG + testCaseName + 'fs start'); + let stat = await fs.stat(path); + console.log(TAG + testCaseName + "fs stat SUCCESS"); + let len = stat.size % bufferSizeList[index] == 0 ? Math.floor(stat.size / bufferSizeList[index]) : Math.floor(stat.size / bufferSizeList[index] + 1); + console.log(TAG + testCaseName + `len ${len}`); + let file = await fs.open(path, 0o0); + console.log(TAG + testCaseName + "open SUCCESS"); + let buf = new ArrayBuffer(bufferSizeList[index]); + while (true) { + for (let i = 0; i < len; i++) { + let options = { + offset: i * bufferSizeList[index], + length: bufferSizeList[index] + } + let readsize = await fs.read(file.fd, buf, options); + let time = Date.now(); + let writeSize = await new Promise((resolve, reject) => { + audioRendererList[index].write(buf, (err, writeSize) => { + time = Date.now(); + if (err) { + reject(err) + } else { + resolve(writeSize) + } + }) + }) + } + break + } + console.log(TAG + testCaseName + "writeRender success" + `audioRendererList ${index} write end, state:${audioRendererList[index].state}\n`); + console.log(TAG + testCaseName + "writeRender " + ` file descriptor: ${file.fd} `); + await fs.close(file.fd).then(() => { + console.log(TAG + testCaseName + "writeRender success" + `audioRendererList close success`); + }).catch((err) => { + console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList close : Error: ${JSON.stringify(err)}\n`); + }) + } catch (err) { + console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList write : Error: ${JSON.stringify(err)}\n`); + assertFunction() + done() + } + } + + async function writeRenderChange(assertFunction, done) { + console.log(TAG + ' writeRender start'); + if (isCheckAudioRendererObj()) { + await Promise.all(audioRendererList.map((item, index) => asyncWriteChangeFunc(index))).then((resArray) => { + console.log(TAG + testCaseName + `writeRender end ${JSON.stringify(resArray)}`) + if (isCheckAllWriteSuccess(resArray)) { + console.log(TAG + testCaseName + `all write render success ; status ${JSON.stringify(resArray)}`) + } else { + console.log(TAG + testCaseName + `all write render fail ; status ${JSON.stringify(resArray)}`) + assertFunction() + done() + } + }).catch((errArray) => { + console.log(TAG + testCaseName + `writeRender error ${JSON.stringify(errArray)}`) + console.log(TAG + testCaseName + `all write render fail ; status ${JSON.stringify(errArray)}`) + assertFunction() + done() + }) + } else { + assertFunction(); + done() + } + } + + function asyncWriteChangeFunc(index) { + return new Promise(async (resolve, reject) => { + let bfsize = 0; + let sr = audioRendererOptionsList[index].streamInfo.samplingRate; + let chn = audioRendererOptionsList[index].streamInfo.channels; + bufferSizeList[index] = await audioRendererList[index].getBufferSize() + console.log(TAG + testCaseName + `getBufferSize audioRendererList ${index} ${bufferSizeList[index]} SUCCESS`); + let path = pathDir + audioPaths[index] + console.log(TAG + testCaseName + `audio path ${path} `); + try { + console.log(TAG + testCaseName + 'fs start'); + let stat = await fs.stat(path); + console.log(TAG + testCaseName + "fs stat SUCCESS"); + let len = stat.size % bufferSizeList[index] == 0 ? Math.floor(stat.size / bufferSizeList[index]) : Math.floor(stat.size / bufferSizeList[index] + 1); + console.log(TAG + testCaseName + `len ${len}`); + let file = await fs.open(path, 0o0); + console.log(TAG + testCaseName + "open SUCCESS"); + let buf = new ArrayBuffer(bufferSizeList[index]); + while (true) { + for (let i = 0; i < len; i++) { + if (i === Math.floor(len / 2)) { + if (index === 1) { + await audioRendererList[index].setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE) + } + } + let options = { + offset: i * bufferSizeList[index], + length: bufferSizeList[index] + } + let readsize = await fs.read(file.fd, buf, options); + let time = Date.now(); + let writeSize = await new Promise((resolve, reject) => { + audioRendererList[index].write(buf, (err, writeSize) => { + time = Date.now(); + if (err) { + reject(err) + } else { + resolve(writeSize) + } + }) + }) + } + break + } + console.log(TAG + testCaseName + "writeRender success" + `audioRendererList ${index} write end, state:${audioRendererList[index].state}\n`); + console.log(TAG + testCaseName + "writeRender " + ` file descriptor: ${file.fd} `); + await fs.close(file.fd).then(() => { + console.log(TAG + testCaseName + "writeRender success" + `audioRendererList close success`); + resolve(true) + }).catch((err) => { + console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList close : Error: ${JSON.stringify(err)}\n`); + resolve(false) + }) + } catch (err) { + console.log(TAG + testCaseName + "writeRender failed" + `audioRendererList write : Error: ${JSON.stringify(err)}\n`); + reject(false) + } + }) + + } + + + async function release(assertFunction, done) { + if (isCheckAudioRendererObj()) { + for (let index = 0; index < audioRendererList.length; index++) { + await audioRendererList[index].release() + audioRendererList[index] = null + } + } else { + assertFunction(); + done() + } + } + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0100 + * @tc.name : GET_AUDIOEFFECTINFOARRY - UNKNOWN - Promise + * @tc.desc : GET_AUDIOEFFECTINFOARRY - UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0100', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_UNKNOWN).then((audioEffectInfoArray) => { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + }).catch((err) => { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0200 + * @tc.name : GET_AUDIOEFFECTINFOARRY - MEDIA - Promise + * @tc.desc : GET_AUDIOEFFECTINFOARRY - MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0200', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_MEDIA).then((audioEffectInfoArray) => { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + }).catch((err) => { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0300 + * @tc.name : GET_AUDIOEFFECTINFOARRY - VOICE_CALL - Promise + * @tc.desc : GET_AUDIOEFFECTINFOARRY - VOICE_CALL + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0300', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION).then((audioEffectInfoArray) => { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + }).catch((err) => { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0400 + * @tc.name : GET_AUDIOEFFECTINFOARRY - RING - Promise + * @tc.desc : GET_AUDIOEFFECTINFOARRY - RING + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0400', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE).then((audioEffectInfoArray) => { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + }).catch((err) => { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0500 + * @tc.name : GET_AUDIOEFFECTINFOARRY - MOVIE - Promise + * @tc.desc : GET_AUDIOEFFECTINFOARRY - MOVIE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0500', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_MOVIE).then((audioEffectInfoArray) => { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + }).catch((err) => { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0600 + * @tc.name : GET_AUDIOEFFECTINFOARRY - MUSIC - Callback + * @tc.desc : GET_AUDIOEFFECTINFOARRY - MUSIC + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0600', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_MUSIC, async (err, audioEffectInfoArray) => { + if (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } else { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + } + }); + + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0700 + * @tc.name : GET_AUDIOEFFECTINFOARRY - ALARM - Callback + * @tc.desc : GET_AUDIOEFFECTINFOARRY - ALARM + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0700', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_ALARM, async (err, audioEffectInfoArray) => { + if (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } else { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + } + }); + + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0800 + * @tc.name : GET_AUDIOEFFECTINFOARRY - VOICE_ASSISTANT - Callback + * @tc.desc : GET_AUDIOEFFECTINFOARRY - VOICE_ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0800', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, async (err, audioEffectInfoArray) => { + if (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } else { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + } + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0900 + * @tc.name : GET_AUDIOEFFECTINFOARRY - ACCESSIBILITY - Callback + * @tc.desc : GET_AUDIOEFFECTINFOARRY - ACCESSIBILITY + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_0900', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, async (err, audioEffectInfoArray) => { + if (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } else { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + } + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1000 + * @tc.name : GET_AUDIOEFFECTINFOARRY - VOICE_MESSAGE - Callback + * @tc.desc : GET_AUDIOEFFECTINFOARRY - VOICE_MESSAGE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1000', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_VOICE_MESSAGE, async (err, audioEffectInfoArray) => { + if (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } else { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + } + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1100 + * @tc.name : GET_AUDIOEFFECTINFOARRY - RINGTONE - Callback + * @tc.desc : GET_AUDIOEFFECTINFOARRY - RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1100', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_RINGTONE, async (err, audioEffectInfoArray) => { + if (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } else { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + } + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1200 + * @tc.name : GET_AUDIOEFFECTINFOARRY - NOTIFICATION - Callback + * @tc.desc : GET_AUDIOEFFECTINFOARRY - NOTIFICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1200', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_NOTIFICATION, async (err, audioEffectInfoArray) => { + if (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } else { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + } + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1300 + * @tc.name : GET_AUDIOEFFECTINFOARRY - GAME - Callback + * @tc.desc : GET_AUDIOEFFECTINFOARRY - GAME + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1300', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_GAME, async (err, audioEffectInfoArray) => { + if (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } else { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + } + }); + + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1400 + * @tc.name : GET_AUDIOEFFECTINFOARRY - AUDIOBOOK - Promise + * @tc.desc : GET_AUDIOEFFECTINFOARRY - AUDIOBOOK + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1400', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_AUDIOBOOK).then((audioEffectInfoArray) => { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + }).catch((err) => { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1500 + * @tc.name : GET_AUDIOEFFECTINFOARRY - NAVIGATION - Promise + * @tc.desc : GET_AUDIOEFFECTINFOARRY - NAVIGATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_AUDIOEFFECTINFOARRY_1500', 2, async function (done) { + try { + audioStreamManager.getAudioEffectInfoArray(audio.StreamUsage.STREAM_USAGE_NAVIGATION).then((audioEffectInfoArray) => { + expect(audioEffectInfoArray[0]).assertEqual(0); + expect(audioEffectInfoArray[1]).assertEqual(1); + console.log(`${TAG} getAudioEffectInfoArray success:${JSON.stringify(audioEffectInfoArray)}`); + done(); + }).catch((err) => { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + }); + } catch (err) { + console.error(`${TAG} getAudioEffectInfoArray :ERROR: ${err}`); + expect(false).asserttrue(); + done(); + } + + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0100 + * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & UNKNOWN - Promise + * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0100', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0100 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0200 + * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & MEDIA - Promise + * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0200', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0200 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0300 + * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & COMMUNICATION - Promise + * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0300', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0300 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0400 + * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & ASSISTANT - Promise + * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0400', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0400 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0500 + * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & ALARM - Callback + * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & ALARM + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0500', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0500 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_ALARM, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0600 + * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & RINGTONE - Callback + * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0600', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0600 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0700 + * @tc.name : GET_SET_AudioEffectMode-UNKNOWN & ACCESSIBILITY - Callback + * @tc.desc : GET_SET_AudioEffectMode-UNKNOWN & ACCESSIBILITY + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0700', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0700 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0800 + * @tc.name : GET_SET_AudioEffectMode-SPEECH & UNKNOWN - Promise + * @tc.desc : GET_SET_AudioEffectMode-SPEECH & UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0800', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0800 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0900 + * @tc.name : GET_SET_AudioEffectMode-SPEECH & MEDIA - Promise + * @tc.desc : GET_SET_AudioEffectMode-SPEECH & MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0900', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_0900 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1000 + * @tc.name : GET_SET_AudioEffectMode-SPEECH & COMMUNICATION - Promise + * @tc.desc : GET_SET_AudioEffectMode-SPEECH & COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1000', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1000 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1100 + * @tc.name : GET_SET_AudioEffectMode-SPEECH & ASSISTANT - Promise + * @tc.desc : GET_SET_AudioEffectMode-SPEECH & ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1100', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1100 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1200 + * @tc.name : GET_SET_AudioEffectMode-SPEECH & ALARM - Callback + * @tc.desc : GET_SET_AudioEffectMode-SPEECH & ALARM + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1200', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1200 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_ALARM, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1300 + * @tc.name : GET_SET_AudioEffectMode-SPEECH & RINGTONE - Callback + * @tc.desc : GET_SET_AudioEffectMode-SPEECH & RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1300', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1300 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1400 + * @tc.name : GET_SET_AudioEffectMode-SPEECH & ACCESSIBILITY - Callback + * @tc.desc : GET_SET_AudioEffectMode-SPEECH & ACCESSIBILITY + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1400', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1400 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1500 + * @tc.name : GET_SET_AudioEffectMode-MUSIC & UNKNOWN - Promise + * @tc.desc : GET_SET_AudioEffectMode-MUSIC & UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1500', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1500 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1600 + * @tc.name : GET_SET_AudioEffectMode-MUSIC & MEDIA - Promise + * @tc.desc : GET_SET_AudioEffectMode-MUSIC & MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1600', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1600 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1700 + * @tc.name : GET_SET_AudioEffectMode-MUSIC & COMMUNICATION - Promise + * @tc.desc : GET_SET_AudioEffectMode-MUSIC & COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1700', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1700 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1800 + * @tc.name : GET_SET_AudioEffectMode-MUSIC & ASSISTANT - Promise + * @tc.desc : GET_SET_AudioEffectMode-MUSIC & ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1800', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1800 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1900 + * @tc.name : GET_SET_AudioEffectMode-MUSIC & ALARM - Callback + * @tc.desc : GET_SET_AudioEffectMode-MUSIC & ALARM + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1900', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_1900 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_ALARM, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2000 + * @tc.name : GET_SET_AudioEffectMode-MUSIC & RINGTONE - Callback + * @tc.desc : GET_SET_AudioEffectMode-MUSIC & RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2000', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2000 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2100 + * @tc.name : GET_SET_AudioEffectMode-MUSIC & ACCESSIBILITY - Callback + * @tc.desc : GET_SET_AudioEffectMode-MUSIC & ACCESSIBILITY + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2100', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2100 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2200 + * @tc.name : GET_SET_AudioEffectMode-MOVIE & UNKNOWN - Promise + * @tc.desc : GET_SET_AudioEffectMode-MOVIE & UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2200', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2200 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2300 + * @tc.name : GET_SET_AudioEffectMode-MOVIE & MEDIA - Promise + * @tc.desc : GET_SET_AudioEffectMode-MOVIE & MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2300', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2300 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2400 + * @tc.name : GET_SET_AudioEffectMode-MOVIE & COMMUNICATION - Promise + * @tc.desc : GET_SET_AudioEffectMode-MOVIE & COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2400', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2400 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2500 + * @tc.name : GET_SET_AudioEffectMode-MOVIE & ASSISTANT - Promise + * @tc.desc : GET_SET_AudioEffectMode-MOVIE & ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2500', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2500 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2600 + * @tc.name : GET_SET_AudioEffectMode-MOVIE & ALARM - Callback + * @tc.desc : GET_SET_AudioEffectMode-MOVIE & ALARM + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2600', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2600 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_ALARM, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2700 + * @tc.name : GET_SET_AudioEffectMode-MOVIE & RINGTONE - Callback + * @tc.desc : GET_SET_AudioEffectMode-MOVIE & RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2700', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2700 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2800 + * @tc.name : GET_SET_AudioEffectMode-MOVIE & ACCESSIBILITY - Callback + * @tc.desc : GET_SET_AudioEffectMode-MOVIE & ACCESSIBILITY + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2800', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2800 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2900 + * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & UNKNOWN - Promise + * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2900', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_2900 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3000 + * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & MEDIA - Promise + * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3000', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3000 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3100 + * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & COMMUNICATION - Promise + * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3100', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3100 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3200 + * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & ASSISTANT - Promise + * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3200', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3200 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3300 + * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & ALARM - Callback + * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & ALARM + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3300', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3300 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_ALARM, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3400 + * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & RINGTONE - Callback + * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3400', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3400 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3500 + * @tc.name : GET_SET_AudioEffectMode-SONIFICATION & ACCESSIBILITY - Callback + * @tc.desc : GET_SET_AudioEffectMode-SONIFICATION & ACCESSIBILITY + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3500', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3500 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SONIFICATION, + usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3600 + * @tc.name : GET_SET_AudioEffectMode-RINGTONE & UNKNOWN - Promise + * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & UNKNOWN + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3600', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3600 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3700 + * @tc.name : GET_SET_AudioEffectMode-RINGTONE & MEDIA - Promise + * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & MEDIA + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3700', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3700 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3800 + * @tc.name : GET_SET_AudioEffectMode-RINGTONE & COMMUNICATION - Promise + * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & COMMUNICATION + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3800', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3800 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3900 + * @tc.name : GET_SET_AudioEffectMode-RINGTONE & ASSISTANT - Promise + * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & ASSISTANT + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3900', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_3900 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 1) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_DEFAULT SUCCESS"); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE).then(async () => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + await audioRenderer.getAudioEffectMode().then((audioEffectMode) => { + if (audioEffectMode == 0) { + expect(true).assertTrue(); + console.log(TAG + "getAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.release(); + done(); + } + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + }).catch((err) => { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + }) + } + + + }).catch((err) => { + console.log(TAG + "getAudioEffectMode failed" + err.message); + expect(false).assertTrue(); + done(); + }) + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4000 + * @tc.name : GET_SET_AudioEffectMode-RINGTONE & ALARM - Callback + * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & ALARM + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4000', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4000 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_ALARM, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4100 + * @tc.name : GET_SET_AudioEffectMode-RINGTONE & RINGTONE - Callback + * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & RINGTONE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4100', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4100 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4200 + * @tc.name : GET_SET_AudioEffectMode-RINGTONE & ACCESSIBILITY - Callback + * @tc.desc : GET_SET_AudioEffectMode-RINGTONE & ACCESSIBILITY + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4200', 2, async function (done) { + console.info(TAG + 'SUB_MULTIMEDIA_AUDIO_GET_SET_AUDIOEFFECTMODE_4200 come in') + let audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + let audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_RINGTONE, + usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, + rendererFlags: 0 + } + + let audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + } + + let audioRenderer; + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + audioRenderer = data; + console.info(TAG + ' AudioRenderer Created : Success : Stream Type: SUCCESS'); + }).catch((err) => { + console.error(TAG + ` AudioRenderer Created : ERROR : ${err}`); + }); + await audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 1) { + console.info(`${TAG} getAudioEffectMode EFFECT_DEFAULT SUCCESS: ${effectmode}`); + audioRenderer.setAudioEffectMode(audio.AudioEffectMode.EFFECT_NONE, (err) => { + if (err) { + console.log(TAG + "setAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + + } else { + console.log(TAG + "setAudioEffectMode EFFECT_NONE SUCCESS"); + audioRenderer.getAudioEffectMode((err, effectmode) => { + if (effectmode == 0) { + expect(true).assertTrue(); + console.info(`${TAG} getAudioEffectMode EFFECT_NONE SUCCESS: ${effectmode}`); + audioRenderer.release(); + done(); + } else { + console.log(TAG + "getAudioEffectMode EFFECT_NONE fail" + err.message); + expect(false).assertTrue(); + done(); + } + }); + } + + + }); + } else { + console.log(TAG + "getAudioEffectMode failed" + err.message); + done(); + } + }); + + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0100 + * @tc.name : AudioEffect_Play_MUSIC_UNKNOWN + * @tc.desc : AudioEffect_Play_MUSIC + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0100', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0100]' + console.info(TAG + testCaseName + 'start') + streamNum = 1 + audioRendererList = [] + await getPath() + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_UNKNOWN, + rendererFlags: 0 + } + }] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT + ]; + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + ] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0200 + * @tc.name : AudioEffect_Play_MUSIC + * @tc.desc : AudioEffect_Play_MUSIC + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0200', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0200]' + console.info(TAG + testCaseName + 'start') + streamNum = 1 + audioRendererList = [] + await getPath() + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT + ]; + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + ] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0300 + * @tc.name : AudioEffect_Play_VOICE_CALL + * @tc.desc : AudioEffect_Play_VOICE_CALL + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0300', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0300]' + console.info(TAG + testCaseName + 'start') + streamNum = 1 + audioRendererList = [] + await getPath() + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 0 + } + }] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT + ]; + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + ] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0400 + * @tc.name : AudioEffect_Play_RING + * @tc.desc : AudioEffect_Play_RING + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0400', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0400]' + console.info(TAG + testCaseName + 'start') + streamNum = 1 + audioRendererList = [] + await getPath() + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_NOTIFICATION_RINGTONE, + rendererFlags: 0 + } + }] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT + ]; + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + ] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0500 + * @tc.name : AudioEffect_Play_MOVIE + * @tc.desc : AudioEffect_Play_MOVIE + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0500', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0500]' + console.info(TAG + testCaseName + 'start') + streamNum = 1 + audioRendererList = [] + await getPath() + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT + ]; + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + ] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0600 + * @tc.name : AudioEffect_Play_SPEECH + * @tc.desc : AudioEffect_Play_SPEECH + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0600', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0600]' + console.info(TAG + testCaseName + 'start') + streamNum = 1 + audioRendererList = [] + await getPath() + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT + ]; + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + ] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0700 + * @tc.name : AudioEffect_Play_ALARM + * @tc.desc : AudioEffect_Play_ALARM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0700', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0700]' + console.info(TAG + testCaseName + 'start') + streamNum = 1 + audioRendererList = [] + await getPath() + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_ALARM, + rendererFlags: 0 + } + }] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT + ]; + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + ] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0800 + * @tc.name : AudioEffect_Play_VOICE_ASSISTANT + * @tc.desc : AudioEffect_Play_VOICE_ASSISTANT + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0800', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0800]' + console.info(TAG + testCaseName + 'start') + streamNum = 1 + audioRendererList = [] + await getPath() + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_ASSISTANT, + rendererFlags: 0 + } + }] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT + ]; + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + ] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0900 + * @tc.name : AudioEffect_Play_ACCESSIBILITY + * @tc.desc : AudioEffect_Play_ACCESSIBILITY + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0900', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_0900]' + console.info(TAG + testCaseName + 'start') + streamNum = 1 + audioRendererList = [] + await getPath() + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_ACCESSIBILITY, + rendererFlags: 0 + } + }] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT + ]; + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + ] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + + + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1000 + * @tc.name : AudioEffect_Play_SameStreams_DiffAudioEffectMode + * @tc.desc : AudioEffect_Play_SameStreams_DiffAudioEffectMode + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1000', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1000]' + console.info(TAG + testCaseName + 'start') + streamNum = 2 + audioRendererList = [] + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }, { + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }] + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + 'pcm_48ksr_32kbr_2ch.wav' + ] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT, + audio.AudioEffectMode.EFFECT_NONE, + ]; + await getPath() + audioRendererList = [] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1100 + * @tc.name : AudioEffect_Play_SameStreams_SameAudioEffectMode_EFFECT_NONE + * @tc.desc : AudioEffect_Play_SameStreams_SameAudioEffectMode_EFFECT_NONE + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1100', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1100]' + console.info(TAG + testCaseName + 'start') + streamNum = 2 + audioRendererList = [] + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }, { + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }] + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + 'pcm_48ksr_32kbr_2ch.wav' + ] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_NONE, + audio.AudioEffectMode.EFFECT_NONE, + ]; + await getPath() + audioRendererList = [] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1200 + * @tc.name : AudioEffect_Play_SameStreams_SameAudioEffectMode_EFFECT_DEFAULT + * @tc.desc : AudioEffect_Play_SameStreams_SameAudioEffectMode_EFFECT_DEFAULT + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1200', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1200]' + console.info(TAG + testCaseName + 'start') + streamNum = 2 + audioRendererList = [] + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }, { + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }] + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + 'pcm_48ksr_32kbr_2ch.wav' + + ] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT, + audio.AudioEffectMode.EFFECT_DEFAULT, + ]; + await getPath() + audioRendererList = [] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1300 + * @tc.name : AudioEffect_Play_DiffStreams_DiffAudioEffectMode + * @tc.desc : AudioEffect_Play_DiffStreams_DiffAudioEffectMode + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1300', 1, async function (done) { + testCaseName = '[SUB_MULTIMEDIA_AUDIO_AUDIOEFFECT_PLAY_1300]' + console.info(TAG + testCaseName + 'start') + streamNum = 2 + audioRendererList = [] + audioRendererOptionsList = [{ + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MUSIC, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }, { + streamInfo: { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }, + rendererInfo: { + content: audio.ContentType.CONTENT_TYPE_MOVIE, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + }] + audioPaths = [ + 'StarWars10s-2C-48000-4SW.wav', + 'pcm_48ksr_32kbr_2ch.wav' + ] + audioEffectModeList = [ + audio.AudioEffectMode.EFFECT_DEFAULT, + audio.AudioEffectMode.EFFECT_NONE, + ]; + await getPath() + audioRendererList = [] + console.log(TAG + testCaseName + 'TestLog: Start Testing createAudioRenderer function'); + await createAudioRenderer(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing setAudioEffectMode function'); + await setAudioEffectMode(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing start function'); + await start(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing writeRender function'); + await writeRender(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing release function'); + await release(expect().assertFail, done) + console.log(TAG + testCaseName + 'TestLog: Start Testing end'); + done() + }) }) \ No newline at end of file