提交 1c1062e2 编写于 作者: O openharmony_ci 提交者: Gitee

!619 media audio js test update

Merge pull request !619 from XUXIAOBO/xxb-wzy-master-patch-53150
...@@ -14,3 +14,4 @@ ...@@ -14,3 +14,4 @@
*/ */
require('./PlayerLocalTestAudioFUNC.test.js') require('./PlayerLocalTestAudioFUNC.test.js')
require('./PlayerLocalTestAudioFormat.test.js')
\ No newline at end of file
...@@ -19,9 +19,9 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -19,9 +19,9 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe('PlayerLocalTestAudioFUNC', function () { describe('PlayerLocalTestAudioFUNC', function () {
let audioPlayer = media.createAudioPlayer(); let audioPlayer = media.createAudioPlayer();
let isTimeOut = false; let isTimeOut = false;
const AUDIO_SOURCE = "file://data/media/audio/Homey.mp3"; const AUDIO_SOURCE = 'file://data/media/audio/01.mp3';
const PLAY_TIME = 3000; const PLAY_TIME = 3000;
const DURATION_TIME = 89239; const DURATION_TIME = 99432;
const SEEK_TIME = 5000; const SEEK_TIME = 5000;
const DELTA_TIME = 1000; const DELTA_TIME = 1000;
const END_STATE = 0; const END_STATE = 0;
...@@ -38,24 +38,24 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -38,24 +38,24 @@ describe('PlayerLocalTestAudioFUNC', function () {
const LOOP_STATE = 11; const LOOP_STATE = 11;
const SECOND_INDEX = 1; const SECOND_INDEX = 1;
const RAND_NUM = 5; const RAND_NUM = 5;
const TIME_OUT = 35000; const TIME_OUT = 40000;
const MAX_VOLUME = 1; const MAX_VOLUME = 1;
beforeAll(function() { beforeAll(function() {
console.info("beforeAll case"); console.info('beforeAll case');
}) })
beforeEach(function() { beforeEach(function() {
isTimeOut = false; isTimeOut = false;
console.info("beforeEach case"); console.info('beforeEach case');
}) })
afterEach(function() { afterEach(function() {
console.info("afterEach case"); console.info('afterEach case');
}) })
afterAll(function() { afterAll(function() {
console.info("afterAll case"); console.info('afterAll case');
}) })
function sleep(time) { function sleep(time) {
...@@ -63,7 +63,15 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -63,7 +63,15 @@ describe('PlayerLocalTestAudioFUNC', function () {
} }
function initAudioPlayer() { function initAudioPlayer() {
if (typeof (audioPlayer) != 'undefined') {
audioPlayer.release();
audioPlayer = undefined;
}
audioPlayer = media.createAudioPlayer(); audioPlayer = media.createAudioPlayer();
if (typeof (audioPlayer) == 'undefined') {
console.info('case create player is faild');
expect().assertFail();
}
} }
function nextStep(mySteps) { function nextStep(mySteps) {
...@@ -104,6 +112,7 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -104,6 +112,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
console.info(`case to release`); console.info(`case to release`);
mySteps.shift(); mySteps.shift();
audioPlayer.release(); audioPlayer.release();
audioPlayer = undefined;
break; break;
case LOOP_STATE: case LOOP_STATE:
audioPlayer.loop = mySteps[SECOND_INDEX]; audioPlayer.loop = mySteps[SECOND_INDEX];
...@@ -116,8 +125,7 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -116,8 +125,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
} }
} }
function setCallback(mySteps) { function setSrcCallback(mySteps) {
console.info(`case setCallback`);
audioPlayer.on('dataLoad', () => { audioPlayer.on('dataLoad', () => {
mySteps.shift(); mySteps.shift();
console.info(`case dataLoad called`); console.info(`case dataLoad called`);
...@@ -126,7 +134,9 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -126,7 +134,9 @@ describe('PlayerLocalTestAudioFUNC', function () {
expect(audioPlayer.state).assertEqual('paused'); expect(audioPlayer.state).assertEqual('paused');
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setPlayCallback(mySteps) {
audioPlayer.on('play', () => { audioPlayer.on('play', () => {
mySteps.shift(); mySteps.shift();
console.info(`case play called`); console.info(`case play called`);
...@@ -140,7 +150,9 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -140,7 +150,9 @@ describe('PlayerLocalTestAudioFUNC', function () {
expect(audioPlayer.state).assertEqual('playing'); expect(audioPlayer.state).assertEqual('playing');
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setPauseCallback(mySteps) {
audioPlayer.on('pause', () => { audioPlayer.on('pause', () => {
mySteps.shift(); mySteps.shift();
console.info(`case pause called`); console.info(`case pause called`);
...@@ -149,14 +161,18 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -149,14 +161,18 @@ describe('PlayerLocalTestAudioFUNC', function () {
expect(audioPlayer.state).assertEqual('paused'); expect(audioPlayer.state).assertEqual('paused');
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setResetCallback(mySteps) {
audioPlayer.on('reset', () => { audioPlayer.on('reset', () => {
mySteps.shift(); mySteps.shift();
console.info(`case reset called`); console.info(`case reset called`);
expect(audioPlayer.state).assertEqual('idle'); expect(audioPlayer.state).assertEqual('idle');
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setStopCallback(mySteps) {
audioPlayer.on('stop', () => { audioPlayer.on('stop', () => {
if (mySteps[0] == RESET_STATE) { if (mySteps[0] == RESET_STATE) {
console.info(`case reset stop called`); console.info(`case reset stop called`);
...@@ -169,9 +185,11 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -169,9 +185,11 @@ describe('PlayerLocalTestAudioFUNC', function () {
expect(audioPlayer.state).assertEqual('stopped'); expect(audioPlayer.state).assertEqual('stopped');
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setSeekCallback(mySteps) {
audioPlayer.on('timeUpdate', (seekDoneTime) => { audioPlayer.on('timeUpdate', (seekDoneTime) => {
if (typeof (seekDoneTime) == "undefined") { if (typeof (seekDoneTime) == 'undefined') {
console.info(`case seek filed,errcode is ${seekDoneTime}`); console.info(`case seek filed,errcode is ${seekDoneTime}`);
return; return;
} }
...@@ -188,21 +206,25 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -188,21 +206,25 @@ describe('PlayerLocalTestAudioFUNC', function () {
console.info('case loop is true'); console.info('case loop is true');
sleep(PLAY_STATE); sleep(PLAY_STATE);
} }
if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == "paused")) { if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == 'paused')) {
nextStep(mySteps); nextStep(mySteps);
} }
}); });
}
function setVolumeCallback(mySteps) {
audioPlayer.on('volumeChange', () => { audioPlayer.on('volumeChange', () => {
console.info(`case setvolume called`); console.info(`case setvolume called`);
mySteps.shift(); mySteps.shift();
mySteps.shift(); mySteps.shift();
if (audioPlayer.state == "playing") { if (audioPlayer.state == 'playing') {
sleep(PLAY_TIME); sleep(PLAY_TIME);
} }
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setFinishCallback(mySteps) {
audioPlayer.on('finish', () => { audioPlayer.on('finish', () => {
mySteps.shift(); mySteps.shift();
expect(audioPlayer.state).assertEqual('stopped'); expect(audioPlayer.state).assertEqual('stopped');
...@@ -210,7 +232,9 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -210,7 +232,9 @@ describe('PlayerLocalTestAudioFUNC', function () {
console.info(`case finish called`); console.info(`case finish called`);
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setErrorCallback(mySteps) {
audioPlayer.on('error', (err) => { audioPlayer.on('error', (err) => {
console.info(`case error called,errName is ${err.name}`); console.info(`case error called,errName is ${err.name}`);
console.info(`case error called,errCode is ${err.code}`); console.info(`case error called,errCode is ${err.code}`);
...@@ -225,6 +249,26 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -225,6 +249,26 @@ describe('PlayerLocalTestAudioFUNC', function () {
} }
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setCallback(mySteps, done) {
console.info(`case setCallback`);
setSrcCallback(mySteps);
setPlayCallback(mySteps);
setPauseCallback(mySteps);
setResetCallback(mySteps);
setStopCallback(mySteps);
setSeekCallback(mySteps);
setVolumeCallback(mySteps);
setFinishCallback(mySteps);
setErrorCallback(mySteps);
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect().assertFail();
}
done();
}, TIME_OUT);
}; };
/* * /* *
...@@ -238,15 +282,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -238,15 +282,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0100', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -260,15 +297,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -260,15 +297,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RESET_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -282,15 +312,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -282,15 +312,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0300', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -304,15 +327,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -304,15 +327,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0500', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0500', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -326,15 +342,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -326,15 +342,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0600', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0600', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, PAUSE_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, PAUSE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -348,15 +357,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -348,15 +357,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0700', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0700', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -370,15 +372,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -370,15 +372,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0800', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0800', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, STOP_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -393,15 +388,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -393,15 +388,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RESET_STATE, SRC_STATE, PLAY_STATE, let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RESET_STATE, SRC_STATE, PLAY_STATE,
PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE); PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -416,15 +404,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -416,15 +404,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, RESET_STATE, SRC_STATE, PLAY_STATE, let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, RESET_STATE, SRC_STATE, PLAY_STATE,
PAUSE_STATE, RESET_STATE, END_STATE); PAUSE_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -439,15 +420,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -439,15 +420,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RESET_STATE, let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RESET_STATE,
SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE); SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -461,15 +435,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -461,15 +435,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -483,15 +450,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -483,15 +450,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1300', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, PAUSE_STATE, ERROR_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, PAUSE_STATE, ERROR_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -505,15 +465,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -505,15 +465,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1400', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1400', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, PAUSE_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, PAUSE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -528,15 +481,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -528,15 +481,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME, let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME,
PLAY_STATE, FINISH_STATE, END_STATE); PLAY_STATE, FINISH_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -550,15 +496,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -550,15 +496,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1600', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1600', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, PAUSE_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, PAUSE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -572,15 +511,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -572,15 +511,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1700', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1700', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, RESET_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -594,15 +526,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -594,15 +526,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1800', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1800', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, STOP_STATE, RESET_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, STOP_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -616,15 +541,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -616,15 +541,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1900', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1900', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, 0, ERROR_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, 0, ERROR_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -638,15 +556,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -638,15 +556,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2000', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2000', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, 0, RESET_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, 0, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -661,15 +572,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -661,15 +572,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME / RAND_NUM, let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME / RAND_NUM,
STOP_STATE, END_STATE); STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -683,15 +587,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -683,15 +587,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -705,15 +602,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -705,15 +602,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2300', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, STOP_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -728,15 +618,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -728,15 +618,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, 0, ERROR_STATE, let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, 0, ERROR_STATE,
RESET_STATE, SRC_STATE, PLAY_STATE, END_STATE); RESET_STATE, SRC_STATE, PLAY_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -750,15 +633,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -750,15 +633,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2500', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2500', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -773,15 +649,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -773,15 +649,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, SEEK_TIME, ERROR_STATE, let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, SEEK_TIME, ERROR_STATE,
PAUSE_STATE, ERROR_STATE, RESET_STATE, END_STATE); PAUSE_STATE, ERROR_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -796,15 +665,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -796,15 +665,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, SEEK_TIME, ERROR_STATE, let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, SEEK_TIME, ERROR_STATE,
RESET_STATE, SRC_STATE, PLAY_STATE, END_STATE); RESET_STATE, SRC_STATE, PLAY_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -818,15 +680,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -818,15 +680,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2800', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2800', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME, FINISH_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME, FINISH_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -841,15 +696,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -841,15 +696,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME, let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME,
FINISH_STATE, END_STATE); FINISH_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -863,15 +711,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -863,15 +711,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3000', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3000', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME / RAND_NUM, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME / RAND_NUM, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -885,15 +726,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -885,15 +726,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, 0, PLAY_STATE, RESET_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, 0, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -908,15 +742,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -908,15 +742,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME, PLAY_STATE, let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME, PLAY_STATE,
FINISH_STATE, RESET_STATE, END_STATE); FINISH_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -931,15 +758,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -931,15 +758,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME, PLAY_STATE, let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME, PLAY_STATE,
FINISH_STATE, RESET_STATE, END_STATE); FINISH_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -954,15 +774,8 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -954,15 +774,8 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME, let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME,
FINISH_STATE, PLAY_STATE, RESET_STATE, END_STATE); FINISH_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -999,7 +812,7 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -999,7 +812,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
testAudioPlayer.seek(DURATION_TIME); testAudioPlayer.seek(DURATION_TIME);
}); });
testAudioPlayer.on('timeUpdate', (seekDoneTime) => { testAudioPlayer.on('timeUpdate', (seekDoneTime) => {
if (typeof (seekDoneTime) == "undefined") { if (typeof (seekDoneTime) == 'undefined') {
console.info(`case seek filed,errcode is ${seekDoneTime}`); console.info(`case seek filed,errcode is ${seekDoneTime}`);
return; return;
} }
...@@ -1043,14 +856,7 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -1043,14 +856,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
let mySteps = new Array(SRC_STATE, PLAY_STATE, VOLUME_STATE, 0, let mySteps = new Array(SRC_STATE, PLAY_STATE, VOLUME_STATE, 0,
VOLUME_STATE, MAX_VOLUME, RESET_STATE, END_STATE); VOLUME_STATE, MAX_VOLUME, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = AUDIO_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
}) })
/*
* 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('PlayerLocalTestAudioFormat', function () {
const BASIC_PATH = 'file:///data/media/audio/';
const MAX_VOLUME = 1;
const PLAY_TIME = 3000;
const SEEK_TIME = 10000; // 10s
let isToSeek = false;
let isToDuration = false;
beforeAll(function() {
console.info('beforeAll case');
})
beforeEach(function() {
isToSeek = false;
isToDuration = false;
console.info('beforeEach case');
})
afterEach(function() {
console.info('afterEach case');
})
afterAll(function() {
console.info('afterAll case');
})
function sleep(time) {
for(let t = Date.now(); Date.now() - t <= time;);
}
function setSrcCallback(audioPlayer) {
audioPlayer.on('dataLoad', () => {
console.info('case set source success');
expect(audioPlayer.state).assertEqual('paused');
expect(audioPlayer.currentTime).assertEqual(0);
audioPlayer.play();
});
}
function setPlayCallback(audioPlayer) {
audioPlayer.on('play', () => {
console.info('case start to play');
expect(audioPlayer.state).assertEqual('playing');
sleep(PLAY_TIME);
if (!isToSeek) {
audioPlayer.pause();
} else {
audioPlayer.seek(SEEK_TIME);
}
});
}
function setPauseCallback(audioPlayer) {
audioPlayer.on('pause', () => {
console.info('case now is paused');
expect(audioPlayer.state).assertEqual('paused');
audioPlayer.setVolume(MAX_VOLUME);
});
}
function setResetCallback(audioPlayer, done) {
audioPlayer.on('reset', () => {
console.info('case reset success');
expect(audioPlayer.state).assertEqual('idle');
audioPlayer.release();
audioPlayer = undefined;
done();
});
}
function setStopCallback(audioPlayer) {
audioPlayer.on('stop', () => {
console.info('case stop success');
expect(audioPlayer.state).assertEqual('stopped');
audioPlayer.reset();
});
}
function setSeekCallback(audioPlayer, done) {
audioPlayer.on('timeUpdate', (seekDoneTime) => {
if (typeof (seekDoneTime) == "undefined") {
console.info(`case seek filed,errcode is ${seekDoneTime}`);
audioPlayer.release();
expect().assertFail();
done();
return;
}
console.info('case seek success, and seek time is ' + seekDoneTime);
if (!isToDuration) {
expect(SEEK_TIME).assertEqual(seekDoneTime);
isToDuration = true;
sleep(PLAY_TIME);
audioPlayer.seek(audioPlayer.duration);
} else {
expect(audioPlayer.duration).assertEqual(seekDoneTime);
}
});
}
function setVolumeCallback(audioPlayer) {
audioPlayer.on('volumeChange', () => {
console.info('case set volume value to ' + MAX_VOLUME);
audioPlayer.play();
isToSeek = true;
});
}
function setFinishCallback(audioPlayer) {
audioPlayer.on('finish', () => {
console.info('case play end');
expect(audioPlayer.state).assertEqual('stopped');
audioPlayer.stop();
});
}
function setErrorCallback(audioPlayer, done) {
audioPlayer.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}`);
audioPlayer.release();
expect().assertFail();
done();
});
}
function playSource(audioSource, done) {
let audioPlayer = media.createAudioPlayer();
if (typeof (audioPlayer) == 'undefined') {
console.info('case create player is faild');
expect().assertFail();
done();
return;
}
setSrcCallback(audioPlayer);
setPlayCallback(audioPlayer);
setPauseCallback(audioPlayer);
setResetCallback(audioPlayer, done);
setStopCallback(audioPlayer);
setSeekCallback(audioPlayer, done);
setVolumeCallback(audioPlayer);
setFinishCallback(audioPlayer);
setErrorCallback(audioPlayer, done);
audioPlayer.src = audioSource;
}
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP3_01_0100
* @tc.name : 001.Playing mp3 streams
* @tc.desc : Format : MP3
Codec : MP3
Samplerate : 48000
Bitrate : 32
Channel : 1
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP3_01_0100', 0, async function (done) {
playSource(BASIC_PATH + '01.mp3', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP3_01_0200
* @tc.name : 002.Playing mp3 streams
* @tc.desc : Format : MP3
Codec : MP3
Samplerate : 48000
Bitrate : 16/32
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP3_01_0200', 0, async function (done) {
playSource(BASIC_PATH + '02.mp3', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP3_01_0300
* @tc.name : 003.Playing mp3 streams
* @tc.desc : Format : MP3
Codec : MP3
Samplerate : 48000
Bitrate : 32
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP3_01_0300', 0, async function (done) {
playSource(BASIC_PATH + '03.mp3', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP3_01_0400
* @tc.name : 004.Playing mp3 streams
* @tc.desc : Format : MP3
Codec : MP3
Samplerate : 48000
Bitrate : 64
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP3_01_0400', 0, async function (done) {
playSource(BASIC_PATH + '04.mp3', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0100
* @tc.name : 001.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : AAC LC
Samplerate : 48000
Bitrate : 32
Channel : 1
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0100', 0, async function (done) {
playSource(BASIC_PATH + '47.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0200
* @tc.name : 002.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : AAC LC
Samplerate : 48000
Bitrate : 16
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0200', 0, async function (done) {
playSource(BASIC_PATH + '48.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0300
* @tc.name : 003.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : AAC LC
Samplerate : 48000
Bitrate : 64
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0300', 0, async function (done) {
playSource(BASIC_PATH + '49.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0400
* @tc.name : 004.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : AAC LC
Samplerate : 48000
Bitrate : 32
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0400', 0, async function (done) {
playSource(BASIC_PATH + '50.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0500
* @tc.name : 005.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : AAC LC
Samplerate : 96000
Bitrate : 32
Channel : 1
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0500', 0, async function (done) {
playSource(BASIC_PATH + '51.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0600
* @tc.name : 006.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : AAC LC
Samplerate : 96000
Bitrate : 64
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0600', 0, async function (done) {
playSource(BASIC_PATH + '54.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0700
* @tc.name : 007.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : MP3
Samplerate : 48000
Bitrate : 32
Channel : 1
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0700', 0, async function (done) {
playSource(BASIC_PATH + '64.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0800
* @tc.name : 008.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : MP3
Samplerate : 48000
Bitrate : 16
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0800', 0, async function (done) {
playSource(BASIC_PATH + '65.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0900
* @tc.name : 009.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : MP3
Samplerate : 48000
Bitrate : 64
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_0900', 0, async function (done) {
playSource(BASIC_PATH + '66.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1000
* @tc.name : 010.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : MP3
Samplerate : 48000
Bitrate : 32
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1000', 0, async function (done) {
playSource(BASIC_PATH + '67.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1100
* @tc.name : 011.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : Vorbis
Samplerate : 48000
Bitrate : 16
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1100', 0, async function (done) {
playSource(BASIC_PATH + '92.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1200
* @tc.name : 012.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : Vorbis
Samplerate : 48000
Bitrate : 64
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1200', 0, async function (done) {
playSource(BASIC_PATH + '93.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1300
* @tc.name : 013.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : Vorbis
Samplerate : 48000
Bitrate : 32
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1300', 0, async function (done) {
playSource(BASIC_PATH + '94.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1400
* @tc.name : 014.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : Vorbis
Samplerate : 96000
Bitrate : 16
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1400', 0, async function (done) {
playSource(BASIC_PATH + '96.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1500
* @tc.name : 015.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : Vorbis
Samplerate : 96000
Bitrate : 32
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1500', 0, async function (done) {
playSource(BASIC_PATH + '97.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1600
* @tc.name : 016.Playing mp4 streams
* @tc.desc : Format : MP4
Codec : Vorbis
Samplerate : 96000
Bitrate : 64
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_MP4_01_1600', 0, async function (done) {
playSource(BASIC_PATH + '98.mp4', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0100
* @tc.name : 001.Playing m4a streams
* @tc.desc : Format : M4A
Codec : AAC LC
Samplerate : 48000
Bitrate : 32
Channel : 1
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0100', 0, async function (done) {
playSource(BASIC_PATH + '55.m4a', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0200
* @tc.name : 002.Playing m4a streams
* @tc.desc : Format : M4A
Codec : AAC LC
Samplerate : 48000
Bitrate : 16
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0200', 0, async function (done) {
playSource(BASIC_PATH + '56.m4a', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0300
* @tc.name : 003.Playing m4a streams
* @tc.desc : Format : M4A
Codec : AAC LC
Samplerate : 48000
Bitrate : 64
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0300', 0, async function (done) {
playSource(BASIC_PATH + '57.m4a', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0400
* @tc.name : 004.Playing m4a streams
* @tc.desc : Format : M4A
Codec : AAC LC
Samplerate : 48000
Bitrate : 32
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0400', 0, async function (done) {
playSource(BASIC_PATH + '58.m4a', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0500
* @tc.name : 005.Playing m4a streams
* @tc.desc : Format : M4A
Codec : AAC LC
Samplerate : 96000
Bitrate : 32
Channel : 1
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0500', 0, async function (done) {
playSource(BASIC_PATH + '59.m4a', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0600
* @tc.name : 006.Playing m4a streams
* @tc.desc : Format : M4A
Codec : AAC LC
Samplerate : 96000
Bitrate : 32
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0600', 0, async function (done) {
playSource(BASIC_PATH + '61.m4a', done);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0700
* @tc.name : 007.Playing m4a streams
* @tc.desc : Format : M4A
Codec : AAC LC
Samplerate : 96000
Bitrate : 64
Channel : 2
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_Format_M4A_01_0700', 0, async function (done) {
playSource(BASIC_PATH + '62.m4a', done);
})
})
...@@ -20,7 +20,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -20,7 +20,7 @@ describe('PlayerLocalTestAudioAPI', function () {
let audioPlayer = media.createAudioPlayer(); let audioPlayer = media.createAudioPlayer();
let loopValue = false; let loopValue = false;
let isTimeOut = 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 PLAY_TIME = 3000;
const END_STATE = 0; const END_STATE = 0;
const SRC_STATE = 1; const SRC_STATE = 1;
...@@ -34,7 +34,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -34,7 +34,7 @@ describe('PlayerLocalTestAudioAPI', function () {
const ERROR_STATE = 9; const ERROR_STATE = 9;
const FINISH_STATE = 10; const FINISH_STATE = 10;
const LOOP_STATE = 11; const LOOP_STATE = 11;
const DURATION_TIME = 89239; const DURATION_TIME = 99432;
const SEEK_TIME = 5000; const SEEK_TIME = 5000;
const DELTA_TIME = 1000; const DELTA_TIME = 1000;
const SECOND_INDEX = 1; const SECOND_INDEX = 1;
...@@ -42,20 +42,20 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -42,20 +42,20 @@ describe('PlayerLocalTestAudioAPI', function () {
const VOLUME_VALUE = 0.5; const VOLUME_VALUE = 0.5;
beforeAll(function() { beforeAll(function() {
console.info("beforeAll case"); console.info('beforeAll case');
}) })
beforeEach(function() { beforeEach(function() {
isTimeOut = false; isTimeOut = false;
console.info("beforeEach case"); console.info('beforeEach case');
}) })
afterEach(function() { afterEach(function() {
console.info("afterEach case"); console.info('afterEach case');
}) })
afterAll(function() { afterAll(function() {
console.info("afterAll case"); console.info('afterAll case');
}) })
function sleep(time) { function sleep(time) {
...@@ -63,7 +63,15 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -63,7 +63,15 @@ describe('PlayerLocalTestAudioAPI', function () {
}; };
function initAudioPlayer() { function initAudioPlayer() {
if (typeof (audioPlayer) != 'undefined') {
audioPlayer.release();
audioPlayer = undefined;
}
audioPlayer = media.createAudioPlayer(); audioPlayer = media.createAudioPlayer();
if (typeof (audioPlayer) == 'undefined') {
console.info('case create player is faild');
expect().assertFail();
}
} }
function nextStep(mySteps) { function nextStep(mySteps) {
...@@ -74,7 +82,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -74,7 +82,7 @@ describe('PlayerLocalTestAudioAPI', function () {
switch (mySteps[0]) { switch (mySteps[0]) {
case SRC_STATE: case SRC_STATE:
console.info(`case to prepare`); console.info(`case to prepare`);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
break; break;
case PLAY_STATE: case PLAY_STATE:
console.info(`case to play`); console.info(`case to play`);
...@@ -104,6 +112,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -104,6 +112,7 @@ describe('PlayerLocalTestAudioAPI', function () {
console.info(`case to release`); console.info(`case to release`);
mySteps.shift(); mySteps.shift();
audioPlayer.release(); audioPlayer.release();
audioPlayer = undefined;
nextStep(mySteps); nextStep(mySteps);
break; break;
case LOOP_STATE: case LOOP_STATE:
...@@ -118,8 +127,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -118,8 +127,7 @@ describe('PlayerLocalTestAudioAPI', function () {
} }
} }
function setCallback(mySteps) { function setSrcCallback(mySteps) {
console.info(`case setCallback`);
audioPlayer.on('dataLoad', () => { audioPlayer.on('dataLoad', () => {
mySteps.shift(); mySteps.shift();
console.info(`case dataLoad called`); console.info(`case dataLoad called`);
...@@ -128,7 +136,9 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -128,7 +136,9 @@ describe('PlayerLocalTestAudioAPI', function () {
expect(audioPlayer.state).assertEqual('paused'); expect(audioPlayer.state).assertEqual('paused');
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setPlayCallback(mySteps) {
audioPlayer.on('play', () => { audioPlayer.on('play', () => {
mySteps.shift(); mySteps.shift();
console.info(`case play called`); console.info(`case play called`);
...@@ -141,7 +151,9 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -141,7 +151,9 @@ describe('PlayerLocalTestAudioAPI', function () {
expect(audioPlayer.state).assertEqual('playing'); expect(audioPlayer.state).assertEqual('playing');
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setPauseCallback(mySteps) {
audioPlayer.on('pause', () => { audioPlayer.on('pause', () => {
mySteps.shift(); mySteps.shift();
console.info(`case pause called`); console.info(`case pause called`);
...@@ -150,14 +162,18 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -150,14 +162,18 @@ describe('PlayerLocalTestAudioAPI', function () {
expect(audioPlayer.state).assertEqual('paused'); expect(audioPlayer.state).assertEqual('paused');
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setResetCallback(mySteps) {
audioPlayer.on('reset', () => { audioPlayer.on('reset', () => {
mySteps.shift(); mySteps.shift();
console.info(`case reset called`); console.info(`case reset called`);
expect(audioPlayer.state).assertEqual('idle'); expect(audioPlayer.state).assertEqual('idle');
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setStopCallback(mySteps) {
audioPlayer.on('stop', () => { audioPlayer.on('stop', () => {
if (mySteps[0] == RESET_STATE) { if (mySteps[0] == RESET_STATE) {
console.info(`case reset stop called`); console.info(`case reset stop called`);
...@@ -170,9 +186,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -170,9 +186,11 @@ describe('PlayerLocalTestAudioAPI', function () {
expect(audioPlayer.state).assertEqual('stopped'); expect(audioPlayer.state).assertEqual('stopped');
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setSeekCallback(mySteps) {
audioPlayer.on('timeUpdate', (seekDoneTime) => { audioPlayer.on('timeUpdate', (seekDoneTime) => {
if (typeof (seekDoneTime) == "undefined") { if (typeof (seekDoneTime) == 'undefined') {
console.info(`case seek filed,errcode is ${seekDoneTime}`); console.info(`case seek filed,errcode is ${seekDoneTime}`);
return; return;
} }
...@@ -189,21 +207,25 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -189,21 +207,25 @@ describe('PlayerLocalTestAudioAPI', function () {
console.info('case loop is true'); console.info('case loop is true');
sleep(PLAY_STATE); sleep(PLAY_STATE);
} }
if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == "paused")) { if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == 'paused')) {
nextStep(mySteps); nextStep(mySteps);
} }
}); });
}
function setVolumeCallback(mySteps) {
audioPlayer.on('volumeChange', () => { audioPlayer.on('volumeChange', () => {
console.info(`case setvolume called`); console.info(`case setvolume called`);
mySteps.shift(); mySteps.shift();
mySteps.shift(); mySteps.shift();
if (audioPlayer.state == "playing") { if (audioPlayer.state == 'playing') {
sleep(PLAY_TIME); sleep(PLAY_TIME);
} }
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setFinishCallback(mySteps) {
audioPlayer.on('finish', () => { audioPlayer.on('finish', () => {
mySteps.shift(); mySteps.shift();
expect(audioPlayer.state).assertEqual('stopped'); expect(audioPlayer.state).assertEqual('stopped');
...@@ -211,7 +233,9 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -211,7 +233,9 @@ describe('PlayerLocalTestAudioAPI', function () {
console.info(`case finish called`); console.info(`case finish called`);
nextStep(mySteps); nextStep(mySteps);
}); });
}
function setErrorCallback(mySteps) {
audioPlayer.on('error', (err) => { audioPlayer.on('error', (err) => {
console.info(`case error called,errName is ${err.name}`); console.info(`case error called,errName is ${err.name}`);
console.info(`case error called,errCode is ${err.code}`); console.info(`case error called,errCode is ${err.code}`);
...@@ -231,6 +255,26 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -231,6 +255,26 @@ describe('PlayerLocalTestAudioAPI', function () {
nextStep(mySteps); nextStep(mySteps);
} }
}); });
}
function setCallback(mySteps, done) {
console.info(`case setCallback`);
setSrcCallback(mySteps);
setPlayCallback(mySteps);
setPauseCallback(mySteps);
setResetCallback(mySteps);
setStopCallback(mySteps);
setSeekCallback(mySteps);
setVolumeCallback(mySteps);
setFinishCallback(mySteps);
setErrorCallback(mySteps);
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}; };
/* * /* *
...@@ -244,15 +288,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -244,15 +288,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0100', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -266,15 +303,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -266,15 +303,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0200', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, PLAY_STATE, ERROR_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -288,15 +318,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -288,15 +318,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0300', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, SEEK_TIME, PLAY_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -310,15 +333,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -310,15 +333,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0400', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, RESET_STATE, PLAY_STATE, ERROR_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -332,15 +348,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -332,15 +348,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0100', 0, async function (done) {
let mySteps = new Array(PAUSE_STATE, ERROR_STATE, END_STATE); let mySteps = new Array(PAUSE_STATE, ERROR_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.pause(); audioPlayer.pause();
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -354,15 +363,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -354,15 +363,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -376,15 +378,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -376,15 +378,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0300', 0, async function (done) { 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); let mySteps = new Array(PLAY_STATE, STOP_STATE, PAUSE_STATE, ERROR_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -398,15 +393,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -398,15 +393,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0400', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, PAUSE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -420,15 +408,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -420,15 +408,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0100', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -442,15 +423,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -442,15 +423,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0200', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -464,15 +438,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -464,15 +438,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0300', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -486,15 +453,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -486,15 +453,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0100', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -508,15 +468,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -508,15 +468,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0200', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, SEEK_TIME, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
* @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0300 * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0300
...@@ -529,15 +482,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -529,15 +482,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0300', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -551,15 +497,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -551,15 +497,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0100', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -573,15 +512,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -573,15 +512,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0200', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -595,15 +527,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -595,15 +527,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0100', 0, async function (done) {
var mySteps = new Array(VOLUME_STATE, VOLUME_VALUE, ERROR_STATE, END_STATE); var mySteps = new Array(VOLUME_STATE, VOLUME_VALUE, ERROR_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.setVolume(VOLUME_VALUE); 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 * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0200
...@@ -616,15 +541,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -616,15 +541,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0200', 0, async function (done) { 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); var mySteps = new Array(SRC_STATE, PLAY_STATE, VOLUME_STATE, VOLUME_VALUE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
* @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0300 * @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0300
...@@ -637,15 +555,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -637,15 +555,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0300', 0, async function (done) { 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); var mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, VOLUME_STATE, VOLUME_VALUE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -659,15 +570,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -659,15 +570,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0100', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, RELEASE_STATE, END_STATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -681,15 +585,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -681,15 +585,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0200', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -703,15 +600,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -703,15 +600,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0300', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -725,15 +615,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -725,15 +615,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, SEEK_TIME, RELEASE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -747,15 +630,8 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -747,15 +630,8 @@ describe('PlayerLocalTestAudioAPI', function () {
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400', 0, async function (done) { 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); let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps); setCallback(mySteps, done);
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeOut) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
...@@ -786,9 +662,9 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -786,9 +662,9 @@ describe('PlayerLocalTestAudioAPI', function () {
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0200', 0, async function (done) {
initAudioPlayer(); initAudioPlayer();
audioPlayer.src = Audio_SOURCE; audioPlayer.src = AUDIO_SOURCE;
sleep(PLAY_TIME); sleep(PLAY_TIME);
expect(audioPlayer.src).assertEqual(Audio_SOURCE); expect(audioPlayer.src).assertEqual(AUDIO_SOURCE);
expect(audioPlayer.currentTime).assertEqual(0); expect(audioPlayer.currentTime).assertEqual(0);
expect(audioPlayer.duration).assertEqual(DURATION_TIME); expect(audioPlayer.duration).assertEqual(DURATION_TIME);
expect(audioPlayer.state).assertEqual('paused'); expect(audioPlayer.state).assertEqual('paused');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册