未验证 提交 703af7fc 编写于 作者: O openharmony_ci 提交者: Gitee

!6899 audio player timeupdate 事件从seekdon改成position上报,测试用例进行对应修改

Merge pull request !6899 from FULIZHONG/OpenHarmony-3.1-Release
...@@ -128,6 +128,9 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -128,6 +128,9 @@ describe('PlayerLocalTestAudioAPI', function () {
case SEEK_STATE: case SEEK_STATE:
console.info(`case seek to time is ${mySteps[SECOND_INDEX]}`); console.info(`case seek to time is ${mySteps[SECOND_INDEX]}`);
audioPlayer.seek(mySteps[SECOND_INDEX]); audioPlayer.seek(mySteps[SECOND_INDEX]);
mySteps.shift();
mySteps.shift();
nextStep(mySteps, done);
break; break;
case VOLUME_STATE: case VOLUME_STATE:
console.info(`case to setVolume`); console.info(`case to setVolume`);
...@@ -206,22 +209,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -206,22 +209,7 @@ describe('PlayerLocalTestAudioAPI', function () {
console.info(`case seek filed,errcode is ${seekDoneTime}`); console.info(`case seek filed,errcode is ${seekDoneTime}`);
return; return;
} }
if (mySteps[0] != SEEK_STATE) { console.info(`case timeUpdate, seekDoneTime is ${seekDoneTime}`);
return;
}
mySteps.shift();
mySteps.shift();
console.info(`case seekDoneTime is ${seekDoneTime}`);
console.info(`case seek called`);
expect(audioPlayer.currentTime + DELTA_TIME).assertClose(seekDoneTime + DELTA_TIME, DELTA_TIME);
console.info(`case loop is ${audioPlayer.loop}`);
if ((audioPlayer.loop == true) && (seekDoneTime == DURATION_TIME)) {
console.info('case loop is true');
sleep(PLAY_STATE);
}
if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == 'paused')) {
nextStep(mySteps,done);
}
}); });
audioPlayer.on('volumeChange', () => { audioPlayer.on('volumeChange', () => {
console.info(`case setvolume called`); console.info(`case setvolume called`);
...@@ -250,6 +238,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -250,6 +238,7 @@ describe('PlayerLocalTestAudioAPI', function () {
nextStep(mySteps,done); nextStep(mySteps,done);
} else if (mySteps[0] == ERROR_STATE) { } else if (mySteps[0] == ERROR_STATE) {
mySteps.shift(); mySteps.shift();
nextStep(mySteps,done);
} else if (mySteps[0] == END_STATE) { } else if (mySteps[0] == END_STATE) {
console.info('case release player error'); console.info('case release player error');
} else { } else {
......
...@@ -129,6 +129,11 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -129,6 +129,11 @@ describe('PlayerLocalTestAudioFUNC', function () {
case SEEK_STATE: case SEEK_STATE:
console.info(`case seek to time is ${mySteps[SECOND_INDEX]}`); console.info(`case seek to time is ${mySteps[SECOND_INDEX]}`);
audioPlayer.seek(mySteps[SECOND_INDEX]); audioPlayer.seek(mySteps[SECOND_INDEX]);
if (mySteps[2] != ERROR_STATE) {
mySteps.shift();
mySteps.shift();
nextStep(mySteps, done);
}
break; break;
case VOLUME_STATE: case VOLUME_STATE:
console.info(`case to setVolume`); console.info(`case to setVolume`);
...@@ -139,6 +144,7 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -139,6 +144,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
mySteps.shift(); mySteps.shift();
audioPlayer.release(); audioPlayer.release();
audioPlayer = undefined; audioPlayer = undefined;
nextStep(mySteps, done);
break; break;
case LOOP_STATE: case LOOP_STATE:
audioPlayer.loop = mySteps[SECOND_INDEX]; audioPlayer.loop = mySteps[SECOND_INDEX];
...@@ -205,26 +211,7 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -205,26 +211,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
nextStep(mySteps,done); nextStep(mySteps,done);
}); });
audioPlayer.on('timeUpdate', (seekDoneTime) => { audioPlayer.on('timeUpdate', (seekDoneTime) => {
if (typeof (seekDoneTime) == 'undefined') { console.info('case timeUpdate seekDoneTime is' + seekDoneTime);
console.info(`case seek filed,errcode is ${seekDoneTime}`);
return;
}
if (mySteps[0] != SEEK_STATE) {
return;
}
mySteps.shift();
mySteps.shift();
console.info(`case seekDoneTime is ${seekDoneTime}`);
console.info(`case seek called`);
expect(audioPlayer.currentTime + DELTA_TIME).assertClose(seekDoneTime + DELTA_TIME, DELTA_TIME);
console.info(`case loop is ${audioPlayer.loop}`);
if ((audioPlayer.loop == true) && (seekDoneTime == DURATION_TIME)) {
console.info('case loop is true');
sleep(PLAY_STATE);
}
if ((seekDoneTime < audioPlayer.duration) || (audioPlayer.state == 'paused')) {
nextStep(mySteps,done);
}
}); });
audioPlayer.on('volumeChange', () => { audioPlayer.on('volumeChange', () => {
console.info(`case setvolume called`); console.info(`case setvolume called`);
...@@ -243,18 +230,16 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -243,18 +230,16 @@ describe('PlayerLocalTestAudioFUNC', function () {
nextStep(mySteps,done); nextStep(mySteps,done);
}); });
audioPlayer.on('error', (err) => { 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,errCode is ${err.code}`);
console.info(`case error called,errMessage is ${err.message}`);
if ((mySteps[0] == SEEK_STATE) || (mySteps[0] == VOLUME_STATE)) { if ((mySteps[0] == SEEK_STATE) || (mySteps[0] == VOLUME_STATE)) {
mySteps.shift(); mySteps.shift();
mySteps.shift(); mySteps.shift();
mySteps.shift();
} else { } else {
mySteps.shift(); mySteps.shift();
mySteps.shift();
} }
nextStep(mySteps,done); expect(mySteps[0]).assertEqual(ERROR_STATE);
mySteps.shift();
nextStep(mySteps, done);
}); });
} }
...@@ -452,7 +437,7 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -452,7 +437,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1500', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_04_1500', 0, async function (done) {
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, RESET_STATE, RELEASE_STATE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdPath;
......
...@@ -114,13 +114,11 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -114,13 +114,11 @@ describe('PlayerLocalTestAudioFormat', function () {
return; return;
} }
console.info('case seek success, and seek time is ' + seekDoneTime); console.info('case seek success, and seek time is ' + seekDoneTime);
if (!isToDuration) { if ((!isToDuration) && (seekDoneTime >= SEEK_TIME)) {
expect(SEEK_TIME).assertEqual(seekDoneTime); expect(SEEK_TIME).assertEqual(seekDoneTime);
isToDuration = true; isToDuration = true;
sleep(PLAY_TIME); sleep(PLAY_TIME);
audioPlayer.seek(audioPlayer.duration); audioPlayer.seek(audioPlayer.duration);
} else {
expect(audioPlayer.duration).assertEqual(seekDoneTime);
} }
}); });
audioPlayer.on('volumeChange', () => { audioPlayer.on('volumeChange', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册