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

!2957 音视频播放:增加fd输入测试,公共函数提取

Merge pull request !2957 from NOBUGGERS/r0051460_0402
...@@ -15,11 +15,19 @@ ...@@ -15,11 +15,19 @@
"cleanup-apps": true "cleanup-apps": true
}, },
{ {
"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"
],
"teardown-command":[
]
},
{
"type": "PushKit", "type": "PushKit",
"pre-push": [ "pre-push": [
], ],
"push": [ "push": [
"./resource/audio/01.mp3 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/", "./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/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/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/04.mp3 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/",
...@@ -44,13 +52,6 @@ ...@@ -44,13 +52,6 @@
"./resource/audio/97.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/98.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/"
] ]
},
{
"type": "ShellKit",
"run-command": [
],
"teardown-command":[
]
} }
] ]
} }
...@@ -15,12 +15,14 @@ ...@@ -15,12 +15,14 @@
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import fileIO from '@ohos.fileio' import fileIO from '@ohos.fileio'
import {getFileDescriptor, closeFileDescriptor} from './PlayerLocalTestBase.js';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('PlayerLocalTestAudioFUNC', function () { describe('PlayerLocalTestAudioFUNC', function () {
let audioPlayer = media.createAudioPlayer(); let audioPlayer = media.createAudioPlayer();
let isTimeOut = false; let isTimeOut = false;
const AUDIO_SOURCE = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/01.mp3'; const AUDIO_SOURCE = '/data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioplayer/01.mp3';
const AUDIO_FILE = '01.mp3';
const PLAY_TIME = 3000; const PLAY_TIME = 3000;
const DURATION_TIME = 219600; const DURATION_TIME = 219600;
const SEEK_TIME = 5000; const SEEK_TIME = 5000;
...@@ -37,15 +39,20 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -37,15 +39,20 @@ describe('PlayerLocalTestAudioFUNC', function () {
const ERROR_STATE = 9; const ERROR_STATE = 9;
const FINISH_STATE = 10; const FINISH_STATE = 10;
const LOOP_STATE = 11; const LOOP_STATE = 11;
const FDSRC_STATE = 12;
const SECOND_INDEX = 1; const SECOND_INDEX = 1;
const RAND_NUM = 5; const RAND_NUM = 5;
const TIME_OUT = 40000; const TIME_OUT = 40000;
const MAX_VOLUME = 1; const MAX_VOLUME = 1;
let fdPath; let fdPath;
let fdValue; let fdValue;
let fileDescriptor;
beforeAll(async function() { beforeAll(async function() {
await getFd(); await getFd();
await getFileDescriptor(AUDIO_FILE).then((res) => {
fileDescriptor = res;
});
console.info('beforeAll case'); console.info('beforeAll case');
}) })
...@@ -60,6 +67,7 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -60,6 +67,7 @@ describe('PlayerLocalTestAudioFUNC', function () {
afterAll(async function() { afterAll(async function() {
await fileIO.close(fdValue); await fileIO.close(fdValue);
await closeFileDescriptor(AUDIO_FILE);
console.info('afterAll case'); console.info('afterAll case');
}) })
...@@ -103,6 +111,10 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -103,6 +111,10 @@ describe('PlayerLocalTestAudioFUNC', function () {
console.info(`case to prepare`); console.info(`case to prepare`);
audioPlayer.src = fdPath; audioPlayer.src = fdPath;
break; break;
case FDSRC_STATE:
console.info(`case to prepare`);
audioPlayer.fdSrc = fileDescriptor;
break;
case PLAY_STATE: case PLAY_STATE:
console.info(`case to play`); console.info(`case to play`);
audioPlayer.play(); audioPlayer.play();
...@@ -819,4 +831,142 @@ describe('PlayerLocalTestAudioFUNC', function () { ...@@ -819,4 +831,142 @@ describe('PlayerLocalTestAudioFUNC', function () {
setCallback(mySteps, done); setCallback(mySteps, done);
audioPlayer.src = fdPath; audioPlayer.src = fdPath;
}) })
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0100
* @tc.name : 001.play
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0100', 0, async function (done) {
console.info(`case update`);
let mySteps = new Array(SRC_STATE, PLAY_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.fdSrc = fileDescriptor;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0200
* @tc.name : 002.play->pause
* @tc.desc : Audio playback control test
* @tc.size : MediumTestTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0200', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, RESET_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.fdSrc = fileDescriptor;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0300
* @tc.name : 003.play->pause->play->reset
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0300', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.fdSrc = fileDescriptor;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0500
* @tc.name : 005.play->reset
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0500', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.fdSrc = fileDescriptor;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0600
* @tc.name : 006.play->pause->play->pause
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0600', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, PAUSE_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.fdSrc = fileDescriptor;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0700
* @tc.name : 007.play->pause->stop
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0700', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.fdSrc = fileDescriptor;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0800
* @tc.name : 008.play->pause->play->stop
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0800', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, PLAY_STATE, STOP_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.fdSrc = fileDescriptor;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0900
* @tc.name : 009.play->stop->reset->play->pause->play->reset
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_0900', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, STOP_STATE, RESET_STATE, SRC_STATE, PLAY_STATE,
PAUSE_STATE, PLAY_STATE, RESET_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.fdSrc = fileDescriptor;
})
/* *
* @tc.number : SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_1000
* @tc.name : 010.play->pause->stop->reset->play->pause->reset
* @tc.desc : Audio playback control test
* @tc.size : MediumTest
* @tc.type : Function test
* @tc.level : Level0
*/
it('SUB_MEDIA_PLAYER_LOCAL_AUDIO_FUNCTION_05_1000', 0, async function (done) {
let mySteps = new Array(SRC_STATE, PLAY_STATE, PAUSE_STATE, STOP_STATE, RESET_STATE, SRC_STATE, PLAY_STATE,
PAUSE_STATE, RESET_STATE, END_STATE);
initAudioPlayer();
setCallback(mySteps, done);
audioPlayer.fdSrc = fileDescriptor;
})
}) })
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import resourceManager from '@ohos.resourceManager';
export async function getFileDescriptor(fileName) {
let fileDescriptor;
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);
});
});
return fileDescriptor;
}
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);
});
});
}
...@@ -14,20 +14,21 @@ ...@@ -14,20 +14,21 @@
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
}, },
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/audio/H264_AAC.mp4 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videoplayer/"
]
},
{ {
"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"
], ],
"teardown-command":[ "teardown-command":[
] ]
},
{
"type": "PushKit",
"pre-push": [
],
"push": [
"./resource/audio/H264_AAC.mp4 ->/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/"
]
} }
] ]
} }
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
import media from '@ohos.multimedia.media' import media from '@ohos.multimedia.media'
import router from '@system.router' import router from '@system.router'
import fileIO from '@ohos.fileio' import {getFileDescriptor, closeFileDescriptor} from './VideoPlayerTestBase.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 () {
const AUDIO_SOURCE = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videoplayer/H264_AAC.mp4'; const VIDEO_SOURCE = 'H264_AAC.mp4';
const PLAY_TIME = 3000; const PLAY_TIME = 3000;
const SEEK_TIME = 5000; const SEEK_TIME = 5000;
const WIDTH_VALUE = 720; const WIDTH_VALUE = 720;
...@@ -29,7 +29,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -29,7 +29,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
const SETSURFACE_EVENT = 'setDisplaySurface'; const SETSURFACE_EVENT = 'setDisplaySurface';
const GETDESCRIPTION = 'getTrackDescription'; const GETDESCRIPTION = 'getTrackDescription';
const PREPARE_EVENT = 'prepare'; const PREPARE_EVENT = 'prepare';
const PREPARE2_EVENT = 'prepare2'; const SRC_PREPARE_EVENT = 'src2prepare';
const PLAY_EVENT = 'play'; const PLAY_EVENT = 'play';
const PAUSE_EVENT = 'pause'; const PAUSE_EVENT = 'pause';
const STOP_EVENT = 'stop'; const STOP_EVENT = 'stop';
...@@ -46,20 +46,20 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -46,20 +46,20 @@ 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 fdPath; let fileDescriptor;
let fdValue;
let temp = 0; let temp = 0;
let events = require('events'); let events = require('events');
let eventEmitter = new events.EventEmitter(); let eventEmitter = new events.EventEmitter();
beforeAll(function() { beforeAll(async function() {
console.info('beforeAll case'); console.info('beforeAll case');
await getFileDescriptor(VIDEO_SOURCE).then((res) => {
fileDescriptor = res;
});
}) })
beforeEach(async function() { beforeEach(async function() {
console.info('case flush surfaceID start');
await toNewPage(); await toNewPage();
console.info('case flush surfaceID end');
await msleep(1000).then(() => { await msleep(1000).then(() => {
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
console.info('beforeEach case'); console.info('beforeEach case');
...@@ -71,7 +71,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -71,7 +71,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
}) })
afterAll(async function() { afterAll(async function() {
await fileIO.close(fdValue); await closeFileDescriptor(VIDEO_SOURCE);
console.info('afterAll case'); console.info('afterAll case');
}) })
...@@ -112,19 +112,6 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -112,19 +112,6 @@ describe('VideoPlayerFuncCallbackTest', function () {
} }
} }
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 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}`);
...@@ -149,7 +136,6 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -149,7 +136,6 @@ describe('VideoPlayerFuncCallbackTest', function () {
eventEmitter.emit(steps[0], videoPlayer, steps, done); eventEmitter.emit(steps[0], videoPlayer, steps, done);
} }
} }
function setOnCallback(videoPlayer) { function setOnCallback(videoPlayer) {
videoPlayer.on('playbackCompleted', () => { videoPlayer.on('playbackCompleted', () => {
console.info('case playbackCompleted success'); console.info('case playbackCompleted success');
...@@ -190,7 +176,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -190,7 +176,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
eventEmitter.on(SETSURFACE_EVENT, (videoPlayer, steps, done) => { eventEmitter.on(SETSURFACE_EVENT, (videoPlayer, steps, done) => {
steps.shift(); steps.shift();
videoPlayer.url = fdPath; videoPlayer.fdSrc = fileDescriptor;
videoPlayer.setDisplaySurface(surfaceID, (err) => { videoPlayer.setDisplaySurface(surfaceID, (err) => {
if (typeof (err) == 'undefined') { if (typeof (err) == 'undefined') {
expect(videoPlayer.state).assertEqual('idle'); expect(videoPlayer.state).assertEqual('idle');
...@@ -218,9 +204,9 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -218,9 +204,9 @@ describe('VideoPlayerFuncCallbackTest', function () {
}); });
}); });
eventEmitter.on(PREPARE2_EVENT, (videoPlayer, steps, done) => { eventEmitter.on(SRC_PREPARE_EVENT, (videoPlayer, steps, done) => {
steps.shift(); steps.shift();
videoPlayer.url = fdPath; videoPlayer.fdSrc = fileDescriptor;
videoPlayer.prepare((err) => { videoPlayer.prepare((err) => {
if (typeof (err) == 'undefined') { if (typeof (err) == 'undefined') {
expect(videoPlayer.state).assertEqual('prepared'); expect(videoPlayer.state).assertEqual('prepared');
...@@ -446,7 +432,6 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -446,7 +432,6 @@ 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) {
await getFd();
surfaceID = globalThis.value; surfaceID = globalThis.value;
console.info('case new surfaceID is ' + surfaceID); console.info('case new surfaceID is ' + surfaceID);
let videoPlayer = null; let videoPlayer = null;
...@@ -742,7 +727,7 @@ describe('VideoPlayerFuncCallbackTest', function () { ...@@ -742,7 +727,7 @@ describe('VideoPlayerFuncCallbackTest', function () {
console.info('case new surfaceID is ' + surfaceID); 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, PREPARE2_EVENT, STOP_EVENT, RESET_EVENT, SRC_PREPARE_EVENT,
PLAY_EVENT, RELEASE_EVENT, END_EVENT); PLAY_EVENT, RELEASE_EVENT, END_EVENT);
eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done); eventEmitter.emit(mySteps[0], videoPlayer, mySteps, done);
}) })
......
...@@ -19,10 +19,9 @@ import fileIO from '@ohos.fileio' ...@@ -19,10 +19,9 @@ import fileIO from '@ohos.fileio'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('VideoPlayerFuncPromiseTest', function () { describe('VideoPlayerFuncPromiseTest', function () {
const AUDIO_SOURCE = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videoplayer/H264_AAC.mp4'; const VIDEO_SOURCE = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videoplayer/H264_AAC.mp4';
const PLAY_TIME = 3000; const PLAY_TIME = 3000;
const SEEK_TIME = 5000; const SEEK_TIME = 5000;
const SEEK_CLOSEST = 3;
const WIDTH_VALUE = 720; const WIDTH_VALUE = 720;
const HEIGHT_VALUE = 480; const HEIGHT_VALUE = 480;
const DURATION_TIME = 10034; const DURATION_TIME = 10034;
...@@ -38,9 +37,7 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -38,9 +37,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
}) })
beforeEach(async function() { beforeEach(async function() {
console.info('case flush surfaceID start');
await toNewPage(); await toNewPage();
console.info('case flush surfaceID end');
await msleep(1000).then(() => { await msleep(1000).then(() => {
}, failureCallback).catch(catchCallback); }, failureCallback).catch(catchCallback);
console.info('beforeEach case'); console.info('beforeEach case');
...@@ -95,7 +92,7 @@ describe('VideoPlayerFuncPromiseTest', function () { ...@@ -95,7 +92,7 @@ describe('VideoPlayerFuncPromiseTest', function () {
async function getFd() { async function getFd() {
fdPath = 'fd://'; fdPath = 'fd://';
await fileIO.open(AUDIO_SOURCE).then((fdNumber) => { await fileIO.open(VIDEO_SOURCE).then((fdNumber) => {
fdPath = fdPath + '' + fdNumber; fdPath = fdPath + '' + fdNumber;
fdValue = fdNumber; fdValue = fdNumber;
console.info('[fileIO]case open fd success,fdPath is ' + fdPath); console.info('[fileIO]case open fd success,fdPath is ' + fdPath);
......
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import resourceManager from '@ohos.resourceManager';
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 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);
});
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册