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

!2965 公共操作提取,用例执行前增加文件读取是否成功的判断

Merge pull request !2965 from NOBUGGERS/r00514670_0408
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
*/ */
import resourceManager from '@ohos.resourceManager'; import resourceManager from '@ohos.resourceManager';
import {expect} from 'deccjsunit/index'
export async function getFileDescriptor(fileName) { export async function getFileDescriptor(fileName) {
let fileDescriptor; let fileDescriptor = undefined;
await resourceManager.getResourceManager().then(async (mgr) => { await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.getRawFileDescriptor(fileName).then(value => { await mgr.getRawFileDescriptor(fileName).then(value => {
console.log('case getRawFileDescriptor fd: ' + value.fd);
fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length}; fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length};
}).catch(error => { }).catch(error => {
console.log('case getRawFileDescriptor err: ' + error); console.log('case getRawFileDescriptor err: ' + error);
...@@ -37,3 +37,11 @@ export async function closeFileDescriptor(fileName) { ...@@ -37,3 +37,11 @@ export async function closeFileDescriptor(fileName) {
}); });
}); });
} }
export function isFileOpen(fileDescriptor, done) {
if (fileDescriptor == undefined) {
expect().assertFail();
console.info('case error fileDescriptor undefined, open file fail');
done();
}
}
\ No newline at end of file
...@@ -17,40 +17,40 @@ ...@@ -17,40 +17,40 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir -p /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile" "mkdir -p /data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile"
], ],
"teardown-command":[ "teardown-command":[
] ]
}, },
{ {
"type": "PushKit", "type": "PushKit",
"pre-push": [ "pre-push": [
], ],
"push": [ "push": [
"./resource/audio/01.mp3 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/", "./resource/audio/01.mp3 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/02.mp3 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/02.mp3 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/03.mp3 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/03.mp3 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/04.mp3 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/04.mp3 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/47.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/47.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/49.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/49.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/50.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/50.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/51.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/51.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/54.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/54.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/55.m4a ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/55.m4a ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/57.m4a ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/57.m4a ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/58.m4a ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/58.m4a ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/59.m4a ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/59.m4a ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/62.m4a ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/62.m4a ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/64.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/64.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/65.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/65.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/66.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/66.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/67.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/67.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/92.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/92.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/93.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/93.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/94.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/94.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/96.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/96.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/97.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./resource/audio/97.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./resource/audio/98.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/" "./resource/audio/98.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/"
] ]
} }
] ]
......
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
*/ */
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import {getFileDescriptor, closeFileDescriptor, isFileOpen} from '../../../../../MediaTestBase.js';
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('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/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/01.mp3'; const AUDIO_SOURCE = '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;
...@@ -39,13 +39,14 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -39,13 +39,14 @@ describe('PlayerLocalTestAudioAPI', function () {
const SEEK_TIME = 5000; const SEEK_TIME = 5000;
const DELTA_TIME = 1000; const DELTA_TIME = 1000;
const SECOND_INDEX = 1; const SECOND_INDEX = 1;
const TIME_OUT = 20000;
const VOLUME_VALUE = 0.5; const VOLUME_VALUE = 0.5;
let fdPath; let fdHead = 'fd://';
let fdValue; let fileDescriptor = undefined;
beforeAll(async function() { beforeAll(async function() {
await getFd(); await getFileDescriptor(AUDIO_SOURCE).then((res) => {
fileDescriptor = res;
});
console.info('beforeAll case'); console.info('beforeAll case');
}) })
...@@ -59,7 +60,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -59,7 +60,7 @@ describe('PlayerLocalTestAudioAPI', function () {
}) })
afterAll(async function() { afterAll(async function() {
await fileIO.close(fdValue); await closeFileDescriptor(AUDIO_SOURCE);
console.info('afterAll case'); console.info('afterAll case');
}) })
...@@ -67,19 +68,6 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -67,19 +68,6 @@ describe('PlayerLocalTestAudioAPI', function () {
for(let t = Date.now();Date.now() - t <= time;); for(let t = Date.now();Date.now() - t <= time;);
} }
async function getFd() {
fdPath = 'fd://';
await fileIO.open(AUDIO_SOURCE).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
fdValue = fdNumber;
console.info('[fileIO]case open fd success,fdPath is ' + fdPath);
}, (err) => {
console.info('[fileIO]case open fd failed');
}).catch((err) => {
console.info('[fileIO]case catch open fd failed');
});
}
function initAudioPlayer() { function initAudioPlayer() {
if (typeof (audioPlayer) != 'undefined') { if (typeof (audioPlayer) != 'undefined') {
audioPlayer.release(); audioPlayer.release();
...@@ -92,7 +80,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -92,7 +80,7 @@ describe('PlayerLocalTestAudioAPI', function () {
} }
} }
function nextStep(mySteps,done) { function nextStep(mySteps, done) {
if (mySteps[0] == END_STATE) { if (mySteps[0] == END_STATE) {
done(); done();
console.info('case to done'); console.info('case to done');
...@@ -101,7 +89,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -101,7 +89,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 = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
break; break;
case PLAY_STATE: case PLAY_STATE:
console.info(`case to play`); console.info(`case to play`);
...@@ -263,11 +251,12 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -263,11 +251,12 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0100', 0, async function (done) {
isFileOpen(fileDescriptor, done);
console.info(`case update`); console.info(`case update`);
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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -279,10 +268,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -279,10 +268,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0200', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -294,10 +284,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -294,10 +284,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0300', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -309,10 +300,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -309,10 +300,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0400', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -324,6 +316,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -324,6 +316,7 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0100', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
...@@ -339,10 +332,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -339,10 +332,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0200', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -354,10 +348,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -354,10 +348,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0300', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -369,10 +364,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -369,10 +364,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Pause_API_0400', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -384,10 +380,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -384,10 +380,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0100', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -399,10 +396,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -399,10 +396,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0200', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -414,10 +412,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -414,10 +412,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Stop_API_0300', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -429,10 +428,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -429,10 +428,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0100', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -444,10 +444,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -444,10 +444,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0200', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -459,10 +460,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -459,10 +460,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Seek_API_0300', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -474,10 +476,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -474,10 +476,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0100', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -489,10 +492,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -489,10 +492,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Reset_API_0200', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -504,6 +508,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -504,6 +508,7 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0100', 0, async function (done) {
isFileOpen(fileDescriptor, done);
var mySteps = new Array(VOLUME_STATE, VOLUME_VALUE, END_STATE); var mySteps = new Array(VOLUME_STATE, VOLUME_VALUE, END_STATE);
initAudioPlayer(); initAudioPlayer();
setCallback(mySteps, done); setCallback(mySteps, done);
...@@ -519,10 +524,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -519,10 +524,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0200', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -534,10 +540,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -534,10 +540,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_SetVolume_API_0300', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -549,10 +556,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -549,10 +556,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0100', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -564,10 +572,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -564,10 +572,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0200', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -579,10 +588,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -579,10 +588,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0300', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -594,10 +604,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -594,10 +604,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -609,10 +620,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -609,10 +620,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Release_API_0400', 0, async function (done) {
isFileOpen(fileDescriptor, 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, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
}) })
/* * /* *
...@@ -624,6 +636,7 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -624,6 +636,7 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0100', 0, async function (done) {
isFileOpen(fileDescriptor, done);
initAudioPlayer(); initAudioPlayer();
expect(audioPlayer.src).assertEqual(undefined); expect(audioPlayer.src).assertEqual(undefined);
expect(audioPlayer.duration).assertEqual(undefined); expect(audioPlayer.duration).assertEqual(undefined);
...@@ -642,10 +655,11 @@ describe('PlayerLocalTestAudioAPI', function () { ...@@ -642,10 +655,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0200', 0, async function (done) {
isFileOpen(fileDescriptor, done);
initAudioPlayer(); initAudioPlayer();
audioPlayer.src = fdPath; audioPlayer.src = fdHead + fileDescriptor.fd;
sleep(PLAY_TIME); sleep(PLAY_TIME);
expect(audioPlayer.src).assertEqual(fdPath); expect(audioPlayer.src).assertEqual(fdHead + fileDescriptor.fd);
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');
......
...@@ -14,18 +14,17 @@ ...@@ -14,18 +14,17 @@
*/ */
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import {getFileDescriptor, closeFileDescriptor, isFileOpen} from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('PlayerLocalTestAudioFormat', function () { describe('PlayerLocalTestAudioFormat', function () {
const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/'; let audioSource = '01.mp3';
const MAX_VOLUME = 1; const MAX_VOLUME = 1;
const PLAY_TIME = 3000; const PLAY_TIME = 3000;
const SEEK_TIME = 10000; // 10s const SEEK_TIME = 10000; // 10s
let isToSeek = false; let isToSeek = false;
let isToDuration = false; let isToDuration = false;
let fdPath; let fileDescriptor = undefined;
let fdValue;
beforeAll(function() { beforeAll(function() {
console.info('beforeAll case'); console.info('beforeAll case');
...@@ -42,7 +41,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -42,7 +41,7 @@ describe('PlayerLocalTestAudioFormat', function () {
}) })
afterAll(async function() { afterAll(async function() {
await fileIO.close(fdValue); await closeFileDescriptor(audioSource);
console.info('afterAll case'); console.info('afterAll case');
}) })
...@@ -50,23 +49,14 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -50,23 +49,14 @@ describe('PlayerLocalTestAudioFormat', function () {
for(let t = Date.now(); Date.now() - t <= time;); for(let t = Date.now(); Date.now() - t <= time;);
} }
async function getFd(pathName) { async function playSource(audioFile, done) {
fdPath = 'fd://';
await fileIO.open(pathName).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber;
fdValue = fdNumber;
console.info('[fileIO]case open fd success,fdPath is ' + fdPath);
}, (err) => {
console.info('[fileIO]case open fd failed');
}).catch((err) => {
console.info('[fileIO]case catch open fd failed');
});
}
async function playSource(audioSource, done) {
let audioPlayer = media.createAudioPlayer(); let audioPlayer = media.createAudioPlayer();
await getFd(audioSource); audioSource = audioFile;
audioPlayer.src = fdPath; await getFileDescriptor(audioSource).then((res) => {
fileDescriptor = res;
});
isFileOpen(fileDescriptor, done);
audioPlayer.src = 'fd://' + fileDescriptor.fd;
audioPlayer.on('dataLoad', () => { audioPlayer.on('dataLoad', () => {
console.info('case set source success'); console.info('case set source success');
expect(audioPlayer.state).assertEqual('paused'); expect(audioPlayer.state).assertEqual('paused');
...@@ -151,7 +141,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -151,7 +141,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP3_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP3_0100', 0, async function (done) {
playSource(BASIC_PATH + '01.mp3', done); playSource('01.mp3', done);
}) })
/* * /* *
...@@ -167,7 +157,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -167,7 +157,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP3_0200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP3_0200', 0, async function (done) {
playSource(BASIC_PATH + '02.mp3', done); playSource('02.mp3', done);
}) })
/* * /* *
...@@ -183,7 +173,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -183,7 +173,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP3_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP3_0300', 0, async function (done) {
playSource(BASIC_PATH + '03.mp3', done); playSource('03.mp3', done);
}) })
/* * /* *
...@@ -199,7 +189,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -199,7 +189,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP3_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP3_0400', 0, async function (done) {
playSource(BASIC_PATH + '04.mp3', done); playSource('04.mp3', done);
}) })
/* * /* *
...@@ -215,7 +205,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -215,7 +205,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0100', 0, async function (done) {
playSource(BASIC_PATH + '47.mp4', done); playSource('47.mp4', done);
}) })
...@@ -232,7 +222,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -232,7 +222,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0300', 0, async function (done) {
playSource(BASIC_PATH + '49.mp4', done); playSource('49.mp4', done);
}) })
/* * /* *
...@@ -248,7 +238,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -248,7 +238,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0400', 0, async function (done) {
playSource(BASIC_PATH + '50.mp4', done); playSource('50.mp4', done);
}) })
/* * /* *
...@@ -264,7 +254,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -264,7 +254,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0500', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0500', 0, async function (done) {
playSource(BASIC_PATH + '51.mp4', done); playSource('51.mp4', done);
}) })
/* * /* *
...@@ -280,7 +270,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -280,7 +270,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0600', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0600', 0, async function (done) {
playSource(BASIC_PATH + '54.mp4', done); playSource('54.mp4', done);
}) })
/* * /* *
...@@ -296,7 +286,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -296,7 +286,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0700', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0700', 0, async function (done) {
playSource(BASIC_PATH + '64.mp4', done); playSource('64.mp4', done);
}) })
/* * /* *
...@@ -312,7 +302,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -312,7 +302,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0800', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0800', 0, async function (done) {
playSource(BASIC_PATH + '65.mp4', done); playSource('65.mp4', done);
}) })
/* * /* *
...@@ -328,7 +318,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -328,7 +318,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0900', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_0900', 0, async function (done) {
playSource(BASIC_PATH + '66.mp4', done); playSource('66.mp4', done);
}) })
/* * /* *
...@@ -344,7 +334,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -344,7 +334,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1000', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1000', 0, async function (done) {
playSource(BASIC_PATH + '67.mp4', done); playSource('67.mp4', done);
}) })
/* * /* *
...@@ -360,7 +350,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -360,7 +350,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1100', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1100', 0, async function (done) {
playSource(BASIC_PATH + '92.mp4', done); playSource('92.mp4', done);
}) })
/* * /* *
...@@ -376,7 +366,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -376,7 +366,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1200', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1200', 0, async function (done) {
playSource(BASIC_PATH + '93.mp4', done); playSource('93.mp4', done);
}) })
/* * /* *
...@@ -392,7 +382,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -392,7 +382,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1300', 0, async function (done) {
playSource(BASIC_PATH + '94.mp4', done); playSource('94.mp4', done);
}) })
/* * /* *
...@@ -408,7 +398,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -408,7 +398,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1400', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1400', 0, async function (done) {
playSource(BASIC_PATH + '96.mp4', done); playSource('96.mp4', done);
}) })
/* * /* *
...@@ -424,7 +414,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -424,7 +414,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1500', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1500', 0, async function (done) {
playSource(BASIC_PATH + '97.mp4', done); playSource('97.mp4', done);
}) })
/* * /* *
...@@ -440,7 +430,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -440,7 +430,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1600', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_MP4_1600', 0, async function (done) {
playSource(BASIC_PATH + '98.mp4', done); playSource('98.mp4', done);
}) })
/* * /* *
...@@ -456,7 +446,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -456,7 +446,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_M4A_0100', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_M4A_0100', 0, async function (done) {
playSource(BASIC_PATH + '55.m4a', done); playSource('55.m4a', done);
}) })
...@@ -473,7 +463,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -473,7 +463,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_M4A_0300', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_M4A_0300', 0, async function (done) {
playSource(BASIC_PATH + '57.m4a', done); playSource('57.m4a', done);
}) })
/* * /* *
...@@ -489,7 +479,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -489,7 +479,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_M4A_0400', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_M4A_0400', 0, async function (done) {
playSource(BASIC_PATH + '58.m4a', done); playSource('58.m4a', done);
}) })
/* * /* *
...@@ -505,7 +495,7 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -505,7 +495,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_M4A_0500', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_M4A_0500', 0, async function (done) {
playSource(BASIC_PATH + '59.m4a', done); playSource('59.m4a', done);
}) })
/* * /* *
...@@ -521,6 +511,6 @@ describe('PlayerLocalTestAudioFormat', function () { ...@@ -521,6 +511,6 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_M4A_0700', 0, async function (done) { it('SUB_MEDIA_PLAYER_LOCAL_FORMAT_M4A_0700', 0, async function (done) {
playSource(BASIC_PATH + '62.m4a', done); playSource('62.m4a', done);
}) })
}) })
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
{ {
"type": "ShellKit", "type": "ShellKit",
"run-command": [ "run-command": [
"mkdir -p /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" "mkdir -p /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile"
], ],
"teardown-command":[ "teardown-command":[
] ]
}, },
{ {
"type": "PushKit", "type": "PushKit",
"pre-push": [ "pre-push": [
], ],
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require('./VideoPlayerFuncCallbackTest.test.js') require('./VideoPlayerFuncCallbackTest.test.js')
require('./VideoPlayerFuncPromiseTest.test.js') require('./VideoPlayerFuncPromiseTest.test.js')
require('./VideoPlayerAPICallbackTest.test.js') require('./VideoPlayerAPICallbackTest.test.js')
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
*/ */
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import router from '@system.router' import {toNewPage, clearRouter} from './VideoPlayerTestBase.js';
import {getFileDescriptor, closeFileDescriptor} from './VideoPlayerTestBase.js'; import {getFileDescriptor, closeFileDescriptor, isFileOpen} from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoPlayerFuncCallbackTest', function () { describe('VideoPlayerFuncCallbackTest', function () {
...@@ -46,8 +46,8 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -46,8 +46,8 @@ describe('VideoPlayerFuncCallbackTest', function () {
const NEXT_FRAME_TIME = 8333; const NEXT_FRAME_TIME = 8333;
const PREV_FRAME_TIME = 4166; const PREV_FRAME_TIME = 4166;
let surfaceID = ''; let surfaceID = '';
let fileDescriptor; let fileDescriptor = undefined;
let temp = 0; let page = 0;
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
...@@ -59,14 +59,16 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -59,14 +59,16 @@ describe('VideoPlayerFuncCallbackTest', function () {
}) })
beforeEach(async function() { beforeEach(async function() {
await toNewPage(); await toNewPage(page);
await msleep(1000).then(() => { page = (page + 1) % 2;
}, failureCallback).catch(catchCallback); await msleep(1000).then(() => {}, failureCallback).catch(catchCallback);
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
console.info('beforeEach case'); console.info('beforeEach case');
}) })
afterEach(async function() { afterEach(async function() {
await router.clear(); await clearRouter();
console.info('afterEach case'); console.info('afterEach case');
}) })
...@@ -93,25 +95,6 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -93,25 +95,6 @@ describe('VideoPlayerFuncCallbackTest', function () {
return new Promise((resolve) => setTimeout(resolve, ms)); return new Promise((resolve) => setTimeout(resolve, ms));
} }
async function toNewPage() {
let path = '';
if (temp == 0) {
path = 'pages/surfaceTest/surfaceTest';
temp = 1;
} else {
path = 'pages/surfaceTest/surfaceTest2';
temp = 0;
}
let options = {
uri: path,
}
try {
let result = await router.push(options);
} catch {
console.info('case route failed');
}
}
function printfError(error, done) { function printfError(error, done) {
expect().assertFail(); expect().assertFail();
console.info(`case error called,errMessage is ${error.message}`); console.info(`case error called,errMessage is ${error.message}`);
...@@ -432,8 +415,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -432,8 +415,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0100', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0100', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT,
PREPARE_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT); PREPARE_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -449,8 +431,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -449,8 +431,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0200', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0200', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT,
PLAY_EVENT, PAUSE_EVENT, RELEASE_EVENT, END_EVENT); PLAY_EVENT, PAUSE_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -466,8 +447,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -466,8 +447,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0300', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0300', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT); PAUSE_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -483,8 +463,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -483,8 +463,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0400', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0400', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT,
PLAY_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT); PLAY_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -500,8 +479,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -500,8 +479,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0500', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0500', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT,
PLAY_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT); PLAY_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -517,8 +495,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -517,8 +495,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0600', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0600', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, SEEK_TIME, RELEASE_EVENT, END_EVENT); SEEK_EVENT, SEEK_TIME, RELEASE_EVENT, END_EVENT);
...@@ -534,8 +511,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -534,8 +511,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0700', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0700', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC, SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC,
...@@ -552,8 +528,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -552,8 +528,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0800', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0800', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT); SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT);
...@@ -569,8 +544,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -569,8 +544,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0900', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0900', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SETSPEED_EVENT, SPEED_VALUE, RELEASE_EVENT, END_EVENT); SETSPEED_EVENT, SPEED_VALUE, RELEASE_EVENT, END_EVENT);
...@@ -586,8 +560,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -586,8 +560,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0 * @tc.level : Level0
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1000', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1000', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT,
GETDESCRIPTION, RELEASE_EVENT, END_EVENT); GETDESCRIPTION, RELEASE_EVENT, END_EVENT);
...@@ -603,8 +576,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -603,8 +576,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1200', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1200', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT); PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -620,8 +592,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -620,8 +592,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1300', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1300', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT); PAUSE_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -637,8 +608,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -637,8 +608,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1400', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1400', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SEEK_EVENT, SEEK_TIME, PLAY_EVENT, RELEASE_EVENT, END_EVENT); PAUSE_EVENT, SEEK_EVENT, SEEK_TIME, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -654,8 +624,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -654,8 +624,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1500', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1500', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC, PAUSE_EVENT, SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC,
...@@ -672,8 +641,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -672,8 +641,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1600', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1600', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SETVOLUME_EVENT, VOLUME_VALUE, PLAY_EVENT, RELEASE_EVENT, END_EVENT); PAUSE_EVENT, SETVOLUME_EVENT, VOLUME_VALUE, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -689,8 +657,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -689,8 +657,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1700', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1700', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SETSPEED_EVENT, SPEED_VALUE, PLAY_EVENT, RELEASE_EVENT, END_EVENT); PAUSE_EVENT, SETSPEED_EVENT, SPEED_VALUE, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -706,8 +673,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -706,8 +673,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1800', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1800', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
STOP_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT); STOP_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -723,8 +689,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -723,8 +689,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1900', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1900', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
STOP_EVENT, RESET_EVENT, SRC_PREPARE_EVENT, STOP_EVENT, RESET_EVENT, SRC_PREPARE_EVENT,
...@@ -741,8 +706,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -741,8 +706,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2000', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2000', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, 0, PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT); SEEK_EVENT, 0, PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT);
...@@ -758,8 +722,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -758,8 +722,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2100', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2100', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_MODE_EVENT, 0, media.SeekMode.SEEK_NEXT_SYNC, SEEK_MODE_EVENT, 0, media.SeekMode.SEEK_NEXT_SYNC,
...@@ -776,8 +739,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -776,8 +739,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2200', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2200', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, DURATION_TIME, RELEASE_EVENT, END_EVENT); SEEK_EVENT, DURATION_TIME, RELEASE_EVENT, END_EVENT);
...@@ -793,8 +755,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -793,8 +755,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1 * @tc.level : Level1
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2300', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2300', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_MODE_EVENT, DURATION_TIME, media.SeekMode.SEEK_PREV_SYNC, SEEK_MODE_EVENT, DURATION_TIME, media.SeekMode.SEEK_PREV_SYNC,
...@@ -811,8 +772,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -811,8 +772,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2400', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2400', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, DURATION_TIME + 1, RELEASE_EVENT, END_EVENT); SEEK_EVENT, DURATION_TIME + 1, RELEASE_EVENT, END_EVENT);
...@@ -828,8 +788,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -828,8 +788,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2500', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2500', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_MODE_EVENT, DURATION_TIME + 1, media.SeekMode.SEEK_PREV_SYNC, SEEK_MODE_EVENT, DURATION_TIME + 1, media.SeekMode.SEEK_PREV_SYNC,
...@@ -846,8 +805,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -846,8 +805,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2600', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2600', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SETVOLUME_EVENT, 0, SETVOLUME_EVENT, 0.2, SETVOLUME_EVENT, 0.4, SETVOLUME_EVENT, 0.6, SETVOLUME_EVENT, 0, SETVOLUME_EVENT, 0.2, SETVOLUME_EVENT, 0.4, SETVOLUME_EVENT, 0.6,
...@@ -864,8 +822,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -864,8 +822,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level2 * @tc.level : Level2
*/ */
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2700', 0, async function (done) { it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2700', 0, async function (done) {
surfaceID = globalThis.value; isFileOpen(fileDescriptor, done);
console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT, let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SETSPEED_EVENT, media.PlaybackSpeed.SPEED_FORWARD_2_00_X, RELEASE_EVENT, END_EVENT); SETSPEED_EVENT, media.PlaybackSpeed.SPEED_FORWARD_2_00_X, RELEASE_EVENT, END_EVENT);
......
...@@ -13,26 +13,25 @@ ...@@ -13,26 +13,25 @@
* limitations under the License. * limitations under the License.
*/ */
import resourceManager from '@ohos.resourceManager'; import router from '@system.router'
export async function getFileDescriptor(fileName) { export async function toNewPage(page) {
let fileDescriptor; let path = '';
await resourceManager.getResourceManager().then(async (mgr) => { if (page == 0) {
await mgr.getRawFileDescriptor(fileName).then(value => { path = 'pages/surfaceTest/surfaceTest';
fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length}; } else {
}).catch(error => { path = 'pages/surfaceTest/surfaceTest2';
console.log('case getRawFileDescriptor err: ' + error); }
}); let options = {
}); uri: path,
return fileDescriptor; }
try {
await router.push(options);
} catch {
console.info('case route failed');
}
} }
export async function closeFileDescriptor(fileName) { export async function clearRouter() {
await resourceManager.getResourceManager().then(async (mgr) => { await router.clear();
await mgr.closeRawFileDescriptor(fileName).then(value => {
console.log('case closeRawFileDescriptor ' + value);
}).catch(error => {
console.log('case closeRawFileDescriptor err: ' + error);
});
});
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册