未验证 提交 835c4dee 编写于 作者: O openharmony_ci 提交者: Gitee

!9579 录屏录音用例上库

Merge pull request !9579 from 秦莉文/OpenHarmony-4.0-Beta2
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("audio_capturer_js_hap") {
hap_profile = "./src/main/config.json"
deps = [
":audio_capturer_js_assets",
":audio_capturer_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAudioCapturerJsTest"
subsystem_name = "multimedia"
part_name = "audio_framework"
}
ohos_js_assets("audio_capturer_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("audio_capturer_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("audio_capturer_js_hap") {
hap_profile = "./src/main/config.json"
deps = [
":audio_capturer_js_assets",
":audio_capturer_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAudioCapturerJsTest"
subsystem_name = "multimedia"
part_name = "audio_framework"
}
ohos_js_assets("audio_capturer_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("audio_capturer_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for audio manager Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "1500000",
"testcase-timeout": "50000",
"bundle-name": "ohos.acts.multimedia.audio.audiocapturer",
"package-name": "ohos.acts.multimedia.audio.audiocapturer",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAudioCapturerJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"uinput -T -d 300 600 -m 300 600 300 100 -u 300 100",
"power-shell setmode 602"
],
"teardown-command":[
"power-shell setmode 600"
],
"cleanup-apps": true
},
{
"type": "PushKit",
"pre-push": [],
"push": [
]
}
]
{
"description": "Configuration for audio manager Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "1500000",
"testcase-timeout": "50000",
"bundle-name": "ohos.acts.multimedia.audio.audiocapturer",
"package-name": "ohos.acts.multimedia.audio.audiocapturer",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAudioCapturerJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"uinput -T -d 300 600 -m 300 600 300 100 -u 300 100",
"power-shell setmode 602",
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.audio.audiocapturer/haps/entry/files",
"chmod 777 -R /data/app/el2/100/base/ohos.acts.multimedia.audio.audiocapturer/haps/entry"
],
"teardown-command":[
"power-shell setmode 600"
],
"cleanup-apps": true
},
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/media/audioplayer/wav/pcm_48ksr_32kbr_2ch.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiocapturer/haps/entry/files/"
]
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.multimedia.audio.audiocapturer",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.multimedia.audio.audiocapturer",
"name": ".entry",
"deviceType": [
"tablet",
"default",
"phone",
"2in1"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"reqPermissions": [
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.MICROPHONE",
"reason": "use ohos.permission.MICROPHONE"
},
{
"name": "ohos.permission.MANAGE_AUDIO_CONFIG",
"reason": "use ohos.permission.MANAGE_AUDIO_CONFIG"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
{
"app": {
"bundleName": "ohos.acts.multimedia.audio.audiocapturer",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.multimedia.audio.audiocapturer",
"name": ".entry",
"deviceType": [
"tablet",
"default",
"phone",
"2in1"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"reqPermissions": [
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.MICROPHONE",
"reason": "use ohos.permission.MICROPHONE"
},
{
"name": "ohos.permission.MANAGE_AUDIO_CONFIG",
"reason": "use ohos.permission.MANAGE_AUDIO_CONFIG"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info("============== AceApplication onCreate ==============");
},
onDestroy() {
console.info('=============AceApplication onDestroy=============');
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info("============== AceApplication onCreate ==============");
},
onDestroy() {
console.info('=============AceApplication onDestroy=============');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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.
*/
<div class="container">
<text class="title">
Hello, World!
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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.
*/
<div class="container">
<text class="title">
Hello, World!
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:// www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import audio from '@ohos.multimedia.audio';
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
import resourceManager from '@ohos.resourceManager';
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium';
import { UiDriver, BY } from '@ohos.UiTest'
export default function audioCapturer() {
describe('AudioPlaybackCapturer', function () {
let Tag = 'AudioPlaybackCapturerTest';
let fdRead;
let readPath;
let fdPath;
let filePath;
let dirPath;
const LE24 = -1;
const LE32 = -1;
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function getPermission() {
let permissions = ['ohos.permission.MICROPHONE'];
featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => {
console.info("request success" + JSON.stringify(data));
})
}
async function driveFn() {
console.info(`come in driveFn`);
let driver = await UiDriver.create();
console.info(`driver is ${JSON.stringify(driver)}`);
await sleep(100);
console.info(`UiDriver start`);
let button = await driver.findComponent(BY.text('允许'));
console.info(`button is ${JSON.stringify(button)}`);
await sleep(100);
await button.click();
}
beforeAll(async function () {
await getPermission();
await driveFn();
console.info('TestLog: Start Testing AudioPlaybackCapturer Interfaces');
})
beforeEach(async function () {
console.info(`${Tag} AudioFrameworkTest: beforeEach: Prerequisites at the test case level`);
await sleep(1000);
})
afterEach(function () {
console.info(`${Tag} AudioFrameworkTest: afterEach: Test case-level clearance conditions`);
})
afterAll(function () {
console.info(`${Tag} AudioFrameworkTest: afterAll: Test suite-level cleanup condition`);
})
async function closeFileDescriptor(fileName) {
await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.closeRawFileDescriptor(fileName).then(value => {
console.log(`${Tag}:case closeRawFileDescriptor success for file:${fileName}`);
}).catch(error => {
console.log(`${Tag}:case closeRawFileDescriptor err: ${error}`);
});
});
}
async function getFd(fileName) {
let context = await featureAbility.getContext();
await context.getFilesDir().then((data) => {
dirPath = data + '/' + fileName;
console.info(`${Tag} case2 dirPath is ${JSON.stringify(dirPath)}`);
})
}
async function getFdRead(pathName, done) {
let context = await featureAbility.getContext();
console.info(`case0 context is : ${context}`);
await context.getFilesDir().then((data) => {
console.info(`case1 getFilesDir is path : ${data}`);
filePath = data + '/' + pathName;
console.info(`case4 filePath is : ${filePath}`);
})
fdPath = 'fd://';
await fileio.open(filePath).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
fdRead = fdNumber;
console.info(`[fileIO]case open fd success,fdPath is : ${fdPath}`);
console.info(`[fileIO]case open fd success,fdRead is : ${fdRead}`);
}, (err) => {
console.info(`[fileIO]case open fd failed : ${err}`);
}).catch((error) => {
console.info(`[fileIO]case catch open fd error : ${error}`);
});
}
async function playbackPromise(AudioRendererOptions, pathName) {
let resultFlag = false;
let audioRen;
let isPass = false;
await audio.createAudioRenderer(AudioRendererOptions).then((data) => {
audioRen = data;
console.info(`${Tag}: AudioRender Created : Success : Stream Type: SUCCESS`);
}).catch((err) => {
console.info(`${Tag}: AudioRender Created : ERROR : ${err.message}`);
resultFlag = false;
});
console.log(`isPass: ${isPass}`);
if (isPass) {
resultFlag = true;
return resultFlag;
}
console.info(`${Tag}: AudioRenderer : STATE : ${audioRen.state}`);
await audioRen.start().then(() => {
console.info(`${Tag}: renderInstant started :SUCCESS`);
}).catch((err) => {
console.info(`${Tag}: renderInstant start :ERROR : ${err.message}`);
resultFlag = false;
});
console.info(`${Tag}: AudioRenderer : STATE : ${audioRen.state}`);
let bufferSize;
await audioRen.getBufferSize().then((data) => {
console.info(`${Tag}: getBufferSize :SUCCESS ${data}`);
bufferSize = data;
}).catch((err) => {
console.info(`${Tag}: getBufferSize :ERROR : ${err.message}`);
resultFlag = false;
});
let ss = fileio.fdopenStreamSync(fdRead, 'r');
console.info(`${Tag}:case 2:AudioFrameworkRenderLog: File Path: ${ss}`);
let discardHeader = new ArrayBuffer(44);
console.info(`${Tag}:case 2-1:AudioFrameworkRenderLog: File Path: `);
ss.readSync(discardHeader);
console.info(`${Tag}:case 2-2:AudioFrameworkRenderLog: File Path: `);
let totalSize = fileio.fstatSync(fdRead).size;
console.info(`${Tag}:case 3 : AudioFrameworkRenderLog: File totalSize size: ${totalSize}`);
totalSize = totalSize - 44;
console.info(`${Tag}: File size : Removing header: ${totalSize}`);
let rlen = 0;
while (rlen < totalSize / 4) {
let buf = new ArrayBuffer(bufferSize);
rlen += ss.readSync(buf);
console.info(`${Tag}:BufferAudioFramework: bytes read from file: ${rlen}`);
await audioRen.write(buf);
}
console.info(`${Tag}: Renderer after read`);
await audioRen.drain().then(() => {
console.info(`${Tag}: Renderer drained : SUCCESS`);
}).catch((err) => {
console.error(`${Tag}: Renderer drain: ERROR : ${err.message}`);
});
console.info(`${Tag}: AudioRenderer : STATE : ${audioRen.state}`);
await audioRen.stop().then(() => {
console.info(`${Tag}: Renderer stopped : SUCCESS`);
}).catch((err) => {
console.info(`${Tag}: Renderer stop:ERROR : ${err.message}`);
});
console.info(`${Tag}: AudioRenderer : STATE : ${audioRen.state}`);
await audioRen.release().then(() => {
console.info(`${Tag}: Renderer release : SUCCESS`);
}).catch((err) => {
console.info(`${Tag}: Renderer release :ERROR : ${err.message}`);
});
console.info(`${Tag}: AudioRenderer : STATE : ${audioRen.state}`);
return resultFlag;
}
async function recPromise(AudioCapturerOptions,AudioRendererOptions, pathName,done) {
let audioCap;
try {
audioCap = await audio.createAudioCapturer(AudioCapturerOptions);
console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: success`);
} catch (err) {
console.info(`${Tag} AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${JSON.stringify(err.message)}`);
LE24 = audio.AudioSampleFormat.SAMPLE_FORMAT_S24LE;
LE32 = audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE;
let sampleFormat = AudioCapturerOptions.streamInfo.sampleFormat;
if ((sampleFormat == LE24 || sampleFormat == LE32) && err.code == 202) {
done();
return;
}
expect(false).assertTrue();
done();
return;
}
try {
let audioParamsGet = await audioCap.getStreamInfo();
if (audioParamsGet != undefined && audioParamsGet != null) {
console.info(`${Tag} AudioFrameworkRecLog: Capturer getStreamInfo:${JSON.stringify(audioParamsGet)}`);
} else {
console.info(`${Tag} AudioFrameworkRecLog: audioParamsGet are incorrect,is : ${JSON.stringify(audioParamsGet)}`);
expect(false).assertTrue();
}
} catch (err) {
console.log(`${Tag} AudioFrameworkRecLog: getStreamInfo :ERROR: ${JSON.stringify(err.message)}`);
expect(false).assertTrue();
}
try {
let audioParamsGet = await audioCap.getCapturerInfo();
if (audioParamsGet != undefined) {
console.info(`${Tag} AudioFrameworkRecLog: Capturer CapturerInfo: ${JSON.stringify(audioParamsGet)}`);
} else {
console.info(`${Tag} AudioFrameworkRecLog: audioParamsGet are incorrect , is : ${JSON.stringify(audioParamsGet)}`);
expect(false).assertTrue();
}
} catch (err) {
console.log(`${Tag} AudioFrameworkRecLog: CapturerInfo :ERROR: ${JSON.stringify(err.message)}`);
expect(false).assertTrue();
}
try {
await audioCap.start();
console.log(`${Tag} start ok`);
await playbackPromise(AudioRendererOptions, pathName);
let bufferSize = await audioCap.getBufferSize();
console.log(`${Tag} bufferSize: ${JSON.stringify(bufferSize)} , dirPath: ${JSON.stringify(dirPath)}`);
let fd = fileio.openSync(dirPath, 0o102, 0o777);
console.log(`${Tag} fd: ${JSON.stringify(fd)}`);
if (fd !== null) {
console.info(`${Tag} AudioFrameworkRecLog: file fd created`);
}
else {
console.info(`${Tag} AudioFrameworkRecLog: Capturer start : ERROR `);
expect(false).assertTrue();
}
fd = fileio.openSync(dirPath, 0o2002, 0o666);
console.log(`${Tag} fd-re: ${JSON.stringify(fd)}`);
if (fd !== null) {
console.info(`${Tag} AudioFrameworkRecLog: file fd opened : Append Mode :PASS`);
}
else {
console.info(`${Tag} AudioFrameworkRecLog: file fd Open: Append Mode : FAILED`);
expect(false).assertTrue();
}
let numBuffersToCapture = 45;
while (numBuffersToCapture) {
console.info(`${Tag} AudioFrameworkRecLog: ---------READ BUFFER---------`);
let buffer = await audioCap.read(bufferSize, true);
console.info(`${Tag} AudioFrameworkRecLog: ---------WRITE BUFFER---------`);
let number = fileio.writeSync(fd, buffer);
console.info(`${Tag} AudioFrameworkRecLog:BufferRecLog: data written: ${JSON.stringify(number)}`);
numBuffersToCapture--;
}
console.log(`${Tag} read ok`);
await audioCap.stop();
console.log(`${Tag} stop ok`);
} catch (err) {
console.log(`${Tag} start-read-stop err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
}
try {
await audioCap.release();
console.log(`${Tag} release ok`);
} catch (err) {
console.log(`${Tag} release err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
}
done();
}
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_INNER_CAPTURER_PROMISE_0100
*@tc.name : SOURCE_TYPE_PLAYBACK_CAPTURER_PRIVACY_TYPE_PUBLIC
*@tc.desc : SOURCE_TYPE_PLAYBACK_CAPTURER_PRIVACY_TYPE_PUBLIC
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_INNER_CAPTURER_PROMISE_0100', 2, async function (done) {
let audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW,
}
let audioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_PLAYBACK_CAPTURE,
capturerFlags: 0
}
let playbackCaptureConfig = {
CaptureFilterOptions: [
{
usage: audio.StreamUsage.STREAM_USAGE_MEDIA
}
]
}
let audioCapturerOptions = {
streamInfo: audioStreamInfo,
capturerInfo: audioCapturerInfo,
playbackCaptureConfig: playbackCaptureConfig,
}
let AudioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
let AudioRendererInfo = {
usage: audio.StreamUsage.STREAM_USAGE_MEDIA,
rendererFlags: 0
}
let AudioPrivacyType = {
privacyType:audio.AudioPrivacyType.PRIVACY_TYPE_PUBLIC
}
let AudioRendererOptions = {
streamInfo: AudioStreamInfo,
rendererInfo: AudioRendererInfo,
privacyType : AudioPrivacyType
}
readPath = 'pcm_48ksr_32kbr_2ch.wav'
await getFdRead(readPath, done);
await getFd("capture_js-48000-2C-1S32LE.pcm");
await recPromise(audioCapturerOptions,AudioRendererOptions,filePath,done);
await sleep(100);
await closeFileDescriptor(readPath);
done();
})
/**
*@tc.number : SUB_MULTIMEDIA_AUDIO_INNER_CAPTURER_PROMISE_0200
*@tc.name : SOURCE_TYPE_PLAYBACK_CAPTURER_PRIVACY_TYPE_PUBLIC
*@tc.desc : SOURCE_TYPE_PLAYBACK_CAPTURER_PRIVACY_TYPE_PUBLIC
*@tc.size : MEDIUM
*@tc.type : Function
*@tc.level : Level 2
*/
it('SUB_MULTIMEDIA_AUDIO_INNER_CAPTURER_PROMISE_0200', 2, async function (done) {
let audioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW,
}
let audioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_PLAYBACK_CAPTURE,
capturerFlags: 0
}
let playbackCaptureConfig = {
CaptureFilterOptions: [
{
usage: audio.StreamUsage.STREAM_USAGE_MOVIE
}
]
}
let audioCapturerOptions = {
streamInfo: audioStreamInfo,
capturerInfo: audioCapturerInfo,
playbackCaptureConfig: playbackCaptureConfig,
}
let AudioStreamInfo = {
samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000,
channels: audio.AudioChannel.CHANNEL_2,
sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S32LE,
encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
}
let AudioRendererInfo = {
usage: audio.StreamUsage.STREAM_USAGE_MOVIE,
rendererFlags: 0
}
let AudioPrivacyType = {
privacyType:audio.AudioPrivacyType.PRIVACY_TYPE_PRIVATE
}
let AudioRendererOptions = {
streamInfo: AudioStreamInfo,
rendererInfo: AudioRendererInfo,
privacyType : AudioPrivacyType
}
readPath = 'pcm_48ksr_32kbr_2ch.wav'
await getFdRead(readPath, done);
await getFd("capture_js-44100-2C-1S32LE.pcm");
await recPromise(audioCapturerOptions,AudioRendererOptions,filePath,done);
await sleep(100);
await closeFileDescriptor(readPath);
done();
})
})
}
/**
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import audioCapturer from './AudioCapturer.test.js'
import AudioCapturerInterruptUnitTest from './AudioCapturerInterrupt.test.js'
export default function testsuite() {
audioCapturer()
AudioCapturerInterruptUnitTest()
}
/**
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import audioCapturer from './AudioCapturer.test.js'
import AudioCapturerInterruptUnitTest from './AudioCapturerInterrupt.test.js'
import AudioPlaybackCapturer from './AudioPlaybackCapturer.test.js'
export default function testsuite() {
audioCapturer()
AudioCapturerInterruptUnitTest()
AudioPlaybackCapturer()
}
{
"string": [
{
"name": "app_name",
"value": "JsHelloWorld"
},
{
"name": "mainability_description",
"value": "hap sample empty page"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
{
"string": [
{
"name": "app_name",
"value": "JsHelloWorld"
},
{
"name": "mainability_description",
"value": "hap sample empty page"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册