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 index dabfb99eae5727fa691984a02d37aeb81798fa3f..e295c35e8602e28f58ef3badd1ec87169a927f1b 100644 --- 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 @@ -290,7 +290,7 @@ export default function audioManagerTest() { .catch((error) => { if (error) { console.log(`${TagFrmwk}:getSystemVolumeInDb : error ${error.message} ${error.code}`); - expect(Number(error.code)).assertEqual(env.UNSUPORTED_OPTION_6800104); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); done(); } else { expect(false).assertTrue(); @@ -431,17 +431,23 @@ export default function audioManagerTest() { * @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(); - } - }); + try { + 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(); + } + }); + } catch (error) { + console.log(`${TagFrmwk}:getSystemVolumeInDb error, check error code: ${error.code}`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } }) /** @@ -453,17 +459,23 @@ export default function audioManagerTest() { * @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(); - } - }); + try { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 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 : error ${err.message} ${err.code}`); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.log(`${TagFrmwk}:getSystemVolumeInDb error, check error code: ${error.code}`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } }) /** @@ -475,17 +487,23 @@ export default function audioManagerTest() { * @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(); - } - }); + try { + await audioVolumeGroupManager.getSystemVolumeInDb(audio.AudioVolumeType.MEDIA, 3, (err, data) => { + if (err) { + console.log(`${TagFrmwk}:getSystemVolumeInDb error ${err.message} ${err.code}`); + expect(false).assertTrue(); + done(); + } else { + console.log(`${TagFrmwk}:getSystemVolumeInDb error ${err.message} ${err.code}`); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + console.log(`${TagFrmwk}:getSystemVolumeInDb error, check error code: ${error.code}`); + expect(Number(error.code)).assertEqual(env.INVALID_INPUT_PARAMETER_6800101); + done(); + } }) /** diff --git a/multimedia/audio/audio_js_standard/AudioRendererEnhance/Test.json b/multimedia/audio/audio_js_standard/AudioRendererEnhance/Test.json index b8b0d54beecc3918aaaf49e7ee5a24915f8c0bbd..7385221d8f4d5ec226797d9e8ef08287efb80c2c 100644 --- a/multimedia/audio/audio_js_standard/AudioRendererEnhance/Test.json +++ b/multimedia/audio/audio_js_standard/AudioRendererEnhance/Test.json @@ -20,6 +20,7 @@ "type": "ShellKit", "run-command": [ "power-shell wakeup", + "power-shell setmode 602", "mkdir -p /data/app/el2/100/base/com.example.xts_test_case/haps/entry/files", "chmod 777 -R /data/app/el2/100/base/com.example.xts_test_case/haps/entry" ], 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 index eb3bf5f71dcfa531c4f3a4eb1bc80abd6822e1b0..0f544db1d7e4c30f23aff154bf6e36151d5d4062 100644 --- 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 @@ -14,8 +14,6 @@ */ //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; 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 deleted file mode 100644 index 1491e014869f95c87bad95e62e6a186d1d317529..0000000000000000000000000000000000000000 --- a/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/GetAndSetRendererSamplingRate.test.ets +++ /dev/null @@ -1,657 +0,0 @@ -/* - * 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/List.test.ets b/multimedia/audio/audio_js_standard/AudioRendererEnhance/src/main/ets/test/List.test.ets index 1a9b67cea4c0f748f5becd564cb620a0bc0d9383..ff20823d2ced18bf6c24f14f5861e97338210e29 100644 --- 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 @@ -14,14 +14,12 @@ */ 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(); }