From 1ef620e8f8c700fbef124e9a221ee05e8380d948 Mon Sep 17 00:00:00 2001 From: wangzx0705 Date: Thu, 27 Jul 2023 04:32:07 +0000 Subject: [PATCH] cherry pick audio xts_acts test to OpenHarmony-4.0-Beta2 Signed-off-by: wangzx0705 --- multimedia/BUILD.gn | 2 + .../AudioManagerEnhance/BUILD.gn | 39 + .../AudioManagerEnhance/Test.json | 31 + .../signature/openharmony_sx.p7b | Bin 0 -> 3598 bytes .../AudioManagerEnhance/src/main/config.json | 118 +++ .../src/main/ets/MainAbility/app.ets | 24 + .../src/main/ets/MainAbility/pages/index.ets | 31 + .../src/main/ets/TestAbility/app.ets | 33 + .../src/main/ets/TestAbility/pages/index.ets | 49 ++ .../ets/TestRunner/OpenHarmonyTestRunner.ts | 53 ++ .../src/main/ets/test/Const.ets | 26 + .../main/ets/test/GetMax_Minvolume.test.ets | 141 ++++ .../ets/test/GetSystemVolumeInDb.test.ets | 565 +++++++++++++ .../ets/test/IsVolumeUnadjustable.test.ets | 189 +++++ .../src/main/ets/test/List.test.ets | 23 + .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 24 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../main/resources/en_US/element/string.json | 16 + .../main/resources/zh_CN/element/string.json | 16 + .../AudioRendererEnhance/BUILD.gn | 39 + .../AudioRendererEnhance/Test.json | 49 ++ .../signature/openharmony_sx.p7b | Bin 0 -> 3593 bytes .../AudioRendererEnhance/src/main/config.json | 100 +++ .../src/main/ets/MainAbility/app.ets | 34 + .../src/main/ets/MainAbility/pages/index.ets | 30 + .../src/main/ets/TestAbility/app.ets | 34 + .../src/main/ets/TestAbility/pages/index.ets | 49 ++ .../ets/TestRunner/OpenHarmonyTestRunner.ts | 53 ++ .../src/main/ets/test/Const.ets | 25 + .../GetAndSetRendererSamplingRate.test.ets | 657 +++++++++++++++ .../ets/test/GetCurrentOutputDevices.test.ets | 255 ++++++ .../test/GetMaxAndMinStreamVolume.test.ets | 782 ++++++++++++++++++ .../main/ets/test/GetUnderflowCount.test.ets | 384 +++++++++ .../src/main/ets/test/List.test.ets | 27 + .../ets/test/OnOffOutputDeviceChange.test.ets | 269 ++++++ .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 24 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../main/resources/en_US/element/string.json | 16 + .../main/resources/zh_CN/element/string.json | 16 + 41 files changed, 4239 insertions(+) create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/BUILD.gn create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/Test.json create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/signature/openharmony_sx.p7b create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/config.json create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/MainAbility/app.ets create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/MainAbility/pages/index.ets create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestAbility/app.ets create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestAbility/pages/index.ets create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/Const.ets create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetMax_Minvolume.test.ets create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetSystemVolumeInDb.test.ets create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/IsVolumeUnadjustable.test.ets create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/List.test.ets create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/base/element/color.json create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/base/element/string.json create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/base/media/icon.png create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/en_US/element/string.json create mode 100644 multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/zh_CN/element/string.json create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/BUILD.gn create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/Test.json create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/signature/openharmony_sx.p7b create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/config.json create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/MainAbility/app.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/MainAbility/pages/index.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestAbility/app.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestAbility/pages/index.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/Const.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetAndSetRendererSamplingRate.test.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetCurrentOutputDevices.test.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetMaxAndMinStreamVolume.test.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetUnderflowCount.test.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/List.test.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/OnOffOutputDeviceChange.test.ets create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/base/element/color.json create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/base/element/string.json create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/base/media/icon.png create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/en_US/element/string.json create mode 100644 multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/zh_CN/element/string.json diff --git a/multimedia/BUILD.gn b/multimedia/BUILD.gn index f714bf6f2..1fdec9e07 100644 --- a/multimedia/BUILD.gn +++ b/multimedia/BUILD.gn @@ -25,7 +25,9 @@ group("multimedia") { "audio/audio_js_standard/audioInterrupt:audio_interrupt_js_hap", "audio/audio_js_standard/audioInterruptRender:audioRenderInterrupt", "audio/audio_js_standard/audioManager:audio_manager_js_hap", + "audio/audio_js_standard/AudioManagerEnhance:audio_manager_enhance_ets_hap", "audio/audio_js_standard/audioRenderer:audio_renderer_js_hap", + "audio/audio_js_standard/AudioRendererEnhance:audio_render_enhance_ets_hap", "audio/audio_js_standard/audioVoip:audio_voip_js_hap", "audio/audio_js_standard/audio_ndk_test:audioDemo_ndk_hap", "avsession/avsession_js_standard/avsessionManager:avsession_framework_js_hap", diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/BUILD.gn b/multimedia/audio/audio_js_standard/AudioManagerEnhance/BUILD.gn new file mode 100644 index 000000000..daf3a3794 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/BUILD.gn @@ -0,0 +1,39 @@ +# 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_manager_enhance_ets_hap") { + hap_profile = "./src/main/config.json" + deps = [ + ":audio_manager_enhance_ets_assets", + ":audio_manager_enhance_ets_resources", + ":audio_manager_enhance_ets_test_assets", + ] + ets2abc = true + + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAudioManagerEnhanceTest" + subsystem_name = "multimedia" + part_name = "audio_framework" +} +ohos_js_assets("audio_manager_enhance_ets_assets") { + source_dir = "./src/main/ets/MainAbility" +} +ohos_js_assets("audio_manager_enhance_ets_test_assets") { + source_dir = "./src/main/ets/TestAbility" +} +ohos_resources("audio_manager_enhance_ets_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/Test.json b/multimedia/audio/audio_js_standard/AudioManagerEnhance/Test.json new file mode 100644 index 000000000..1fb199765 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/Test.json @@ -0,0 +1,31 @@ +{ + "description": "Configuration for audio manager enhance Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "3000000", + "bundle-name":"com.example.xts_audiomanager", + "package-name": "com.example.xts_audiomanager", + "shell-timeout": "600000", + "testcase-timeout": 100000 + }, + "kits": [ + { + "test-file-name": [ + "ActsAudioManagerEnhanceTest.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" + ] + } + ] +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/signature/openharmony_sx.p7b b/multimedia/audio/audio_js_standard/AudioManagerEnhance/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..2881502f4bc1af861f77593ef3403e8db199b198 GIT binary patch literal 3598 zcmcgvZFCb=8g4$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XqFEidgA=yZCe}H- zr>d{)ZQk+biWNn#Gxr=DogIJmk>j>yiPMi$r{ZpYS?F!;v-f;b0cB;dD6*O2%>_hn z%Qp6%sQoWVT@f(m`X#AA0f}S(yIRS>`0GJIE;LL$6sthBcpz2*omSfdDsPM`A(gW1 zTG2-(Bj&tTZk;~s(wQe!^R701_5Fk|el-7a=7bMEw$J?&74$=or~uOHY>{s6uG;M37pevp^pM-PAKdw$$*!^M-Idp^GuUG&d= S7pf{h3RB1HipI3xdH%nOe382V literal 0 HcmV?d00001 diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/config.json b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/config.json new file mode 100644 index 000000000..e5ed5069f --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/config.json @@ -0,0 +1,118 @@ +{ + "app": { + "bundleName": "com.example.xts_audiomanager", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "target": 7, + "releaseType": "Release" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.xts_audiomanager", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "default", + "tablet" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "reqPermissions": [ + { + "name": "ohos.permission.MICROPHONE", + "reason": "use ohos.permission.MICROPHONE" + }, + { + "name": "ohos.permission.ACCESS_NOTIFICATION_POLICY", + "reason": "use ohos.permission.ACCESS_NOTIFICATION_POLICY" + }, + { + "name": "ohos.permission.MODIFY_AUDIO_SETTINGS", + "reason": "use ohos.permission.MODIFY_AUDIO_SETTINGS" + }, + { + "name": "ohos.permission.MANAGE_AUDIO_CONFIG", + "reason": "use ohos.permission.MANAGE_AUDIO_CONFIG" + } + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "ets", + "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": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } + } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/MainAbility/app.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/MainAbility/app.ets new file mode 100644 index 000000000..02e2e0041 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/MainAbility/app.ets @@ -0,0 +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. + */ +import hilog from '@ohos.hilog'; + +export default { + onCreate() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onCreate'); + }, + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onDestroy'); + }, +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/MainAbility/pages/index.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 000000000..a3361dc31 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +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. + */ +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestAbility/app.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestAbility/app.ets new file mode 100644 index 000000000..a60e863e8 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestAbility/app.ets @@ -0,0 +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 hilog from '@ohos.hilog'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test.ets'; + +export default { + onCreate() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onCreate'); + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onDestroy'); + }, +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestAbility/pages/index.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 000000000..f54a4fc5f --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..882019408 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,53 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', + JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare'); + } + + onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', + JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', + d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', + d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +}; \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/Const.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/Const.ets new file mode 100644 index 000000000..f1fe9857b --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/Const.ets @@ -0,0 +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. + */ +//ts-nocheck +//public invalid +export const SAMPLING_RATE_44100 = 44100; +export const SAMPLING_RATE_48000 = 48000; +export const OUTPUT_NUMBER_0 = 0; +export const OUTPUT_NUMBER_1 = 1; + +//-------------------------------------------------------------- +export const INVALID_INPUT_PARAMETER_401 = 401; +export const INVALID_INPUT_PARAMETER_6800101 = 6800101; +export const UNSUPORTED_OPTION_6800104 = 6800104; +export const DEAFULT_MEDIA_DB = 0.08370080590248108; \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetMax_Minvolume.test.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetMax_Minvolume.test.ets new file mode 100644 index 000000000..fe25485e9 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetMax_Minvolume.test.ets @@ -0,0 +1,141 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import audio from '@ohos.multimedia.audio'; +import featureAbility from '@ohos.ability.featureAbility'; +import ArrayList from '@ohos.util.ArrayList'; +import * as env from './Const.ets'; + +export default function audioManagerTest() { + describe('getMax_Minvolume', function () { + let audioManager = null; + let audioVolumeManager = null; + let audioVolumeGroupManager = null; + let TagFrmwk = "audioManagerEnhanceTest"; + beforeAll(async function () { + console.info('TestLog: Start Testing audioManagerTest Interfaces\n'); + await getPermission(); + await sleep(3000); + }) + beforeEach(async function () { + console.info(`${TagFrmwk}: beforeEach: Prerequisites at the test case level`); + getAudioManager(); + await sleep(100); + }) + afterEach(async function () { + console.info(`${TagFrmwk}: afterEach: Test case-level clearance conditions`); + await sleep(100); + }) + afterAll(function () { + console.info(`${TagFrmwk}: afterAll: Test suite-level cleanup condition`); + }) + function getAudioManager() { + audioManager = audio.getAudioManager(); + if (audioManager != null) { + console.info(`${TagFrmwk}: getAudioManger : PASS`); + audioVolumeManager = audioManager.getVolumeManager(); + console.info(`${TagFrmwk}: getVolumeManager : PASS`); + let groupid = audio.DEFAULT_VOLUME_GROUP_ID; + audioVolumeManager.getVolumeGroupManager(groupid, (err, value) => { + if (err) { + console.info("getVolumeGroupManager failed. err:" + JSON.stringify(err)); + console.info("groupid:" + groupid); + return; + } + console.info("getVolumeGroupManager success"); + audioVolumeGroupManager = value; + }); + } + else { + console.info(`${TagFrmwk}: getAudioManger : FAIL`); + } + } + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + async function getPermission() { + console.info("getPermission IN\n") + let permissions = ['ohos.permission.MICROPHONE','ohos.permission.MODIFY_AUDIO_SETTINGS','ohos.permission.ACCESS_NOTIFICATION_POLICY']; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("request success" + JSON.stringify(data)); + }) + } + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0100 + *@tc.name : getDefaultVolume - Media + *@tc.desc : Judge volume is Unadjustable or adjustable + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMAXVOLUME_0100', 0, async function (done) { + try { + let maxvol; + var maxvol1 = new ArrayList(); + var maxvol2 = [15, 15, 15, 15, 15, 15, 15]; + for(let index in audio.AudioVolumeType){ + maxvol = await audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType[index]); + console.info(`${index} max volume : ${maxvol}`); + if(index != 'ALL'){ + maxvol1.add(maxvol); + } + } + for(let i =0; i < maxvol1.length; i++){ + console.info(`check maxvolume: maxvol1 : ${maxvol1[i]}, maxvol2 : ${maxvol2[i]}`); + expect(maxvol1[i]).assertEqual(maxvol2[i]); + } + done(); + }catch (error){ + console.log(`getVolume error: ${error.code}, message ${error.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0100 + *@tc.name : getDefaultVolume - Media + *@tc.desc : Judge volume is Unadjustable or adjustable + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETMINVOLUME_0100', 0, async function (done) { + try { + let minvol; + var minvol1 = new ArrayList(); + var minvol2 = [1, 1, 0, 0, 0, 1, 1]; + for(let index in audio.AudioVolumeType){ + minvol = await audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType[index]); + console.info(`${index} min volume : ${minvol}`); + if(index != 'ALL'){ + minvol1.add(minvol); + } + } + for(let i =0; i < minvol1.length; i++){ + console.info(`check minvolume minvol1 : ${minvol1[i]}, minvol2 : ${minvol2[i]}`); + expect(minvol1[i]).assertEqual(minvol2[i]); + } + done(); + }catch (error){ + console.log(`getVolume error ${error.code}, message ${error.message}`); + expect(false).assertTrue(); + done(); + } + }) + + }) +} diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetSystemVolumeInDb.test.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetSystemVolumeInDb.test.ets new file mode 100644 index 000000000..dabfb99ea --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/GetSystemVolumeInDb.test.ets @@ -0,0 +1,565 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import audio from '@ohos.multimedia.audio'; +import featureAbility from '@ohos.ability.featureAbility'; +import ArrayList from '@ohos.util.ArrayList'; +import * as env from './Const.ets'; + +export default function audioManagerTest() { + describe('getSystemVolumeInDb', function () { + let audioManager = null; + let audioVolumeManager = null; + let audioVolumeGroupManager = null; + let TagFrmwk = "audioManagerEnhanceTest"; + beforeAll(async function () { + await getPermission(); + await sleep(3000); + console.info('TestLog: Start Testing audioManagerTest Interfaces'); + }) + beforeEach(async function () { + console.info(`${TagFrmwk}: beforeEach: Prerequisites at the test case level`); + getAudioManager(); + await sleep(100); + }) + afterEach(async function () { + console.info(`${TagFrmwk}: afterEach: Test case-level clearance conditions`); + await sleep(100); + }) + afterAll(function () { + console.info(`${TagFrmwk}: afterAll: Test suite-level cleanup condition`); + }) + + function getAudioManager() { + audioManager = audio.getAudioManager(); + if (audioManager != null) { + console.info(`${TagFrmwk}: getAudioManger : PASS`); + audioVolumeManager = audioManager.getVolumeManager(); + console.info(`${TagFrmwk}: getVolumeManager : PASS`); + let groupid = audio.DEFAULT_VOLUME_GROUP_ID; + audioVolumeManager.getVolumeGroupManager(groupid, (err, value) => { + if (err) { + console.info("getVolumeGroupManager failed. err:" + JSON.stringify(err)); + console.info("groupid:" + groupid); + return; + } + console.info("getVolumeGroupManager success"); + audioVolumeGroupManager = value; + }); + } + else { + console.info(`${TagFrmwk}: getAudioManger : FAIL`); + } + } + + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + async function getPermission() { + console.info("getPermission IN\n") + let permissions = ['ohos.permission.MICROPHONE', 'ohos.permission.MODIFY_AUDIO_SETTINGS', 'ohos.permission.ACCESS_NOTIFICATION_POLICY']; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("request success" + JSON.stringify(data)); + }) + } + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0100 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0100', 0, async function (done) { + try { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.SPEAKER) + .then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); + expect(data).assertEqual(env.DEAFULT_MEDIA_DB); + expect(true).assertTrue(); + done(); + }) + .catch((error) => { + console.log(`${TagFrmwk}: getSystemVolumeInDb : error ${error}`); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0200 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0200', 0, async function (done) { + try { + var db1 = new ArrayList(); + var db2 = [0.06932847946882248, 0.06932847946882248, 0.08370080590248108, 0.08370080590248108, 0.08370080590248108, 0.06932847946882248, 0.06932847946882248, 0.08370080590248108]; + for (let index in audio.AudioVolumeType) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[index], 3, audio.DeviceType.SPEAKER) + .then((data) => { + console.info(`${index} getSystemVolumeInDb :SUCCESS ${data}`); + db1.add(data); + }) + .catch((error) => { + console.log(`${TagFrmwk}: ${index} getSystemVolumeInDb : error ${error}`); + expect(false).assertTrue(); + done(); + }); + } + for (let i = 0; i < db1.length; i++) { + console.log(`${db1[i]}: ${db2[i]}`); + expect(Number(db1[i])).assertEqual(Number(db2[i])); + } + done(); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0300 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0300', 0, async function (done) { + try { + let maxVol = await audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA); + let minVol = await audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA); + let volLevel = 0; + for (volLevel = minVol; volLevel <= maxVol; volLevel++) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, volLevel, audio.DeviceType.SPEAKER) + .then((data) => { + console.info(` ${volLevel} getSystemVolumeInDb :SUCCESS ${data}`); + }) + .catch((error) => { + console.log(`${TagFrmwk}: ${volLevel} getSystemVolumeInDb : error ${error}`); + expect(false).assertTrue(); + done(); + }); + } + done(); + } catch (error) { + console.info(`SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0300: error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0400 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0400', 0, async function (done) { + try { + for (let index in audio.DeviceType) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 1, audio.DeviceType[index]) + .then((data) => { + console.info(`${index} getSystemVolumeInDb :SUCCESS ${data}`); + }) + .catch((error) => { + if (index == 'DEFAULT' || index == 'MAX' || index == 'INVALID' || index == 'NONE') { + console.log(`${index} getSystemVolumeInDb :${error.code} ${error.message}`); + } else { + console.log(`${TagFrmwk}:${index} getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(false).assertTrue(); + done(); + } + }); + } + done(); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB: error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0500 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0500', 0, async function (done) { + try { + await audioVolumeGroupManager.getSystemVolumeInDb(-1, 3, audio.DeviceType.SPEAKER).then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}, testcase FAIL!`); + expect(false).assertTrue(); + done(); + }).catch((error) => { + if (error) { + console.log(`${TagFrmwk}:getSystemVolumeInDb error ${error.message} ${error.code}`); + expect(Number(error.code)).assertEqual(env.UNSUPORTED_OPTION_6800104); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0600 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0600', 0, async function (done) { + try { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, -1, audio.DeviceType.SPEAKER) + .then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); + expect(false).assertTrue(); + done(); + }) + .catch((error) => { + if (error) { + console.log(`${TagFrmwk}: getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(Number(error.code)).assertEqual(env.UNSUPORTED_OPTION_6800104); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0700 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0700', 0, async function (done) { + try { + let maxVol = audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA); + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, maxVol + 1, audio.DeviceType.SPEAKER) + .then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}, testcase FAIL!`); + expect(false).assertTrue(); + done(); + }) + .catch((error) => { + if (error) { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(Number(error.code)).assertEqual(env.UNSUPORTED_OPTION_6800104); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0800 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0800', 0, async function (done) { + try { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, -1).then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); + expect(data).assertEqual(env.DEAFULT_MEDIA_DB); + done(); + }).catch((error) => { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0900 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_0900', 0, async function (done) { + try { + await audioVolumeGroupManager.getSystemVolumeInDb('123', 3, audio.DeviceType.SPEAKER).then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); + expect(false).assertTrue(); + done(); + }).catch((error) => { + if (error) { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1000 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1000', 0, async function (done) { + try { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, '123', audio.DeviceType.SPEAKER) + .then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); + expect(false).assertTrue(); + done(); + }) + .catch((error) => { + if (error) { + console.log(`${TagFrmwk}:getSystemVolumeInDb error: ${error.message} ${error.code}`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1100 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_PROMISE_1100', 0, async function (done) { + try { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, audio.DeviceType.MIC) + .then((data) => { + console.info(`getSystemVolumeInDb :SUCCESS ${data}`); + expect(data).assertEqual(env.DEAFULT_MEDIA_DB); + done(); + }) + .catch((error) => { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${error.message} ${error.code}`); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1200 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1200', 0, async function (done) { + await audioVolumeGroupManager.getSystemVolumeInDb(3, audio.DeviceType.SPEAKER, (err, data) => { + if (err) { + console.log(`${TagFrmwk}getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(Number(err.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } else { + console.log(`${TagFrmwk}: getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(false).assertTrue(); + done(); + } + }); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1300 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1300', 0, async function (done) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, audio.DeviceType.SPEAKER, (err, data) => { + if (err) { + console.log(`${TagFrmwk} getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(Number(err.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } else { + console.log(`${TagFrmwk} getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(false).assertTrue(); + done(); + } + }); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1400 + * @tc.name : getSystemVolumeInDb - Media - Promise + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1400', 0, async function (done) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, (err, data) => { + if (err) { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(Number(err.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } else { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(false).assertTrue(); + done(); + } + }); + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1500 + * @tc.name : getSystemVolumeInDb - Media - Callback + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1500', 0, async function (done) { + try { + var db1 = new ArrayList(); + var db2 = new ArrayList(); + var device = [audio.DeviceType.SPEAKER, audio.DeviceType.EARPIECE, audio.DeviceType.WIRED_HEADSET]; + for (var deviceIndex = 0; deviceIndex < device.length; deviceIndex++) { + for (let typeIndex in audio.AudioVolumeType) { + let maxVol = await audioVolumeGroupManager.getMaxVolume(audio.AudioVolumeType[typeIndex]); + let minVol = await audioVolumeGroupManager.getMinVolume(audio.AudioVolumeType[typeIndex]); + for (let volIndex = minVol; volIndex <= maxVol; volIndex++) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[typeIndex], volIndex, device[deviceIndex], (err, data) => { + if (err) { + console.info(`getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(false).assertTrue(); + done(); + } else { + db1.add(data); + } + }); + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType[typeIndex], volIndex, device[deviceIndex], (err, data) => { + if (err) { + console.info(`getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(false).assertTrue(); + done(); + } else { + db2.add(data); + } + }); + await sleep(20); + } + } + } + console.log(`${TagFrmwk}:getSystemVolumeInDb : SUCCESS`); + for (let i = 0; i < db1.length; i++) { + expect(db1[i]).assertEqual(db2[i]); + } + done(); + } catch (error) { + console.info(`GETSYSTEMVOLUMEINDB error ${error.message}, code ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1600 + * @tc.name : getSystemVolumeInDb - Media - Callback + * @tc.desc : Gets the volume db value that system calculate by volume type, volume level and device type + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_GETSYSTEMVOLUMEINDB_CALLBACK_1600', 0, async function (done) { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 0, audio.DeviceType.SPEAKER, (err, data) => { + if (err) { + console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${err.message} ${err.code}`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwk}:getSystemVolumeInDb SUCCESS dB:${data}`); + expect(data).assertEqual(0); + done(); + } + }) + }) + }) +} diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/IsVolumeUnadjustable.test.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/IsVolumeUnadjustable.test.ets new file mode 100644 index 000000000..97fd82d5a --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/IsVolumeUnadjustable.test.ets @@ -0,0 +1,189 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import audio from '@ohos.multimedia.audio'; +import featureAbility from '@ohos.ability.featureAbility'; +import * as env from './Const.ets'; + +export default function audioManagerTest() { + describe('isVolumeUnadjustable', function () { + let audioManager = null; + let audioVolumeManager = null; + let audioVolumeGroupManager = null; + let TagFrmwk = "audioManagerEnhanceTest"; + const VOLUME_ADJUST_UP = 0; + const VOLUME_ADJUST_DOWN = 1; + beforeAll(async function () { + console.info('TestLog: Start Testing audioManagerTest Interfaces\n'); + await getPermission(); + await sleep(3000); + }) + beforeEach(async function () { + console.info(`${TagFrmwk}: beforeEach: Prerequisites at the test case level`); + getAudioManager(); + await sleep(100); + }) + afterEach(async function () { + console.info(`${TagFrmwk}: afterEach: Test case-level clearance conditions`); + await sleep(100); + }) + afterAll(function () { + console.info(`${TagFrmwk}: afterAll: Test suite-level cleanup condition`); + }) + function getAudioManager() { + audioManager = audio.getAudioManager(); + if (audioManager != null) { + console.info(`${TagFrmwk}: getAudioManger : PASS`); + audioVolumeManager = audioManager.getVolumeManager(); + console.info(`${TagFrmwk}: getVolumeManager : PASS`); + let groupid = audio.DEFAULT_VOLUME_GROUP_ID; + audioVolumeManager.getVolumeGroupManager(groupid, (err, value) => { + if (err) { + console.info("getVolumeGroupManager failed. err:" + JSON.stringify(err)); + console.info("groupid:" + groupid); + return; + } + console.info("getVolumeGroupManager success"); + audioVolumeGroupManager = value; + }); + } + else { + console.info(`${TagFrmwk}: getAudioManger : FAIL`); + } + } + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + async function getPermission() { + console.info("getPermission IN\n") + let permissions = ['ohos.permission.MICROPHONE','ohos.permission.MODIFY_AUDIO_SETTINGS','ohos.permission.ACCESS_NOTIFICATION_POLICY']; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("request success" + JSON.stringify(data)); + }) + } + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ISVOLUMEUNADJUSTABLE_0100 + *@tc.name : isVolumeUnadjustable - Media + *@tc.desc : Judge volume is Unadjustable or adjustable + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ISVOLUMEUNADJUSTABLE_0100', 0, async function (done) { + try { + let bol = await audioVolumeGroupManager.isVolumeUnadjustable(); + if (bol == false || bol == true) { + console.info(`isVolumeUnadjustable SUCCESS, is ${bol}`); + expect(true).assertTrue(); + done(); + } else { + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.log(`isVolumeUnadjustable error: ${error.code}, message ${error.message}`); + expect(false).assertTrue(); + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ISVOLUMEUNADJUSTABLE_0200 + *@tc.name : isVolumeUnadjustable - Media + *@tc.desc : Judge volume is Unadjustable or adjustable + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ISVOLUMEUNADJUSTABLE_0200', 0, async function (done) { + try { + let bol = await audioVolumeGroupManager.isVolumeUnadjustable(); + if (bol == false) { + let vol = await audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA); + await audioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, vol + 1); + let vol1 = await audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA); + expect(bol).assertEqual(false); + expect(vol1).assertEqual(vol + 1); + done(); + } else { + let vol2 = await audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA); + await audioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, vol2 + 1).then(() => { + console.info(`setVolume SUCCESS !, testcase fail !`); + }).catch((error) => { + if (error.code == 6800301) { + console.log(`${TagFrmwk}: setVolume error:${error.code}, system volume cannot be changed !`); + let vol3 = audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA); + expect(bol).assertEqual(true); + expect(vol3).assertEqual(vol2); + done(); + } else { + console.log(`${TagFrmwk}: setVolume error, unkown error: ${error.message} ${error.code}`); + expect(false).assertTrue(); + done(); + } + }); + } + } catch (error) { + console.log(`isVolumeUnadjustable error ${error.message} ${error.code}, testcase FAIL !`); + expect(false).assertTrue(); + done(); + } + }) + + /** + *@tc.number : SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ISVOLUMEUNADJUSTABLE_0300 + *@tc.name : isVolumeUnadjustable - Media + *@tc.desc : Judge volume is Unadjustable or adjustable + *@tc.size : MEDIUM + *@tc.type : Function + *@tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_VOLUME_GROUP_MANAGER_ISVOLUMEUNADJUSTABLE_0300', 0, async function (done) { + try { + let bol = await audioVolumeGroupManager.isVolumeUnadjustable(); + if (bol == false) { + let Vol = await audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA); + await audioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, Vol - 1); + let Vol1 = await audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA); + expect(bol).assertEqual(false); + expect(Vol1).assertEqual(Vol - 1); + done(); + } else { + let Vol2 = await audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA); + await audioVolumeGroupManager.setVolume(audio.AudioVolumeType.MEDIA, Vol2 - 1).then(() => { + }).catch((error) => { + if (error.code == 6800301) { + console.log(`${TagFrmwk} setVolume error: ${error.code}, system volume cannot be changed!`); + let Vol3 = audioVolumeGroupManager.getVolume(audio.AudioVolumeType.MEDIA); + expect(bol).assertEqual(true); + expect(Vol3).assertEqual(Vol2); + done(); + } else { + console.log(`${TagFrmwk}: setVolume : error ${error.code}, unknown error! `); + expect(false).assertTrue(); + done(); + } + }); + } + } catch (error) { + console.log(`isVolumeUnadjustable unknown error: error ${error.message} ${error.code}`); + expect(false).assertTrue(); + done(); + } + }) + + }) +} diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/List.test.ets b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..6139d15a1 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/ets/test/List.test.ets @@ -0,0 +1,23 @@ +/* + * 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 isVolumeUnadjustable from './IsVolumeUnadjustable.test.ets'; +import getSystemVolumeInDb from './GetSystemVolumeInDb.test.ets'; +import getMax_Minvolume from './GetMax_Minvolume.test.ets'; + +export default function testsuite() { + getMax_Minvolume(); + isVolumeUnadjustable(); + getSystemVolumeInDb(); +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/base/element/color.json b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/base/element/color.json new file mode 100644 index 000000000..d66f9a7d4 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/base/element/string.json b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/base/element/string.json new file mode 100644 index 000000000..bab0cfab6 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "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/AudioManagerEnhance/src/main/resources/base/media/icon.png b/multimedia/audio/audio_js_standard/AudioManagerEnhance/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxj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eeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/Believer60s.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-1C-8000-2SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-1C-16000-2SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-1C-32000-1SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-1C-44100-2SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-1C-64000-3SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-1C-96000-4SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-2C-11025-1SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-2C-12000-2SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-2C-16000-3SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-2C-22050-2SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-2C-24000-3SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/", + "./resource/audio/audioManager/StarWars10s-2C-48000-4SW.wav ->/data/app/el2/100/base/com.example.xts_test_case/haps/entry/files/" + ] + } + ] +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/signature/openharmony_sx.p7b b/multimedia/audio/audio_js_standard/AudioRendererEnhance/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..11b321561d665856fc2b8a2ce3bf9ce7882de3c8 GIT binary patch literal 3593 zcmcgvdvp_38gE{$r4)()13JB`DD^(trSApf>9#AX0E2t|Vy24Rej>iQQ*`5^^a8-Q40z1=IXgTo59?v0v zWX|{9@80{n-}n1|_gs)2rpnE~XOVT$_l2@Nd1topJCH5>S}v18g`gle|KUYe8Ld#t zWgx5Sx*jO&%&Jx>v#Mw3s@v#9GRm=<02idy)zFM<4wj0E4mDH`%7J=@I+cnBMN<#7 zReqz9*62gxpRQ6L)EM=^prMR3fGTvM5Dgi`XudrzO-|4ZO(kj3LB->mU^K}mqW%;w z?bjc{C4Etrr^5+K@`{0N6cY_b`F3^nTs6z_8b2N45)v}KQD>;sYxRa1y?!dh(+SaC zX)x-lDn$3Z8ESuu4KlPQ%7!>;dXR3T87@vIG`-LrahkPKi5SPWi~9@$6QC1(G!zX` zyo6dK{SXwx?WHEv>BcR%33j8s-X@m7aTAd-nP5L1h6Nmf!#GMgOfxfPm_Wke)<{dU zqn0Giu;76Sj7Xa@unh^@>k!!MhFk0oaRnzSpkc4MjwENJ0$&@z>QXMu((bP}rf4_X zNFV_WhCHY#O_1&igz>jTB7qpx=4V^Nby!`biS@hDX2OK_M!{)=o@vYtH}st|=|)kb&{(g>y$v?ruhr{ui<9xzgY;}O9P5iA+)b<% z+z^FYgaDR~d$kroiMhZnHpVZWH=y+h^={aWgaiHA#StmfO>AGT2?P=BCKz`6y$%ye z#_R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Ns0O7gF^g0pk0_BxJ^ehIK)*3-Fp}F?y#Znb z=_|AYc_f*)M-gv9p-F4bA6WfTiGKT%cQ^R{bsE0AOnGYTi{E_2FEs7gocrDOFU!Wh zcl6o9KfPA9VSc<}@qziji0^Fcdi8HkQ2+8LE2dS}zS8~DTPw$|+W5`l#YNwI&@pN8 z505wQ+!g7@zdmxNd(?+#j*bw;YX2Rau%$Y&*4aH( zbLo|aZTp^kuIMf1-s7XQ<1RmO!oDogvz$5=_wvia@9JK>_mgrcD}zOn%@Q9ipyjrd zvHwOL_&(~4f-%?LNBIg!9Q)~2B?IHG8Tl$`xOgd6fJ*T~H0rDLx<)Yb`lu38D@)PK z{+h>=;OgGLoVR|RIDg;9vM)Bwdz1e0cki5Q0otw0!H{b=xm<|>R9-sg>bZ-ZX86xf z(wLNFI`$vOg{hUSE1KGJE3Xa?>w}J O-sgIf%lr84j{gBaiH$t~ literal 0 HcmV?d00001 diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/config.json b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/config.json new file mode 100644 index 000000000..d19b83e81 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/config.json @@ -0,0 +1,100 @@ +{ + "app": { + "bundleName": "com.example.xts_test_case", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "target": 7, + "releaseType": "Release" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.xts_test_case", + "name": ".entry", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "default", + "tablet" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "formsEnabled": false, + "name": ".MainAbility", + "srcLanguage": "ets", + "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": "ets", + "srcPath": "TestAbility", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "label": "$string:TestAbility_label", + "type": "page", + "visible": true, + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/MainAbility/app.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/MainAbility/app.ets new file mode 100644 index 000000000..61a9c415e --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/MainAbility/app.ets @@ -0,0 +1,34 @@ +/* + * 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 hilog from '@ohos.hilog'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test.ets'; +import featureAbility from '@ohos.ability.featureAbility'; + +export default { + onCreate() { + hilog.info(0x0000, 'mainTag', '%{public}s', 'Application onCreate'); + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.info(0x0000, 'mainTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + hilog.info(0x0000, 'mainTag', '%{public}s', 'Application onDestroy'); + }, +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/MainAbility/pages/index.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 000000000..808f6c74a --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,30 @@ +/* + * 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. + */ +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestAbility/app.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestAbility/app.ets new file mode 100644 index 000000000..f49b6eb76 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestAbility/app.ets @@ -0,0 +1,34 @@ +/* + * 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 hilog from '@ohos.hilog'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test.ets'; +import featureAbility from '@ohos.ability.featureAbility'; + +export default { + onCreate() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onCreate'); + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onDestroy'); + }, +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestAbility/pages/index.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 000000000..f54a4fc5f --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..882019408 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,53 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', + JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare'); + } + + onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', + JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', + d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', + d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +}; \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/Const.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/Const.ets new file mode 100644 index 000000000..eb3bf5f71 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/Const.ets @@ -0,0 +1,25 @@ +/* + * 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. + */ +//ts-nocheck +//public invalid +export const SAMPLING_RATE_44100 = 44100; +export const SAMPLING_RATE_48000 = 48000; +export const OUTPUT_NUMBER_0 = 0; +export const OUTPUT_NUMBER_1 = 1; + +//-------------------------------------------------------------- +export const INVALID_INPUT_PARAMETER_401 = 401; +export const INVALID_INPUT_PARAMETER_6800101 = 6800101; +export const UNSUPORTED_OPTION_6800104 = 6800104; diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetAndSetRendererSamplingRate.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetAndSetRendererSamplingRate.test.ets new file mode 100644 index 000000000..1491e0148 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetAndSetRendererSamplingRate.test.ets @@ -0,0 +1,657 @@ +/* + * 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 featureAbility from '@ohos.ability.featureAbility'; +import fs from '@ohos.file.fs'; +import * as env from './Const.ets'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import audio from '@ohos.multimedia.audio'; + +export default function audioRendererTest() { + describe('get_setRendererSamplingRate', function () { + let TagFrmwkRender = "audioRendererEnhanceTest"; + let audioRen; + console.info(`${TagFrmwkRender}: Create AudioManger Object JS Framework`); + beforeAll(function () { + console.info(`${TagFrmwkRender}: beforeAll: Prerequisites at the test suite level`); + }) + beforeEach(async function () { + console.info(`${TagFrmwkRender}: beforeEach: Prerequisites at the test case level`); + await sleep(1000); + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try{ + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info('audioRendererEnhanceTest: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + }).catch((err) => { + console.info('audioRendererEnhanceTest: AudioRender Created : ERROR : ' + err.message); + }); + }catch (error){ + console.info('audioRendererEnhanceTest: AudioRender Created : catch ERROR : ' + error.code + error.message); + } + }) + afterEach(async function () { + console.info(`${TagFrmwkRender}: afterEach: Test case-level clearance conditions`); + sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + }) + afterAll(async function () { + console.info(`${TagFrmwkRender}: afterAll: Test suite-level cleanup condition`); + }) + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + let filePath; + async function renderPlay() { + let bufferSize + try { + bufferSize = await audioRen.getBufferSize() + console.info( `audioRenderer getBufferSize success,bufferSize:${bufferSize} \n`); + await audioRen.start(); + console.info(`audioRenderer start success\n`); + } catch (err) { + console.info(`audioRenderer start : Error: ${JSON.stringify(err)}\n`); + return; + } + + var context = featureAbility.getContext(); + await context.getFilesDir().then((data) => { + console.error('#####app file: '+ data); + filePath = data; + console.error('#####app filePath: '+ filePath); + }).catch((Error) => { + console.error('####app file err: ' + Error.message); + }) + + let path = filePath + '/StarWars10s-1C-8000-2SW.wav'; + console.info(`path:${path}\n`); + try { + let len; + try { + let stat = await fs.stat(path); + console.info(`stat:${JSON.stringify(stat)}\n`); + console.info(`size:${stat.size}\n`); + len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1); + }catch (error) { + console.info(`#######audioRenderer stat : Error: ${JSON.stringify(error)}\n`); + } + + let file = await fs.open(path, 0o0); + console.info(`fd:${file.fd}\n`); + let buf = new ArrayBuffer(bufferSize); + console.info(`audioRenderer write start.......... \n`); + for (let i = 0; i < len; i++) { + let options = { + offset: i * bufferSize, + length: bufferSize + } + let readsize = await fs.read(file.fd, buf, options); + let writeSize = await audioRen.write(buf); + } + console.info(`audioRenderer write end............ \n`); + } catch (err) { + console.info(`audioRenderer write : Error: ${JSON.stringify(err)}\n`); + } + } + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_PROMISE_0100 + * @tc.name : AudioRenderer - getRendererSamplingRate "uint32" - promise + * @tc.desc : AudioRenderer - getRendererSamplingRate in prepare to get the SamplingRate + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_PROMISE_0100', 0, async function (done) { + try{ + await audioRen.getRendererSamplingRate().then((data) => { + console.info(`${TagFrmwkRender}: #####getRendererSamplingRate :SUCCESS ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_44100); + done(); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: #####getRendererSamplingRate : error = " + error); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.log("#####SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_PROMISE_0100: catch error = " + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_PROMISE_0200 + * @tc.name : AudioRenderer - getRendererSamplingRate "uint32" - promise + * @tc.desc : AudioRenderer - setRendererSamplingRate INVALID_INPUT_PARAMETER, then get the default SamplingRate + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_PROMISE_0200', 0, async function (done) { + let rate = '123'; + try{ + await audioRen.setRendererSamplingRate(rate).then((data) => { + console.info(`${TagFrmwkRender}: setRendererSamplingRate :set ${rate}, SUCCESS`); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: ####setRendererSamplingRate : error = " + error); + }); + }catch(error){ + console.log("####setRendererSamplingRate: catch error = " + error); + } + + try{ + await audioRen.getRendererSamplingRate().then((data) => { + console.info(`${TagFrmwkRender}: #####getRendererSamplingRate :SUCCESS ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_44100); + done(); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: #####getRendererSamplingRate : error = " + error); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.log("#####getRendererSamplingRate: catch error = " + error); + expect(false).assertTrue(); + done(); + } + }); + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_PROMISE_0300 + * @tc.name : AudioRenderer - getRendererSamplingRate "uint32" - promise + * @tc.desc : AudioRenderer - set a effective SamplingRate, then set a invalid SamplingRate, can get the effective SamplingRate + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_PROMISE_0300', 0, async function (done) { + let samplingrate = 48000; + try{ + await audioRen.setRendererSamplingRate(samplingrate).then((data) => { + console.info(`${TagFrmwkRender}: ####setRendererSamplingRate :set ${samplingrate}, SUCCESS`); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: ####setRendererSamplingRate : error = " + error); + }); + }catch(error){ + console.log("####setRendererSamplingRate: catch error = " + error); + } + + let rate = '123'; + try{ + await audioRen.setRendererSamplingRate(rate).then((data) => { + console.info(`${TagFrmwkRender}: setRendererSamplingRate :set ${rate}, SUCCESS`); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: ####setRendererSamplingRate : error = " + error); + }); + }catch(error){ + console.log("####setRendererSamplingRate: catch error = " + error); + } + + try{ + await audioRen.getRendererSamplingRate().then((data) => { + console.info(`${TagFrmwkRender}: #####getRendererSamplingRate :SUCCESS ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_48000); + done(); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: #####getRendererSamplingRate : error = " + error); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.log("#####getRendererSamplingRate: catch error = " + error); + expect(false).assertTrue(); + done(); + } + }); + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_PROMISE_0400 + * @tc.name : AudioRenderer - getRendererSamplingRate "uint32" - promise + * @tc.desc : AudioRenderer - getRendererSamplingRate in running + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_PROMISE_0400', 0, async function (done) { + try{ + renderPlay(); + await audioRen.getRendererSamplingRate().then((data) => { + console.info(`${TagFrmwkRender}: #####getRendererSamplingRate :SUCCESS ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_44100); + done(); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: #####getRendererSamplingRate : error = " + error); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.log("#####SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_PROMISE_0400: catch error = " + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0100 + * @tc.name : AudioRenderer -setRendererSamplingRate "uint32" - promise + * @tc.desc : AudioRenderer - setRendererSamplingRate in prepare, then getRendererSamplingRate + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0100', 0, async function (done) { + let samplingrate = 48000; + try{ + await audioRen.setRendererSamplingRate(samplingrate).then((data) => { + console.info(`${TagFrmwkRender}: #####setRendererSamplingRate :SUCCESS`); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: #####setRendererSamplingRate : error = " + error); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.log("####SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0100: catch error = " + error); + expect(false).assertTrue(); + done(); + } + + try{ + await audioRen.getRendererSamplingRate().then((data) => { + console.info(`${TagFrmwkRender}: ####getRendererSamplingRate :SUCCESS ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_48000); + done(); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: #####getRendererSamplingRate : error = " + error); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.log("#####getRendererSamplingRate: catch error = " + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0200 + * @tc.name : AudioRenderer - setRendererSamplingRate "uint32" - promise + * @tc.desc : AudioRenderer - setRendererSamplingRate input unsuported option 0 to return error.code + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0200', 0, async function (done) { + let samplingrate = 0; + try{ + await audioRen.setRendererSamplingRate(samplingrate); + }catch(error) { + if (error.code == env.UNSUPORTED_OPTION_6800104){ + console.log(`${TagFrmwkRender}: setRendererSamplingRate: catch error: [${error.code}, ${error.message}]`); + try{ + await audioRen.getRendererSamplingRate().then((data) => { + console.info(`${TagFrmwkRender}: getRendererSamplingRate :SUCCESS ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_44100); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: getRendererSamplingRate : error = " + error); + expect(false).assertTrue(); + }); + }catch(error){ + console.log("setRendererSamplingRate: catch error = " + error); + } + done(); + } else { + expect(false).assertTrue(); + done(); + } + }; + done(); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0300 + * @tc.name : AudioRenderer - setRendererSamplingRate "uint32" - promise + * @tc.desc : AudioRenderer - setRendererSamplingRate input invalid parameter '123' to return error.code + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0300', 0, async function (done) { + let samplingrate = '123'; + try{ + await audioRen.setRendererSamplingRate(samplingrate); + console.info(`####setRendererSamplingRate: execution success`); + }catch(error){ + if (error.code == env.INVALID_INPUT_PARAMETER_6800101){ + console.log(`SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0300: catch error, error: [${error.code}, ${error.message}]`); + try{ + await audioRen.getRendererSamplingRate().then((data) => { + console.info(`${TagFrmwkRender}: ####getRendererSamplingRate :SUCCESS ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_44100); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: ####getRendererSamplingRate : error = " + error); + expect(false).assertTrue(); + }); + }catch(error){ + console.log("####getRendererSamplingRate: catch error = " + error); + } + } else { + expect(false).assertTrue(); + done(); + } + }; + done(); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0400 + * @tc.name : AudioRenderer - setRendererSamplingRate "uint32" - promise + * @tc.desc : AudioRenderer - setRendererSamplingRate in running, then getRendererSamplingRate + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0400', 0, async function (done) { + let samplingrate = 48000; + try { + renderPlay(); + await audioRen.setRendererSamplingRate(samplingrate); + console.info(`SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_PROMISE_0400: execution success`); + }catch (error){ + console.log("#####setRendererSamplingRate : error = " + error); + expect(false).assertTrue(); + done(); + }; + + try{ + await audioRen.getRendererSamplingRate().then((data) => { + console.info(`${TagFrmwkRender}: ####getRendererSamplingRate :SUCCESS ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_48000); + done(); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}: #####getRendererSamplingRate : error = " + error); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.log("#####getRendererSamplingRate: catch error = " + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_CALLBACK_0100 + * @tc.name : AudioRenderer - getRendererSamplingRate "uint32" - callback + * @tc.desc : AudioRenderer - getRendererSamplingRate in prepare + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_CALLBACK_0100', 0, async function (done) { + audioRen.getRendererSamplingRate((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}: getRendererSamplingRate Success now SamplingRate: ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_44100); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_CALLBACK_0200 + * @tc.name : AudioRenderer - getRendererSamplingRate "uint32" - callback + * @tc.desc : AudioRenderer - set a valid SamplingRate, get the default SamplingRate + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_CALLBACK_0200', 0, async function (done) { + let rate = '123'; + audioRen.setRendererSamplingRate(rate, (err) => { + if (err) { + console.info(`${TagFrmwkRender}: setRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message}`); + audioRen.getRendererSamplingRate((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}: getRendererSamplingRate Success! SamplingRate: ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_44100); + done(); + } + }); + } else { + console.info(`${TagFrmwkRender}: setRendererSamplingRate : set ${rate} SUCCESS`); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_CALLBACK_0300 + * @tc.name : AudioRenderer - getRendererSamplingRate "uint32" - callback + * @tc.desc : AudioRenderer - getRendererSamplingRate + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_CALLBACK_0300', 0, async function (done) { + let rate1 = 48000; + audioRen.setRendererSamplingRate(rate1, (err) => { + if (err) { + console.info(`${TagFrmwkRender}: set rate1 ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}: set rate1: ${rate1} SUCCESS! begin set rate2`); + let rate2 = '123'; + audioRen.setRendererSamplingRate(rate2, (err) => { + if (err) { + console.info(`${TagFrmwkRender}: set rate2 ERROR! code: ${err.code}, mesage: ${err.message}`); + audioRen.getRendererSamplingRate((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}: getRendererSamplingRate Success now sampling rate: ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_48000); + done(); + } + }); + } else { + console.info(`${TagFrmwkRender}: set Rate2: ${rate2} SUCCESS! testcase FAIL!`); + expect(false).assertTrue(); + done(); + } + }); + } + }); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_CALLBACK_0400 + * @tc.name : AudioRenderer - getRendererSamplingRate "uint32" - callback + * @tc.desc : AudioRenderer - getRendererSamplingRate "uint32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETRENDERERSAMPLINGRATE_CALLBACK_0400', 0, async function (done) { + renderPlay(); + audioRen.getRendererSamplingRate((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}:getRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}:getRendererSamplingRate Success! now samplingRate: ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_44100); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_CALLBACK_0100 + * @tc.name : AudioRenderer - setRendererSamplingRate "uint32" - callback + * @tc.desc : AudioRenderer - setRendererSamplingRate "uint32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_CALLBACK_0100', 0, async function (done) { + let rate = 48000; + audioRen.setRendererSamplingRate(rate, (err) => { + if (err) { + console.info(`${TagFrmwkRender}: setRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}: setRendererSamplingRate : set ${rate} SUCCESS start getting samplingRate`); + audioRen.getRendererSamplingRate((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}: getRendererSamplingRate Success! samplingRate: ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_48000); + done(); + } + }); + } + }); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_CALLBACK_0200 + * @tc.name : AudioRenderer - setRendererSamplingRate "uint32" - callback + * @tc.desc : AudioRenderer - setRendererSamplingRate "uint32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_CALLBACK_0200', 0, async function (done) { + let rate = 0; + audioRen.setRendererSamplingRate(rate, (err) => { + if (err.code == env.UNSUPORTED_OPTION_6800104) { + console.info(`${TagFrmwkRender}: setRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message} start getting samplingRate`); + audioRen.getRendererSamplingRate((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}: getRendererSamplingRate Success! now samplingRate: ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_44100); + done(); + } + }); + } else { + console.info(`${TagFrmwkRender}: setRendererSamplingRate Success! testcase FAIL!`); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_CALLBACK_0300 + * @tc.name : AudioRenderer - setRendererSamplingRate "uint32" - callback + * @tc.desc : AudioRenderer - setRendererSamplingRate "uint32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_CALLBACK_0300', 0, async function (done) { + let rate = '123'; + audioRen.setRendererSamplingRate(rate, (err) => { + if (err.code == env.INVALID_INPUT_PARAMETER_6800101) { + console.info(`${TagFrmwkRender}: setRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message} start getting samplingRate`); + audioRen.getRendererSamplingRate((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}:getRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}:getRendererSamplingRate Success! now samplingRate: ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_44100); + done(); + } + }); + } else { + console.info(`${TagFrmwkRender}: setRendererSamplingRate Success! testcase FAIL!`); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_CALLBACK_0400 + * @tc.name : AudioRenderer - setRendererSamplingRate "uint32" - callback + * @tc.desc : AudioRenderer - setRendererSamplingRate "uint32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_SETRENDERERSAMPLINGRATE_CALLBACK_0400', 0, async function (done) { + let rate = 48000; + renderPlay(); + audioRen.setRendererSamplingRate(rate, (err) => { + if (err) { + console.info(`${TagFrmwkRender}:setRendererSamplingRate ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}:setRendererSamplingRate : set samplingRate:${rate} SUCCESS! start getting samplingRate`); + audioRen.getRendererSamplingRate((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}:getRendererSamplingRate : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}:getRendererSamplingRate : Success ${data}`); + expect(data).assertEqual(env.SAMPLING_RATE_48000); + done(); + } + }); + } + }); + }); + }) +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetCurrentOutputDevices.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetCurrentOutputDevices.test.ets new file mode 100644 index 000000000..87d30d4bc --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetCurrentOutputDevices.test.ets @@ -0,0 +1,255 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import audio from '@ohos.multimedia.audio'; +import fs from '@ohos.file.fs'; +import featureAbility from '@ohos.ability.featureAbility'; +import * as env from './Const.ets'; + +export default function audioRendererTest() { + describe('getCurrentOutputDevices', function () { + let TagFrmwkRender = "audioRendererEnhanceTest"; + let audioRen; + console.info(`${TagFrmwkRender}: Create AudioManger Object JS Framework`); + beforeAll(function () { + console.info(`${TagFrmwkRender}: beforeAll: Prerequisites at the test suite level`); + }) + beforeEach(async function () { + console.info(`${TagFrmwkRender}: beforeEach: Prerequisites at the test case level`); + await sleep(1000); + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try{ + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info('audioRendererEnhanceTest: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('audioRendererEnhanceTest: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('audioRendererEnhanceTest: AudioRender Created : ERROR : ' + err.message); + }); + }catch (error){ + console.info('audioRendererEnhanceTest: AudioRender Created : catch ERROR : ' + error.code + error.message); + } + }) + afterEach(async function () { + console.info(`${TagFrmwkRender}: afterEach: Test case-level clearance conditions`); + sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + }) + afterAll(async function () { + console.info(`${TagFrmwkRender}: afterAll: Test suite-level cleanup condition`); + }) + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + let filePath; + async function renderPlay() { + let bufferSize + try { + bufferSize = await audioRen.getBufferSize() + console.info( `audioRenderer getBufferSize success,bufferSize:${bufferSize} \n`); + await audioRen.start(); + console.info(`audioRenderer start success\n`); + } catch (err) { + console.info(`audioRenderer start : Error: ${JSON.stringify(err)}\n`); + return; + } + + var context = featureAbility.getContext(); + await context.getFilesDir().then((data) => { + console.error('#####app file: '+ data); + filePath = data; + console.error('#####app filePath: '+ filePath); + }).catch((Error) => { + console.error('####app file err: ' + Error.message); + }) + + let path = filePath + '/StarWars10s-1C-8000-2SW.wav'; + console.info(`path:${path}\n`); + try { + let len; + try { + let stat = await fs.stat(path); + console.info(`stat:${JSON.stringify(stat)}\n`); + console.info(`size:${stat.size}\n`); + len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1); + }catch (error) { + console.info(`#######audioRenderer stat : Error: ${JSON.stringify(error)}\n`); + } + + let file = await fs.open(path, 0o0); + console.info(`fd:${file.fd}\n`); + + let buf = new ArrayBuffer(bufferSize); + console.info(`audioRenderer write start.......... \n`); + for (let i = 0; i < len; i++) { + let options = { + offset: i * bufferSize, + length: bufferSize + } + let readsize = await fs.read(file.fd, buf, options); + let writeSize = await audioRen.write(buf); + } + console.info(`audioRenderer write end............ \n`); + } catch (err) { + console.info(`audioRenderer write : Error: ${JSON.stringify(err)}\n`); + } + } + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_PROMISE_0100 + * @tc.name : AudioRenderer -getCurrentOutputDevices "struct" - promise + * @tc.desc : AudioRenderer - getCurrentOutputDevices "struct" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_PROMISE_0100', 0, async function (done) { + try { + await audioRen.getCurrentOutputDevices().then((data) => { + console.info(`${TagFrmwkRender}: deviceRole:${data.deviceRole}, deviceType:${data.deviceType}, id:${data.id}, name:${data.name}, address:${data.address}, sampleRates:${data.sampleRates}, channelCounts:${data.channelCounts}, channelMasks:${data.channelMasks}`); + expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); + expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); + expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + done(); + }).catch((error) => { + console.log("${TagFrmwkRender}: getCurrentOutputDevices error = " + error); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info(`get current output deviceinfo unknown errro: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_PROMISE_0200 + * @tc.name : AudioRenderer -getCurrentOutputDevices "struct" - promise + * @tc.desc : AudioRenderer - getCurrentOutputDevices "struct" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_PROMISE_0200', 0, async function (done) { + try { + await renderPlay(); + await audioRen.getCurrentOutputDevices().then((data) => { + console.info(`${TagFrmwkRender}: deviceRole:${data.deviceRole}, deviceType:${data.deviceType}, id:${data.id}, address:${data.address}, sampleRates:${data.sampleRates}, channelCounts:${data.channelCounts}, channelMasks:${data.channelMasks}`); + expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); + expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); + expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + console.info(`${TagFrmwkRender}: Renderer get current output device SUCCESS, now stop audiorender`); + audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drain : SUCCESS, stop audiorender`); + audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopp : SUCCESS`); + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + }).catch((error) => { + console.log("${TagFrmwkRender}: getCurrentOutputDevices : error = " + error); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_CALLBACK_0100 + * @tc.name : AudioRenderer -getCurrentOutputDevices "struct" - callback + * @tc.desc : AudioRenderer - getCurrentOutputDevices "struct" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_CALLBACK_0100', 0, async function (done) { + audioRen.getCurrentOutputDevices((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getCurrentOutputDevices ERROR ! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + } else { + console.info(`${TagFrmwkRender}: deviceRole:${data.deviceRole}, deviceType:${data.deviceType}, id:${data.id}, address:${data.address}, sampleRates:${data.sampleRates}, channelCounts:${data.channelCounts}, channelMasks:${data.channelMasks}`); + expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); + expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); + expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_CALLBACK_0200 + * @tc.name : AudioRenderer -getCurrentOutputDevices "struct" - callback + * @tc.desc : AudioRenderer - getCurrentOutputDevices "struct" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETCURRENTOUTPUTDEVICES_CALLBACK_0200', 0, async function (done) { + await renderPlay(); + audioRen.getCurrentOutputDevices((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getCurrentOutputDevices ERROR! error: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}: getCurrentOutputDevices :deviceRole:${data.deviceRole}, deviceType:${data.deviceType}, id:${data.id}, address:${data.address}, sampleRates:${data.sampleRates}, channelCounts:${data.channelCounts}, channelMasks:${data.channelMasks}`); + expect(data.deviceRole).assertEqual(audio.DeviceRole.OUTPUT_DEVICE); + expect(data.deviceType).assertEqual(audio.DeviceType.SPEAKER); + expect(data.id).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + console.info(`${TagFrmwkRender}: Renderer getCurrentOutputDevices SUCCESS! now stop the audiorenderer`); + audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drain, stop the audiorenderer`); + audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopp SUCCESS, testcase SUCCESS!`); + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + } + }); + }); + }) +} diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetMaxAndMinStreamVolume.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetMaxAndMinStreamVolume.test.ets new file mode 100644 index 000000000..5949abf58 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetMaxAndMinStreamVolume.test.ets @@ -0,0 +1,782 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import audio from '@ohos.multimedia.audio'; +import fs from '@ohos.file.fs'; +import featureAbility from '@ohos.ability.featureAbility'; +import * as env from './Const.ets'; + +export default function audioRendererTest() { + describe('getMax_MinStreamVolume', function () { + let TagFrmwkRender = "audioRendererEnhanceTest"; + let audioRen; + console.info(`${TagFrmwkRender}: Create AudioManger Object JS Framework`); + beforeAll(function () { + console.info(`${TagFrmwkRender}: beforeAll: Prerequisites at the test suite level`); + }) + beforeEach(async function () { + console.info(`${TagFrmwkRender}: beforeEach: Prerequisites at the test case level`); + await sleep(1000); + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try{ + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info('audioRendererEnhanceTest: AudioRender Created : Stream Type:STREAM_USAGE_MEDIA SUCCESS data state: ' + Object.keys(data)); + console.info('audioRendererEnhanceTest: AudioRender Created : Stream Type:STREAM_USAGE_MEDIA SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('audioRendererEnhanceTest: AudioRender Created : ERROR : ' + err.message); + }); + }catch (error){ + console.info('audioRendererEnhanceTest: AudioRender Created : catch ERROR : ' + error.code + error.message); + } + }) + afterEach(async function () { + console.info(`${TagFrmwkRender}: afterEach: Test case-level clearance conditions`); + sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + }) + afterAll(async function () { + console.info(`${TagFrmwkRender}: afterAll: Test suite-level cleanup condition`); + }) + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + let filePath; + async function renderPlay() { + let bufferSize + try { + bufferSize = await audioRen.getBufferSize() + console.info( `audioRenderer getBufferSize success,bufferSize:${bufferSize} \n`); + await audioRen.start(); + console.info(`audioRenderer start success\n`); + } catch (err) { + console.info(`audioRenderer start : Error: ${JSON.stringify(err)}\n`); + return; + } + + var context = featureAbility.getContext(); + await context.getFilesDir().then((data) => { + console.error('#####app file: '+ data); + filePath = data; + console.error('#####app filePath: '+ filePath); + }).catch((Error) => { + console.error('####app file err: ' + Error.message); + }) + + let path = filePath + '/StarWars10s-1C-8000-2SW.wav'; + console.info(`path:${path}\n`); + try { + let len; + try { + let stat = await fs.stat(path); + console.info(`stat:${JSON.stringify(stat)}\n`); + console.info(`size:${stat.size}\n`); + len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1); + console.info(`len:${len}\n`); + }catch (error) { + console.info(`#######audioRenderer stat : Error: ${JSON.stringify(error)}\n`); + } + + let file = await fs.open(path, 0o0); + console.info(`fd:${file.fd}\n`); + + let buf = new ArrayBuffer(bufferSize); + console.info(`audioRenderer write start.......... \n`); + + let inputVolume = 0.5; + await audioRen.setVolume(inputVolume).then(() => { + console.info(`${TagFrmwkRender}: setVolume to 0.5 : Success`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + }); + + for (let i = 0; i < len; i++) { + let options = { + offset: i * bufferSize, + length: bufferSize + } + let readsize = await fs.read(file.fd, buf, options); + let writeSize = await audioRen.write(buf); + + if (i == len - 100) { + await audioRen.getMinStreamVolume().then((data) => { + console.info(`${TagFrmwkRender}: #####getMinStreamVolume :SUCCESS ${data}`); + inputVolume = data; + }).catch ((error)=>{ + console.log("#####getMinStreamVolume : error = " + error); + }); + await audioRen.setVolume(inputVolume).then(() => { + console.info(`${TagFrmwkRender}: setVolume to ${inputVolume} : Success`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + }); + } + + if(i == len - 50){ + await audioRen.getMaxStreamVolume().then((data) => { + console.info(`${TagFrmwkRender}: #####getMaxStreamVolume :SUCCESS ${data}`); + inputVolume = data; + }).catch ((error)=>{ + console.log("#####getMaxStreamVolume : error = " + error); + }); + await audioRen.setVolume(inputVolume).then(() => { + console.info(`${TagFrmwkRender}: setVolume to ${inputVolume} : Success`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + }); + } + + } + console.info(`audioRenderer write end............ \n`); + } catch (err) { + console.info(`audioRenderer write : Error: ${JSON.stringify(err)}\n`); + } + } + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0100 + * @tc.name : AudioRenderer -getMaxStreamVolume "unit_32" - promise + * @tc.desc : AudioRenderer - getMaxStreamVolume "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0100', 0, async function (done) { + try{ + await audioRen.getMaxStreamVolume().then((data) => { + console.info(`${TagFrmwkRender}:getMaxStreamVolume :SUCCESS ${data}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_1); + done(); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}:getMaxStreamVolume : error = " + error); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.log("GETMAXSTREAMVOLUME catch error = " + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0200 + * @tc.name : AudioRenderer -getMaxStreamVolume "unit_32" - promise + * @tc.desc : AudioRenderer - getMaxStreamVolume "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0200', 0, async function (done) { + try{ + await renderPlay(); + await audioRen.getMaxStreamVolume().then((data) => { + console.info(`${TagFrmwkRender}:getMaxStreamVolume :SUCCESS ${data}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_1); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}:getMaxStreamVolume : error = " + error); + expect(false).assertTrue(); + done(); + }); + await audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + await audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + done(); + }catch(error){ + console.log("GETMAXSTREAMVOLUME catch error = " + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0300 + * @tc.name : AudioRenderer -getMaxStreamVolume "unit_32" - promise + * @tc.desc : AudioRenderer - getMaxStreamVolume "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0300', 0, async function (done) { + let StreamType; + try{ + for (StreamType in audio.StreamUsage) { + let audioRender; + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: StreamType, + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try { + if (Number(audio.StreamUsage[StreamType]) != 9) { + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); + }); + } else { + audioRender = audioRen; + } + } catch (error) { + console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); + } + await audioRender.getMaxStreamVolume().then((data) => { + console.info(`${TagFrmwkRender}:getMaxStreamVolume:Stream Type: ${StreamType} SUCCESS ${data}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_1); + }).catch ((error)=>{ + console.info(`${TagFrmwkRender}:getMaxStreamVolume:Stream Type: ${StreamType} ERROR : code: ${error.code}, mesage: ${error.message}`); + expect(false).assertTrue(); + done(); + }); + + sleep(1000); + await audioRender.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + } + done(); + }catch (error){ + console.info(`GETMAXSTREAMVOLUME Stream ERROR : code: ${error.code}, mesage: ${error.message}`); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0400 + * @tc.name : AudioRenderer -getMaxStreamVolume "unit_32" - promise + * @tc.desc : AudioRenderer - getMaxStreamVolume "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_PROMISE_0400', 0, async function (done) { + try{ + await audioRen.getMaxStreamVolume().then((data) => { + console.info(`${TagFrmwkRender}:getMaxStreamVolume :SUCCESS ${data}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_1); + audioRen.setVolume(data).then(() => { + console.info(`${TagFrmwkRender}: setVolume to maxVolume Success! maxVolume: ${data}`); + expect(true).assertTrue(); + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + }); + }).catch ((error)=>{ + console.info(`${TagFrmwkRender}:getMaxStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.info(`GETMAXSTREAMVOLUME catch error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0100 + * @tc.name : AudioRenderer -getMinStreamVolume "unit_32" - promise + * @tc.desc : AudioRenderer - getMinStreamVolume "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0100', 0, async function (done) { + try{ + await audioRen.getMinStreamVolume().then((data) => { + console.info(`${TagFrmwkRender}:getMinStreamVolume :SUCCESS ${data}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_0); + done(); + }).catch ((error)=>{ + console.info(`${TagFrmwkRender}:getMinStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.info(`GETMINSTREAMVOLUME catch error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0200 + * @tc.name : AudioRenderer -getMinStreamVolume "unit_32" - promise + * @tc.desc : AudioRenderer - getMinStreamVolume "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0200', 0, async function (done) { + try{ + await renderPlay(); + await audioRen.getMinStreamVolume().then((data) => { + console.info(`${TagFrmwkRender}:getMinStreamVolume :SUCCESS ${data}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_0); + }).catch ((error)=>{ + console.info(`${TagFrmwkRender}:getMinStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); + expect(false).assertTrue(); + done(); + }); + await audioRen.drain().then(() => { + console.info(`${TagFrmwkRender}: Renderer drained : SUCCESS`); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + await audioRen.stop().then(() => { + console.info(`${TagFrmwkRender}: Renderer stopped : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + done(); + }catch(error){ + console.info(`GETMINSTREAMVOLUME catch error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0300 + * @tc.name : AudioRenderer -getMinStreamVolume "unit_32" - promise + * @tc.desc : AudioRenderer - getMinStreamVolume "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0300', 0, async function (done) { + let StreamType; + try{ + for (StreamType in audio.StreamUsage) { + let audioRender; + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: StreamType, + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try { + if (Number(audio.StreamUsage[StreamType]) != 9) { + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); + }); + } else { + audioRender = audioRen; + } + } catch (error) { + console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); + } + await audioRender.getMinStreamVolume().then((data) => { + console.info(`${TagFrmwkRender}:getMinStreamVolume:Stream Type: ${StreamType} SUCCESS ${data}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_0); + }).catch ((error)=>{ + console.info(`${TagFrmwkRender}:getMinStreamVolume:Stream Type: ${StreamType} ERROR : code: ${error.code}, mesage: ${error.message}`); + expect(false).assertTrue(); + done(); + }); + + sleep(1000); + await audioRender.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + } + done(); + }catch (error){ + console.info(`GETMINSTREAMVOLUME Stream ERROR : code: ${error.code}, mesage: ${error.message}`); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0400 + * @tc.name : AudioRenderer -getMinStreamVolume "unit_32" - promise + * @tc.desc : AudioRenderer - getMinStreamVolume "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_PROMISE_0400', 0, async function (done) { + try{ + await audioRen.getMinStreamVolume().then((data) => { + console.info(`${TagFrmwkRender}: getMinStreamVolume :SUCCESS ${data}`); + expect(data).assertEqual(env.OUTPUT_NUMBER_0); + audioRen.setVolume(data).then(() => { + console.info(`${TagFrmwkRender}: setVolume to minVolume Success! minVolume: ${data}`); + expect(true).assertTrue(); + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + }); + }).catch ((error)=>{ + console.info(`${TagFrmwkRender}:getMinStreamVolume : ERROR : code: ${error.code}, mesage: ${error.message}`); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.info(`GETMINSTREAMVOLUME catch error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_CALLBACK_0100 + * @tc.name : AudioRenderer - getMaxStreamVolume "uint_32" - callback + * @tc.desc : AudioRenderer - getMaxStreamVolume "uint_32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_CALLBACK_0100', 0, async function (done) { + audioRen.getMaxStreamVolume((err, maxVolume) => { + if (err) { + console.error('${TagFrmwkRender} Get max stream volume Fail: ${err}'); + expect(false).assertTrue(); + done(); + } else { + console.info('${TagFrmwkRender} Get max stream volume Success! ${maxVolume}'); + expect(maxVolume).assertEqual(env.OUTPUT_NUMBER_1); + done(); + } + }) + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_CALLBACK_0200 + * @tc.name : AudioRenderer - getMaxStreamVolume "uint_32" - callback + * @tc.desc : AudioRenderer - getMaxStreamVolume "uint_32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_CALLBACK_0200', 0, async function (done) { + await renderPlay(); + audioRen.getMaxStreamVolume((err, maxVolume) => { + if (err) { + console.error('${TagFrmwkRender} Get max stream volume Fail: ${err}'); + expect(false).assertTrue(); + done(); + } else { + console.info('${TagFrmwkRender} Get max stream volume Success! ${maxVolume}'); + expect(maxVolume).assertEqual(env.OUTPUT_NUMBER_1); + done(); + } + }) + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_CALLBACK_0300 + * @tc.name : AudioRenderer - getMaxStreamVolume "uint_32" - callback + * @tc.desc : AudioRenderer - getMaxStreamVolume "uint_32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_CALLBACK_0300', 0, async function (done) { + let StreamType; + try{ + for (StreamType in audio.StreamUsage) { + let audioRender; + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: StreamType, + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try { + if (Number(audio.StreamUsage[StreamType]) != 9) { + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); + }); + } else { + audioRender = audioRen; + } + } catch (error) { + console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); + } + audioRen.getMaxStreamVolume((err, maxVolume) => { + if (err) { + console.error('${TagFrmwkRender} Get max stream volume Fail: ${err}'); + expect(false).assertTrue(); + done(); + } else { + console.info('${TagFrmwkRender} Get max stream volume Success! ${maxVolume}'); + expect(maxVolume).assertEqual(env.OUTPUT_NUMBER_1); + done(); + } + }) + + sleep(1000); + await audioRender.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + } + done(); + + }catch(error){ + console.log(`${TagFrmwkRender}:getMaxStreamVolume: catch error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } + + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_CALLBACK_0400 + * @tc.name : AudioRenderer - getMaxStreamVolume "uint_32" - callback + * @tc.desc : AudioRenderer - getMaxStreamVolume "uint_32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMAXSTREAMVOLUME_CALLBACK_0400', 0, async function (done) { + audioRen.getMaxStreamVolume((err, maxVolume) => { + if (err) { + console.error('${TagFrmwkRender} Get max stream volume Fail: ${err}'); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender} Get max stream volume Success! maxVolume: ${maxVolume}`); + expect(maxVolume).assertEqual(env.OUTPUT_NUMBER_1); + audioRen.setVolume(maxVolume).then(() => { + console.info(`${TagFrmwkRender}: setVolume to maxVolume Success! maxVolume: ${maxVolume}`); + expect(true).assertTrue(); + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume ERROR! : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + }); + } + }) + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_CALLBACK_0100 + * @tc.name : AudioRenderer - getMinStreamVolume "float" - callback + * @tc.desc : AudioRenderer - getMinStreamVolume "float" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_CALLBACK_0100', 0, async function (done) { + audioRen.getMinStreamVolume((err, minVolume) => { + if (err) { + console.error('${TagFrmwkRender} Get min stream volume Fail: ${err}'); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender} Get min stream volume Success! minVolume: ${minVolume}`); + expect(minVolume).assertEqual(env.OUTPUT_NUMBER_0); + done(); + } + }) + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_CALLBACK_0200 + * @tc.name : AudioRenderer - getMinStreamVolume "uint_32" - callback + * @tc.desc : AudioRenderer - getMinStreamVolume "uint_32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_CALLBACK_0200', 0, async function (done) { + await renderPlay(); + audioRen.getMinStreamVolume((err, minVolume) => { + if (err) { + console.error('${TagFrmwkRender} Get min stream volume Fail: ${err}'); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender} Get min stream volume Success! minVolume: ${minVolume}`); + expect(minVolume).assertEqual(env.OUTPUT_NUMBER_0); + done(); + } + }) + }); + + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_CALLBACK_0300 + * @tc.name : AudioRenderer - getMinStreamVolume "uint_32" - callback + * @tc.desc : AudioRenderer - getMinStreamVolume "uint_32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_CALLBACK_0300', 0, async function (done) { + let StreamType; + + try{ + for (StreamType in audio.StreamUsage) { + let audioRender; + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: StreamType, + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try { + if (Number(audio.StreamUsage[StreamType]) != 9) { + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); + }); + } else { + audioRender = audioRen; + } + } catch (error) { + console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); + } + audioRen.getMinStreamVolume((err, minVolume) => { + if (err) { + console.error('${TagFrmwkRender} Get min stream volume Fail: ${err}'); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender} Get min stream volume Success! minVolume: ${minVolume}`); + expect(minVolume).assertEqual(env.OUTPUT_NUMBER_0); + } + }) + + sleep(1000); + await audioRender.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + } + done(); + }catch(error){ + console.log(`${TagFrmwkRender}:getMinStreamVolume: catch error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_CALLBACK_0400 + * @tc.name : AudioRenderer - getMinStreamVolume "float" - callback + * @tc.desc : AudioRenderer - getMinStreamVolume "float" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETMINSTREAMVOLUME_CALLBACK_0400', 0, async function (done) { + let minVolume = 1.0; + audioRen.getMinStreamVolume((err, minVolume) => { + if (err) { + console.error('${TagFrmwkRender} Get min stream volume Fail: ${err}'); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender} Get min stream volume Success! minVolume: ${minVolume}`); + expect(minVolume).assertEqual(env.OUTPUT_NUMBER_0); + audioRen.setVolume(minVolume).then(() => { + console.info(`${TagFrmwkRender}: setVolume to minVolume Success! minVolume: ${minVolume}`); + expect(true).assertTrue(); + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: setVolume : ERROR : code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + }); + } + }) + }); + + }) +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetUnderflowCount.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetUnderflowCount.test.ets new file mode 100644 index 000000000..bd0e579f7 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetUnderflowCount.test.ets @@ -0,0 +1,384 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import audio from '@ohos.multimedia.audio'; +import fs from '@ohos.file.fs'; +import featureAbility from '@ohos.ability.featureAbility'; +import * as env from './Const.ets'; + +export default function audioRendererTest() { + describe('getUnderflowCount', function () { + let TagFrmwkRender = "audioRendererEnhanceTest"; + let audioRen; + console.info(`${TagFrmwkRender}: Create AudioManger Object JS Framework`); + beforeAll(function () { + console.info(`${TagFrmwkRender}: beforeAll: Prerequisites at the test suite level`); + }) + beforeEach(async function () { + console.info(`${TagFrmwkRender}: beforeEach: Prerequisites at the test case level`); + await sleep(1000); + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try{ + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info('audioRendererEnhanceTest: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('audioRendererEnhanceTest: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('audioRendererEnhanceTest: AudioRender Created : ERROR : ' + err.message); + }); + }catch (error){ + console.info('audioRendererEnhanceTest: AudioRender Created : catch ERROR : ' + error.code + error.message); + } + }) + afterEach(async function () { + console.info(`${TagFrmwkRender}: afterEach: Test case-level clearance conditions`); + sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + }) + afterAll(async function () { + console.info(`${TagFrmwkRender}: afterAll: Test suite-level cleanup condition`); + }) + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + let filePath; + async function renderPlay() { + let bufferSize + try { + bufferSize = await audioRen.getBufferSize() + console.info( `audioRenderer getBufferSize success,bufferSize:${bufferSize} \n`); + await audioRen.start(); + console.info(`audioRenderer start success\n`); + } catch (err) { + console.info(`audioRenderer start : Error: ${JSON.stringify(err)}\n`); + return; + } + + var context = featureAbility.getContext(); + await context.getFilesDir().then((data) => { + console.error('#####app file: '+ data); + filePath = data; + console.error('#####app filePath: '+ filePath); + }).catch((Error) => { + console.error('####app file err: ' + Error.message); + }) + + let path = filePath + '/StarWars10s-1C-8000-2SW.wav'; + console.info(`path:${path}\n`); + try { + let len; + try { + let stat = await fs.stat(path); + console.info(`stat:${JSON.stringify(stat)}\n`); + console.info(`size:${stat.size}\n`); + len = stat.size % bufferSize == 0 ? Math.floor(stat.size / bufferSize) : Math.floor(stat.size / bufferSize + 1); + }catch (error) { + console.info(`#######audioRenderer stat : Error: ${JSON.stringify(error)}\n`); + } + + let file = await fs.open(path, 0o0); + console.info(`fd:${file.fd}\n`); + + let buf = new ArrayBuffer(bufferSize); + console.info(`audioRenderer write start.......... \n`); + for (let i = 0; i < len; i++) { + let options = { + offset: i * bufferSize, + length: bufferSize + } + let readsize = await fs.read(file.fd, buf, options); + let writeSize = await audioRen.write(buf); + //构建欠载音频帧 + if(i == len - 1){ + await sleep(1000); + } + if(i == len - 5){ + await sleep(1000); + } + } + console.info(`audioRenderer write end............ \n`); + } catch (err) { + console.info(`audioRenderer write : Error: ${JSON.stringify(err)}\n`); + } + } + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0100 + * @tc.name : AudioRenderer -getUnderflowCount "unit_32" - promise + * @tc.desc : AudioRenderer - getUnderflowCount "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0100', 0, async function (done) { + try{ + await audioRen.getUnderflowCount().then((data) => { + console.info(`${TagFrmwkRender}:getUnderflowCount :SUCCESS ${data}`); + expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + done(); + }).catch ((error)=>{ + console.log("${TagFrmwkRender}:getUnderflowCount : error = " + error); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.log("GETUNDERFLOWCOUNT catch unknown error = " + error); + expect(false).assertTrue(); + done(); + } + + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0200 + * @tc.name : AudioRenderer -getUnderflowCount "unit_32" - promise + * @tc.desc : AudioRenderer - getUnderflowCount "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0200', 0, async function (done) { + try { + await renderPlay(); + await audioRen.getUnderflowCount().then((data) => { + expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + audioRen.drain().then(() => { + audioRen.stop().then(() => { + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + }).catch((error) => { + console.log("${TagFrmwkRender}: getUnderflowCount : error = " + error); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.log("GETUNDERFLOWCOUNT catch unknown error = " + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0300 + * @tc.name : AudioRenderer -getUnderflowCount "unit_32" - promise + * @tc.desc : AudioRenderer - getUnderflowCount "unit_32" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_PROMISE_0300', 0, async function (done) { + let StreamType; + try { + for (StreamType in audio.StreamUsage) { + let audioRender; + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: Number(audio.StreamUsage[StreamType]), + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try { + if (Number(audio.StreamUsage[StreamType]) != 9) { + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType}: ${Number(audio.StreamUsage[StreamType])}`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.code + err.message); + }); + } else { + audioRender = audioRen; + } + } catch (error) { + console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); + } + await audioRender.getUnderflowCount().then((data) => { + console.info(`${TagFrmwkRender}: getUnderflowCount SUCCESS! ${StreamType} data ${data}:, now release audiorender`); + expect(data).assertLargerOrEqual(0); + }).catch((error) => { + console.info(`${TagFrmwkRender}: getUnderflowCount: ERROR : code: ${error.code}, mesage: ${error.message}`); + expect(false).assertTrue(); + done(); + }); + sleep(1000); + await audioRender.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer ${StreamType} release SUCCESS! `); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release ERROR: ${err.message}`); + }); + } + done(); + } catch (error) { + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0100 + * @tc.name : AudioRenderer - getUnderflowCount "uint_32" - callback + * @tc.desc : AudioRenderer - getUnderflowCount "uint_32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0100', 0, async function (done) { + audioRen.getUnderflowCount((err, data) => { + if (err) { + console.info(`${TagFrmwkRender}: getUnderflowCount ERROR! code: ${err.code}, mesage: ${err.message}`); + expect(false).assertTrue(); + done(); + } else { + console.info(`${TagFrmwkRender}: getUnderflowCount : Success! ${data}`); + expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0200 + * @tc.name : AudioRenderer - getUnderflowCount "uint_32" - callback + * @tc.desc : AudioRenderer - getUnderflowCount "uint_32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0200', 0, async function (done) { + try { + await renderPlay(); + audioRen.getUnderflowCount((error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: getUnderflowCount execution fail,error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + audioRen.drain().then(() => { + audioRen.stop().then(() => { + done(); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer stop:ERROR : ${err.message}`); + }); + }).catch((err) => { + console.error(`${TagFrmwkRender}: Renderer drain: ERROR : ${err.message}`); + }); + } + }); + } catch (error) { + console.log(`${TagFrmwkRender}: getUnderflowCount unknown error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0300 + * @tc.name : AudioRenderer - getUnderflowCount "uint_32" - callback + * @tc.desc : AudioRenderer - getUnderflowCount "uint_32" - callback + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_GETUNDERFLOWCOUNT_CALLBACK_0300', 0, async function (done) { + let StreamType; + try { + for (StreamType in audio.StreamUsage) { + let audioRender; + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: StreamType, + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try { + if (Number(audio.StreamUsage[StreamType]) != 9) { + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRender = data; + console.info(`${TagFrmwkRender}: AudioRender Created : Stream Type: ${StreamType} SUCCESS data state: ` + Object.keys(data)); + }).catch((err) => { + console.info(`${TagFrmwkRender}: AudioRender Created : ERROR : ` + err.message); + }); + } else { + audioRender = audioRen; + } + } catch (error) { + console.info(`${TagFrmwkRender}: AudioRender Created : catch ERROR : ` + error.code + error.message); + } + audioRen.getUnderflowCount((error, data) => { + if (error) { + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwkRender}:getUnderflowCount StreamType:${StreamType} execution success, data: ${JSON.stringify(data)}`); + expect(data).assertLargerOrEqual(env.OUTPUT_NUMBER_0); + } + }); + sleep(1000); + await audioRender.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer ${StreamType} release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + } + done(); + } catch (error) { + expect(false).assertTrue(); + done(); + } + }); + }) +} diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/List.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..1a9b67cea --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/List.test.ets @@ -0,0 +1,27 @@ +/* + * 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 getMax_MinStreamVolume from './GetMaxAndMinStreamVolume.test.ets' +import getUnderflowCount from './GetUnderflowCount.test.ets' +import get_setRendererSamplingRate from './GetAndSetRendererSamplingRate.test.ets' +import getCurrentOutputDevices from './GetCurrentOutputDevices.test.ets' +import on_off_outputDeviceChange from './OnOffOutputDeviceChange.test.ets' + +export default function testsuite() { + getMax_MinStreamVolume(); + getUnderflowCount(); + get_setRendererSamplingRate(); + getCurrentOutputDevices(); + on_off_outputDeviceChange(); +} diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/OnOffOutputDeviceChange.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/OnOffOutputDeviceChange.test.ets new file mode 100644 index 000000000..a28ef1622 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/OnOffOutputDeviceChange.test.ets @@ -0,0 +1,269 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; +import audio from '@ohos.multimedia.audio'; +import * as env from './Const.ets'; + +export default function audioRendererTest() { + describe('on_off_outputDeviceChange', function () { + let TagFrmwkRender = "audioRendererEnhanceTest"; + let audioRen; + console.info(`${TagFrmwkRender}: Create AudioManger Object JS Framework`); + beforeAll(function () { + console.info(`${TagFrmwkRender}: beforeAll: Prerequisites at the test suite level`); + }) + beforeEach(async function () { + console.info(`${TagFrmwkRender}: beforeEach: Prerequisites at the test case level`); + await sleep(1000); + 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 AudioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_UNKNOWN, + usage: audio.StreamUsage.STREAM_USAGE_MEDIA, + rendererFlags: 0 + } + let AudioRendererOptions = { + streamInfo: AudioStreamInfo, + rendererInfo: AudioRendererInfo + } + try{ + await audio.createAudioRenderer(AudioRendererOptions).then((data) => { + audioRen = data; + console.info('audioRendererEnhanceTest: AudioRender Created : Success : Stream Type: SUCCESS data state: ' + Object.keys(data)); + console.info('audioRendererEnhanceTest: AudioRender Created : Success : Stream Type: SUCCESS data value: ' + JSON.stringify(data)); + }).catch((err) => { + console.info('audioRendererEnhanceTest: AudioRender Created : ERROR : ' + err.message); + }); + }catch (error){ + console.info('audioRendererEnhanceTest: AudioRender Created : catch ERROR : ' + error.code + error.message); + } + }) + afterEach(async function () { + console.info(`${TagFrmwkRender}: afterEach: Test case-level clearance conditions`); + sleep(2000); + await audioRen.release().then(() => { + console.info(`${TagFrmwkRender}: Renderer release : SUCCESS`); + }).catch((err) => { + console.info(`${TagFrmwkRender}: Renderer release :ERROR : ${err.message}`); + }); + }) + afterAll(async function () { + console.info(`${TagFrmwkRender}: afterAll: Test suite-level cleanup condition`); + }) + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_ON_CALLBACK_0100 + * @tc.name : AudioRenderer -on "struct" - promise + * @tc.desc : AudioRenderer - on "struct" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_ON_CALLBACK_0100', 0, async function (done) { + try { + audioRen.on(-1, (error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: On error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + if (error) { + console.log(`${TagFrmwkRender}: On catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_401); + done(); + } else { + expect(false).assertTrue(); + done(); + } + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_ON_CALLBACK_0200 + * @tc.name : AudioRenderer -on "struct" - promise + * @tc.desc : AudioRenderer - on "struct" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_ON_CALLBACK_0200', 0, async function (done) { + try { + audioRen.on('123', (error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: On error, error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + if (error) { + console.log(`${TagFrmwkRender}: On catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } else { + expect(false).assertTrue(); + done(); + } + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_ON_CALLBACK_0300 + * @tc.name : AudioRenderer -on "struct" - promise + * @tc.desc : AudioRenderer - on "struct" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_ON_CALLBACK_0300', 0, async function (done) { + try { + audioRen.on((error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: On execution fail,error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwkRender}: On execution success, testcase FAIL!`); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + if (error) { + console.log(`${TagFrmwkRender}: On: catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_401); + done(); + } else { + expect(false).assertTrue(); + done(); + } + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_OFF_CALLBACK_0100 + * @tc.name : AudioRenderer -on "struct" - promise + * @tc.desc : AudioRenderer - on "struct" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_OFF_CALLBACK_0100', 0, async function (done) { + try { + audioRen.off(-1, (error, data) => { + if (error) { + console.log(`${TagFrmwkRender}:Off execution fail,error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwkRender}:Off execution success, testcase FAIL! `); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + if (error) { + console.log(`${TagFrmwkRender}:On catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } else { + expect(false).assertTrue(); + done(); + } + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_OFF_CALLBACK_0200 + * @tc.name : AudioRenderer -on "struct" - promise + * @tc.desc : AudioRenderer - on "struct" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_OFF_CALLBACK_0200', 0, async function (done) { + try { + audioRen.off('123', (error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: Off execution fail,error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwkRender}: Off execution success, testcase FAIL! `); + expect(true).assertTrue(); + done(); + } + }); + } catch (error) { + if (error) { + console.log(`${TagFrmwkRender}: Off catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(env.UNSUPORTED_OPTION_6800104); + done(); + } else { + expect(false).assertTrue(); + done(); + } + } + }); + + /** + * @tc.number : SUB_MULTIMEDIA_AUDIO_RENDERER_OFF_CALLBACK_0300 + * @tc.name : AudioRenderer -off "struct" - promise + * @tc.desc : AudioRenderer - off "struct" - promise + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_MULTIMEDIA_AUDIO_RENDERER_OFF_CALLBACK_0300', 0, async function (done) { + try { + audioRen.off((error, data) => { + if (error) { + console.log(`${TagFrmwkRender}: Off execution fail,error: [${error.code}, ${error.message}]`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwkRender}: Off execution success, testcase FAIL! `); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + if (error) { + console.log(`${TagFrmwkRender}: Off catch error, error: [${error.code}, ${error.message}]`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } else { + expect(false).assertTrue(); + done(); + } + } + }); + }) +} diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/base/element/color.json b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/base/element/color.json new file mode 100644 index 000000000..d66f9a7d4 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/base/element/string.json b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/base/element/string.json new file mode 100644 index 000000000..bab0cfab6 --- /dev/null +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "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/AudioRendererEnhance/src/main/resources/base/media/icon.png b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y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