提交 b7ddc106 编写于 作者: S sharpshooter_t

add media test Signed-off-by: sharpshooter_t <taojun13@huawei.com>

Signed-off-by: Nsharpshooter_t <taojun13@huawei.com>
上级 6595402e
......@@ -20,6 +20,7 @@ group("multimedia") {
"audio/audio_js_standard/audioPlayer:audio_player_js_hap",
"audio/audio_js_standard/audioPlayer_API:audio_player_api_js_hap",
"audio/audio_js_standard/audioManager:audio_manager_js_hap",
"audio/audio_js_standard/audioRecorder:audio_recorder_js_hap",
"media/media_cpp_test_standard:ActsMediaCppStandardTest"
]
} else {
......
# 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_recorder_js_hap") {
hap_profile = "./src/main/config.json"
deps = [
":audio_recorder_js_assets",
":audio_recorder_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "AudioRecorderJsTest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("audio_recorder_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("audio_recorder_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
\ No newline at end of file
{
"description": "Configuration for audio manager Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "ohos.acts.multimedia.audio.function",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"AudioRecorderJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.multimedia.audio.function",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.multimedia.audio.function",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.multimedia.audio.function.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/*
* 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 device from '@system.device';
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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 app from '@system.app'
import {Core, ExpectExtend} from 'deccjsunit/index'
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')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
},
}
\ 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.
*/
#ifndef DISABLE_PLAYER_TEST_H
#define DISABLE_PLAYER_TEST_H
#endif
\ 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.
*/
require('./RecorderLocalTestAudioFUNC.test.js')
require('./RecorderLocalTestAudioAPI.test.js')
\ 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 media from '@ohos.multimedia.media'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('RecorderLocalTestAudioAPI', function () {
let audioRecorder = media.createAudioRecorder();
let isTimeOut = false;
const END_STATE = 0;
const PRE_STATE = 1;
const START_STATE = 2;
const PAUSE_STATE = 3;
const RESUME_STATE = 4;
const STOP_STATE = 5;
const RESET_STATE = 6;
const RELEASE_STATE = 7;
const ERROR_STATE = 8;
const TIME_OUT = 15000; // 15s
const FORMAT_M4A = 6;
const SOURCE_TYPE = 1;
const ENCORDER_AACLC = 3;
const CHANNEL_TWO = 2;
let audioConfig = {
audioSourceType : SOURCE_TYPE,
audioEncoder : ENCORDER_AACLC,
audioEncodeBitRate : 22050,
audioSampleRate : 22050,
numberOfChannels : CHANNEL_TWO,
format : FORMAT_M4A,
uri : 'file:///data/accounts/account_0/appdata/recorder/testAPI.m4a',
location : { latitude : 1, longitude : 1 },
}
function initAudioRecorder() {
if (typeof (audioRecorder) != 'undefined') {
audioRecorder.release();
audioRecorder = undefined;
}
audioRecorder = media.createAudioRecorder();
}
function nextStep(mySteps) {
if (mySteps[0] == END_STATE) {
console.info('case end!!!');
isTimeOut = true;
return;
}
switch (mySteps[0]) {
case PRE_STATE:
console.info('case to prepare');
audioRecorder.prepare(audioConfig);
break;
case START_STATE:
console.info('case to start');
audioRecorder.start();
break;
case PAUSE_STATE:
console.info('case to pause');
audioRecorder.pause();
break;
case RESUME_STATE:
console.info('case to resume');
audioRecorder.resume();
break;
case STOP_STATE:
console.info('case to stop');
audioRecorder.stop();
break;
case RESET_STATE:
console.info('case to reset');
audioRecorder.reset();
break;
case RELEASE_STATE:
console.info('case to release');
audioRecorder.release();
break;
case ERROR_STATE:
console.info('case to wait error callback');
break;
default:
break;
}
}
function setErrorCallback(mySteps) {
audioRecorder.on('error', (err) => {
console.info(`case error called,errName is ${err.name}`);
console.info(`case error called,errCode is ${err.code}`);
console.info(`case error called,errMessage is ${err.message}`);
console.info('case err returned in error() case callback');
mySteps.shift();
expect(mySteps[0]).assertEqual(ERROR_STATE);
mySteps.shift();
nextStep(mySteps);
});
}
function setCallback(mySteps, done) {
audioRecorder.on('prepare', () => {
console.info('setCallback prepare() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('start', () => {
console.info('setCallback start() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('pause', () => {
console.info('setCallback pause() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('resume', () => {
console.info('setCallback resume() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('stop', () => {
console.info('setCallback stop() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('reset', () => {
console.info('setCallback reset() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('release', () => {
console.info('setCallback release() case callback is called');
mySteps.shift();
nextStep(mySteps);
audioRecorder = undefined;
});
setErrorCallback(mySteps);
setTimeout(function() {
if (!isTimeOut) {
console.info('case is time out!');
expect(isTimeOut).assertTrue();
}
mySteps = undefined;
done();
}, TIME_OUT);
}
beforeAll(function () {
console.info('beforeAll case');
})
beforeEach(function () {
isTimeOut = false;
console.info('beforeEach case');
})
afterEach(function () {
console.info('afterEach case');
})
afterAll(function () {
console.info('afterAll case');
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_createAudioRecorder_API_0100
* @tc.name : Create an AudioRecoder Object by function of createAudioRecorder
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_createAudioRecorder_API_0100', 0, async function (done) {
let testAudioRecorder;
expect(testAudioRecorder).assertNull();
testAudioRecorder= media.createAudioRecorder();
expect(testAudioRecorder != undefined).assertTrue();
done();
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0100
* @tc.name : 01.creatAudioRecorder->prepare
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0100', 0, async function (done) {
let testAudioRecorder= media.createAudioRecorder();
expect(testAudioRecorder != null).assertTrue();
testAudioRecorder.prepare(audioConfig);
done();
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0200
* @tc.name : 02.start->prepare
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0200', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(START_STATE, ERROR_STATE, PRE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.start();
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0500
* @tc.name : 05.stop->prepare
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0500', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, RESET_STATE, PRE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0600
* @tc.name : 06.reset->prepare
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0600', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, RESET_STATE, PRE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0800
* @tc.name : 08.all steps->prepare
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0800', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, PRE_STATE, ERROR_STATE, STOP_STATE,
PRE_STATE, RESET_STATE, PRE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0900
* @tc.name : 09.prepare called three times
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Prepare_API_0900', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, PRE_STATE, ERROR_STATE, PRE_STATE, ERROR_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0100
* @tc.name : 01.creatAudioRecorder->start
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0100', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(START_STATE, ERROR_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.start();
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0200
* @tc.name : 02.prepare->start
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0200', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0500
* @tc.name : 05.stop->start
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0500', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, START_STATE, ERROR_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0600
* @tc.name : 06.reset->start
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0600', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, RESET_STATE, START_STATE, ERROR_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0800
* @tc.name : 08.all steps->start
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0800', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, START_STATE, ERROR_STATE,
PRE_STATE, START_STATE, RESET_STATE, START_STATE, ERROR_STATE, PRE_STATE, START_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0900
* @tc.name : 09.start called three times
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Start_API_0900', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, START_STATE, START_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0100
* @tc.name : 01.creatAudioRecorder->stop
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0100', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(STOP_STATE, ERROR_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.stop();
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0200
* @tc.name : 02.prepare->stop
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0200', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, STOP_STATE, ERROR_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0300
* @tc.name : 03.start->stop
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0300', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0600
* @tc.name : 06.reset->stop
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0600', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, RESET_STATE, STOP_STATE, ERROR_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0800
* @tc.name : 08.all steps->stop
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0800', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, STOP_STATE, ERROR_STATE, RESET_STATE, PRE_STATE, START_STATE, STOP_STATE,
RESET_STATE, PRE_STATE, RESET_STATE, STOP_STATE, ERROR_STATE, PRE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0900
* @tc.name : 09.stop called three times
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Stop_API_0900', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, STOP_STATE, ERROR_STATE,
STOP_STATE, ERROR_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0100
* @tc.name : 01.creatAudioRecorder->reset
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0100', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(RESET_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.reset();
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0200
* @tc.name : 02.prepare->reset
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0200', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, RESET_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0300
* @tc.name : 03.start->reset
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0300', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, RESET_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0600
* @tc.name : 06.stop->reset
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0600', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, RESET_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0800
* @tc.name : 08.all steps->reset
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0800', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, RESET_STATE, PRE_STATE, START_STATE, RESET_STATE, PRE_STATE, START_STATE,
STOP_STATE, RESET_STATE, PRE_STATE, START_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0900
* @tc.name : 09.reset callend three times
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Reset_API_0900', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, RESET_STATE, RESET_STATE, RESET_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Release_API_0100
* @tc.name : 01.creatAudioRecorder->release
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Release_API_0100', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(RELEASE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.release();
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Release_API_0200
* @tc.name : 02.prepare->release
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Release_API_0200', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, RELEASE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Release_API_0300
* @tc.name : 03.start->release
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Release_API_0300', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, RELEASE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Release_API_0600
* @tc.name : 06.stop->release
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Release_API_0600', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, RELEASE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_AudioRecorder_Release_API_0700
* @tc.name : 07.reset->release
* @tc.desc : Reliability Test
* @tc.size : MediumTest
* @tc.type : Reliability
* @tc.level : Level2
*/
it('SUB_MEDIA_RECORDER_AudioRecorder_Release_API_0700', 0, async function (done) {
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, RESET_STATE, RELEASE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
})
\ 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 media from '@ohos.multimedia.media'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('RecorderLocalTestAudioFUNC', function () {
let audioRecorder = media.createAudioRecorder();
let isTimeOut = false;
const BASIC_PATH = 'file:///data/accounts/account_0/appdata/recorder/'
const END_STATE = 0;
const PRE_STATE = 1;
const START_STATE = 2;
const PAUSE_STATE = 3;
const RESUME_STATE = 4;
const STOP_STATE = 5;
const RESET_STATE = 6;
const RELEASE_STATE = 7;
const ERROR_STATE = 8;
const RECORDER_TIME = 5000;
const TIME_OUT = 20000; // 20s
const CHANNEL_ONE = 1;
const CHANNEL_TWO = 2;
const FORMAT_MP4 = 2;
const FORMAT_M4A = 6;
const SOURCE_TYPE = 1;
const ENCORDER_AACLC = 3;
let audioConfig = {
audioSourceType : SOURCE_TYPE,
audioEncoder : ENCORDER_AACLC,
audioEncodeBitRate : 22050,
audioSampleRate : 22050,
numberOfChannels : CHANNEL_TWO,
format : FORMAT_M4A,
uri : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.m4a',
location : { latitude : 1, longitude : 1 },
}
function sleep(time) {
for(let t = Date.now();Date.now() - t <= time;);
};
function initAudioRecorder() {
if (typeof (audioRecorder) != 'undefined') {
audioRecorder.release();
audioRecorder = undefined;
}
audioRecorder = media.createAudioRecorder();
}
beforeAll(function () {
console.info('beforeAll case');
})
beforeEach(function () {
isTimeOut = false;
console.info('beforeEach case');
})
afterEach(function () {
console.info('afterEach case');
})
afterAll(function () {
console.info('afterAll case');
})
function nextStep(mySteps) {
if (mySteps[0] == END_STATE) {
isTimeOut = true;
return;
}
switch (mySteps[0]) {
case PRE_STATE:
console.info('case to prepare');
audioRecorder.prepare(audioConfig);
break;
case START_STATE:
console.info('case to start');
audioRecorder.start();
break;
case PAUSE_STATE:
console.info('case to pause');
audioRecorder.pause();
break;
case RESUME_STATE:
console.info('case to resume');
audioRecorder.resume();
break;
case STOP_STATE:
console.info('case to stop');
audioRecorder.stop();
break;
case RESET_STATE:
console.info('case to reset');
audioRecorder.reset();
break;
case RELEASE_STATE:
console.info('case to release');
audioRecorder.release();
break;
case ERROR_STATE:
console.info('case to wait error callback');
break;
default:
break;
}
}
function setErrorCallback(mySteps) {
audioRecorder.on('error', (err) => {
console.info(`case error called,errName is ${err.name}`);
console.info(`case error called,errCode is ${err.code}`);
console.info(`case error called,errMessage is ${err.message}`);
mySteps.shift();
expect(mySteps[0]).assertEqual(ERROR_STATE);
mySteps.shift();
nextStep(mySteps);
});
}
function setCallback(mySteps, done) {
audioRecorder.on('prepare', () => {
console.info('setCallback prepare() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('start', () => {
console.info('setCallback start() case callback is called');
sleep(RECORDER_TIME);
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('pause', () => {
console.info('setCallback pause() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('resume', () => {
console.info('setCallback resume() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('stop', () => {
console.info('setCallback stop() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('reset', () => {
console.info('setCallback reset() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
audioRecorder.on('release', () => {
console.info('setCallback release() case callback is called');
mySteps.shift();
nextStep(mySteps);
});
setErrorCallback(mySteps);
setTimeout(function() {
if (!isTimeOut) {
console.info('case is time out!');
expect(isTimeOut).assertTrue();
}
mySteps = undefined;
done();
}, TIME_OUT);
}
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0100
* @tc.name : 01.AAC
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0100', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test1.m4a';
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, RELEASE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0210
* @tc.name : 02.AAC_Different Channels 1
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0210', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test2.m4a';
audioConfig.numberOfChannels = CHANNEL_ONE;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0220
* @tc.name : 02.AAC_Different Channels 2
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0220', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test3.m4a';
audioConfig.numberOfChannels = CHANNEL_TWO;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0310
* @tc.name : 03.AAC_DifferentSampleRate 8000
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0310', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test4.m4a';
audioConfig.audioSampleRate = 8000; // samplerate 8000
audioConfig.numberOfChannels = CHANNEL_TWO;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0320
* @tc.name : 03.AAC_DifferentSampleRate 32000
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0320', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test5.mp4';
audioConfig.audioSampleRate = 32000; // samplerate 32000
audioConfig.numberOfChannels = CHANNEL_ONE;
audioConfig.fileFormat = FORMAT_MP4;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0330
* @tc.name : 03.AAC_DifferentSampleRate 44100
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0330', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test6.mp4';
audioConfig.audioSampleRate = 44100; // samplerate 44100
audioConfig.numberOfChannels = CHANNEL_TWO;
audioConfig.fileFormat = FORMAT_MP4;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0340
* @tc.name : 03.AAC_DifferentSampleRate 64000
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0340', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test7.m4a';
audioConfig.audioSampleRate = 64000; // samplerate 64000
audioConfig.numberOfChannels = CHANNEL_ONE;
audioConfig.fileFormat = FORMAT_M4A;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0350
* @tc.name : 03.AAC_DifferentSampleRate 96000
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0340', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test8.m4a';
audioConfig.audioSampleRate = 96000; // samplerate 96000
audioConfig.numberOfChannels = CHANNEL_TWO;
audioConfig.fileFormat = FORMAT_M4A;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0410
* @tc.name : 04.AAC_DifferentBitrate 8000
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0410', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test9.mp4';
audioConfig.audioSampleRate = 22050; // samplerate 22050
audioConfig.audioEncodeBitRate = 8000; // encodeBitrate 8000
audioConfig.numberOfChannels = CHANNEL_TWO;
audioConfig.fileFormat = FORMAT_MP4;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0420
* @tc.name : 04.AAC_DifferentBitrate 16000
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0420', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test10.mp4';
audioConfig.audioSampleRate = 44100; // samplerate 44100
audioConfig.audioEncodeBitRate = 16000; // encodeBitrate 16000
audioConfig.numberOfChannels = CHANNEL_ONE;
audioConfig.fileFormat = FORMAT_MP4;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0430
* @tc.name : 04.AAC_DifferentBitrate 32000
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0430', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test11.m4a';
audioConfig.audioSampleRate = 44100; // samplerate 44100
audioConfig.audioEncodeBitRate = 32000; // encodeBitrate 32000
audioConfig.numberOfChannels = CHANNEL_ONE;
audioConfig.fileFormat = FORMAT_M4A;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0440
* @tc.name : 04.AAC_DifferentBitrate 64000
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0440', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test12.m4a';
audioConfig.audioSampleRate = 44100; // samplerate 44100
audioConfig.audioEncodeBitRate = 64000; // encodeBitrate 64000
audioConfig.numberOfChannels = CHANNEL_TWO;
audioConfig.fileFormat = FORMAT_M4A;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Codec_AAC_Function_0450
* @tc.name : 04.AAC_DifferentBitrate 112000
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Codec_AAC_Function_0450', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test13.m4a';
audioConfig.audioSampleRate = 44100; // samplerate 44100
audioConfig.audioEncodeBitRate = 112000; // encodeBitrate 112000
audioConfig.numberOfChannels = CHANNEL_TWO;
audioConfig.fileFormat = FORMAT_M4A;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Format_MP4_Function_0200
* @tc.name : 02.AAC,mp4
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Format_MP4_Function_0200', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test14.mp4';
audioConfig.audioEncodeBitRate = 22050; // samplerate 22050
audioConfig.audioSampleRate = 22050; // encodeBitrate 22050
audioConfig.fileFormat = FORMAT_MP4;
audioConfig.numberOfChannels = CHANNEL_TWO;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_Format_M4A_Function_0200
* @tc.name : 02.AAC,mp4
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_Format_MP4_Function_0200', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test15.m4a';
audioConfig.audioEncodeBitRate = 22050; // samplerate 22050
audioConfig.audioSampleRate = 22050; // encodeBitrate 22050
audioConfig.fileFormat = FORMAT_M4A;
audioConfig.numberOfChannels = CHANNEL_TWO;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_LOCAL_AUDIO_Function_06_0100
* @tc.name : 001.start
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_LOCAL_AUDIO_Function_06_0100', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test16.m4a';
audioConfig.fileFormat = FORMAT_M4A;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, STOP_STATE, RELEASE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_LOCAL_AUDIO_Function_06_0500
* @tc.name : 005.reset
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_LOCAL_AUDIO_Function_06_0500', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test17.m4a';
audioConfig.fileFormat = FORMAT_M4A;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, RESET_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
/* *
* @tc.number : SUB_MEDIA_RECORDER_LOCAL_AUDIO_Function_06_1100
* @tc.name : 011.start->reset->start->stop
* @tc.desc : Audio recordr control test
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level0
*/
it('SUB_MEDIA_RECORDER_LOCAL_AUDIO_Function_06_1100', 0, async function (done) {
audioConfig.uri = BASIC_PATH + 'test18.mp4';
audioConfig.fileFormat = FORMAT_MP4;
initAudioRecorder();
let mySteps = new Array(PRE_STATE, START_STATE, RESET_STATE, PRE_STATE,
START_STATE, STOP_STATE, RELEASE_STATE, END_STATE);
setCallback(mySteps, done);
audioRecorder.prepare(audioConfig);
})
})
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "MyApplication"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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.
*/
#ifndef PLAYER_TEST_H
#define PLAYER_TEST_H
#include "securec.h"
#include "TestParamsConfig.h"
#include "window_manager.h"
#include "surface_type.h"
#include "display_type.h"
namespace OHOS {
namespace Media {
static const std::string SURFACE_STRIDE_ALIGNMENT = "SURFACE_STRIDE_ALIGNMENT";
static const std::string SURFACE_FORMAT = "SURFACE_FORMAT";
static WindowConfig g_config = {
1920,
1080,
PIXEL_FMT_RGBA_8888,
0,
0,
WINDOW_TYPE_NORMAL
};
static WindowConfig g_sub_config = {
720,
480,
PIXEL_FMT_YCRCB_420_SP,
0,
0,
WINDOW_TYPE_VIDEO,
};
class PlayerSignal {
public:
PlayerStates state_ = PLAYER_IDLE;
int32_t seekPositon_;
bool seekDoneFlag_;
bool mutexFlag_ = true;
std::mutex mutexSeek_;
std::mutex mutexReset_;
std::mutex mutexPrepare_;
std::mutex mutexPlay_;
std::mutex mutexPause_;
std::mutex mutexStop_;
std::condition_variable condVarSeek_;
std::condition_variable condVarReset_;
std::condition_variable condVarPrepare_;
std::condition_variable condVarPlay_;
std::condition_variable condVarPause_;
std::condition_variable condVarStop_;
void SetState(PlayerStates state);
void SetSeekResult(bool seekDoneFlag);
};
class TestPlayer {
public:
std::shared_ptr<Player> player_ = nullptr;
sptr<Window> window_ = nullptr;
explicit TestPlayer(std::shared_ptr<PlayerSignal> test);
virtual ~TestPlayer();
bool CreatePlayer();
int32_t SetSource(const std::string &uri);
int32_t SetDataSrc(const std::string &uri, bool seekable);
int32_t Play();
int32_t Prepare();
int32_t PrepareAsync();
int32_t Pause();
int32_t Stop();
int32_t Reset();
int32_t Release();
int32_t SetVolume(float leftVolume, float rightVolume);
int32_t Seek(int32_t mseconds, PlayerSeekMode mode);
int32_t GetCurrentTime(int32_t &currentTime);
int32_t GetDuration(int32_t &duration);
int32_t SetPlaybackSpeed(PlaybackRateMode mode);
int32_t GetPlaybackSpeed(PlaybackRateMode &mode);
sptr<Surface> GetVideoSurface(WindowConfig g_sub_config);
int32_t SetVideoSurface(sptr<Surface> surface);
bool IsPlaying();
bool IsLooping();
int32_t SetLooping(bool loop);
int32_t SetPlayerCallback(const std::shared_ptr<PlayerCallback> &callback);
private:
std::shared_ptr<PlayerSignal> test_;
};
class TestPlayerCallback : public PlayerCallback {
public:
int errorNum_ = 0;
PlayerStates state_ = PLAYER_STATE_ERROR;
explicit TestPlayerCallback(std::shared_ptr<PlayerSignal> test);
virtual ~TestPlayerCallback();
void OnError(PlayerErrorType errorType, int32_t errorCode);
int WaitForSeekDone(int32_t currentPositon);
void OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody = {});
int WaitForState(PlayerStates state);
private:
void PrintState(PlayerStates state);
PlayerErrorType errorType_ = PLAYER_ERROR_UNKNOWN;
int32_t errorCode_ = -1;
bool seekDoneFlag_ = false;
int32_t postion_ = 0;
std::shared_ptr<PlayerSignal> test_;
};
}
}
#endif
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册