提交 8103f9e5 编写于 作者: B bird_j 提交者: Gitee

PlayerLocalTestAudioFUNC 代码整改 Signed-off-by: bird_j <jianghongpeng@huawei.com>

上级 9d2792ed
...@@ -16,585 +16,1041 @@ ...@@ -16,585 +16,1041 @@
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('PlayerLocalTestAudioAPI', function () { describe('PlayerLocalTestAudioFUNC', function () {
var audioPlayer = media.createAudioPlayer(); let audioPlayer = media.createAudioPlayer();
var audioSource = "data/media/audio/Homey.mp3"; let isTimeOut = false;
var PLAY_TIME = 3000; const AUDIO_SOURCE = "file://data/media/audio/Homey.mp3";
var ENDSTATE = 0; const PLAY_TIME = 3000;
var SRCSTATE = 1; const DURATION_TIME = 89239;
var PLAYSTATE = 2; const SEEK_TIME = 5000;
var PAUSESTATE = 3; const DELTA_TIME = 1000;
var STOPSTATE = 4; const END_STATE = 0;
var RESETSTATE = 5; const SRC_STATE = 1;
var SEEKSTATE = 6; const PLAY_STATE = 2;
var VOLUMESTATE = 7; const PAUSE_STATE = 3;
var RELEASESTATE = 8; const STOP_STATE = 4;
var ERRORSTATE = 9; const RESET_STATE = 5;
var FINISHSTATE = 10; const SEEK_STATE = 6;
var LOOPSTATE = 11; const VOLUME_STATE = 7;
var DURATION_TIME = 89239; const RELEASE_STATE = 8;
var SEEK_TIME = 5000; const ERROR_STATE = 9;
var DELTA_TIME = 1000; const FINISH_STATE = 10;
var PAUSEERROR = 'pauseError'; const LOOP_STATE = 11;
var PLAYERROR = 'playError'; const SECOND_INDEX = 1;
var loopValue = false; const RAND_NUM = 5;
beforeAll(function () { const TIME_OUT = 35000;
console.log("beforeAll case"); const MAX_VOLUME = 1;
})
beforeAll(function() {
beforeEach(function () { console.info("beforeAll case");
console.log("beforeEach case"); })
})
beforeEach(function() {
afterEach(function () { isTimeOut = false;
console.log("afterEach case"); console.info("beforeEach case");
audioPlayer.release(); })
})
afterEach(function() {
afterAll(function () { console.info("afterEach case");
console.log("afterAll case"); })
})
afterAll(function() {
var sleep = function(time) { console.info("afterAll case");
for(var t = Date.now();Date.now() - t <= time;); })
};
function sleep(time) {
for(let t = Date.now(); Date.now() - t <= time;);
}
var initAudioPlayer = function() { function initAudioPlayer() {
audioPlayer = media.createAudioPlayer(); audioPlayer = media.createAudioPlayer();
} }
var nextStep = function(mySteps, done) { function nextStep(mySteps) {
if (mySteps[0] == ENDSTATE) { if (mySteps[0] == END_STATE) {
if (mySteps[1] == false || mySteps[1] == true) { isTimeOut = true;
expect(audioPlayer.loop).assertEqual(mySteps[1]);
}
done();
return; return;
} }
switch (mySteps[0]) { switch (mySteps[0]) {
case SRCSTATE: case SRC_STATE:
console.log(`case to prepare`); console.info(`case to prepare`);
audioPlayer.src = audioSource; audioPlayer.src = AUDIO_SOURCE;
break; break;
case PLAYSTATE: case PLAY_STATE:
console.log(`case to play`); console.info(`case to play`);
audioPlayer.play(); audioPlayer.play();
break; break;
case PAUSESTATE: case PAUSE_STATE:
console.log(`case to pause`); console.info(`case to pause`);
audioPlayer.pause(); audioPlayer.pause();
break; break;
case STOPSTATE: case STOP_STATE:
console.log(`case to stop`); console.info(`case to stop`);
audioPlayer.stop(); audioPlayer.stop();
break; break;
case RESETSTATE: case RESET_STATE:
console.log(`case to reset`); console.info(`case to reset`);
audioPlayer.reset(); audioPlayer.reset();
break; break;
case SEEKSTATE: case SEEK_STATE:
console.log(`case seek to time is ${mySteps[1]}`); console.info(`case seek to time is ${mySteps[SECOND_INDEX]}`);
audioPlayer.seek(mySteps[1]); audioPlayer.seek(mySteps[SECOND_INDEX]);
break; break;
case VOLUMESTATE: case VOLUME_STATE:
console.log(`case to setVolume`); console.info(`case to setVolume`);
audioPlayer.setVolume(mySteps[1]); audioPlayer.setVolume(mySteps[SECOND_INDEX]);
break; break;
case RELEASESTATE: case RELEASE_STATE:
console.log(`case to release`); console.info(`case to release`);
mySteps.shift(); mySteps.shift();
audioPlayer.release(); audioPlayer.release();
nextStep(mySteps, done);
break; break;
case LOOPSTATE: case LOOP_STATE:
loopValue = mySteps[1]; audioPlayer.loop = mySteps[SECOND_INDEX];
mySteps.shift(); mySteps.shift();
mySteps.shift(); mySteps.shift();
audioPlayer.loop = loopValue; nextStep(mySteps);
nextStep(mySteps, done);
break; break;
default: default:
break; break;
} }
} }
var setCallback = function(mySteps, done) {
console.log(`case setCallback`); function setCallback(mySteps) {
console.info(`case setCallback`);
audioPlayer.on('dataLoad', () => { audioPlayer.on('dataLoad', () => {
mySteps.shift(); mySteps.shift();
console.log(`case dataLoad called`); console.info(`case dataLoad called`);
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');
nextStep(mySteps, done); nextStep(mySteps);
}); });
audioPlayer.on('play', () => { audioPlayer.on('play', () => {
mySteps.shift(); mySteps.shift();
console.log(`case play called`); console.info(`case play called`);
console.log(`case play currentTime is ${audioPlayer.currentTime}`); sleep(PLAY_TIME);
console.info(`case play currentTime is ${audioPlayer.currentTime}`);
expect(audioPlayer.duration).assertEqual(DURATION_TIME); expect(audioPlayer.duration).assertEqual(DURATION_TIME);
if (mySteps[0] == FINISHSTATE) { if (mySteps[0] == FINISH_STATE) {
console.log(`case wait for finish`); console.info(`case wait for finish`);
return; return;
} }
expect(audioPlayer.state).assertEqual('playing'); expect(audioPlayer.state).assertEqual('playing');
nextStep(mySteps, done); nextStep(mySteps);
}); });
audioPlayer.on('pause', () => { audioPlayer.on('pause', () => {
mySteps.shift(); mySteps.shift();
console.log(`case pause called`); console.info(`case pause called`);
console.log(`case pause currentTime is ${audioPlayer.currentTime}`); console.info(`case pause currentTime is ${audioPlayer.currentTime}`);
expect(audioPlayer.duration).assertEqual(DURATION_TIME); expect(audioPlayer.duration).assertEqual(DURATION_TIME);
expect(audioPlayer.state).assertEqual('paused'); expect(audioPlayer.state).assertEqual('paused');
nextStep(mySteps, done); nextStep(mySteps);
}); });
audioPlayer.on('reset', () => { audioPlayer.on('reset', () => {
mySteps.shift(); mySteps.shift();
console.log(`case reset called`); console.info(`case reset called`);
expect(audioPlayer.state).assertEqual('idle'); expect(audioPlayer.state).assertEqual('idle');
nextStep(mySteps, done); nextStep(mySteps);
}); });
audioPlayer.on('stop', () => { audioPlayer.on('stop', () => {
if (mySteps[0] == RESET_STATE) {
console.info(`case reset stop called`);
return;
}
mySteps.shift(); mySteps.shift();
console.log(`case stop called`); console.info(`case stop called`);
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('stopped'); expect(audioPlayer.state).assertEqual('stopped');
nextStep(mySteps, done); nextStep(mySteps);
}); });
audioPlayer.on('timeUpdate', (seekDoneTime) => { audioPlayer.on('timeUpdate', (seekDoneTime) => {
if (typeof (seekDoneTime) == "undefined") { if (typeof (seekDoneTime) == "undefined") {
console.log(`case seek filed,errcode is ${seekDoneTime}`); console.info(`case seek filed,errcode is ${seekDoneTime}`);
return;
}
if (mySteps[0] != SEEK_STATE) {
return; return;
} }
mySteps.shift(); mySteps.shift();
mySteps.shift(); mySteps.shift();
console.log(`case seekDoneTime is ${seekDoneTime}`); console.info(`case seekDoneTime is ${seekDoneTime}`);
console.log(`case seek called`); console.info(`case seek called`);
expect(audioPlayer.currentTime + DELTA_TIME).assertClose(seekDoneTime + DELTA_TIME, DELTA_TIME); expect(audioPlayer.currentTime + DELTA_TIME).assertClose(seekDoneTime + DELTA_TIME, DELTA_TIME);
console.log(`case loop is ${audioPlayer.loop}`); console.info(`case loop is ${audioPlayer.loop}`);
if ((audioPlayer.loop == true) && (seekDoneTime == DURATION_TIME)) { if ((audioPlayer.loop == true) && (seekDoneTime == DURATION_TIME)) {
console.log('case loop is true'); console.info('case loop is true');
sleep(PLAYSTATE); sleep(PLAY_STATE);
} }
if (seekDoneTime < audioPlayer.duration || audioPlayer.state == "paused") { if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == "paused")) {
nextStep(mySteps, done); nextStep(mySteps);
} }
}); });
audioPlayer.on('volumeChange', () => { audioPlayer.on('volumeChange', () => {
console.log(`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, done); nextStep(mySteps);
}); });
audioPlayer.on('finish', () => { audioPlayer.on('finish', () => {
mySteps.shift(); mySteps.shift();
expect(audioPlayer.state).assertEqual('stopped'); expect(audioPlayer.state).assertEqual('stopped');
expect(audioPlayer.currentTime).assertClose(audioPlayer.duration, DELTA_TIME); expect(audioPlayer.currentTime).assertClose(audioPlayer.duration, DELTA_TIME);
console.log(`case finish called`); console.info(`case finish called`);
nextStep(mySteps, done); nextStep(mySteps);
}); });
audioPlayer.on('error', (err) => { audioPlayer.on('error', (err) => {
console.log(`case error called,errName is ${err.name}`); console.info(`case error called,errName is ${err.name}`);
console.log(`case error called,errCode is ${err.code}`); console.info(`case error called,errCode is ${err.code}`);
console.log(`case error called,errMessage is ${err.message}`); console.info(`case error called,errMessage is ${err.message}`);
if ((mySteps[0] == SEEKSTATE) || (mySteps[0] == VOLUMESTATE)) { if ((mySteps[0] == SEEK_STATE) || (mySteps[0] == VOLUME_STATE)) {
expect(mySteps[2]).assertEqual(ERRORSTATE);
mySteps.shift();
mySteps.shift();
mySteps.shift();
mySteps.shift(); mySteps.shift();
nextStep(mySteps, done);
} else if (mySteps[0] == ERRORSTATE) {
mySteps.shift(); mySteps.shift();
mySteps.shift(); mySteps.shift();
} else if (mySteps[0] == ENDSTATE) {
console.log('case release player error');
} else { } else {
expect(mySteps[1]).assertEqual(ERRORSTATE);
mySteps.shift(); mySteps.shift();
mySteps.shift(); mySteps.shift();
mySteps.shift();
nextStep(mySteps, done);
} }
nextStep(mySteps);
}); });
}; };
/* * /* *
* @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0200 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0100
* @tc.name : 02.play操作在pause之后 * @tc.name : 001.play
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0100', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, PLAYSTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Play_API_0300 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0200
* @tc.name : 03.play操作在stop之后 * @tc.name : 002.play->pause
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTestTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0200', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, STOPSTATE, PLAYSTATE, ERRORSTATE, PLAYERROR, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Play_API_0400 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0300
* @tc.name : 04.play操作在seek之后 * @tc.name : 003.play->pause->play->reset
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0300', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, SEEKSTATE, SEEK_TIME, PLAYSTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Play_API_0800 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0500
* @tc.name : 08.play操作在reset之后 * @tc.name : 005.play->reset
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0800', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0500', 0, async function (done) {
var mySteps = new Array(SRCSTATE, RESETSTATE, PLAYSTATE, ERRORSTATE, PLAYERROR, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Play_API_0900 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0600
* @tc.name : 09.play操作在release之后 * @tc.name : 006.play->pause->play->pause
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0900', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0600', 0, async function (done) {
var mySteps = new Array(SRCSTATE, RELEASESTATE, PLAYSTATE, ERRORSTATE, PLAYERROR, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, PAUSE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Pause_API_0100 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0700
* @tc.name : 01.pause操作在createAudioPlayer之后 * @tc.name : 007.play->pause->stop
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0700', 0, async function (done) {
var mySteps = new Array(PAUSESTATE, ERRORSTATE, PAUSEERROR, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.pause(); 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_Pause_API_0200 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0800
* @tc.name : 02.pause操作在play之后 * @tc.name : 008.play->pause->play->stop
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0800', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Pause_API_0300 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0900
* @tc.name : 02.pause操作在stop之后 * @tc.name : 009.play->stop->reset->play->pause->play->reset
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_0900', 0, async function (done) {
var mySteps = new Array(PLAYSTATE, STOPSTATE, PAUSESTATE, ERRORSTATE, PAUSEERROR, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RESET_STATE, SRC_STATE, PLAY_STATE,
PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Pause_API_0400 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1000
* @tc.name : 04.pause操作在seek之后 * @tc.name : 010.play->pause->stop->reset->play->pause->reset
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1000', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, PAUSESTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, RESET_STATE, SRC_STATE, PLAY_STATE,
PAUSE_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_LOCAL_AUDIO_Function_04_1100
* @tc.name : 011.play->stop->reset->play->reset
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1100', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RESET_STATE,
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);
})
/* * /* *
* @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0200 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1200
* @tc.name : 02.stop操作在play之后 * @tc.name : 012.play->pause->play->reset
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1200', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, STOPSTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Stop_API_0300 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1300
* @tc.name : 03.stop操作在pause之后 * @tc.name : 013.play->stop->pause
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1300', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, STOPSTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, PAUSE_STATE, ERROR_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Stop_API_0400 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1400
* @tc.name : 04.stop操作在seek之后 * @tc.name : 014.play->seek->pause
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1400', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, STOPSTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, PAUSE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_0200 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1500
* @tc.name : 02.seek操作在play之后 * @tc.name : 015.play->pause->seek(duration)
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1500', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME,
PLAY_STATE, FINISH_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_LOCAL_AUDIO_Function_04_1600
* @tc.name : 03.seek操作在pause之后 * @tc.name : 016.play->pause->play->seek(0)->pause
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1600', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, SEEKSTATE, SEEK_TIME, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, PAUSE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_0900 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1700
* @tc.name : 9.seek到起始位置(0) * @tc.name : 017.play->seek(0)->reset
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0900', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1700', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, 0, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Reset_API_0200 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1800
* @tc.name : 02.reset操作在play之后 * @tc.name : 018.play->seek->stop->reset
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1800', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, RESETSTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, 0, STOP_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Reset_API_0300 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1900
* @tc.name : 03.reset操作在pause之后 * @tc.name : 019.play->stop->seek
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_1900', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, RESETSTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, 0, ERROR_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Release_API_0200 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2000
* @tc.name : 02.release操作在play之后 * @tc.name : 020.play->pause->seek->reset
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2000', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, RELEASESTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, 0, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Release_API_0300 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2100
* @tc.name : 03.release操作在pause之后 * @tc.name : 021.play->pause->seek->stop
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2100', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, PAUSESTATE, RELEASESTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME / RAND_NUM,
STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Release_API_0400 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2200
* @tc.name : 04.release操作在stop之后 * @tc.name : 022.play->pause->play->seek(0)
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2200', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, STOPSTATE, RELEASESTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Release_API_0500 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2300
* @tc.name : 05.release操作在seek之后 * @tc.name : 023.play->pause->play->seek(0)->stop
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0500', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2300', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, SEEKSTATE, SEEK_TIME, RELEASESTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, SEEK_STATE, 0, STOP_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Release_API_0700 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2400
* @tc.name : 07.release操作在reset之后 * @tc.name : 024.play->stop->seek(0)->reset->play
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0700', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2400', 0, async function (done) {
var mySteps = new Array(SRCSTATE, PLAYSTATE, RESETSTATE, RELEASESTATE, ENDSTATE); let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, 0, ERROR_STATE,
RESET_STATE, SRC_STATE, PLAY_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps);
audioPlayer.src = audioSource; 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_Time_API_0100 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2500
* @tc.name : 01.获取参数操作在createAudioPlayer之后 * @tc.name : 025.play->seek(0)
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0100', 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);
initAudioPlayer(); initAudioPlayer();
expect(audioPlayer.src).assertEqual(undefined); setCallback(mySteps);
expect(audioPlayer.duration).assertEqual(undefined); audioPlayer.src = AUDIO_SOURCE;
expect(audioPlayer.currentTime).assertEqual(undefined); setTimeout(function() {
expect(audioPlayer.state).assertEqual('idle'); if (!isTimeOut) {
expect(audioPlayer.loop).assertEqual(false); console.info(`case is time out!`);
done(); expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
}) })
/* * /* *
* @tc.number : SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0200 * @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2600
* @tc.name : 02.获取参数操作在setsrc之后 * @tc.name : 026.play->stop->seek->pause
* @tc.desc : * @tc.desc : Audio playback control test
* @tc.size : MEDIUM * @tc.size : MediumTest
* @tc.type : API Test * @tc.type : Function test
* @tc.level : Level 2 * @tc.level : Level 3
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2600', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, SEEK_TIME, ERROR_STATE,
PAUSE_STATE, ERROR_STATE, RESET_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
audioPlayer.src = audioSource; setCallback(mySteps);
sleep(PLAY_TIME); audioPlayer.src = AUDIO_SOURCE;
expect(audioPlayer.src).assertEqual(audioSource); setTimeout(function() {
expect(audioPlayer.currentTime).assertEqual(0); if (!isTimeOut) {
expect(audioPlayer.duration).assertEqual(DURATION_TIME); console.info(`case is time out!`);
expect(audioPlayer.state).assertEqual('paused'); expect(isTimeOut).assertTrue();
expect(audioPlayer.loop).assertEqual(false); }
done(); done();
}, TIME_OUT);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2700
* @tc.name : 027.play->stop->seek->reset->play
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level 3
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2700', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, SEEK_STATE, SEEK_TIME, ERROR_STATE,
RESET_STATE, SRC_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);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2800
* @tc.name : 028.play->seek(duration)
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
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);
initAudioPlayer();
setCallback(mySteps);
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_LOCAL_AUDIO_Function_04_2900
* @tc.name : 029.play->seek(out of duration)
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level 3
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_2900', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME,
FINISH_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);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3000
* @tc.name : 030.play->->seek(rand)
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
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);
initAudioPlayer();
setCallback(mySteps);
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_LOCAL_AUDIO_Function_04_3200
* @tc.name : 032.play->pause->seek(0)->play
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
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);
initAudioPlayer();
setCallback(mySteps);
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_LOCAL_AUDIO_Function_04_3300
* @tc.name : 033.play->pause->seek(duration)->play
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3300', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME, PLAY_STATE,
FINISH_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);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3400
* @tc.name : 034.play->pause->seek(out of duratin)->play
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level 3
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3400', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME, PLAY_STATE,
FINISH_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);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3500
* @tc.name : 035.play->seek(out of duratin)->play
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level 3
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3500', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, SEEK_STATE, DURATION_TIME + DELTA_TIME,
FINISH_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);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3600
* @tc.name : 036.Loop Play
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3600', 0, async function (done) {
let playCount = 0;
let seekCount = 0;
let isTimeDone = false;
let testAudioPlayer = media.createAudioPlayer();
testAudioPlayer.on('dataLoad', () => {
console.info(`case dataLoad called`);
expect(testAudioPlayer.currentTime).assertEqual(0);
expect(testAudioPlayer.duration).assertEqual(DURATION_TIME);
expect(testAudioPlayer.state).assertEqual('paused');
testAudioPlayer.loop = true;
testAudioPlayer.play();
});
testAudioPlayer.on('play', () => {
console.info(`case play called`);
console.info(`case play currentTime is ${testAudioPlayer.currentTime}`);
expect(testAudioPlayer.duration).assertEqual(DURATION_TIME);
expect(testAudioPlayer.state).assertEqual('playing');
sleep(PLAY_TIME);
if (playCount > 0) {
return;
}
playCount++
testAudioPlayer.seek(DURATION_TIME);
});
testAudioPlayer.on('timeUpdate', (seekDoneTime) => {
if (typeof (seekDoneTime) == "undefined") {
console.info(`case seek filed,errcode is ${seekDoneTime}`);
return;
}
if (seekCount > 0) {
testAudioPlayer.reset();
return;
}
seekCount++
console.info(`case seekDoneTime is ${seekDoneTime}`);
console.info(`case seek called`);
});
testAudioPlayer.on('finish', () => {
expect(testAudioPlayer.state).assertEqual('playing');
console.info(`case finish called`);
});
testAudioPlayer.on('reset', () => {
expect(testAudioPlayer.state).assertEqual('idle');
console.info(`case reset called`);
testAudioPlayer.release();
isTimeDone = true;
});
testAudioPlayer.src = AUDIO_SOURCE;
setTimeout(function() {
if (!isTimeDone) {
console.info(`case is time out!`);
expect(isTimeOut).assertTrue();
}
done();
}, TIME_OUT);
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3700
* @tc.name : 037.set volume 0 to 1
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_Function_04_3700', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, VOLUME_STATE, 0,
VOLUME_STATE, MAX_VOLUME, 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);
}) })
}) })
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册