提交 d6e31590 编写于 作者: L ling990

modify Signed-off-by: ling990 <liling96@huawei.com>

Signed-off-by: Nling990 <liling96@huawei.com>
上级 88c15291
...@@ -146,6 +146,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -146,6 +146,7 @@ describe('AudioDecoderReliabilityPromise', function () {
"sample_rate": 44100, "sample_rate": 44100,
"audio_raw_format": 4, "audio_raw_format": 4,
}; };
let expectError = false;
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -257,6 +258,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -257,6 +258,7 @@ describe('AudioDecoderReliabilityPromise', function () {
381, 410, 394, 386, 345, 345, 354, 397, 386, 375, 390, 347, 411, 381, 383, 374, 379, 381, 410, 394, 386, 345, 345, 354, 397, 386, 375, 390, 347, 411, 381, 383, 374, 379,
380, 378, 391, 380, 339, 390, 383, 375]; 380, 378, 391, 380, 339, 390, 383, 375];
ES_LENGTH = 500; ES_LENGTH = 500;
expectError = false;
}) })
afterEach(function() { afterEach(function() {
...@@ -267,7 +269,6 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -267,7 +269,6 @@ describe('AudioDecoderReliabilityPromise', function () {
wait(2000); wait(2000);
}) })
afterAll(function() { afterAll(function() {
console.info('afterAll case'); console.info('afterAll case');
}) })
...@@ -277,6 +278,12 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -277,6 +278,12 @@ describe('AudioDecoderReliabilityPromise', function () {
expect(err).assertUndefined(); expect(err).assertUndefined();
} }
let failCallbackTrue = function(err, mySteps, done) {
console.info('case callback err : ' + err);
expect(err != undefined).assertTrue();
nextStep(mySteps, done);
}
let failCatch = function(err) { let failCatch = function(err) {
console.info('case catch err : ' + err); console.info('case catch err : ' + err);
expect(err).assertUndefined(); expect(err).assertUndefined();
...@@ -303,7 +310,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -303,7 +310,7 @@ describe('AudioDecoderReliabilityPromise', function () {
audioDecodeProcessor = processor; audioDecodeProcessor = processor;
setCallback(savepath, done); setCallback(savepath, done);
console.info("case start api test"); console.info("case start api test");
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}) })
} }
...@@ -353,7 +360,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -353,7 +360,7 @@ describe('AudioDecoderReliabilityPromise', function () {
for(let t = Date.now(); Date.now() - t <= time;); for(let t = Date.now(); Date.now() - t <= time;);
} }
function nextStep(mySteps, mediaDescription, done) { function nextStep(mySteps, done) {
console.info("case myStep[0]: " + mySteps[0]); console.info("case myStep[0]: " + mySteps[0]);
if (mySteps[0] == END) { if (mySteps[0] == END) {
done(); done();
...@@ -367,7 +374,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -367,7 +374,7 @@ describe('AudioDecoderReliabilityPromise', function () {
audioDecodeProcessor.configure(mediaDescription).then(() => { audioDecodeProcessor.configure(mediaDescription).then(() => {
console.info(`case configure 1`); console.info(`case configure 1`);
readFile(AUDIOPATH); readFile(AUDIOPATH);
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case PREPARE: case PREPARE:
...@@ -375,7 +382,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -375,7 +382,7 @@ describe('AudioDecoderReliabilityPromise', function () {
console.info(`case to prepare`); console.info(`case to prepare`);
audioDecodeProcessor.prepare().then(() => { audioDecodeProcessor.prepare().then(() => {
console.info(`case prepare 1`); console.info(`case prepare 1`);
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case START: case START:
...@@ -389,7 +396,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -389,7 +396,7 @@ describe('AudioDecoderReliabilityPromise', function () {
} }
audioDecodeProcessor.start().then(() => { audioDecodeProcessor.start().then(() => {
console.info(`case start 1`); console.info(`case start 1`);
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case FLUSH: case FLUSH:
...@@ -403,7 +410,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -403,7 +410,7 @@ describe('AudioDecoderReliabilityPromise', function () {
workdoneAtEOS = true; workdoneAtEOS = true;
flushAtEOS = false; flushAtEOS = false;
} }
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case STOP: case STOP:
...@@ -411,7 +418,7 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -411,7 +418,7 @@ describe('AudioDecoderReliabilityPromise', function () {
console.info(`case to stop`); console.info(`case to stop`);
audioDecodeProcessor.stop().then(() => { audioDecodeProcessor.stop().then(() => {
console.info(`case stop 1`); console.info(`case stop 1`);
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case RESET: case RESET:
...@@ -419,13 +426,13 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -419,13 +426,13 @@ describe('AudioDecoderReliabilityPromise', function () {
console.info(`case to reset`); console.info(`case to reset`);
audioDecodeProcessor.reset().then(() => { audioDecodeProcessor.reset().then(() => {
console.info(`case reset 1`); console.info(`case reset 1`);
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case HOLDON: case HOLDON:
mySteps.shift(); mySteps.shift();
setTimeout(() =>{ setTimeout(() =>{
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, WAITTIME); }, WAITTIME);
break; break;
case WAITFORALLOUTS: case WAITFORALLOUTS:
...@@ -435,53 +442,48 @@ describe('AudioDecoderReliabilityPromise', function () { ...@@ -435,53 +442,48 @@ describe('AudioDecoderReliabilityPromise', function () {
case CONFIGURE_ERROR: case CONFIGURE_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to configure 2`); console.info(`case to configure 2`);
audioDecodeProcessor.configure(mediaDescription, (err) => { audioDecodeProcessor.configure(mediaDescription).then(() => {
expect(err != undefined).assertTrue();
console.info(`case configure error 1`); console.info(`case configure error 1`);
nextStep(mySteps, mediaDescription, done); expect(expectError).assertTrue();
}); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break; break;
case PREPARE_ERROR: case PREPARE_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to prepare 2`); console.info(`case to prepare 2`);
audioDecodeProcessor.prepare((err) => { audioDecodeProcessor.prepare().then(() => {
expect(err != undefined).assertTrue();
console.info(`case prepare error 1`); console.info(`case prepare error 1`);
nextStep(mySteps, mediaDescription, done); expect(expectError).assertTrue();
}); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break; break;
case START_ERROR: case START_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to start 2`); console.info(`case to start 2`);
audioDecodeProcessor.start((err) => { audioDecodeProcessor.start().then(() => {
expect(err != undefined).assertTrue();
console.info(`case start error 1`); console.info(`case start error 1`);
nextStep(mySteps, mediaDescription, done); expect(expectError).assertTrue();
}); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break; break;
case FLUSH_ERROR: case FLUSH_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to flush 2`); console.info(`case to flush 2`);
audioDecodeProcessor.flush((err) => { audioDecodeProcessor.flush().then(() => {
expect(err != undefined).assertTrue();
console.info(`case flush error 1`); console.info(`case flush error 1`);
nextStep(mySteps, mediaDescription, done); expect(expectError).assertTrue();
}); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break; break;
case STOP_ERROR: case STOP_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to stop 2`); console.info(`case to stop 2`);
audioDecodeProcessor.stop((err) => { audioDecodeProcessor.stop().then(() => {
expect(err != undefined).assertTrue();
console.info(`case stop error 1`); console.info(`case stop error 1`);
nextStep(mySteps, mediaDescription, done); expect(expectError).assertTrue();
}); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break; break;
case JUDGE_EOS: case JUDGE_EOS:
mySteps.shift(); mySteps.shift();
console.info(`case judge EOS state`); console.info(`case judge EOS state`);
expect(sawOutputEOS).assertTrue(); expect(sawOutputEOS).assertTrue();
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
break; break;
default: default:
break; break;
......
...@@ -292,9 +292,35 @@ describe('AudioEncoderFuncPromise', function () { ...@@ -292,9 +292,35 @@ describe('AudioEncoderFuncPromise', function () {
"sample_rate": 48000, "sample_rate": 48000,
"audio_raw_format": 16, "audio_raw_format": 16,
} }
let mediaDescription2 = {
"codec_mime": 'audio/mp4a-latm',
}
let savepath = BASIC_PATH + '0000.txt'; let savepath = BASIC_PATH + '0000.txt';
needgetMediaDes = true; needgetMediaDes = true;
workdoneAtEOS = true; workdoneAtEOS = true;
await media.getMediaCapability().then((mediaCaps) => {
console.info('getMediaCapability success');
if (typeof (mediaCaps) != 'undefined') {
await mediaCaps.getAudioEncoderCaps().then((audioCaps) => {
console.info('getAudioEncoderCaps success');
if (typeof (audioCaps) != 'undefined') {
console.info("case audioCaps " + audioCaps);
} else {
console.info("case audioCaps is not defined");
}
}, failCallback).catch(failCatch);
await mediaCaps.findAudioEncoder(mediaDescription2).then((codecname) => {
console.info('getAudioEncoderCaps success');
if (typeof (codecname) != 'undefined') {
console.info("case codecname " + codecname);
} else {
console.info("case codecname is not defined");
}
}, failCallback).catch(failCatch);
} else {
console.info('mediaCaps is not defined');
}
}, failCallback).catch(failCatch);
await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => { await media.createAudioEncoderByMime('audio/mp4a-latm').then((processor) => {
console.info("case create createAudioEncoder success"); console.info("case create createAudioEncoder success");
audioEncodeProcessor = processor; audioEncodeProcessor = processor;
......
...@@ -57,6 +57,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -57,6 +57,7 @@ describe('AudioEncoderSTTPromise', function () {
"sample_rate": 48000, "sample_rate": 48000,
"audio_raw_format": 16, "audio_raw_format": 16,
}; };
let expectError = false;
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -78,6 +79,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -78,6 +79,7 @@ describe('AudioEncoderSTTPromise', function () {
inputQueue = []; inputQueue = [];
outputQueue = []; outputQueue = [];
ES_LENGTH = 200; ES_LENGTH = 200;
expectError = false;
}) })
afterEach(function() { afterEach(function() {
...@@ -97,6 +99,12 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -97,6 +99,12 @@ describe('AudioEncoderSTTPromise', function () {
expect(err).assertUndefined(); expect(err).assertUndefined();
} }
let failCallbackTrue = function(err, mySteps, done) {
console.info('case callback err : ' + err);
expect(err != undefined).assertTrue();
nextStep(mySteps, done);
}
let failCatch = function(err) { let failCatch = function(err) {
console.info('case catch err : ' + err); console.info('case catch err : ' + err);
expect(err).assertUndefined(); expect(err).assertUndefined();
...@@ -121,7 +129,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -121,7 +129,7 @@ describe('AudioEncoderSTTPromise', function () {
audioEncodeProcessor = processor; audioEncodeProcessor = processor;
setCallback(savepath, done); setCallback(savepath, done);
console.info("case start api test"); console.info("case start api test");
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
} }
...@@ -200,7 +208,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -200,7 +208,7 @@ describe('AudioEncoderSTTPromise', function () {
for(let t = Date.now();Date.now() - t <= time;); for(let t = Date.now();Date.now() - t <= time;);
} }
function nextStep(mySteps, mediaDescription, done) { function nextStep(mySteps, done) {
console.info("case myStep[0]: " + mySteps[0]); console.info("case myStep[0]: " + mySteps[0]);
if (mySteps[0] == END) { if (mySteps[0] == END) {
done(); done();
...@@ -214,7 +222,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -214,7 +222,7 @@ describe('AudioEncoderSTTPromise', function () {
audioEncodeProcessor.configure(mediaDescription).then(() => { audioEncodeProcessor.configure(mediaDescription).then(() => {
console.info(`case configure 1`); console.info(`case configure 1`);
readFile(AUDIOPATH); readFile(AUDIOPATH);
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case PREPARE: case PREPARE:
...@@ -222,7 +230,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -222,7 +230,7 @@ describe('AudioEncoderSTTPromise', function () {
console.info(`case to prepare`); console.info(`case to prepare`);
audioEncodeProcessor.prepare().then(() => { audioEncodeProcessor.prepare().then(() => {
console.info(`case prepare 1`); console.info(`case prepare 1`);
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case START: case START:
...@@ -236,7 +244,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -236,7 +244,7 @@ describe('AudioEncoderSTTPromise', function () {
} }
audioEncodeProcessor.start().then(() => { audioEncodeProcessor.start().then(() => {
console.info(`case start 1`); console.info(`case start 1`);
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case FLUSH: case FLUSH:
...@@ -250,7 +258,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -250,7 +258,7 @@ describe('AudioEncoderSTTPromise', function () {
workdoneAtEOS = true; workdoneAtEOS = true;
flushAtEOS = false; flushAtEOS = false;
} }
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case STOP: case STOP:
...@@ -258,7 +266,7 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -258,7 +266,7 @@ describe('AudioEncoderSTTPromise', function () {
console.info(`case to stop`); console.info(`case to stop`);
audioEncodeProcessor.stop().then(() => { audioEncodeProcessor.stop().then(() => {
console.info(`case stop 1`); console.info(`case stop 1`);
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case RESET: case RESET:
...@@ -266,13 +274,13 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -266,13 +274,13 @@ describe('AudioEncoderSTTPromise', function () {
console.info(`case to reset`); console.info(`case to reset`);
audioEncodeProcessor.reset().then(() => { audioEncodeProcessor.reset().then(() => {
console.info(`case reset 1`); console.info(`case reset 1`);
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, failCallback).catch(failCatch); }, failCallback).catch(failCatch);
break; break;
case HOLDON: case HOLDON:
mySteps.shift(); mySteps.shift();
setTimeout(() =>{ setTimeout(() =>{
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
}, WAITTIME); }, WAITTIME);
break; break;
case WAITFORALLOUTS: case WAITFORALLOUTS:
...@@ -281,54 +289,49 @@ describe('AudioEncoderSTTPromise', function () { ...@@ -281,54 +289,49 @@ describe('AudioEncoderSTTPromise', function () {
break; break;
case CONFIGURE_ERROR: case CONFIGURE_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to configure`); console.info(`case to configure 2`);
audioEncodeProcessor.configure(mediaDescription, (err) => { audioEncodeProcessor.configure(mediaDescription).then(() => {
expect(err != undefined).assertTrue();
console.info(`case configure error 1`); console.info(`case configure error 1`);
nextStep(mySteps, mediaDescription, done); expect(expectError).assertTrue();
}); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break; break;
case PREPARE_ERROR: case PREPARE_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to prepare`); console.info(`case to prepare 2`);
audioEncodeProcessor.prepare((err) => { audioEncodeProcessor.prepare().then(() => {
expect(err != undefined).assertTrue();
console.info(`case prepare error 1`); console.info(`case prepare error 1`);
nextStep(mySteps, mediaDescription, done); expect(expectError).assertTrue();
}); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break; break;
case START_ERROR: case START_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to start`); console.info(`case to start 2`);
audioEncodeProcessor.start((err) => { audioEncodeProcessor.start().then(() => {
expect(err != undefined).assertTrue();
console.info(`case start error 1`); console.info(`case start error 1`);
nextStep(mySteps, mediaDescription, done); expect(expectError).assertTrue();
}); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break; break;
case FLUSH_ERROR: case FLUSH_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to flush`); console.info(`case to flush 2`);
audioEncodeProcessor.flush((err) => { audioEncodeProcessor.flush().then(() => {
expect(err != undefined).assertTrue();
console.info(`case flush error 1`); console.info(`case flush error 1`);
nextStep(mySteps, mediaDescription, done); expect(expectError).assertTrue();
}); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break; break;
case STOP_ERROR: case STOP_ERROR:
mySteps.shift(); mySteps.shift();
console.info(`case to stop`); console.info(`case to stop 2`);
audioEncodeProcessor.stop((err) => { audioEncodeProcessor.stop().then(() => {
expect(err != undefined).assertTrue();
console.info(`case stop error 1`); console.info(`case stop error 1`);
nextStep(mySteps, mediaDescription, done); expect(expectError).assertTrue();
}); }, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break; break;
case JUDGE_EOS: case JUDGE_EOS:
mySteps.shift(); mySteps.shift();
console.info(`case judge EOS state`); console.info(`case judge EOS state`);
expect(sawOutputEOS).assertTrue(); expect(sawOutputEOS).assertTrue();
nextStep(mySteps, mediaDescription, done); nextStep(mySteps, done);
break; break;
default: default:
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册