提交 1ef620e8 编写于 作者: W wangzx0705

cherry pick audio xts_acts test to OpenHarmony-4.0-Beta2

Signed-off-by: Nwangzx0705 <wangzx0705@thundersoft.com>
上级 836b8a76
......@@ -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",
......
# 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"
}
{
"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
{
"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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
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
/*
* 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
/*
* 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<Number>();
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<Number>();
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();
}
})
})
}
/*
* 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();
}
})
})
}
/*
* 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
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"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
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
# 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_render_enhance_ets_hap") {
hap_profile = "./src/main/config.json"
deps = [
":audio_render_enhance_ets_assets",
":audio_render_enhance_ets_resources",
":audio_render_enhance_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAudioRendererEnhanceTest"
subsystem_name = "multimedia"
part_name = "audio_framework"
}
ohos_js_assets("audio_render_enhance_ets_assets") {
source_dir = "./src/main/ets/MainAbility"
}
ohos_js_assets("audio_render_enhance_ets_test_assets") {
source_dir = "./src/main/ets/TestAbility"
}
ohos_resources("audio_render_enhance_ets_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for audio renderer enhance Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "3000000",
"bundle-name":"com.example.xts_test_case",
"package-name": "com.example.xts_test_case",
"shell-timeout": "600000",
"testcase-timeout": 100000
},
"kits": [
{
"test-file-name": [
"ActsAudioRendererEnhanceTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"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"
],
"cleanup-apps": true
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/audio/audioManager/Believer.wav ->/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
{
"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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
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
/*
* 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;
/*
* 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}`);
});
}
});
});
})
}
/*
* 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();
}
});
})
}
/*
* 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();
}
/*
* 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();
}
}
});
})
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"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
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册