提交 348d3087 编写于 作者: L lwx1121892

<liuxueqi3@huawei.com>

Signed-off-by: Nlwx1121892 <liuxueqi3@huawei.com>
上级 dcbec281
......@@ -13,7 +13,7 @@
],
"type": "AppInstallKit",
"run-command": [
"mkdir /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files/media"
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/media"
],
"cleanup-apps": true
},
......@@ -22,25 +22,25 @@
"pre-push": [
],
"push": [
"./resource/audio/audioManager/Believer.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/Believer60s.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-1C-8000-2SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-1C-16000-2SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-1C-32000-1SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-1C-44100-2SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-1C-64000-3SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-1C-96000-4SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-2C-11025-1SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-2C-12000-2SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-2C-16000-3SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-2C-22050-2SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-2C-24000-3SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/StarWars10s-2C-48000-4SW.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files",
"./resource/audio/audioManager/Believer.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files/media",
"./resource/audio/audioManager/file_example_WAV_1MG.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files/media",
"./resource/audio/audioManager/safe_and_sound_32.wav ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files/media",
"./resource/audio/audioManager/test.mp3 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files/media",
"./resource/audio/audioManager/test.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiomanager/files/media"
"./resource/audio/audioManager/Believer.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/Believer60s.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-1C-8000-2SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-1C-16000-2SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-1C-32000-1SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-1C-44100-2SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-1C-64000-3SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-1C-96000-4SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-2C-11025-1SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-2C-12000-2SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-2C-16000-3SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-2C-22050-2SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-2C-24000-3SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/StarWars10s-2C-48000-4SW.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/",
"./resource/audio/audioManager/Believer.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/media",
"./resource/audio/audioManager/file_example_WAV_1MG.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/media",
"./resource/audio/audioManager/safe_and_sound_32.wav ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/media",
"./resource/audio/audioManager/test.mp3 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/media",
"./resource/audio/audioManager/test.mp4 ->/data/app/el2/100/base/ohos.acts.multimedia.audio.audiomanager/haps/entry/files/media"
]
}
]
......
......@@ -23,7 +23,7 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
import featureAbility from '@ohos.ability.featureAbility'
import resourceManager from '@ohos.resourceManager';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
describe('audioCall', function () {
var mediaDir;
......@@ -31,6 +31,8 @@ describe('audioCall', function () {
let readpath;
var resultFlagRec;
var resultFlagRen;
let fdPath;
let filePath;
const audioManager = audio.getAudioManager();
console.info('AudioFrameworkRenderLog: Create AudioManger Object JS Framework');
......@@ -55,11 +57,19 @@ describe('audioCall', function () {
return mediaDirTemp;
}*/
async function getAbilityInfo(fileName) {
let context = await featureAbility.getContext();
console.info("case0 context is " + context);
await context.getFilesDir().then((data) => {
console.info("case1 getFilesDir is path " + data);
mediaDir = data + '/' + fileName;
console.info('case2 mediaDir is ' + mediaDir);
})
}
beforeAll(async function () {
await applyPermission();
console.info('AudioFrameworkTest: beforeAll: Prerequisites at the test suite level');
mediaDir = '/data/storage/el2/base/haps/entry/cache';
// mediaDir = '/data/storage/el2/base/haps/entry/cache';
})
beforeEach(async function () {
......@@ -76,21 +86,10 @@ describe('audioCall', function () {
console.info('AudioFrameworkTest: afterAll: Test suite-level cleanup condition');
})
function sleep (ms) {
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function getFileDescriptor(fileName) {
let fileDescriptor = undefined;
await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.getRawFileDescriptor(fileName).then(value => {
fileDescriptor = { fd: value.fd, offset: value.offset, length: value.length };
}).catch(error => {
console.log('AudioFrameworkRenderLog:case getRawFileDescriptor err: ' + error);
});
});
return fileDescriptor;
}
async function closeFileDescriptor(fileName) {
await resourceManager.getResourceManager().then(async (mgr) => {
......@@ -101,19 +100,40 @@ describe('audioCall', function () {
});
});
}
async function getFdRead(pathName, done) {
await getFileDescriptor(pathName).then((res) => {
if (res == undefined) {
expect().assertFail();
console.info('AudioFrameworkRenderLog:case error fileDescriptor undefined, open file fail');
done();
} else {
fdRead = res.fd;
console.info("AudioFrameworkRenderLog:case 0 fdRead is: " + fdRead);
}
// async function getFdRead(pathName, done) {
// await getFileDescriptor(pathName).then((res) => {
// if (res == undefined) {
// expect().assertFail();
// console.info('AudioFrameworkRenderLog:case error fileDescriptor undefined, open file fail');
// done();
// } else {
// fdRead = res.fd;
// console.info("AudioFrameworkRenderLog:case 0 fdRead is: " + fdRead);
// }
// })
// }
async function getFdRead(pathName) {
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');
}).catch((err) => {
console.info('[fileIO]case catch open fd failed');
});
}
async function applyPermission() {
let appInfo = await bundle.getApplicationInfo('ohos.acts.multimedia.audio.audiomanager', 0, 100);
let atManager = abilityAccessCtrl.createAtManager();
......@@ -144,7 +164,7 @@ describe('audioCall', function () {
}
async function playbackPromise (AudioRendererOptions, pathName, AudioScene) {
async function playbackPromise(AudioRendererOptions, pathName, AudioScene) {
resultFlagRen = 'new';
console.info('AudioFrameworkRenderLog: Promise : Audio Playback Function');
......@@ -153,11 +173,11 @@ describe('audioCall', function () {
audioRen = data;
console.info('AudioFrameworkRenderLog: AudioRender Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : '+err.message);
resultFlagRen=false;
console.info('AudioFrameworkRenderLog: AudioRender Created : ERROR : ' + err.message);
resultFlagRen = false;
return resultFlagRen;
});
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : ' + audioRen.state);
await audioRen.getStreamInfo().then(async function (audioParamsGet) {
console.info('AudioFrameworkRenderLog: Renderer getStreamInfo:');
......@@ -166,11 +186,11 @@ describe('audioCall', function () {
console.info('AudioFrameworkRenderLog: Renderer channels:' + audioParamsGet.channels);
console.info('AudioFrameworkRenderLog: Renderer encodingType:' + audioParamsGet.encodingType);
}).catch((err) => {
console.log('AudioFrameworkRenderLog: getStreamInfo :ERROR: '+err.message);
console.log('AudioFrameworkRenderLog: getStreamInfo :ERROR: ' + err.message);
resultFlagRen = false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
if (resultFlagRen == false) {
console.info('AudioFrameworkRenderLog: resultFlagRen : ' + resultFlagRen);
return resultFlagRen;
}
......@@ -180,37 +200,37 @@ describe('audioCall', function () {
console.info('AudioFrameworkRenderLog: Renderer usage:' + audioParamsGet.usage);
console.info('AudioFrameworkRenderLog: Renderer rendererFlags:' + audioParamsGet.rendererFlags);
}).catch((err) => {
console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: '+err.message);
console.log('AudioFrameworkRenderLog: RendererInfo :ERROR: ' + err.message);
resultFlagRen = false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
if (resultFlagRen == false) {
console.info('AudioFrameworkRenderLog: resultFlagRen : ' + resultFlagRen);
return resultFlagRen;
}
await audioRen.start().then(async function () {
console.info('AudioFrameworkRenderLog: renderInstant started :SUCCESS ');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : '+err.message);
resultFlagRen=false;
console.info('AudioFrameworkRenderLog: renderInstant start :ERROR : ' + err.message);
resultFlagRen = false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
if (resultFlagRen == false) {
console.info('AudioFrameworkRenderLog: resultFlagRen : ' + resultFlagRen);
return resultFlagRen;
}
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : ' + audioRen.state);
var bufferSize;
await audioRen.getBufferSize().then(async function (data) {
console.info('AudioFrameworkRenderLog: getBufferSize :SUCCESS '+data);
bufferSize=data;
console.info('AudioFrameworkRenderLog: getBufferSize :SUCCESS ' + data);
bufferSize = data;
}).catch((err) => {
console.info('AudioFrameworkRenderLog: getBufferSize :ERROR : '+err.message);
resultFlagRen=false;
console.info('AudioFrameworkRenderLog: getBufferSize :ERROR : ' + err.message);
resultFlagRen = false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
if (resultFlagRen == false) {
console.info('AudioFrameworkRenderLog: resultFlagRen : ' + resultFlagRen);
return resultFlagRen;
}
......@@ -219,21 +239,21 @@ describe('audioCall', function () {
let discardHeader = new ArrayBuffer(44);
ss.readSync(discardHeader);
let totalSize = fileio.fstatSync(fdRead).size;
console.info('AudioFrameworkRenderLog:case3: File totalSize size: ' +totalSize);
totalSize = totalSize-44;
console.info('AudioFrameworkRenderLog: File size : Removing header: ' +totalSize);
console.info('AudioFrameworkRenderLog:case3: File totalSize size: ' + totalSize);
totalSize = totalSize - 44;
console.info('AudioFrameworkRenderLog: File size : Removing header: ' + totalSize);
let rlen = 0;
while (rlen < totalSize/4) {
while (rlen < totalSize / 4) {
let buf = new ArrayBuffer(bufferSize);
rlen += ss.readSync(buf);
console.info('AudioFrameworkRenderLog:BufferAudioFramework: bytes read from file: ' +rlen);
console.info('AudioFrameworkRenderLog:BufferAudioFramework: bytes read from file: ' + rlen);
await audioRen.write(buf);
if (rlen > (totalSize/2)){
if (rlen > (totalSize / 2)) {
await audioManager.getAudioScene().then(async function (data) {
console.info('AudioFrameworkRenderLog:AudioFrameworkAudioScene: getAudioScene : Value : '+data);
console.info('AudioFrameworkRenderLog:AudioFrameworkAudioScene: getAudioScene : Value : ' + data);
}).catch((err) => {
console.info('AudioFrameworkRenderLog:AudioFrameworkAudioScene: getAudioScene : ERROR : '+err.message);
resultFlagRen=false;
console.info('AudioFrameworkRenderLog:AudioFrameworkAudioScene: getAudioScene : ERROR : ' + err.message);
resultFlagRen = false;
});
}
}
......@@ -242,42 +262,42 @@ describe('audioCall', function () {
await audioRen.drain().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer drained : SUCCESS');
}).catch((err) => {
console.error('AudioFrameworkRenderLog: Renderer drain: ERROR : '+err.message);
resultFlagRen=false;
console.error('AudioFrameworkRenderLog: Renderer drain: ERROR : ' + err.message);
resultFlagRen = false;
});
if (resultFlagRen == false){
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
if (resultFlagRen == false) {
console.info('AudioFrameworkRenderLog: resultFlagRen : ' + resultFlagRen);
return resultFlagRen;
}
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : ' + audioRen.state);
await audioRen.stop().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer stopped : SUCCESS');
resultFlagRen=true;
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
resultFlagRen = true;
console.info('AudioFrameworkRenderLog: resultFlagRen : ' + resultFlagRen);
}).catch((err) => {
console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : '+err.message);
resultFlagRen=false;
console.info('AudioFrameworkRenderLog: Renderer stop:ERROR : ' + err.message);
resultFlagRen = false;
});
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : ' + audioRen.state);
await audioRen.release().then(async function () {
console.info('AudioFrameworkRenderLog: Renderer release : SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRenderLog: Renderer release :ERROR : '+err.message);
resultFlagRen=false;
console.info('AudioFrameworkRenderLog: Renderer release :ERROR : ' + err.message);
resultFlagRen = false;
});
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : '+audioRen.state);
console.info('AudioFrameworkRenderLog: AudioRenderer : STATE : ' + audioRen.state);
console.info('AudioFrameworkRenderLog: resultFlagRen : '+resultFlagRen);
console.info('AudioFrameworkRenderLog: resultFlagRen : ' + resultFlagRen);
return resultFlagRen;
}
async function recPromise (AudioCapturerOptions, fpath, AudioScene) {
async function recPromise(AudioCapturerOptions, fpath, AudioScene) {
resultFlagRec = 'new';
console.info('AudioFrameworkRecLog: Promise : Audio Recording Function');
......@@ -288,13 +308,13 @@ describe('audioCall', function () {
audioCap = data;
console.info('AudioFrameworkRecLog: AudioCapturer Created : Success : Stream Type: SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : '+err.message);
console.info('AudioFrameworkRecLog: AudioCapturer Created : ERROR : ' + err.message);
return resultFlagRec;
});
console.info('AudioFrameworkRecLog: AudioCapturer : Path : '+fpath);
console.info('AudioFrameworkRecLog: AudioCapturer : Path : ' + fpath);
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state);
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCap.state);
await audioCap.getStreamInfo().then(async function (audioParamsGet) {
......@@ -304,11 +324,11 @@ describe('audioCall', function () {
console.info('AudioFrameworkRecLog: Capturer channels:' + audioParamsGet.channels);
console.info('AudioFrameworkRecLog: Capturer encodingType:' + audioParamsGet.encodingType);
}).catch((err) => {
console.log('AudioFrameworkRecLog: getStreamInfo :ERROR: '+err.message);
console.log('AudioFrameworkRecLog: getStreamInfo :ERROR: ' + err.message);
resultFlagRec = false;
});
if (resultFlagRec == false){
console.info('AudioFrameworkRecLog: resultFlagRec : '+resultFlagRec);
if (resultFlagRec == false) {
console.info('AudioFrameworkRecLog: resultFlagRec : ' + resultFlagRec);
return resultFlagRec;
}
......@@ -317,26 +337,26 @@ describe('audioCall', function () {
console.info('AudioFrameworkRecLog: Capturer SourceType:' + audioParamsGet.source);
console.info('AudioFrameworkRecLog: Capturer capturerFlags:' + audioParamsGet.capturerFlags);
}).catch((err) => {
console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: '+err.message);
console.log('AudioFrameworkRecLog: CapturerInfo :ERROR: ' + err.message);
resultFlagRec = false;
});
if (resultFlagRec == false){
console.info('AudioFrameworkRecLog: resultFlag : '+resultFlagRec);
if (resultFlagRec == false) {
console.info('AudioFrameworkRecLog: resultFlag : ' + resultFlagRec);
return resultFlagRec;
}
await audioCap.start().then(async function () {
console.info('AudioFrameworkRecLog: Capturer started :SUCCESS ');
}).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message);
resultFlagRec=false;
console.info('AudioFrameworkRecLog: Capturer start :ERROR : ' + err.message);
resultFlagRec = false;
});
if (resultFlagRec == false){
console.info('AudioFrameworkRecLog: resultFlagRec : '+resultFlagRec);
if (resultFlagRec == false) {
console.info('AudioFrameworkRecLog: resultFlagRec : ' + resultFlagRec);
return resultFlagRec;
}
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state);
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCap.state);
var bufferSize = await audioCap.getBufferSize();
console.info('AudioFrameworkRecLog: buffer size: ' + bufferSize);
......@@ -345,9 +365,9 @@ describe('audioCall', function () {
if (fd !== null) {
console.info('AudioFrameworkRecLog: file fd created');
}
else{
console.info('AudioFrameworkRecLog: Capturer start :ERROR : '+err.message);
resultFlagRec=false;
else {
console.info('AudioFrameworkRecLog: Capturer start :ERROR : ' + err.message);
resultFlagRec = false;
return resultFlagRec;
}
......@@ -355,9 +375,9 @@ describe('audioCall', function () {
if (fd !== null) {
console.info('AudioFrameworkRecLog: file fd opened : Append Mode :PASS');
}
else{
else {
console.info('AudioFrameworkRecLog: file fd Open: Append Mode : FAILED');
resultFlagRec=false;
resultFlagRec = false;
return resultFlagRec;
}
......@@ -369,27 +389,27 @@ describe('audioCall', function () {
numBuffersToCapture--;
}
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state);
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCap.state);
await audioCap.stop().then(async function () {
console.info('AudioFrameworkRecLog: Capturer stopped : SUCCESS');
resultFlagRec=true;
console.info('AudioFrameworkRecLog: resultFlagRec : '+resultFlagRec);
resultFlagRec = true;
console.info('AudioFrameworkRecLog: resultFlagRec : ' + resultFlagRec);
}).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer stop:ERROR : '+err.message);
resultFlagRec=false;
console.info('AudioFrameworkRecLog: Capturer stop:ERROR : ' + err.message);
resultFlagRec = false;
});
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state);
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCap.state);
await audioCap.release().then(async function () {
console.info('AudioFrameworkRecLog: Capturer release : SUCCESS');
}).catch((err) => {
console.info('AudioFrameworkRecLog: Capturer release :ERROR : '+err.message);
resultFlagRec=false;
console.info('AudioFrameworkRecLog: Capturer release :ERROR : ' + err.message);
resultFlagRec = false;
});
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : '+audioCap.state);
console.info('AudioFrameworkRecLog: AudioCapturer : STATE : ' + audioCap.state);
return resultFlagRec;
......@@ -424,11 +444,10 @@ describe('audioCall', function () {
rendererInfo: AudioRendererInfo
}
readpath = 'StarWars10s-1C-44100-2SW.wav';
await getFdRead(readpath,done);
var resultFlag = await playbackPromise(AudioRendererOptions, readpath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await getFdRead("StarWars10s-1C-44100-2SW.wav");
var resultFlag = await playbackPromise(AudioRendererOptions, filePath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(100);
console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag);
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag);
expect(resultFlag).assertTrue();
await closeFileDescriptor(readpath);
done();
......@@ -453,17 +472,17 @@ describe('audioCall', function () {
var AudioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 0
capturerFlags: 1
}
var AudioCapturerOptions = {
streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo
}
var resultFlag = await recPromise(AudioCapturerOptions, mediaDir+'/capture_js-44100-2C-16B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await getAbilityInfo("capture_js-44100-2C-16B.pcm");
var resultFlag = await recPromise(AudioCapturerOptions, mediaDir, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(100);
console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag);
console.info('AudioFrameworkRenderLog: resultFlag : ' + resultFlag);
expect(resultFlag).assertTrue();
done();
......@@ -489,7 +508,7 @@ describe('audioCall', function () {
var AudioCapturerInfo = {
source: audio.SourceType.SOURCE_TYPE_MIC,
capturerFlags: 0
capturerFlags: 1
}
var AudioCapturerOptions = {
......@@ -514,19 +533,20 @@ describe('audioCall', function () {
streamInfo: AudioStreamInfoRen,
rendererInfo: AudioRendererInfo
}
recPromise(AudioCapturerOptions, mediaDir+'/capture_js-44100-2C-16B-2.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await getAbilityInfo("capture_js-44100-2C-16B-2.pcm");
recPromise(AudioCapturerOptions, mediaDir, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(500);
readpath = 'StarWars10s-1C-44100-2SW.wav';
await getFdRead(readpath,done);
await playbackPromise(AudioRendererOptions, readpath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await getFdRead(readpath);
await playbackPromise(AudioRendererOptions, filePath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(1000);
console.info('AudioFrameworkRecLog: resultFlag : Capturer : '+resultFlagRec);
console.info('AudioFrameworkRenderLog: resultFlag : Renderer : '+resultFlagRen);
console.info('AudioFrameworkRecLog: resultFlag : Capturer : ' + resultFlagRec);
console.info('AudioFrameworkRenderLog: resultFlag : Renderer : ' + resultFlagRen);
if (resultFlagRec == true){
if (resultFlagRec == true) {
expect(resultFlagRen).assertTrue();
}
else{
else {
expect(false).assertTrue();
}
await closeFileDescriptor(readpath);
......
......@@ -28,6 +28,8 @@ describe('audioRenderer_audo2', function () {
var mediaDir;
let fdRead;
let readpath;
let fdPath;
let filePath;
/*async function getPathName(){
var path1 = '/data/app/el1/bundle/public/';
var packageName;
......@@ -55,7 +57,7 @@ describe('audioRenderer_audo2', function () {
beforeAll(async function () {
await applyPermission();
console.info('AudioFrameworkTest: beforeAll: Prerequisites at the test suite level');
mediaDir = '/data/storage/el2/base/haps/entry/cache';
// mediaDir = '/data/storage/el2/base/haps/entry/cache';
})
beforeEach(async function () {
......@@ -75,18 +77,15 @@ describe('audioRenderer_audo2', function () {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function getFileDescriptor(fileName) {
let fileDescriptor = undefined;
await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.getRawFileDescriptor(fileName).then(value => {
fileDescriptor = { fd: value.fd, offset: value.offset, length: value.length };
}).catch(error => {
console.log('AudioFrameworkRenderLog:case getRawFileDescriptor err: ' + error);
});
});
return fileDescriptor;
async function getAbilityInfo(fileName) {
let context = await featureAbility.getContext();
console.info("case0 context is " + context);
await context.getFilesDir().then((data) => {
console.info("case1 getFilesDir is path " + data);
mediaDir = data + '/' + fileName;
console.info('case2 mediaDir is ' + mediaDir);
})
}
async function closeFileDescriptor(fileName) {
await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.closeRawFileDescriptor(fileName).then(value => {
......@@ -96,17 +95,39 @@ describe('audioRenderer_audo2', function () {
});
});
}
async function getFdRead(pathName, done) {
await getFileDescriptor(pathName).then((res) => {
if (res == undefined) {
expect().assertFail();
console.info('AudioFrameworkRenderLog:case error fileDescriptor undefined, open file fail');
done();
} else {
fdRead = res.fd;
console.info("AudioFrameworkRenderLog:case 0 fdRead is: " + fdRead);
}
// async function getFdRead(pathName, done) {
// await getFileDescriptor(pathName).then((res) => {
// if (res == undefined) {
// expect().assertFail();
// console.info('AudioFrameworkRenderLog:case error fileDescriptor undefined, open file fail');
// done();
// } else {
// fdRead = res.fd;
// console.info("AudioFrameworkRenderLog:case 0 fdRead is: " + fdRead);
// }
// })
// }
async function getFdRead(pathName) {
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');
}).catch((err) => {
console.info('[fileIO]case catch open fd failed');
});
}
async function applyPermission() {
......@@ -434,13 +455,13 @@ describe('audioRenderer_audo2', function () {
rendererInfo: AudioRendererInfo
}
readpath = 'StarWars10s-1C-44100-2SW.wav';
await getFdRead(readpath,done);
var resultFlag = await playbackPromise(AudioRendererOptions, readpath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
// readpath = 'StarWars10s-1C-44100-2SW.wav';
await getFdRead("StarWars10s-1C-44100-2SW.wav");
var resultFlag = await playbackPromise(AudioRendererOptions, filePath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(100);
console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag);
expect(resultFlag).assertTrue();
await closeFileDescriptor(readpath);
await closeFileDescriptor(filePath);
done();
})
......@@ -470,8 +491,9 @@ describe('audioRenderer_audo2', function () {
streamInfo: AudioStreamInfo,
capturerInfo: AudioCapturerInfo
}
var resultFlag = await recPromise(AudioCapturerOptions, mediaDir+'/capture_js-44100-2C-16B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await getAbilityInfo("capture_js-44100-2C-16B.pcm");
var resultFlag = await recPromise(AudioCapturerOptions, mediaDir, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
// var resultFlag = await recPromise(AudioCapturerOptions, mediaDir+'/capture_js-44100-2C-16B.pcm', audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(100);
console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag);
expect(resultFlag).assertTrue();
......@@ -522,17 +544,17 @@ describe('audioRenderer_audo2', function () {
streamInfo: AudioStreamInfoRen,
rendererInfo: AudioRendererInfo
}
recPromise(AudioCapturerOptions, mediaDir+'/capture_js-44100-2C-16B-2.pcm', audio.AudioScene.AUDIO_SCENE_PHONE_CHAT);
await getAbilityInfo("capture_js-44100-2C-16B-2.pcm");
recPromise(AudioCapturerOptions, mediaDir, audio.AudioScene.AUDIO_SCENE_PHONE_CHAT);
await sleep(500);
readpath = 'StarWars10s-1C-44100-2SW.wav';
await getFdRead(readpath,done);
await getFdRead(readpath);
var resultFlag = await playbackPromise(AudioRendererOptions, readpath, audio.AudioScene.AUDIO_SCENE_VOICE_CHAT);
await sleep(100);
console.info('AudioFrameworkRenderLog: resultFlag : '+resultFlag);
expect(resultFlag).assertTrue();
await closeFileDescriptor(readpath,done);
await closeFileDescriptor(readpath);
done();
})
......
......@@ -17,7 +17,7 @@
{
"type": "ShellKit",
"run-command": [
"mkdir /data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/cache/",
"mkdir -p /data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/cache/",
"chmod -R 666 /data/app/el2/100/base/ohos.acts.multimedia.image/haps/entry/cache/*"
],
"teardown-command":[
......
/*
* 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.
*/
package ohos.acts.multimedia.image;
import ohos.ace.ability.AceAbility;
import ohos.aafwk.content.Intent;
/*
* java MainAbility
*/
public class MainAbility extends AceAbility {
@Override
public void onStart(Intent intent) {
super.onStart(intent);
}
@Override
public void onStop() {
super.onStop();
}
}
/*
* 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.
*/
package ohos.acts.multimedia.image;
import ohos.aafwk.ability.AbilityPackage;
/*
* java MyApplication
*/
public class MyApplication extends AbilityPackage {
@Override
public void onInitialize() {
super.onInitialize();
}
}
......@@ -2412,7 +2412,7 @@ describe('Image', function () {
expect(false).assertTrue();
done();
} else {
let packOpts = { format: ["image/jpeg"], quality: 99 }
let packOpts = { format: "image/jpeg", quality: 99 }
imagePackerApi.packing(imageSourceApi, packOpts)
.then(data => {
console.info('TC_062 success');
......@@ -2460,7 +2460,7 @@ describe('Image', function () {
expect(false).assertTrue();
done();
} else {
let packOpts = { format: ["image/jpeg"], quality: 1 }
let packOpts = { format: "image/jpeg", quality: 1 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-1 success');
expect(data != undefined).assertTrue();
......@@ -2692,7 +2692,7 @@ describe('Image', function () {
expect(false).assertTrue();
done();
} else {
let packOpts = { format: ["image/jpeg"], quality: 100 }
let packOpts = { format: "image/jpeg", quality: 100 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
if (err) {
expect(false).assertTrue();
......@@ -2745,7 +2745,7 @@ describe('Image', function () {
expect(false).assertTrue();
done();
} else {
let packOpts = { format: ["image/jpeg"], quality: 0 }
let packOpts = { format: "image/jpeg", quality: 0 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-8 success');
expect(data != undefined).assertTrue();
......@@ -2785,7 +2785,7 @@ describe('Image', function () {
expect(false).assertTrue();
done();
} else {
let packOpts = { format: ["image/jpeg"], quality: -1 }
let packOpts = { format: "image/jpeg", quality: -1 }
imagePackerApi.packing(imageSourceApi, packOpts, (err, data) => {
console.info('TC_062-9 success');
expect(data == undefined).assertTrue();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册