提交 212476b5 编写于 作者: X XUXIAOBO 提交者: Gitee

media audio apii test

Signed-off-by: NXUXIAOBO <xuxiaobo5@huawei.com>
上级 766a2360
......@@ -20,7 +20,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let audioPlayer = media.createAudioPlayer();
let loopValue = false;
let isTimeOut = false;
const Audio_SOURCE = "data/media/audio/Homey.mp3";
const AUDIO_SOURCE = 'file://data/media/audio/01.mp3';
const PLAY_TIME = 3000;
const END_STATE = 0;
const SRC_STATE = 1;
......@@ -34,7 +34,7 @@ describe('PlayerLocalTestAudioAPI', function () {
const ERROR_STATE = 9;
const FINISH_STATE = 10;
const LOOP_STATE = 11;
const DURATION_TIME = 89239;
const DURATION_TIME = 99432;
const SEEK_TIME = 5000;
const DELTA_TIME = 1000;
const SECOND_INDEX = 1;
......@@ -42,20 +42,20 @@ describe('PlayerLocalTestAudioAPI', function () {
const VOLUME_VALUE = 0.5;
beforeAll(function() {
console.info("beforeAll case");
console.info('beforeAll case');
})
beforeEach(function() {
isTimeOut = false;
console.info("beforeEach case");
console.info('beforeEach case');
})
afterEach(function() {
console.info("afterEach case");
console.info('afterEach case');
})
afterAll(function() {
console.info("afterAll case");
console.info('afterAll case');
})
function sleep(time) {
......@@ -63,7 +63,15 @@ describe('PlayerLocalTestAudioAPI', function () {
};
function initAudioPlayer() {
if (typeof (audioPlayer) != 'undefined') {
audioPlayer.release();
audioPlayer = undefined;
}
audioPlayer = media.createAudioPlayer();
if (typeof (audioPlayer) == 'undefined') {
console.info('case create player is faild');
expect().assertFail();
}
}
function nextStep(mySteps) {
......@@ -74,7 +82,7 @@ describe('PlayerLocalTestAudioAPI', function () {
switch (mySteps[0]) {
case SRC_STATE:
console.info(`case to prepare`);
audioPlayer.src = Audio_SOURCE;
audioPlayer.src = AUDIO_SOURCE;
break;
case PLAY_STATE:
console.info(`case to play`);
......@@ -104,6 +112,7 @@ describe('PlayerLocalTestAudioAPI', function () {
console.info(`case to release`);
mySteps.shift();
audioPlayer.release();
audioPlayer = undefined;
nextStep(mySteps);
break;
case LOOP_STATE:
......@@ -118,7 +127,7 @@ describe('PlayerLocalTestAudioAPI', function () {
}
}
function setCallback(mySteps) {
function setCallback(mySteps, done) {
console.info(`case setCallback`);
audioPlayer.on('dataLoad', () => {
mySteps.shift();
......@@ -172,7 +181,7 @@ describe('PlayerLocalTestAudioAPI', function () {
});
audioPlayer.on('timeUpdate', (seekDoneTime) => {
if (typeof (seekDoneTime) == "undefined") {
if (typeof (seekDoneTime) == 'undefined') {
console.info(`case seek filed,errcode is ${seekDoneTime}`);
return;
}
......@@ -189,7 +198,7 @@ describe('PlayerLocalTestAudioAPI', function () {
console.info('case loop is true');
sleep(PLAY_STATE);
}
if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == "paused")) {
if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == 'paused')) {
nextStep(mySteps);
}
});
......@@ -198,7 +207,7 @@ describe('PlayerLocalTestAudioAPI', function () {
console.info(`case setvolume called`);
mySteps.shift();
mySteps.shift();
if (audioPlayer.state == "playing") {
if (audioPlayer.state == 'playing') {
sleep(PLAY_TIME);
}
nextStep(mySteps);
......@@ -231,6 +240,14 @@ describe('PlayerLocalTestAudioAPI', function () {
nextStep(mySteps);
}
});
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
};
/* *
......@@ -244,15 +261,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0100', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -266,15 +276,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, PLAY_STATE, ERROR_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -288,15 +291,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0300', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, SEEK_TIME, PLAY_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -310,15 +306,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0400', 0, async function (done) {
let mySteps = new Array(SRC_STATE, RESET_STATE, PLAY_STATE, ERROR_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -332,15 +321,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0100', 0, async function (done) {
let mySteps = new Array(PAUSE_STATE, ERROR_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
setCallback(mySteps, done);
audioPlayer.pause();
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
})
/* *
......@@ -354,15 +336,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -376,15 +351,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0300', 0, async function (done) {
let mySteps = new Array(PLAY_STATE, STOP_STATE, PAUSE_STATE, ERROR_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -398,15 +366,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0400', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, PAUSE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -420,15 +381,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0100', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -442,15 +396,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -464,15 +411,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0300', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, STOP_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -486,15 +426,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0100', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -508,15 +441,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, SEEK_TIME, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0300
......@@ -529,15 +455,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0300', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -551,15 +470,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0100', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -573,15 +485,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RESET_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -595,15 +500,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0100', 0, async function (done) {
var mySteps = new Array(VOLUME_STATE, VOLUME_VALUE, ERROR_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
setCallback(mySteps, done);
audioPlayer.setVolume(VOLUME_VALUE);
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0200
......@@ -616,15 +514,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0200', 0, async function (done) {
var mySteps = new Array(SRC_STATE, PLAY_STATE, VOLUME_STATE, VOLUME_VALUE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0300
......@@ -637,15 +528,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0300', 0, async function (done) {
var mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, VOLUME_STATE, VOLUME_VALUE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -659,15 +543,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0100', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -681,15 +558,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -703,15 +573,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0300', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -725,15 +588,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -747,15 +603,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps);
audioPlayer.src = Audio_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE;
})
/* *
......@@ -786,9 +635,9 @@ describe('PlayerLocalTestAudioAPI', function () {
*/
it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0200', 0, async function (done) {
initAudioPlayer();
audioPlayer.src = Audio_SOURCE;
audioPlayer.src = AUDIO_SOURCE;
sleep(PLAY_TIME);
expect(audioPlayer.src).assertEqual(Audio_SOURCE);
expect(audioPlayer.src).assertEqual(AUDIO_SOURCE);
expect(audioPlayer.currentTime).assertEqual(0);
expect(audioPlayer.duration).assertEqual(DURATION_TIME);
expect(audioPlayer.state).assertEqual('paused');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册