提交 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 () {
"sample_rate": 44100,
"audio_raw_format": 4,
};
let expectError = false;
beforeAll(function() {
console.info('beforeAll case');
......@@ -257,6 +258,7 @@ describe('AudioDecoderReliabilityPromise', function () {
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];
ES_LENGTH = 500;
expectError = false;
})
afterEach(function() {
......@@ -267,7 +269,6 @@ describe('AudioDecoderReliabilityPromise', function () {
wait(2000);
})
afterAll(function() {
console.info('afterAll case');
})
......@@ -277,6 +278,12 @@ describe('AudioDecoderReliabilityPromise', function () {
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) {
console.info('case catch err : ' + err);
expect(err).assertUndefined();
......@@ -303,7 +310,7 @@ describe('AudioDecoderReliabilityPromise', function () {
audioDecodeProcessor = processor;
setCallback(savepath, done);
console.info("case start api test");
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
})
}
......@@ -353,7 +360,7 @@ describe('AudioDecoderReliabilityPromise', function () {
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]);
if (mySteps[0] == END) {
done();
......@@ -367,7 +374,7 @@ describe('AudioDecoderReliabilityPromise', function () {
audioDecodeProcessor.configure(mediaDescription).then(() => {
console.info(`case configure 1`);
readFile(AUDIOPATH);
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case PREPARE:
......@@ -375,7 +382,7 @@ describe('AudioDecoderReliabilityPromise', function () {
console.info(`case to prepare`);
audioDecodeProcessor.prepare().then(() => {
console.info(`case prepare 1`);
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case START:
......@@ -389,7 +396,7 @@ describe('AudioDecoderReliabilityPromise', function () {
}
audioDecodeProcessor.start().then(() => {
console.info(`case start 1`);
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case FLUSH:
......@@ -403,7 +410,7 @@ describe('AudioDecoderReliabilityPromise', function () {
workdoneAtEOS = true;
flushAtEOS = false;
}
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case STOP:
......@@ -411,7 +418,7 @@ describe('AudioDecoderReliabilityPromise', function () {
console.info(`case to stop`);
audioDecodeProcessor.stop().then(() => {
console.info(`case stop 1`);
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case RESET:
......@@ -419,13 +426,13 @@ describe('AudioDecoderReliabilityPromise', function () {
console.info(`case to reset`);
audioDecodeProcessor.reset().then(() => {
console.info(`case reset 1`);
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case HOLDON:
mySteps.shift();
setTimeout(() =>{
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, WAITTIME);
break;
case WAITFORALLOUTS:
......@@ -435,53 +442,48 @@ describe('AudioDecoderReliabilityPromise', function () {
case CONFIGURE_ERROR:
mySteps.shift();
console.info(`case to configure 2`);
audioDecodeProcessor.configure(mediaDescription, (err) => {
expect(err != undefined).assertTrue();
audioDecodeProcessor.configure(mediaDescription).then(() => {
console.info(`case configure error 1`);
nextStep(mySteps, mediaDescription, done);
});
expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break;
case PREPARE_ERROR:
mySteps.shift();
console.info(`case to prepare 2`);
audioDecodeProcessor.prepare((err) => {
expect(err != undefined).assertTrue();
audioDecodeProcessor.prepare().then(() => {
console.info(`case prepare error 1`);
nextStep(mySteps, mediaDescription, done);
});
expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break;
case START_ERROR:
mySteps.shift();
console.info(`case to start 2`);
audioDecodeProcessor.start((err) => {
expect(err != undefined).assertTrue();
audioDecodeProcessor.start().then(() => {
console.info(`case start error 1`);
nextStep(mySteps, mediaDescription, done);
});
expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break;
case FLUSH_ERROR:
mySteps.shift();
console.info(`case to flush 2`);
audioDecodeProcessor.flush((err) => {
expect(err != undefined).assertTrue();
audioDecodeProcessor.flush().then(() => {
console.info(`case flush error 1`);
nextStep(mySteps, mediaDescription, done);
});
expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break;
case STOP_ERROR:
mySteps.shift();
console.info(`case to stop 2`);
audioDecodeProcessor.stop((err) => {
expect(err != undefined).assertTrue();
audioDecodeProcessor.stop().then(() => {
console.info(`case stop error 1`);
nextStep(mySteps, mediaDescription, done);
});
expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break;
case JUDGE_EOS:
mySteps.shift();
console.info(`case judge EOS state`);
expect(sawOutputEOS).assertTrue();
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
break;
default:
break;
......
......@@ -292,9 +292,35 @@ describe('AudioEncoderFuncPromise', function () {
"sample_rate": 48000,
"audio_raw_format": 16,
}
let mediaDescription2 = {
"codec_mime": 'audio/mp4a-latm',
}
let savepath = BASIC_PATH + '0000.txt';
needgetMediaDes = 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) => {
console.info("case create createAudioEncoder success");
audioEncodeProcessor = processor;
......
......@@ -57,6 +57,7 @@ describe('AudioEncoderSTTPromise', function () {
"sample_rate": 48000,
"audio_raw_format": 16,
};
let expectError = false;
beforeAll(function() {
console.info('beforeAll case');
......@@ -78,6 +79,7 @@ describe('AudioEncoderSTTPromise', function () {
inputQueue = [];
outputQueue = [];
ES_LENGTH = 200;
expectError = false;
})
afterEach(function() {
......@@ -97,6 +99,12 @@ describe('AudioEncoderSTTPromise', function () {
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) {
console.info('case catch err : ' + err);
expect(err).assertUndefined();
......@@ -121,7 +129,7 @@ describe('AudioEncoderSTTPromise', function () {
audioEncodeProcessor = processor;
setCallback(savepath, done);
console.info("case start api test");
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
}
......@@ -200,7 +208,7 @@ describe('AudioEncoderSTTPromise', function () {
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]);
if (mySteps[0] == END) {
done();
......@@ -214,7 +222,7 @@ describe('AudioEncoderSTTPromise', function () {
audioEncodeProcessor.configure(mediaDescription).then(() => {
console.info(`case configure 1`);
readFile(AUDIOPATH);
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case PREPARE:
......@@ -222,7 +230,7 @@ describe('AudioEncoderSTTPromise', function () {
console.info(`case to prepare`);
audioEncodeProcessor.prepare().then(() => {
console.info(`case prepare 1`);
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case START:
......@@ -236,7 +244,7 @@ describe('AudioEncoderSTTPromise', function () {
}
audioEncodeProcessor.start().then(() => {
console.info(`case start 1`);
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case FLUSH:
......@@ -250,7 +258,7 @@ describe('AudioEncoderSTTPromise', function () {
workdoneAtEOS = true;
flushAtEOS = false;
}
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case STOP:
......@@ -258,7 +266,7 @@ describe('AudioEncoderSTTPromise', function () {
console.info(`case to stop`);
audioEncodeProcessor.stop().then(() => {
console.info(`case stop 1`);
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case RESET:
......@@ -266,13 +274,13 @@ describe('AudioEncoderSTTPromise', function () {
console.info(`case to reset`);
audioEncodeProcessor.reset().then(() => {
console.info(`case reset 1`);
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, failCallback).catch(failCatch);
break;
case HOLDON:
mySteps.shift();
setTimeout(() =>{
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
}, WAITTIME);
break;
case WAITFORALLOUTS:
......@@ -281,54 +289,49 @@ describe('AudioEncoderSTTPromise', function () {
break;
case CONFIGURE_ERROR:
mySteps.shift();
console.info(`case to configure`);
audioEncodeProcessor.configure(mediaDescription, (err) => {
expect(err != undefined).assertTrue();
console.info(`case to configure 2`);
audioEncodeProcessor.configure(mediaDescription).then(() => {
console.info(`case configure error 1`);
nextStep(mySteps, mediaDescription, done);
});
expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break;
case PREPARE_ERROR:
mySteps.shift();
console.info(`case to prepare`);
audioEncodeProcessor.prepare((err) => {
expect(err != undefined).assertTrue();
console.info(`case to prepare 2`);
audioEncodeProcessor.prepare().then(() => {
console.info(`case prepare error 1`);
nextStep(mySteps, mediaDescription, done);
});
expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break;
case START_ERROR:
mySteps.shift();
console.info(`case to start`);
audioEncodeProcessor.start((err) => {
expect(err != undefined).assertTrue();
console.info(`case to start 2`);
audioEncodeProcessor.start().then(() => {
console.info(`case start error 1`);
nextStep(mySteps, mediaDescription, done);
});
expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break;
case FLUSH_ERROR:
mySteps.shift();
console.info(`case to flush`);
audioEncodeProcessor.flush((err) => {
expect(err != undefined).assertTrue();
console.info(`case to flush 2`);
audioEncodeProcessor.flush().then(() => {
console.info(`case flush error 1`);
nextStep(mySteps, mediaDescription, done);
});
expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break;
case STOP_ERROR:
mySteps.shift();
console.info(`case to stop`);
audioEncodeProcessor.stop((err) => {
expect(err != undefined).assertTrue();
console.info(`case to stop 2`);
audioEncodeProcessor.stop().then(() => {
console.info(`case stop error 1`);
nextStep(mySteps, mediaDescription, done);
});
expect(expectError).assertTrue();
}, (err) => {failCallbackTrue(err, mySteps, done)}).catch(failCatch);
break;
case JUDGE_EOS:
mySteps.shift();
console.info(`case judge EOS state`);
expect(sawOutputEOS).assertTrue();
nextStep(mySteps, mediaDescription, done);
nextStep(mySteps, done);
break;
default:
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册