提交 b3fd2270 编写于 作者: N NOBUGGERS

公共操作提取,用例执行前增加文件读取是否成功的判断 Signed-off-by: NOBUGGERS <ruanmeng@huawei.com>

Signed-off-by: NNOBUGGERS <ruanmeng@huawei.com>
上级 514212f7
......@@ -14,12 +14,12 @@
*/
import resourceManager from '@ohos.resourceManager';
import {expect} from 'deccjsunit/index'
export async function getFileDescriptor(fileName) {
let fileDescriptor;
let fileDescriptor = undefined;
await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.getRawFileDescriptor(fileName).then(value => {
console.log('case getRawFileDescriptor fd: ' + value.fd);
fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length};
}).catch(error => {
console.log('case getRawFileDescriptor err: ' + error);
......@@ -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 @@
{
"type": "ShellKit",
"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":[
]
},
{
{
"type": "PushKit",
"pre-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/02.mp3 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/03.mp3 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/04.mp3 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/47.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/49.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/50.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/51.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/54.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/55.m4a ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/57.m4a ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/58.m4a ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/59.m4a ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/62.m4a ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/64.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/65.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/66.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/67.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/92.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/93.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/94.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/96.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/97.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
"./resource/audio/98.mp4 ->/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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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/app/el1/bundle/public/ohos.acts.multimedia.audio.audioplayer/ohos.acts.multimedia.audio.audioplayer/assets/entry/resources/rawfile/",
"./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 @@
*/
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'
describe('PlayerLocalTestAudioAPI', function () {
let audioPlayer = media.createAudioPlayer();
let loopValue = 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 END_STATE = 0;
const SRC_STATE = 1;
......@@ -39,13 +39,14 @@ describe('PlayerLocalTestAudioAPI', function () {
const SEEK_TIME = 5000;
const DELTA_TIME = 1000;
const SECOND_INDEX = 1;
const TIME_OUT = 20000;
const VOLUME_VALUE = 0.5;
let fdPath;
let fdValue;
let fdHead = 'fd://';
let fileDescriptor = undefined;
beforeAll(async function() {
await getFd();
await getFileDescriptor(AUDIO_SOURCE).then((res) => {
fileDescriptor = res;
});
console.info('beforeAll case');
})
......@@ -59,7 +60,7 @@ describe('PlayerLocalTestAudioAPI', function () {
})
afterAll(async function() {
await fileIO.close(fdValue);
await closeFileDescriptor(AUDIO_SOURCE);
console.info('afterAll case');
})
......@@ -67,19 +68,6 @@ describe('PlayerLocalTestAudioAPI', function () {
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() {
if (typeof (audioPlayer) != 'undefined') {
audioPlayer.release();
......@@ -92,7 +80,7 @@ describe('PlayerLocalTestAudioAPI', function () {
}
}
function nextStep(mySteps,done) {
function nextStep(mySteps, done) {
if (mySteps[0] == END_STATE) {
done();
console.info('case to done');
......@@ -101,7 +89,7 @@ describe('PlayerLocalTestAudioAPI', function () {
switch (mySteps[0]) {
case SRC_STATE:
console.info(`case to prepare`);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
break;
case PLAY_STATE:
console.info(`case to play`);
......@@ -263,11 +251,12 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
it('SUB_MEDIA_PLAYER_AudioPlayer_Play_API_0100', 0, async function (done) {
isFileOpen(fileDescriptor, done);
console.info(`case update`);
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -279,10 +268,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -294,10 +284,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -309,10 +300,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -324,6 +316,7 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
......@@ -339,10 +332,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -354,10 +348,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -369,10 +364,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -384,10 +380,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -399,10 +396,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -414,10 +412,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -429,10 +428,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -444,10 +444,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -459,10 +460,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -474,10 +476,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -489,10 +492,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -504,6 +508,7 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
......@@ -519,10 +524,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -534,10 +540,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -549,10 +556,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -564,10 +572,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -579,10 +588,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -594,10 +604,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -609,10 +620,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
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);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
})
/* *
......@@ -624,6 +636,7 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0100', 0, async function (done) {
isFileOpen(fileDescriptor, done);
initAudioPlayer();
expect(audioPlayer.src).assertEqual(undefined);
expect(audioPlayer.duration).assertEqual(undefined);
......@@ -642,10 +655,11 @@ describe('PlayerLocalTestAudioAPI', function () {
* @tc.level : Level2
*/
it('SUB_MEDIA_PLAYER_AudioPlayer_Time_API_0200', 0, async function (done) {
isFileOpen(fileDescriptor, done);
initAudioPlayer();
audioPlayer.src = fdPath;
audioPlayer.src = fdHead + fileDescriptor.fd;
sleep(PLAY_TIME);
expect(audioPlayer.src).assertEqual(fdPath);
expect(audioPlayer.src).assertEqual(fdHead + fileDescriptor.fd);
expect(audioPlayer.currentTime).assertEqual(0);
expect(audioPlayer.duration).assertEqual(DURATION_TIME);
expect(audioPlayer.state).assertEqual('paused');
......
......@@ -14,18 +14,17 @@
*/
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'
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 PLAY_TIME = 3000;
const SEEK_TIME = 10000; // 10s
let isToSeek = false;
let isToDuration = false;
let fdPath;
let fdValue;
let fileDescriptor = undefined;
beforeAll(function() {
console.info('beforeAll case');
......@@ -42,7 +41,7 @@ describe('PlayerLocalTestAudioFormat', function () {
})
afterAll(async function() {
await fileIO.close(fdValue);
await closeFileDescriptor(audioSource);
console.info('afterAll case');
})
......@@ -50,23 +49,14 @@ describe('PlayerLocalTestAudioFormat', function () {
for(let t = Date.now(); Date.now() - t <= time;);
}
async function getFd(pathName) {
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) {
async function playSource(audioFile, done) {
let audioPlayer = media.createAudioPlayer();
await getFd(audioSource);
audioPlayer.src = fdPath;
audioSource = audioFile;
await getFileDescriptor(audioSource).then((res) => {
fileDescriptor = res;
});
isFileOpen(fileDescriptor, done);
audioPlayer.src = 'fd://' + fileDescriptor.fd;
audioPlayer.on('dataLoad', () => {
console.info('case set source success');
expect(audioPlayer.state).assertEqual('paused');
......@@ -151,7 +141,7 @@ describe('PlayerLocalTestAudioFormat', function () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 () {
* @tc.level : Level0
*/
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 @@
{
"type": "ShellKit",
"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":[
]
},
{
{
"type": "PushKit",
"pre-push": [
],
......
......@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./VideoPlayerFuncCallbackTest.test.js')
require('./VideoPlayerFuncPromiseTest.test.js')
require('./VideoPlayerAPICallbackTest.test.js')
......
......@@ -14,8 +14,8 @@
*/
import media from '@ohos.multimedia.media'
import router from '@system.router'
import {getFileDescriptor, closeFileDescriptor} from './VideoPlayerTestBase.js';
import {toNewPage, clearRouter} from './VideoPlayerTestBase.js';
import {getFileDescriptor, closeFileDescriptor, isFileOpen} from '../../../../../MediaTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoPlayerFuncCallbackTest', function () {
......@@ -46,8 +46,8 @@ describe('VideoPlayerFuncCallbackTest', function () {
const NEXT_FRAME_TIME = 8333;
const PREV_FRAME_TIME = 4166;
let surfaceID = '';
let fileDescriptor;
let temp = 0;
let fileDescriptor = undefined;
let page = 0;
let events = require('events');
let eventEmitter = new events.EventEmitter();
......@@ -59,14 +59,16 @@ describe('VideoPlayerFuncCallbackTest', function () {
})
beforeEach(async function() {
await toNewPage();
await msleep(1000).then(() => {
}, failureCallback).catch(catchCallback);
await toNewPage(page);
page = (page + 1) % 2;
await msleep(1000).then(() => {}, failureCallback).catch(catchCallback);
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
console.info('beforeEach case');
})
afterEach(async function() {
await router.clear();
await clearRouter();
console.info('afterEach case');
})
......@@ -93,25 +95,6 @@ describe('VideoPlayerFuncCallbackTest', function () {
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) {
expect().assertFail();
console.info(`case error called,errMessage is ${error.message}`);
......@@ -432,8 +415,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0100', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT,
PREPARE_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -449,8 +431,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0200', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT,
PLAY_EVENT, PAUSE_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -466,8 +447,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0300', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -483,8 +463,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0400', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT,
PLAY_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -500,8 +479,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0500', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT,
PLAY_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -517,8 +495,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0600', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, SEEK_TIME, RELEASE_EVENT, END_EVENT);
......@@ -534,8 +511,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0700', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC,
......@@ -552,8 +528,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0800', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SETVOLUME_EVENT, VOLUME_VALUE, RELEASE_EVENT, END_EVENT);
......@@ -569,8 +544,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_0900', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SETSPEED_EVENT, SPEED_VALUE, RELEASE_EVENT, END_EVENT);
......@@ -586,8 +560,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level0
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1000', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT,
GETDESCRIPTION, RELEASE_EVENT, END_EVENT);
......@@ -603,8 +576,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1200', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -620,8 +592,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1300', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -637,8 +608,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1400', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SEEK_EVENT, SEEK_TIME, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -654,8 +624,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1500', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SEEK_MODE_EVENT, SEEK_TIME, media.SeekMode.SEEK_NEXT_SYNC,
......@@ -672,8 +641,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1600', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SETVOLUME_EVENT, VOLUME_VALUE, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -689,8 +657,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1700', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
PAUSE_EVENT, SETSPEED_EVENT, SPEED_VALUE, PLAY_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -706,8 +673,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1800', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
STOP_EVENT, RESET_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -723,8 +689,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_1900', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
STOP_EVENT, RESET_EVENT, SRC_PREPARE_EVENT,
......@@ -741,8 +706,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2000', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, 0, PAUSE_EVENT, STOP_EVENT, RELEASE_EVENT, END_EVENT);
......@@ -758,8 +722,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2100', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_MODE_EVENT, 0, media.SeekMode.SEEK_NEXT_SYNC,
......@@ -776,8 +739,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2200', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, DURATION_TIME, RELEASE_EVENT, END_EVENT);
......@@ -793,8 +755,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level1
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2300', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_MODE_EVENT, DURATION_TIME, media.SeekMode.SEEK_PREV_SYNC,
......@@ -811,8 +772,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level2
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2400', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_EVENT, DURATION_TIME + 1, RELEASE_EVENT, END_EVENT);
......@@ -828,8 +788,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level2
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2500', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
let mySteps = new Array(CREATE_EVENT, SETSURFACE_EVENT, PREPARE_EVENT, PLAY_EVENT,
SEEK_MODE_EVENT, DURATION_TIME + 1, media.SeekMode.SEEK_PREV_SYNC,
......@@ -846,8 +805,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level2
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2600', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
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,
......@@ -864,8 +822,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
* @tc.level : Level2
*/
it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_CALLBACK_2700', 0, async function (done) {
surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID);
isFileOpen(fileDescriptor, done);
let videoPlayer = null;
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);
......
......@@ -13,26 +13,25 @@
* limitations under the License.
*/
import resourceManager from '@ohos.resourceManager';
import router from '@system.router'
export async function getFileDescriptor(fileName) {
let fileDescriptor;
await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.getRawFileDescriptor(fileName).then(value => {
fileDescriptor = {fd: value.fd, offset: value.offset, length: value.length};
}).catch(error => {
console.log('case getRawFileDescriptor err: ' + error);
});
});
return fileDescriptor;
export async function toNewPage(page) {
let path = '';
if (page == 0) {
path = 'pages/surfaceTest/surfaceTest';
} else {
path = 'pages/surfaceTest/surfaceTest2';
}
let options = {
uri: path,
}
try {
await router.push(options);
} catch {
console.info('case route failed');
}
}
export async function closeFileDescriptor(fileName) {
await resourceManager.getResourceManager().then(async (mgr) => {
await mgr.closeRawFileDescriptor(fileName).then(value => {
console.log('case closeRawFileDescriptor ' + value);
}).catch(error => {
console.log('case closeRawFileDescriptor err: ' + error);
});
});
export async function clearRouter() {
await router.clear();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册